<?php /** * Endpoint Manager Install File * * @author Andrew Nagy * @license MPL / GPLv2 / LGPL * @package Provisioner */ require 'functions.inc'; $endpoint = new endpointmanager(); function out($text) { echo $text . "<br />"; } if ($_REQUEST['type'] == "brand") { $endpoint->update_brand($_REQUEST['id']); } elseif ($_REQUEST['type'] == "js-multiple") { $list = explode(",", $_REQUEST['id']); sort($list, SORT_STRING); foreach ($list as $data) { } } elseif ($_REQUEST['type'] == "firmware") { $endpoint->install_firmware($data['id']); } elseif ($_REQUEST['type'] == "manual_install") { switch ($_REQUEST['install_type']) { case "upload_master_xml": if (file_exists(PHONE_MODULES_PATH . "temp/master.xml")) { $handle = fopen(PHONE_MODULES_PATH . "temp/master.xml", "rb"); $contents = stream_get_contents($handle); fclose($handle);
<?php /** * Ajax Select File * * @author Andrew Nagy * @license MPL / GPLv2 / LGPL * @package Provisioner */ require 'functions.inc'; $endpoint = new endpointmanager(); include 'jsonwrapper.php'; function in_array_recursive($needle, $haystack) { $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($haystack)); foreach ($it as $element) { if ($element == $needle) { return TRUE; } } return FALSE; } if ($_REQUEST['id'] == "" or $_REQUEST['id'] == "0") { $out[0]['optionValue'] = ""; $out[0]['optionDisplay'] = ""; echo json_encode($out); die; } if ($_REQUEST['atype'] == "model") { $sql = "SELECT * FROM endpointman_model_list WHERE enabled = 1 AND brand =" . $_GET['id']; } elseif ($_REQUEST['atype'] == "template") {
<?php require '/etc/freepbx.conf'; require '/var/www/html/admin/modules/endpointman/includes/functions.inc'; $endpoint = new endpointmanager(); if (!isset($endpoint->global_cfg['server_type']) or $endpoint->global_cfg['server_type'] != 'http') { header('HTTP/1.1 403 Forbidden'); die; } if (isset($_SERVER["PATH_INFO"]) && $_SERVER["PATH_INFO"] != '/' && !empty($_SERVER["PATH_INFO"])) { $requested_file = substr($_SERVER["PATH_INFO"], 1); } elseif (isset($_REQUEST['request'])) { $requested_file = $_REQUEST['request']; } $path_parts = explode(".", $requested_file); $path_parts2 = explode("_", $path_parts[0]); $mac = $path_parts2[0]; define("PHONE_MODULES_DIR", "/var/www/html/admin/modules/_ep_phone_modules/"); require PHONE_MODULES_DIR . "servers/http_server.php"; $http_provisioner = new provisioner_http(); $http_provisioner->get($requested_file); $http_provisioner->provisioner_path = PHONE_MODULES_DIR; if (isset($http_provisioner->mac_address)) { $sql = 'SELECT id FROM `endpointman_mac_list` WHERE `mac` LIKE CONVERT(_utf8 \'%' . $http_provisioner->mac_address . '%\' USING latin1) COLLATE latin1_swedish_ci'; $mac_id = $endpoint->db->getOne($sql); $phone_info = $endpoint->get_phone_info($mac_id); if ($http_provisioner->load_provisioner($phone_info['directory'], $phone_info['cfg_dir'])) { //Determine if global settings have been overridden $settings = ''; if ($phone_info['template_id'] > 0) { if (isset($phone_info['template_data_info']['global_settings_override'])) {
function endpointman_configpageinit($pagename) { global $currentcomponent, $amp_conf, $db; $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null; $type = ''; $tech = ''; $extdisplay = ''; if ($display == "extensions") { if (isset($_REQUEST['extension'])) { $extdisplay = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null; } else { $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null; } } elseif ($display == "devices") { if (isset($_REQUEST['deviceid'])) { $extdisplay = isset($_REQUEST['deviceid']) ? $_REQUEST['deviceid'] : null; } else { $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null; } } else { // we only care about extensions or devices, otherwise return return true; } if (isset($extdisplay) && !empty($extdisplay)) { $sql = "SELECT tech FROM devices WHERE id = " . $extdisplay; $tech = $db->getOne($sql); if (!$tech) { $tech = "sip"; $type = 'new'; } elseif ($tech == 'sip') { $type = 'edit'; $tech = 'sip'; } } elseif (isset($_REQUEST['tech_hardware']) or isset($_REQUEST['tech'])) { $tech = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : $_REQUEST['tech']; if ($tech == 'sip_generic' or $tech == 'sip') { $tech = "sip"; $type = 'new'; } } if ($tech == 'sip' and !empty($type)) { global $endpoint; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $delete = isset($_REQUEST['epm_delete']) ? $_REQUEST['epm_delete'] : null; $doc_root = $amp_conf['AMPWEBROOT'] . "/admin/modules/endpointman/"; if (file_exists($doc_root . "includes/functions.inc")) { require $doc_root . "includes/functions.inc"; $endpoint = new endpointmanager(); ini_set('display_errors', 0); if ($action == "del") { $sql = "SELECT mac_id,luid FROM endpointman_line_list WHERE ext = " . $extdisplay; $macid = $endpoint->eda->sql($sql, 'getRow', DB_FETCHMODE_ASSOC); if ($macid) { $endpoint->delete_line($macid['luid'], TRUE); } } if ($action == "edit" or $action == "add") { if (isset($delete)) { $sql = "SELECT mac_id,luid FROM endpointman_line_list WHERE ext = " . $extdisplay; $macid = $endpoint->eda->sql($sql, 'getRow', DB_FETCHMODE_ASSOC); if ($macid) { $endpoint->delete_line($macid['luid'], TRUE); } } $mac = isset($_REQUEST['epm_mac']) ? $_REQUEST['epm_mac'] : null; if (!empty($mac)) { //Mac is set $brand = isset($_REQUEST['epm_brand']) ? $_REQUEST['epm_brand'] : null; $model = isset($_REQUEST['epm_model']) ? $_REQUEST['epm_model'] : null; $line = isset($_REQUEST['epm_line']) ? $_REQUEST['epm_line'] : null; $temp = isset($_REQUEST['epm_temps']) ? $_REQUEST['epm_temps'] : null; if (isset($_REQUEST['name'])) { $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : null; } else { $name = isset($_REQUEST['description']) ? $_REQUEST['description'] : null; } if (isset($_REQUEST['deviceid'])) { if ($_REQUEST['devicetype'] == "fixed") { //SQL to get the Description of the extension from the extension table $sql = "SELECT name FROM users WHERE extension = '" . $_REQUEST['deviceuser'] . "'"; $name_o = $endpoint->eda->sql($sql, 'getOne'); if ($name_o) { $name = $name_o; } } } $reboot = isset($_REQUEST['epm_reboot']) ? $_REQUEST['epm_reboot'] : null; if ($endpoint->mac_check_clean($mac)) { $sql = "SELECT id FROM endpointman_mac_list WHERE mac = '" . $endpoint->mac_check_clean($mac) . "'"; $macid = $endpoint->eda->sql($sql, 'getOne'); if ($macid) { //In Database already $sql = 'SELECT * FROM endpointman_line_list WHERE ext = ' . $extdisplay . ' AND mac_id = ' . $macid; $lines_list =& $endpoint->eda->sql($sql, 'getRow', DB_FETCHMODE_ASSOC); if ($lines_list and isset($model) and isset($line) and !isset($delete) and isset($temp)) { //Modifying line already in the database $endpoint->update_device($macid, $model, $temp, $lines_list['luid'], $name, $lines_list['line']); $row = $endpoint->get_phone_info($macid); if (isset($reboot)) { $endpoint->prepare_configs($row); } else { $endpoint->prepare_configs($row, FALSE); } } elseif (isset($model) and !isset($delete) and isset($line) and isset($temp)) { //Add line to the database if (empty($line)) { $endpoint->add_line($macid, NULL, $extdisplay, $name); } else { $endpoint->add_line($macid, $line, $extdisplay, $name); } $endpoint->update_device($macid, $model, $temp, NULL, NULL, NULL, FALSE); $row = $endpoint->get_phone_info($macid); if (isset($reboot)) { $endpoint->prepare_configs($row); } else { $endpoint->prepare_configs($row, FALSE); } } } elseif (!isset($delete)) { //Add Extension/Phone to database $mac_id = $endpoint->add_device($mac, $model, $extdisplay, $temp, NULL, $name); if ($mac_id) { debug('Write files?'); $row = $endpoint->get_phone_info($mac_id); $endpoint->prepare_configs($row); } } } } } endpointman_applyhooks(); } else { //System can't find the include file. } } }
of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ require dirname($_SERVER["SCRIPT_FILENAME"]) . "/modules/endpointman/includes/functions.inc"; global $endpoint; $endpoint = new endpointmanager(); global $db; if (!function_exists("out")) { function out($text) { echo $text . "<br />"; } } if (!function_exists("outn")) { function outn($text) { echo $text; } } out("Removing Phone Modules Directory"); $endpoint->deltree(PHONE_MODULES_PATH);
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require 'functions.inc'; $endpoint = new endpointmanager(); if ($_REQUEST['pop_type'] == 'edit_specifics') { $info = $endpoint->get_phone_info($_REQUEST['edit_id']); if (isset($_REQUEST['button_save'])) { $endpoint->message['advanced_settings'] = "Updated!"; foreach ($info['line'] as $data) { $line = $data['line']; $final['displayname_' . $line] = $_REQUEST['displayname_' . $line]; } $sql = "UPDATE endpointman_mac_list SET specific_settings = '" . serialize($final) . "' WHERE id =" . $_REQUEST['edit_id']; $endpoint->db->query($sql); } $info = $endpoint->get_phone_info($_REQUEST['edit_id']); $specific_settings = !empty($info['specific_settings']) ? unserialize($info['specific_settings']) : array(); $z = 0; foreach ($info['line'] as $data) { $line = $data['line']; $displayname[$z]['displayname'] = isset($specific_settings['displayname_' . $line]) ? $specific_settings['displayname_' . $line] : '{$displayname.line.' . $line . '}'; $displayname[$z]['line'] = $line; $z++; } $endpoint->prepare_message_box(); $endpoint->tpl->assign("display_name", $displayname); echo $endpoint->tpl->draw('specifics_pop');
<?php $bootstrap_settings['freepbx_auth'] = false; if (!@(include_once getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { include_once '/etc/asterisk/freepbx.conf'; } define('PROVISIONER_BASE', $amp_conf['AMPWEBROOT'] . '/admin/modules/_ep_phone_modules/'); require $amp_conf['AMPWEBROOT'] . '/admin/modules/endpointman/includes/functions.inc'; require $amp_conf['AMPWEBROOT'] . '/admin/modules/endpointman/includes/timezone.inc'; $endpoint = new endpointmanager(); //Check if it's allowed in FreePBX through Endpoint Manager first if (!isset($endpoint->global_cfg['server_type']) or $endpoint->global_cfg['server_type'] != 'http') { header('HTTP/1.1 403 Forbidden'); die; } $provis_ip = $endpoint->global_cfg['srvip']; if (getMethod() == 'PUT' or getMethod() == 'POST') { //write log files or other files to drive. not sussed out yet completely. /* PUT data comes in on the stdin stream */ //$putdata = fopen("php://input", "r"); /* Open a file for writing */ //$fp = fopen($endpoint->global_cfg['config_location'] . $_SERVER['REDIRECT_URL'], "a"); /* Read the data 1 KB at a time and write to the file */ //while ($data = fread($putdata, 1024)) // fwrite($fp, $data); /* Close the streams */ //fclose($fp); //fclose($putdata); header('HTTP/1.1 200 OK'); die;
<?php /** * Endpoint Manager Uninstaller * * @author Andrew Nagy * @license MPL / GPLv2 / LGPL * @package Endpoint Manager */ require dirname($_SERVER["SCRIPT_FILENAME"]) . "/modules/endpointman/includes/functions.inc"; global $endpoint; $endpoint = new endpointmanager(); global $db; if (!function_exists("out")) { function out($text) { echo $text . "<br />"; } } if (!function_exists("outn")) { function outn($text) { echo $text; } } out("Removing Phone Modules Directory"); $endpoint->rmrf(PHONE_MODULES_PATH); exec("rm -R " . PHONE_MODULES_PATH); out("Dropping all relevant tables"); $sql = "DROP TABLE `endpointman_brand_list`"; $result = $db->query($sql);
<?php /** * Endpoint Manager Install File * * @author Andrew Nagy * @license MPL / GPLv2 / LGPL * @package Provisioner */ require 'functions.inc'; $endpoint = new endpointmanager(); echo "<html><head><title>Installer</title></head><body>"; if (!function_exists("out")) { function out($text) { echo $text . "<br />"; } } if ($_REQUEST['type'] == "brand") { $endpoint->download_brand($_REQUEST['id']); } elseif ($_REQUEST['type'] == "js-multiple") { $list = explode(",", $_REQUEST['id']); sort($list, SORT_STRING); foreach ($list as $data) { } } elseif ($_REQUEST['type'] == "firmware") { $endpoint->install_firmware($_REQUEST['id']); } elseif ($_REQUEST['type'] == "manual_install") { switch ($_REQUEST['install_type']) { case "export_brand": $sql = 'SELECT `name`, `directory` FROM `endpointman_brand_list` WHERE `id` = ' . $_REQUEST['package'] . '';