From de0a07562f7f1e40697d1f85e66ad9b90e9a9107 Mon Sep 17 00:00:00 2001 From: Diederik de Groot Date: Thu, 9 Apr 2020 09:25:43 +0000 Subject: [PATCH] Ran: .......................................... 42 / 42 (100%) No fixable errors were found Time: 10.05 secs; Memory: 41.75MB Signed-off-by: Diederik de Groot --- Sccp_manager.class.php | 386 +++++++----- Sccp_manager.inc/aminterface/Event.class.php | 116 ++-- .../aminterface/Message.class.php | 182 +++--- .../aminterface/Response.class.php | 261 ++++---- .../aminterface/aminterface.class.php | 180 +++--- .../aminterface/oldinterface.class.php | 85 +-- Sccp_manager.inc/dbinterface.class.php | 90 +-- Sccp_manager.inc/extconfigs.class.php | 62 +- Sccp_manager.inc/sipconfigs.class.php | 46 +- Sccp_manager.inc/srvinterface.class.php | 75 ++- Sccp_manager.inc/xmlinterface.class.php | 81 +-- assets/css/sccp_manager.css | 2 +- assets/js/jquery.selectlistactions.js | 9 +- assets/js/sccp_manager.js | 92 +-- conf/Sccp.class.php | 325 +++++----- functions.inc.php | 41 +- install.php | 113 ++-- page.sccp_adv.php | 60 +- page.sccp_phone.php | 60 +- page.sccpsettings.php | 58 +- uninstall.php | 54 +- views/advserver.keyset.php | 87 ++- views/advserver.model.php | 6 +- views/form.adddevice.php | 34 +- views/form.addruser.php | 2 +- views/form.addsdevice.php | 34 +- views/form.buttons.php | 206 +++---- views/form.dptemplate.php | 18 +- views/form.sbuttons.php | 190 +++--- views/formShow.php | 568 +++++++++--------- views/hardware.extension.php | 2 +- views/hardware.phone.php | 2 +- views/hardware.rnav.php | 26 +- views/hardware.sphone.php | 2 +- views/server.advanced.php | 4 +- views/server.codec.php | 13 +- views/server.datetime.php | 6 +- views/server.device.php | 18 +- views/server.info.php | 118 ++-- views/server.setting.php | 16 +- 40 files changed, 2004 insertions(+), 1726 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 95612ec..d11029b 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1,8 +1,8 @@ - * + Dial Templates + Configuration + * + Dial Templates + Configuration * + Dial Templates in Global Configuration ( Enabled / Disabled ; default template ) * ? Dial Templates - Howto IT Include in XML.Config ??????? * + Dial Templates - SIP Device @@ -32,7 +32,7 @@ * + Change Installer ?? (test ) * + Installer Realtime config update * + Installer Adaptive DB reconfig. - * + Add system info page + * + Add system info page * + Change Cisco Language data * + Make DB Acces from separate class * + Make System Acces from separate class @@ -41,26 +41,26 @@ * + Add Switch to select XML schema (display) * + SRST Config * + secondary_dialtone_digits = "" line config - * + secondary_dialtone_tone = 0x22 line config + * + secondary_dialtone_tone = 0x22 line config * - deviceSecurityMode http://usecallmanager.nz//itl-file-tlv.html * - transportLayerProtocol http://usecallmanager.nz//itl-file-tlv.html - * - Check Time zone .... + * - Check Time zone .... * - Failover config * + Auto Addons! * + DND Mode * - support kv-store ????? - * + Shared Line + * + Shared Line * - bug Soft key set (empty keysets ) * - bug Fix ...(K no w bug? no fix) - * - restore default Value on page + * - restore default Value on page * - restore default Value on sccp.class * - 'Device SEP ID.[XXXXXXXXXXXX]=MAC' - * + ATA's start with ATAXXXXXXXXXXXX. + * + ATA's start with ATAXXXXXXXXXXXX. * + Create ATADefault.cnf.xml * - Create Second line Use MAC AABBCCDDEEFF rotation MAC BBCCDDEEFF01 (ATA 187 ) * + Add SEP, ATA, VG prefix. * + Add Cisco SIP device Tftp config. - * - VG248 ports start with VGXXXXXXXXXXXX0. + * - VG248 ports start with VGXXXXXXXXXXXX0. * * I think this file should be split in 3 parts (as in Model-View-Controller(MVC)) * * XML/Database Parts -> Model directory * * Processing parts -> Controller directory @@ -71,31 +71,32 @@ * + dir "templates" * + dir "firmware" * + dir "locales" - * + Create Simple User Interface + * + Create Simple User Interface * + sccpsimple.xml * + Add error information on the server information page (critical display error - the system can not work correctly) - * - Add Warning Information on Server Info Page - * - ADD Reload Line + * - Add Warning Information on Server Info Page + * - ADD Reload Line * - Add Call Map (show Current call Information) */ namespace FreePBX\modules; -class Sccp_manager extends \FreePBX_Helpers implements \BMO { +class Sccp_manager extends \FreePBX_Helpers implements \BMO +{ /* Field Values for type seq */ -// const General - sccp.conf = '0'; -// const General - sccp.conf[general] = '0'; -// const General - sccp.conf[%keyset%] = '5'; NAME space -// const General - sccp.conf[%keyset%] = '6'; data -// const General - default.xml = '10'; -// const General - templet.xml = '20'; -// const General - system_path = '2'; -// const General - don't store = '99'; -// private $SCCP_LANG_DICTIONARY = 'SCCP-dictionary.xml'; // CISCO LANG file search in /tftp-path - private $SCCP_LANG_DICTIONARY = 'be-sccp.jar'; // CISCO LANG file search in /tftp-path +// const General - sccp.conf = '0'; +// const General - sccp.conf[general] = '0'; +// const General - sccp.conf[%keyset%] = '5'; NAME space +// const General - sccp.conf[%keyset%] = '6'; data +// const General - default.xml = '10'; +// const General - templet.xml = '20'; +// const General - system_path = '2'; +// const General - don't store = '99'; +// private $SCCP_LANG_DICTIONARY = 'SCCP-dictionary.xml'; // CISCO LANG file search in /tftp-path + private $SCCP_LANG_DICTIONARY = 'be-sccp.jar'; // CISCO LANG file search in /tftp-path private $pagedata = null; - private $sccp_driver_ver = '11.31'; // Ver fore SCCP.CLASS.PHP + private $sccp_driver_ver = '11.31'; // Ver fore SCCP.CLASS.PHP public $sccp_manager_ver = '14.0.0.2'; private $tftpLang = array(); // private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! @@ -111,7 +112,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public $class_error; //error construct public $info_warning; - public function __construct($freepbx = null) { + public function __construct($freepbx = null) + { if ($freepbx == null) { throw new Exception("Not given a FreePBX Object"); } @@ -141,7 +143,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return; } - $this->getSccpSettingFromDB(); // Overwrite Exist + $this->getSccpSettingFromDB(); // Overwrite Exist // $this->getSccpSetingINI(false); // get from sccep.ini $this->init_sccp_path(); $this->initVarfromDefs(); @@ -152,7 +154,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->sccpvalues['sccp_compatible']['data'] = $this->sccpvalues['SccpDBmodel']['data']; } } - // Load Advanced Form Constructor Data + // Load Advanced Form Constructor Data if (empty($this->sccpvalues['displayconfig'])) { $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v' . $this->sccpvalues['sccp_compatible']['data']; } else { @@ -171,7 +173,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Generate Input elements in Html Code from sccpgeneral.xml */ - public function ShowGroup($grup_name, $heder_show, $form_prefix = 'sccp', $form_values = null) { + public function ShowGroup($grup_name, $heder_show, $form_prefix = 'sccp', $form_values = null) + { $htmlret = ""; if (empty($form_values)) { $form_values = $this->sccpvalues; @@ -181,8 +184,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $htmlret .= load_view(__DIR__ . '/views/formShow.php', array( 'itm' => $item, 'h_show' => $heder_show, 'form_prefix' => $form_prefix, 'fvalues' => $form_values, - 'tftp_lang' => $this->getTftpLang(), 'metainfo' => $this->sccp_metainfo) - ); + 'tftp_lang' => $this->getTftpLang(), 'metainfo' => $this->sccp_metainfo)); } } else { $htmlret .= load_view(__DIR__ . '/views/formShowError.php'); @@ -194,7 +196,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Load config vars from base array */ - public function initVarfromDefs() { + public function initVarfromDefs() + { foreach ($this->extconfigs->getextConfig('sccpDefaults') as $key => $value) { if (empty($this->sccpvalues[$key])) { $this->sccpvalues[$key] = array('keyword' => $key, 'data' => $value, 'type' => '0', 'seq' => '0'); @@ -206,7 +209,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Load config vars from xml */ - public function initVarfromXml() { + public function initVarfromXml() + { if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group') as $item) { foreach ($item->children() as $child) { @@ -215,7 +219,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $seq = (string) $child['seq']; } if ($seq < 99) { - if ($child['type'] == 'IE') { foreach ($child->xpath('input') as $value) { $tp = 0; @@ -224,8 +227,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } else { $datav = (string) $value->value; } - if (strtolower($value->type) == 'number') + if (strtolower($value->type) == 'number') { $tp = 1; + } if (empty($this->sccpvalues[(string) $value->name])) { $this->sccpvalues[(string) $value->name] = array('keyword' => (string) $value->name, 'data' => $datav, 'type' => $tp, 'seq' => $seq); // $this->sccpvalues[] = array('keyword' => (string)$value->name, 'data' =>(string)$value->default, 'type'=> '0'); @@ -262,35 +266,37 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /* unused */ - public function doConfigPageInit($page) { + public function doConfigPageInit($page) + { $this->doGeneralPost(); } /* unused */ - public function install() { - + public function install() + { } /* unused */ - public function uninstall() { - + public function uninstall() + { } /* unused */ - public function backup() { - + public function backup() + { } /* unused */ - public function restore($backup) { - + public function restore($backup) + { } - public function getActionBar($request) { + public function getActionBar($request) + { $buttons = array(); switch ($request['display']) { case 'sccp_adv': @@ -368,7 +374,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Show form information - General */ - public function myShowPage() { + public function myShowPage() + { $request = $_REQUEST; $action = !empty($request['action']) ? $request['action'] : ''; if ($this->sccpvalues['sccp_compatible']['data'] >= '433') { @@ -395,7 +402,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } if (empty($this->pagedata)) { -// $driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER'); +// $driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER'); $this->pagedata = array( "general" => array( "name" => _("General SCCP Settings"), @@ -434,7 +441,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->pagedata; } - public function InfoServerShowPage() { + public function InfoServerShowPage() + { $request = $_REQUEST; $action = !empty($request['action']) ? $request['action'] : ''; $this->pagedata = array( @@ -454,7 +462,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->pagedata; } - public function AdvServerShowPage() { + public function AdvServerShowPage() + { $request = $_REQUEST; $action = !empty($request['action']) ? $request['action'] : ''; $inputform = !empty($request['tech_hardware']) ? $request['tech_hardware'] : ''; @@ -500,7 +509,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->pagedata; } - public function PhoneShowPage() { + public function PhoneShowPage() + { $request = $_REQUEST; $action = !empty($request['action']) ? $request['action'] : ''; $inputform = !empty($request['tech_hardware']) ? $request['tech_hardware'] : ''; @@ -591,13 +601,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->pagedata; } - public function FormShowPage() { + public function FormShowPage() + { $request = $_REQUEST; $action = !empty($request['action']) ? $request['action'] : ''; if (empty($this->pagedata)) { -// $driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER'); +// $driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER'); $this->pagedata = array( "general" => array( @@ -622,13 +633,15 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->pagedata; } - public function getRightNav($request) { + public function getRightNav($request) + { if (isset($request['tech_hardware']) && ($request['tech_hardware'] == 'cisco')) { return load_view(__DIR__ . "/views/hardware.rnav.php", array('request' => $request)); } } - public function ajaxRequest($req, &$setting) { + public function ajaxRequest($req, &$setting) + { switch ($req) { case 'backupsettings': case 'savesettings': @@ -661,7 +674,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return false; } - public function ajaxHandler() { + public function ajaxHandler() + { $request = $_REQUEST; $msg = array(); $cmd_id = $request['command']; @@ -682,7 +696,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $msg [] = 'Config Saved: ' . $res['Response']; $msg [] = 'Info :' . $res['data']; // needreload(); -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => $msg, 'reload' => true); break; case 'save_sip_hardware': @@ -701,14 +715,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return array('status' => false, 'message' => print_r($res)); break; /* !TODO!: -TODO-: dialplan templates should be removed (only required for very old devices (like ATA) */ -// ------------------------------- Old + Sip deviece support - In the development--- +// ------------------------------- Old + Sip deviece support - In the development--- case 'save_dialplan_template': $res = $this->save_DialPlan($request); - //public + //public if (empty($res)) { return array('status' => true, 'search' => '?display=sccp_adv', 'hash' => 'sccpdialplan'); } else { -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => false, 'message' => print_r($res)); } break; @@ -716,14 +730,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!empty($request['dialplan'])) { $get_file = $request['dialplan']; $res = $this->del_DialPlan($get_file); -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => 'Dial Template has been deleted ! ', 'table_reload' => true); } else { -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => false, 'message' => print_r($res)); } break; -// ------------------------------- Old deviece support - In the development--- +// ------------------------------- Old deviece support - In the development--- case 'delete_hardware': if (!empty($request['idn'])) { foreach ($request['idn'] as $idv) { @@ -731,17 +745,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if ($this->strpos_array($idv, array('SEP', 'ATA', 'VG')) !== false) { $this->dbinterface->sccp_save_db('sccpdevice', array('name' => $idv), 'delete', "name"); $this->dbinterface->sccp_save_db("sccpbuttons", array(), 'delete', '', $idv); - $this->sccp_delete_device_XML($idv); // Концы в вводу !! + $this->sccp_delete_device_XML($idv); // Концы в вводу !! // $this->sccp_core_commands(array('cmd' => 'reload_phone', 'name' => $idv)); // $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv)); $this->srvinterface->sccp_device_reset($idv); } } -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'table_reload' => true, 'message' => 'HW is Delete ! '); } break; -// ------------- Create device tftp configuration +// ------------- Create device tftp configuration case 'create_hw_tftp': $ver_id = ' Test !'; if (!empty($request['idn'])) { @@ -762,12 +776,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $ver_id = $this->sccp_create_device_XML($data['name']); }; - if ($this->sccpvalues['siptftp']['data'] == 'on') { // Check SIP Support Enabled + if ($this->sccpvalues['siptftp']['data'] == 'on') { // Check SIP Support Enabled $this->sccp_create_xmlSoftkey(); // Create Softkey Sets for SIP } -// !TODO!: -TODO-: Do these returned message strings work with i18n ? -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: -TODO-: Do these returned message strings work with i18n ? +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => 'Create new config files (version:' . $ver_id . ')'); break; @@ -814,7 +828,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => $msgr, 'reload' => true); // return array('status' => true, 'message' => 'Reset command send
' . $msg, 'reload' => true); // } @@ -829,13 +843,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $hw_list[] = array('name' => $idv); } if ($idv == 'all') { - } } } $res = $this->sccp_db_update_butons($hw_list); $msg .= $res['Response'] . ' raw: ' . $res['data'] . ' '; -// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) return array('status' => true, 'message' => 'Update Butons Labels Complite ' . $msg, 'reload' => true); case 'model_add': @@ -887,7 +900,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'all': case 'extension': case 'enabled': - $devices = $this->getSccp_model_information($request['type'], $validate = TRUE); + $devices = $this->getSccp_model_information($request['type'], $validate = true); break; } if (empty($devices)) { @@ -919,7 +932,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } $this->sccp_create_sccp_init(); -// !TODO!: -TODO-: Check SIP Support Enabled +// !TODO!: -TODO-: Check SIP Support Enabled $this->sccp_create_xmlSoftkey(); $msg = print_r($this->srvinterface->sccp_reload(), 1); // $msg = print_r($this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')), 1); @@ -968,7 +981,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - * + * */ return $result; break; @@ -1000,7 +1013,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } if (!empty($staus)) { -// Array ( [name] => SEP0004F2EDCBFD [mac] => SEP0004F2EDCBFD [type] => 7937 [button] => line,7818,default ) +// Array ( [name] => SEP0004F2EDCBFD [mac] => SEP0004F2EDCBFD [type] => 7937 [button] => line,7818,default ) foreach ($staus as $dev_ids) { $id_name = $dev_ids['name']; if (empty($dev_ids['news'])) { @@ -1021,7 +1034,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } return $result; break; -// ------------------------------- Old deviece support - In the development--- +// ------------------------------- Old deviece support - In the development--- case 'getDialTemplate': $result = $this->get_DialPlanList(); if (empty($result)) { @@ -1029,7 +1042,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } return $result; break; -// ------------------------------- Old deviece support - In the development--- +// ------------------------------- Old deviece support - In the development--- case 'backupsettings': $filename = $this->sccp_create_sccp_backup(); $file_name = basename($filename); @@ -1047,19 +1060,22 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } - public function doGeneralPost() { + public function doGeneralPost() + { // $this->FreePBX->WriteConfig($config); - if (!isset($_REQUEST['Submit'])) + if (!isset($_REQUEST['Submit'])) { return; + } } /* - * + * * * Save Hardware Device Information to Db + ???? Create / update XML Profile - * + * */ - function get_buttons_phone($get_settings, $ref_id = '', $ref_type = 'sccpdevice') { + function get_buttons_phone($get_settings, $ref_id = '', $ref_type = 'sccpdevice') + { // Get Model Buttons info $res = array(); $def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'), @@ -1174,7 +1190,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $res; } - function save_hw_phone($get_settings, $validateonly = false) { + function save_hw_phone($get_settings, $validateonly = false) + { $hdr_prefix = 'sccp_hw_'; $hdr_arprefix = 'sccp_hw-ar_'; @@ -1225,9 +1242,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $i++; }; $value = implode(";", $save_codec); - } else - $value = 'all'; // Bug If not System Codecs -// } else $value = 'alaw;ulaw'; // Bug If not System Codecs + } else { + $value = 'all'; // Bug If not System Codecs + } +// } else $value = 'alaw;ulaw'; // Bug If not System Codecs break; case 'phonecodepage': $value = 'null'; @@ -1249,21 +1267,21 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // foreach ($get_settings[$hdr_arprefix . $key.'_sip'] as $vkey => $vval) { // } // break; -// - default : +// + default: if (!empty($get_settings[$hdr_prefix . $key])) { $value = $get_settings[$hdr_prefix . $key]; } if (!empty($get_settings[$hdr_arprefix . $key])) { $arr_data = ''; - $arr_clear = FALSE; + $arr_clear = false; foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) { $tmp_data = ''; foreach ($vval as $vkey => $vval) { switch ($vkey) { case 'inherit': if ($vval == 'on') { - $arr_clear = TRUE; + $arr_clear = true; // Злобный ХАК if ($key == 'permit') { $save_settings['deny'] = 'NONE'; @@ -1301,7 +1319,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $save_settings[$key] = $value; } } -// Save / Updade Base +// Save / Updade Base $this->dbinterface->sccp_save_db("sccpdevice", $save_settings, 'replace'); // Get Model Buttons info @@ -1311,7 +1329,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // Sace Buttons config $this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, $update_hw, '', $name_dev); -// Create Device XML +// Create Device XML $this->sccp_create_device_XML($name_dev); if ($hw_id == 'new') { @@ -1325,7 +1343,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $save_settings; } - function save_submit($get_settings, $validateonly = false) { + function save_submit($get_settings, $validateonly = false) + { $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -1416,7 +1435,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $save_settings; } - function save_rouming_users($get_settings, $validateonly = false) { + function save_rouming_users($get_settings, $validateonly = false) + { $hdr_prefix = 'sccp_ru_'; $hdr_arprefix = 'sccp_ru-ar_'; @@ -1427,7 +1447,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'devstate' => array('name' => 'Coffee', 'value' => 'coffee'), 'monitor' => array('name' => 'Record Calls', 'value' => '') ); - * + * */ $name_dev = ''; $db_field = $this->dbinterface->get_db_SccpTableData("get_colums_sccpuser"); @@ -1450,20 +1470,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $value = $get_settings[$hdr_prefix . 'netlang'] . ':' . $get_settings[$hdr_prefix . 'devlang']; } break; - default : + default: if (!empty($get_settings[$hdr_prefix . $key])) { $value = $get_settings[$hdr_prefix . $key]; } if (!empty($get_settings[$hdr_arprefix . $key])) { $arr_data = ''; - $arr_clear = FALSE; + $arr_clear = false; foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) { $tmp_data = ''; foreach ($vval as $vkey => $vval) { switch ($vkey) { case 'inherit': if ($vval == 'on') { - $arr_clear = TRUE; + $arr_clear = true; // Злобный ХАК if ($key == 'permit') { $save_settings['deny'] = 'NONE'; @@ -1501,7 +1521,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $save_settings[$key] = $value; } } -// Save / Updade Base +// Save / Updade Base // return $save_settings; // $update_hw = ($hw_id == 'new') ? 'update' : 'clear'; @@ -1515,7 +1535,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $save_settings; } - public function getSccpSettingFromDB() { + public function getSccpSettingFromDB() + { $raw_data = $this->dbinterface->get_db_SccpSetting(); foreach ($raw_data as $var) { $this->sccpvalues[$var['keyword']] = array('keyword' => $var['keyword'], 'data' => $var['data'], 'seq' => $var['seq'], 'type' => $var['type']); @@ -1523,7 +1544,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return; } - public function getMyConfig($var = null, $id = "noid") { + public function getMyConfig($var = null, $id = "noid") + { // $final = false; switch ($var) { case "voicecodecs": @@ -1558,7 +1580,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $final; } - public function getCodecs($type, $showDefaults = false) { + public function getCodecs($type, $showDefaults = false) + { $allSupported = array(); // $Sccp_Codec = array('gsm','slin16','allow','ulaw','g722','g723','g726','g728','g729','ilibc','isac','opus','h224','aac','h264','h263','h265','h261'); $Sccp_Codec = array('gsm', 'slin16', 'alaw', 'ulaw', 'g722', 'g723', 'g726', 'g728', 'g729', 'ilibc', 'opus', 'h264', 'h263', 'h265', 'h261'); @@ -1630,7 +1653,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * @param {string} $type Codec Type * @param {array} $codecs=array() The codecs with order, if blank set defaults */ - public function setCodecs($type, $codecs = array()) { + public function setCodecs($type, $codecs = array()) + { $default = empty($codecs) ? true : false; switch ($type) { case 'audio': @@ -1656,11 +1680,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return true; } - function Sccp_manager_hookGet_config($engine) { + function Sccp_manager_hookGet_config($engine) + { $this->debugdata($engine); } - function Sccp_manager_get_config($engine) { + function Sccp_manager_get_config($engine) + { $this->debugdata($engine); } @@ -1687,13 +1713,15 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /** * Retrieve Active Codecs * return fiends Lag pack - * + * */ - public function getTftpLang() { + public function getTftpLang() + { return $this->tftpLang; } - private function initTftpLang() { + private function initTftpLang() + { $result = array(); if (empty($this->sccppath["tftp_path"]) || empty($this->sccppath["tftp_lang_path"])) { return; @@ -1724,7 +1752,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Check tftp/xml file path and permissions */ - private function init_tftp_lang_path() { + private function init_tftp_lang_path() + { $dir = $this->sccppath["tftp_lang_path"]; foreach ($this->extconfigs->getextConfig('sccp_lang') as $lang_key => $lang_value) { $filename = $dir . DIRECTORY_SEPARATOR . $lang_value['locale']; @@ -1742,7 +1771,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // !TODO!: -TODO-: This function is getting a little big. Might be possible to sperate tftp work into it's own file/class. Initially, you need to remove the not working section and commented out section - function init_sccp_path() { + function init_sccp_path() + { global $db; global $amp_conf; $driver_revision = array('0' => '', '430' => '.v431', '431' => '.v432', '432' => '.v432', '433' => '.v433'); @@ -1802,21 +1832,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /* * Soft Key - * + * */ - function sccp_create_xmlSoftkey() { + function sccp_create_xmlSoftkey() + { foreach ($this->srvinterface->sccp_list_keysets() as $keyl => $vall) { $this->xmlinterface->create_xmlSoftkeyset($this->sccp_conf_init, $this->sccppath, $keyl); } } /* - * DialPlan - * + * DialPlan + * */ - function get_DialPlanList() { + function get_DialPlanList() + { $dir = $this->sccppath["tftp_dialplan"] . '/dial*.xml'; $base_len = strlen($this->sccppath["tftp_dialplan"]) + 1; $res = glob($dir); @@ -1828,7 +1860,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $res; } - function get_DialPlan($get_file) { + function get_DialPlan($get_file) + { $file = $this->sccppath["tftp_dialplan"] . '/' . $get_file . '.xml'; if (file_exists($file)) { // $load_xml_data = simplexml_load_file($file); @@ -1842,7 +1875,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $res; } - function del_DialPlan($get_file) { + function del_DialPlan($get_file) + { if (!empty($get_file)) { $file = $this->sccppath["tftp_dialplan"] . '/' . $get_file . '.xml'; if (file_exists($file)) { @@ -1852,7 +1886,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $res; } - function save_DialPlan($get_settings) { + function save_DialPlan($get_settings) + { $confDir = $this->sccppath["tftp_dialplan"]; return $this->xmlinterface->save_DialPlan($confDir, $get_settings); @@ -1860,10 +1895,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /* * Update Butons Labels on mysql DB - * + * */ - private function sccp_db_update_butons($hw_list = array()) { + private function sccp_db_update_butons($hw_list = array()) + { $save_buttons = array(); if (!empty($hw_list)) { @@ -1883,7 +1919,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return array('Response' => ' Found 0 device ', 'data' => ''); } $copy_fld = array('ref', 'reftype', 'instance', 'buttontype'); - $user_list = $user_list = $this->dbinterface->get_db_SccpTableByID("SccpExtension", Array(), 'name'); + $user_list = $user_list = $this->dbinterface->get_db_SccpTableByID("SccpExtension", array(), 'name'); foreach ($buton_list as $value) { $btn_opt = explode(',', $value['options']); $btn_id = $btn_opt[0]; @@ -1909,7 +1945,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * sccp_db_save_setting(empty) - Save All settings from $sccpvalues */ - private function sccp_db_save_setting($save_value = array()) { + private function sccp_db_save_setting($save_value = array()) + { global $db; global $amp_conf; @@ -1933,7 +1970,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Create XMLDefault.cnf.xml */ - function sccp_create_tftp_XML() { + function sccp_create_tftp_XML() + { foreach ($this->sccpvalues as $key => $value) { $data_value[$key] = $value['data']; @@ -1941,8 +1979,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $data_value['server_if_list'] = $this->getIP_information2('ip4'); $model_information = $this->getSccp_model_information($get = "enabled", $validate = false); // Get Active - if (empty($model_information)) + if (empty($model_information)) { $model_information = $this->getSccp_model_information($get = "all", $validate = false); // Get All + } $lang_data = $this->extconfigs->getextConfig('sccp_lang'); $data_value['tftp_path'] = $this->sccppath["tftp_path"]; @@ -1954,7 +1993,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Create (SEP) dev_ID.cnf.xml */ - function sccp_create_device_XML($dev_id = '') { + function sccp_create_device_XML($dev_id = '') + { if (empty($dev_id)) { return false; @@ -1964,7 +2004,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dev_line_data = null; $dev_config = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); -// Support Cisco Sip Device +// Support Cisco Sip Device if (!empty($dev_config['type'])) { if (strpos($dev_config['type'], 'sip') !== false) { $sccp_native = false; @@ -2004,10 +2044,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { foreach ($this->sccpvalues as $key => $value) { $data_value[$key] = $value['data']; } - //Get Cisco Code only Old Device - $data_value['ntp_timezone_id'] = $this->extconfigs->getextConfig('sccp_timezone', $data_value['ntp_timezone']); // Old Cisco Device - // $data_value['ntp_timezone_id'] = $data_value['ntp_timezone']; // New Cisco Device ! - // $data_value['ntp_timezone_id'] = // SPA Cisco Device ! + //Get Cisco Code only Old Device + $data_value['ntp_timezone_id'] = $this->extconfigs->getextConfig('sccp_timezone', $data_value['ntp_timezone']); // Old Cisco Device + // $data_value['ntp_timezone_id'] = $data_value['ntp_timezone']; // New Cisco Device ! + // $data_value['ntp_timezone_id'] = // SPA Cisco Device ! $data_value['server_if_list'] = $this->getIP_information2('ip4'); $dev_config = array_merge($dev_config, $this->sccppath); $dev_config['tftp_firmware'] = ''; @@ -2029,7 +2069,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $this->xmlinterface->create_SEP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data); } - function sccp_delete_device_XML($dev_id = '') { + function sccp_delete_device_XML($dev_id = '') + { if (empty($dev_id)) { return false; } @@ -2051,7 +2092,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } - private function sccp_create_sccp_backup() { + private function sccp_create_sccp_backup() + { global $amp_conf; $dir_info = array(); $backup_files = array($amp_conf['ASTETCDIR'] . '/sccp', $amp_conf['ASTETCDIR'] . '/extensions', $amp_conf['ASTETCDIR'] . '/extconfig', @@ -2104,8 +2146,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $filename; } - function sccp_create_sccp_init() { -// Make sccp.conf data + function sccp_create_sccp_init() + { +// Make sccp.conf data // [general] foreach ($this->sccpvalues as $key => $value) { if ($value['seq'] == 0) { @@ -2123,7 +2166,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->sccp_conf_init['general']['phonecodepage'] = $lang_data['codepage']; } break; - case "netlang": // Remove Key + case "netlang": // Remove Key case "tftp_path": case "sccp_compatible": break; @@ -2133,13 +2176,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } // [Namesoftkeyset] -// type=softkeyset +// type=softkeyset $this->cnf_wr->writeConfig('sccp.conf', $this->sccp_conf_init); -// return $this-> sccp_conf_init; +// return $this-> sccp_conf_init; } - function getSccp_model_information($get = "all", $validate = false, $format_list = "all", $filter = array()) { + function getSccp_model_information($get = "all", $validate = false, $format_list = "all", $filter = array()) + { // $file_ext = array('.loads', '.LOADS', '.sbn', '.SBN', '.bin', '.BIN','.zup','.ZUP'); $file_ext = array('.loads', '.sbn', '.bin', '.zup'); // $dir = $this->sccppath["tftp_path"]; @@ -2182,7 +2226,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } break; case 'internal2': - break; case 'off': default: // Place in root TFTP dir @@ -2195,7 +2238,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - /* OLD search + /* OLD search $file = $dir . '/' . $raw_settings[$i]['loadimage']; if (is_dir($file)) { $file .= '/' . $raw_settings[$i]['loadimage']; @@ -2213,7 +2256,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $raw_settings[$i]['validate'] = 'yes;'; } } - * + * */ } else { $raw_settings[$i]['validate'] = '-;'; @@ -2233,7 +2276,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $raw_settings; } - function get_hint_info($sort = true, $filter = array()) { + function get_hint_info($sort = true, $filter = array()) + { $res = array(); $default_hint = '@ext-local'; @@ -2241,7 +2285,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // $res = $this->srvinterface->core_list_all_exten('hint', $filter); if (empty($res)) { -// Old Req get all hints +// Old Req get all hints $tmp_data = $this->srvinterface->sccp_list_all_hints(); foreach ($tmp_data as $value) { $res[$value] = array('key' => $value, 'exten' => before('@', $value), 'label' => $value); @@ -2271,13 +2315,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $res_sort[$value] = $res[$value]; } -// Update info from sip DB +// Update info from sip DB /* !TODO!: Update Hint info from sip DB ??? */ return $res_sort; } - function getIP_information2($type = '') { + function getIP_information2($type = '') + { $interfaces = array(); switch ($type) { case 'ip4': @@ -2293,21 +2338,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } foreach ($result as $line) { $vals = preg_split("/\s+/", $line); - if ($vals[3] == "mtu") + if ($vals[3] == "mtu") { continue; - if ($vals[2] != "inet" && $vals[2] != "inet6") + } + if ($vals[2] != "inet" && $vals[2] != "inet6") { continue; + } if (preg_match("/(.+?)(?:@.+)?:$/", $vals[1], $res)) { continue; } $ret = preg_match("/(\d*+.\d*+.\d*+.\d*+)[\/(\d*+)]*/", $vals[3], $ip); - $interfaces[$vals[1] . ':' . $vals[2]] = Array('name' => $vals[1], 'type' => $vals[2], 'ip' => ((empty($ip[1]) ? '' : $ip[1]))); + $interfaces[$vals[1] . ':' . $vals[2]] = array('name' => $vals[1], 'type' => $vals[2], 'ip' => ((empty($ip[1]) ? '' : $ip[1]))); } return $interfaces; } - function getIP_information_old() { + function getIP_information_old() + { $interfaces['auto'] = array('0.0.0.0', 'All', '0'); exec("/sbin/ip -4 -o addr", $result, $ret); @@ -2315,8 +2363,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $vals = preg_split("/\s+/", $line); // We only care about ipv4 (inet) lines, or definition lines - if ($vals[2] != "inet" && $vals[3] != "mtu") + if ($vals[2] != "inet" && $vals[3] != "mtu") { continue; + } if (preg_match("/(.+?)(?:@.+)?:$/", $vals[1], $res)) { // Matches vlans, which are eth0.100@eth0 // It's a network definition. @@ -2337,27 +2386,31 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } // $int = 0; // foreach ($interfaces as $value) { -// $this->sccpvalues['interfaces_'.$int] = array('keyword' => 'interfaces_'.$value[1], 'data' => $value[0], 'type' => '1', 'seq' => '99'); +// $this->sccpvalues['interfaces_'.$int] = array('keyword' => 'interfaces_'.$value[1], 'data' => $value[0], 'type' => '1', 'seq' => '99'); // $int ++; // } return $interfaces; } - private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement) { + private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement) + { $dom = dom_import_simplexml($xml); $import = $dom->ownerDocument->importNode( - dom_import_simplexml($element), TRUE + dom_import_simplexml($element), + true ); $dom->parentNode->replaceChild($import, $dom); } - private function appendSimpleXmlNode($xml, $element = SimpleXMLElement) { + private function appendSimpleXmlNode($xml, $element = SimpleXMLElement) + { $dom = dom_import_simplexml($xml); $import = $dom->ownerDocument->importNode( - dom_import_simplexml($element), TRUE + dom_import_simplexml($element), + true ); -// $dom->parentNode->appendChild($import, $dom); +// $dom->parentNode->appendChild($import, $dom); $dom->parentNode->appendChild($import->cloneNode(true)); } @@ -2365,7 +2418,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // $dom = dom_import_simplexml($node); // $dom->parentNode->removeChild($dom); // } - private function strpos_array($haystack, $needles) { + private function strpos_array($haystack, $needles) + { if (is_array($needles)) { foreach ($needles as $str) { if (is_array($str)) { @@ -2373,19 +2427,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } else { $pos = strpos($haystack, $str); } - if ($pos !== FALSE) { + if ($pos !== false) { return $pos; } } } else { return strpos($haystack, $needles); } - return FALSE; + return false; } - private function find_all_files($dir, $file_mask = null, $mode = 'full') { + private function find_all_files($dir, $file_mask = null, $mode = 'full') + { - $result = NULL; + $result = null; if (empty($dir) || (!file_exists($dir))) { return $result; } @@ -2434,5 +2489,4 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } return $result; } - } diff --git a/Sccp_manager.inc/aminterface/Event.class.php b/Sccp_manager.inc/aminterface/Event.class.php index 7580822..585fc74 100644 --- a/Sccp_manager.inc/aminterface/Event.class.php +++ b/Sccp_manager.inc/aminterface/Event.class.php @@ -1,9 +1,9 @@ getKey('Event'); } - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); $this->_events = array(); $this->_eventsCount = 0; // $this->_completed = !$this->isList(); } - } -class UnknownEvent extends Event { - public function __construct($rawContent='') { +class UnknownEvent extends Event +{ + public function __construct($rawContent = '') + { print_r($rawContent); // die(); } - } -class TableStart_Event extends Event { +class TableStart_Event extends Event +{ - public function getTableName() { + public function getTableName() + { return $this->getKey('TableName'); } - } -class TableEnd_Event extends Event { +class TableEnd_Event extends Event +{ - public function getTableName() { + public function getTableName() + { return $this->getKey('TableName'); } - } -class SCCPSoftKeySetEntry_Event extends Event { +class SCCPSoftKeySetEntry_Event extends Event +{ protected $_data; - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); return null; } - } -class SCCPShowSoftKeySetsComplete_Event extends Event { +class SCCPShowSoftKeySetsComplete_Event extends Event +{ - public function getListItems() { + public function getListItems() + { return intval($this->getKey('ListItems')); } - } -class ExtensionStatus_Event extends Event { +class ExtensionStatus_Event extends Event +{ - public function getPrivilege() { + public function getPrivilege() + { return $this->getKey('Privilege'); } - public function getExtension() { + public function getExtension() + { return $this->getKey('Exten'); } - public function getContext() { + public function getContext() + { return $this->getKey('Context'); } - public function getHint() { + public function getHint() + { return $this->getKey('Hint'); } - public function getStatus() { + public function getStatus() + { return $this->getKey('Status'); } - } -class SCCPDeviceEntry_Event extends Event { +class SCCPDeviceEntry_Event extends Event +{ } -class SCCPShowDeviceComplete_Event extends Event { +class SCCPShowDeviceComplete_Event extends Event +{ - public function getListItems() { + public function getListItems() + { return intval($this->getKey('ListItems')); } - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); $this->_completed = $this->getKey('EventList'); // return null; } } -class SCCPShowDevice_Event extends Event { +class SCCPShowDevice_Event extends Event +{ - public function getCapabilities() { + public function getCapabilities() + { $ret = array(); $codecs = explode(", ", substr($this->getKey('Capabilities'), 1, -1)); foreach ($codecs as $codec) { @@ -124,7 +142,8 @@ class SCCPShowDevice_Event extends Event { return $ret; } - public function getCodecsPreference() { + public function getCodecsPreference() + { $ret = array(); $codecs = explode(", ", substr($this->getKey('CodecsPreference'), 1, -1)); foreach ($codecs as $codec) { @@ -133,25 +152,30 @@ class SCCPShowDevice_Event extends Event { } return $ret; } - } -class SCCPShowDevicesComplete_Event extends Event { +class SCCPShowDevicesComplete_Event extends Event +{ - public function getListItems() { + public function getListItems() + { return intval($this->getKey('ListItems')); } - } -class SCCPDeviceButtonEntry_Event extends Event { +class SCCPDeviceButtonEntry_Event extends Event +{ } -class SCCPDeviceLineEntry_Event extends Event { +class SCCPDeviceLineEntry_Event extends Event +{ } -class SCCPDeviceStatisticsEntry_Event extends Event { +class SCCPDeviceStatisticsEntry_Event extends Event +{ } -class SCCPDeviceSpeeddialEntry_Event extends Event { +class SCCPDeviceSpeeddialEntry_Event extends Event +{ } -class ExtensionStateListComplete_Event extends Event { +class ExtensionStateListComplete_Event extends Event +{ -} \ No newline at end of file +} diff --git a/Sccp_manager.inc/aminterface/Message.class.php b/Sccp_manager.inc/aminterface/Message.class.php index 6d76cd0..f52178b 100644 --- a/Sccp_manager.inc/aminterface/Message.class.php +++ b/Sccp_manager.inc/aminterface/Message.class.php @@ -1,20 +1,22 @@ _responseHandler) > 0) { // throw new AMIException('Hier:' . $this->_responseHandler); return (string) $this->_responseHandler; @@ -38,7 +41,8 @@ abstract class Message { } } - public function setResponseHandler($responseHandler) { + public function setResponseHandler($responseHandler) + { if (0 == strlen($responseHandler)) { return; } @@ -50,7 +54,8 @@ abstract class Message { } } - public function setVariable($key, $value) { + public function setVariable($key, $value) + { $key = strtolower($key); $this->variables[$key] = $value; /* print_r('
----Set Value -------
'); @@ -59,7 +64,8 @@ abstract class Message { */ } - public function getVariable($key) { + public function getVariable($key) + { $key = strtolower($key); if (!isset($this->variables[$key])) { @@ -68,18 +74,20 @@ abstract class Message { return $this->variables[$key]; } - protected function setKey($key, $value) { + protected function setKey($key, $value) + { $key = strtolower((string) $key); $this->keys[$key] = (string) $value; /* print_r('
----Set Key -------
'); print_r($key); print_r($value); - * + * */ } - public function getKey($key) { + public function getKey($key) + { $key = strtolower($key); if (!isset($this->keys[$key])) { return null; @@ -88,23 +96,28 @@ abstract class Message { return $this->keys[$key]; } - public function getVariables() { + public function getVariables() + { return $this->variables; } - public function getActionID() { + public function getActionID() + { return $this->getKey('ActionID'); } - public function getKeys() { + public function getKeys() + { return $this->keys; } - private function serializeVariable($key, $value) { + private function serializeVariable($key, $value) + { return "Variable: $key=$value"; } - protected function setSanitizedKey($key, $value) { + protected function setSanitizedKey($key, $value) + { $key = strtolower((string) $key); $_string_key = array('actionid', 'descr'); if (array_search($key, $_string_key) !== false) { @@ -114,13 +127,14 @@ abstract class Message { } } - protected function sanitizeInput($value, $prefered_type = '') { + protected function sanitizeInput($value, $prefered_type = '') + { if ($prefered_type == '') { - if (!isset($value) || $value === NULL || strlen($value) == 0) { - return NULL; - } else if (is_numeric($value)) { + if (!isset($value) || $value === null || strlen($value) == 0) { + return null; + } elseif (is_numeric($value)) { $prefered_type = 'numeric'; - } else if (is_string($value)) { + } elseif (is_string($value)) { $prefered_type = 'string'; } else { throw new AMIException("Don't know how to convert: '" . $value . "'\n"); @@ -129,26 +143,26 @@ abstract class Message { if ($prefered_type !== '') { switch ($prefered_type) { case 'string': - if (!isset($value) || $value === NULL || strlen($value) == 0) { + if (!isset($value) || $value === null || strlen($value) == 0) { return ''; } if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) { return (boolean) $value; - } else if (filter_var($value, FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE)) { + } elseif (filter_var($value, FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE)) { return (string) $value; - } else if (filter_var($value, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_NULL_ON_FAILURE)) { + } elseif (filter_var($value, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_NULL_ON_FAILURE)) { return (string) htmlspecialchars($value, ENT_QUOTES); } else { throw new AMIException("Incoming String is not sanitary. Skipping: '" . $value . "'\n"); } break; case 'numeric': - if (!isset($value) || $value === NULL || strlen($value) == 0) { + if (!isset($value) || $value === null || strlen($value) == 0) { return 0; } if (filter_var($value, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX | FILTER_FLAG_ALLOW_OCTAL)) { return intval($value, 0); - } else if (filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND | FILTER_FLAG_ALLOW_SCIENTIFIC)) { + } elseif (filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND | FILTER_FLAG_ALLOW_SCIENTIFIC)) { return (float) $value; } else { return (double) $value; @@ -160,11 +174,13 @@ abstract class Message { } } - protected function finishMessage($message) { + protected function finishMessage($message) + { return $message . self::EOL . self::EOL; } - public function serialize() { + public function serialize() + { $result = array(); foreach ($this->getKeys() as $k => $v) { $result[] = $k . ': ' . $v; @@ -182,7 +198,8 @@ abstract class Message { return $mStr; } - public function setActionID($actionID) { + public function setActionID($actionID) + { if (0 == strlen($actionID)) { throw new AMIException('ActionID cannot be empty.'); return; @@ -196,38 +213,44 @@ abstract class Message { $this->setKey('ActionID', $actionID); } - public function __sleep() { + public function __sleep() + { return array('lines', 'variables', 'keys', 'createdDate'); } - public function __construct() { + public function __construct() + { $this->lines = array(); $this->variables = array(); $this->keys = array(); $this->createdDate = time(); } - } -abstract class IncomingMessage extends Message { +abstract class IncomingMessage extends Message +{ protected $rawContent; - public function getEventList() { + public function getEventList() + { return $this->getKey('EventList'); } - public function getRawContent() { + public function getRawContent() + { return $this->rawContent; } - public function __sleep() { + public function __sleep() + { $ret = parent::__sleep(); $ret[] = 'rawContent'; return $ret; } - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct(); $this->rawContent = $rawContent; $lines = explode(Message::EOL, $rawContent); @@ -243,11 +266,11 @@ abstract class IncomingMessage extends Message { } } } - } // namespace FreePBX\modules\Sccp_manager\aminterface\Message; -class LoginAction extends ActionMessage { +class LoginAction extends ActionMessage +{ /** * Constructor. @@ -257,111 +280,122 @@ class LoginAction extends ActionMessage { * * @return void */ - public function __construct($user, $password) { + public function __construct($user, $password) + { parent::__construct('Login'); $this->setKey('Username', $user); $this->setKey('Secret', $password); $this->setKey('Events', 'off'); // &---- $this->setResponseHandler('Login'); } - } -abstract class ActionMessage extends Message { +abstract class ActionMessage extends Message +{ - public function __construct($what) { + public function __construct($what) + { parent::__construct(); $this->setKey('Action', $what); $this->setKey('ActionID', microtime(true)); } - } -class CommandAction extends ActionMessage { - public function __construct($command) { +class CommandAction extends ActionMessage +{ + public function __construct($command) + { parent::__construct('Command'); $this->setKey('Command', $command); $this->setResponseHandler("Command"); } - } -class ReloadAction extends ActionMessage { +class ReloadAction extends ActionMessage +{ - public function __construct($module = false) { + public function __construct($module = false) + { parent::__construct('Reload'); if ($module !== false) { $this->setKey('Module', $module); $this->setResponseHandler("Generic"); } } - } -class ExtensionStateListAction extends ActionMessage { +class ExtensionStateListAction extends ActionMessage +{ - public function __construct() { + public function __construct() + { parent::__construct('ExtensionStateList'); $this->setKey('Segment', 'general'); $this->setKey('ResultFormat', 'command'); $this->setResponseHandler("ExtensionStateList"); } - } -class SCCPShowGlobalsAction extends ActionMessage { +class SCCPShowGlobalsAction extends ActionMessage +{ public function __construct() { parent::__construct('SCCPShowGlobals'); } } -class SCCPShowSoftkeySetsAction extends ActionMessage { +class SCCPShowSoftkeySetsAction extends ActionMessage +{ - public function __construct() { + public function __construct() + { parent::__construct('SCCPShowSoftkeySets'); $this->setKey('Segment', 'general'); $this->setKey('ResultFormat', 'command'); $this->setResponseHandler("SCCPShowSoftkeySets"); } - } -class SCCPShowDeviceAction extends ActionMessage { +class SCCPShowDeviceAction extends ActionMessage +{ - public function __construct($devicename) { + public function __construct($devicename) + { parent::__construct('SCCPShowDevice'); $this->setKey('Segment', 'general'); $this->setKey('ResultFormat', 'command'); $this->setKey('DeviceName', $devicename); $this->setResponseHandler("SCCPShowDevice"); } - } -class SCCPShowDevicesAction extends ActionMessage { +class SCCPShowDevicesAction extends ActionMessage +{ - public function __construct() { + public function __construct() + { parent::__construct('SCCPShowDevices'); $this->setKey('Segment', 'general'); $this->setKey('ResultFormat', 'command'); $this->setResponseHandler("SCCPShowDevices"); } - } -class SCCPTokenAckAction extends ActionMessage { +class SCCPTokenAckAction extends ActionMessage +{ - public function __construct($DeviceName) { + public function __construct($DeviceName) + { parent::__construct('SCCPTokenAck'); $this->setKey('DeviceId', $DeviceName); $this->setResponseHandler("SCCPGeneric"); } - } -class SCCPDeviceRestartAction extends ActionMessage { +class SCCPDeviceRestartAction extends ActionMessage +{ - public function __construct($DeviceName, $Type = "restart") { + public function __construct($DeviceName, $Type = "restart") + { parent::__construct('SCCPDeviceRestart'); $this->setResponseHandler("SCCPGeneric"); if (empty($Type)) { @@ -374,18 +408,16 @@ class SCCPDeviceRestartAction extends ActionMessage { throw new Exception('Param2 has to be one of \'restart\', \'full\', \'reset\'.'); } } - } class SCCPConfigMetaDataAction extends ActionMessage { - public function __construct($segment=false) + public function __construct($segment = false) { parent::__construct('SCCPConfigMetaData'); if ($segment != false) { - $this->setKey('Segment', $segment); + $this->setKey('Segment', $segment); } $this->setResponseHandler("SCCPGeneric"); } } - diff --git a/Sccp_manager.inc/aminterface/Response.class.php b/Sccp_manager.inc/aminterface/Response.class.php index 6cfbd0f..c4bd495 100644 --- a/Sccp_manager.inc/aminterface/Response.class.php +++ b/Sccp_manager.inc/aminterface/Response.class.php @@ -1,9 +1,9 @@ _completed; } - public function __sleep() { + public function __sleep() + { $ret = parent::__sleep(); $ret[] = '_completed'; $ret[] = '_events'; @@ -34,8 +37,7 @@ abstract class Response extends IncomingMessage { public function addEvent($event) { $this->_events[] = $event; - if ( - stristr($event->getEventList(), 'complete') !== false + if (stristr($event->getEventList(), 'complete') !== false || stristr($event->getName(), 'complete') !== false || stristr($event->getName(), 'DBGetResponse') !== false ) { @@ -71,7 +73,8 @@ abstract class Response extends IncomingMessage { } - public function getVariable($_rawContent, $_fields='') { + public function getVariable($_rawContent, $_fields = '') + { $lines = explode(Message::EOL, $_rawContent); foreach ($_fields as $key => $value) { foreach ($lines as $data) { @@ -83,37 +86,42 @@ abstract class Response extends IncomingMessage { } } - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); $this->_events = array(); $this->_eventsCount = 0; $this->_completed = !$this->isList(); } - } //**************************************************************************** -class Generic_Response extends Response { +class Generic_Response extends Response +{ - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); // print_r('
---- r --
'); // print_r($rawContent); } } -class Login_Response extends Response { +class Login_Response extends Response +{ - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); return $this->isSuccess(); } - } -class Command_Response extends Response { +class Command_Response extends Response +{ private $_temptable; - public function __construct($rawContent) { + public function __construct($rawContent) + { // print_r('
---- r --
'); // print_r($rawContent); // print_r('
---- re --
'); @@ -125,26 +133,27 @@ class Command_Response extends Response { $content = explode(':', $line); if (is_array($content)) { switch (strtolower($content[0])) { - case 'output': - $_tmp_str = trim(substr($line,7)); - if (!empty($_tmp_str)){ - $this->_temptable['output'][]= trim(substr($line,7)); - } - break; - default: - $this->_temptable[$content[0]][]= trim(substr($line,strlen($content[0])+1)); - break; + case 'output': + $_tmp_str = trim(substr($line, 7)); + if (!empty($_tmp_str)) { + $this->_temptable['output'][]= trim(substr($line, 7)); + } + break; + default: + $this->_temptable[$content[0]][]= trim(substr($line, strlen($content[0])+1)); + break; } } } - if (!empty($this->_temptable)){ + if (!empty($this->_temptable)) { $this->setKey('output', 'array'); } $this->_completed = $this->isSuccess(); // return $this->isSuccess(); } - public function getResult() { + public function getResult() + { if (stristr($this->getKey('output'), 'array') !== false) { $result = $this->_temptable; } else { @@ -152,15 +161,16 @@ class Command_Response extends Response { } return $result; } - } -class SCCPGeneric_Response extends Response { +class SCCPGeneric_Response extends Response +{ protected $_tables; private $_temptable; - public function addEvent($event) { + public function addEvent($event) + { // not eventlist (start/complete) // print_r('
---- addEvent --
'); // print_r($event); @@ -170,18 +180,18 @@ class SCCPGeneric_Response extends Response { ) { $unknownevent = "FreePBX\\modules\\Sccp_manager\\aminterface\\UnknownEvent"; if (!($event instanceof $unknownevent)) { - // Handle TableStart/TableEnd Differently + // Handle TableStart/TableEnd Differently if (stristr($event->getName(), 'TableStart') != false) { $this->_temptable = array(); $this->_temptable['Name'] = $event->getTableName(); $this->_temptable['Entries'] = array(); - } else if (stristr($event->getName(), 'TableEnd') != false) { + } elseif (stristr($event->getName(), 'TableEnd') != false) { if (!is_array($this->_tables)) { $this->_tables = array(); } $this->_tables[$event->getTableName()] = $this->_temptable; unset($this->_temptable); - } else if (is_array($this->_temptable)) { + } elseif (is_array($this->_temptable)) { $this->_temptable['Entries'][] = $event; } else { // add regular event @@ -193,25 +203,25 @@ class SCCPGeneric_Response extends Response { } } // finish eventlist - if ( - stristr($event->getEventList(), 'complete') != false || stristr($event->getName(), 'complete') != false + if (stristr($event->getEventList(), 'complete') != false || stristr($event->getName(), 'complete') != false ) { $this->_completed = true; } } - protected function ConvertTableData($_tablename,$_fkey,$_fields) { - $_rawtable = $this->Table2Array($_tablename); + protected function ConvertTableData($_tablename, $_fkey, $_fields) + { + $_rawtable = $this->Table2Array($_tablename); $result = array(); foreach ($_rawtable as $_row) { $all_key_ok = true; - if (is_array($_fkey)){ + if (is_array($_fkey)) { foreach ($_fkey as $_fid) { - if (empty($_row[$_fid])) { - $all_key_ok = false; - } else { - $set_name[$_fid] = $_row[$_fid]; - } + if (empty($_row[$_fid])) { + $all_key_ok = false; + } else { + $set_name[$_fid] = $_row[$_fid]; + } } } else { if (empty($_row[$_fkey])) { @@ -233,20 +243,21 @@ class SCCPGeneric_Response extends Response { return $result; } - protected function ConvertEventData($_fkey,$_fields) { + protected function ConvertEventData($_fkey, $_fields) + { $result = array(); foreach ($this->_events as $_row) { $all_key_ok = true; $tmp_result = $_row->getKeys(); $set_name = array(); - if (is_array($_fkey)){ + if (is_array($_fkey)) { foreach ($_fkey as $_fid) { - if (empty($tmp_result[$_fid])) { - $all_key_ok = false; - } else { - $set_name[$_fid] = $tmp_result[$_fid]; - } + if (empty($tmp_result[$_fid])) { + $all_key_ok = false; + } else { + $set_name[$_fid] = $tmp_result[$_fid]; + } } } else { if (empty($tmp_result[$_fkey])) { @@ -271,20 +282,20 @@ class SCCPGeneric_Response extends Response { public function hasTable() { - if (is_array($this->_tables)) { - return true; - } - return false; + if (is_array($this->_tables)) { + return true; + } + return false; } public function getTableNames() { - return (is_array($this->_tables)) ? array_keys($this->_tables) : null; + return (is_array($this->_tables)) ? array_keys($this->_tables) : null; } - public function Table2Array($tablename = '') + public function Table2Array($tablename = '') { $result =array(); - if ( !is_string($tablename) || empty($tablename)){ + if (!is_string($tablename) || empty($tablename)) { return false; } if ($this->hasTable()) { @@ -292,24 +303,24 @@ class SCCPGeneric_Response extends Response { $result[]= $trow->getKeys(); } return $result; - } else { + } else { return false; } } - public function Events2Array() + public function Events2Array() { $result =array(); if (is_array($this->_events)) { - foreach ($this->_events as $trow) { + foreach ($this->_events as $trow) { $tmp_result = $trow->getKeys(); if (is_array($tmp_result)) { - $result = array_merge($result,$tmp_result); + $result = array_merge($result, $tmp_result); } else { $result [] = $tmp_result; } } return $result; - } else { + } else { return false; } } @@ -317,42 +328,44 @@ class SCCPGeneric_Response extends Response { public function getTable($tablename) { if ($this->hasTable() && array_key_exists($tablename, $this->_tables)) { - return $this->_tables[$tablename]; + return $this->_tables[$tablename]; } - throw new PAMIException("No such table."); + throw new PAMIException("No such table."); } public function getJSON() { - if (strlen($this->getKey('JSON')) > 0) { - if (($json = json_decode($this->getKey('JSON'), true)) != false) { - return $json; - } - } - throw new AMIException("No JSON Key found to return."); - } + if (strlen($this->getKey('JSON')) > 0) { + if (($json = json_decode($this->getKey('JSON'), true)) != false) { + return $json; + } + } + throw new AMIException("No JSON Key found to return."); + } - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); $_fields = array("EventList" => "EventList:", "Message" => "Message:"); // $this->getVariable($rawContent, $_fields); $this->_completed = !$this->isList(); } - public function getResult() { + public function getResult() + { if ($this->getKey('JSON') != null) { $result = $this->getJSON(); } else { - $result = $this->getMessage (); + $result = $this->getMessage(); } return $result; } - - } -class SCCPJSON_Response extends Response { +class SCCPJSON_Response extends Response +{ - public function __construct($rawContent) { + public function __construct($rawContent) + { parent::__construct($rawContent); $_fields = array("DataType" => "DataType:", "JSONRAW" => "JSON:"); $this->getVariable($rawContent, $_fields); @@ -362,71 +375,93 @@ class SCCPJSON_Response extends Response { } return $this->isSuccess(); } - } -class SCCPShowSoftkeySets_Response extends SCCPGeneric_Response { - public function __construct($rawContent) { +class SCCPShowSoftkeySets_Response extends SCCPGeneric_Response +{ + public function __construct($rawContent) + { parent::__construct($rawContent); - } - public function getResult() { + public function getResult() + { $_fields = array('description'=>'description','label'=>'label','lblid'=>'lblid'); - $result = $this->ConvertTableData('SoftKeySets',array('set','mode'),$_fields); + $result = $this->ConvertTableData('SoftKeySets', array('set','mode'), $_fields); return $result; } - } -class SCCPShowDevices_Response extends SCCPGeneric_Response { - public function __construct($rawContent) { +class SCCPShowDevices_Response extends SCCPGeneric_Response +{ + public function __construct($rawContent) + { parent::__construct($rawContent); } - public function getResult() { + public function getResult() + { $_fields = array('mac'=>'mac','address'=>'address','descr'=>'descr','regstate'=>'status', 'token'=>'token','act'=>'act', 'lines'=>'lines','nat'=>'nat','regtime'=>'regtime'); - $result = $this->ConvertTableData('Devices',array('mac'),$_fields); + $result = $this->ConvertTableData('Devices', array('mac'), $_fields); return $result; } - } -class SCCPShowDevice_Response extends SCCPGeneric_Response { - public function __construct($rawContent) { +class SCCPShowDevice_Response extends SCCPGeneric_Response +{ + public function __construct($rawContent) + { parent::__construct($rawContent); } - public function getResult() { + public function getResult() + { $result = array(); $result = $this->Events2Array(); - $result['Buttons'] = $this->ConvertTableData('Buttons', array('id'), - array('id'=>'id','channelobjecttype'=>'channelobjecttype','inst'=>'inst', - 'typestr'=>'typestr','type'=>'type','pendupdt'=>'pendupdt','penddel'=>'penddel', 'default'=>'default')); - $result['SpeeddialButtons'] = $this->ConvertTableData('Buttons', array('id'), - array('id'=>'id','channelobjecttype'=>'channelobjecttype','name'=>'name','number'=>'number','hint'=>'hint')); - $result['CallStatistics'] = $this->ConvertTableData('CallStatistics', array('type'), - array('type'=>'type','channelobjecttype'=>'channelobjecttype','calls'=>'calls','pcktsnt'=>'pcktsnt','pcktrcvd'=>'pcktrcvd', + $result['Buttons'] = $this->ConvertTableData( + 'Buttons', + array('id'), + array('id'=>'id','channelobjecttype'=>'channelobjecttype','inst'=>'inst', + 'typestr'=>'typestr', + 'type'=>'type', + 'pendupdt'=>'pendupdt', + 'penddel'=>'penddel', + 'default'=>'default') + ); + $result['SpeeddialButtons'] = $this->ConvertTableData( + 'Buttons', + array('id'), + array('id'=>'id','channelobjecttype'=>'channelobjecttype','name'=>'name','number'=>'number','hint'=>'hint') + ); + $result['CallStatistics'] = $this->ConvertTableData( + 'CallStatistics', + array('type'), + array('type'=>'type','channelobjecttype'=>'channelobjecttype','calls'=>'calls','pcktsnt'=>'pcktsnt','pcktrcvd'=>'pcktrcvd', 'lost'=>'lost','jitter'=>'jitter','latency'=>'latency', 'quality'=>'quality','avgqual'=>'avgqual','meanqual'=>'meanqual', - 'maxqual'=>'maxqual','rconceal'=>'rconceal','sconceal'=>'sconceal')); - $result['SCCP_Vendor'] = Array('vendor' => strtok($result['skinnyphonetype'], ' '), 'model' => strtok('('), - 'model_id' => strtok(')'), 'vendor_addon' => strtok($result['configphonetype'], ' '), - 'model_addon' => strtok(' ')); + 'maxqual'=>'maxqual', + 'rconceal'=>'rconceal', + 'sconceal'=>'sconceal') + ); + $result['SCCP_Vendor'] = array('vendor' => strtok($result['skinnyphonetype'], ' '), 'model' => strtok('('), + 'model_id' => strtok(')'), 'vendor_addon' => strtok($result['configphonetype'], ' '), + 'model_addon' => strtok(' ')); if (empty($result['SCCP_Vendor']['vendor']) || $result['SCCP_Vendor']['vendor'] == 'Undefined') { - $result['SCCP_Vendor'] = Array('vendor' => 'Undefined', 'model' => $result['configphonetype'], - 'model_id' => '', 'vendor_addon' => $result['SCCP_Vendor']['vendor_addon'], + $result['SCCP_Vendor'] = array('vendor' => 'Undefined', 'model' => $result['configphonetype'], + 'model_id' => '', 'vendor_addon' => $result['SCCP_Vendor']['vendor_addon'], 'model_addon' => $result['SCCP_Vendor']['model_addon']); } $result['MAC_Address'] =$result['macaddress']; return $result; } - } -class ExtensionStateList_Response extends SCCPGeneric_Response { - public function __construct($rawContent) { +class ExtensionStateList_Response extends SCCPGeneric_Response +{ + public function __construct($rawContent) + { parent::__construct($rawContent); } - public function getResult() { - $result = $this->ConvertEventData(array('exten','context'),array('exten','context','hint','status','statustext')); + public function getResult() + { + $result = $this->ConvertEventData(array('exten','context'), array('exten','context','hint','status','statustext')); return $result; } } diff --git a/Sccp_manager.inc/aminterface/aminterface.class.php b/Sccp_manager.inc/aminterface/aminterface.class.php index d41fe50..a633d1c 100644 --- a/Sccp_manager.inc/aminterface/aminterface.class.php +++ b/Sccp_manager.inc/aminterface/aminterface.class.php @@ -1,17 +1,17 @@ 'Message.class.php', 'Response' => 'Response.class.php', 'Event' => 'Event.class.php'); @@ -37,7 +38,6 @@ class aminterface { $class = $driverNamespace . "\\" . $key; $driver = __DIR__ . "/" . $value; if (!class_exists($class, false)) { - if (file_exists($driver)) { include(__DIR__ . "/" . $value); } else { @@ -47,7 +47,8 @@ class aminterface { } } - public function __construct($parent_class = null) { + public function __construct($parent_class = null) + { global $amp_conf; $this->paren_class = $parent_class; $this->_socket = false; @@ -57,10 +58,10 @@ class aminterface { $this->_eventListeners = array(); -// $this->_eventFactory = new EventFactoryImpl(\Logger::getLogger('EventFactory')); -// $this->_responseFactory = new ResponseFactoryImpl(\Logger::getLogger('ResponseFactory')); - $this->_incomingQueue = array(); - $this->_lastActionId = false; +// $this->_eventFactory = new EventFactoryImpl(\Logger::getLogger('EventFactory')); +// $this->_responseFactory = new ResponseFactoryImpl(\Logger::getLogger('ResponseFactory')); + $this->_incomingQueue = array(); + $this->_lastActionId = false; $fld_conf = array('user' => 'AMPMGRUSER', 'pass' => 'AMPMGRPASS'); if (isset($amp_conf['AMPMGRUSER'])) { @@ -75,19 +76,23 @@ class aminterface { } } - public function status() { + public function status() + { if ($this->_config['enabled']) { return true; - } else {return false;} + } else { + return false; + } } - public function info() { + public function info() + { $Ver = '13.0.4'; if ($this->_config['enabled']) { - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'AMI data ver: ' . $Ver, 'test' => get_declared_classes()); } else { - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'Disabled AMI ver: ' . $Ver); } } @@ -96,15 +101,20 @@ class aminterface { * Opens a tcp connection to ami. * */ - public function open() { + public function open() + { $cString = $this->_config['tsoket'] . $this->_config['host'] . ':' . $this->_config['port']; $this->_context = stream_context_create(); $errno = 0; $errstr = ''; $this->_ProcessingMessage = ''; $this->_socket = @stream_socket_client( - $cString, $errno, $errstr, - $this->_config['timeout'], STREAM_CLIENT_CONNECT, $this->_context + $cString, + $errno, + $errstr, + $this->_config['timeout'], + STREAM_CLIENT_CONNECT, + $this->_context ); if ($this->_socket === false) { $this->_errorException('Error connecting to ami: ' . $errstr . $cString); @@ -129,13 +139,15 @@ class aminterface { /** * Closes the connection to ami. */ - public function close() { + public function close() + { $this->_connect_state = false; $this->_ProcessingMessage = ''; @stream_socket_shutdown($this->_socket, STREAM_SHUT_RDWR); } - public function send($message) { + public function send($message) + { $messageToSend = $message->serialize(); $length = strlen($messageToSend); $this->_countE = 0; @@ -171,7 +183,8 @@ class aminterface { $this->_errorException("Read waittime: " . ($this->socket_param['timeout']) . " exceeded (timeout).\n"); } - protected function getRelated($message) { + protected function getRelated($message) + { $ret = false; $id = 0; $id = $message->getActionID('ActionID'); @@ -185,11 +198,13 @@ class aminterface { return $ret; } - private function _messageToEvent($msg) { + private function _messageToEvent($msg) + { return $this->_eventFromRaw($msg); } - protected function getMessages() { + protected function getMessages() + { $msgs = array(); // Read something. $read = @fread($this->_socket, 65535); @@ -200,28 +215,30 @@ class aminterface { if ($read == "") { usleep(100); } else { - $this->_msgToDebug(98,'--- Not Empy AMI MSG --- '); + $this->_msgToDebug(98, '--- Not Empy AMI MSG --- '); } $this->_ProcessingMessage .= $read; $this->_DumpMessage .= $read; while (($marker = strpos($this->_ProcessingMessage, aminterface\Message::EOM))) { $msg = substr($this->_ProcessingMessage, 0, $marker); $this->_ProcessingMessage = substr( - $this->_ProcessingMessage, $marker + strlen(aminterface\Message::EOM) + $this->_ProcessingMessage, + $marker + strlen(aminterface\Message::EOM) ); $msgs[] = $msg; } return $msgs; } - public function process() { + public function process() + { $msgs = $this->getMessages(); - $this->_msgToDebug(90,$msgs); + $this->_msgToDebug(90, $msgs); $this->_countE++; if ($this->_countE > 10000) { - $this->_msgToDebug(9,'--- Procecc Die, Dump --- '); - $this->_msgToDebug(9,$this->_DumpMessage); - $this->_msgToDebug(9,'--- END Procecc Die, Dump --- '); + $this->_msgToDebug(9, '--- Procecc Die, Dump --- '); + $this->_msgToDebug(9, $this->_DumpMessage); + $this->_msgToDebug(9, '--- END Procecc Die, Dump --- '); die(); } foreach ($msgs as $aMsg) { @@ -230,13 +247,13 @@ class aminterface { if (($resPos !== false) && (($resPos < $evePos) || $evePos === false)) { $response = $this->_msgToResponse($aMsg); // resp Ok $this->_incomingQueue[$this->_lastActionId] = $response; - } else if ($evePos !== false) { + } elseif ($evePos !== false) { $event = $this->_messageToEvent($aMsg); // Event Ok - $this->_msgToDebug(99,'--- Response Type 2 --- '); - $this->_msgToDebug(99,$aMsg); - $this->_msgToDebug(99,'--- Event Response Type 2 --- '); - $this->_msgToDebug(99,$event); + $this->_msgToDebug(99, '--- Response Type 2 --- '); + $this->_msgToDebug(99, $aMsg); + $this->_msgToDebug(99, '--- Event Response Type 2 --- '); + $this->_msgToDebug(99, $event); if ($event != null) { $response = $this->findResponse($event); @@ -244,15 +261,15 @@ class aminterface { // print_r('
--- E2 Response Type 2 ----------
'); if ($response === false || $response->isComplete()) { - $this->dispatch($event); // не работает + $this->dispatch($event); // не работает } else { $response->addEvent($event); } } } else { // broken ami.. sending a response with events without - // Event and ActionId - $this->_msgToDebug(1,'resp broken ami'); + // Event and ActionId + $this->_msgToDebug(1, 'resp broken ami'); $bMsg = 'Event: ResponseEvent' . "\r\n"; $bMsg .= 'ActionId: ' . $this->_lastActionId . "\r\n" . $aMsg; $event = $this->_messageToEvent($bMsg); @@ -261,19 +278,20 @@ class aminterface { } } // print_r('
--- EProcecc ----------
'); - } - private function _msgToDebug($level, $msg) { + private function _msgToDebug($level, $msg) + { if ($level > $this->debug_level) { return; - } + } print_r('
level: '.$level.' '); print_r($msg); print_r('
'); } - private function _msgToResponse($msg) { + private function _msgToResponse($msg) + { // print_r("
------------hmsg----------
"); // print_r($this->_lastActionClass); // print_r($this->_lastRequestedResponseHandler); @@ -293,39 +311,42 @@ class aminterface { } /* - * - * + * + * */ - public function _msgFromRaw($message, $requestingaction = false, $responseHandler = false) { + public function _msgFromRaw($message, $requestingaction = false, $responseHandler = false) + { $_className = false; $responseclass = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\Generic_Response'; if ($responseHandler != false) { $_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . $responseHandler . '_Response'; - } else if ($requestingaction != false) { + } elseif ($requestingaction != false) { $_className = '\\FreePBX\\modules\\Sccp_manager\\' . substr(get_class($requestingaction), 20, -6) . '_Response'; } if ($_className) { if (class_exists($_className, true)) { $responseclass = $_className; - } else if ($responseHandler != false) { + } elseif ($responseHandler != false) { $this->_errorException('Response Class ' . $_className . ' requested via responseHandler, could not be found'); } } return new $responseclass($message); } - protected function _errorException($msg) { + protected function _errorException($msg) + { $this->_error[] = $msg; } /* - * Replace or dublicate to AMI interface + * Replace or dublicate to AMI interface */ - public function _eventFromRaw($message) { + public function _eventFromRaw($message) + { $eventStart = strpos($message, 'Event: ') + 7; if ($eventStart > strlen($message)) { @@ -344,31 +365,33 @@ class aminterface { return new $className($message); } - public function _respnceFromRaw($message, $requestingaction = false, $responseHandler = false) { + public function _respnceFromRaw($message, $requestingaction = false, $responseHandler = false) + { $responseclass = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\Response'; $_className = false; if ($responseHandler != false) { $_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . $responseHandler . '_Response'; - } else if ($requestingaction != false) { + } elseif ($requestingaction != false) { $_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . substr(get_class($requestingaction), 20, -6) . '_Response'; } if ($_className) { if (class_exists($_className, true)) { $responseclass = $_className; - } else if ($responseHandler != false) { + } elseif ($responseHandler != false) { throw new AMIException('Response Class ' . $_className . ' requested via responseHandler, could not be found'); } } -// if ($this->_logger->isDebugEnabled()) $this->_logger->debug('Created: ' . $responseclass . "\n"); +// if ($this->_logger->isDebugEnabled()) $this->_logger->debug('Created: ' . $responseclass . "\n"); print_r($responseclass); die(); return new $responseclass($message); } -// protected function findResponse(IncomingMessage $message) { - protected function findResponse($message) { +// protected function findResponse(IncomingMessage $message) { + protected function findResponse($message) + { $actionId = $message->getActionId(); if (isset($this->_incomingQueue[$actionId])) { return $this->_incomingQueue[$actionId]; @@ -376,7 +399,8 @@ class aminterface { return false; } - protected function dispatch($message) { + protected function dispatch($message) + { print_r("
------------dispatch----------
"); print_r($message); return false; @@ -391,25 +415,26 @@ class aminterface { } if ($listener instanceof \Closure) { $listener($message); - } else if (is_array($listener)) { + } elseif (is_array($listener)) { $listener[0]->$listener[1]($message); } else { $listener->handle($message); } } print_r("
------------E dispatch----------
"); - } //------------------------------------------------------------------------------- - function core_list_all_exten($keyfld = '', $filter = array()) { + function core_list_all_exten($keyfld = '', $filter = array()) + { $result = array(); return $result; } //-------------------Adaptive Function ------------------------------------------------------------ - function core_list_hints() { + function core_list_hints() + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\ExtensionStateListAction(); @@ -424,7 +449,8 @@ class aminterface { return $result; } - function core_list_all_hints() { + function core_list_all_hints() + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\ExtensionStateListAction(); @@ -439,7 +465,8 @@ class aminterface { return $result; } // --------------------- SCCP Comands - function sccp_list_keysets() { + function sccp_list_keysets() + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowSoftkeySetsAction(); @@ -451,7 +478,8 @@ class aminterface { } return $result; } - function sccp_get_active_device() { + function sccp_get_active_device() + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDevicesAction(); @@ -463,7 +491,8 @@ class aminterface { } return $result; } - function sccp_getdevice_info($devicename) { + function sccp_getdevice_info($devicename) + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDeviceAction($devicename); @@ -473,14 +502,15 @@ class aminterface { } return $result; } - function sccp_device_reset($devicename,$action = '') { + function sccp_device_reset($devicename, $action = '') + { if ($this->_connect_state) { if ($action == 'tokenack') { $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPTokenAckAction($devicename); } else { - $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPDeviceRestartAction($devicename,$action); + $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPDeviceRestartAction($devicename, $action); } - $_response = $this->send($_action); + $_response = $this->send($_action); $result['data'] = 'Device :'.$devicename.' Result: '.$_response->getMessage(); $result['Response']=$_response->getKey('Response'); // $result = $_response->getResult(); @@ -489,7 +519,8 @@ class aminterface { } //------------------- Core Comands ---- - function core_sccp_reload() { + function core_sccp_reload() + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\ReloadAction('chan_sccp'); @@ -499,7 +530,8 @@ class aminterface { } return $result; } - function getSCCPVersion() { + function getSCCPVersion() + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPConfigMetaDataAction(); @@ -509,7 +541,8 @@ class aminterface { return $result; } - function getRealTimeStatus() { + function getRealTimeStatus() + { $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\CommandAction('realtime mysql status'); @@ -523,5 +556,4 @@ class aminterface { } return $result; } - } diff --git a/Sccp_manager.inc/aminterface/oldinterface.class.php b/Sccp_manager.inc/aminterface/oldinterface.class.php index 54a9f22..e873cbb 100644 --- a/Sccp_manager.inc/aminterface/oldinterface.class.php +++ b/Sccp_manager.inc/aminterface/oldinterface.class.php @@ -10,18 +10,21 @@ namespace FreePBX\modules\Sccp_manager; -class oldinterface { +class oldinterface +{ var $error; - public function __construct($parent_class = null) { + public function __construct($parent_class = null) + { $this->paren_class = $parent_class; $this->error = ""; } - public function info() { + public function info() + { $Ver = '13.0.4'; - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'Old interface data ver: ' . $Ver); } @@ -34,7 +37,8 @@ class oldinterface { * Replace or dublicate to AMI interface */ - public function sccp_core_commands($params = array()) { + public function sccp_core_commands($params = array()) + { global $astman; $cmd_list = array('get_softkey' => array('cmd' => "sccp show softkeyssets", 'param' => ''), 'get_version' => array('cmd' => "sccp show version", 'param' => ''), @@ -77,7 +81,6 @@ class oldinterface { if (!empty($params['name'])) { $astman->Command('sccp device ' . $params['name'] . ' ' . $msg); } else { - } break; default: @@ -89,7 +92,8 @@ class oldinterface { return $result; } - public function sccp_getdevice_info($dev_id) { + public function sccp_getdevice_info($dev_id) + { if (empty($dev_id)) { return array(); } @@ -113,9 +117,9 @@ class oldinterface { } else { $res2 = ''; } - $res3['SCCP_Vendor'] = Array('vendor' => strtok($res1, ' '), 'model' => strtok('('), 'model_id' => strtok(')'), 'vendor_addon' => strtok($res2, ' '), 'model_addon' => strtok(' ')); + $res3['SCCP_Vendor'] = array('vendor' => strtok($res1, ' '), 'model' => strtok('('), 'model_id' => strtok(')'), 'vendor_addon' => strtok($res2, ' '), 'model_addon' => strtok(' ')); if (empty($res3['SCCP_Vendor']['vendor']) || $res3['SCCP_Vendor']['vendor'] == 'Undefined') { - $res3['SCCP_Vendor'] = Array('vendor' => 'Undefined', 'model' => $res4, 'model_id' => '', 'vendor_addon' => $res3['SCCP_Vendor']['vendor_addon'], 'model_addon' => $res3['SCCP_Vendor']['model_addon']); + $res3['SCCP_Vendor'] = array('vendor' => 'Undefined', 'model' => $res4, 'model_id' => '', 'vendor_addon' => $res3['SCCP_Vendor']['vendor_addon'], 'model_addon' => $res3['SCCP_Vendor']['model_addon']); // return $res4; // return array(); } @@ -130,7 +134,8 @@ class oldinterface { * A function should be used in the form of buttons for getting all hint. Not working. I don't know how to use properly. */ - public function sccp_list_hints() { + public function sccp_list_hints() + { $hint_key = array(); $hint_all = $this->sccp_list_all_hints(); foreach ($hint_all as $value) { @@ -143,7 +148,8 @@ class oldinterface { return $hint_key; } - public function sccp_list_all_hints() { + public function sccp_list_all_hints() + { $ast_out = $this->sccp_core_commands(array('cmd' => 'get_hints')); $ast_out = preg_split("/[\n]/", $ast_out['data']); $ast_key = array(); @@ -171,7 +177,8 @@ class oldinterface { return $ast_key; } - public function sccp_realtime_status() { + public function sccp_realtime_status() + { $ast_res = array(); $ast_out = $this->sccp_core_commands(array('cmd' => 'get_realtime_status')); $ast_out = preg_split("/[\n]/", $ast_out['data']); @@ -190,7 +197,8 @@ class oldinterface { // !TODO!: -TODO-: install.php is still using the other version number. This is actually where I use another method ? - public function get_compatible_sccp() { + public function get_compatible_sccp() + { $res = $this->getSCCPVersion(); if (empty($res)) { return 0; @@ -220,7 +228,8 @@ class oldinterface { // return $res["vCode"]; } - public function getSCCPVersion() { + public function getSCCPVersion() + { $res = $this->getChanSCCPVersion(); if (empty($res)) { $res = $this->getCoreSCCPVersion(); @@ -228,7 +237,8 @@ class oldinterface { return $res; } - function getCoreSCCPVersion() { + function getCoreSCCPVersion() + { $result = array(); $ast_out = $this->sccp_version(); $result["Version"] = $ast_out[0]; @@ -252,9 +262,10 @@ class oldinterface { return $result; } - private function sccp_version() { + private function sccp_version() + { $ast_out = $this->sccp_core_commands(array('cmd' => 'get_version')); - if ( ($ast_out['Response'] == 'Error') || (strpos($ast_out['data'], 'No such command') != false) ) { + if (($ast_out['Response'] == 'Error') || (strpos($ast_out['data'], 'No such command') != false)) { return array('-1'); } if (preg_match("/Release.*\(/", $ast_out['data'], $matches)) { @@ -265,7 +276,8 @@ class oldinterface { } } - function getChanSCCPVersion() { + function getChanSCCPVersion() + { global $astman; $result = array(); if (!$astman) { @@ -285,11 +297,9 @@ class oldinterface { $result["vCode"] = 400; if ($version_parts[1] == "1") { $result["vCode"] = 410; - } else - if ($version_parts[1] == "2") { + } elseif ($version_parts[1] == "2") { $result["vCode"] = 420; - } else - if ($version_parts[1] >= "3") { + } elseif ($version_parts[1] >= "3") { $result["vCode"] = 430; } } @@ -338,7 +348,8 @@ class oldinterface { return $result; } - public function sccp_list_keysets() { + public function sccp_list_keysets() + { $ast_out = $this->sccp_core_commands(array('cmd' => 'get_softkey')); $ast_out = preg_split("/[\n]/", $ast_out['data']); @@ -364,7 +375,8 @@ class oldinterface { return $ast_key; } - public function sccp_get_active_device() { + public function sccp_get_active_device() + { $ast_out = $this->sccp_core_commands(array('cmd' => 'get_device')); $ast_out = preg_split("/[\n]/", $ast_out['data']); @@ -397,7 +409,7 @@ class oldinterface { // list ($descr, $address, $devname, $status, $junk) = $line_arr; // if (strlen($ast_key[$devname]) < 1) { if (strlen($devname) > 1) { - $ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $address, 'descr' => $descr, 'token' => $token); + $ast_key[$devname] = array('name' => $devname, 'status' => $status, 'address' => $address, 'descr' => $descr, 'token' => $token); } /* if (isset($ast_key[$devname])) { @@ -418,7 +430,8 @@ class oldinterface { * Replace sccp_core_commands($params = array()) { */ - private function astman_retrieveJSFromMetaData($segment = "") { + private function astman_retrieveJSFromMetaData($segment = "") + { global $astman; $params = array(); if ($segment != "") { @@ -434,7 +447,8 @@ class oldinterface { } } - private function strpos_array($haystack, $needles) { + private function strpos_array($haystack, $needles) + { if (is_array($needles)) { foreach ($needles as $str) { if (is_array($str)) { @@ -442,22 +456,25 @@ class oldinterface { } else { $pos = strpos($haystack, $str); } - if ($pos !== FALSE) { + if ($pos !== false) { return $pos; } } } else { return strpos($haystack, $needles); } - return FALSE; + return false; } - private function loc_after($value, $inthat) { - if (!is_bool(strpos($inthat, $value))) + private function loc_after($value, $inthat) + { + if (!is_bool(strpos($inthat, $value))) { return substr($inthat, strpos($inthat, $value) + strlen($value)); + } } - function getеtestChanSCC() { + function getеtestChanSCC() + { global $astman; // $action = Array('SCCPShowGlobals',); $params = array(); @@ -472,7 +489,8 @@ class oldinterface { /* * [Segments] => ( [0] => general [1] => device [2] => line [3] => softkey ) */ - function getеtestChanSCCP_GlablsInfo($Segment = '') { + function getеtestChanSCCP_GlablsInfo($Segment = '') + { global $astman; $params = array(); @@ -498,5 +516,4 @@ class oldinterface { } return $metadata; } - } diff --git a/Sccp_manager.inc/dbinterface.class.php b/Sccp_manager.inc/dbinterface.class.php index 8173022..9c6f144 100644 --- a/Sccp_manager.inc/dbinterface.class.php +++ b/Sccp_manager.inc/dbinterface.class.php @@ -1,35 +1,39 @@ paren_class = $parent_class; + public function __construct($parent_class = null) + { + $this->paren_class = $parent_class; } - public function info() { + public function info() + { $Ver = '13.0.2'; - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'Data access interface ver: ' . $Ver); } /* * Core Access Function */ - public function get_db_SccpTableByID($dataid, $data = array(), $indexField = '') { + public function get_db_SccpTableByID($dataid, $data = array(), $indexField = '') + { $resut = array(); $raw = $this->get_db_SccpTableData($dataid, $data); - if ( empty($raw) || empty($indexField)) { + if (empty($raw) || empty($indexField)) { return $raw; } foreach ($raw as $value) { @@ -39,9 +43,10 @@ class dbinterface { return $resut; } - public function get_db_SccpTableData($dataid, $data = array()) { + public function get_db_SccpTableData($dataid, $data = array()) + { if ($dataid == '') { - return False; + return false; } switch ($dataid) { case "SccpExtension": @@ -49,7 +54,8 @@ class dbinterface { $sql = "SELECT * FROM `sccpline` ORDER BY `name`"; $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); } else { - $sql = "SELECT * FROM `sccpline` WHERE `name`='" . $data['name']. "'";; + $sql = "SELECT * FROM `sccpline` WHERE `name`='" . $data['name']. "'"; + ; $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); } break; @@ -72,7 +78,8 @@ class dbinterface { } } if (!empty($data['name'])) { - $filtred = "`name`='" . $data['name']. "'";; + $filtred = "`name`='" . $data['name']. "'"; + ; $singlrow = true; } if (!empty($data['type'])) { @@ -141,7 +148,7 @@ class dbinterface { $sql = 'SELECT * FROM sccpbuttonconfig WHERE ' .$sql. 'ORDER BY `instance`;'; $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); } else { - $raw_settings = Array(); + $raw_settings = array(); } break; } @@ -149,13 +156,15 @@ class dbinterface { return $raw_settings; } - public function get_db_SccpSetting() { + public function get_db_SccpSetting() + { $sql = "SELECT `keyword`, `data`, `type`, `seq` FROM `sccpsettings` ORDER BY `type`, `seq`"; $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); return $raw_settings; } - public function get_db_sysvalues() { + public function get_db_sysvalues() + { $sql = "SHOW VARIABLES LIKE '%group_concat%'"; $raw_settings = sql($sql, "getRow", DB_FETCHMODE_ASSOC); return $raw_settings; @@ -165,7 +174,8 @@ class dbinterface { * Get Sccp Device Model information */ - function getDb_model_info($get = "all", $format_list = "all", $filter = array()) { + function getDb_model_info($get = "all", $format_list = "all", $filter = array()) + { global $db; switch ($format_list) { case "model": @@ -230,8 +240,9 @@ class dbinterface { return $raw_settings; } - function sccp_save_db($db_name = "", $save_value = array(), $mode = 'update', $key_fld = "", $hwid = "") { - // mode clear - Empty tabele before update + function sccp_save_db($db_name = "", $save_value = array(), $mode = 'update', $key_fld = "", $hwid = "") + { + // mode clear - Empty tabele before update // mode update - update / replace record global $db; // global $amp_conf; @@ -315,42 +326,44 @@ class dbinterface { /* * My be Replace by SccpTables ??! - * + * */ - public function dump_sccp_tables($data_path, $database, $user, $pass ) { + public function dump_sccp_tables($data_path, $database, $user, $pass) + { $filename = $data_path.'/sccp_backup_'.date('G_a_m_d_y').'.sql'; - $result = exec('mysqldump '.$database.' --password='.$pass.' --user='.$user.' --single-transaction >'.$filename ,$output); + $result = exec('mysqldump '.$database.' --password='.$pass.' --user='.$user.' --single-transaction >'.$filename, $output); return $filename; } /* - * Check Table structure + * Check Table structure */ - public function validate() { + public function validate() + { global $db; $check_fields = array('430' => array('_hwlang' => "varchar(12)"), '431' => array('private'=> "enum('on','off')"), '433' => array('directed_pickup'=>'') ); $sql = "DESCRIBE `sccpdevice`;"; $raw_result = sql($sql, "getAll", DB_FETCHMODE_ASSOC); $result = 0; foreach ($raw_result as $value) { - $id_result[$value['Field']] = $value['Type']; + $id_result[$value['Field']] = $value['Type']; } foreach ($check_fields as $key => $value) { - $sub_result = true; - foreach($value as $skey => $svalue) { - if (!empty($svalue) ) { - if (empty($id_result[$skey])) { - $sub_result = false; + $sub_result = true; + foreach ($value as $skey => $svalue) { + if (!empty($svalue)) { + if (empty($id_result[$skey])) { + $sub_result = false; + } else { + if (strtolower($id_result[$skey]) != strtolower($svalue)) { + $sub_result = false; + } + } } else { - if (strtolower($id_result[$skey]) != strtolower($svalue)) { + if (!empty($id_result[$skey])) { $sub_result = false; } - } - } else { - if (!empty($id_result[$skey])) { - $sub_result = false; } - } } if ($sub_result) { $result = $key; @@ -361,5 +374,4 @@ class dbinterface { return $result; } - } diff --git a/Sccp_manager.inc/extconfigs.class.php b/Sccp_manager.inc/extconfigs.class.php index 4643f3a..7e4f178 100644 --- a/Sccp_manager.inc/extconfigs.class.php +++ b/Sccp_manager.inc/extconfigs.class.php @@ -1,24 +1,28 @@ paren_class = $parent_class; } - public function info() { + public function info() + { $Ver = '13.0.3'; - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'Default Setings and Enums ver: ' . $Ver); } - public function getextConfig($id = '', $index = '') { + public function getextConfig($id = '', $index = '') + { switch ($id) { case 'keyset': $result = $this->keysetdefault; @@ -29,7 +33,7 @@ class extconfigs { case 'sccpDefaults': $result = $this->sccpDefaults; break; - case 'sccp_timezone_offset': // Sccp manafer: 1400 (+ Id) :2007 (+ Id) + case 'sccp_timezone_offset': // Sccp manafer: 1400 (+ Id) :2007 (+ Id) if (empty($index)) { return 0; } @@ -43,7 +47,7 @@ class extconfigs { return $tmp_ofset / 60; break; - case 'sccp_timezone': // Sccp manafer: 1400 (+ Id) :2007 (+ Id) + case 'sccp_timezone': // Sccp manafer: 1400 (+ Id) :2007 (+ Id) $result = array(); if (empty($index)) { @@ -56,10 +60,10 @@ class extconfigs { $tz_tmp = array(); foreach ($timezone_abbreviations as $subArray) { - $tf_idt = array_search($index ,array_column($subArray, 'timezone_id')); + $tf_idt = array_search($index, array_column($subArray, 'timezone_id')); if (!empty($tf_idt)) { $tz_tmp[] = $subArray[$tf_idt]; - } + } } if (empty($tz_tmp)) { return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich'); @@ -72,7 +76,7 @@ class extconfigs { $tmp_ofset = $tmp_dt->getOffset(); foreach ($tz_tmp as $subArray) { if ($subArray['offset'] == $tmp_ofset) { - $time_set = $subArray; + $time_set = $subArray; break; } } @@ -103,9 +107,10 @@ class extconfigs { } } - private function get_cisco_time_zone($tzc){ + private function get_cisco_time_zone($tzc) + { - if ( (empty($tzc)) or (!array_key_exists($tzc, $this->cisco_timezone))) { + if ((empty($tzc)) or (!array_key_exists($tzc, $this->cisco_timezone))) { // return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich'); return array(); } @@ -259,35 +264,36 @@ class extconfigs { 'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight') ); - public function validate_init_path($confDir = '', $db_vars, $sccp_driver_replace = '') { + public function validate_init_path($confDir = '', $db_vars, $sccp_driver_replace = '') + { // global $db; // global $amp_conf; -// *** Setings for Provision Sccp - $adv_config = Array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings', +// *** Setings for Provision Sccp + $adv_config = array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings', 'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates', 'dialplan' => 'dialplan', 'softkey' => 'softkey'); -// 'pro' /tftpboot - root dir +// 'pro' /tftpboot - root dir // /tftpboot/locales/locales/%Languge_name% // /tftpboot/settings/XMLdefault.cnf.xml // /tftpboot/settings/SEP[MAC].cnf.xml // /tftpboot/firmware/79xx/SCCPxxxx.loads - $adv_tree['pro'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales', 'dialplan' => 'tftproot', 'softkey' => 'tftproot'); + $adv_tree['pro'] = array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales', 'dialplan' => 'tftproot', 'softkey' => 'tftproot'); -// 'def' /tftpboot - root dir +// 'def' /tftpboot - root dir // /tftpboot/languages/%Languge_name% // /tftpboot/XMLdefault.cnf.xml // /tftpboot/SEP[MAC].cnf.xml // /tftpboot/SCCPxxxx.loads - $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => '', 'firmware' => '', 'languages' => 'tftproot', 'dialplan' => '', 'softkey' => ''); + $adv_tree['def'] = array('templates' => 'tftproot', 'settings' => '', 'locales' => '', 'firmware' => '', 'languages' => 'tftproot', 'dialplan' => '', 'softkey' => ''); // $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => ''); // $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'tftproot'); -//* **************------ **** - $base_tree = Array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware', 'tftp_dialplan' => 'dialplan', 'tftp_softkey' => 'softkey'); +//* **************------ **** + $base_tree = array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware', 'tftp_dialplan' => 'dialplan', 'tftp_softkey' => 'softkey'); if (empty($confDir)) { return array('error' => 'empty СonfDir'); } - $base_config = Array('asterisk' => $confDir, 'sccp_conf' => $confDir . '/sccp.conf', 'tftp_path' => ''); + $base_config = array('asterisk' => $confDir, 'sccp_conf' => $confDir . '/sccp.conf', 'tftp_path' => ''); // Test Base dir (/tftproot) if (!empty($db_vars["tftp_path"])) { @@ -371,7 +377,7 @@ class extconfigs { } } */ - // TFTP -REWrite double model + // TFTP -REWrite double model if (empty($_SERVER['DOCUMENT_ROOT'])) { if (!empty($this->paren_class)) { $this->paren_class->class_error['DOCUMENT_ROOT'] = 'Empty DOCUMENT_ROOT'; @@ -400,7 +406,7 @@ class extconfigs { } } - if (!file_exists($base_config["sccp_conf"])) { // System re Config + if (!file_exists($base_config["sccp_conf"])) { // System re Config $sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf'); file_put_contents($base_config["sccp_conf"], $sccpfile); } @@ -408,9 +414,10 @@ class extconfigs { return $base_config; } - public function validate_RealTime($realm = '') { + public function validate_RealTime($realm = '') + { global $amp_conf; - $res = Array(); + $res = array(); if (empty($realm)) { $realm = 'sccp'; } @@ -504,5 +511,4 @@ class extconfigs { } return $res; } - } diff --git a/Sccp_manager.inc/sipconfigs.class.php b/Sccp_manager.inc/sipconfigs.class.php index 339828b..92945b5 100644 --- a/Sccp_manager.inc/sipconfigs.class.php +++ b/Sccp_manager.inc/sipconfigs.class.php @@ -1,31 +1,35 @@ paren_class = $parent_class; // $freepbx // $this->database = $freepbx->Database; } - public function info() { + public function info() + { $Ver = '13.0.4'; - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'Sip Setings ver: ' . $Ver); } - public function get_db_sip_TableData($dataid, $data = array()) { + public function get_db_sip_TableData($dataid, $data = array()) + { global $db; if ($dataid == '') { - return False; + return false; } switch ($dataid) { case "Device": @@ -40,7 +44,6 @@ class sipconfigs { $tech[$value['id']][$value['keyword']]=$value['data']; } } catch (\Exception $e) { - } return $tech; case "DeviceById": @@ -55,14 +58,13 @@ class sipconfigs { $value = $value[0]; } } catch (\Exception $e) { - } return $tech; } - } - public function getSipConfig() { + public function getSipConfig() + { $result = array(); // $def_sip_proto = 'sip'; // $def_proto = 'tcp'; @@ -74,17 +76,17 @@ class sipconfigs { $tmp_binds = \FreePBX::Sipsettings()->getBinds(); $if_list = $this->paren_class ->getIP_information2('ip4'); -/* +/* $tmp_bind_ip = !empty($tmp_sipsetigs['externhost_val']) ? $tmp_sipsetigs['externhost_val'] : ''; $tmp_bind_ip = !empty($tmp_sipsetigs['externip_val']) ? $tmp_sipsetigs['externip_val'] : $tmp_bind_ip; $tmp_bind_ip = !empty($tmp_sipsetigs['bindaddr']) ? $tmp_sipsetigs['bindaddr'] : $tmp_bind_ip; - */ + */ $tmp_binds = is_array($tmp_binds) ? $tmp_binds: array(); $result = array(); - foreach($tmp_binds as $f_protocol => $f_bind) { - foreach($f_bind as $f_ip => $f_port) { + foreach ($tmp_binds as $f_protocol => $f_bind) { + foreach ($f_bind as $f_ip => $f_port) { if (($f_ip == '0.0.0.0') || ($f_ip == '[::]')) { - foreach($if_list as $f_if => $f_data) { + foreach ($if_list as $f_if => $f_data) { if ($f_data['ip'] == "127.0.0.1") { continue; } @@ -104,7 +106,7 @@ class sipconfigs { $def_proto = 'pjsip'; } return $result; - + foreach ($tmp_sip_binds[$def_sip_proto] as $key => $value) { if (empty($value[$def_proto])) { $def_proto = 'udp'; @@ -119,10 +121,10 @@ class sipconfigs { $tmp_bind_ip = $key; } $result['sipbindport'] = $value[$def_proto]; - } + } $result['sipbind'] = $tmp_bind_ip; $result['sipsuportproto'] = $supp_proto; - + $binds= array(); $driver = \FreePBX::Config()->get_conf_setting('ASTSIPDRIVER'); if ($driver == "both" || $driver == "chan_pjsip") { @@ -145,13 +147,13 @@ class sipconfigs { } else { $binds['pjsip'] = array("0.0.0.0" => array()); } - + $result['nd'] = $driver; - + $result['nb'] = $binds; $result['nb2'] = $b; return $result; - * + * */ } } diff --git a/Sccp_manager.inc/srvinterface.class.php b/Sccp_manager.inc/srvinterface.class.php index 33eb96b..c2b77eb 100644 --- a/Sccp_manager.inc/srvinterface.class.php +++ b/Sccp_manager.inc/srvinterface.class.php @@ -10,13 +10,15 @@ namespace FreePBX\modules\Sccp_manager; -class srvinterface { +class srvinterface +{ var $error; var $_info; var $ami_mode; - public function __construct($parent_class = null) { + public function __construct($parent_class = null) + { $this->paren_class = $parent_class; if ($this->paren_class == null) { $this->paren_class = $this; @@ -49,17 +51,19 @@ class srvinterface { $this->ami_mode = $this->aminterface->status(); } - public function info() { + public function info() + { $Ver = '14.0.1'; $info = ''; foreach ($this->_info as $key => $value) { $info .= $value['about'] . "\n "; } - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'Server interface data ver: ' . $Ver . "\n " . $info); } - public function sccp_device_reset($id = '') { + public function sccp_device_reset($id = '') + { if ($this->ami_mode) { return $this->aminterface->sccp_device_reset($id, 'reset'); } else { @@ -67,7 +71,8 @@ class srvinterface { } } - public function sccp_device_restart($id = '') { + public function sccp_device_restart($id = '') + { if ($this->ami_mode) { return $this->aminterface->sccp_device_reset($id, 'restart'); } else { @@ -75,7 +80,8 @@ class srvinterface { } } - public function sccp_device_reload($id = '') { + public function sccp_device_reload($id = '') + { if ($this->ami_mode) { return $this->aminterface->sccp_device_reset($id, 'full'); } else { @@ -83,7 +89,8 @@ class srvinterface { } } - public function sccp_reset_token($id = '') { + public function sccp_reset_token($id = '') + { if ($this->ami_mode) { return $this->aminterface->sccp_device_reset($id, 'tokenack'); } else { @@ -91,16 +98,18 @@ class srvinterface { } } - public function sccp_reload() { + public function sccp_reload() + { if ($this->ami_mode) { return $this->aminterface->core_sccp_reload(); -// return $this->oldinterface->sccp_core_commands(array('cmd' => 'sccp_reload')); // !!!!!!!!!!!!!!!!!!!!!!!!!--------------------------- Remove +// return $this->oldinterface->sccp_core_commands(array('cmd' => 'sccp_reload')); // !!!!!!!!!!!!!!!!!!!!!!!!!--------------------------- Remove } else { return $this->oldinterface->sccp_core_commands(array('cmd' => 'sccp_reload')); } } - public function sccp_line_reload($id = '') { + public function sccp_line_reload($id = '') + { if ($this->ami_mode) { return $this->oldinterface->sccp_core_commands(array('cmd' => 'reload_line', 'name' => $id)); } else { @@ -108,7 +117,8 @@ class srvinterface { } } - private function sccp_core_commands($params = array()) { + private function sccp_core_commands($params = array()) + { if ($this->ami_mode) { if (!empty($params['cmd'])) { @@ -133,7 +143,7 @@ class srvinterface { // break; // case 'get_realtime_status': // break; -// case 'phone_call': +// case 'phone_call': // case 'phone_message': case 'get_softkey': @@ -154,7 +164,8 @@ class srvinterface { } } - public function sccp_getdevice_info($dev_id) { + public function sccp_getdevice_info($dev_id) + { if (empty($dev_id)) { return array(); } @@ -165,7 +176,8 @@ class srvinterface { } } - public function sccp_list_hints() { + public function sccp_list_hints() + { if ($this->ami_mode) { return $this->aminterface->core_list_hints(); } else { @@ -173,7 +185,8 @@ class srvinterface { } } - public function sccp_list_all_hints() { + public function sccp_list_all_hints() + { if ($this->ami_mode) { return $this->aminterface->core_list_all_hints(); @@ -182,7 +195,8 @@ class srvinterface { } } - public function sccp_realtime_status() { + public function sccp_realtime_status() + { if (!$this->ami_mode) { return $this->oldinterface->sccp_realtime_status(); } else { @@ -199,7 +213,8 @@ class srvinterface { } } - public function get_compatible_sccp() { + public function get_compatible_sccp() + { $res = $this->getSCCPVersion(); if (empty($res)) { @@ -230,7 +245,8 @@ class srvinterface { // return $res["vCode"]; } - public function getSCCPVersion() { + public function getSCCPVersion() + { $res = $this->getChanSCCPVersion(); if (empty($res)) { $res = $this->oldinterface->getCoreSCCPVersion(); @@ -238,7 +254,8 @@ class srvinterface { return $res; } - public function sccp_list_keysets() { + public function sccp_list_keysets() + { if ($this->ami_mode) { return $this->aminterface->sccp_list_keysets(); @@ -247,7 +264,8 @@ class srvinterface { } } - public function sccp_get_active_device() { + public function sccp_get_active_device() + { if ($this->ami_mode) { return $this->aminterface->sccp_get_active_device(); } else { @@ -255,7 +273,8 @@ class srvinterface { } } - function getChanSCCPVersion() { + function getChanSCCPVersion() + { if (!$this->ami_mode) { return $this->oldinterface->getChanSCCPVersion(); } else { @@ -274,7 +293,7 @@ class srvinterface { case "2": $result["vCode"] = 420; break; - case 3. . .5 : + case 3. . .5: $result["vCode"] = 430; break; default: @@ -318,7 +337,8 @@ class srvinterface { } // ---------------------------- Debug Data ------------------------------------------- - function t_get_ami_data() { + function t_get_ami_data() + { global $amp_conf; $fp = fsockopen("127.0.0.1", "5038", $errno, $errstr, 10); if (!$fp) { @@ -336,12 +356,12 @@ class srvinterface { // fputs($fp,"DeviceName: SEP00070E36555C\r\n"); // fputs ($fp,"Action: DeviceStateList\r\n"); - fputs ($fp,"Action: SCCPShowDevices\r\n"); - fputs($fp,"Segment: general\r\n"); + fputs($fp, "Action: SCCPShowDevices\r\n"); + fputs($fp, "Segment: general\r\n"); // fputs ($fp,"Action: SCCPShowDevice\r\n"); // fputs ($fp,"DeviceName: SEP00070E36555C\r\n"); -// +// // fputs($fp, "Action: ExtensionStateList\r\n"); // fputs($fp, "Action: ExtensionStateList\r\n"); // fputs($fp, "Command: sccp show version\r\n"); @@ -391,5 +411,4 @@ class srvinterface { fclose($fp); return $resp; } - } diff --git a/Sccp_manager.inc/xmlinterface.class.php b/Sccp_manager.inc/xmlinterface.class.php index d1002f1..42a97d2 100644 --- a/Sccp_manager.inc/xmlinterface.class.php +++ b/Sccp_manager.inc/xmlinterface.class.php @@ -1,33 +1,37 @@ paren_class = $parent_class; } - public function info() { + public function info() + { $Ver = '13.0.4'; - return Array('Version' => $Ver, + return array('Version' => $Ver, 'about' => 'Create XML data interface ver: ' . $Ver); } - function create_default_XML($store_path = '', $data_values = array(), $model_information = array(), $lang_info = array()) { + function create_default_XML($store_path = '', $data_values = array(), $model_information = array(), $lang_info = array()) + { $data_path = $data_values['tftp_path']; if (empty($store_path) || empty($data_path) || empty($data_values)) { return; @@ -88,7 +92,7 @@ class xmlinterface { $xnode->name = ''; $xnode->langCode = ''; } -// $this -> replaceSimpleXmlNode($xml_work->$key,$xnode); +// $this -> replaceSimpleXmlNode($xml_work->$key,$xnode); break; case 'networkLocale': $lang = $data_values['netlang']; @@ -99,7 +103,7 @@ class xmlinterface { } break; } - //$this-> replaceSimpleXmlNode($xml_work->$value, $xnode ); + //$this-> replaceSimpleXmlNode($xml_work->$value, $xnode ); } } @@ -113,7 +117,8 @@ class xmlinterface { } } - function create_SEP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) { + function create_SEP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) + { $var_xml_general_fields = array('authenticationURL' => 'dev_authenticationURL', 'informationURL' => 'dev_informationURL', 'messagesURL' => 'dev_messagesURL', 'servicesURL' => 'dev_servicesURL', 'directoryURL' => 'dev_directoryURL', 'proxyServerURL' => 'dev_proxyServerURL', 'idleTimeout' => 'dev_idleTimeout', @@ -282,7 +287,7 @@ class xmlinterface { $xnode_obj->processNodeName = $data_values['bindaddr']; } break; - * + * */ } } @@ -292,7 +297,7 @@ class xmlinterface { $xml_work->$key = time(); break; case 'loadInformation': -// Set Path Image ???? +// Set Path Image ???? if (isset($dev_config["tftp_firmware"])) { $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; } else { @@ -365,14 +370,15 @@ class xmlinterface { } // print_r($xml_work); - $xml_work->asXml($xml_name); // Save + $xml_work->asXml($xml_name); // Save } else { die('Error Hardware template :' . $xml_template . ' not found'); } return time(); } - private function get_server_sccp_bind($data_values = array()) { + private function get_server_sccp_bind($data_values = array()) + { $res = array(); if ($data_values['bindaddr'] !== '0.0.0.0') { return array('ip' => $data_values['bindaddr'], 'port' => $data_values['port']); @@ -450,10 +456,11 @@ class xmlinterface { } return $res; } - * + * */ - function create_SEP_SIP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) { + function create_SEP_SIP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) + { $var_xml_general_fields = array('authenticationURL' => 'dev_authenticationURL', 'informationURL' => 'dev_informationURL', 'messagesURL' => 'dev_messagesURL', 'servicesURL' => 'dev_servicesURL', 'directoryURL' => 'dev_directoryURL', 'proxyServerURL' => 'dev_proxyServerURL', 'idleTimeout' => 'dev_idleTimeout', @@ -669,7 +676,7 @@ class xmlinterface { //$xnode = null; break; case 'softKeyFile': - case 'dialTemplate': // Доработать ! + case 'dialTemplate': // Доработать ! $xml_ext_file = ''; $templet_path = (($dkey == 'softKeyFile') ? $dev_config['tftp_softkey'] : $dev_config['tftp_dialplan']); $tmp_key = ($dkey == 'softKeyFile') ? 'softkeyset' : '_dialrules'; @@ -696,7 +703,7 @@ class xmlinterface { $xml_work->$key = time(); break; case 'loadInformation': -// Set Path Image ???? +// Set Path Image ???? if (isset($dev_config["tftp_firmware"])) { $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; } else { @@ -764,17 +771,18 @@ class xmlinterface { } // print_r($xml_work); - $xml_work->asXml($xml_name); // Save + $xml_work->asXml($xml_name); // Save } else { die('Error Hardware template :' . $xml_template . ' not found'); } return time(); } - function save_DialPlan($confDir, $get_settings) { + function save_DialPlan($confDir, $get_settings) + { $xmlstr = "\n"; $xmlstr .= "" . time() . "\n"; - $dialFelds = array('match', 'timeout', 'rewrite', 'tone'); //str -to lo ! + $dialFelds = array('match', 'timeout', 'rewrite', 'tone'); //str -to lo ! $hdr_prefix = 'sccp_dial_'; $hdr_arprefix = 'sccp_dial-ar_'; @@ -787,7 +795,7 @@ class xmlinterface { foreach ($dialFelds as $fld) { if (isset($value[$fld])) { if ($value[$fld] == 'empty' || $value[$fld] == '') { -// +// } else { $xmlstr .= ' ' . $fld . '="' . (string) $value[$fld] . '"'; } @@ -806,8 +814,9 @@ class xmlinterface { } else { $errors = array('Fields Dial Plan Name is requered !!'); } - } else + } else { $put_file = (string) $get_settings['idtemplate']; + } } else { $errors = array('Fields Dial Plan Name is requered !!'); } @@ -822,7 +831,8 @@ class xmlinterface { return $errors; } - function create_xmlSoftkeyset($config, $confDir, $name) { + function create_xmlSoftkeyset($config, $confDir, $name) + { if (empty($config[$name])) { if ($name == 'default') { $typeSoft = $confDir["tftp_templates"] . '/SIPDefaultSoftKey.xml_template'; @@ -872,22 +882,25 @@ class xmlinterface { return $errors; } - private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement) { + private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement) + { $dom = dom_import_simplexml($xml); $import = $dom->ownerDocument->importNode( - dom_import_simplexml($element), TRUE + dom_import_simplexml($element), + true ); $dom->parentNode->replaceChild($import, $dom); } - private function appendSimpleXmlNode($xml, $element = SimpleXMLElement) { + private function appendSimpleXmlNode($xml, $element = SimpleXMLElement) + { $dom = dom_import_simplexml($xml); $import = $dom->ownerDocument->importNode( - dom_import_simplexml($element), TRUE + dom_import_simplexml($element), + true ); -// $dom->parentNode->appendChild($import, $dom); +// $dom->parentNode->appendChild($import, $dom); $dom->parentNode->appendChild($import->cloneNode(true)); } - } diff --git a/assets/css/sccp_manager.css b/assets/css/sccp_manager.css index 4e9eb12..0d64c6c 100644 --- a/assets/css/sccp_manager.css +++ b/assets/css/sccp_manager.css @@ -3,7 +3,7 @@ To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. */ -/* +/* Created on : 03.05.2017, 16:13:49 Author : Alex */ diff --git a/assets/js/jquery.selectlistactions.js b/assets/js/jquery.selectlistactions.js index afbfe2f..7dffe0e 100644 --- a/assets/js/jquery.selectlistactions.js +++ b/assets/js/jquery.selectlistactions.js @@ -1,11 +1,4 @@ -/** - * jQuery.SelectListActions - * https://github.com/esausilva/jquery.selectlistactions.js - * - * (c) http://esausilva.com - */ - -(function ($) { +(function ($) { //Moves selected item(s) from sourceList to destinationList $.fn.moveToList = function (sourceList, destinationList) { var opts = $(sourceList + ' option:selected'); diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index ce0a133..b8502ff 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -26,13 +26,13 @@ $(document).ready(function () { }); /* - $('#ajaxbackup').on('click', function (e) { + $('#ajaxbackup').on('click', function (e) { var vdata = ''; var snd_command = 'backupsettings'; $('.fpbx-submit').each(function () { vdata = vdata + $(this).serialize() + '&'; }); - + $.ajax({ type: 'POST', url: 'ajax.php?module=sccp_manager&command=' + snd_command, @@ -42,7 +42,7 @@ $(document).ready(function () { if (data.message) { alert(data.message); } else { - alert('Data Save'); + alert('Data Save'); } } else { if (Array.isArray(data.message)) { @@ -53,7 +53,7 @@ $(document).ready(function () { } } }); - + }); */ $('#ajaxsubmit2').on('click', function (e) { @@ -140,7 +140,6 @@ $(document).ready(function () { if (data.reload === true && old_style ===true ) { location.reload(); } - } else { bs_alert(data.message,data.status); } @@ -248,7 +247,7 @@ $(document).ready(function () { var kid = $(this).data('id'); var kval = $(this).val(); $('.lineid_' + kid).each(function () { - var lval = $(this).data('type'); + var lval = $(this).data('type'); if (lval == 'featurep') { if ( kval == 'parkinglot') { $(this).removeClass('hidden'); @@ -264,7 +263,7 @@ $(document).ready(function () { var kid = $(this).data('id'); var kval = $(this).val(); $('.lineid_' + kid).each(function () { - var lval = $(this).data('type'); + var lval = $(this).data('type'); var class_id = [kval]; switch (kval) { case 'silent': @@ -278,9 +277,9 @@ $(document).ready(function () { case 'service': case 'feature': if (lval == 'featurep') { - if ($('.futuretype').val() == 'parkinglot') { - class_id = [kval,lval]; - } + if ($('.futuretype').val() == 'parkinglot') { + class_id = [kval,lval]; + } } break; case 'speeddial': @@ -311,7 +310,6 @@ $(document).ready(function () { $('#sccp_hw_addon').val('NONE').change(); } $('#sccp_hw_addon').attr("disabled", "disabled"); - } else { $('#sccp_hw_addon').removeAttr('disabled'); } @@ -328,7 +326,8 @@ $(document).ready(function () { }); - $('.sccp_button_hide').each(function () { // On page create !! + $('.sccp_button_hide').each(function () { + // On page create !! var dev_id = $(this).data('vhide'); var dev_class = $(this).data('clhide'); var dev_val = $(this).val(); @@ -391,7 +390,8 @@ $(document).ready(function () { }); - $('.sccp_button_disabled').each(function () { // On page create !! + $('.sccp_button_disabled').each(function () { + // On page create !! var dev_id = $(this).data('vhide'); var dev_class = $(this).data('clhide'); var dev_val = $(this).val(); @@ -466,7 +466,7 @@ $(document).ready(function () { if (dev_class.includes('validate-netmask')) { confirm(dev_id); } -// confirm(dev_id); +// confirm(dev_id); }); $('.sccp_test').on('click', function (e) { @@ -507,7 +507,7 @@ $(document).ready(function () { // console.log($(this).data('id')); // ----------------------- Server.keyset form ---------------- -// +// if ($(this).data('id') === 'keyset_add') { var dev_cmd = 'updateSoftKey'; if ($(this).data('mode') === 'new') { @@ -584,7 +584,6 @@ $(document).ready(function () { }); } console.log(datas); - } if ($(this).data('id') === 'delete_hardware') { var dev_cmd = $(this).data('id'); @@ -603,7 +602,6 @@ $(document).ready(function () { if (!confirm(_('Are you sure you wish to delete selected device ?'))) { dev_cmd = ''; } - } if ($(this).data('id') === 'reset_dev' || $(this).data('id') === 'reset_token' || $(this).data('id') === 'update_button_label') { var dev_cmd = $(this).data('id'); @@ -636,11 +634,9 @@ $(document).ready(function () { } else { dev_cmd = ''; } - } } if (dev_cmd !== '') { - $.ajax({ type: 'POST', url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, @@ -655,7 +651,7 @@ $(document).ready(function () { $('table').bootstrapTable('refresh'); } if (data.reload === true && old_style === true) { - location.reload(); + location.reload(); } } else { if (Array.isArray(data.message)) { @@ -676,7 +672,6 @@ $(document).ready(function () { } }); - } }); @@ -690,14 +685,14 @@ $(document).ready(function () { -//$("table").on('click-cell.bs.table', function (field, value, row, $element) { +//$("table").on('click-cell.bs.table', function (field, value, row, $element) { // var id_fld=$element['model']; Работает ! // console.log('Table test: '+ id_fld); // $('#bt'+id_fld).removeAttr('hidden'); //}); -// Bootstrap table Enabled / Disabled buttons ( class="btn-tab-select") +// Bootstrap table Enabled / Disabled buttons ( class="btn-tab-select") $("table").on('check-all.bs.table', function (rows) { var id_fld = $(this).data('id'); $(".btn-tab-select").each(function () { @@ -738,11 +733,11 @@ $("table").on('uncheck-all.bs.table', function (rows) { // console.log('Table unselect all' + id_fld); }); -// -// On table Click !!!!!! +// +// On table Click !!!!!! $("table").on("post-body.bs.table", function () { // console.log('Table '); -// delete extension +// delete extension $(this).find(".clickable.delete").click(function () { var id = $(this).data("id"); @@ -763,7 +758,8 @@ $("table").on("post-body.bs.table", function () { }); }); -function load_oncliсk(e, data) { +function load_oncliсk(e, data) +{ // console.log('load_oncliсk'); var add_softkey = false; @@ -796,7 +792,7 @@ function load_oncliсk(e, data) { var opts_idx = -1; for (var i = 0; i < dev_fld.length; i++) { opts = $('#destination_' + dev_fld[i] + ' option'); - if (opts.length > 0) { // Remove all + if (opts.length > 0) { // Remove all $(opts).remove(); $('#source_' + dev_fld[i]).append($(opts).clone()); } @@ -821,7 +817,8 @@ function load_oncliсk(e, data) { } -function add_dynamic_input(pe, pclass, vdefault) { +function add_dynamic_input(pe, pclass, vdefault) +{ // We'd like a new one, please. pcls = pe.data('for'); pname = pe.data('id'); @@ -846,7 +843,8 @@ function add_dynamic_input(pe, pclass, vdefault) { } } -function del_dynamic_table(pe, pclass, vdefault) { +function del_dynamic_table(pe, pclass, vdefault) +{ pcls = pe.data('for'); pname = pe.data('id'); @@ -865,7 +863,8 @@ function del_dynamic_table(pe, pclass, vdefault) { } } -function add_dynamic_table(pe, pclass, vdefault) { +function add_dynamic_table(pe, pclass, vdefault) +{ // We'd like a new one, please. pcls = pe.data('for'); pname = pe.data('id'); @@ -996,33 +995,34 @@ var theForm = document.editIax; /* String.prototype.hex2bin = function() - { + { var i = 0, len = this.length, result = ""; - + //Converting the hex string into an escaped string, so if the hex string is "a2b320", it will become "%a2%b3%20" for(; i < len; i+=2) - result += '%' + this.substr(i, 2); - + result += '%' + this.substr(i, 2); + return unescape(result); } */ -function bs_page_reload() { +function bs_page_reload() +{ window.location.reload(false); } function bs_alert(data, status, reload) { if (document.getElementById('hwalert') === null) { - if (Array.isArray(data)) { + if (Array.isArray(data)) { data.forEach(function (entry) { alert(entry); }); - }else { + } else { alert(data); } return true; // Old style } else { - var modal = $("#hwalert"); + var modal = $("#hwalert"); if (typeof status != "undefined") { if (status === true) { modal.find('.modal-title').text('Operation result'); @@ -1034,14 +1034,14 @@ function bs_alert(data, status, reload) } // var modal2 = modal.find('.modal-title'); // console.log(modal2); -// modal.find('.modal-body').text(data); +// modal.find('.modal-body').text(data); var modal2 = modal.find('.modal-body'); var msg_html = ''; - if (Array.isArray(data)) { - data.forEach(function(entry) { + if (Array.isArray(data)) { + data.forEach(function (entry) { msg_html = msg_html + '

'+ entry + '

'; }); - }else { + } else { msg_html = data; } modal2[0].innerHTML = msg_html; @@ -1059,13 +1059,15 @@ function hex2bin(hex) { var bytes = [], str; - for (var i = 0; i < hex.length - 1; i += 2) + for (var i = 0; i < hex.length - 1; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); + } return String.fromCharCode.apply(String, bytes); } -function sleep(milliseconds) { +function sleep(milliseconds) +{ var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds) { diff --git a/conf/Sccp.class.php b/conf/Sccp.class.php index 224eb3b..7252336 100644 --- a/conf/Sccp.class.php +++ b/conf/Sccp.class.php @@ -1,11 +1,13 @@ 'pin', "label" => 'label', "accountcode" => 'account', "context" =>'lcontext',"incominglimit"=>'incominglimit', "callgroup"=>'callgroup',"pickupgroup"=>'pickupgroup', @@ -14,22 +16,23 @@ class Sccp extends \FreePBX\modules\Core\Driver { "cid_num" => 'cid_num', "cid_name" => 'label', "mailbox" => 'description', "musicclass" => 'musicclass', "dnd" => 'dnd', "silencesuppression" => 'silencesuppression', - "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone', + "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone', 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup' ); - public function getInfo() { - return array( - "rawName" => "sccp", - "hardware" => "sccp_custom", - "prettyName" => _("Sccp Custom Driver"), - "shortName" => "SCCP", - "description" => _("Sccp Device"), - "Version" => "11.3", - "about" => "Sccp mysql class Base ver: 11.3, Sccp ver: default" + public function getInfo() + { + return array( + "rawName" => "sccp", + "hardware" => "sccp_custom", + "prettyName" => _("Sccp Custom Driver"), + "shortName" => "SCCP", + "description" => _("Sccp Device"), + "Version" => "11.3", + "about" => "Sccp mysql class Base ver: 11.3, Sccp ver: default" - ); - } + ); + } /* public function addDevice1($id, $settings) { $sql = 'INSERT INTO sccp (id, keyword, data, flags) values (?,?,?,?)'; @@ -41,170 +44,176 @@ class Sccp extends \FreePBX\modules\Core\Driver { return true; } */ - public function addDevice($id, $settings) { + public function addDevice($id, $settings) + { $add_fld = array ("name"=>'label',"outboundcid"=>'cid_num',"langcode"=>'language',"extdisplay"=>'description'); -// print_r($_REQUEST); -// echo '

'; -// die(print_r($settings)); + // print_r($_REQUEST); + // echo '

'; + // die(print_r($settings)); $settings['cid_num']['value']=''; - if (isset($_REQUEST)){ - foreach($add_fld as $key => $val) { - if (!empty($_REQUEST[$key])){ - $settings[$val]['value'] = $_REQUEST[$key]; - } + if (isset($_REQUEST)) { + foreach ($add_fld as $key => $val) { + if (!empty($_REQUEST[$key])) { + $settings[$val]['value'] = $_REQUEST[$key]; } } - if (empty($settings['cid_num']['value'])) { - $settings['cid_num']['value']= $id; - } + } + if (empty($settings['cid_num']['value'])) { + $settings['cid_num']['value']= $id; + } $sql = 'INSERT INTO sccpline (name'; $sqlv = 'values ("'.$id.'"'; - foreach($this->data_fld as $key => $val) { - if (!empty($settings[$val]) ) { - if (!empty($settings[$val]['value'])){ - $sql .= ', '.$key; - $sqlv .= ", '".$settings[$val]['value']."' "; - } + foreach ($this->data_fld as $key => $val) { + if (!empty($settings[$val])) { + if (!empty($settings[$val]['value'])) { + $sql .= ', '.$key; + $sqlv .= ", '".$settings[$val]['value']."' "; } } - $sql .= ") ".$sqlv.");"; - $sth = $this->database->prepare($sql); + } + $sql .= ") ".$sqlv.");"; + $sth = $this->database->prepare($sql); $sth->execute(); - return true; + return true; } - public function delDevice($id) { - $sql = "DELETE FROM sccpline WHERE name = ?"; - $sth = $this->database->prepare($sql); - $sth->execute(array($id)); - return true; - } + public function delDevice($id) + { + $sql = "DELETE FROM sccpline WHERE name = ?"; + $sth = $this->database->prepare($sql); + $sth->execute(array($id)); + return true; + } - public function getDevice($id) { + public function getDevice($id) + { $sccp_line = array(); -// $sql = "SELECT name as id, name as name"; - $sql = "SELECT name as id, name as name "; - foreach($this->data_fld as $key => $val) { + // $sql = "SELECT name as id, name as name"; + $sql = "SELECT name as id, name as name "; + foreach ($this->data_fld as $key => $val) { $sql .= ',`'. $key .'` as '.$val; - } - $sql .= " FROM sccpline WHERE name = ?"; - $sth = $this->database->prepare($sql); - $result = array(); - $tech = array(); - try { - $sth->execute(array($id)); - $result = $sth->fetch(\PDO::FETCH_ASSOC); + } + $sql .= " FROM sccpline WHERE name = ?"; + $sth = $this->database->prepare($sql); + $result = array(); + $tech = array(); + try { + $sth->execute(array($id)); + $result = $sth->fetch(\PDO::FETCH_ASSOC); $tech = $result; $tech['dial']='SCCP/'.$id; - } catch(\Exception $e) {} + } catch (\Exception $e) { + } - return $tech; - } + return $tech; + } - public function getDefaultDeviceSettings($id, $displayname, &$flag) { - $dial = 'SCCP'; - $settings = array( - "pin" => array( - "value" => "", - "flag" => $flag++ - ), - "incominglimit" => array( - "value" => "", - "flag" => $flag++ - ), - "lcontext" => array( - "value" => "from-internal", - "flag" => $flag++ - ), - "callgroup" => array( - "value" => "", - "flag" => $flag++ - ), - "namedcallgroup" => array( - "value" => "", - "flag" => $flag++ - ), - "pickupgroup" => array( - "value" => "", - "flag" => $flag++ - ), - "namedpickupgroup" => array( - "value" => "", - "flag" => $flag++ - ), - "transfer" => array( - "value" => "yes", - "flag" => $flag++ - ), - "adhocNumber" => array( - "value" => "", - "flag" => $flag++ - ), - "echocancel" => array( - "value" => "no", - "flag" => $flag++ - ), - "dnd" => array( - "value" => "UserDefined", - "flag" => $flag++ - ), - "silencesuppression" => array( - "value" => "no", - "flag" => $flag++ - ), - "secondary_dialtone_digits" => array( - "value" => "9", - "flag" => $flag++ - ), - "secondary_dialtone_tone" => array( - "value" => "0x22", - "flag" => $flag++ - ), - "musicclass" => array( - "value" => "default", - "flag" => $flag++ - ), - ); - return array( - "dial" => $dial, - "settings" => $settings - ); - } + public function getDefaultDeviceSettings($id, $displayname, &$flag) + { + $dial = 'SCCP'; + $settings = array( + "pin" => array( + "value" => "", + "flag" => $flag++ + ), + "incominglimit" => array( + "value" => "", + "flag" => $flag++ + ), + "lcontext" => array( + "value" => "from-internal", + "flag" => $flag++ + ), + "callgroup" => array( + "value" => "", + "flag" => $flag++ + ), + "namedcallgroup" => array( + "value" => "", + "flag" => $flag++ + ), + "pickupgroup" => array( + "value" => "", + "flag" => $flag++ + ), + "namedpickupgroup" => array( + "value" => "", + "flag" => $flag++ + ), + "transfer" => array( + "value" => "yes", + "flag" => $flag++ + ), + "adhocNumber" => array( + "value" => "", + "flag" => $flag++ + ), + "echocancel" => array( + "value" => "no", + "flag" => $flag++ + ), + "dnd" => array( + "value" => "UserDefined", + "flag" => $flag++ + ), + "silencesuppression" => array( + "value" => "no", + "flag" => $flag++ + ), + "secondary_dialtone_digits" => array( + "value" => "9", + "flag" => $flag++ + ), + "secondary_dialtone_tone" => array( + "value" => "0x22", + "flag" => $flag++ + ), + "musicclass" => array( + "value" => "default", + "flag" => $flag++ + ), + ); + return array( + "dial" => $dial, + "settings" => $settings + ); + } # !TODO!: -TODO-: Would it not be better to put this part in the view directory (MVC) ? No, This is a template for Freepbx. - public function getDeviceDisplay($display, $deviceInfo, $currentcomponent, $primarySection) { - $section = _("Settings"); - $category = "general"; - $tmparr = array(); - $tt = _("The maximum number of incoming calls on this line."); -// $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '2', 'tt' => $tt, 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel); -// !TODO!: Please change the default value for incominglimit to '6' or higher - $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '2', 'tt' => $tt, 'level' => 1); + public function getDeviceDisplay($display, $deviceInfo, $currentcomponent, $primarySection) + { + $section = _("Settings"); + $category = "general"; + $tmparr = array(); + $tt = _("The maximum number of incoming calls on this line."); + // $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '2', 'tt' => $tt, 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel); + // !TODO!: Please change the default value for incominglimit to '6' or higher + $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), 'value' => '2', 'tt' => $tt, 'level' => 1); $tt = _("Asterisk context which this line will use to send and receive calls (Note: Only change this is you know what you are doing)."); - $tmparr['lcontext'] = array('prompttext' => _('Line context'), 'value' => 'from-internal', 'tt' => $tt, 'level' => 1); + $tmparr['lcontext'] = array('prompttext' => _('Line context'), 'value' => 'from-internal', 'tt' => $tt, 'level' => 1); -// !TODO!: -TODO-: Maybe completely remove support for old numberic callgroup/pickupgroup in favor of the named version ? See Sccp.class.php.v431 + // !TODO!: -TODO-: Maybe completely remove support for old numberic callgroup/pickupgroup in favor of the named version ? See Sccp.class.php.v431 $tt = _("Phone call group (numeric only, example:1,3-4)"); - $tmparr['callgroup'] = array('prompttext' => _('Call group id'),'value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['callgroup'] = array('prompttext' => _('Call group id'),'value' => '', 'tt' => $tt, 'level' => 1); -// !TODO!: -TODO-: multiple allowed (not sure if that is implemented here). See Sccp.class.php.v431 + // !TODO!: -TODO-: multiple allowed (not sure if that is implemented here). See Sccp.class.php.v431 $tt = _("Phone named call group (>asterisk-11)"); - $tmparr['namedcallgroup'] = array('prompttext' => _('Named Call Group'),'value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['namedcallgroup'] = array('prompttext' => _('Named Call Group'),'value' => '', 'tt' => $tt, 'level' => 1); $tt = _("Sets the pickup group (numeric only, example:1,3-4) this line is a member of. Allows this line to pickup calls from remote phones which are in this callhroup."); $tmparr['pickupgroup'] = array('prompttext' => _('Pickup group id'),'value' => '', 'tt' => $tt, 'level' => 1); -// !TODO!: -TODO-: multiple allowed (not sure if that is implemented here). See Sccp.class.php.v431 + // !TODO!: -TODO-: multiple allowed (not sure if that is implemented here). See Sccp.class.php.v431 $tt = _("Sets the named pickup name group this line is a member of. Allows this line to pickup calls from remote phones which are in this name callgroup (>asterisk-11)."); - $tmparr['namedpickupgroup'] = array('prompttext' => _('Named Pickup Group'),'value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['namedpickupgroup'] = array('prompttext' => _('Named Pickup Group'),'value' => '', 'tt' => $tt, 'level' => 1); $tt = _("Phone pincode (Note used)"); - $tmparr['pin'] = array('value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['pin'] = array('value' => '', 'tt' => $tt, 'level' => 1); $tt = _("Digits to indicate an external line to user (secondary dialtone) Sample 9 or 8 (max 9 digits)"); - $tmparr['secondary_dialtone_digits'] = array('prompttext' => _('Secondary dialtone digits'), 'value' => '', 'tt' => $tt, 'level' => 1); + $tmparr['secondary_dialtone_digits'] = array('prompttext' => _('Secondary dialtone digits'), 'value' => '', 'tt' => $tt, 'level' => 1); unset($select); $select[] = array( 'value' => '0x21', 'text' => 'Inside Dial Tone'); @@ -249,8 +258,8 @@ class Sccp extends \FreePBX\modules\Core\Driver { $select[] = array( 'value' => '0x7A', 'text' => 'MLPP Bpa'); $select[] = array( 'value' => '0x7B', 'text' => 'MLPP Bnea'); $select[] = array( 'value' => '0x7C', 'text' => 'MLPP Upa'); -/* !TODO!: +TODO+: I would remove the values below this line, except for 'No Tone' */ -// $select[] = array( 'value' => '0x7F', 'text' => 'No Tone'); + /* !TODO!: +TODO+: I would remove the values below this line, except for 'No Tone' */ + // $select[] = array( 'value' => '0x7F', 'text' => 'No Tone'); $select[] = array( 'value' => '0x80', 'text' => 'Meetme Greeting Tone'); $select[] = array( 'value' => '0x81', 'text' => 'Meetme Number Invalid Tone'); $select[] = array( 'value' => '0x82', 'text' => 'Meetme Number Failed Tone'); @@ -267,7 +276,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { $tt = _("Outside dialtone frequency (defaul 0x22)"); $tmparr['secondary_dialtone_tone'] = array('prompttext' => _('Secondary dialtone'), 'value' => '0x22', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'select'); -# !TODO!: -TODO-: is there no easier way to specify a boolean radio group ? No. + # !TODO!: -TODO-: is there no easier way to specify a boolean radio group ? No. unset($select); $select[] = array('value' => 'yes', 'text' => 'Yes'); $select[] = array('value' => 'no', 'text' => 'No'); @@ -285,8 +294,8 @@ class Sccp extends \FreePBX\modules\Core\Driver { $select[] = array('value' => 'reject', 'text' => 'Reject'); $select[] = array('value' => 'silent', 'text' => 'Silent'); $select[] = array('value' => 'UserDefined', 'text' => 'UserDefined'); -# !TODO!: -TODO-: The next entry should be "null/empty" (not UserDefined) -> to indicate the trie-state behaviour -# !TODO!: -TODO-: Userdefined is also a possible state, but it is not used or implemented (and it should not be implemented here, i think). See Sccp.class.php.v431, See Sccp.class.php - Old Style + # !TODO!: -TODO-: The next entry should be "null/empty" (not UserDefined) -> to indicate the trie-state behaviour + # !TODO!: -TODO-: Userdefined is also a possible state, but it is not used or implemented (and it should not be implemented here, i think). See Sccp.class.php.v431, See Sccp.class.php - Old Style $tt = _("DND: How will dnd react when it is set on the device level dnd can have three states: off / busy(reject) / silent / UserDefined").'
'. _("UserDefined - dnd that cycles through all three states off -> reject -> silent -> off (this is the normal behaviour)").'
'. _("Reject - Usesr can only switch off and on (in reject/busy mode)").'
'. @@ -301,19 +310,19 @@ class Sccp extends \FreePBX\modules\Core\Driver { unset($select); $select[] = array('value' => 'default', 'text' => _('default')); - if (function_exists('music_list')){ - $moh_list = music_list(); - } else { - $moh_list = array('default'); - } - foreach ($moh_list as $value) { - $select[] = array('value' => $value, 'text' => _($value)); - } + if (function_exists('music_list')) { + $moh_list = music_list(); + } else { + $moh_list = array('default'); + } + foreach ($moh_list as $value) { + $select[] = array('value' => $value, 'text' => _($value)); + } $tt = _("Music on hold"); $tmparr['musicclass'] = array('prompttext' => _('Music on hold'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1); - $devopts = $tmparr; - return $devopts; - } + $devopts = $tmparr; + return $devopts; + } } diff --git a/functions.inc.php b/functions.inc.php index d0f3f60..041b659 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -22,41 +22,52 @@ */ -function after($this, $inthat) { - if (!is_bool(strpos($inthat, $this))) +function after($this, $inthat) +{ + if (!is_bool(strpos($inthat, $this))) { return substr($inthat, strpos($inthat, $this) + strlen($this)); + } } -function after_last($this, $inthat) { - if (!is_bool(strrevpos($inthat, $this))) +function after_last($this, $inthat) +{ + if (!is_bool(strrevpos($inthat, $this))) { return substr($inthat, strrevpos($inthat, $this) + strlen($this)); + } } -function before($this, $inthat) { +function before($this, $inthat) +{ return substr($inthat, 0, strpos($inthat, $this)); } -function before_last($this, $inthat) { +function before_last($this, $inthat) +{ return substr($inthat, 0, strrevpos($inthat, $this)); } -function between($this, $that, $inthat) { +function between($this, $that, $inthat) +{ return before($that, after($this, $inthat)); } -function between_last($this, $that, $inthat) { +function between_last($this, $that, $inthat) +{ return after_last($this, before_last($that, $inthat)); } -function strrevpos($instr, $needle) { +function strrevpos($instr, $needle) +{ $rev_pos = strpos(strrev($instr), strrev($needle)); - if ($rev_pos === false) + if ($rev_pos === false) { return false; - else + } else { return strlen($instr) - $rev_pos - strlen($needle); + } } -function strpos_array($haystack, $needles) { +function strpos_array($haystack, $needles) +{ if (is_array($needles)) { foreach ($needles as $str) { if (is_array($str)) { @@ -64,14 +75,12 @@ function strpos_array($haystack, $needles) { } else { $pos = strpos($haystack, $str); } - if ($pos !== FALSE) { + if ($pos !== false) { return $pos; } } } else { return strpos($haystack, $needles); } - return FALSE; + return false; } - -?> \ No newline at end of file diff --git a/install.php b/install.php index 7905f63..975bca6 100644 --- a/install.php +++ b/install.php @@ -3,8 +3,8 @@ * Hand DB Change : ALTER TABLE `asterisk`.`sccpline` CHANGE COLUMN `transfer` `transfer` ENUM('on','off') NULL DEFAULT NULL ; ALTER TABLE `asterisk`.`sccpdevice` CHANGE COLUMN `transfer` `transfer` ENUM('on','off') NULL DEFAULT NULL; - * - * + * + * */ if (!defined('FREEPBX_IS_AUTH')) { @@ -27,7 +27,8 @@ if (class_exists($class, false)) { $srvinterface = new $class(); } -function Get_DB_config($sccp_compatible) { +function Get_DB_config($sccp_compatible) +{ global $mobile_hw; $db_config_v0 = array( 'sccpdevmodel' => array( @@ -98,7 +99,7 @@ function Get_DB_config($sccp_compatible) { 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), 'dtmfmode' => array('drop' => "yes"), -// 'force_dtmfmode' => array('create' => "ENUM('auto','rfc2833','skinny') NOT NULL default 'auto'", 'modify' => "ENUM('auto','rfc2833','skinny')", 'def_modify'=> 'auto'), +// 'force_dtmfmode' => array('create' => "ENUM('auto','rfc2833','skinny') NOT NULL default 'auto'", 'modify' => "ENUM('auto','rfc2833','skinny')", 'def_modify'=> 'auto'), 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), @@ -185,8 +186,8 @@ function Get_DB_config($sccp_compatible) { 'trustphoneip' => array('drop' => "yes"), 'mwilamp' => array('create' => "enum('on','off','wink','flash','blink') NULL default 'on'", 'modify' => "enum('on','off','wink','flash','blink')"), 'mwioncall' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), - 'private' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), // Что-то лишенне - 'privacy' => array('create' => "enum('full','on','off') NOT NULL default 'full'", 'modify' => "enum('full','on','off')"), // Что-то лишенне + 'private' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), // Что-то лишенне + 'privacy' => array('create' => "enum('full','on','off') NOT NULL default 'full'", 'modify' => "enum('full','on','off')"), // Что-то лишенне 'nat' => array('create' => "enum('on','off','auto') NULL default NULL", 'modify' => "enum('on','off','auto')"), 'conf_allow' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), 'conf_play_part_announce' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), @@ -222,7 +223,7 @@ function Get_DB_config($sccp_compatible) { ) ); - // Software mobile + // Software mobile $db_config_v4 = array( 'sccpdevmodel' => array( 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), @@ -262,7 +263,7 @@ function Get_DB_config($sccp_compatible) { 'cfwdall' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), 'cfwdbusy' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), 'cfwdnoanswer' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), - 'park' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), + 'park' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), 'directrtp' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"), 'dndFeature' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"), 'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NULL default NULL", 'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"), @@ -276,8 +277,8 @@ function Get_DB_config($sccp_compatible) { 'phonecodepage' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL', 'modify' => "VARCHAR(50)"), 'mwilamp' => array('create' => "enum('on','off','wink','flash','blink') NULL default 'on'", 'modify' => "enum('on','off','wink','flash','blink')"), 'mwioncall' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"), - 'private' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), // Что-то лишенне - 'privacy' => array('create' => "enum('full','on','off') NOT NULL default 'full'", 'modify' => "enum('full','on','off')"), // Что-то лишенне + 'private' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), // Что-то лишенне + 'privacy' => array('create' => "enum('full','on','off') NOT NULL default 'full'", 'modify' => "enum('full','on','off')"), // Что-то лишенне 'nat' => array('create' => "enum('on','off','auto') NULL default NULL", 'modify' => "enum('on','off','auto')"), 'conf_allow' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), 'conf_play_part_announce' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), @@ -356,7 +357,7 @@ function Get_DB_config($sccp_compatible) { ) ); - if ($sccp_compatible >= 433 ) { + if ($sccp_compatible >= 433) { if ($mobile_hw == '1') { return $db_config_v4M; } @@ -378,10 +379,11 @@ $sccp_compatible = 0; //$db_config = $db_config_v0; $db_config = ''; -function CheckSCCPManagerDBTables($table_req) { -global $amp_conf; -global $astman; - global $db; +function CheckSCCPManagerDBTables($table_req) +{ + global $amp_conf; + global $astman; + global $db; outn("
  • " . _("Checking for Sccp_manager database tables..") . "
  • "); foreach ($table_req as $value) { $check = $db->getRow("SELECT 1 FROM `$value` LIMIT 0", DB_FETCHMODE_ASSOC); @@ -394,25 +396,27 @@ global $astman; } } -function CheckSCCPManagerDBVersion() { +function CheckSCCPManagerDBVersion() +{ global $db; outn("
  • " . _("Checking for previw version Sccp_manager..") . "
  • "); $check = $db->getRow("SELECT data FROM `sccpsettings` where keyword ='sccp_compatible'", DB_FETCHMODE_ASSOC); if (DB::IsError($check)) { outn(_("Can't find previw version : ")); - return FALSE; + return false; } if (!empty($check['data'])) { outn(_("Find DB Schema : " . $check['data'])); return $check['data']; } else { - return FALSE; + return false; } } /* notused */ -function CheckPermissions() { +function CheckPermissions() +{ outn("
  • " . _("Checking Filesystem Permissions") . "
  • "); $dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/views'; if (fileowner($_SERVER['DOCUMENT_ROOT']) != fileowner($dst)) { @@ -420,7 +424,8 @@ function CheckPermissions() { } } -function CheckAsteriskVersion() { +function CheckAsteriskVersion() +{ outn("
  • " . _("Checking Asterisk Version : ") . $version . "
  • "); $version = FreePBX::Config()->get('ASTVERSION'); if (!empty($version)) { @@ -439,7 +444,8 @@ function CheckAsteriskVersion() { return $ver_compatible; } -function CheckChanSCCPCompatible() { +function CheckChanSCCPCompatible() +{ global $srvinterface, $astman; if (!$astman) { ie_freepbx('No asterisk manager connection provided!. Installation Failed'); @@ -449,7 +455,8 @@ function CheckChanSCCPCompatible() { return $sccp_compatible; } -function InstallDB_Buttons() { +function InstallDB_Buttons() +{ global $db; outn("
  • " . _("Creating buttons table...") . "
  • "); // $check = $db->getRow("SELECT 1 FROM buttonconfig LIMIT 0", DB_FETCHMODE_ASSOC); @@ -470,10 +477,10 @@ function InstallDB_Buttons() { die_freepbx("Can not create sccpbuttonconfig table, error:$check\n"); } return true; - } -function InstallDB_sccpsettings() { +function InstallDB_sccpsettings() +{ global $db; outn("
  • " . _("Creating sccpsettings table...") . "
  • "); $sql = "CREATE TABLE IF NOT EXISTS `sccpsettings` ( @@ -490,7 +497,8 @@ function InstallDB_sccpsettings() { return true; } -function InstallDB_sccpdevmodel() { +function InstallDB_sccpdevmodel() +{ global $db; outn("
  • " . _("Creating sccpdevmodel table...") . "
  • "); $sql = "CREATE TABLE IF NOT EXISTS `sccpdevmodel` ( @@ -512,7 +520,8 @@ function InstallDB_sccpdevmodel() { return true; } -function InstallDB_sccpuser() { +function InstallDB_sccpuser() +{ global $db; outn("
  • " . _("Creating sccpuser table...") . "
  • "); $sql = "CREATE TABLE IF NOT EXISTS `sccpuser` ( @@ -534,7 +543,8 @@ function InstallDB_sccpuser() { return true; } -function InstallDB_updateSchema($db_config) { +function InstallDB_updateSchema($db_config) +{ global $db; if (!$db_config) { die_freepbx("No db_config provided"); @@ -658,7 +668,8 @@ function InstallDB_updateSchema($db_config) { return true; } -function InstallDB_fillsccpdevmodel() { +function InstallDB_fillsccpdevmodel() +{ global $db; outn("
  • " . _("Fill sccpdevmodel") . "
  • "); $sql = "REPLACE INTO `sccpdevmodel` (`model`, `vendor`, `dns`, `buttons`, `loadimage`, `loadinformationid`, `enabled`, `nametemplate`) VALUES ('12 SP', 'CISCO', 1, 1, '', 'loadInformation3', 0, NULL)," . @@ -667,7 +678,7 @@ function InstallDB_fillsccpdevmodel() { "('7916;7916', 'CISCO', 0, 48, 'B016-1-0-4-2', 'loadInformation230', 1, NULL), ('7920', 'CISCO', 1, 1, 'cmterm_7920.4.0-03-02', 'loadInformation30002', 0, NULL), ('7921', 'CISCO', 1, 1, 'CP7921G-1.4.6.3', 'loadInformation365', 0, NULL),('7925', 'CISCO', 1, 6, 'CP7925G-1.4.1SR1', 'loadInformation484', 0, NULL), ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.1SR1', 'loadInformation557', 0, NULL), ('7931', 'CISCO', 1, 34, 'SCCP31.9-2-1S', 'loadInformation348', 0, NULL), ('7935', 'CISCO', 1, 2, 'P00503021900', 'loadInformation9', 0, NULL), ('7936', 'CISCO', 1, 1, 'cmterm_7936.3-3-21-0', 'loadInformation30019', 0, NULL), ('7937', 'CISCO', 1, 1, 'apps37sccp.1-4-5-7', 'loadInformation431', 0, 'SEP0000000000.cnf.xml_7937_template'), ('7940', 'CISCO', 1, 2, 'P0030801SR02', 'loadInformation8', 1, 'SEP0000000000.cnf.xml_7940_template'), " . "('7941', 'CISCO', 1, 2, 'SCCP41.9-4-2SR3-1S', 'loadInformation115', 0, 'SEP0000000000.cnf.xml_796x_template'),('7941G-GE', 'CISCO', 1, 2, 'SCCP41.9-4-2SR3-1S', 'loadInformation309', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7942', 'CISCO', 1, 2, 'SCCP42.9-4-2SR3-1S', 'loadInformation434', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7945', 'CISCO', 1, 2, 'SCCP45.9-3-1SR1-1S', 'loadInformation435', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7960', 'CISCO', 3, 6, 'P0030801SR02', 'loadInformation7', 1, 'SEP0000000000.cnf.xml_796x_template'), ('7961', 'CISCO', 3, 6, 'SCCP41.9-4-2SR3-1S', 'loadInformation30018', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7961G-GE', 'CISCO', 3, 6, 'SCCP41.9-4-2SR3-1S', 'loadInformation308', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7962', 'CISCO', 3, 6, 'SCCP42.9-4-2SR3-1S', 'loadInformation404', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7965', 'CISCO', 3, 6, 'SCCP45.9-3-1SR1-1S', 'loadInformation436', 0, 'SEP0000000000.cnf.xml_796x_template'), ('7970', 'CISCO', 3, 8, 'SCCP70.9-4-2SR3-1S', 'loadInformation30006', 0, NULL), ('7971', 'CISCO', 1, 2, 'SCCP70.9-4-2SR3-1S', 'loadInformation119', 0, NULL), ('7975', 'CISCO', 3, 8, 'SCCP75.9-4-2SR3-1S', 'loadInformation437', 0, NULL), ('7985', 'CISCO', 3, 8, 'cmterm_7985.4-1-7-0', 'loadInformation302', 0, NULL), ('8941', 'CISCO', 1, 0, 'SCCP894x.9-2-2-0', 'loadInformation586', 0, NULL), ('8945', 'CISCO', 1, 0, 'SCCP894x.9-2-2-0', 'loadInformation585', 0, NULL), ('ATA 186', 'CISCO', 1, 1, 'ATA030204SCCP090202A', 'loadInformation12', 0, 'SEP0000000000.cnf.xml_ATA_template'), ('ATA 187', 'CISCO', 1, 1, 'ATA187.9-2-3-1', 'loadInformation550', 0, 'SEP0000000000.cnf.xml_ATA_template'), ('CN622', 'MOTOROLA', 1, 1, '', 'loadInformation335', 0, NULL), ('Digital Access', 'CISCO', 1, 1, 'D001M022', 'loadInformation40', 0, NULL), ('Digital Access+', 'CISCO', 1, 1, 'D00303010033', 'loadInformation42', 0, NULL), ('E-Series', 'NOKIA', 1, 1, '', '', 0, NULL), ('ICC', 'NOKIA', 1, 1, '', '', 0, NULL), " . "('Analog Access', 'CISCO', 1, 1, 'A001C030', 'loadInformation30', 0, ''),('WS-X6608', 'CISCO', 1, 1, 'D00404000032', 'loadInformation43', 0, ''), ('WS-X6624', 'CISCO', 1, 1, 'A00204000013', 'loadInformation43', 0, ''), ('WS-X6608', 'CISCO', 1, 1, 'C00104000003', 'loadInformation51', 0, ''), ('H.323 Phone', 'CISCO', 1, 1, '', 'loadInformation61', 0, ''), ('Simulator', 'CISCO', 1, 1, '', 'loadInformation100', 0, ''), ('MTP', 'CISCO', 1, 1, '', 'loadInformation111', 0, ''), ('MGCP Station', 'CISCO', 1, 1, '', 'loadInformation120', 0, ''), ('MGCP Trunk', 'CISCO', 1, 1, '', 'loadInformation121', 0, ''), ('UPC', 'CISCO', 1, 1, '', 'loadInformation358', 0, ''), ". - "('TelePresence', 'TELEPRESENCE', 1, 1, '', 'loadInformation375', 0, ''), ('1000', 'TELEPRESENCE', 1, 1, '', 'loadInformation478', 0, ''), ('3000', 'TELEPRESENCE', 1, 1, '', 'loadInformation479', 0, ''), ('3200', 'TELEPRESENCE', 1, 1, '', 'loadInformation480', 0, ''), ('500-37', 'TELEPRESENCE', 1, 1, '', 'loadInformation481', 0, ''), ('1300-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation505', 0, ''), ('1100', 'TELEPRESENCE', 1, 1, '', 'loadInformation520', 0, ''), ('200', 'TELEPRESENCE', 1, 1, '', 'loadInformation557', 0, ''), ('400', 'TELEPRESENCE', 1, 1, '', 'loadInformation558', 0, ''), ('EX90', 'TELEPRESENCE', 1, 1, '', 'loadInformation584', 0, ''), ('500-32', 'TELEPRESENCE', 1, 1, '', 'loadInformation590', 0, ''), ('1300-47', 'TELEPRESENCE', 1, 1, '', 'loadInformation591', 0, ''), ('TX1310-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation596', 0, ''), ('EX60', 'TELEPRESENCE', 1, 1, '', 'loadInformation604', 0, ''), ('C90', 'TELEPRESENCE', 1, 1, '', 'loadInformation606', 0, ''), ('C60', 'TELEPRESENCE', 1, 1, '', 'loadInformation607', 0, ''), ('C40', 'TELEPRESENCE', 1, 1, '', 'loadInformation608', 0, ''), ('C20', 'TELEPRESENCE', 1, 1, '', 'loadInformation609', 0, ''), ('C20-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation610', 0, ''), ('C60-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation611', 0, ''), ('C40-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation612', 0, ''), ('C60-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation613', 0, ''), ('C60-52D', 'TELEPRESENCE', 1, 1, '', 'loadInformation614', 0, ''),('C60-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation615', 0, ''), ('C90-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation616', 0, ''), ('MX200', 'TELEPRESENCE', 1, 1, '', 'loadInformation617', 0, ''), ('TX9000', 'TELEPRESENCE', 1, 1, '', 'loadInformation619', 0, ''), ('TX9200', 'TELEPRESENCE', 1, 1, '', 'loadInformation620', 0, ''), ('SX20', 'TELEPRESENCE', 1, 1, '', 'loadInformation626', 0, ''), ('MX300', 'TELEPRESENCE', 1, 1, '', 'loadInformation627', 0, ''), ('C40-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation633', 0, ''), ('Jabber', 'CISCO', 1, 1, '', 'loadInformation652', 0, ''), ". + "('TelePresence', 'TELEPRESENCE', 1, 1, '', 'loadInformation375', 0, ''), ('1000', 'TELEPRESENCE', 1, 1, '', 'loadInformation478', 0, ''), ('3000', 'TELEPRESENCE', 1, 1, '', 'loadInformation479', 0, ''), ('3200', 'TELEPRESENCE', 1, 1, '', 'loadInformation480', 0, ''), ('500-37', 'TELEPRESENCE', 1, 1, '', 'loadInformation481', 0, ''), ('1300-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation505', 0, ''), ('1100', 'TELEPRESENCE', 1, 1, '', 'loadInformation520', 0, ''), ('200', 'TELEPRESENCE', 1, 1, '', 'loadInformation557', 0, ''), ('400', 'TELEPRESENCE', 1, 1, '', 'loadInformation558', 0, ''), ('EX90', 'TELEPRESENCE', 1, 1, '', 'loadInformation584', 0, ''), ('500-32', 'TELEPRESENCE', 1, 1, '', 'loadInformation590', 0, ''), ('1300-47', 'TELEPRESENCE', 1, 1, '', 'loadInformation591', 0, ''), ('TX1310-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation596', 0, ''), ('EX60', 'TELEPRESENCE', 1, 1, '', 'loadInformation604', 0, ''), ('C90', 'TELEPRESENCE', 1, 1, '', 'loadInformation606', 0, ''), ('C60', 'TELEPRESENCE', 1, 1, '', 'loadInformation607', 0, ''), ('C40', 'TELEPRESENCE', 1, 1, '', 'loadInformation608', 0, ''), ('C20', 'TELEPRESENCE', 1, 1, '', 'loadInformation609', 0, ''), ('C20-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation610', 0, ''), ('C60-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation611', 0, ''), ('C40-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation612', 0, ''), ('C60-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation613', 0, ''), ('C60-52D', 'TELEPRESENCE', 1, 1, '', 'loadInformation614', 0, ''),('C60-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation615', 0, ''), ('C90-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation616', 0, ''), ('MX200', 'TELEPRESENCE', 1, 1, '', 'loadInformation617', 0, ''), ('TX9000', 'TELEPRESENCE', 1, 1, '', 'loadInformation619', 0, ''), ('TX9200', 'TELEPRESENCE', 1, 1, '', 'loadInformation620', 0, ''), ('SX20', 'TELEPRESENCE', 1, 1, '', 'loadInformation626', 0, ''), ('MX300', 'TELEPRESENCE', 1, 1, '', 'loadInformation627', 0, ''), ('C40-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation633', 0, ''), ('Jabber', 'CISCO', 1, 1, '', 'loadInformation652', 0, ''), ". "('S60', 'NOKIA', 0, 1, '', 'loadInformation376', 0, ''), ('9971', 'CISCO', 1, 1, '', 'loadInformation493', 0, ''), ('9951', 'CISCO', 1, 1, '', 'loadInformation537', 0, ''), ('8961', 'CISCO', 1, 1, '', 'loadInformation540', 0, ''), ('Iphone', 'APPLE', 0, 1, '', 'loadInformation562', 0, ''), ('Android', 'ANDROID', 0, 1, '', 'loadInformation575', 0, ''), ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.5.3', 'loadInformation577', 0, ''), ('7821', 'CISCO', 1, 1, '', 'loadInformation621', 0, ''), ('7841', 'CISCO', 1, 1, '', 'loadInformation622', 0, ''), ('7861', 'CISCO', 1, 1, '', 'loadInformation623', 0, ''), ('VXC 6215', 'CISCO', 1, 1, '', 'loadInformation634', 0, ''), ('8831', 'CISCO', 1, 1, '', 'loadInformation659', 0, ''), ('8841', 'CISCO', 1, 1, '', 'loadInformation683', 0, ''), ('8851', 'CISCO', 1, 1, '', 'loadInformation684', 0, ''), ('8861', 'CISCO', 1, 1, '', 'loadInformation685', 0, ''), ". "('Analog', 'CISCO', 1, 1, '', 'loadInformation30027', 0, ''), ('ISDN', 'CISCO', 1, 1, '', 'loadInformation30028', 0, ''), ('SCCP GW', 'CISCO', 1, 1, '', 'loadInformation30032', 0, ''), ('IP-STE', 'CISCO', 1, 1, '', 'loadInformation30035', 0, ''), ". "('SPA 521S', 'CISCO', 1, 1, '', 'loadInformation80000', 0, ''), ('SPA 502G', 'CISCO', 1, 1, '', 'loadInformation80003', 0, ''), ('SPA 504G', 'CISCO', 1, 1, '', 'loadInformation80004', 0, ''), ('SPA 525G', 'CISCO', 1, 1, '', 'loadInformation80005', 0, ''), ('SPA 525G2', 'CISCO', 1, 1, '', 'loadInformation80009', 0, ''), ('SPA 303G', 'CISCO', 1, 1, '', 'loadInformation80011', 0, ''),". @@ -681,7 +692,8 @@ function InstallDB_fillsccpdevmodel() { return true; } -function InstallDB_updateSccpDevice() { +function InstallDB_updateSccpDevice() +{ global $db; outn("
  • " . _("Update sccpdevice") . "
  • "); $sql = "UPDATE `sccpdevice` set audio_tos='0xB8',audio_cos='6',video_tos='0x88',video_cos='5' where audio_tos=NULL or audio_tos='';"; @@ -691,7 +703,8 @@ function InstallDB_updateSccpDevice() { } } -function InstallDB_createButtonConfigTrigger() { +function InstallDB_createButtonConfigTrigger() +{ global $db; outn("
  • " . _("(Re)Create buttonconfig trigger") . "
  • "); $sql = "DROP TRIGGER IF EXISTS sccp_trg_buttonconfig;"; @@ -725,7 +738,8 @@ function InstallDB_createButtonConfigTrigger() { // outn("
  • " . $sql . "
  • "); return true; } -function InstallDB_updateDBVer($sccp_compatible) { +function InstallDB_updateDBVer($sccp_compatible) +{ global $db; outn("
  • " . _("Update DB Ver") . "
  • "); $sql = "REPLACE INTO `sccpsettings` (`keyword`, `data`, `seq`, `type`), VALUES ('SccpDBmodel', '"+$sccp_compatible+ "','30','0');"; @@ -733,10 +747,11 @@ function InstallDB_updateDBVer($sccp_compatible) { if (DB::IsError($check)) { die_freepbx(sprintf(_("Error updating sccpdeviceconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage())); } - return true; + return true; } -function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { +function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) +{ global $db; outn("
  • " . _("(Re)Create sccpdeviceconfig view") . "
  • "); $sql = ""; @@ -765,11 +780,11 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { GROUP BY sccpdevice.name;"; } else { /* $sql = " - CREATE OR REPLACE + CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS - SELECT IF(sccpdevice._profileid = 0, - GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) ORDER BY defbutton.instance ASC SEPARATOR ';' ), + SELECT IF(sccpdevice._profileid = 0, + GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) ORDER BY defbutton.instance ASC SEPARATOR ';' ), GROUP_CONCAT( CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) ORDER BY userbutton.instance ASC SEPARATOR ';' ) ) AS button, sccpdevice.* @@ -778,28 +793,27 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { LEFT JOIN sccpbuttonconfig userbutton ON ( userbutton.ref = sccpdevice._loginname ) LEFT JOIN sccpline ON ( sccpline.name = sccpdevice._loginname) GROUP BY sccpdevice.name;"; -*/ +*/ $sql = "DROP VIEW IF EXISTS `sccpdeviceconfig`; DROP VIEW IF EXISTS `sccpuserconfig`;"; /// global $hw_mobil; global $mobile_hw; if ($mobile_hw == '1') { - $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS + $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) ORDER BY instance ASC SEPARATOR ';' ) AS sccpbutton, sccpdevice.* FROM sccpdevice LEFT JOIN sccpbuttonconfig ON (sccpbuttonconfig.reftype = 'sccpdevice' AND sccpbuttonconfig.ref = sccpdevice.name ) GROUP BY sccpdevice.name; "; - $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS + $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) ORDER BY instance ASC SEPARATOR ';' ) AS button, sccpuser.* FROM sccpuser LEFT JOIN sccpbuttonconfig ON ( sccpbuttonconfig.reftype = 'sccpuser' AND sccpbuttonconfig.ref = sccpuser.id) GROUP BY sccpuser.name; "; - } else { - $sql .= "CREATE OR REPLACE + $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS SELECT case sccpdevice._profileid @@ -813,7 +827,7 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { FROM sccpdevice LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice._loginname ) GROUP BY sccpdevice.name;"; - } + } } $results = $db->query($sql); if (DB::IsError($check)) { @@ -821,7 +835,8 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { } return true; } -function CreateBackUpConfig() { +function CreateBackUpConfig() +{ global $amp_conf; outn("
  • " . _("Create Config BackUp") . "
  • "); $cnf_int = \FreePBX::Config(); @@ -830,7 +845,7 @@ function CreateBackUpConfig() { $dir = $cnf_int->get('ASTETCDIR'); $fsql = $dir.'/sccp_backup_'.date("Ymd").'.sql'; - $result = exec('mysqldump '.$amp_conf['AMPDBNAME'].' --password='.$amp_conf['AMPDBPASS'].' --user='.$amp_conf['AMPDBUSER'].' --single-transaction >'.$fsql ,$output); + $result = exec('mysqldump '.$amp_conf['AMPDBNAME'].' --password='.$amp_conf['AMPDBPASS'].' --user='.$amp_conf['AMPDBUSER'].' --single-transaction >'.$fsql, $output); $zip = new \ZipArchive(); $filename = $dir . "/sccp_instal_backup" . date("Ymd"). ".zip"; @@ -853,7 +868,8 @@ function CreateBackUpConfig() { outn("
  • " . _("Create Config BackUp: ") . $filename ."
  • "); } -function RenameConfig() { +function RenameConfig() +{ global $amp_conf; outn("
  • " . _("Move Old Config") . "
  • "); $cnf_int = \FreePBX::Config(); @@ -869,7 +885,8 @@ function RenameConfig() { } } -function Setup_RealTime() { +function Setup_RealTime() +{ global $amp_conf; outn("
  • " . _("Pre config RealTime") . "
  • "); $cnf_int = \FreePBX::Config(); @@ -948,7 +965,7 @@ CheckSCCPManagerDBTables($table_req); #CheckPermissions(); CheckAsteriskVersion(); $sccp_compatible = CheckChanSCCPCompatible(); -if ($sccp_compatible == 0) { +if ($sccp_compatible == 0) { // die_freepbx('Chan Sccp not Found. Install it before continuing'); outn("
    "); outn("Chan Sccp not Found. Install it before continuing !"); diff --git a/page.sccp_adv.php b/page.sccp_adv.php index 405e0b1..73bb256 100644 --- a/page.sccp_adv.php +++ b/page.sccp_adv.php @@ -1,5 +1,7 @@ Sccp_manager; if (empty($spage->class_error)) { $display_page = $spage->AdvServerShowPage(); - $display_info = _("SCCP Advance Server Configuration"); + $display_info = _("SCCP Advance Server Configuration"); } else { $display_page = $spage->InfoServerShowPage(); - $display_info = _("SCCP Server Configuration"); + $display_info = _("SCCP Server Configuration"); } ?>
    -

    -
    -
    -
    -
    - -
    - $page) { ?> -
    - -
    - +

    +
    +
    +
    +
    + +
    + $page) { ?> +
    + +
    +
    -
    -
    -
    -
    +
    +
    +
    +

    - +
    diff --git a/views/server.setting.php b/views/server.setting.php index 3d5510c..31a6a61 100644 --- a/views/server.setting.php +++ b/views/server.setting.php @@ -21,13 +21,13 @@
    - ShowGroup('sccp_general',1); - echo $this->ShowGroup('sccp_dev_time_s',1); - echo $this->ShowGroup('sccp_net',1); - echo $this->ShowGroup('sccp_lang',1); - echo $this->ShowGroup('sccp_qos_config',1); - echo $this->ShowGroup('sccp_extpath_config',1); + ShowGroup('sccp_general', 1); + echo $this->ShowGroup('sccp_dev_time_s', 1); + echo $this->ShowGroup('sccp_net', 1); + echo $this->ShowGroup('sccp_lang', 1); + echo $this->ShowGroup('sccp_qos_config', 1); + echo $this->ShowGroup('sccp_extpath_config', 1); ?> @@ -43,7 +43,7 @@