header("HTTP/1.0 500 Internal Server Error", true, 500); echo "<h1>" . _("Error 500 Internal Server Error") . "</h1>"; echo _("System Failure!"); die; } if (array_key_exists($filename, $files)) { echo $files[$filename]; } else { header("HTTP/1.0 404 Not Found", true, 404); echo "<h1>" . _("Error 404 Not Found") . "</h1>"; echo _("File not Found!"); die; } } else { require_once PROVISIONER_BASE . 'endpoint/base.php'; $data = Provisioner_Globals::dynamic_global_files($filename, FreePBX::Endpointman()->configmod->get("config_location"), $web_path); if ($data !== FALSE) { echo $data; } else { header("HTTP/1.0 404 Not Found", true, 404); echo "<h1>" . _("Error 404 Not Found") . "</h1>"; echo _("File not Found!"); die; } } } else { header('HTTP/1.1 403 Forbidden', true, 403); echo "<h1>" . _("Error 403 Forbidden") . "</h1>"; echo _("Access denied!"); die; }
public function config() { $use_regex = false; if (array_key_exists('file', $_REQUEST)) { $file = $_REQUEST['file']; } else { $file = implode(DIRECTORY_SEPARATOR, func_get_args()); } if (empty($file)) { echo "Endpoint Manager works!"; exit; } if (!file_exists(dirname(dirname(__FILE__)) . '/libraries/endpoint/base.php')) { header('HTTP/1.1 500 Internal Server Error'); exit; } require_once dirname(dirname(__FILE__)) . '/libraries/endpoint/base.php'; $data = Provisioner_Globals::dynamic_global_files($file, dirname(dirname(__FILE__)) . '/firmwares/', $this->siteURL() . Kohana::config('core.site_domain') . Kohana::config('core.index_page') . '/endpointmanager/config/'); if ($data !== FALSE) { print $data; exit; } if ($use_regex) { $configfileinfo = $this->_identify_configfile_regex($file); } else { $configfileinfo = $this->_identify_configfile($file); } $class = "endpoint_" . $configfileinfo["details"]["brand"] . "_" . $configfileinfo["details"]["family"] . '_phone'; $provisioner_lib = new $class(); $defaults = $this->_get_defaults(); $provisioner_lib->DateTimeZone = new DateTimeZone($defaults['global']['timezone']); $provisioner_lib->brand_name = $configfileinfo['endpoint']["brand"]; $provisioner_lib->family_line = $this->_findfamily($configfileinfo['endpoint']['brand'], $configfileinfo['endpoint']["model"]); $provisioner_lib->model = $configfileinfo['endpoint']["model"]; $provisioner_lib->mac = $configfileinfo["endpoint"]["mac"]; $provisioner_lib->settings = array_merge_recursive($defaults['global'], $provisioner_lib->settings); if (array_key_exists($provisioner_lib->brand_name, $defaults)) { $provisioner_lib->settings = array_merge_recursive($defaults[$provisioner_lib->brand_name], $provisioner_lib->settings); } if (array_key_exists('firmware', $provisioner_lib->settings) && is_array($provisioner_lib->settings['firmware'])) { foreach ($provisioner_lib->settings['firmware'] as $key => $value) { if (in_array($provisioner_lib->model, explode("/", $key))) { $provisioner_lib->settings['firmware'] = $provisioner_lib->settings['firmware'][$provisioner_lib->model]; } } if (is_array($provisioner_lib->settings['firmware'])) { $provisioner_lib->settings['firmware'] = ''; } } $lineinfo = unserialize($configfileinfo['endpoint']['lines']); if ($lineinfo === false) { $lineinfo = array(); } $lines = array(); $provisioner_lib->settings["line"] = array(); for ($index = 0; $index < $configfileinfo['linecount']; $index++) { if (!array_key_exists($index, $lineinfo) or empty($lineinfo[$index]['sip'])) { } else { $device = Doctrine::getTable('Device')->find($lineinfo[$index]['sip']); if ($defaults['global']['linedisplay'] == 'extension') { $displayname = $device['plugins']['sip']['username']; } elseif (isset($device['plugins']['callerid']['internal_name'])) { $displayname = $device['plugins']['callerid']['internal_name']; } elseif (isset($device['plugins']['callerid']['external_name'])) { $displayname = $device['plugins']['callerid']['external_name']; } else { $displayname = $device['plugins']['sip']['username']; } $provisioner_lib->settings['line'][] = array("line" => $index, "username" => $device['plugins']['sip']['username'], "authname" => $device['plugins']['sip']['username'], 'displayname' => $displayname, 'secret' => $device['plugins']['sip']['password'], 'subscribe_mwi' => 1, 'server_host' => $device['User']['Location']['domain'], 'server_port' => 5060, 'server_expires' => 3600, 'backup_server_host' => '', 'backup_server_port' => 5060); } } $settings = unserialize($configfileinfo['endpoint']->settings); if (!is_array($settings)) { $settings = array(); } if ($provisioner_lib->brand_name == "snom" && array_key_exists("buttons", $settings)) { foreach ($settings["buttons"] as $index => $button) { if ($button["type"] == 'none') { // do nothing! } elseif ($button["type"] == 'sipaccount') { if (isset($provisioner_lib->settings['line'][$button["sipaccount"] - 1])) { $displayname = $provisioner_lib->settings['line'][$button["sipaccount"] - 1]["displayname"]; } else { $displayname = "?"; } $provisioner_lib->settings["loops"]["functionkey"][$index] = array("type" => "line", "label" => $displayname, "context" => "active", "value" => ""); } elseif ($button["type"] == "keyevent") { $provisioner_lib->settings["loops"]["functionkey"][$index] = array("type" => "keyevent", "label" => $this->keyevents[$button["keyevent"]], "context" => "active", "value" => $button["keyevent"]); } elseif ($button["type"] == "blf") { $dev = Doctrine::getTable('Device')->findOneBy('device_id', $button["blf"]); if (isset($dev->plugins["callerid"]["internal_name"])) { $displayname = $dev->plugins["callerid"]["internal_name"]; } else { $displayname = $dev->name; } $provisioner_lib->settings["loops"]["functionkey"][$index] = array("type" => "blf", "label" => $displayname, "context" => "active", "value" => "<sip:" . $dev->plugins["sip"]["username"] . '@' . $device['User']['Location']['domain'] . ">|*22"); } elseif ($button["type"] == "speeddial") { $sd = Doctrine::getTable("ExternalXfer")->findOneBy('external_xfer_id', $button["speeddial"]); $provisioner_lib->settings["loops"]["functionkey"][$index] = array("type" => "dest", "label" => $sd->name, "context" => "active", "value" => $sd->Number[0]["number"] . '@' . $device['User']['Location']['domain']); } elseif ($button["type"] == "internal_dial") { $provisioner_lib->settings["loops"]["functionkey"][$index] = array("type" => "dest", "label" => $button["internal_dial_label"], "context" => "active", "value" => $button["internal_dial"] . '@' . $device['User']['Location']['domain']); } elseif ($button["type"] == "external_dial") { $provisioner_lib->settings["loops"]["functionkey"][$index] = array("type" => "dest", "label" => $button["external_dial_label"], "context" => "active", "value" => "1" . $button["external_dial"] . '@' . $device['User']['Location']['domain']); } else { $provisioner_lib->settings["loops"]["functionkey"][$index] = array("type" => "bob", "label" => "bob", "context" => "active", "value" => "val"); print_r($button); } } } $provisioner_lib->root_dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "libraries" . DIRECTORY_SEPARATOR; $provisioner_lib->processor_info = 'Endpoint Manager 1.3 for Blue.Box'; if ($use_regex) { header("content-type: text/plain"); $provisioner_lib->prepare_for_generateconfig(); print $provisioner_lib->generate_file($file, $configfileinfo['possibility']['file']); exit; } else { $rd = $provisioner_lib->generate_all_files(); if (array_key_exists($file, $rd)) { header("content-type: text/plain"); print $rd[$file]; } else { header("HTTP/1.0 404 Not Found"); print "File {$file} not found\n"; die; } } exit; }
$mac_id = $endpoint->eda->sql($sql, 'getOne'); $phone_info = $endpoint->get_phone_info($mac_id); $files = $endpoint->prepare_configs($phone_info, FALSE, FALSE); if (!$files) { header("HTTP/1.0 500 Internal Server Error"); die; } if (array_key_exists($filename, $files)) { echo $files[$filename]; } else { header("HTTP/1.0 404 Not Found"); die; } } else { require_once PROVISIONER_BASE . 'endpoint/base.php'; $data = Provisioner_Globals::dynamic_global_files($filename, $endpoint->global_cfg['config_location'], $web_path); if ($data !== FALSE) { echo $data; } else { header("HTTP/1.0 404 Not Found"); } } } else { header('HTTP/1.1 403 Forbidden'); die; } function getMethod() { $method = $_SERVER['REQUEST_METHOD']; $override = isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']) ? $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] : (isset($_GET['method']) ? $_GET['method'] : ''); if ($method == 'POST' && strtoupper($override) == 'PUT') {