2600hz/bluebox — Issue #29: Endpoint Manager 1.2 issue with Grandstream config requests
Author: moefan
Created: 2012-01-29 17:21:27+00:00
State: open

Grandstream devices request config files as "cfg" but nothing is returned on request. I can manually download config file by entering http:///bluebox/index.php/endpointmanager/config/.cfg but not using http:///bluebox/index.php/endpointmanager/config/cfg or even http:///bluebox/index.php/endpointmanager/config/cfg.cfg.

I have tried debugging and determined that the wrong array key (ie file name) is being set somewhere originating from the generate_all_files() function in ./libraries/endpoint/base.php but I'm new to PHP so having a hard time tracing.

In the meantime I've made sloppy fix to ./controllers/endpointmanager.php by replacing

$rd = $provisioner_lib->generate_all_files();
if(array_key_exists($file, $rd)) {
print $rd[$file];
} else {
header("HTTP/1.0 404 Not Found");
die();
}
exit;

with

$rd = $provisioner_lib->generate_all_files();
if (preg_match('/cfg[0-9A-Fa-f]{12}/i', $file)) {
$tempfile = preg_replace('/^' . 'cfg' . '/', '', $file) . '.cfg';
} else {
$tempfile = $file;
}
if(array_key_exists($tempfile, $rd)) {
print $rd[$tempfile];
} else {
header("HTTP/1.0 404 Not Found");
die();
}
exit;