-- Added new features for the future (now disabled)
-- Changed time zone settings -- Changed the list of supported codecs -- Added the ability to specify the DNS name as the server interface
This commit is contained in:
parent
809c11fc0c
commit
413bcf1b38
|
@ -75,7 +75,8 @@
|
|||
* + 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 Call Map (show Current call Information)
|
||||
*/
|
||||
|
||||
namespace FreePBX\modules;
|
||||
|
@ -94,7 +95,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
// 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.3'; // 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 !!!
|
||||
|
@ -243,7 +244,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
}
|
||||
// if ($child['type'] == 'SLD' || $child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SL' || $child['type'] == 'SLM' || $child['type'] == 'SLZ' || $child['type'] == 'SLZN' || $child['type'] == 'SLA') {
|
||||
if (in_array($child['type'], array('SLD','SLS','SLT','SL','SLM','SLZ','SLZN','SLA') )) {
|
||||
if (in_array($child['type'], array('SLD', 'SLS', 'SLT', 'SL', 'SLM', 'SLZ', 'SLTZN', 'SLA'))) {
|
||||
if (empty($child->value)) {
|
||||
$datav = (string) $child->default;
|
||||
} else {
|
||||
|
@ -519,12 +520,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
"buttons" => array(
|
||||
"name" => _("Device Buttons"),
|
||||
"page" => 'views/form.buttons.php'
|
||||
));
|
||||
));
|
||||
if ($this->sccpvalues['sccp_compatible']['data'] < '433') {
|
||||
$this->pagedata["sccpcodec"] = array(
|
||||
"name" => _("Device SCCP Codec"),
|
||||
"page" => 'views/server.codec.php'
|
||||
);
|
||||
"name" => _("Device SCCP Codec"),
|
||||
"page" => 'views/server.codec.php'
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -537,7 +538,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
"buttons" => array(
|
||||
"name" => _("Sip device Buttons"),
|
||||
"page" => 'views/form.sbuttons.php'
|
||||
));
|
||||
));
|
||||
// if ($this->sccpvalues['sccp_compatible']['data'] < '433') {
|
||||
// $this->pagedata["sccpcodec"] = array(
|
||||
// "name" => _("Device SCCP Codec"),
|
||||
|
@ -675,10 +676,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
// $this->sccp_create_sccp_init();
|
||||
$this->sccp_create_tftp_XML();
|
||||
|
||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload'));
|
||||
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload'));
|
||||
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone'));
|
||||
$msg []= 'Config Saved: ' . $res['Response'];
|
||||
$msg []= 'Info :' . $res['data'];
|
||||
$res = $this->srvinterface->sccp_reload();
|
||||
$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)
|
||||
return array('status' => true, 'message' => $msg, 'reload' => true);
|
||||
|
@ -694,9 +696,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
break;
|
||||
case 'save_ruser':
|
||||
// $res = $request;
|
||||
$res = $this->save_rouming_users($request);
|
||||
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'general');
|
||||
return array('status' => false, 'message' => print_r($res));
|
||||
$res = $this->save_rouming_users($request);
|
||||
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'general');
|
||||
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 suport - In the development---
|
||||
|
@ -731,7 +733,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$this->dbinterface->sccp_save_db("sccpbuttons", array(), 'delete', '', $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_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)
|
||||
|
@ -744,14 +747,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
if (!empty($request['idn'])) {
|
||||
$models = array();
|
||||
foreach ($request['idn'] as $idv) {
|
||||
$this->sccp_delete_device_XML($idv);
|
||||
$models []= array('name'=>$idv);
|
||||
$this->sccp_delete_device_XML($idv);
|
||||
$models [] = array('name' => $idv);
|
||||
}
|
||||
} else {
|
||||
$this->sccp_delete_device_XML('all');
|
||||
$this->sccp_delete_device_XML('all');
|
||||
$models = $this->dbinterface->get_db_SccpTableData("SccpDevice");
|
||||
}
|
||||
|
||||
|
||||
$this->sccp_create_tftp_XML(); // Default XML
|
||||
$ver_id = ' on found active model !';
|
||||
//return array('status' => false, 'message' => 'Error :'. print_r($models,1));
|
||||
|
@ -778,11 +781,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$msg = strpos($idv, 'SEP-');
|
||||
if (!(strpos($idv, 'SEP') === false)) {
|
||||
if ($cmd_id == 'reset_token') {
|
||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $idv));
|
||||
$msgr[] = $msg .' '. $res['Response'] . ' ' . $res['data'];
|
||||
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $idv));
|
||||
$res = $this->srvinterface->sccp_reset_token($idv);
|
||||
|
||||
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
|
||||
} else {
|
||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv));
|
||||
$msgr[] = $msg .' '. $res['Response'] . ' ' . $res['data'];
|
||||
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv));
|
||||
$res = $this->srvinterface->sccp_device_reset($idv);
|
||||
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
|
||||
}
|
||||
// $msg = print_r($this->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $idv)), 1);
|
||||
// $msg = $res['Response'] . ' ' . $res['data'];
|
||||
|
@ -792,12 +798,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
foreach ($dev_list as $key => $data) {
|
||||
if ($cmd_id == 'reset_token') {
|
||||
if (($data['token'] == 'Rej') || ($data['status'] == 'Token ')) {
|
||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $key));
|
||||
// $msg .= 'Send Token reset to :' . $key . ' <br>';
|
||||
$msgr[] = 'Send Token reset to :' . $key ;
|
||||
$res = $this->srvinterface->sccp_reset_token($idv);
|
||||
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $key));
|
||||
// $msg .= 'Send Token reset to :' . $key . ' <br>';
|
||||
$msgr[] = 'Send Token reset to :' . $key;
|
||||
}
|
||||
} else {
|
||||
$res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $key));
|
||||
$res = $this->srvinterface->sccp_device_reset($idv);
|
||||
// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $key));
|
||||
// $msg .= $res['Response'] . ' ' . $res['data'] . ' <br>';
|
||||
$msgr[] = $res['Response'] . ' ' . $res['data'];
|
||||
}
|
||||
|
@ -807,7 +815,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)
|
||||
return array('status' => true, 'message' => $msgr, 'reload' => true);
|
||||
return array('status' => true, 'message' => $msgr, 'reload' => true);
|
||||
// return array('status' => true, 'message' => 'Reset command send <br>' . $msg, 'reload' => true);
|
||||
// }
|
||||
break;
|
||||
|
@ -821,6 +829,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$hw_list[] = array('name' => $idv);
|
||||
}
|
||||
if ($idv == 'all') {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -828,7 +837,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$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)
|
||||
return array('status' => true, 'message' => 'Update Butons Labels Complite ' . $msg, 'reload' => true);
|
||||
|
||||
|
||||
case 'model_add':
|
||||
$save_settings = array();
|
||||
$key_name = array('model', 'vendor', 'dns', 'buttons', 'loadimage', 'loadinformationid', 'nametemplate');
|
||||
|
@ -892,7 +901,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$id_name = $request['softkey'];
|
||||
unset($this->sccp_conf_init[$id_name]);
|
||||
$this->sccp_create_sccp_init();
|
||||
$msg = print_r($this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')), 1);
|
||||
$msg = print_r($this->srvinterface->sccp_reload(), 1);
|
||||
// $msg = print_r($this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')), 1);
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
break;
|
||||
|
@ -911,8 +921,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
// !TODO!: -TODO-: Check SIP Suport Enabled
|
||||
$this->sccp_create_xmlSoftkey();
|
||||
|
||||
$msg = print_r($this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')), 1);
|
||||
$msg = print_r($this->srvinterface->sccp_reload(), 1);
|
||||
// $msg = print_r($this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')), 1);
|
||||
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
// return $this->sccp_conf_init[$id_name];
|
||||
|
@ -945,29 +955,29 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
if (empty($result)) {
|
||||
return array();
|
||||
}
|
||||
/* $res_info = $this->aminterface->core_list_all_exten('exten');
|
||||
if (!empty($res_info)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$tpm_info = $res_info[$value['name']];
|
||||
if (!empty($tpm_info)) {
|
||||
$result[$key]['line_status'] = $tpm_info['status'];
|
||||
$result[$key]['line_statustext'] = $tpm_info['statustext'];
|
||||
} else {
|
||||
$result[$key]['line_status'] = '';
|
||||
$result[$key]['line_statustext'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
/* $res_info = $this->aminterface->core_list_all_exten('exten');
|
||||
if (!empty($res_info)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$tpm_info = $res_info[$value['name']];
|
||||
if (!empty($tpm_info)) {
|
||||
$result[$key]['line_status'] = $tpm_info['status'];
|
||||
$result[$key]['line_statustext'] = $tpm_info['statustext'];
|
||||
} else {
|
||||
$result[$key]['line_status'] = '';
|
||||
$result[$key]['line_statustext'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
return $result;
|
||||
break;
|
||||
case 'getPhoneGrid':
|
||||
$cmd_type = !empty($request['type']) ? $request['type'] : '';
|
||||
|
||||
$result = $this->dbinterface->get_db_SccpTableData('SccpDevice', array('type'=>$cmd_type));
|
||||
if ($cmd_type == 'cisco-sip'){
|
||||
return $result;
|
||||
|
||||
$result = $this->dbinterface->get_db_SccpTableData('SccpDevice', array('type' => $cmd_type));
|
||||
if ($cmd_type == 'cisco-sip') {
|
||||
return $result;
|
||||
}
|
||||
$staus = $this->srvinterface->sccp_get_active_device();
|
||||
if (empty($result)) {
|
||||
|
@ -1048,6 +1058,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
* * Save Hardware Device Information to Db + ???? Create / update XML Profile
|
||||
*
|
||||
*/
|
||||
|
||||
function get_buttons_phone($get_settings, $ref_id = '', $ref_type = 'sccpdevice') {
|
||||
// Get Model Buttons info
|
||||
$res = array();
|
||||
|
@ -1096,7 +1107,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 'monitor':
|
||||
$btn_t = 'speeddial';
|
||||
|
@ -1161,7 +1172,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
}
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
function save_hw_phone($get_settings, $validateonly = false) {
|
||||
|
@ -1215,13 +1225,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$i++;
|
||||
};
|
||||
$value = implode(";", $save_codec);
|
||||
} else $value = 'all'; // 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';
|
||||
if (!empty($get_settings[$hdr_prefix . 'devlang'])) {
|
||||
$lang_data = $this->extconfigs->getextConfig('sccp_lang',$get_settings[$hdr_prefix . 'devlang']);
|
||||
$lang_data = $this->extconfigs->getextConfig('sccp_lang', $get_settings[$hdr_prefix . 'devlang']);
|
||||
if (!empty($lang_data)) {
|
||||
$value = $lang_data['codepage'];
|
||||
}
|
||||
|
@ -1295,8 +1306,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
// Get Model Buttons info
|
||||
// $save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, 'sccpdevice');
|
||||
$save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, $hw_type);
|
||||
|
||||
$save_buttons = $this->get_buttons_phone($get_settings, $name_dev, $hw_type);
|
||||
|
||||
// Sace Buttons config
|
||||
$this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, $update_hw, '', $name_dev);
|
||||
|
||||
|
@ -1304,9 +1315,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$this->sccp_create_device_XML($name_dev);
|
||||
|
||||
if ($hw_id == 'new') {
|
||||
$this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $name_dev));
|
||||
// $this->srvinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $name_dev));
|
||||
$this->srvinterface->sccp_device_reset($name_dev);
|
||||
} else {
|
||||
$this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone', 'name' => $name_dev));
|
||||
$this->srvinterface->sccp_device_restart($name_dev);
|
||||
// $this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone', 'name' => $name_dev));
|
||||
}
|
||||
|
||||
return $save_settings;
|
||||
|
@ -1384,9 +1397,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
case 'sccp_ntp_timezone':
|
||||
$tz_id = $value;
|
||||
$TZdata = $this->extconfigs->getextConfig('sccp_timezone', $tz_id);
|
||||
$TZdata = $this->extconfigs->getextConfig('sccp_timezone_offset', $tz_id);
|
||||
if (!empty($TZdata)) {
|
||||
$save_settings[] = array('keyword' => 'tzoffset', 'data' => ($TZdata['offset'] / 60),
|
||||
$save_settings[] = array('keyword' => 'tzoffset', 'data' => ($TZdata / 60),
|
||||
'seq' => '98',
|
||||
'type' => '2');
|
||||
}
|
||||
|
@ -1403,28 +1416,26 @@ 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_';
|
||||
|
||||
$save_buttons = array();
|
||||
$save_settings = array();
|
||||
/*
|
||||
$def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'),
|
||||
'devstate' => array('name' => 'Coffee', 'value' => 'coffee'),
|
||||
'monitor' => array('name' => 'Record Calls', 'value' => '')
|
||||
);
|
||||
*
|
||||
*/
|
||||
/*
|
||||
$def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'),
|
||||
'devstate' => array('name' => 'Coffee', 'value' => 'coffee'),
|
||||
'monitor' => array('name' => 'Record Calls', 'value' => '')
|
||||
);
|
||||
*
|
||||
*/
|
||||
$name_dev = '';
|
||||
$db_field = $this->dbinterface->get_db_SccpTableData("get_colums_sccpuser");
|
||||
// $hw_id = (empty($get_settings['sccp_deviceid'])) ? 'new' : $get_settings['sccp_deviceid'];
|
||||
// $update_hw = ($hw_id == 'new') ? 'update' : 'clear';
|
||||
$hw_prefix = 'SEP';
|
||||
$name_dev = $get_settings[$hdr_prefix . 'id'];
|
||||
|
||||
|
||||
foreach ($db_field as $data) {
|
||||
$key = (string) $data['Field'];
|
||||
$value = "";
|
||||
|
@ -1493,21 +1504,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
// Save / Updade Base
|
||||
// return $save_settings;
|
||||
// $update_hw = ($hw_id == 'new') ? 'update' : 'clear';
|
||||
|
||||
|
||||
$this->dbinterface->sccp_save_db("sccpuser", $save_settings, 'replace', 'name');
|
||||
|
||||
$save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, 'sccpline');
|
||||
$save_buttons = $this->get_buttons_phone($get_settings, $name_dev, 'sccpline');
|
||||
// Sace Buttons config
|
||||
$this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons,'clear', '', $name_dev);
|
||||
$this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, 'clear', '', $name_dev);
|
||||
return $save_buttons;
|
||||
|
||||
return $save_settings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getSccpSettingFromDB() {
|
||||
$raw_data = $this->dbinterface->get_db_SccpSetting();
|
||||
foreach ($raw_data as $var) {
|
||||
|
@ -1554,7 +1561,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
public function getCodecs($type, $showDefaults = false) {
|
||||
$allSupported = array();
|
||||
// $Sccp_Codec = array('gsm','slin16','alow','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');
|
||||
$Sccp_Codec = array('gsm', 'slin16', 'alaw', 'ulaw', 'g722', 'g723', 'g726', 'g728', 'g729', 'ilibc', 'opus', 'h264', 'h263', 'h265', 'h261');
|
||||
switch ($type) {
|
||||
case 'audio':
|
||||
$lcodecs = $this->getMyConfig('voicecodecs');
|
||||
|
@ -1577,12 +1584,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
break;
|
||||
}
|
||||
foreach ($allCodecs as $c => $v) {
|
||||
if (array_search($c,$Sccp_Codec) !=null) {
|
||||
$allSupported[$c] =$v;
|
||||
if (array_search($c, $Sccp_Codec) != null) {
|
||||
$allSupported[$c] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($lcodecs) || (!is_array($lcodecs)) ) {
|
||||
if (empty($lcodecs) || (!is_array($lcodecs))) {
|
||||
if (empty($allSupported)) {
|
||||
$lcodecs = $allCodecs;
|
||||
} else {
|
||||
|
@ -1592,7 +1599,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
foreach ($lcodecs as $c => $v) {
|
||||
if (isset($allSupported[$c])) {
|
||||
$codecs[$c] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1792,17 +1799,18 @@ 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);
|
||||
$this->xmlinterface->create_xmlSoftkeyset($this->sccp_conf_init, $this->sccppath, $keyl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DialPlan
|
||||
*
|
||||
|
@ -1845,7 +1853,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
|
||||
function save_DialPlan($get_settings) {
|
||||
|
||||
|
||||
$confDir = $this->sccppath["tftp_dialplan"];
|
||||
return $this->xmlinterface->save_DialPlan($confDir, $get_settings);
|
||||
}
|
||||
|
@ -1854,48 +1862,48 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
* Update Butons Labels on mysql DB
|
||||
*
|
||||
*/
|
||||
|
||||
private function sccp_db_update_butons($hw_list = array()) {
|
||||
|
||||
|
||||
$save_buttons = array();
|
||||
if (!empty($hw_list)) {
|
||||
$buton_list = array();
|
||||
foreach ($hw_list as $value) {
|
||||
$buton_tmp =$this->dbinterface->get_db_SccpTableData("get_sccpdevice_buttons", array('buttontype'=>'speeddial','id'=>$value['name']));
|
||||
$buton_tmp = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial', 'id' => $value['name']));
|
||||
// die(print_r($buton_tmp,1));
|
||||
if (!empty($buton_tmp)) {
|
||||
$buton_list = array_merge($buton_list, $buton_tmp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$buton_list = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_buttons", array('buttontype'=>'speeddial'));
|
||||
$buton_list = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial'));
|
||||
}
|
||||
// die(print_r($buton_list,1));
|
||||
if (empty($buton_list)) {
|
||||
return array('Response'=> ' Found 0 device ', 'data'=> '');
|
||||
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');
|
||||
$copy_fld = array('ref', 'reftype', 'instance', 'buttontype');
|
||||
$user_list = $user_list = $this->dbinterface->get_db_SccpTableByID("SccpExtension", Array(), 'name');
|
||||
foreach ($buton_list as $value) {
|
||||
$btn_opt = explode(',',$value['options']);
|
||||
$btn_opt = explode(',', $value['options']);
|
||||
$btn_id = $btn_opt[0];
|
||||
if (!empty($user_list[$btn_id])){
|
||||
if (!empty($user_list[$btn_id])) {
|
||||
if ($user_list[$btn_id]['label'] != $value['name']) {
|
||||
$btn_data['name'] = $user_list[$btn_id]['label'];
|
||||
foreach ($copy_fld as $ckey) {
|
||||
$btn_data[$ckey] = $value[$ckey];
|
||||
$btn_data[$ckey] = $value[$ckey];
|
||||
}
|
||||
$save_buttons[] = $btn_data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (empty($save_buttons)) {
|
||||
return array('Response'=> 'No update required', 'data'=> ' 0 - records ');
|
||||
return array('Response' => 'No update required', 'data' => ' 0 - records ');
|
||||
}
|
||||
$res = $this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, 'replace', '','');
|
||||
return array('Response'=> 'Update records :'.count($save_buttons),'data'=>$res);
|
||||
$res = $this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, 'replace', '', '');
|
||||
return array('Response' => 'Update records :' . count($save_buttons), 'data' => $res);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Save Config Value to mysql DB
|
||||
* sccp_db_save_setting(empty) - Save All settings from $sccpvalues
|
||||
|
@ -1954,36 +1962,36 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$sccp_native = true;
|
||||
$data_value = array();
|
||||
$dev_line_data = null;
|
||||
|
||||
|
||||
$dev_config = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id));
|
||||
// Support Cisco Sip Device
|
||||
if (!empty($dev_config['type'])) {
|
||||
if (strpos($dev_config['type'],'sip') !== false) {
|
||||
if (strpos($dev_config['type'], 'sip') !== false) {
|
||||
$sccp_native = false;
|
||||
$tmp_bind =$this->sipconfigs->getSipConfig();
|
||||
$dev_ext_config = $this->dbinterface->get_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields'=>'sip_ext'));
|
||||
$tmp_bind = $this->sipconfigs->getSipConfig();
|
||||
$dev_ext_config = $this->dbinterface->get_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields' => 'sip_ext'));
|
||||
$data_value = array_merge($data_value, $dev_ext_config);
|
||||
$data_tmp = explode(';',$dev_ext_config['sip_lines']);
|
||||
$data_value['sbind']=array();
|
||||
$data_tmp = explode(';', $dev_ext_config['sip_lines']);
|
||||
$data_value['sbind'] = array();
|
||||
foreach ($data_tmp as $value) {
|
||||
$tmp_line = explode(',',$value);
|
||||
$tmp_line = explode(',', $value);
|
||||
switch ($tmp_line[0]) {
|
||||
case 'line':
|
||||
$dev_line_data= $this->sipconfigs->get_db_sip_TableData('DeviceById',array('id'=>$tmp_line[1]));
|
||||
$f_linetype = ($dev_line_data['dial'] == 'PJSIP')? 'pjsip':'sip';
|
||||
case 'line':
|
||||
$dev_line_data = $this->sipconfigs->get_db_sip_TableData('DeviceById', array('id' => $tmp_line[1]));
|
||||
$f_linetype = ($dev_line_data['dial'] == 'PJSIP') ? 'pjsip' : 'sip';
|
||||
$dev_line_data['sbind'] = $tmp_bind[$f_linetype];
|
||||
if (!empty($dev_line_data)) {
|
||||
$data_value['siplines'][] = $dev_line_data;
|
||||
}
|
||||
if ($tmp_line[2] =='default') {
|
||||
$data_value['sbind']=$tmp_bind[$f_linetype];
|
||||
if ($tmp_line[2] == 'default') {
|
||||
$data_value['sbind'] = $tmp_bind[$f_linetype];
|
||||
}
|
||||
break;
|
||||
case 'speeddial':
|
||||
$data_value['speeddial'][] = array("name"=>$tmp_line[1],"dial"=>$tmp_line[2]);
|
||||
case 'speeddial':
|
||||
$data_value['speeddial'][] = array("name" => $tmp_line[1], "dial" => $tmp_line[2]);
|
||||
break;
|
||||
default:
|
||||
$data_value['sipfunctions'][] = $tmp_line;
|
||||
$data_value['sipfunctions'][] = $tmp_line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1992,11 +2000,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
}
|
||||
// return print_r($dev_config ,true);
|
||||
|
||||
|
||||
foreach ($this->sccpvalues as $key => $value) {
|
||||
$data_value[$key] = $value['data'];
|
||||
}
|
||||
$data_value['ntp_timezone_id'] = $this->extconfigs->getextConfig('sccp_timezone', $data_value['ntp_timezone']);
|
||||
//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'] = '';
|
||||
|
@ -2010,7 +2021,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
// return print_r($data_value,true);
|
||||
// return print_r($dev_config,true);
|
||||
|
||||
|
||||
$lang_data = $this->extconfigs->getextConfig('sccp_lang');
|
||||
if (!$sccp_native) {
|
||||
return $this->xmlinterface->create_SEP_SIP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data);
|
||||
|
@ -2075,7 +2086,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
fclose($fh);
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
$filename = $result . "." . gethostname() . ".zip";
|
||||
$filename = $result . "." . gethostname() . ".zip";
|
||||
if ($zip->open($filename, \ZIPARCHIVE::CREATE)) {
|
||||
$zip->addFile($result);
|
||||
$zip->addFile($backup_info);
|
||||
|
@ -2106,8 +2117,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
case "permit":
|
||||
$this->sccp_conf_init['general'][$key] = explode(';', $value['data']);
|
||||
break;
|
||||
case "devlang":
|
||||
$lang_data = $this->extconfigs->getextConfig('sccp_lang',$value['data']);
|
||||
case "devlang":
|
||||
$lang_data = $this->extconfigs->getextConfig('sccp_lang', $value['data']);
|
||||
if (!empty($lang_data)) {
|
||||
$this->sccp_conf_init['general']['phonecodepage'] = $lang_data['codepage'];
|
||||
}
|
||||
|
@ -2160,7 +2171,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$raw_settings[$i]['validate'] = '-;-';
|
||||
if (!empty($raw_settings[$i]['loadimage'])) {
|
||||
$raw_settings[$i]['validate'] = 'no;';
|
||||
if (((strtolower($raw_settings[$i]['vendor']) == 'cisco') || (strtolower($raw_settings[$i]['vendor']) == 'cisco-sip')) && !empty($dir_list) ){
|
||||
if (((strtolower($raw_settings[$i]['vendor']) == 'cisco') || (strtolower($raw_settings[$i]['vendor']) == 'cisco-sip')) && !empty($dir_list)) {
|
||||
foreach ($dir_list as $filek) {
|
||||
switch ($search_mode) {
|
||||
case 'pro':
|
||||
|
@ -2227,7 +2238,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$default_hint = '@ext-local';
|
||||
|
||||
// get all extension
|
||||
$res = $this->aminterface->core_list_all_exten('hint', $filter);
|
||||
// $res = $this->srvinterface->core_list_all_exten('hint', $filter);
|
||||
|
||||
if (empty($res)) {
|
||||
// Old Req get all hints
|
||||
$tmp_data = $this->srvinterface->sccp_list_all_hints();
|
||||
|
@ -2422,4 +2434,5 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,792 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
/* !TODO!: Re-Indent this file. -TODO-: What do you mean? coreaccessinterface ?? */
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
abstract class Message {
|
||||
|
||||
const EOL = "\r\n";
|
||||
const EOM = "\r\n\r\n";
|
||||
|
||||
protected $lines;
|
||||
protected $variables;
|
||||
protected $keys;
|
||||
protected $createdDate;
|
||||
private $_responseHandler;
|
||||
|
||||
public function getResponseHandler() {
|
||||
if (strlen($this->_responseHandler) > 0) {
|
||||
//throw new PAMIException('Hier:' . $this->_responseHandler);
|
||||
return (string) $this->_responseHandler;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public function setResponseHandler($responseHandler) {
|
||||
if (0 == strlen($responseHandler)) {
|
||||
return ;
|
||||
}
|
||||
$className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\Message\\Response\\' . $responseHandler . 'Response';
|
||||
if (class_exists($className, true)) {
|
||||
$this->_responseHandler = $responseHandler;
|
||||
} else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
public function setVariable($key, $value) {
|
||||
$key = strtolower($key);
|
||||
$this->variables[$key] = $value;
|
||||
}
|
||||
|
||||
public function getVariable($key) {
|
||||
$key = strtolower($key);
|
||||
if (!isset($this->variables[$key])) {
|
||||
return null;
|
||||
}
|
||||
return $this->variables[$key];
|
||||
}
|
||||
|
||||
protected function setKey($key, $value) {
|
||||
$key = strtolower((string) $key);
|
||||
$this->keys[$key] = (string) $value;
|
||||
}
|
||||
|
||||
public function getKey($key) {
|
||||
$key = strtolower($key);
|
||||
if (!isset($this->keys[$key])) {
|
||||
return null;
|
||||
}
|
||||
//return (string)$this->keys[$key];
|
||||
return $this->keys[$key];
|
||||
}
|
||||
|
||||
public function getVariables() {
|
||||
return $this->variables;
|
||||
}
|
||||
|
||||
public function getActionID() {
|
||||
return $this->getKey('ActionID');
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return $this->keys;
|
||||
}
|
||||
|
||||
private function serializeVariable($key, $value) {
|
||||
return "Variable: $key=$value";
|
||||
}
|
||||
|
||||
protected function finishMessage($message) {
|
||||
return $message . self::EOL . self::EOL;
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
$result = array();
|
||||
foreach ($this->getKeys() as $k => $v) {
|
||||
$result[] = $k . ': ' . $v;
|
||||
}
|
||||
foreach ($this->getVariables() as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
foreach ($v as $singleValue) {
|
||||
$result[] = $this->serializeVariable($k, $singleValue);
|
||||
}
|
||||
} else {
|
||||
$result[] = $this->serializeVariable($k, $v);
|
||||
}
|
||||
}
|
||||
$mStr = $this->finishMessage(implode(self::EOL, $result));
|
||||
return $mStr;
|
||||
}
|
||||
|
||||
public function setActionID($actionID) {
|
||||
if (0 == strlen($actionID)) {
|
||||
// throw new PAMIException('ActionID cannot be empty.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($actionID) > 69) {
|
||||
// throw new PAMIException('ActionID can be at most 69 characters long.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setKey('ActionID', $actionID);
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->lines = array();
|
||||
$this->variables = array();
|
||||
$this->keys = array();
|
||||
$this->createdDate = time();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface\Message;
|
||||
|
||||
abstract class Response {
|
||||
|
||||
protected $_events;
|
||||
protected $_completed;
|
||||
protected $keys;
|
||||
|
||||
public function isSuccess() {
|
||||
return stristr($this->getKey('Response'), 'Error') === false;
|
||||
}
|
||||
|
||||
public function isComplete() {
|
||||
return $this->_completed;
|
||||
}
|
||||
|
||||
public function isList() {
|
||||
return
|
||||
stristr($this->getKey('EventList'), 'start') !== false || stristr($this->getMessage(), 'follow') !== false
|
||||
;
|
||||
}
|
||||
|
||||
public function setActionId($actionId) {
|
||||
$this->setKey('ActionId', $actionId);
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return $this->getKey('Message');
|
||||
}
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
|
||||
$this->_events = array();
|
||||
$this->_eventsCount = 0;
|
||||
$this->_completed = !$this->isList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//namespace FreePBX\modules\Sccp_manager\aminterface\Message;
|
||||
|
||||
class LoginAction extends \FreePBX\modules\Sccp_manager\aminterface\Message {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $user AMI username.
|
||||
* @param string $password AMI password.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user, $password) {
|
||||
parent::__construct('Login');
|
||||
$this->setKey('Action', $what);
|
||||
$this->setKey('ActionID', microtime(true));
|
||||
$this->setKey('Username', $user);
|
||||
$this->setKey('Secret', $password);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class aminterface {
|
||||
|
||||
var $_socket;
|
||||
var $_error;
|
||||
var $_config;
|
||||
// var $ProcessingMessage;
|
||||
private $_lastActionClass;
|
||||
private $_lastActionId;
|
||||
private $_lastRequestedResponseHandler;
|
||||
private $_ProcessingMessage;
|
||||
private $_responseFactory;
|
||||
|
||||
public function __construct($parent_class = null) {
|
||||
global $amp_conf;
|
||||
$this->paren_class = $parent_class;
|
||||
$this->_socket = false;
|
||||
$this->_error = array();
|
||||
$this->_config = array('host' => 'localhost', 'user' => '', 'pass' => '', 'port' => '5038', 'tsoket' => 'tcp://', 'timeout' => 30, 'enabled' => false);
|
||||
$fld_conf = array('user' => 'AMPMGRUSER', 'pass' => 'AMPMGRPASS');
|
||||
if (isset($amp_conf['AMPMGRUSER'])) {
|
||||
foreach ($fld_conf as $key => $value) {
|
||||
if (isset($amp_conf[$value])) {
|
||||
$this->_config[$key] = $amp_conf[$value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$Ver = '13.0.4';
|
||||
if ($this->_config['enabled']) {
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'AMI data ver: ' . $Ver);
|
||||
} else {
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'Disabled AMI ver: ' . $Ver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a tcp connection to ami.
|
||||
*
|
||||
*/
|
||||
public function open() {
|
||||
$cString = $this->_config['tsoket'] . $this->_config['host'] . ':' . $this->_config['port'];
|
||||
$this->_context = stream_context_create();
|
||||
$errno = 0;
|
||||
$errstr = '';
|
||||
$this->_socket = @stream_socket_client(
|
||||
$cString, $errno, $errstr,
|
||||
$this->_config['timeout'], STREAM_CLIENT_CONNECT, $this->_context
|
||||
);
|
||||
if ($this->_socket === false) {
|
||||
$this->_errorException('Error connecting to ami: ' . $errstr . $cString);
|
||||
return false;
|
||||
}
|
||||
// FreePBX\modules\Sccp_manager\aminterface\Message\LoginAction::
|
||||
$msg = new aminerface\Message\LoginAction($this->_config['user'], $this->_config['pass']);
|
||||
|
||||
$response = $this->send($msg);
|
||||
return $response;
|
||||
/*
|
||||
$params = array('Action' => 'Login', 'UserName' => $this->_config['user'], 'Secret' => $this->_config['pass'], 'Events' => 'on');
|
||||
$id = @stream_get_line($this->_socket, 1024, aminterface\Message::EOL);
|
||||
|
||||
if (strstr($id, 'Asterisk') === false) {
|
||||
$this->_errorException('Unknown peer. Is this an ami?: ' . $id);
|
||||
return false;
|
||||
}
|
||||
$response = $this->send($params);
|
||||
if (!$response->isSuccess()) {
|
||||
$this->_errorException('Could not connect: ' . $response->getMessage());
|
||||
return false;
|
||||
}
|
||||
@stream_set_blocking($this->_socket, 0);
|
||||
$this->_ProcessingMessage = '';
|
||||
//register_tick_function(array($this, 'process'));
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection to ami.
|
||||
*/
|
||||
public function close() {
|
||||
@stream_socket_shutdown($this->_socket, STREAM_SHUT_RDWR);
|
||||
}
|
||||
|
||||
public function send($message) {
|
||||
$messageToSend = $message->serialize();
|
||||
/* foreach ($params as $key => $value) {
|
||||
$messageToSend .= $key . ': ' . $value . aminterface\Message::EOL;
|
||||
}
|
||||
$messageToSend .= aminterface\Message::EOL;
|
||||
*
|
||||
*/
|
||||
$length = strlen($messageToSend);
|
||||
|
||||
$this->_lastActionId = $message->getActionId();
|
||||
$this->_lastRequestedResponseHandler = $message->getResponseHandler();
|
||||
$this->_lastActionClass = $message;
|
||||
|
||||
if (@fwrite($this->_socket, $messageToSend) < $length) {
|
||||
$this->_errorException('Could not send message');
|
||||
return false;
|
||||
}
|
||||
while (1) {
|
||||
stream_set_timeout($this->_socket, 1);
|
||||
// stream_set_timeout($this->_socket, (isset($this->socket_param['timeout']) ? $this->socket_param['timeout'] : 1));
|
||||
$this->process();
|
||||
$info = stream_get_meta_data($this->_socket);
|
||||
if ($info['timed_out'] == false) {
|
||||
$response = $this->getRelated($message);
|
||||
if ($response != false) {
|
||||
$this->_lastActionId = false;
|
||||
return $response;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_errorException("Read waittime: " . ($this->socket_param['timeout']) . " exceeded (timeout).\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getRelated($message) {
|
||||
$ret = false;
|
||||
$id = 0;
|
||||
// $id = $message->getActionID('ActionID');
|
||||
if (isset($this->_incomingQueue[$id])) {
|
||||
$response = $this->_incomingQueue[$id];
|
||||
if ($response->isComplete()) {
|
||||
unset($this->_incomingQueue[$id]);
|
||||
$ret = $response;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected function getMessages() {
|
||||
$msgs = array();
|
||||
// Read something.
|
||||
$read = @fread($this->_socket, 65535);
|
||||
if ($read === false || @feof($this->_socket)) {
|
||||
$this->_errorException('Error reading');
|
||||
}
|
||||
$this->_ProcessingMessage .= $read;
|
||||
// If we have a complete message, then return it. Save the rest for
|
||||
// later.
|
||||
return $msgs;
|
||||
while (($marker = strpos($this->_ProcessingMessage, Message::EOM))) {
|
||||
$msg = substr($this->_ProcessingMessage, 0, $marker);
|
||||
$this->_ProcessingMessage = substr(
|
||||
$this->_ProcessingMessage, $marker + strlen(Message::EOM)
|
||||
);
|
||||
$msgs[] = $msg;
|
||||
}
|
||||
return $msgs;
|
||||
}
|
||||
|
||||
public function process() {
|
||||
$msgs = $this->getMessages();
|
||||
foreach ($msgs as $aMsg) {
|
||||
$resPos = strpos($aMsg, 'Response:');
|
||||
$evePos = strpos($aMsg, 'Event:');
|
||||
if (($resPos !== false) && (($resPos < $evePos) || $evePos === false)) {
|
||||
$response = $this->_msgToResponse($aMsg);
|
||||
$this->_incomingQueue[$this->_lastActionId] = $response;
|
||||
} else if ($evePos !== false) {
|
||||
/* $event = $this->_messageToEvent($aMsg);
|
||||
$response = $this->findResponse($event);
|
||||
if ($response === false || $response->isComplete()) {
|
||||
$this->dispatch($event);
|
||||
} else {
|
||||
$response->addEvent($event);
|
||||
}
|
||||
*
|
||||
*/
|
||||
} else {
|
||||
// broken ami.. sending a response with events without
|
||||
// Event and ActionId
|
||||
$bMsg = 'Event: ResponseEvent' . "\r\n";
|
||||
$bMsg .= 'ActionId: ' . $this->_lastActionId . "\r\n" . $aMsg;
|
||||
$event = $this->_messageToEvent($bMsg);
|
||||
$response = $this->findResponse($event);
|
||||
$response->addEvent($event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _msgToResponse($msg) {
|
||||
$response = $this->_msgFromRaw($msg, $this->_lastActionClass, $this->_lastRequestedResponseHandler);
|
||||
/* $actionId = $response->getActionId();
|
||||
if ($actionId === null) {
|
||||
$actionId = $this->_lastActionId;
|
||||
$response->setActionId($this->_lastActionId);
|
||||
}
|
||||
*
|
||||
*/
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function _msgFromRaw($message, $requestingaction = false, $responseHandler = false) {
|
||||
|
||||
$_className = false;
|
||||
if ($responseHandler != false) {
|
||||
$_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\Response';
|
||||
// $_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . $responseHandler . 'Response';
|
||||
} else if ($requestingaction != false) {
|
||||
switch ($requestingaction) {
|
||||
case 'login':
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// $_className = '\\FreePBX\\modules\\Sccp_manager\\Response\\' . substr(get_class($requestingaction), 20, -6) . 'Response';
|
||||
$_className = '\\FreePBX\\modules\\Sccp_manager\\Response';
|
||||
}
|
||||
if ($_className) {
|
||||
if (class_exists($_className, true)) {
|
||||
$responseclass = $_className;
|
||||
} else if ($responseHandler != false) {
|
||||
$this->_errorException('Response Class ' . $_className . ' requested via responseHandler, could not be found');
|
||||
}
|
||||
}
|
||||
// return new $responseclass($message);
|
||||
}
|
||||
|
||||
protected function _errorException($msg) {
|
||||
$this->_error[] = $msg;
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace or dublicate to AMI interface
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
function core_list_all_exten($keyfld = '', $filter = array()) {
|
||||
$result = array();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
public function sccp_list_extnint() {
|
||||
$hint_key = array();
|
||||
$hint_all = $this->sccp_list_all_hints();
|
||||
foreach ($hint_all as $value) {
|
||||
$res = $this->loc_after('@', $value);
|
||||
// array_search($res, $hint_key)) != NULL)
|
||||
if (!isset($hint_key[$res])) {
|
||||
$hint_key[$res] = '@' . $res;
|
||||
}
|
||||
}
|
||||
return $hint_key;
|
||||
}
|
||||
|
||||
private function astman_retrieveJSFromMetaData($segment = "") {
|
||||
global $astman;
|
||||
$params = array();
|
||||
if ($segment != "") {
|
||||
$params["Segment"] = $segment;
|
||||
}
|
||||
$response = $astman->send_request('SCCPConfigMetaData', $params);
|
||||
if ($response["Response"] == "Success") {
|
||||
//outn(_("JSON-content:").$response["JSON"]);
|
||||
$decode = json_decode($response["JSON"], true);
|
||||
return $decode;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getеtestChanSCC() {
|
||||
global $astman;
|
||||
// $action = Array('SCCPShowGlobals',);
|
||||
$params = array();
|
||||
$action = 'SCCPShowSoftkeySets';
|
||||
// $params = array('Segment' => 'device', 'ResultFormat'=>'command' );
|
||||
// $params = array('Segment' => 'device');
|
||||
// $params = array();
|
||||
$metadata = $astman->send_request($action, $params);
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
|
||||
function core_list_all_exten($keyfld = '', $filter = array()) {
|
||||
$result = array();
|
||||
$fld_data = array('exten', 'context', 'statustext', 'status');
|
||||
$row_data = $this->astman_GetRaw('ExtensionStateList');
|
||||
if (empty($row_data) || empty($row_data['eventlist'])) {
|
||||
return $result;
|
||||
}
|
||||
if ($row_data['eventlist'] == 'Complete') {
|
||||
foreach ($row_data['list'] as $value) {
|
||||
$exten = $value['exten'];
|
||||
$context = $value['context'];
|
||||
$exclude = empty($exten);
|
||||
switch ($keyfld) {
|
||||
case 'exten':
|
||||
$store_key = $exten;
|
||||
break;
|
||||
case 'hint':
|
||||
default:
|
||||
$store_key = $exten . '@' . $context;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($filter)) {
|
||||
foreach ($filter as $fkey => $fvalue) {
|
||||
if (!empty($value[$fkey])) {
|
||||
if (strpos(';' . $fvalue . ';', ';' . $value[$fkey] . ';') !== false) {
|
||||
$exclude = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$exclude) {
|
||||
foreach ($fld_data as $key) {
|
||||
$result[$store_key][$key] = (empty($value[$key]) ? '' : $value[$key] );
|
||||
}
|
||||
$result[$store_key]['key'] = $exten . '@' . $context;
|
||||
$result[$store_key]['label'] = $exten . '@' . $context;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function astLogin($host = "", $username = "", $password = "") {
|
||||
if ($this->Sok_param['enabled'] != true) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (empty($host) || empty($username) || empty($password)) {
|
||||
if (empty($this->Sok_param['host']) || empty($this->Sok_param['user']) || empty($this->Sok_param['pass'])) {
|
||||
return FALSE;
|
||||
}
|
||||
$host = (empty($host) ? $this->Sok_param['host'] : $host);
|
||||
$username = (empty($username) ? $this->Sok_param['user'] : $username);
|
||||
$password = (empty($password) ? $this->Sok_param['pass'] : $password);
|
||||
}
|
||||
$this->socket = @fsockopen($host, "5038", $errno, $errstr, 1);
|
||||
|
||||
if (!$this->socket) {
|
||||
$this->error = "Could not connect - $errstr ($errno)";
|
||||
return FALSE;
|
||||
} else {
|
||||
stream_set_timeout($this->socket, 1);
|
||||
|
||||
// $wrets = $this->astQuery("Action: Login\r\nUserName: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n");
|
||||
$wrets = $this->astQuery("Action: Login\r\nUserName: $username\r\nSecret: $password\r\nEvents: on\r\n\r\n");
|
||||
|
||||
if (strpos($wrets['raw'], "Message: Authentication accepted") != FALSE) {
|
||||
return TRUE;
|
||||
} else {
|
||||
$this->error = "Could not login - Authentication failed ";
|
||||
fclose($this->socket);
|
||||
$this->socket = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function astLogout() {
|
||||
if ($this->socket) {
|
||||
fputs($this->socket, "Action: Logoff\r\n\r\n");
|
||||
while (!feof($this->socket)) {
|
||||
$wrets .= fread($this->socket, 8192);
|
||||
}
|
||||
fclose($this->socket);
|
||||
$this->socket = "FALSE";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private function astQuery($query, $rawdata = false) {
|
||||
$wrets = "";
|
||||
// return $this->socket;
|
||||
if ($this->socket === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
$time_Query = microtime(true);
|
||||
$parameters = array();
|
||||
$parameters['raw'] = '';
|
||||
$data_store = 'data';
|
||||
$parameters[$data_store] = '';
|
||||
fputs($this->socket, $query);
|
||||
$parameters['raw_q'] = $query;
|
||||
$stop_data = false;
|
||||
$row_list = false;
|
||||
$row_list_arr = Array();
|
||||
$stop_data = false;
|
||||
$row_list = !$rawdata;
|
||||
do {
|
||||
$line = fgets($this->socket, 4096);
|
||||
$parameters['raw'] .= $line;
|
||||
if (!$rawdata) {
|
||||
// if (true) {
|
||||
$a = strpos($line, ':');
|
||||
if ($a) {
|
||||
$key = trim(strtolower(substr($line, 0, $a)));
|
||||
switch ($key) {
|
||||
case 'eventlist':
|
||||
if (strpos($line, 'start') !== false) {
|
||||
$row_list = true;
|
||||
} else {
|
||||
$row_list = false;
|
||||
}
|
||||
case 'response':
|
||||
case 'message':
|
||||
$parameters[$key] = trim(substr($line, $a + 2));
|
||||
if (!empty($parameters['response']) && !empty($parameters['message'])) {
|
||||
if ($parameters['response'] == 'Error') {
|
||||
$stop_data = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'json':
|
||||
$parameters[$key] = substr($line, $a + 2);
|
||||
$data_store = $key;
|
||||
break;
|
||||
default:
|
||||
if ($row_list) {
|
||||
$row_list_arr[$key] = trim(str_replace("\r\n", "", substr($line, $a + 2)));
|
||||
;
|
||||
}
|
||||
$parameters[$data_store] .= $line;
|
||||
break;
|
||||
}
|
||||
// store parameter in $parameters
|
||||
} else {
|
||||
if (!isset($parameters[$data_store])) {
|
||||
$parameters[$data_store] = '';
|
||||
}
|
||||
$parameters[$data_store] .= $line;
|
||||
}
|
||||
}
|
||||
if ($line == "\r\n") {
|
||||
if ($row_list == false) {
|
||||
$stop_data = true;
|
||||
} else {
|
||||
$parameters['list'][] = $row_list_arr;
|
||||
$row_list_arr = array();
|
||||
}
|
||||
}
|
||||
$info = stream_get_meta_data($this->socket);
|
||||
} while ($stop_data == false && $info['timed_out'] == false);
|
||||
|
||||
$parameters['time_Query'] = microtime(true) - $time_Query;
|
||||
$this->Sok_param['total'] = $this->Sok_param['total'] + $parameters['time_Query'];
|
||||
// $this->astLogout();
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
function GetError() {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
function astman_GetRaw($action = "", $parameters = array()) {
|
||||
$option = "";
|
||||
$result = array();
|
||||
|
||||
if ($this->_socket === FALSE) {
|
||||
if (!$this->astLogin()) {
|
||||
$result["Response"] = "Faild";
|
||||
$result["Error"] = $this->error;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$query = "Action: $action\r\n";
|
||||
|
||||
foreach ($parameters as $var => $val) {
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $k => $v) {
|
||||
$query .= "$var: $k=$v\r\n";
|
||||
}
|
||||
} else {
|
||||
$query .= "$var: $val\r\n";
|
||||
}
|
||||
}
|
||||
$result = $this->astQuery($query . "\r\n", true);
|
||||
$result = $this->astQuery($query . "\r\n", false);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
private function astman_retrieveMeta($action = "", $parameters=array(), $rawdata = false) {
|
||||
// $parameters=array()
|
||||
global $amp_conf;
|
||||
|
||||
if (empty($action)) {
|
||||
$action = 'SCCPConfigMetaData';
|
||||
}
|
||||
$query = "Action: $action\r\n";
|
||||
|
||||
foreach($parameters as $var=>$val) {
|
||||
if (is_array($val)) {
|
||||
foreach($val as $k => $v) {
|
||||
$query .= "$var: $k=$v\r\n";
|
||||
}
|
||||
} else {
|
||||
$query .= "$var: $val\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->astQuery($query."\r\n",$rawdata);
|
||||
|
||||
if ($result["Response"] == "Success") {
|
||||
if ($rawdata) {
|
||||
return $result;
|
||||
} else {
|
||||
if (!empty($result["JSON"])) {
|
||||
$decode = json_decode($response["JSON"], true);
|
||||
return $decode;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $result;
|
||||
return array();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
function t_get_meta_data() {
|
||||
global $amp_conf;
|
||||
$fp = fsockopen("127.0.0.1", "5038", $errno, $errstr, 10);
|
||||
|
||||
if (!$fp) {
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
} else {
|
||||
fputs($fp, "Action: login\r\n");
|
||||
fputs($fp, "Username: " . $amp_conf[AMPMGRUSER] . "\r\n");
|
||||
// fputs ($fp,"Secret: secret\r\n");
|
||||
fputs($fp, "Secret: " . $amp_conf[AMPMGRPASS] . "\r\n");
|
||||
fputs($fp, "Events: on\r\n\r\n");
|
||||
|
||||
// fputs ($fp,"Action: SCCPShowDevices\r\n");
|
||||
// fputs ($fp,"Action: DeviceStateList\r\n");
|
||||
fputs($fp, "Action: ExtensionStateList\r\n");
|
||||
fputs($fp, "Action: Status\r\n");
|
||||
|
||||
// fputs ($fp,"Segment: general\r\n");
|
||||
// "Segments":["general","device","line","softkey"]}
|
||||
// fputs ($fp,"Segment: device\r\n");
|
||||
// fputs ($fp,"ResultFormat: command\r\n");
|
||||
fputs($fp, "\r\n");
|
||||
|
||||
/*
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"Option: fallback\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"ListResult: freepbx\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"Option: dtmfmode\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
*/
|
||||
|
||||
fputs($fp, "Action: logoff\r\n\r\n");
|
||||
// print_r(fgets($fp));
|
||||
$resp = '';
|
||||
while (!feof($fp)) {
|
||||
$resp .= fgets($fp);
|
||||
}
|
||||
// print_r(fgets($fp));
|
||||
// print_r('<br>');
|
||||
// echo fgets($fp, 128);
|
||||
}
|
||||
fclose($fp);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
}
|
157
Sccp_manager.inc/aminterface/Event.class.php
Normal file
157
Sccp_manager.inc/aminterface/Event.class.php
Normal file
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
/* !TODO!: Re-Indent this file. -TODO-: What do you mean? coreaccessinterface ?? */
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
// ************************************************************************** Event *********************************************
|
||||
|
||||
abstract class Event extends IncomingMessage {
|
||||
|
||||
protected $_events;
|
||||
|
||||
public function getName() {
|
||||
return $this->getKey('Event');
|
||||
}
|
||||
|
||||
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='') {
|
||||
print_r($rawContent);
|
||||
// die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TableStart_Event extends Event {
|
||||
|
||||
public function getTableName() {
|
||||
return $this->getKey('TableName');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TableEnd_Event extends Event {
|
||||
|
||||
public function getTableName() {
|
||||
return $this->getKey('TableName');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPSoftKeySetEntry_Event extends Event {
|
||||
|
||||
protected $_data;
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPShowSoftKeySetsComplete_Event extends Event {
|
||||
|
||||
public function getListItems() {
|
||||
return intval($this->getKey('ListItems'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ExtensionStatus_Event extends Event {
|
||||
|
||||
public function getPrivilege() {
|
||||
return $this->getKey('Privilege');
|
||||
}
|
||||
|
||||
public function getExtension() {
|
||||
return $this->getKey('Exten');
|
||||
}
|
||||
|
||||
public function getContext() {
|
||||
return $this->getKey('Context');
|
||||
}
|
||||
|
||||
public function getHint() {
|
||||
return $this->getKey('Hint');
|
||||
}
|
||||
|
||||
public function getStatus() {
|
||||
return $this->getKey('Status');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPDeviceEntry_Event extends Event {
|
||||
|
||||
}
|
||||
|
||||
class SCCPShowDeviceComplete_Event extends Event {
|
||||
|
||||
public function getListItems() {
|
||||
return intval($this->getKey('ListItems'));
|
||||
}
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
$this->_completed = $this->getKey('EventList');
|
||||
// return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SCCPShowDevice_Event extends Event {
|
||||
|
||||
public function getCapabilities() {
|
||||
$ret = array();
|
||||
$codecs = explode(", ", substr($this->getKey('Capabilities'), 1, -1));
|
||||
foreach ($codecs as $codec) {
|
||||
$codec_parts = explode(" ", $codec);
|
||||
$ret[] = array("name" => $codec_parts[0], "value" => substr($codec_parts[1], 1, -1));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getCodecsPreference() {
|
||||
$ret = array();
|
||||
$codecs = explode(", ", substr($this->getKey('CodecsPreference'), 1, -1));
|
||||
foreach ($codecs as $codec) {
|
||||
$codec_parts = explode(" ", $codec);
|
||||
$ret[] = array("name" => $codec_parts[0], "value" => substr($codec_parts[1], 1, -1));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPShowDevicesComplete_Event extends Event {
|
||||
|
||||
public function getListItems() {
|
||||
return intval($this->getKey('ListItems'));
|
||||
}
|
||||
|
||||
}
|
||||
class SCCPDeviceButtonEntry_Event extends Event {
|
||||
}
|
||||
|
||||
class SCCPDeviceLineEntry_Event extends Event {
|
||||
}
|
||||
class SCCPDeviceStatisticsEntry_Event extends Event {
|
||||
}
|
||||
class SCCPDeviceSpeeddialEntry_Event extends Event {
|
||||
}
|
||||
class ExtensionStateListComplete_Event extends Event {
|
||||
|
||||
}
|
391
Sccp_manager.inc/aminterface/Message.class.php
Normal file
391
Sccp_manager.inc/aminterface/Message.class.php
Normal file
|
@ -0,0 +1,391 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
/* !TODO!: Re-Indent this file. -TODO-: What do you mean? coreaccessinterface ?? */
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
class AMIException extends \Exception {
|
||||
|
||||
}
|
||||
|
||||
abstract class Message {
|
||||
|
||||
const EOL = "\r\n";
|
||||
const EOM = "\r\n\r\n";
|
||||
|
||||
protected $lines;
|
||||
protected $variables;
|
||||
protected $keys;
|
||||
protected $createdDate;
|
||||
private $_responseHandler;
|
||||
|
||||
public function _ToDebug($level,$msg) {
|
||||
|
||||
}
|
||||
|
||||
public function getResponseHandler() {
|
||||
if (strlen($this->_responseHandler) > 0) {
|
||||
// throw new AMIException('Hier:' . $this->_responseHandler);
|
||||
return (string) $this->_responseHandler;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public function setResponseHandler($responseHandler) {
|
||||
if (0 == strlen($responseHandler)) {
|
||||
return;
|
||||
}
|
||||
$className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . $responseHandler . '_Response';
|
||||
if (class_exists($className, true)) {
|
||||
$this->_responseHandler = $responseHandler;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function setVariable($key, $value) {
|
||||
$key = strtolower($key);
|
||||
$this->variables[$key] = $value;
|
||||
/* print_r('<br>----Set Value -------<br>');
|
||||
print_r($key);
|
||||
print_r($value);
|
||||
*/
|
||||
}
|
||||
|
||||
public function getVariable($key) {
|
||||
$key = strtolower($key);
|
||||
|
||||
if (!isset($this->variables[$key])) {
|
||||
return null;
|
||||
}
|
||||
return $this->variables[$key];
|
||||
}
|
||||
|
||||
protected function setKey($key, $value) {
|
||||
$key = strtolower((string) $key);
|
||||
$this->keys[$key] = (string) $value;
|
||||
/*
|
||||
print_r('<br>----Set Key -------<br>');
|
||||
print_r($key);
|
||||
print_r($value);
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
public function getKey($key) {
|
||||
$key = strtolower($key);
|
||||
if (!isset($this->keys[$key])) {
|
||||
return null;
|
||||
}
|
||||
//return (string)$this->keys[$key];
|
||||
return $this->keys[$key];
|
||||
}
|
||||
|
||||
public function getVariables() {
|
||||
return $this->variables;
|
||||
}
|
||||
|
||||
public function getActionID() {
|
||||
return $this->getKey('ActionID');
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return $this->keys;
|
||||
}
|
||||
|
||||
private function serializeVariable($key, $value) {
|
||||
return "Variable: $key=$value";
|
||||
}
|
||||
|
||||
protected function setSanitizedKey($key, $value) {
|
||||
$key = strtolower((string) $key);
|
||||
$_string_key = array('actionid', 'descr');
|
||||
if (array_search($key, $_string_key) !== false) {
|
||||
$this->keys[$key] = (string) $this->sanitizeInput($value, 'string');
|
||||
} else {
|
||||
$this->keys[$key] = $this->sanitizeInput($value);
|
||||
}
|
||||
}
|
||||
|
||||
protected function sanitizeInput($value, $prefered_type = '') {
|
||||
if ($prefered_type == '') {
|
||||
if (!isset($value) || $value === NULL || strlen($value) == 0) {
|
||||
return NULL;
|
||||
} else if (is_numeric($value)) {
|
||||
$prefered_type = 'numeric';
|
||||
} else if (is_string($value)) {
|
||||
$prefered_type = 'string';
|
||||
} else {
|
||||
throw new AMIException("Don't know how to convert: '" . $value . "'\n");
|
||||
}
|
||||
}
|
||||
if ($prefered_type !== '') {
|
||||
switch ($prefered_type) {
|
||||
case 'string':
|
||||
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)) {
|
||||
return (string) $value;
|
||||
} else if (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) {
|
||||
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)) {
|
||||
return (float) $value;
|
||||
} else {
|
||||
return (double) $value;
|
||||
}
|
||||
default:
|
||||
throw new PAMIException("Don't know how to convert: '" . $value . "'\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function finishMessage($message) {
|
||||
return $message . self::EOL . self::EOL;
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
$result = array();
|
||||
foreach ($this->getKeys() as $k => $v) {
|
||||
$result[] = $k . ': ' . $v;
|
||||
}
|
||||
foreach ($this->getVariables() as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
foreach ($v as $singleValue) {
|
||||
$result[] = $this->serializeVariable($k, $singleValue);
|
||||
}
|
||||
} else {
|
||||
$result[] = $this->serializeVariable($k, $v);
|
||||
}
|
||||
}
|
||||
$mStr = $this->finishMessage(implode(self::EOL, $result));
|
||||
return $mStr;
|
||||
}
|
||||
|
||||
public function setActionID($actionID) {
|
||||
if (0 == strlen($actionID)) {
|
||||
throw new AMIException('ActionID cannot be empty.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($actionID) > 69) {
|
||||
throw new AMIException('ActionID can be at most 69 characters long.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setKey('ActionID', $actionID);
|
||||
}
|
||||
|
||||
public function __sleep() {
|
||||
return array('lines', 'variables', 'keys', 'createdDate');
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->lines = array();
|
||||
$this->variables = array();
|
||||
$this->keys = array();
|
||||
$this->createdDate = time();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class IncomingMessage extends Message {
|
||||
|
||||
protected $rawContent;
|
||||
|
||||
public function getEventList() {
|
||||
return $this->getKey('EventList');
|
||||
}
|
||||
|
||||
public function getRawContent() {
|
||||
return $this->rawContent;
|
||||
}
|
||||
|
||||
public function __sleep() {
|
||||
$ret = parent::__sleep();
|
||||
$ret[] = 'rawContent';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct();
|
||||
$this->rawContent = $rawContent;
|
||||
$lines = explode(Message::EOL, $rawContent);
|
||||
foreach ($lines as $line) {
|
||||
$content = explode(':', $line);
|
||||
$name = strtolower(trim($content[0]));
|
||||
unset($content[0]);
|
||||
$value = isset($content[1]) ? trim(implode(':', $content)) : '';
|
||||
try {
|
||||
$this->setSanitizedKey($name, $value);
|
||||
} catch (AMIException $e) {
|
||||
throw new AMIException("Error: '" . $e . "'\n Dump RawContent:\n" . $this->rawContent . "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// namespace FreePBX\modules\Sccp_manager\aminterface\Message;
|
||||
class LoginAction extends ActionMessage {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $user AMI username.
|
||||
* @param string $password AMI password.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 {
|
||||
|
||||
public function __construct($what) {
|
||||
parent::__construct();
|
||||
$this->setKey('Action', $what);
|
||||
$this->setKey('ActionID', microtime(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CommandAction extends ActionMessage {
|
||||
public function __construct($command) {
|
||||
parent::__construct('Command');
|
||||
$this->setKey('Command', $command);
|
||||
$this->setResponseHandler("Command");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ReloadAction extends ActionMessage {
|
||||
|
||||
public function __construct($module = false) {
|
||||
parent::__construct('Reload');
|
||||
if ($module !== false) {
|
||||
$this->setKey('Module', $module);
|
||||
$this->setResponseHandler("Generic");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ExtensionStateListAction extends ActionMessage {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('ExtensionStateList');
|
||||
$this->setKey('Segment', 'general');
|
||||
$this->setKey('ResultFormat', 'command');
|
||||
$this->setResponseHandler("ExtensionStateList");
|
||||
}
|
||||
|
||||
}
|
||||
class SCCPShowGlobalsAction extends ActionMessage {
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('SCCPShowGlobals');
|
||||
}
|
||||
}
|
||||
|
||||
class SCCPShowSoftkeySetsAction extends ActionMessage {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('SCCPShowSoftkeySets');
|
||||
$this->setKey('Segment', 'general');
|
||||
$this->setKey('ResultFormat', 'command');
|
||||
$this->setResponseHandler("SCCPShowSoftkeySets");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPShowDeviceAction extends ActionMessage {
|
||||
|
||||
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 {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('SCCPShowDevices');
|
||||
$this->setKey('Segment', 'general');
|
||||
$this->setKey('ResultFormat', 'command');
|
||||
$this->setResponseHandler("SCCPShowDevices");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPTokenAckAction extends ActionMessage {
|
||||
|
||||
public function __construct($DeviceName) {
|
||||
parent::__construct('SCCPTokenAck');
|
||||
$this->setKey('DeviceId', $DeviceName);
|
||||
$this->setResponseHandler("SCCPGeneric");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPDeviceRestartAction extends ActionMessage {
|
||||
|
||||
public function __construct($DeviceName, $Type = "restart") {
|
||||
parent::__construct('SCCPDeviceRestart');
|
||||
$this->setResponseHandler("SCCPGeneric");
|
||||
if (empty($Type)) {
|
||||
$Type = "restart";
|
||||
}
|
||||
$this->setKey('DeviceName', $DeviceName);
|
||||
if (in_array(strtolower($Type), array('restart', 'full', 'reset'))) {
|
||||
$this->setKey('Type', $Type);
|
||||
} else {
|
||||
throw new Exception('Param2 has to be one of \'restart\', \'full\', \'reset\'.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPConfigMetaDataAction extends ActionMessage
|
||||
{
|
||||
public function __construct($segment=false)
|
||||
{
|
||||
parent::__construct('SCCPConfigMetaData');
|
||||
if ($segment != false) {
|
||||
$this->setKey('Segment', $segment);
|
||||
}
|
||||
$this->setResponseHandler("SCCPGeneric");
|
||||
}
|
||||
}
|
||||
|
432
Sccp_manager.inc/aminterface/Response.class.php
Normal file
432
Sccp_manager.inc/aminterface/Response.class.php
Normal file
|
@ -0,0 +1,432 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
/* !TODO!: Re-Indent this file. -TODO-: What do you mean? coreaccessinterface ?? */
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
// ************************************************************************** Response *********************************************
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
abstract class Response extends IncomingMessage {
|
||||
|
||||
protected $_events;
|
||||
protected $_completed;
|
||||
protected $keys;
|
||||
|
||||
public function isComplete() {
|
||||
return $this->_completed;
|
||||
}
|
||||
|
||||
public function __sleep() {
|
||||
$ret = parent::__sleep();
|
||||
$ret[] = '_completed';
|
||||
$ret[] = '_events';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function addEvent($event)
|
||||
{
|
||||
$this->_events[] = $event;
|
||||
if (
|
||||
stristr($event->getEventList(), 'complete') !== false
|
||||
|| stristr($event->getName(), 'complete') !== false
|
||||
|| stristr($event->getName(), 'DBGetResponse') !== false
|
||||
) {
|
||||
$this->_completed = true;
|
||||
}
|
||||
}
|
||||
public function getEvents()
|
||||
{
|
||||
return $this->_events;
|
||||
}
|
||||
|
||||
public function isSuccess()
|
||||
{
|
||||
return stristr($this->getKey('Response'), 'Error') === false;
|
||||
}
|
||||
|
||||
public function isList()
|
||||
{
|
||||
return
|
||||
stristr($this->getKey('EventList'), 'start') !== false
|
||||
|| stristr($this->getMessage(), 'follow') !== false
|
||||
;
|
||||
}
|
||||
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->getKey('Message');
|
||||
}
|
||||
|
||||
public function setActionId($actionId)
|
||||
{
|
||||
$this->setKey('ActionId', $actionId);
|
||||
}
|
||||
|
||||
|
||||
public function getVariable($_rawContent, $_fields='') {
|
||||
$lines = explode(Message::EOL, $_rawContent);
|
||||
foreach ($_fields as $key => $value) {
|
||||
foreach ($lines as $data) {
|
||||
$_pst = strpos($data, $value);
|
||||
if ($_pst !== false) {
|
||||
$this->setKey($key, substr($data, $_pst + strlen($value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
$this->_events = array();
|
||||
$this->_eventsCount = 0;
|
||||
$this->_completed = !$this->isList();
|
||||
}
|
||||
|
||||
}
|
||||
//****************************************************************************
|
||||
class Generic_Response extends Response {
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
// print_r('<br>---- r --<br>');
|
||||
// print_r($rawContent);
|
||||
}
|
||||
}
|
||||
|
||||
class Login_Response extends Response {
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
return $this->isSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Command_Response extends Response {
|
||||
private $_temptable;
|
||||
|
||||
public function __construct($rawContent) {
|
||||
// print_r('<br>---- r --<br>');
|
||||
// print_r($rawContent);
|
||||
// print_r('<br>---- re --<br>');
|
||||
$this->_temptable = array();
|
||||
parent::__construct($rawContent);
|
||||
|
||||
$lines = explode(Message::EOL, $rawContent);
|
||||
foreach ($lines as $line) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($this->_temptable)){
|
||||
$this->setKey('output', 'array');
|
||||
}
|
||||
|
||||
$this->_completed = $this->isSuccess();
|
||||
// return $this->isSuccess();
|
||||
}
|
||||
public function getResult() {
|
||||
if (stristr($this->getKey('output'), 'array') !== false) {
|
||||
$result = $this->_temptable;
|
||||
} else {
|
||||
$result = $this->getMessage();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPGeneric_Response extends Response {
|
||||
|
||||
protected $_tables;
|
||||
private $_temptable;
|
||||
|
||||
public function addEvent($event) {
|
||||
// not eventlist (start/complete)
|
||||
// print_r('<br>---- addEvent --<br>');
|
||||
// print_r($event);
|
||||
// print_r('<br>---- Event List--<br>');
|
||||
// print_r($event->getEventList());
|
||||
if (stristr($event->getEventList(), 'start') === false && stristr($event->getEventList(), 'complete') === false && stristr($event->getName(), 'complete') === false
|
||||
) {
|
||||
$unknownevent = "FreePBX\\modules\\Sccp_manager\\aminterface\\UnknownEvent";
|
||||
if (!($event instanceof $unknownevent)) {
|
||||
// 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) {
|
||||
if (!is_array($this->_tables)) {
|
||||
$this->_tables = array();
|
||||
}
|
||||
$this->_tables[$event->getTableName()] = $this->_temptable;
|
||||
unset($this->_temptable);
|
||||
} else if (is_array($this->_temptable)) {
|
||||
$this->_temptable['Entries'][] = $event;
|
||||
} else {
|
||||
// add regular event
|
||||
$this->_events[] = $event;
|
||||
}
|
||||
} else {
|
||||
// add regular event
|
||||
$this->_events[] = $event;
|
||||
}
|
||||
}
|
||||
// finish eventlist
|
||||
if (
|
||||
stristr($event->getEventList(), 'complete') != false || stristr($event->getName(), 'complete') != false
|
||||
) {
|
||||
$this->_completed = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected function ConvertTableData($_tablename,$_fkey,$_fields) {
|
||||
$_rawtable = $this->Table2Array($_tablename);
|
||||
$result = array();
|
||||
foreach ($_rawtable as $_row) {
|
||||
$all_key_ok = true;
|
||||
if (is_array($_fkey)){
|
||||
foreach ($_fkey as $_fid) {
|
||||
if (empty($_row[$_fid])) {
|
||||
$all_key_ok = false;
|
||||
} else {
|
||||
$set_name[$_fid] = $_row[$_fid];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (empty($_row[$_fkey])) {
|
||||
$all_key_ok = false;
|
||||
} else {
|
||||
$set_name[$_fkey] = $_row[$_fkey];
|
||||
}
|
||||
}
|
||||
$Data = &$result;
|
||||
if ($all_key_ok) {
|
||||
foreach ($set_name as $value_id) {
|
||||
$Data = &$Data[$value_id];
|
||||
}
|
||||
foreach ($_fields as $value_key => $value_id) {
|
||||
$Data[$value_id] = $_row[$value_key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
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)){
|
||||
foreach ($_fkey as $_fid) {
|
||||
if (empty($tmp_result[$_fid])) {
|
||||
$all_key_ok = false;
|
||||
} else {
|
||||
$set_name[$_fid] = $tmp_result[$_fid];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (empty($tmp_result[$_fkey])) {
|
||||
$all_key_ok = false;
|
||||
} else {
|
||||
$set_name[$_fkey] = $tmp_result[$_fkey];
|
||||
}
|
||||
}
|
||||
$Data = &$result;
|
||||
if ($all_key_ok) {
|
||||
foreach ($set_name as $value_id) {
|
||||
$Data = &$Data[$value_id];
|
||||
}
|
||||
foreach ($_fields as $value_id) {
|
||||
$Data[$value_id] = $tmp_result[$value_id];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function hasTable()
|
||||
{
|
||||
if (is_array($this->_tables)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function getTableNames()
|
||||
{
|
||||
return (is_array($this->_tables)) ? array_keys($this->_tables) : null;
|
||||
}
|
||||
|
||||
public function Table2Array($tablename = '')
|
||||
{
|
||||
$result =array();
|
||||
if ( !is_string($tablename) || empty($tablename)){
|
||||
return false;
|
||||
}
|
||||
if ($this->hasTable()) {
|
||||
foreach ($this->_tables[$tablename]['Entries'] as $trow) {
|
||||
$result[]= $trow->getKeys();
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function Events2Array()
|
||||
{
|
||||
$result =array();
|
||||
if (is_array($this->_events)) {
|
||||
foreach ($this->_events as $trow) {
|
||||
$tmp_result = $trow->getKeys();
|
||||
if (is_array($tmp_result)) {
|
||||
$result = array_merge($result,$tmp_result);
|
||||
} else {
|
||||
$result [] = $tmp_result;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTable($tablename)
|
||||
{
|
||||
if ($this->hasTable() && array_key_exists($tablename, $this->_tables)) {
|
||||
return $this->_tables[$tablename];
|
||||
}
|
||||
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.");
|
||||
}
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
$_fields = array("EventList" => "EventList:", "Message" => "Message:");
|
||||
// $this->getVariable($rawContent, $_fields);
|
||||
$this->_completed = !$this->isList();
|
||||
}
|
||||
|
||||
public function getResult() {
|
||||
if ($this->getKey('JSON') != null) {
|
||||
$result = $this->getJSON();
|
||||
} else {
|
||||
$result = $this->getMessage ();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class SCCPJSON_Response extends Response {
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
$_fields = array("DataType" => "DataType:", "JSONRAW" => "JSON:");
|
||||
$this->getVariable($rawContent, $_fields);
|
||||
$js_res = $this->getKey('JSONRAW');
|
||||
if (isset($js_res)) {
|
||||
$this->setKey('Response', 'Success');
|
||||
}
|
||||
return $this->isSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPShowSoftkeySets_Response extends SCCPGeneric_Response {
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
|
||||
}
|
||||
public function getResult() {
|
||||
$_fields = array('description'=>'description','label'=>'label','lblid'=>'lblid');
|
||||
$result = $this->ConvertTableData('SoftKeySets',array('set','mode'),$_fields);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPShowDevices_Response extends SCCPGeneric_Response {
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
}
|
||||
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);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SCCPShowDevice_Response extends SCCPGeneric_Response {
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
}
|
||||
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',
|
||||
'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(' '));
|
||||
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'],
|
||||
'model_addon' => $result['SCCP_Vendor']['model_addon']);
|
||||
}
|
||||
$result['MAC_Address'] =$result['macaddress'];
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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'));
|
||||
return $result;
|
||||
}
|
||||
}
|
527
Sccp_manager.inc/aminterface/aminterface.class.php
Normal file
527
Sccp_manager.inc/aminterface/aminterface.class.php
Normal file
|
@ -0,0 +1,527 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
/* !TODO!: Re-Indent this file. -TODO-: What do you mean? coreaccessinterface ?? */
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
|
||||
class aminterface {
|
||||
|
||||
var $_socket;
|
||||
var $_error;
|
||||
var $_config;
|
||||
var $_test;
|
||||
var $_countE;
|
||||
private $_connect_state;
|
||||
// var $ProcessingMessage;
|
||||
private $_lastActionClass;
|
||||
private $_lastActionId;
|
||||
private $_lastRequestedResponseHandler;
|
||||
private $_ProcessingMessage;
|
||||
private $_DumpMessage;
|
||||
private $_eventFactory;
|
||||
private $_responseFactory;
|
||||
private $debug_level = 1;
|
||||
|
||||
public function load_subspace($parent_class = null) {
|
||||
$driverNamespace = "\\FreePBX\\Modules\\Sccp_manager\\aminterface";
|
||||
|
||||
$drivers = array('Message' => 'Message.class.php', 'Response' => 'Response.class.php', 'Event' => 'Event.class.php');
|
||||
foreach ($drivers as $key => $value) {
|
||||
$class = $driverNamespace . "\\" . $key;
|
||||
$driver = __DIR__ . "/" . $value;
|
||||
if (!class_exists($class, false)) {
|
||||
|
||||
if (file_exists($driver)) {
|
||||
include(__DIR__ . "/" . $value);
|
||||
} else {
|
||||
throw new \Exception("Class required but file not found " . $driver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct($parent_class = null) {
|
||||
global $amp_conf;
|
||||
$this->paren_class = $parent_class;
|
||||
$this->_socket = false;
|
||||
$this->_connect_state = false;
|
||||
$this->_error = array();
|
||||
$this->_config = array('host' => 'localhost', 'user' => '', 'pass' => '', 'port' => '5038', 'tsoket' => 'tcp://', 'timeout' => 30, 'enabled' => false);
|
||||
|
||||
|
||||
$this->_eventListeners = array();
|
||||
// $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'])) {
|
||||
foreach ($fld_conf as $key => $value) {
|
||||
if (isset($amp_conf[$value])) {
|
||||
$this->_config[$key] = $amp_conf[$value];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->_config['enabled']) {
|
||||
$this->load_subspace();
|
||||
}
|
||||
}
|
||||
|
||||
public function status() {
|
||||
if ($this->_config['enabled']) {
|
||||
return true;
|
||||
} else {return false;}
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$Ver = '13.0.4';
|
||||
if ($this->_config['enabled']) {
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'AMI data ver: ' . $Ver, 'test' => get_declared_classes());
|
||||
} else {
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'Disabled AMI ver: ' . $Ver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a tcp connection to ami.
|
||||
*
|
||||
*/
|
||||
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
|
||||
);
|
||||
if ($this->_socket === false) {
|
||||
$this->_errorException('Error connecting to ami: ' . $errstr . $cString);
|
||||
return false;
|
||||
}
|
||||
$msg = new aminterface\LoginAction($this->_config['user'], $this->_config['pass']);
|
||||
$response = $this->send($msg);
|
||||
|
||||
if ($response != false) {
|
||||
if (!$response->isSuccess()) {
|
||||
$this->_errorException('Could not connect: ' . $response->getMessage());
|
||||
return false;
|
||||
} else {
|
||||
@stream_set_blocking($this->_socket, 0);
|
||||
$this->_connect_state = true;
|
||||
$this->_ProcessingMessage = '';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection to ami.
|
||||
*/
|
||||
public function close() {
|
||||
$this->_connect_state = false;
|
||||
$this->_ProcessingMessage = '';
|
||||
@stream_socket_shutdown($this->_socket, STREAM_SHUT_RDWR);
|
||||
}
|
||||
|
||||
public function send($message) {
|
||||
$messageToSend = $message->serialize();
|
||||
$length = strlen($messageToSend);
|
||||
$this->_countE = 0;
|
||||
$this->_DumpMessage = '';
|
||||
$this->_lastActionId = $message->getActionId();
|
||||
$this->_lastRequestedResponseHandler = $message->getResponseHandler();
|
||||
$this->_lastActionClass = $message;
|
||||
if (@fwrite($this->_socket, $messageToSend) < $length) {
|
||||
$this->_errorException('Could not send message');
|
||||
return false;
|
||||
}
|
||||
$time_connect = microtime_float();
|
||||
$this->_msgToDebug(90, 'Time: '. ($time_connect));
|
||||
while (1) {
|
||||
stream_set_timeout($this->_socket, 1);
|
||||
// stream_set_timeout($this->_socket, (isset($this->socket_param['timeout']) ? $this->socket_param['timeout'] : 1));
|
||||
$this->process();
|
||||
$time_co = microtime_float();
|
||||
$this->_msgToDebug(90, 'Time: '. ($time_co-$time_connect));
|
||||
$info = stream_get_meta_data($this->_socket);
|
||||
if ($info['timed_out'] == false) {
|
||||
$response = $this->getRelated($message);
|
||||
if ($response != false) {
|
||||
$this->_lastActionId = false;
|
||||
$this->_msgToDebug(98, '---- Dump MSG -------');
|
||||
$this->_msgToDebug(98, $this->_DumpMessage);
|
||||
return $response;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_errorException("Read waittime: " . ($this->socket_param['timeout']) . " exceeded (timeout).\n");
|
||||
}
|
||||
|
||||
protected function getRelated($message) {
|
||||
$ret = false;
|
||||
$id = 0;
|
||||
$id = $message->getActionID('ActionID');
|
||||
if (isset($this->_incomingQueue[$id])) {
|
||||
$response = $this->_incomingQueue[$id];
|
||||
if ($response->isComplete()) {
|
||||
unset($this->_incomingQueue[$id]);
|
||||
$ret = $response;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function _messageToEvent($msg) {
|
||||
return $this->_eventFromRaw($msg);
|
||||
}
|
||||
|
||||
protected function getMessages() {
|
||||
$msgs = array();
|
||||
// Read something.
|
||||
$read = @fread($this->_socket, 65535);
|
||||
if ($read === false || @feof($this->_socket)) {
|
||||
$this->_errorException('Error reading');
|
||||
}
|
||||
|
||||
if ($read == "") {
|
||||
usleep(100);
|
||||
} else {
|
||||
$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)
|
||||
);
|
||||
$msgs[] = $msg;
|
||||
}
|
||||
return $msgs;
|
||||
}
|
||||
|
||||
public function process() {
|
||||
$msgs = $this->getMessages();
|
||||
$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 --- ');
|
||||
die();
|
||||
}
|
||||
foreach ($msgs as $aMsg) {
|
||||
$resPos = strpos($aMsg, 'Response:');
|
||||
$evePos = strpos($aMsg, 'Event:');
|
||||
if (($resPos !== false) && (($resPos < $evePos) || $evePos === false)) {
|
||||
$response = $this->_msgToResponse($aMsg); // resp Ok
|
||||
$this->_incomingQueue[$this->_lastActionId] = $response;
|
||||
} else if ($evePos !== false) {
|
||||
$event = $this->_messageToEvent($aMsg); // Event Ok
|
||||
|
||||
$this->_msgToDebug(99,'--- Responce Type 2 --- ');
|
||||
$this->_msgToDebug(99,$aMsg);
|
||||
$this->_msgToDebug(99,'--- Event Responce Type 2 --- ');
|
||||
$this->_msgToDebug(99,$event);
|
||||
|
||||
if ($event != null) {
|
||||
$response = $this->findResponse($event);
|
||||
// print_r($response);
|
||||
// print_r('<br>--- E2 Responce Type 2 ----------<br>');
|
||||
|
||||
if ($response === false || $response->isComplete()) {
|
||||
$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');
|
||||
$bMsg = 'Event: ResponseEvent' . "\r\n";
|
||||
$bMsg .= 'ActionId: ' . $this->_lastActionId . "\r\n" . $aMsg;
|
||||
$event = $this->_messageToEvent($bMsg);
|
||||
$response = $this->findResponse($event);
|
||||
$response->addEvent($event);
|
||||
}
|
||||
}
|
||||
// print_r('<br>--- EProcecc ----------<br>');
|
||||
|
||||
}
|
||||
|
||||
private function _msgToDebug($level, $msg) {
|
||||
if ($level > $this->debug_level) {
|
||||
return;
|
||||
}
|
||||
print_r('<br> level: '.$level.' ');
|
||||
print_r($msg);
|
||||
print_r('<br>');
|
||||
}
|
||||
|
||||
private function _msgToResponse($msg) {
|
||||
// print_r("<br>------------hmsg----------<br>");
|
||||
// print_r($this->_lastActionClass);
|
||||
// print_r($this->_lastRequestedResponseHandler);
|
||||
// print_r("<br>------------emsg----------<br>");
|
||||
// print_r($msg);
|
||||
$response = $this->_msgFromRaw($msg, $this->_lastActionClass, $this->_lastRequestedResponseHandler);
|
||||
// print_r("<br>------------rmsg----------<br>");
|
||||
// print_r($response);
|
||||
// print_r("<br>------------ermsg----------<br>");
|
||||
|
||||
$actionId = $response->getActionId();
|
||||
if ($actionId === null) {
|
||||
$actionId = $this->_lastActionId;
|
||||
$response->setActionId($this->_lastActionId);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
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) {
|
||||
$_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) {
|
||||
$this->_errorException('Response Class ' . $_className . ' requested via responseHandler, could not be found');
|
||||
}
|
||||
}
|
||||
return new $responseclass($message);
|
||||
}
|
||||
|
||||
protected function _errorException($msg) {
|
||||
$this->_error[] = $msg;
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace or dublicate to AMI interface
|
||||
*/
|
||||
|
||||
public function _eventFromRaw($message) {
|
||||
$eventStart = strpos($message, 'Event: ') + 7;
|
||||
|
||||
if ($eventStart > strlen($message)) {
|
||||
return new aminterface\UnknownEvent($message);
|
||||
}
|
||||
|
||||
$eventEnd = strpos($message, aminterface\Message::EOL, $eventStart);
|
||||
if ($eventEnd === false) {
|
||||
$eventEnd = strlen($message);
|
||||
}
|
||||
$name = substr($message, $eventStart, $eventEnd - $eventStart);
|
||||
$className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . $name . '_Event';
|
||||
if (class_exists($className, true) === false) {
|
||||
$className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\UnknownEvent';
|
||||
}
|
||||
return new $className($message);
|
||||
}
|
||||
|
||||
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) {
|
||||
$_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) {
|
||||
throw new AMIException('Response Class ' . $_className . ' requested via responseHandler, could not be found');
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
$actionId = $message->getActionId();
|
||||
if (isset($this->_incomingQueue[$actionId])) {
|
||||
return $this->_incomingQueue[$actionId];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function dispatch($message) {
|
||||
print_r("<br>------------dispatch----------<br>");
|
||||
print_r($message);
|
||||
return false;
|
||||
die();
|
||||
foreach ($this->_eventListeners as $data) {
|
||||
$listener = $data[0];
|
||||
$predicate = $data[1];
|
||||
print_r($data);
|
||||
|
||||
if (is_callable($predicate) && !call_user_func($predicate, $message)) {
|
||||
continue;
|
||||
}
|
||||
if ($listener instanceof \Closure) {
|
||||
$listener($message);
|
||||
} else if (is_array($listener)) {
|
||||
$listener[0]->$listener[1]($message);
|
||||
} else {
|
||||
$listener->handle($message);
|
||||
}
|
||||
}
|
||||
print_r("<br>------------E dispatch----------<br>");
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
function core_list_all_exten($keyfld = '', $filter = array()) {
|
||||
$result = array();
|
||||
return $result;
|
||||
}
|
||||
|
||||
//-------------------Adaptive Function ------------------------------------------------------------
|
||||
|
||||
function core_list_hints() {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\ExtensionStateListAction();
|
||||
$_response = $this->send($_action);
|
||||
$_res = $_response->getResult();
|
||||
foreach ($_res as $key => $value) {
|
||||
foreach ($value as $key2 => $value2) {
|
||||
$result[$key2] = '@' . $key2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function core_list_all_hints() {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\ExtensionStateListAction();
|
||||
$_response = $this->send($_action);
|
||||
$_res = $_response->getResult();
|
||||
foreach ($_res as $key => $value) {
|
||||
foreach ($value as $key2 => $value2) {
|
||||
$result[$key.'@'.$key2] = $key.'@'.$key2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// --------------------- SCCP Comands
|
||||
function sccp_list_keysets() {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowSoftkeySetsAction();
|
||||
$_response = $this->send($_action);
|
||||
$_res = $_response->getResult();
|
||||
foreach ($_res as $key => $value) {
|
||||
$result[$key] = $key;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function sccp_get_active_device() {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDevicesAction();
|
||||
$_response = $this->send($_action);
|
||||
$result = $_response->getResult();
|
||||
foreach ($result as $key => $value) {
|
||||
$result[$key]['name'] = $key;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function sccp_getdevice_info($devicename) {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDeviceAction($devicename);
|
||||
$_response = $this->send($_action);
|
||||
$result = $_response->getResult();
|
||||
$result['MAC_Address'] = $result['macaddress'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
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);
|
||||
}
|
||||
$_response = $this->send($_action);
|
||||
$result['data'] = 'Device :'.$devicename.' Result: '.$_response->getMessage();
|
||||
$result['Response']=$_response->getKey('Response');
|
||||
// $result = $_response->getResult();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//------------------- Core Comands ----
|
||||
function core_sccp_reload() {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\ReloadAction('chan_sccp');
|
||||
// $_action = new \FreePBX\modules\Sccp_manager\aminterface\CommandAction('sccp reload force'); // No Responce Result !!
|
||||
$_response = $this->send($_action);
|
||||
$result = $_response->getMessage();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function getSCCPVersion() {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPConfigMetaDataAction();
|
||||
$_response = $this->send($_action);
|
||||
$result = $_response->getResult();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getRealTimeStatus() {
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\CommandAction('realtime mysql status');
|
||||
$_response = $this->send($_action);
|
||||
$res = $_response->getResult();
|
||||
if (!empty($res['output'])) {
|
||||
$result = $res['output'];
|
||||
} else {
|
||||
$result = $_response->getMessage();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
502
Sccp_manager.inc/aminterface/oldinterface.class.php
Normal file
502
Sccp_manager.inc/aminterface/oldinterface.class.php
Normal file
|
@ -0,0 +1,502 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
/* !TODO!: Re-Indent this file. -TODO-: What do you mean? coreaccessinterface ?? */
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class oldinterface {
|
||||
|
||||
var $error;
|
||||
|
||||
public function __construct($parent_class = null) {
|
||||
$this->paren_class = $parent_class;
|
||||
$this->error = "";
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$Ver = '13.0.4';
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'Old interface data ver: ' . $Ver);
|
||||
}
|
||||
|
||||
/*
|
||||
Core Access Function
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Replace or dublicate to AMI interface
|
||||
*/
|
||||
|
||||
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' => ''),
|
||||
'get_device' => array('cmd' => "sccp show devices", 'param' => ''),
|
||||
'get_dev_info' => array('cmd' => "sccp show device", 'param' => 'name'),
|
||||
'get_hints' => array('cmd' => "core show hints", 'param' => ''),
|
||||
'sccp_reload' => array('cmd' => "sccp reload force", 'param' => ''),
|
||||
'reset_phone' => array('cmd' => "sccp reset ", 'param' => 'name'), // Жесткая перезагрузка
|
||||
'restart_phone' => array('cmd' => "sccp restart ", 'param' => 'name'),
|
||||
'reload_phone' => array('cmd' => "sccp reload device ", 'param' => 'name'),
|
||||
'reload_line' => array('cmd' => "sccp reload line ", 'param' => 'name'),
|
||||
'reset_token' => array('cmd' => "sccp tokenack ", 'param' => 'name'),
|
||||
'get_realtime_status' => array('cmd' => "realtime mysql status", 'param' => ''),
|
||||
);
|
||||
$result = true;
|
||||
if (!empty($params['cmd'])) {
|
||||
$id_cmd = $params['cmd'];
|
||||
if (!empty($cmd_list[$id_cmd])) {
|
||||
$id_param = $cmd_list[$id_cmd]['param'];
|
||||
if (!empty($id_param)) {
|
||||
if (!empty($params[$id_param])) {
|
||||
$result = $astman->Command($cmd_list[$id_cmd]['cmd'] . ' ' . $params[$id_param]);
|
||||
}
|
||||
} else {
|
||||
$result = $astman->Command($cmd_list[$id_cmd]['cmd']);
|
||||
}
|
||||
} else {
|
||||
switch ($params['cmd']) {
|
||||
case 'phone_call':
|
||||
if (!empty($params['name'])) {
|
||||
$result = $astman->Command('sccp call ' . $params['name'] . ' ' . $params['call']);
|
||||
}
|
||||
break;
|
||||
case 'phone_message':
|
||||
if (!empty($params['msg'])) {
|
||||
$msg = $params['msg'];
|
||||
} else {
|
||||
$msg = $this->sccpvalues['servername']['data'];
|
||||
}
|
||||
if (!empty($params['name'])) {
|
||||
$astman->Command('sccp device ' . $params['name'] . ' ' . $msg);
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function sccp_getdevice_info($dev_id) {
|
||||
if (empty($dev_id)) {
|
||||
return array();
|
||||
}
|
||||
$res = $this->sccp_core_commands(array('cmd' => 'get_dev_info', 'name' => $dev_id));
|
||||
$res1 = str_replace(array("\r\n", "\r", "\n"), ';', strip_tags((string) $res['data']));
|
||||
if (strpos($res1, 'MAC-Address')) {
|
||||
$res2 = substr($res1, 0, strpos($res1, '+--- Buttons '));
|
||||
$res1 = explode(';', substr($res2, strpos($res2, 'MAC-Address')));
|
||||
foreach ($res1 as $data) {
|
||||
if (!empty($data)) {
|
||||
$tmp = explode(':', $data);
|
||||
$data_key = str_replace(array(" ", "-", "\t"), '_', trim($tmp[0]));
|
||||
$res3[$data_key] = $tmp[1];
|
||||
}
|
||||
}
|
||||
|
||||
$res1 = $res3['Skinny_Phone_Type'];
|
||||
$res4 = $res3['Config_Phone_Type'];
|
||||
if (!empty($res3['Addons'])) {
|
||||
$res2 = $res3['Addons'];
|
||||
} else {
|
||||
$res2 = '';
|
||||
}
|
||||
$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']);
|
||||
// return $res4;
|
||||
// return array();
|
||||
}
|
||||
return $res3;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/* Current not use */
|
||||
/*
|
||||
* 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() {
|
||||
$hint_key = array();
|
||||
$hint_all = $this->sccp_list_all_hints();
|
||||
foreach ($hint_all as $value) {
|
||||
$res = $this->loc_after('@', $value);
|
||||
// array_search($res, $hint_key)) != NULL)
|
||||
if (!isset($hint_key[$res])) {
|
||||
$hint_key[$res] = '@' . $res;
|
||||
}
|
||||
}
|
||||
return $hint_key;
|
||||
}
|
||||
|
||||
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();
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$ast_out[$i] = "";
|
||||
}
|
||||
$i = count($ast_out) - 1;
|
||||
$ast_out[--$i] = "";
|
||||
$ast_out[--$i] = "";
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
list ($line, $junk) = explode(' ', $line);
|
||||
if (!is_bool(strpos($line, ':'))) {
|
||||
$line = trim(substr($line, 0, strpos($line, ':')));
|
||||
}
|
||||
if (isset($ast_key[$line])) {
|
||||
if (strlen($ast_key[$line]) < 1) {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
} else {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ast_key;
|
||||
}
|
||||
|
||||
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']);
|
||||
if (strpos($ast_out[0], 'Privilege') !== false) {
|
||||
$ast_out[0] = "";
|
||||
}
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
$ast_key = strstr(trim($line), ' ', true);
|
||||
$ast_res[$ast_key] = array('message' => $line, 'status' => strpos($line, 'connected') ? 'OK' : 'ERROR');
|
||||
}
|
||||
}
|
||||
return $ast_res;
|
||||
}
|
||||
|
||||
// !TODO!: -TODO-: install.php is still using the other version number. This is actually where I use another method ?
|
||||
|
||||
|
||||
public function get_compatible_sccp() {
|
||||
$res = $this->getSCCPVersion();
|
||||
if (empty($res)) {
|
||||
return 0;
|
||||
}
|
||||
switch ($res["vCode"]) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 433:
|
||||
return 433;
|
||||
|
||||
case 432:
|
||||
case 431:
|
||||
return 431;
|
||||
default:
|
||||
return 430;
|
||||
}
|
||||
/* if ($res["vCode"] >= 433) {
|
||||
|
||||
}
|
||||
if ($res["vCode"] >= 431) {
|
||||
return 431;
|
||||
} else {
|
||||
return 430;
|
||||
}
|
||||
*
|
||||
*/
|
||||
// return $res["vCode"];
|
||||
}
|
||||
|
||||
public function getSCCPVersion() {
|
||||
$res = $this->getChanSCCPVersion();
|
||||
if (empty($res)) {
|
||||
$res = $this->getCoreSCCPVersion();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getCoreSCCPVersion() {
|
||||
$result = array();
|
||||
$ast_out = $this->sccp_version();
|
||||
$result["Version"] = $ast_out[0];
|
||||
if ($ast_out[0] == '-1') {
|
||||
$result["vCode"] = 0;
|
||||
return $result;
|
||||
}
|
||||
$version_parts = explode(".", $ast_out[0]);
|
||||
$result["vCode"] = implode('', $version_parts);
|
||||
if (!empty($ast_out[1]) && $ast_out[1] == 'develop') {
|
||||
$result["develop"] = $ast_out[1];
|
||||
$res = 10;
|
||||
// !TODO!: This does not work as you might expect
|
||||
if (base_convert($ast_out[3], 16, 10) == base_convert('702487a', 16, 10)) {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
if (base_convert($ast_out[3], 16, 10) >= "10403") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 432;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
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) ) {
|
||||
return array('-1');
|
||||
}
|
||||
if (preg_match("/Release.*\(/", $ast_out['data'], $matches)) {
|
||||
$ast_out = substr($matches[0], 9, -1);
|
||||
return explode(' ', $ast_out);
|
||||
} else {
|
||||
return array('unknown');
|
||||
}
|
||||
}
|
||||
|
||||
function getChanSCCPVersion() {
|
||||
global $astman;
|
||||
$result = array();
|
||||
if (!$astman) {
|
||||
return $result;
|
||||
}
|
||||
$metadata = $this->astman_retrieveJSFromMetaData("");
|
||||
// return $metadata;
|
||||
if ($metadata && array_key_exists("Version", $metadata)) {
|
||||
$result["Version"] = $metadata["Version"];
|
||||
$version_parts = explode(".", $metadata["Version"]);
|
||||
$result["vCode"] = 0;
|
||||
|
||||
# not sure about this sccp_ver numbering. Might be better to just check "Version" and Revision
|
||||
# $result["vCode"] = implode('', $version_parts);
|
||||
$result["vCode"] = 0;
|
||||
if ($version_parts[0] == "4") {
|
||||
$result["vCode"] = 400;
|
||||
if ($version_parts[1] == "1") {
|
||||
$result["vCode"] = 410;
|
||||
} else
|
||||
if ($version_parts[1] == "2") {
|
||||
$result["vCode"] = 420;
|
||||
} else
|
||||
if ($version_parts[1] >= "3") {
|
||||
$result["vCode"] = 430;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (array_key_exists("Branch",$metadata)) {
|
||||
if ($metadata["Branch"] == "master") {
|
||||
|
||||
} else
|
||||
if ($metadata["Branch"] == "develop") {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Revision got replaced by RevisionHash in 10404 (using the hash does not work) */
|
||||
if (array_key_exists("Revision", $metadata)) {
|
||||
if (base_convert($metadata["Revision"], 16, 10) == base_convert('702487a', 16, 10)) {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
if (base_convert($metadata["Revision"], 16, 10) >= "10403") {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("RevisionHash", $metadata)) {
|
||||
$result["RevisionHash"] = $metadata["RevisionHash"];
|
||||
} else {
|
||||
$result["RevisionHash"] = '';
|
||||
}
|
||||
if (array_key_exists("RevisionNum", $metadata)) {
|
||||
$result["RevisionNum"] = $metadata["RevisionNum"];
|
||||
if ($metadata["RevisionNum"] >= "10403") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 432;
|
||||
}
|
||||
if ($metadata["RevisionNum"] >= "10491") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 433;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("ConfigureEnabled", $metadata)) {
|
||||
$result["futures"] = implode(';', $metadata["ConfigureEnabled"]);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
die_freepbx("Version information could not be retrieved from chan-sccp, via astman::SCCPConfigMetaData");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function sccp_list_keysets() {
|
||||
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_softkey'));
|
||||
|
||||
$ast_out = preg_split("/[\n]/", $ast_out['data']);
|
||||
$ast_key = array();
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$ast_out[$i] = "";
|
||||
}
|
||||
$i = count($ast_out) - 1;
|
||||
$ast_out[--$i] = "";
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
$line = substr($line, 2);
|
||||
list ($line, $junk) = explode(' ', $line);
|
||||
if (isset($ast_key[$line])) {
|
||||
if (strlen($ast_key[$line]) < 1) {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
} else {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ast_key;
|
||||
}
|
||||
|
||||
public function sccp_get_active_device() {
|
||||
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_device'));
|
||||
|
||||
$ast_out = preg_split("/[\n]/", $ast_out['data']);
|
||||
|
||||
$ast_key = array();
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$ast_out[$i] = "";
|
||||
}
|
||||
$i = count($ast_out) - 1;
|
||||
$ast_out[--$i] = "";
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
$line = substr($line, 2);
|
||||
$line = preg_replace("/\s{2,}/", " ", $line);
|
||||
$line_arr = explode(' ', $line);
|
||||
$it = 1;
|
||||
do {
|
||||
if ($this->strpos_array($line_arr[$it + 1], array('SEP', 'ATA', 'VG')) === false) {
|
||||
// if (strpos($line_arr[$it + 1], 'SEP') === false) {
|
||||
$line_arr[0] .= ' ' . $line_arr[$it];
|
||||
unset($line_arr[$it]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
$it++;
|
||||
} while ((count($line_arr) > 3) and ( $it < count($line_arr)));
|
||||
explode(";|", implode(";|", $line_arr));
|
||||
list ($descr, $adress, $devname, $status, $token, $junk) = explode(";|", implode(";|", $line_arr));
|
||||
|
||||
// list ($descr, $adress, $devname, $status, $junk) = $line_arr;
|
||||
// if (strlen($ast_key[$devname]) < 1) {
|
||||
if (strlen($devname) > 1) {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $token);
|
||||
}
|
||||
/*
|
||||
if (isset($ast_key[$devname])) {
|
||||
if (strlen($ast_key[$devname]) < 1) {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $descr);
|
||||
}
|
||||
} else {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $token);
|
||||
}
|
||||
*
|
||||
*/
|
||||
}
|
||||
}
|
||||
return $ast_key;
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace sccp_core_commands($params = array()) {
|
||||
*/
|
||||
|
||||
private function astman_retrieveJSFromMetaData($segment = "") {
|
||||
global $astman;
|
||||
$params = array();
|
||||
if ($segment != "") {
|
||||
$params["Segment"] = $segment;
|
||||
}
|
||||
$response = $astman->send_request('SCCPConfigMetaData', $params);
|
||||
if ($response["Response"] == "Success") {
|
||||
//outn(_("JSON-content:").$response["JSON"]);
|
||||
$decode = json_decode($response["JSON"], true);
|
||||
return $decode;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function strpos_array($haystack, $needles) {
|
||||
if (is_array($needles)) {
|
||||
foreach ($needles as $str) {
|
||||
if (is_array($str)) {
|
||||
$pos = strpos_array($haystack, $str);
|
||||
} else {
|
||||
$pos = strpos($haystack, $str);
|
||||
}
|
||||
if ($pos !== FALSE) {
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return strpos($haystack, $needles);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
private function loc_after($value, $inthat) {
|
||||
if (!is_bool(strpos($inthat, $value)))
|
||||
return substr($inthat, strpos($inthat, $value) + strlen($value));
|
||||
}
|
||||
|
||||
function getеtestChanSCC() {
|
||||
global $astman;
|
||||
// $action = Array('SCCPShowGlobals',);
|
||||
$params = array();
|
||||
$action = 'SCCPShowSoftkeySets';
|
||||
$params = array('Segment' => 'device', 'ResultFormat'=>'command' );
|
||||
// $params = array('Segment' => 'device');
|
||||
// $params = array();
|
||||
$metadata = $astman->send_request($action, $params);
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/*
|
||||
* [Segments] => ( [0] => general [1] => device [2] => line [3] => softkey )
|
||||
*/
|
||||
function getеtestChanSCCP_GlablsInfo($Segment = '') {
|
||||
global $astman;
|
||||
$params = array();
|
||||
|
||||
$action = 'SCCPConfigMetaData';
|
||||
if (empty($Segment)) {
|
||||
$Segment = 'general';
|
||||
}
|
||||
$params = array('Segment' => $Segment, 'ResultFormat' => 'command');
|
||||
$metadata = $astman->send_request($action, $params);
|
||||
if (!empty($metadata['data'])) {
|
||||
$tmp_data = $metadata['data'];
|
||||
if (strpos($tmp_data, 'JSON:') !== false) {
|
||||
$decode = json_decode(substr($tmp_data, strpos($tmp_data, 'JSON:') + 5), true);
|
||||
$result = array();
|
||||
if (!empty($decode['Options'])) {
|
||||
foreach ($decode['Options'] as $value) {
|
||||
$result[$value['Name']] = $value;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $decode;
|
||||
}
|
||||
}
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,28 +29,63 @@ class extconfigs {
|
|||
case 'sccpDefaults':
|
||||
$result = $this->sccpDefaults;
|
||||
break;
|
||||
case 'sccp_timezone':
|
||||
$result = array();
|
||||
foreach ($this->cisco_timezone as $key => $value) {
|
||||
$cisco_code = $key . ' Standard' . ((empty($value['daylight'])) ? '' : '/' . $value['daylight']) . ' Time';
|
||||
if (isset($value['cisco_code'])) {
|
||||
$cisco_code = (empty($value['cisco_code'])) ? $cisco_code : $value['cisco_code'];
|
||||
}
|
||||
$result[$key] = array('offset' => $value['offset'], 'daylight' => $value['daylight'], 'cisco_code' => $cisco_code);
|
||||
case 'sccp_timezone_offset': // Sccp manafer: 1400 (+ Id) :2007 (+ Id)
|
||||
if (empty($index)) {
|
||||
return 0;
|
||||
}
|
||||
if (array_key_exists($index, $this->cisco_timezone)) {
|
||||
$tmp_time = $this->get_cisco_time_zone($index);
|
||||
return $tmp_time['offset'];
|
||||
}
|
||||
|
||||
$tmp_dt = new \DateTime(null, new \DateTimeZone($index));
|
||||
$tmp_ofset = $tmp_dt->getOffset();
|
||||
return $tmp_ofset / 60;
|
||||
|
||||
break;
|
||||
/* case 'cisco_time':
|
||||
$result = array();
|
||||
foreach ($this->cisco_timezone as $key => $value) {
|
||||
$result[] = array('id'=> ($value['offset']/60) ,'val'=>$key.((empty($value['daylight']))? '': '/'.$value['daylight']));
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case 'cisco_timezone':
|
||||
case 'sccp_timezone': // Sccp manafer: 1400 (+ Id) :2007 (+ Id)
|
||||
$result = array();
|
||||
foreach ($this->cisco_timezone as $key => $value) {
|
||||
$result[] = array('id' => $key, 'val' => $key . ((empty($value['daylight'])) ? '' : '/' . $value['daylight']));
|
||||
// $result[$key] =$key.((empty($value['daylight']))? '': '/'.$value['daylight']);
|
||||
|
||||
if (empty($index)) {
|
||||
return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich');
|
||||
}
|
||||
if (array_key_exists($index, $this->cisco_timezone)) {
|
||||
return $this->get_cisco_time_zone($index);
|
||||
} else {
|
||||
$timezone_abbreviations = \DateTimeZone::listAbbreviations();
|
||||
|
||||
$tz_tmp = array();
|
||||
foreach ($timezone_abbreviations as $subArray) {
|
||||
$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');
|
||||
}
|
||||
|
||||
if (count($tz_tmp)==1) {
|
||||
$time_set = $tz_tmp[0];
|
||||
} else {
|
||||
$tmp_dt = new \DateTime(null, new \DateTimeZone($index));
|
||||
$tmp_ofset = $tmp_dt->getOffset();
|
||||
foreach ($tz_tmp as $subArray) {
|
||||
if ($subArray['offset'] == $tmp_ofset) {
|
||||
$time_set = $subArray;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tmp_ofset = $time_set['offset'] / 60;
|
||||
$tmp_dli = (empty($time_set['dst']) ? '' : 'Daylight' );
|
||||
foreach ($this->cisco_timezone as $key => $value) {
|
||||
if (($value['offset'] == $tmp_ofset) and ( $value['daylight'] == $tmp_dli )) {
|
||||
return $this->get_cisco_time_zone($key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -68,6 +103,20 @@ class extconfigs {
|
|||
}
|
||||
}
|
||||
|
||||
private function get_cisco_time_zone($tzc){
|
||||
|
||||
if ( (empty($tzc)) or (!array_key_exists($tzc, $this->cisco_timezone))) {
|
||||
// return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich');
|
||||
return array();
|
||||
}
|
||||
$tzdata = $this->cisco_timezone[$tzc];
|
||||
$cisco_code = $tzc . ' Standard' . ((empty($tzdata['daylight'])) ? '' : '/' . $tzdata['daylight']) . ' Time';
|
||||
if (isset($tzdata['cisco_code'])) {
|
||||
$cisco_code = (empty($tzdata['cisco_code'])) ? $cisco_code : $tzdata['cisco_code'];
|
||||
}
|
||||
return array('offset' => $tzdata['offset'], 'daylight' => $tzdata['daylight'], 'cisco_code' => $cisco_code);
|
||||
}
|
||||
|
||||
private $sccpDefaults = array(
|
||||
"servername" => 'VPBXSCCP',
|
||||
"bindaddr" => '0.0.0.0', "port" => '2000', # chan_sccp also supports ipv6
|
||||
|
@ -228,10 +277,9 @@ class extconfigs {
|
|||
// /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');
|
||||
|
||||
|
@ -308,7 +356,7 @@ class extconfigs {
|
|||
}
|
||||
}
|
||||
}
|
||||
print_r($base_config,1);
|
||||
print_r($base_config, 1);
|
||||
// die(print_r($base_config,1));
|
||||
// $base_config['External_ini'] = $adv_config;
|
||||
// $base_config['External_mode'] = $adv_tree_mode;
|
||||
|
@ -363,14 +411,14 @@ class extconfigs {
|
|||
public function validate_RealTime($realm = '') {
|
||||
global $amp_conf;
|
||||
$res = Array();
|
||||
if (empty($realm) ) {
|
||||
if (empty($realm)) {
|
||||
$realm = 'sccp';
|
||||
}
|
||||
$cnf_int = \FreePBX::Config();
|
||||
$cnf_wr = \FreePBX::WriteConfig();
|
||||
$cnf_read = \FreePBX::LoadConfig();
|
||||
|
||||
$def_config = array('sccpdevice' => 'mysql,'.$realm.',sccpdeviceconfig', 'sccpline' => 'mysql,'.$realm.',sccpline');
|
||||
|
||||
$def_config = array('sccpdevice' => 'mysql,' . $realm . ',sccpdeviceconfig', 'sccpline' => 'mysql,' . $realm . ',sccpline');
|
||||
$backup_ext = array('_custom.conf', '.conf', '_additional.conf');
|
||||
$def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'],
|
||||
'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'],
|
||||
|
@ -388,17 +436,19 @@ class extconfigs {
|
|||
$ext_conf = $cnf_read->getConfig('extconfig' . $fext);
|
||||
if (!empty($ext_conf['settings']['sccpdevice'])) {
|
||||
// Add chek line
|
||||
if (strtolower($ext_conf['settings']['sccpdevice']) == strtolower($def_config['sccpdevice'])){
|
||||
if (strtolower($ext_conf['settings']['sccpdevice']) == strtolower($def_config['sccpdevice'])) {
|
||||
$res['sccpdevice'] = 'OK';
|
||||
$res['extconfigfile'] = 'extconfig'. $fext;
|
||||
$res['extconfigfile'] = 'extconfig' . $fext;
|
||||
} else {
|
||||
$res['sccpdevice'] = 'Error in line sccpdevice '. $res['sccpdevice'];
|
||||
$res['sccpdevice'] = 'Error in line sccpdevice ' . $res['sccpdevice'];
|
||||
}
|
||||
}
|
||||
if (!empty($ext_conf['settings']['sccpline'])) {
|
||||
if (strtolower($ext_conf['settings']['sccpline']) == strtolower($def_config['sccpline'])){
|
||||
if (strtolower($ext_conf['settings']['sccpline']) == strtolower($def_config['sccpline'])) {
|
||||
$res['sccpline'] = 'OK';
|
||||
} else {$res['sccpline'] = 'Error in line sccpline';}
|
||||
} else {
|
||||
$res['sccpline'] = 'Error in line sccpline';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +485,7 @@ class extconfigs {
|
|||
$res['mysqlconfig'] = 'OK';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (file_exists($dir . '/res_config_mysql.conf')) {
|
||||
$res_conf = $cnf_read->getConfig('res_config_mysql.conf');
|
||||
if (empty($res_conf[$realm])) {
|
||||
|
|
|
@ -13,183 +13,194 @@ namespace FreePBX\modules\Sccp_manager;
|
|||
class srvinterface {
|
||||
|
||||
var $error;
|
||||
var $_info;
|
||||
var $ami_mode;
|
||||
|
||||
public function __construct($parent_class = null) {
|
||||
$this->paren_class = $parent_class;
|
||||
if ($this->paren_class == null) {
|
||||
$this->paren_class = $this;
|
||||
}
|
||||
$this->error = "";
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$Ver = '13.0.4';
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'Server interface data ver: ' . $Ver);
|
||||
}
|
||||
|
||||
/*
|
||||
Core Access Function
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Replace or dublicate to AMI interface
|
||||
*/
|
||||
|
||||
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' => ''),
|
||||
'get_device' => array('cmd' => "sccp show devices", 'param' => ''),
|
||||
'get_dev_info' => array('cmd' => "sccp show device", 'param' => 'name'),
|
||||
'get_hints' => array('cmd' => "core show hints", 'param' => ''),
|
||||
'sccp_reload' => array('cmd' => "sccp reload force", 'param' => ''),
|
||||
'reset_phone' => array('cmd' => "sccp reset ", 'param' => 'name'), // Жесткая перезагрузка
|
||||
'restart_phone' => array('cmd' => "sccp restart ", 'param' => 'name'),
|
||||
'reload_phone' => array('cmd' => "sccp reload device ", 'param' => 'name'),
|
||||
'reset_token' => array('cmd' => "sccp tokenack ", 'param' => 'name'),
|
||||
'get_realtime_status' => array('cmd' => "realtime mysql status", 'param' => ''),
|
||||
);
|
||||
$result = true;
|
||||
if (!empty($params['cmd'])) {
|
||||
$id_cmd = $params['cmd'];
|
||||
if (!empty($cmd_list[$id_cmd])) {
|
||||
$id_param = $cmd_list[$id_cmd]['param'];
|
||||
if (!empty($id_param)) {
|
||||
if (!empty($params[$id_param])) {
|
||||
$result = $astman->Command($cmd_list[$id_cmd]['cmd'] . ' ' . $params[$id_param]);
|
||||
}
|
||||
$driverNamespace = "\\FreePBX\\Modules\\Sccp_manager";
|
||||
$drivers = array('aminterface' => 'aminterface.class.php', 'oldinterface' => 'oldinterface.class.php');
|
||||
$ami_mode = false;
|
||||
foreach ($drivers as $key => $value) {
|
||||
$class = $driverNamespace . "\\" . $key;
|
||||
$driver = __DIR__ . "/aminterface/" . $value;
|
||||
if (!class_exists($class, false)) {
|
||||
if (file_exists($driver)) {
|
||||
include($driver);
|
||||
} else {
|
||||
$result = $astman->Command($cmd_list[$id_cmd]['cmd']);
|
||||
throw new \Exception("Class required but file not found " . $driver);
|
||||
}
|
||||
} else {
|
||||
switch ($params['cmd']) {
|
||||
case 'phone_call':
|
||||
if (!empty($params['name'])) {
|
||||
$result = $astman->Command('sccp call ' . $params['name'] . ' ' . $params['call']);
|
||||
}
|
||||
break;
|
||||
case 'phone_message':
|
||||
if (!empty($params['msg'])) {
|
||||
$msg = $params['msg'];
|
||||
} else {
|
||||
$msg = $this->sccpvalues['servername']['data'];
|
||||
}
|
||||
if (!empty($params['name'])) {
|
||||
$astman->Command('sccp device ' . $params['name'] . ' ' . $msg);
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$result = false;
|
||||
break;
|
||||
if (class_exists($class, false)) {
|
||||
$this->$key = new $class($this->paren_class);
|
||||
$parent_class->$key = $this->$key;
|
||||
$this->_info [] = $this->$key->info();
|
||||
} else {
|
||||
throw new \Exception("Invalid Class inside in the include folder" . $freepbx);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
if ($this->aminterface->status()) {
|
||||
$this->aminterface->open();
|
||||
}
|
||||
$this->ami_mode = $this->aminterface->status();
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$Ver = '14.0.1';
|
||||
$info = '';
|
||||
foreach ($this->_info as $key => $value) {
|
||||
$info .= $value['about'] . "\n ";
|
||||
}
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'Server interface data ver: ' . $Ver . "\n " . $info);
|
||||
}
|
||||
|
||||
public function sccp_device_reset($id = '') {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_device_reset($id, 'reset');
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $id));
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_device_restart($id = '') {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_device_reset($id, 'restart');
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $id));
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_device_reload($id = '') {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_device_reset($id, 'full');
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'reload_phone', 'name' => $id));
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_reset_token($id = '') {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_device_reset($id, 'tokenack');
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'reset_token', 'name' => $id));
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'sccp_reload'));
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_line_reload($id = '') {
|
||||
if ($this->ami_mode) {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'reload_line', 'name' => $id));
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'reload_line', 'name' => $id));
|
||||
}
|
||||
}
|
||||
|
||||
private function sccp_core_commands($params = array()) {
|
||||
|
||||
if ($this->ami_mode) {
|
||||
if (!empty($params['cmd'])) {
|
||||
switch ($params['cmd']) {
|
||||
case 'reset_phone':
|
||||
return $this->aminterface->sccp_device_reset($params['name'], 'reset');
|
||||
break;
|
||||
case 'restart_phone':
|
||||
return $this->aminterface->sccp_device_reset($params['name'], 'restart');
|
||||
break;
|
||||
case 'reload_phone':
|
||||
return $this->aminterface->sccp_device_reset($params['name'], 'full');
|
||||
break;
|
||||
case 'reset_token':
|
||||
return $this->aminterface->sccp_device_reset($params['name'], 'tokenack');
|
||||
break;
|
||||
case 'reload_line':
|
||||
// return $this->aminterface->sccp_device_reset($params['name'], 'full');
|
||||
break;
|
||||
// case 'get_version':
|
||||
// case 'sccp_reload':
|
||||
// break;
|
||||
// case 'get_realtime_status':
|
||||
// break;
|
||||
// case 'phone_call':
|
||||
// case 'phone_message':
|
||||
|
||||
case 'get_softkey':
|
||||
case 'get_device':
|
||||
case 'get_hints':
|
||||
case 'get_dev_info':
|
||||
print_r($params);
|
||||
throw new \Exception("Invalid Class inside in the include folder" . $params['cmd']);
|
||||
die();
|
||||
break;
|
||||
default:
|
||||
return $this->oldinterface->sccp_core_commands($params);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands($params);
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_getdevice_info($dev_id) {
|
||||
if (empty($dev_id)) {
|
||||
return array();
|
||||
}
|
||||
$res = $this->sccp_core_commands(array('cmd' => 'get_dev_info', 'name' => $dev_id));
|
||||
$res1 = str_replace(array("\r\n", "\r", "\n"), ';', strip_tags((string) $res['data']));
|
||||
if (strpos($res1, 'MAC-Address')) {
|
||||
$res2 = substr($res1, 0, strpos($res1, '+--- Buttons '));
|
||||
$res1 = explode(';', substr($res2, strpos($res2, 'MAC-Address')));
|
||||
foreach ($res1 as $data) {
|
||||
if (!empty($data)) {
|
||||
$tmp = explode(':', $data);
|
||||
$data_key = str_replace(array(" ", "-", "\t"), '_', trim($tmp[0]));
|
||||
$res3[$data_key] = $tmp[1];
|
||||
}
|
||||
}
|
||||
|
||||
$res1 = $res3['Skinny_Phone_Type'];
|
||||
$res4 = $res3['Config_Phone_Type'];
|
||||
if (!empty($res3['Addons'])) {
|
||||
$res2 = $res3['Addons'];
|
||||
} else {
|
||||
$res2 = '';
|
||||
}
|
||||
$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']);
|
||||
// return $res4;
|
||||
// return array();
|
||||
}
|
||||
return $res3;
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_getdevice_info($dev_id);
|
||||
} else {
|
||||
return array();
|
||||
return $this->oldinterface->sccp_getdevice_info($dev_id);
|
||||
}
|
||||
}
|
||||
|
||||
/* Current not use */
|
||||
/*
|
||||
* 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() {
|
||||
$hint_key = array();
|
||||
$hint_all = $this->sccp_list_all_hints();
|
||||
foreach ($hint_all as $value) {
|
||||
$res = $this->loc_after('@', $value);
|
||||
// array_search($res, $hint_key)) != NULL)
|
||||
if (!isset($hint_key[$res])) {
|
||||
$hint_key[$res] = '@' . $res;
|
||||
}
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->core_list_hints();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_list_hints();
|
||||
}
|
||||
return $hint_key;
|
||||
}
|
||||
|
||||
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();
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$ast_out[$i] = "";
|
||||
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->core_list_all_hints();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_list_all_hints();
|
||||
}
|
||||
$i = count($ast_out) - 1;
|
||||
$ast_out[--$i] = "";
|
||||
$ast_out[--$i] = "";
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
list ($line, $junk) = explode(' ', $line);
|
||||
if (!is_bool(strpos($line, ':'))) {
|
||||
$line = trim(substr($line, 0, strpos($line, ':')));
|
||||
}
|
||||
if (isset($ast_key[$line])) {
|
||||
if (strlen($ast_key[$line]) < 1) {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
} else {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ast_key;
|
||||
}
|
||||
|
||||
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']);
|
||||
if (strpos($ast_out[0], 'Privilege') !== false) {
|
||||
$ast_out[0] = "";
|
||||
}
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
$ast_key = strstr(trim($line), ' ', true);
|
||||
$ast_res[$ast_key] = array('message' => $line, 'status' => strpos($line, 'connected') ? 'OK' : 'ERROR');
|
||||
if (!$this->ami_mode) {
|
||||
return $this->oldinterface->sccp_realtime_status();
|
||||
} else {
|
||||
$ast_out = $this->aminterface->getRealTimeStatus();
|
||||
if (is_array($ast_out)) {
|
||||
foreach ($ast_out as $aline) {
|
||||
if (strlen($aline) > 3) {
|
||||
$ast_key = strstr(trim($aline), ' ', true);
|
||||
$ast_res[$ast_key] = array('message' => $aline, 'status' => strpos($aline, 'connected') ? 'OK' : 'ERROR');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ast_res;
|
||||
}
|
||||
return $ast_res;
|
||||
}
|
||||
|
||||
// !TODO!: -TODO-: install.php is still using the other version number. This is actually where I use another method ?
|
||||
|
||||
|
||||
public function get_compatible_sccp() {
|
||||
|
||||
$res = $this->getSCCPVersion();
|
||||
if (empty($res)) {
|
||||
return 0;
|
||||
|
@ -222,280 +233,163 @@ class srvinterface {
|
|||
public function getSCCPVersion() {
|
||||
$res = $this->getChanSCCPVersion();
|
||||
if (empty($res)) {
|
||||
$res = $this->getCoreSCCPVersion();
|
||||
$res = $this->oldinterface->getCoreSCCPVersion();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
private function getCoreSCCPVersion() {
|
||||
$result = array();
|
||||
$ast_out = $this->sccp_version();
|
||||
$result["Version"] = $ast_out[0];
|
||||
if ($ast_out[0] == '-1') {
|
||||
$result["vCode"] = 0;
|
||||
return $result;
|
||||
}
|
||||
$version_parts = explode(".", $ast_out[0]);
|
||||
$result["vCode"] = implode('', $version_parts);
|
||||
if (!empty($ast_out[1]) && $ast_out[1] == 'develop') {
|
||||
$result["develop"] = $ast_out[1];
|
||||
$res = 10;
|
||||
// !TODO!: This does not work as you might expect
|
||||
if (base_convert($ast_out[3], 16, 10) == base_convert('702487a', 16, 10)) {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
if (base_convert($ast_out[3], 16, 10) >= "10403") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 432;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
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) ) {
|
||||
return array('-1');
|
||||
}
|
||||
if (preg_match("/Release.*\(/", $ast_out['data'], $matches)) {
|
||||
$ast_out = substr($matches[0], 9, -1);
|
||||
return explode(' ', $ast_out);
|
||||
} else {
|
||||
return array('unknown');
|
||||
}
|
||||
}
|
||||
|
||||
private function getChanSCCPVersion() {
|
||||
global $astman;
|
||||
$result = array();
|
||||
if (!$astman) {
|
||||
return $result;
|
||||
}
|
||||
$metadata = $this->astman_retrieveJSFromMetaData("");
|
||||
// return $metadata;
|
||||
if ($metadata && array_key_exists("Version", $metadata)) {
|
||||
$result["Version"] = $metadata["Version"];
|
||||
$version_parts = explode(".", $metadata["Version"]);
|
||||
$result["vCode"] = 0;
|
||||
|
||||
# not sure about this sccp_ver numbering. Might be better to just check "Version" and Revision
|
||||
# $result["vCode"] = implode('', $version_parts);
|
||||
$result["vCode"] = 0;
|
||||
if ($version_parts[0] == "4") {
|
||||
$result["vCode"] = 400;
|
||||
if ($version_parts[1] == "1") {
|
||||
$result["vCode"] = 410;
|
||||
} else
|
||||
if ($version_parts[1] == "2") {
|
||||
$result["vCode"] = 420;
|
||||
} else
|
||||
if ($version_parts[1] >= "3") {
|
||||
$result["vCode"] = 430;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (array_key_exists("Branch",$metadata)) {
|
||||
if ($metadata["Branch"] == "master") {
|
||||
|
||||
} else
|
||||
if ($metadata["Branch"] == "develop") {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Revision got replaced by RevisionHash in 10404 (using the hash does not work) */
|
||||
if (array_key_exists("Revision", $metadata)) {
|
||||
if (base_convert($metadata["Revision"], 16, 10) == base_convert('702487a', 16, 10)) {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
if (base_convert($metadata["Revision"], 16, 10) >= "10403") {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("RevisionHash", $metadata)) {
|
||||
$result["RevisionHash"] = $metadata["RevisionHash"];
|
||||
} else {
|
||||
$result["RevisionHash"] = '';
|
||||
}
|
||||
if (array_key_exists("RevisionNum", $metadata)) {
|
||||
$result["RevisionNum"] = $metadata["RevisionNum"];
|
||||
if ($metadata["RevisionNum"] >= "10403") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 432;
|
||||
}
|
||||
if ($metadata["RevisionNum"] >= "10491") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 433;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("ConfigureEnabled", $metadata)) {
|
||||
$result["futures"] = implode(';', $metadata["ConfigureEnabled"]);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
die_freepbx("Version information could not be retrieved from chan-sccp, via astman::SCCPConfigMetaData");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function sccp_list_keysets() {
|
||||
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_softkey'));
|
||||
|
||||
$ast_out = preg_split("/[\n]/", $ast_out['data']);
|
||||
$ast_key = array();
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$ast_out[$i] = "";
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_list_keysets();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_list_keysets();
|
||||
}
|
||||
$i = count($ast_out) - 1;
|
||||
$ast_out[--$i] = "";
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
$line = substr($line, 2);
|
||||
list ($line, $junk) = explode(' ', $line);
|
||||
if (isset($ast_key[$line])) {
|
||||
if (strlen($ast_key[$line]) < 1) {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
} else {
|
||||
$ast_key[$line] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ast_key;
|
||||
}
|
||||
|
||||
public function sccp_get_active_device() {
|
||||
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_device'));
|
||||
|
||||
$ast_out = preg_split("/[\n]/", $ast_out['data']);
|
||||
|
||||
$ast_key = array();
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$ast_out[$i] = "";
|
||||
}
|
||||
$i = count($ast_out) - 1;
|
||||
$ast_out[--$i] = "";
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
$line = substr($line, 2);
|
||||
$line = preg_replace("/\s{2,}/", " ", $line);
|
||||
$line_arr = explode(' ', $line);
|
||||
$it = 1;
|
||||
do {
|
||||
if ($this->strpos_array($line_arr[$it + 1], array('SEP', 'ATA', 'VG')) === false) {
|
||||
// if (strpos($line_arr[$it + 1], 'SEP') === false) {
|
||||
$line_arr[0] .= ' ' . $line_arr[$it];
|
||||
unset($line_arr[$it]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
$it++;
|
||||
} while ((count($line_arr) > 3) and ( $it < count($line_arr)));
|
||||
explode(";|", implode(";|", $line_arr));
|
||||
list ($descr, $adress, $devname, $status, $token, $junk) = explode(";|", implode(";|", $line_arr));
|
||||
|
||||
// list ($descr, $adress, $devname, $status, $junk) = $line_arr;
|
||||
// if (strlen($ast_key[$devname]) < 1) {
|
||||
if (strlen($devname) > 1) {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $token);
|
||||
}
|
||||
/*
|
||||
if (isset($ast_key[$devname])) {
|
||||
if (strlen($ast_key[$devname]) < 1) {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $descr);
|
||||
}
|
||||
} else {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $adress, 'descr' => $descr, 'token' => $token);
|
||||
}
|
||||
*
|
||||
*/
|
||||
}
|
||||
}
|
||||
return $ast_key;
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace sccp_core_commands($params = array()) {
|
||||
*/
|
||||
|
||||
private function astman_retrieveJSFromMetaData($segment = "") {
|
||||
global $astman;
|
||||
$params = array();
|
||||
if ($segment != "") {
|
||||
$params["Segment"] = $segment;
|
||||
}
|
||||
$response = $astman->send_request('SCCPConfigMetaData', $params);
|
||||
if ($response["Response"] == "Success") {
|
||||
//outn(_("JSON-content:").$response["JSON"]);
|
||||
$decode = json_decode($response["JSON"], true);
|
||||
return $decode;
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_get_active_device();
|
||||
} else {
|
||||
return false;
|
||||
return $this->oldinterface->sccp_get_active_device();
|
||||
}
|
||||
}
|
||||
|
||||
private function strpos_array($haystack, $needles) {
|
||||
if (is_array($needles)) {
|
||||
foreach ($needles as $str) {
|
||||
if (is_array($str)) {
|
||||
$pos = strpos_array($haystack, $str);
|
||||
function getChanSCCPVersion() {
|
||||
if (!$this->ami_mode) {
|
||||
return $this->oldinterface->getChanSCCPVersion();
|
||||
} else {
|
||||
$result = array();
|
||||
$metadata = $this->aminterface->getSCCPVersion();
|
||||
|
||||
if ($metadata && array_key_exists("Version", $metadata)) {
|
||||
$result["Version"] = $metadata["Version"];
|
||||
$version_parts = explode(".", $metadata["Version"]);
|
||||
$result["vCode"] = 0;
|
||||
if ($version_parts[0] == "4") {
|
||||
switch ($version_parts[1]) {
|
||||
case "1":
|
||||
$result["vCode"] = 410;
|
||||
break;
|
||||
case "2":
|
||||
$result["vCode"] = 420;
|
||||
break;
|
||||
case 3. . .5 :
|
||||
$result["vCode"] = 430;
|
||||
break;
|
||||
default:
|
||||
$result["vCode"] = 400;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Revision got replaced by RevisionHash in 10404 (using the hash does not work) */
|
||||
if (array_key_exists("Revision", $metadata)) {
|
||||
if (base_convert($metadata["Revision"], 16, 10) == base_convert('702487a', 16, 10)) {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
if (base_convert($metadata["Revision"], 16, 10) >= "10403") {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("RevisionHash", $metadata)) {
|
||||
$result["RevisionHash"] = $metadata["RevisionHash"];
|
||||
} else {
|
||||
$pos = strpos($haystack, $str);
|
||||
$result["RevisionHash"] = '';
|
||||
}
|
||||
if ($pos !== FALSE) {
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return strpos($haystack, $needles);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
private function loc_after($value, $inthat) {
|
||||
if (!is_bool(strpos($inthat, $value)))
|
||||
return substr($inthat, strpos($inthat, $value) + strlen($value));
|
||||
}
|
||||
|
||||
function getеtestChanSCC() {
|
||||
global $astman;
|
||||
// $action = Array('SCCPShowGlobals',);
|
||||
$params = array();
|
||||
$action = 'SCCPShowSoftkeySets';
|
||||
// $params = array('Segment' => 'device', 'ResultFormat'=>'command' );
|
||||
// $params = array('Segment' => 'device');
|
||||
// $params = array();
|
||||
$metadata = $astman->send_request($action, $params);
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/*
|
||||
* [Segments] => ( [0] => general [1] => device [2] => line [3] => softkey )
|
||||
*/
|
||||
function getеtestChanSCCP_GlablsInfo($Segment = '') {
|
||||
global $astman;
|
||||
$params = array();
|
||||
|
||||
$action = 'SCCPConfigMetaData';
|
||||
if (empty($Segment)) {
|
||||
$Segment = 'general';
|
||||
}
|
||||
$params = array('Segment' => $Segment, 'ResultFormat' => 'command');
|
||||
$metadata = $astman->send_request($action, $params);
|
||||
if (!empty($metadata['data'])) {
|
||||
$tmp_data = $metadata['data'];
|
||||
if (strpos($tmp_data, 'JSON:') !== false) {
|
||||
$decode = json_decode(substr($tmp_data, strpos($tmp_data, 'JSON:') + 5), true);
|
||||
$result = array();
|
||||
if (!empty($decode['Options'])) {
|
||||
foreach ($decode['Options'] as $value) {
|
||||
$result[$value['Name']] = $value;
|
||||
if (array_key_exists("RevisionNum", $metadata)) {
|
||||
$result["RevisionNum"] = $metadata["RevisionNum"];
|
||||
if ($metadata["RevisionNum"] >= "10403") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 432;
|
||||
}
|
||||
if ($metadata["RevisionNum"] >= "10491") { // new method, RevisionNum is incremental
|
||||
$result["vCode"] = 433;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $decode;
|
||||
if (array_key_exists("ConfigureEnabled", $metadata)) {
|
||||
$result["futures"] = implode(';', $metadata["ConfigureEnabled"]);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
die_freepbx("Version information could not be retrieved from chan-sccp, via astman::SCCPConfigMetaData");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
// ---------------------------- Debug Data -------------------------------------------
|
||||
function t_get_ami_data() {
|
||||
global $amp_conf;
|
||||
$fp = fsockopen("127.0.0.1", "5038", $errno, $errstr, 10);
|
||||
if (!$fp) {
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
} else {
|
||||
$time_connect = microtime_float();
|
||||
fputs($fp, "Action: login\r\n");
|
||||
fputs($fp, "Username: " . $amp_conf[AMPMGRUSER] . "\r\n");
|
||||
// fputs ($fp,"Secret: secret\r\n");
|
||||
fputs($fp, "Secret: " . $amp_conf[AMPMGRPASS] . "\r\n");
|
||||
fputs($fp, "Events: on\r\n\r\n");
|
||||
|
||||
// fputs($fp, "Action: SCCPShowDevice\r\n");
|
||||
// fputs($fp,"Segment: general\r\n");
|
||||
// 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: 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");
|
||||
// fputs($fp, "Command: core show hints\r\n");
|
||||
// fputs ($fp,"Segment: general\r\n");
|
||||
// fputs ($fp,"Segment: general\r\n");
|
||||
// "Segments":["general","device","line","softkey"]}
|
||||
// fputs ($fp,"Segment: device\r\n");
|
||||
// fputs ($fp,"ResultFormat: command\r\n");
|
||||
fputs($fp, "\r\n");
|
||||
$time_send = microtime_float();
|
||||
/*
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"Option: fallback\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"ListResult: freepbx\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"Option: dtmfmode\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
*/
|
||||
fputs($fp, "Action: logoff\r\n\r\n");
|
||||
$time_logoff = microtime_float();
|
||||
|
||||
// print_r(fgets($fp));
|
||||
$resp = '';
|
||||
while (!feof($fp)) {
|
||||
$resp .= fgets($fp);
|
||||
}
|
||||
$time_resp = microtime_float();
|
||||
$resp .= "\r\n\r\n Connect :".($time_send - $time_connect). " Logoff :".($time_logoff- $time_send). " Responce :".($time_resp-$time_logoff)."\r\n\r\n ";
|
||||
// print_r(fgets($fp));
|
||||
// print_r('<br>');
|
||||
// echo fgets($fp, 128);
|
||||
}
|
||||
fclose($fp);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,44 +42,22 @@ class xmlinterface {
|
|||
|
||||
|
||||
$xnode = &$xml_work->callManagerGroup->members;
|
||||
if ($data_values['bindaddr'] == '0.0.0.0') {
|
||||
$ifc = 0;
|
||||
// $xnode->member['priority'] = print_r($data_values['server_if_list'], true);
|
||||
foreach ($data_values['server_if_list'] as $value) {
|
||||
if (!empty($value['ip'])) {
|
||||
$ip_valid = true;
|
||||
if (!empty($data_values['ccm_address'])) {
|
||||
if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false) {
|
||||
// Skip
|
||||
} else {
|
||||
if (strpos($data_values['ccm_address'], $value['ip']) === false) {
|
||||
$ip_valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1'), true) && ($ip_valid)) {
|
||||
$xnode_obj = clone $xnode->member;
|
||||
$xnode_obj['priority'] = $ifc;
|
||||
//$xnode_obj = &$xnode -> member -> callManager;
|
||||
$xnode_obj->callManager->name = $data_values['servername'];
|
||||
$xnode_obj->callManager->ports->ethernetPhonePort = $data_values['port'];
|
||||
$xnode_obj->callManager->processNodeName = $value['ip'];
|
||||
if ($ifc === 0) {
|
||||
$this->replaceSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
}
|
||||
$ifc ++;
|
||||
}
|
||||
}
|
||||
$bind_tmp = $this->get_server_sccp_bind($data_values);
|
||||
$ifc = 0;
|
||||
foreach ($bind_tmp as $bind_value) {
|
||||
$xnode_obj = clone $xnode->member;
|
||||
$xnode_obj['priority'] = $ifc;
|
||||
$xnode_obj->callManager->name = $data_values['servername'];
|
||||
$xnode_obj->callManager->ports->ethernetPhonePort = $bind_value['port'];
|
||||
$xnode_obj->callManager->processNodeName = $bind_value['ip'];
|
||||
if ($ifc === 0) {
|
||||
$this->replaceSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
}
|
||||
} else {
|
||||
$xnode->member['priority'] = '0';
|
||||
$xnode_obj = &$xnode->member->callManager;
|
||||
$xnode_obj->name = $data_values['servername'];
|
||||
$xnode_obj->ports->ethernetPhonePort = $data_values['port'];
|
||||
$xnode_obj->processNodeName = $data_values['bindaddr'];
|
||||
$ifc++;
|
||||
}
|
||||
|
||||
$this->replaceSimpleXmlNode($xml_work->callManagerGroup->members, $xnode);
|
||||
|
||||
foreach ($def_xml_fields as $value) {
|
||||
|
@ -231,14 +209,14 @@ class xmlinterface {
|
|||
$xnode->$nod = $srs_val[0];
|
||||
$nod = $srs_put[1] . $si;
|
||||
$xnode->$nod = $srs_val[1];
|
||||
$si ++;
|
||||
$si++;
|
||||
}
|
||||
while ($si < 4) {
|
||||
$nod = $srs_put[0] . $si;
|
||||
$xnode->$nod = '';
|
||||
$nod = $srs_put[1] . $si;
|
||||
$xnode->$nod = '';
|
||||
$si ++;
|
||||
$si++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -260,7 +238,7 @@ class xmlinterface {
|
|||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
}
|
||||
$ifc ++;
|
||||
$ifc++;
|
||||
}
|
||||
/* if ($data_values['bindaddr'] == '0.0.0.0') {
|
||||
$ifc = 0;
|
||||
|
@ -332,7 +310,7 @@ class xmlinterface {
|
|||
$xnode_obj = $xnode->addChild('addOnModule');
|
||||
$xnode_obj->addAttribute('idx', $ti);
|
||||
$xnode_obj->addChild('loadInformation', $add_val);
|
||||
$ti ++;
|
||||
$ti++;
|
||||
}
|
||||
}
|
||||
// $this->appendSimpleXmlNode($xml_work , $xnode_obj);
|
||||
|
@ -396,60 +374,82 @@ class xmlinterface {
|
|||
|
||||
private function get_server_sccp_bind($data_values = array()) {
|
||||
$res = array();
|
||||
|
||||
if ($data_values['bindaddr'] == '0.0.0.0') {
|
||||
$ifc = 0;
|
||||
foreach ($data_values['server_if_list'] as $value) {
|
||||
if (!empty($value['ip'])) {
|
||||
$ip_valid = true;
|
||||
if (!empty($data_values['ccm_address'])) {
|
||||
if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false) {
|
||||
// Skip
|
||||
} else {
|
||||
if (strpos($data_values['ccm_address'], $value['ip']) === false) {
|
||||
$ip_valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1'), true) && ($ip_valid)) {
|
||||
$res[] = array('ip' => $value['ip'], 'port' => $data_values['port']);
|
||||
if ($data_values['bindaddr'] !== '0.0.0.0') {
|
||||
return array('ip' => $data_values['bindaddr'], 'port' => $data_values['port']);
|
||||
}
|
||||
$ip_fill = true;
|
||||
if (!empty($data_values['ccm_address'])) {
|
||||
$ccm_address = $data_values['ccm_address'];
|
||||
if (strpos($ccm_address, 'internal') === false && strpos($ccm_address, '0.0.0.0') === false) {
|
||||
$tmp_data = explode(';', $ccm_address);
|
||||
$ip_fill = false;
|
||||
foreach ($tmp_data as $tmp_row) {
|
||||
if (strpos($tmp_row, '/') !== false) {
|
||||
$ttmp_r = explode('/', $tmp_row); // IPv6 - ????
|
||||
$rkey = $ttmp_r[0];
|
||||
$res[$rkey] = array('ip' => $rkey, 'port' => $ttmp_r[1]);
|
||||
} else {
|
||||
$rkey = $tmp_row;
|
||||
$res[$rkey] = array('ip' => $rkey, 'port' => $data_values['port']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$res[0] = array('ip' => $data_values['bindaddr'], 'port' => $data_values['port']);
|
||||
}
|
||||
if ($ip_fill) {
|
||||
foreach ($data_values['server_if_list'] as $value) {
|
||||
if (!empty($value['ip'])) {
|
||||
if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1'), true)) {
|
||||
$rkey = $value['ip'];
|
||||
$res[$rkey] = array('ip' => $rkey, 'port' => $data_values['port']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($data_values['externhost'])) {
|
||||
$rkey = $data_values['externhost'];
|
||||
if (!in_array($rkey, array('0.0.0.0', '127.0.0.1', 'localhost'), true)) {
|
||||
$res[$rkey] = array('ip' => $rkey, 'port' => $data_values['port']);
|
||||
}
|
||||
} else {
|
||||
if (!empty($data_values['externip'])) {
|
||||
$rkey = $data_values['externip'];
|
||||
if (!in_array($rkey, array('0.0.0.0', '127.0.0.1'), true)) {
|
||||
$res[$rkey] = array('ip' => $rkey, 'port' => $data_values['port']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/*
|
||||
private function get_server_sip_bind($data_values = array()) {
|
||||
$res = array();
|
||||
private function get_server_sip_bind($data_values = array()) {
|
||||
$res = array();
|
||||
|
||||
if (!empty($data_values['sipbind']) and ( $data_values['sipbind'] != '0.0.0.0')) {
|
||||
$res[0] = array('ip' => $data_values['sipbind'], 'port' => $data_values['sipbindport'], 'tlsport' => $data_values['tlsport'], 'proto' => $data_values['sipsuportproto']);
|
||||
}
|
||||
if (!empty($data_values['sipbind']) and ( $data_values['sipbind'] != '0.0.0.0')) {
|
||||
$res[0] = array('ip' => $data_values['sipbind'], 'port' => $data_values['sipbindport'], 'tlsport' => $data_values['tlsport'], 'proto' => $data_values['sipsuportproto']);
|
||||
}
|
||||
|
||||
$ifc = 0;
|
||||
foreach ($data_values['server_if_list'] as $value) {
|
||||
if (!empty($value['ip'])) {
|
||||
$ip_valid = true;
|
||||
if (!empty($data_values['ccm_address'])) {
|
||||
if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false) {
|
||||
// Skip
|
||||
} else {
|
||||
if (strpos($data_values['ccm_address'], $value['ip']) === false) {
|
||||
$ip_valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1', $data_values['sipbind']), true) && ($ip_valid)) {
|
||||
$res[] = array('ip' => $value['ip'], 'port' => $data_values['sipbindport'], 'tlsport' => $data_values['tlsport'], 'proto' => $data_values['sipsuportproto']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
$ifc = 0;
|
||||
foreach ($data_values['server_if_list'] as $value) {
|
||||
if (!empty($value['ip'])) {
|
||||
$ip_valid = true;
|
||||
if (!empty($data_values['ccm_address'])) {
|
||||
if (strpos($data_values['ccm_address'], 'internal') !== false || strpos($data_values['ccm_address'], '0.0.0.0') !== false) {
|
||||
// Skip
|
||||
} else {
|
||||
if (strpos($data_values['ccm_address'], $value['ip']) === false) {
|
||||
$ip_valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!in_array($value['ip'], array('0.0.0.0', '127.0.0.1', $data_values['sipbind']), true) && ($ip_valid)) {
|
||||
$res[] = array('ip' => $value['ip'], 'port' => $data_values['sipbindport'], 'tlsport' => $data_values['tlsport'], 'proto' => $data_values['sipsuportproto']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -493,12 +493,12 @@ class xmlinterface {
|
|||
$sip_bind = $data_values['sbind'];
|
||||
$bind_proto = 'tcp';
|
||||
$bind_ip_def = '';
|
||||
foreach($sip_bind as $key => $value) {
|
||||
foreach ($sip_bind as $key => $value) {
|
||||
if (empty($bind_ip_def)) {
|
||||
$bind_ip_def = $key;
|
||||
$bind_proto = (isset($value['tcp'])) ? 'tcp' : 'udp';
|
||||
$bind_proto = (isset($value['tcp'])) ? 'tcp' : 'udp';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($xml_template)) {
|
||||
$xml_work = simplexml_load_file($xml_template);
|
||||
|
@ -598,7 +598,7 @@ class xmlinterface {
|
|||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
}
|
||||
$ifc ++;
|
||||
$ifc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ class xmlinterface {
|
|||
}
|
||||
switch ($dkey) {
|
||||
case 'sipProxies':
|
||||
$xnode = &$xml_node->$dkey;
|
||||
$xnode = &$xml_node->$dkey;
|
||||
$xnode->backupProxy = $bind_ip_def;
|
||||
$xnode->backupProxyPort = $sip_bind[$bind_ip_def][$bind_proto];
|
||||
$xnode->emergencyProxy = $bind_proto;
|
||||
|
@ -636,7 +636,7 @@ class xmlinterface {
|
|||
$xnode_obj['button'] = $ifc + 1;
|
||||
$xnode_obj['lineIndex'] = $ifc + 1;
|
||||
//$xnode_obj->proxy = $data_values['bindaddr'];
|
||||
$xnode_obj-> featureID = "9";
|
||||
$xnode_obj->featureID = "9";
|
||||
if ($xnode_obj->proxy != 'USECALLMANAGER') {
|
||||
$xnode_obj->proxy = $bind_proto;
|
||||
$xnode_obj->port = $sip_bind[$bind_ip_def][$bind_proto];
|
||||
|
@ -651,18 +651,18 @@ class xmlinterface {
|
|||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->line, $xnode_obj);
|
||||
}
|
||||
$ifc ++;
|
||||
$ifc++;
|
||||
}
|
||||
}
|
||||
if (!empty($data_values['speeddial'])) {
|
||||
foreach ($data_values['speeddial'] as $spkey => $spvalue) {
|
||||
$xmlstr = '<line button="'. ($ifc + 1) .'"> <featureID>22</featureID>'
|
||||
.'<featureLabel>'.$spvalue["name"].'</featureLabel>'
|
||||
.'<speedDialNumber>'.$spvalue["dial"].'</speedDialNumber>'
|
||||
.'<contact>'.$spvalue["dial"].'</contact> <retrievalPrefix /></line>';
|
||||
$xmlstr = '<line button="' . ($ifc + 1) . '"> <featureID>22</featureID>'
|
||||
. '<featureLabel>' . $spvalue["name"] . '</featureLabel>'
|
||||
. '<speedDialNumber>' . $spvalue["dial"] . '</speedDialNumber>'
|
||||
. '<contact>' . $spvalue["dial"] . '</contact> <retrievalPrefix /></line>';
|
||||
$xnode_obj = simplexml_load_string($xmlstr);
|
||||
$this->appendSimpleXmlNode($xnode->line, $xnode_obj);
|
||||
$ifc ++;
|
||||
$ifc++;
|
||||
}
|
||||
}
|
||||
// $xnode = &$xml_node->$dkey->members;
|
||||
|
@ -674,7 +674,7 @@ class xmlinterface {
|
|||
$templet_path = (($dkey == 'softKeyFile') ? $dev_config['tftp_softkey'] : $dev_config['tftp_dialplan']);
|
||||
$tmp_key = ($dkey == 'softKeyFile') ? 'softkeyset' : '_dialrules';
|
||||
if (!empty($dev_config[$tmp_key])) {
|
||||
$xml_ext_file = (($dkey == 'softKeyFile') ? 'softkey'.$dev_config[$tmp_key].'.xml' : $dev_config[$tmp_key].'.xml');
|
||||
$xml_ext_file = (($dkey == 'softKeyFile') ? 'softkey' . $dev_config[$tmp_key] . '.xml' : $dev_config[$tmp_key] . '.xml');
|
||||
}
|
||||
// $xml_node->$dkey = $templet_path . '/' . $xml_ext_file.'---'.$dev_config[$tmp_key];
|
||||
// break;
|
||||
|
@ -710,7 +710,7 @@ class xmlinterface {
|
|||
$xnode_obj = $xnode->addChild('addOnModule');
|
||||
$xnode_obj->addAttribute('idx', $ti);
|
||||
$xnode_obj->addChild('loadInformation', $add_val);
|
||||
$ti ++;
|
||||
$ti++;
|
||||
}
|
||||
// $this->appendSimpleXmlNode($xml_work , $xnode_obj);
|
||||
}
|
||||
|
@ -771,9 +771,9 @@ class xmlinterface {
|
|||
return time();
|
||||
}
|
||||
|
||||
function save_DialPlan($confDir,$get_settings) {
|
||||
function save_DialPlan($confDir, $get_settings) {
|
||||
$xmlstr = "<DIALTEMPLATE>\n";
|
||||
$xmlstr .= "<versionStamp>".time()."</versionStamp>\n";
|
||||
$xmlstr .= "<versionStamp>" . time() . "</versionStamp>\n";
|
||||
$dialFelds = array('match', 'timeout', 'rewrite', 'tone'); //str -to lo !
|
||||
|
||||
$hdr_prefix = 'sccp_dial_';
|
||||
|
@ -811,7 +811,7 @@ class xmlinterface {
|
|||
} else {
|
||||
$errors = array('Fields Dial Plan Name is requered !!');
|
||||
}
|
||||
|
||||
|
||||
if (empty($errors)) {
|
||||
// $put_file = 'test';
|
||||
$put_file = str_replace(array("\n", "\r", "\t", "/", "\\", ".", ","), '', $put_file);
|
||||
|
@ -824,41 +824,41 @@ class xmlinterface {
|
|||
|
||||
function create_xmlSoftkeyset($config, $confDir, $name) {
|
||||
if (empty($config[$name])) {
|
||||
if ($name =='default') {
|
||||
$typeSoft = $confDir["tftp_templates"].'/SIPDefaultSoftKey.xml_template';
|
||||
if(file_exists($typeSoft)){
|
||||
if ($name == 'default') {
|
||||
$typeSoft = $confDir["tftp_templates"] . '/SIPDefaultSoftKey.xml_template';
|
||||
if (file_exists($typeSoft)) {
|
||||
$file = $confDir["tftp_softkey"] . '/softkey' . $name . '.xml';
|
||||
if (!copy($typeSoft, $file)) {
|
||||
return array('error'=>'Access error'.$name);
|
||||
return array('error' => 'Access error' . $name);
|
||||
}
|
||||
}
|
||||
return array();
|
||||
} else {
|
||||
return array('error'=>'Invalid softkey Name'.$name);
|
||||
return array('error' => 'Invalid softkey Name' . $name);
|
||||
}
|
||||
}
|
||||
$errors = array();
|
||||
$xmlstr = "<softKeyCfg>\n";
|
||||
$xmlstr .= "<versionStamp>".time()."</versionStamp>\n";
|
||||
$xmlstr .= "<versionStamp>" . time() . "</versionStamp>\n";
|
||||
// $xmlstr .= "<typeSoftKey></typeSoftKey>\n";
|
||||
$typeSoft = $confDir["tftp_templates"].'/SIPTypeSoftKey.xml_template';
|
||||
$typeSoft = $confDir["tftp_templates"] . '/SIPTypeSoftKey.xml_template';
|
||||
$read_soft = "";
|
||||
if(file_exists($typeSoft)){
|
||||
$f_read = fopen($typeSoft,'r');
|
||||
if (file_exists($typeSoft)) {
|
||||
$f_read = fopen($typeSoft, 'r');
|
||||
while (!feof($f_read)) {
|
||||
$read_soft .= fread($f_read, 8192);
|
||||
}
|
||||
fclose($f_read);
|
||||
fclose($f_read);
|
||||
}
|
||||
$xmlstr .= $read_soft;
|
||||
// $xmlstr .= $read_soft."\n</typeSoftKey>\n";
|
||||
$xmlstr .= " <softKeySets>\n";
|
||||
foreach ($config[$name] as $key => $value) {
|
||||
$xmlstr .=' <softKeySet id="'.$key.'">'."\n";
|
||||
foreach (explode(",",$value) as $keyvalue ) {
|
||||
$xmlstr .= ' <softKey keyID="'.$keyvalue.'" />'."\n";
|
||||
$xmlstr .= ' <softKeySet id="' . $key . '">' . "\n";
|
||||
foreach (explode(",", $value) as $keyvalue) {
|
||||
$xmlstr .= ' <softKey keyID="' . $keyvalue . '" />' . "\n";
|
||||
}
|
||||
$xmlstr .=" </softKeySet>\n";
|
||||
$xmlstr .= " </softKeySet>\n";
|
||||
}
|
||||
$xmlstr .= " </softKeySets>\n";
|
||||
|
||||
|
@ -870,7 +870,6 @@ class xmlinterface {
|
|||
}
|
||||
|
||||
return $errors;
|
||||
|
||||
}
|
||||
|
||||
private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement) {
|
||||
|
|
|
@ -43,8 +43,8 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
|||
"prettyName" => _("Sccp Custom Driver"),
|
||||
"shortName" => "SCCP",
|
||||
"description" => _("Sccp Device"),
|
||||
"Version" => "11.3.v434m",
|
||||
"about" => "Sccp mysql class Base ver: 11.3, Sccp ver: 434"
|
||||
"Version" => "11.4.v434m",
|
||||
"about" => "Sccp mysql class Base ver: 11.4, Sccp ver: 434"
|
||||
);
|
||||
}
|
||||
public function addDevice($id, $settings) {
|
||||
|
@ -127,6 +127,8 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
|||
// die(print_r($sql));
|
||||
$sth = $this->database->prepare($sql);
|
||||
$sth->execute();
|
||||
|
||||
$this->reload_line($id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -135,9 +137,15 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
|||
$sql = "DELETE FROM sccpline WHERE name = ?";
|
||||
$sth = $this->database->prepare($sql);
|
||||
$sth->execute(array($id));
|
||||
$this->reload_line($id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function reload_line($id) {
|
||||
global $astman;
|
||||
$result = $astman->Command('sccp reload line ' . $id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDevice($id) {
|
||||
$sccp_line = array();
|
||||
|
|
|
@ -295,7 +295,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
</select>
|
||||
<help>Date Format: The date format for the on-screen display. Can be one of the following: (D-M-YA, M.D.Y, Y/M/D) where 'D' is Day, 'M' is Month, 'Y' is Year, 'A' is 24-hour, 'a' is 12-hour, and the separators can be '.','-','/'</help>
|
||||
</item>
|
||||
<item type="SLZN" id="2" seq="95"><label>Time Zone</label>
|
||||
<item type="SLTZN" id="2" seq="95"><label>Time Zone</label>
|
||||
<name>ntp_timezone</name>
|
||||
<select>
|
||||
<default>UTC</default>
|
||||
|
|
|
@ -11,7 +11,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
* SLA - Select element (from - data )
|
||||
* Input element Select SLD - Date format
|
||||
* SLZ - Time Zone
|
||||
* SLZN - Time Zone List
|
||||
* SLTZN - Time Zone List
|
||||
* SLT - TFTP Lang
|
||||
* SLM - Music on hold
|
||||
* SLK - System KeySet
|
||||
|
@ -486,7 +486,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
</select>
|
||||
<help>Date Format: The date format for the on-screen display. Can be one of the following: (D-M-YA, M.D.Y, Y/M/D) where 'D' is Day, 'M' is Month, 'Y' is Year, 'A' is 24-hour, 'a' is 12-hour, and the separators can be '.','-','/'</help>
|
||||
</item>
|
||||
<item type="SLZN" id="2" seq="95">
|
||||
<item type="SLTZN" id="2" seq="95">
|
||||
<label>Time Zone</label>
|
||||
<name>ntp_timezone</name>
|
||||
<class>sccp-custom</class>
|
||||
|
|
|
@ -11,7 +11,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
* SLA - Select element (from - data )
|
||||
* Input element Select SLD - Date format
|
||||
* SLZ - Time Zone
|
||||
* SLZN - Time Zone List
|
||||
* SLTZN - Time Zone List
|
||||
* SLT - TFTP Lang
|
||||
* SLM - Music on hold
|
||||
* SLK - System KeySet
|
||||
|
@ -97,16 +97,24 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
<nameseparator> : </nameseparator>
|
||||
</item>
|
||||
<item type="IE" id="4">
|
||||
<label>External Ip</label>
|
||||
<label>External Ip / Name</label>
|
||||
<input>
|
||||
<name>externip</name>
|
||||
<default></default>
|
||||
<default>0.0.0.0</default>
|
||||
<class>sccp-custom</class>
|
||||
<options placeholder="Provider IP"></options>
|
||||
</input>
|
||||
<help>External IP Address of the firewall, required in case the PBX is running on a seperate host behind it. IP Address that we're going to notify in RTP media stream as the pbx source address.</help>
|
||||
<input>
|
||||
<name>externhost</name>
|
||||
<default></default>
|
||||
<class>sccp-custom</class>
|
||||
<options placeholder="Host Name"></options>
|
||||
</input>
|
||||
|
||||
<help>External IP Address of the firewall, required in case the PBX is running on a seperate host behind it. IP Address that we're going to notify in RTP media stream as the pbx source address. Resolve Hostname (if dynamic) that we're going to resolve when setting up the RTP media stream (only active if externip=0.0.0.0 and host is natted.)</help>
|
||||
<meta_help>1</meta_help>
|
||||
<nameseparator> / </nameseparator>
|
||||
externhost
|
||||
</item>
|
||||
|
||||
<item type="IE" id="5">
|
||||
|
@ -212,12 +220,17 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
</item>
|
||||
|
||||
<item type="IED" id="1" seq="98">
|
||||
<label>Device Connect Address</label>
|
||||
<label>Device Connect Address / Name </label>
|
||||
<name>ccm_address</name>
|
||||
<cbutton field="internal" value="internal">Internal</cbutton>
|
||||
<default>0.0.0.0</default>
|
||||
<input value="NONE" field="ip" nameseparator="">
|
||||
<options placeholder="0.0.0.0" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"/>
|
||||
<default>0.0.0.0:2000</default>
|
||||
<input value="NONE" field="ip" nameseparator=":">
|
||||
<options placeholder="0.0.0.0 / pbx.org"/>
|
||||
<class></class>
|
||||
</input>
|
||||
<input value="NONE" field="port">
|
||||
<options placeholder="2000"/>
|
||||
<class></class>
|
||||
</input>
|
||||
<add_pluss>+</add_pluss>
|
||||
<addbutton-disabled>Add Address</addbutton-disabled>
|
||||
|
@ -512,7 +525,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
</select>
|
||||
<help>Date Format: The date format for the on-screen display. Can be one of the following: (D-M-YA, M.D.Y, Y/M/D) where 'D' is Day, 'M' is Month, 'Y' is Year, 'A' is 24-hour, 'a' is 12-hour, and the separators can be '.','-','/'</help>
|
||||
</item>
|
||||
<item type="SLZN" id="2" seq="95">
|
||||
<item type="SLTZN" id="2" seq="95">
|
||||
<label>Time Zone</label>
|
||||
<name>ntp_timezone</name>
|
||||
<class>sccp-custom</class>
|
||||
|
|
|
@ -11,7 +11,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
* SLA - Select element (from - data )
|
||||
* Input element Select SLD - Date format
|
||||
* SLZ - Time Zone
|
||||
* SLZN - Time Zone List
|
||||
* SLTZN - Time Zone List
|
||||
* SLT - TFTP Lang
|
||||
* SLM - Music on hold
|
||||
* SLK - System KeySet
|
||||
|
@ -559,7 +559,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
</select>
|
||||
<help>Date Format: The date format for the on-screen display. Can be one of the following: (D-M-YA, M.D.Y, Y/M/D) where 'D' is Day, 'M' is Month, 'Y' is Year, 'A' is 24-hour, 'a' is 12-hour, and the separators can be '.','-','/'</help>
|
||||
</item>
|
||||
<item type="SLZN" id="2" seq="95">
|
||||
<item type="SLTZN" id="2" seq="95">
|
||||
<label>Time Zone</label>
|
||||
<name>ntp_timezone</name>
|
||||
<class>sccp-custom</class>
|
||||
|
|
|
@ -11,7 +11,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
* SLA - Select element (from - data )
|
||||
* Input element Select SLD - Date format
|
||||
* SLZ - Time Zone
|
||||
* SLZN - Time Zone List
|
||||
* SLTZN - Time Zone List
|
||||
* SLT - TFTP Lang
|
||||
* SLM - Music on hold
|
||||
* SLK - System KeySet
|
||||
|
@ -672,7 +672,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
</select>
|
||||
<help>Date Format: The date format for the on-screen display. Can be one of the following: (D-M-YA, M.D.Y, Y/M/D) where 'D' is Day, 'M' is Month, 'Y' is Year, 'A' is 24-hour, 'a' is 12-hour, and the separators can be '.','-','/'</help>
|
||||
</item>
|
||||
<item type="SLZN" id="2" seq="95">
|
||||
<item type="SLTZN" id="2" seq="95">
|
||||
<label>Time Zone</label>
|
||||
<name>ntp_timezone</name>
|
||||
<class>sccp-custom</class>
|
||||
|
|
|
@ -58,13 +58,13 @@ ri ^(P00405000700.sbn)$ firmware/7910/\1
|
|||
ri ^(CP7912080004SCCP080108A.sbin)$ firmware/7912/\1
|
||||
|
||||
# 7915 firmware (ancient)
|
||||
ri ^(B015-1-0-4.SBN)$ firmware/7915/\1
|
||||
ri ^(B015-1-0-)(+\.SBN)$ firmware/7915/\1
|
||||
|
||||
# 7916 firmware (ancient)
|
||||
ri ^(B016-1-0-4.SBN)$ firmware/7916/\1
|
||||
ri ^(B016-1-0-)(+\.SBN)$ firmware/7916/\1
|
||||
|
||||
# 7920 firmware (ancient)
|
||||
ri ^(cmterm_7920.4.0-03-02.bin)$ firmware/7920/\1
|
||||
ri ^(cmterm_7920)(+\.bin)$ firmware/7920/\1
|
||||
|
||||
# 7921_7925 firmware (ancient)
|
||||
ri ^(APPS-1.4.3.4.SBN)$ firmware/7921/\1
|
||||
|
|
|
@ -266,6 +266,7 @@ function Get_DB_config($sccp_compatible) {
|
|||
'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')"),
|
||||
'monitor' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"),
|
||||
'audio_tos' => array('def_modify' => "0xB8"),
|
||||
'audio_cos' => array('def_modify' => "6"),
|
||||
'video_tos' => array('def_modify' => "0x88"),
|
||||
|
@ -339,6 +340,7 @@ function Get_DB_config($sccp_compatible) {
|
|||
'directed_pickup' => array('drop' => "yes"),
|
||||
'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')"),
|
||||
'monitor' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"),
|
||||
'_description' => array('rename' => "description"),
|
||||
'_loginname' => array('drop' => "yes"),
|
||||
'_profileid' => array('drop' => "yes"),
|
||||
|
@ -661,8 +663,8 @@ function InstallDB_fillsccpdevmodel() {
|
|||
outn("<li>" . _("Fill sccpdevmodel") . "</li>");
|
||||
$sql = "REPLACE INTO `sccpdevmodel` (`model`, `vendor`, `dns`, `buttons`, `loadimage`, `loadinformationid`, `enabled`, `nametemplate`) VALUES ('12 SP', 'CISCO', 1, 1, '', 'loadInformation3', 0, NULL)," .
|
||||
"('12 SP+', 'CISCO', 1, 1, '', 'loadInformation2', 0, NULL), ('30 SP+', 'CISCO', 1, 1, '', 'loadInformation1', 0, NULL), ('30 VIP', 'CISCO', 1, 1, '', 'loadInformation5', 0, NULL), ('3911', 'CISCO', 1, 1, '', 'loadInformation446', 0, NULL), ('3951', 'CISCO', 1, 1, '', 'loadInformation412', 0, ''), ('6901', 'CISCO', 1, 0, 'SCCP6901.9-2-1-a', 'loadInformation547', 0, NULL), ('6911', 'CISCO', 1, 0, 'SCCP6911.9-2-1-a', 'loadInformation548', 0, NULL), ('6921', 'CISCO', 1, 0, 'SCCP69xx.9-2-1-0', 'loadInformation496', 0, NULL), ('6941', 'CISCO', 1, 1, 'SCCP69xx.9-2-1-0', 'loadInformation495', 0, NULL), ('6945', 'CISCO', 1, 0, 'SCCP6945.9-2-1-0', 'loadInformation564', 0, NULL), ('6961', 'CISCO', 1, 0, 'SCCP69xx.9-2-1-0', 'loadInformation497', 0, NULL), ('7902', 'CISCO', 1, 1, 'CP7902080002SCCP060817A', 'loadInformation30008', 0, NULL), " .
|
||||
"('7905', 'CISCO', 1, 1, 'CP7905080003SCCP070409A', 'loadInformation20000', 0, NULL), ('7906', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation369', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7910', 'CISCO', 1, 1, 'P00405000700', 'loadInformation6', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7911', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7912', 'CISCO', 1, 1, 'CP7912080004SCCP080108A', 'loadInformation30007', 0, NULL), ('7914', 'CISCO', 0, 14, 'S00105000400', 'loadInformation124', 1, NULL),('7914,7914', 'CISCO', 0, 28, 'S00105000400', 'loadInformation124', 1, NULL), ('7915', 'CISCO', 0, 24, 'B015-1-0-4-2', 'loadInformation227', 1, NULL), ('7915,7915', 'CISCO', 0, 48, 'B015-1-0-4', 'loadInformation228', 1, NULL), ('7916', 'CISCO', 0, 24, 'B015-1-0-4', 'loadInformation229', 1, NULL), " .
|
||||
"('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'), " .
|
||||
"('7905', 'CISCO', 1, 1, 'CP7905080003SCCP070409A', 'loadInformation20000', 0, NULL), ('7906', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation369', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7910', 'CISCO', 1, 1, 'P00405000700', 'loadInformation6', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7911', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_template'), ('7912', 'CISCO', 1, 1, 'CP7912080004SCCP080108A', 'loadInformation30007', 0, NULL), ('7914', 'CISCO', 0, 14, 'S00105000400', 'loadInformation124', 1, NULL),('7914;7914', 'CISCO', 0, 28, 'S00105000400', 'loadInformation124', 1, NULL), ('7915', 'CISCO', 0, 24, 'B015-1-0-4-2', 'loadInformation227', 1, NULL), ('7915;7915', 'CISCO', 0, 48, 'B015-1-0-4-2', 'loadInformation228', 1, NULL), ('7916', 'CISCO', 0, 24, 'B016-1-0-4-2', 'loadInformation229', 1, NULL), " .
|
||||
"('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, ''), ".
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* SLA - Select element (from - data )
|
||||
* Input element Select SLD - Date format
|
||||
* SLZ - Time Zone
|
||||
* SLZN - Time Zone List
|
||||
* SLTZN - Time Zone List
|
||||
* SLT - TFTP Lang
|
||||
* SLM - Music on hold
|
||||
* SLK - System KeySet
|
||||
|
@ -35,6 +35,7 @@ $time_zone = array('-12' => 'GTM -12', '-11' => 'GTM -11', '-10' => 'GTM -10', '
|
|||
'04' => 'GTM +4', '05' => 'GTM +5', '06' => 'GTM +6', '07' => 'GTM +7',
|
||||
'08' => 'GTM +8', '09' => 'GTM +9', '10' => 'GTM +10', '11'=> 'GTM +11', '12' => 'GTM +12');
|
||||
|
||||
|
||||
$time_zone_name = array();
|
||||
$extension_list = array();
|
||||
$sofkey_list = array();
|
||||
|
@ -42,7 +43,6 @@ $model_list = array();
|
|||
$device_list = array();
|
||||
$dialplan_list = array();
|
||||
|
||||
//$time_zone_name = \FreePBX::Sccp_manager()-> extconfigs-> getextConfig('cisco_timezone');
|
||||
//$time_zone = \FreePBX::Sccp_manager()-> extconfigs-> getextConfig('cisco_time');
|
||||
//$system_time_zone = \FreePBX::Sccp_manager()->getSysnemTimeZone();
|
||||
//$sofkey_list = \FreePBX::Sccp_manager()-> srvinterface -> sccp_list_keysets();
|
||||
|
@ -486,7 +486,7 @@ foreach ($items as $child) {
|
|||
* Input element Select SLS - System Language
|
||||
*/
|
||||
|
||||
if ($child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SLA' || $child['type'] == 'SLZ' || $child['type'] == 'SLZN') {
|
||||
if ($child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SLA' || $child['type'] == 'SLZ') {
|
||||
// $value = $child -> select;
|
||||
$res_n = (string)$child ->name;
|
||||
$res_id = $npref.$res_n;
|
||||
|
@ -504,12 +504,6 @@ foreach ($items as $child) {
|
|||
if ($child['type'] == 'SLT') {
|
||||
$select_opt= $tftp_lang;
|
||||
}
|
||||
if ($child['type'] == 'SLZN') {
|
||||
if (empty($time_zone_name)) {
|
||||
$time_zone_name = \FreePBX::Sccp_manager()-> extconfigs-> getextConfig('cisco_timezone');
|
||||
}
|
||||
$select_opt= $time_zone_name;
|
||||
}
|
||||
if ($child['type'] == 'SLZ') {
|
||||
$select_opt= $time_zone;
|
||||
// $child->value = ($system_time_zone[offset]/60);
|
||||
|
@ -929,6 +923,82 @@ foreach ($items as $child) {
|
|||
<?php
|
||||
echo '<!-- END '.$child->label.' -->';
|
||||
}
|
||||
/*
|
||||
* Input element Select SLTZN - System Time Zone
|
||||
*/
|
||||
|
||||
if ($child['type'] == 'SLTZN') {
|
||||
// $value = $child -> select;
|
||||
$res_n = (string)$child ->name;
|
||||
$res_id = $npref.$res_n;
|
||||
$child->value ='';
|
||||
|
||||
if (!empty($metainfo[$res_n])){
|
||||
if ($child->meta_help == '1' || $child->help == 'Help!') {
|
||||
$child->help = $metainfo[$res_n]['Description'];
|
||||
}
|
||||
}
|
||||
|
||||
$time_regions = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Russian', 'Indian', 'Pacific');
|
||||
$time_zone_global = DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC );
|
||||
$time_zone_ru = array('Russian/Kaliningrad', 'Russian/Moscow', 'Russian/St.Peterburg', 'Russian/Samara', 'Russian/Novosibirsk', 'Russian/Ekaterinburg', 'Russian/Irkutsk', 'Russian/Yakutsk', 'Russian/Khabarovsk', 'Russian/Vladivostok', 'Russian/Sakhalin', 'Russian/Magadan', 'Russian/Kamchatka');
|
||||
$time_zone_list = array_merge($time_zone_global,$time_zone_ru);
|
||||
$optgroup = '';
|
||||
sort($time_zone_list);
|
||||
|
||||
if (empty($child->class)) {
|
||||
$child->class = 'form-control';
|
||||
}
|
||||
|
||||
if (!empty($fvalues[$res_n])) {
|
||||
if (!empty($fvalues[$res_n]['data'])) {
|
||||
$child->value = $fvalues[$res_n]['data'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($child->value)){
|
||||
$child->value = \date_default_timezone_get();
|
||||
// if (!empty($child->default)){
|
||||
// $child->value = $child->default;
|
||||
// }
|
||||
}
|
||||
|
||||
echo '<!-- Begin '.$child->label.' -->';
|
||||
?>
|
||||
<div class="element-container">
|
||||
<div class="row"> <div class="form-group">
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label);?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i>
|
||||
</div>
|
||||
<div class="col-md-9"> <!-- <div class = "lnet form-group form-inline" data-nextid=1> --> <?php
|
||||
echo '<select name="'.$res_id.'" class="'. $child->class . '" id="' . $res_id . '">';
|
||||
foreach ($time_zone_list as $opt_key) {
|
||||
$z = explode('/', $opt_key, 2);
|
||||
if (count($z) != 2 || !in_array($z[0], $time_regions)) continue;
|
||||
if ($optgroup != $z[0]) {
|
||||
if ($optgroup !== '') echo '</optgroup>';
|
||||
$optgroup = $z[0];
|
||||
echo '<optgroup label="' . htmlentities($z[0]) . '">';
|
||||
}
|
||||
echo '<option value="' . htmlentities($opt_key) . '" label="' . htmlentities(str_replace('_', ' ', $z[1])) . '"' . ($opt_key == $child->value ? ' selected="selected" >' : '>'). htmlentities(str_replace('_', ' ', $opt_key)) . '</option>';
|
||||
}
|
||||
if ($optgroup !== '') echo '</optgroup>';
|
||||
|
||||
?> </select>
|
||||
<!-- </div> --> </div>
|
||||
</div></div>
|
||||
<div class="row"><div class="col-md-12">
|
||||
<span id="<?php echo $res_id;?>-help" class="help-block fpbx-help-block"><?php echo _($child->help);?></span>
|
||||
</div></div>
|
||||
</div>
|
||||
<!--END System Language-->
|
||||
<?php
|
||||
echo '<!-- END '.$child->label.' -->';
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -38,9 +38,9 @@
|
|||
<th data-sortable="true" data-field="mac"><?php echo _('Device SEP ID') ?></th>
|
||||
<th data-sortable="true" data-field="description"><?php echo _('Device Descriptions') ?></th>
|
||||
<th data-sortable="true" data-formatter="DispayTypeFormatter" data-field="type"><?php echo _('Device type') ?></th>
|
||||
<th data-sortable="false" data-field="button" data-formatter="LineFormatter"><?php echo _('Line') ?></th>
|
||||
<th data-sortable="false" data-field="status"><?php echo _('Status') ?></th>
|
||||
<th data-sortable="false" data-field="address"><?php echo _('Address') ?></th>
|
||||
<th data-sortable="true" data-field="button" data-formatter="LineFormatter"><?php echo _('Line') ?></th>
|
||||
<th data-sortable="true" data-field="status"><?php echo _('Status') ?></th>
|
||||
<th data-sortable="true" data-field="address"><?php echo _('Address') ?></th>
|
||||
<th data-field="actions" data-formatter="DispayDeviceActionsKeyFormatter"><?php echo _('Actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
<th data-sortable="true" data-field="mac"><?php echo _('Device SEP ID') ?></th>
|
||||
<th data-sortable="true" data-field="description"><?php echo _('Device Descriptions') ?></th>
|
||||
<th data-sortable="true" data-formatter="DispayTypeFormatter" data-field="type"><?php echo _('Device type') ?></th>
|
||||
<th data-sortable="false" data-field="button" data-formatter="LineFormatter"><?php echo _('Line') ?></th>
|
||||
<th data-sortable="false" data-field="status"><?php echo _('Status') ?></th>
|
||||
<th data-sortable="false" data-field="address"><?php echo _('Address') ?></th>
|
||||
<th data-sortable="true" data-field="button" data-formatter="LineFormatter"><?php echo _('Line') ?></th>
|
||||
<th data-sortable="true" data-field="status"><?php echo _('Status') ?></th>
|
||||
<th data-sortable="true" data-field="address"><?php echo _('Address') ?></th>
|
||||
<th data-field="actions" data-formatter="DispayDeviceActionsKeyFormatterS"><?php echo _('Actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -5,149 +5,444 @@
|
|||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
$test_ami = 0;
|
||||
$test_any = 0;
|
||||
|
||||
$driver = $this->FreePBX->Core->getAllDriversInfo();
|
||||
$core = $this->srvinterface->getSCCPVersion();
|
||||
$ast_realtime = $this->srvinterface->sccp_realtime_status();
|
||||
|
||||
$ast_realm = (empty($ast_realtime['sccp']) ? '':'sccp');
|
||||
$ast_realm = (empty($ast_realtime['sccp']) ? '' : 'sccp');
|
||||
|
||||
foreach ($ast_realtime as $key => $value) {
|
||||
if (empty($ast_realm)) {
|
||||
if ($value['status'] == 'OK') {
|
||||
$ast_realm = $key;
|
||||
}
|
||||
if ($value['status'] == 'OK') {
|
||||
$ast_realm = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$conf_realtime = $this->extconfigs->validate_RealTime($ast_realm);
|
||||
$db_Schema = $this->dbinterface->validate();
|
||||
$mysql_info = $this->dbinterface->get_db_sysvalues();
|
||||
$compatable = $this->srvinterface->get_compatible_sccp();
|
||||
$info = array();
|
||||
|
||||
$conf_realtime = $this->extconfigs->validate_RealTime($ast_realm);
|
||||
$db_Schema = $this->dbinterface->validate();
|
||||
$mysql_info = $this->dbinterface->get_db_sysvalues();
|
||||
$compatable = $this->srvinterface->get_compatible_sccp();
|
||||
$info = array();
|
||||
|
||||
$info['srvinterface'] = $this->srvinterface->info();
|
||||
$info['extconfigs'] = $this->extconfigs->info();
|
||||
$info['dbinterface'] = $this->dbinterface->info();
|
||||
$info['aminterface'] = $this->aminterface->info();
|
||||
$info['XML'] = $this->xmlinterface->info();
|
||||
$info['sccp_class'] = $driver['sccp'];
|
||||
$info['Core_sccp'] = array('Version' => $core['Version'], 'about'=> 'Sccp ver.'. $core['Version'].' r'.$core['vCode']. ' Revision :'. $core['RevisionNum']. ' Hash :'. $core['RevisionHash']);
|
||||
$info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about'=> 'Asterisk.');
|
||||
$info['extconfigs'] = $this->extconfigs->info();
|
||||
$info['dbinterface'] = $this->dbinterface->info();
|
||||
$info['aminterface'] = $this->aminterface->info();
|
||||
$info['XML'] = $this->xmlinterface->info();
|
||||
$info['sccp_class'] = $driver['sccp'];
|
||||
$info['Core_sccp'] = array('Version' => $core['Version'], 'about' => 'Sccp ver.' . $core['Version'] . ' r' . $core['vCode'] . ' Revision :' . $core['RevisionNum'] . ' Hash :' . $core['RevisionHash']);
|
||||
$info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.');
|
||||
|
||||
|
||||
if (!empty($this->sccpvalues['SccpDBmodel'])) {
|
||||
$info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about'=> 'SCCP DB Configure');
|
||||
$info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about' => 'SCCP DB Configure');
|
||||
}
|
||||
if (!empty($this->sccpvalues['tftp_rewrite'])) {
|
||||
if ($this->sccpvalues['tftp_rewrite']['data'] == 'pro') {
|
||||
$info['Provision_SCCP'] = array('Version' => 'base', 'about'=> 'Provision Sccp enabled');
|
||||
$info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled');
|
||||
} else {
|
||||
$info['TFTP_Rewrite'] = array('Version' => 'base', 'about'=> 'Rewrite Supported');
|
||||
$info['TFTP_Rewrite'] = array('Version' => 'base', 'about' => 'Rewrite Supported');
|
||||
}
|
||||
}
|
||||
$info['Сompatible'] = array('Version' => $compatable, 'about'=> 'Ok');
|
||||
$info['Сompatible'] = array('Version' => $compatable, 'about' => 'Ok');
|
||||
if (!empty($this->sccpvalues['SccpDBmodel'])) {
|
||||
if ($compatable > $this->sccpvalues['SccpDBmodel']['data']){
|
||||
if ($compatable > $this->sccpvalues['SccpDBmodel']['data']) {
|
||||
$info['Сompatible']['about'] = '<div class="alert signature alert-danger"> Reinstall SCCP manager required</div>';
|
||||
}
|
||||
}
|
||||
if ($db_Schema == 0) {
|
||||
$info['DB_Schema'] = array('Version' => 'Error', 'about'=> '<div class="alert signature alert-danger"> ERROR DB Version </div>');
|
||||
$info['DB_Schema'] = array('Version' => 'Error', 'about' => '<div class="alert signature alert-danger"> ERROR DB Version </div>');
|
||||
} else {
|
||||
$info['DB_Schema'] = array('Version' => $db_Schema, 'about'=> (($compatable == $db_Schema ) ? 'Ok' : 'Incompatable Version'));
|
||||
$info['DB_Schema'] = array('Version' => $db_Schema, 'about' => (($compatable == $db_Schema ) ? 'Ok' : 'Incompatable Version'));
|
||||
}
|
||||
|
||||
if (empty($ast_realtime)) {
|
||||
$info['RealTime'] = array('Version' => 'Error', 'about'=> '<div class="alert signature alert-danger"> No found Real Time connections</div>');
|
||||
$info['RealTime'] = array('Version' => 'Error', 'about' => '<div class="alert signature alert-danger"> No found Real Time connections</div>');
|
||||
} else {
|
||||
$rt_info = '';
|
||||
$rt_sccp = 'Failed';
|
||||
foreach ($ast_realtime as $key => $value) {
|
||||
if ($key == $ast_realm) {
|
||||
if ($value['status'] == 'OK') {
|
||||
$rt_sccp = 'TEST OK';
|
||||
$rt_sccp = 'TEST OK';
|
||||
$rt_info .= 'SCCP Connections found';
|
||||
} else {
|
||||
$rt_sccp = 'SCCP ERROR';
|
||||
$rt_info .= '<div class="alert signature alert-danger"> Error : '. $value['message']. '</div>';
|
||||
$rt_info .= '<div class="alert signature alert-danger"> Error : ' . $value['message'] . '</div>';
|
||||
}
|
||||
} else if ($value['status'] == 'ERROR') {
|
||||
$rt_info .= '<div> Found error in realtime sectoin ['.$key.'] : '. $value['message']. '</div>';
|
||||
$rt_info .= '<div> Found error in realtime sectoin [' . $key . '] : ' . $value['message'] . '</div>';
|
||||
}
|
||||
}
|
||||
$info['RealTime'] = array('Version' => $rt_sccp, 'about'=> $rt_info);
|
||||
$info['RealTime'] = array('Version' => $rt_sccp, 'about' => $rt_info);
|
||||
}
|
||||
|
||||
if (empty($conf_realtime)) {
|
||||
$info['ConfigsRealTime'] = array('Version' => 'Error', 'about'=> '<div class="alert signature alert-danger"> No found Real Time Configs</div>');
|
||||
$info['ConfigsRealTime'] = array('Version' => 'Error', 'about' => '<div class="alert signature alert-danger"> No found Real Time Configs</div>');
|
||||
} else {
|
||||
$rt_info = '';
|
||||
foreach ($conf_realtime as $key => $value) {
|
||||
if (($value != 'OK') && ($key != 'extconfigfile')) {
|
||||
$rt_info .= '<div> Found error in section '.$key.' :'. $value. '</div>';
|
||||
$rt_info .= '<div> Found error in section ' . $key . ' :' . $value . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($rt_info)) {
|
||||
$info['ConfigsRealTime'] = array('Version' => 'Error', 'about'=> $rt_info);
|
||||
$info['ConfigsRealTime'] = array('Version' => 'Error', 'about' => $rt_info);
|
||||
}
|
||||
}
|
||||
// $mysql_info
|
||||
if ($mysql_info['Value'] <= '2000') {
|
||||
$this->info_warning['MySql'] = Array('Increase Mysql Group Concat Max. Length','Step 1: Go to mysql path <br> nano /etc/my.cnf',
|
||||
'Step 2: And add the following line below [mysqld] as shown below <br> [mysqld] <br>group_concat_max_len = 4096 or more',
|
||||
'Step 3: Save and restart <br> systemctl restart mariadb.service<br> Or <br> service mysqld restart');
|
||||
$this->info_warning['MySql'] = Array('Increase Mysql Group Concat Max. Length', 'Step 1: Go to mysql path <br> nano /etc/my.cnf',
|
||||
'Step 2: And add the following line below [mysqld] as shown below <br> [mysqld] <br>group_concat_max_len = 4096 or more',
|
||||
'Step 3: Save and restart <br> systemctl restart mariadb.service<br> Or <br> service mysqld restart');
|
||||
}
|
||||
global $amp_conf;
|
||||
|
||||
|
||||
// Check Time Zone comatable
|
||||
$conf_tz = $this->sccpvalues['ntp_timezone']['data'];
|
||||
$cisco_tz = $this->extconfigs->getextConfig('sccp_timezone', $conf_tz);
|
||||
if ($cisco_tz['offset'] == 0) {
|
||||
if (!empty($conf_tz)) {
|
||||
$tmp_dt = new DateTime(null, new DateTimeZone($conf_tz));
|
||||
$tmp_ofset = $tmp_dt->getOffset();
|
||||
if (($cisco_tz['offset'] != ($tmp_ofset / 60) )) {
|
||||
$this->info_warning['NTP'] = Array('The selected NTP time zone is not supported by cisco devices.', 'We will use the Greenwich Time zone');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global $amp_conf;
|
||||
|
||||
|
||||
if ($test_any == 1) {
|
||||
# Output option list, HTML.
|
||||
|
||||
$timezone_identifiers = DateTimeZone::listIdentifiers();
|
||||
$timezone_abbreviations = DateTimeZone::listAbbreviations();
|
||||
$a = DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC );
|
||||
|
||||
|
||||
$Ts_set = $a[200];
|
||||
|
||||
|
||||
// ************************************************************************************
|
||||
/*
|
||||
//$tmp_data_list = $this->getSccp_model_information('enabled', $validate = TRUE);
|
||||
//$tmp_data_list = $amp_conf;
|
||||
//$tmp_data_list=FreePBX::create()->Sipsettings->getConfig('bindport');
|
||||
// $tmp_data_list=FreePBX::Sipsettings()->getChanSipSettings();
|
||||
$tmp_data_list=$this->sipconfigs->getSipConfig();
|
||||
//$tmp_data_list=FreePBX::Sipsettings()->getBinds();
|
||||
|
||||
// $tmp_data_list = \FreePBX::Sipsettings()->getSipPortOwner();
|
||||
// $tmp_data_list=$this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||
// $tmp_data_list=$this->dbinterface->get_db_SccpTableData('SccpDevice', array('type'=>'cisco-sip'));
|
||||
// $tmp_data_list= FreePBX::Sipsettings()->getChanSipDefaults();
|
||||
//$tmp_data_list = $this->find_all_files($dir, $file_ext, 'fileonly');
|
||||
print_r("<br> Help Info:<br><pre>");
|
||||
print_r("<br>");
|
||||
print_r($tmp_data_list);
|
||||
//$tmp_data_list = FreePBX::Sipsettings()->getChanSipDefaults();
|
||||
// $tmp_data_list = \FreePBX::Sipsettings()->getSipPortOwner();
|
||||
//print_r($buton_list);
|
||||
print_r("<br>");
|
||||
print_r($this->sccp_conf_init);
|
||||
//$tmp_data_list=$this->sipconfigs->get_db_sip_TableData('Device');
|
||||
print_r("<br>");
|
||||
print_r("<br>");
|
||||
//print_r(array_column($timezone_abbreviations, 'timezone_id'));
|
||||
print_r($Ts_set);
|
||||
$tz_tmp = array();
|
||||
|
||||
foreach ($timezone_abbreviations as $subArray) {
|
||||
$dddd = array_search($Ts_set ,array_column($subArray, 'timezone_id'));
|
||||
if (!empty($dddd)) {
|
||||
$tz_tmp[] = $subArray[$dddd];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($tz_tmp)) {
|
||||
print_r('erroe');
|
||||
}
|
||||
if (count($tz_tmp)==1) {
|
||||
$time_set = $tz_tmp[0];
|
||||
} else {
|
||||
$tmp_dt = new DateTime(null, new DateTimeZone($Ts_set));
|
||||
$tmp_ofset = $tmp_dt->getOffset();
|
||||
foreach ($tz_tmp as $subArray) {
|
||||
if ($subArray['offset'] == $tmp_ofset) {
|
||||
$time_set = $subArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_r("<br>");
|
||||
//print_r($time_set);
|
||||
print_r($this->sccpvalues['ntp_timezone']);
|
||||
//print_r($tz_tmp);
|
||||
print_r("<br>");
|
||||
print_r("<br>");
|
||||
|
||||
print_r("<br>");
|
||||
//print_r($timezone_abbreviations);
|
||||
//print_r($timezone_identifiers);
|
||||
//print_r($timezone);
|
||||
//print_r($transitions);
|
||||
|
||||
|
||||
print_r("<br>");
|
||||
print_r("</pre>");
|
||||
// print_r("DIRECT START");
|
||||
// print_r($this->sccpvalues['ccm_address']);
|
||||
//print_r($this->get_php_classes('\\FreePBX\\modules\\'));
|
||||
//print_r($this->dbinterface->get_db_SccpTableData('SccpExtension'));
|
||||
// print_r($this->srvinterface->getеtestChanSCCP_GlablsInfo());
|
||||
//print_r($this->get_php_classes('\\FreePBX\\modules'));
|
||||
// print_r(get_declared_classes());
|
||||
// $a = $this->aminterface->_config;
|
||||
// print_r($a);
|
||||
// print_r($this->aminterface->info());
|
||||
//print_r(get_declared_classes());
|
||||
// print_r($this->aminterface->open());
|
||||
// $time_start = microtime_float();
|
||||
// $this->aminterface->open();
|
||||
// $time_connect = microtime_float();
|
||||
// print_r($this->aminterface->send(new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowSoftkeySetsAction()));
|
||||
// $a = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowSoftkeySetsAction();
|
||||
// $a = new \FreePBX\modules\Sccp_manager\aminterface\ExtensionStateListAction();
|
||||
// $a = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDeviceAction('SEP00070E36555C');
|
||||
// $a = new \FreePBX\modules\Sccp_manager\aminterface\SCCPDeviceRestartAction('SEP00070E36555C');
|
||||
// $a = new \FreePBX\modules\Sccp_manager\aminterface\ReloadAction('chan_sccp');
|
||||
//$a = new \FreePBX\modules\Sccp_manager\aminterface\CommandAction('core show hints');
|
||||
/*
|
||||
$time_start = microtime_float();
|
||||
print_r($this->srvinterface->t_get_ami_data());
|
||||
$time_get_dl = microtime_float()-$time_start;
|
||||
print_r('<br> Delta :'); print_r($time_get_dl);
|
||||
$time_start = microtime_float();
|
||||
$tmp_data = $this->aminterface->sccp_get_active_device(); print_r($tmp_data);
|
||||
$time_get_dl = microtime_float()-$time_start;
|
||||
print_r('<br> Delta :'); print_r($time_get_dl);
|
||||
|
||||
die();
|
||||
|
||||
/*
|
||||
*/
|
||||
// $a = new \FreePBX\modules\Sccp_manager\aminterface\CommandAction('realtime mysql status');
|
||||
// $a = new \FreePBX\modules\Sccp_manager\aminterface\SCCPConfigMetaDataAction();
|
||||
// $response = $this->aminterface->send($a);
|
||||
//
|
||||
// $response = $this->aminterface->getRealTimeStatus();
|
||||
// $time_get_a = microtime_float();
|
||||
// print_r($response);
|
||||
// $tmp_data = $this->aminterface->core_sccp_reload();
|
||||
// print_r($tmp_data);
|
||||
// print_r($response -> getResult());
|
||||
// $events = $response->getEvents();
|
||||
// $events = $response->Events2Array();
|
||||
//
|
||||
// print_r($events);
|
||||
// print_r('--- RESULT A -----------------');
|
||||
// $b = $this->oldinterface->sccp_realtime_status();
|
||||
// print_r($b);
|
||||
// $b = $this->srvinterface->sccp_realtime_status();
|
||||
// print_r($response->getMessage());
|
||||
// print_r($a);
|
||||
// $events = $response ->getTableNames();
|
||||
// $events = $response->getEvents();
|
||||
// print_r($events);
|
||||
// $b = $response->Table2Array($events[0]);
|
||||
// $b = $response->getResult();
|
||||
// $b = $response->getResult();
|
||||
// print_r($b);
|
||||
// $time_get_ra = microtime_float();
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
// $tmp_data = $this->aminterface->sccp_get_active_device();
|
||||
// print_r($tmp_data);
|
||||
}
|
||||
|
||||
/* Test Ok
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($test_ami == 1) {
|
||||
$time_ami = 0;
|
||||
$time_old = 0;
|
||||
$test_info = array();
|
||||
$tmp_test_name = 'get_version';
|
||||
print_r('<br>-------------- OLD: ' . $tmp_test_name . '---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->oldinterface->get_compatible_sccp();
|
||||
print_r($tmp_data);
|
||||
$tmp_data = $this->oldinterface->getSCCPVersion();
|
||||
print_r($tmp_data);
|
||||
$tmp_data = $this->oldinterface->getChanSCCPVersion();
|
||||
print_r($tmp_data);
|
||||
$tmp_data = $this->oldinterface->sccp_realtime_status();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
|
||||
$test_info[$tmp_test_name]['old'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
$time_get_start = $time_get_dl;
|
||||
|
||||
print_r('<br>-------------- AMI: ' . $tmp_test_name . ' ---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->srvinterface->get_compatible_sccp();
|
||||
print_r($tmp_data);
|
||||
print_r('<br>Not Use<br>');
|
||||
$tmp_data = $this->srvinterface->getChanSCCPVersion();
|
||||
print_r($tmp_data);
|
||||
$tmp_data = $this->srvinterface->sccp_realtime_status();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['ami'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
|
||||
$tmp_test_name = 'getdevice_info';
|
||||
print_r('<br>-------------- OLD: ' . $tmp_test_name . '---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->oldinterface->sccp_getdevice_info('SEP00070E36555C');
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['old'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
print_r('<br>-------------- AMI: ' . $tmp_test_name . ' ---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->srvinterface->sccp_getdevice_info('SEP00070E36555C');
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['ami'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
$tmp_test_name = 'get_active_device';
|
||||
print_r('<br>-------------- OLD: ' . $tmp_test_name . '---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->oldinterface->sccp_get_active_device();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['old'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
print_r('<br>-------------- AMI: ' . $tmp_test_name . ' ---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->aminterface->sccp_get_active_device();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['ami'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
$tmp_test_name = 'sccp_list_keysets';
|
||||
print_r('<br>-------------- OLD: ' . $tmp_test_name . '---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->oldinterface->sccp_list_keysets();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['old'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
print_r('<br>-------------- AMI: ' . $tmp_test_name . ' ---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->aminterface->sccp_list_keysets();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['ami'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
$tmp_test_name = 'list_all_hints';
|
||||
print_r('<br>-------------- OLD: ' . $tmp_test_name . '---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->oldinterface->sccp_list_all_hints();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['old'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
print_r('<br>-------------- AMI: ' . $tmp_test_name . ' ---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->aminterface->core_list_all_hints();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['ami'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
$tmp_test_name = 'sccp_list_hints';
|
||||
print_r('<br>-------------- OLD: ' . $tmp_test_name . '---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->oldinterface->sccp_list_hints();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['old'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
print_r('<br>-------------- AMI: ' . $tmp_test_name . ' ---------------------------<br>');
|
||||
$time_get_start = microtime_float();
|
||||
$tmp_data = $this->aminterface->core_list_hints();
|
||||
print_r($tmp_data);
|
||||
$time_get_dl = microtime_float();
|
||||
$test_info[$tmp_test_name]['ami'] = $time_get_dl - $time_get_start;
|
||||
print_r('<br> Delta :');
|
||||
print_r($time_get_dl - $time_get_start);
|
||||
|
||||
print_r('<br>--- Stat -----------------<br>');
|
||||
|
||||
print_r('<div class="fpbx-container container-fluid"><div class="row"><div class="container"> <div class="table-responsive"><table class="table"><thead><tr><th>Function</th><th>Old Time</th><th> Ami Time</th></tr></thead><tbody>');
|
||||
$time_ami = 0;
|
||||
$time_old = 0;
|
||||
foreach ($test_info as $key => $value) {
|
||||
print_r('<tr><td>' . $key . '</td><td>' . $value['old'] . '</td><td>' . $value['ami'] . '</td></tr>');
|
||||
$time_ami += $value['ami'];
|
||||
$time_old += $value['old'];
|
||||
}
|
||||
print_r('</tbody></table></div></div></div></div>');
|
||||
print_r('<br>Ami Responce :');
|
||||
print_r($time_ami);
|
||||
print_r('<br>PBX Responce :');
|
||||
print_r($time_old);
|
||||
print_r('<br>--- Stat -----------------<br>');
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
||||
// $events = $response->getEvents();
|
||||
// print_r($events);
|
||||
//$b = $response->Table2Array($events[0]);
|
||||
//$b = $response->getResult();
|
||||
// print_r('--- RESULT 2 -----------------<br>');
|
||||
//print_r($events);
|
||||
// print_r($b);
|
||||
// $ser = serialize($response);
|
||||
// print_r($ser);
|
||||
// $result2 = unserialize($ser);
|
||||
// print_r($result2);
|
||||
/* $events = $result2->getEvents();
|
||||
$this->assertEquals($result2->getMessage(), 'Channels will follow');
|
||||
$this->assertEquals($events[0]->getName(), 'CoreShowChannelsComplete');
|
||||
$this->assertEquals($events[0]->getListItems(), 0);
|
||||
*/
|
||||
// print_r('--- RESULT 3 -----------------');
|
||||
// print_r($a);
|
||||
// print_r('--- С RESULT -----------------');
|
||||
// print_r($this->aminterface::SCCPShowDevicesAction());
|
||||
//
|
||||
// print_r($this->aminterface->close());
|
||||
//
|
||||
//
|
||||
//print_r($this->dbinterface->get_db_SccpTableData('SccpExtension'));
|
||||
// print_r($this->srvinterface->getеtestChanSCC());
|
||||
// $test_data = $this->srvinterface-> astman_GetRaw('ExtensionStateList');
|
||||
// print_r($test_data);
|
||||
// print_r($this->srvinterface-> core_list_all_exten());
|
||||
// print_r($this->get_hint_info());
|
||||
// print_r($this->aminterface->open());
|
||||
// print_r($this->aminterface-> core_list_all_exten('exten'));
|
||||
// print_r($this->aminterface->Sok_param['total']);
|
||||
// print_r($this->srvinterface->t_get_meta_data());
|
||||
// print_r($this->sccp_metainfo);
|
||||
print("</pre>");
|
||||
print(" ");
|
||||
/* */
|
||||
// ************************************************************************************
|
||||
|
||||
// $lang_arr = $this->extconfigs->getextConfig('sccp_lang','sk_SK');
|
||||
// print_r('<br>');
|
||||
// print_r(timezone_identifiers_list());
|
||||
// print_r('<br>');
|
||||
|
||||
//print_r($this->dbinterface->info());
|
||||
|
||||
if (!empty($this->info_warning)) {
|
||||
if (!empty($this->info_warning)) {
|
||||
?>
|
||||
<div class="fpbx-container container-fluid">
|
||||
<div class="row">
|
||||
|
@ -156,14 +451,15 @@ print_r("<br> Help Info:<br><pre>");
|
|||
<div class="table-responsive">
|
||||
<br> There are Warning in the SCCP Module:<br><pre>
|
||||
<?php
|
||||
foreach ($this->info_warning as $key => $value) {
|
||||
echo '<h3>'.$key.'</h3>';
|
||||
if (is_array($value)) {
|
||||
echo '<li>'._(implode('</li><li>', $value)).'</li>';
|
||||
} else {
|
||||
echo '<li>'. _($value).'</li>';
|
||||
}
|
||||
foreach ($this->info_warning as $key => $value) {
|
||||
echo '<h3>' . $key . '</h3>';
|
||||
if (is_array($value)) {
|
||||
echo '<li>' . _(implode('</li><li>', $value)) . '</li>';
|
||||
} else {
|
||||
echo '<li>' . _($value) . '</li>';
|
||||
}
|
||||
echo '<br>';
|
||||
}
|
||||
?>
|
||||
</pre>
|
||||
<br><h4 style="border:2px solid Tomato;color:Green;" > Check these problems before continuing to work.</h4> <br>
|
||||
|
@ -171,8 +467,9 @@ print_r("<br> Help Info:<br><pre>");
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<?php }
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (!empty($this->class_error)) {
|
||||
?>
|
||||
|
@ -182,7 +479,7 @@ if (!empty($this->class_error)) {
|
|||
<h2 style="border:2px solid Tomato;color:Tomato;" >Diagnostic information about SCCP Manager errors</h2>
|
||||
<div class="table-responsive">
|
||||
<br> There is an error in the :<br><pre>
|
||||
<?php print_r($this->class_error); ?>
|
||||
<?php print_r($this->class_error); ?>
|
||||
</pre>
|
||||
<br> Correct these problems before continuing to work. <br>
|
||||
<br><h3 style="border:2px solid Tomato;color:Green;" > Open 'SCCP Connectivity' -> Server Config' to change global settings</h3> <br>
|
||||
|
@ -190,8 +487,8 @@ if (!empty($this->class_error)) {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<?php } ?>
|
||||
<br>
|
||||
<?php } ?>
|
||||
<div class="fpbx-container container-fluid">
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
|
@ -206,11 +503,11 @@ if (!empty($this->class_error)) {
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($info as $key => $value) {
|
||||
echo '<tr><td>' . $key . '</td><td>' . $value['Version'] . '</td><td>' . $value['about'] . '</td></tr>';
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
foreach ($info as $key => $value) {
|
||||
echo '<tr><td>' . $key . '</td><td>' . $value['Version'] . '</td><td>' . $value['about'] . '</td></tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -219,5 +516,5 @@ if (!empty($this->class_error)) {
|
|||
|
||||
</div>
|
||||
</div>
|
||||
<?php echo $this->ShowGroup('sccp_info',0); ?>
|
||||
<?php echo $this->ShowGroup('sccp_info', 0); ?>
|
||||
|
||||
|
|
|
@ -14,6 +14,13 @@
|
|||
<!-- div id="toolbar-all">
|
||||
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" onclick="load_oncliсk(this,'*new*')" data-target=".new_network"><i class="fa fa-bolt"></i> <?php echo _("Add Keyset"); ?></button>
|
||||
</div -->
|
||||
<div class="fpbx-container container-fluid">
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
<h2 style="border:2px solid Tomato;color:Tomato;" ><?php echo _("Warning : Any changes to the server configuration can cause all phones to restart"); ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->ShowGroup('sccp_general',1);
|
||||
echo $this->ShowGroup('sccp_dev_time_s',1);
|
||||
|
|
Loading…
Reference in a new issue