示例#1
0
    $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'])) {
                $settings = unserialize($phone_info['template_data_info']['global_settings_override']);
            } else {
                $settings['srvip'] = $endpoint->global_cfg['srvip'];
                $settings['ntp'] = $endpoint->global_cfg['ntp'];
                $settings['config_location'] = $endpoint->global_cfg['config_location'];
                $settings['tz'] = $endpoint->global_cfg['tz'];
            }
        } else {
            if (isset($phone_info['global_settings_override'])) {
                $settings = unserialize($phone_info['global_settings_override']);
示例#2
0
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.
        }
    }
}
示例#3
0
<?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');