Retire Old Interface
Use exclusively AMI interface Delete oldinterface Delete srvinterface and move aminterface to Sccp_manager.inc All calls now pass directly to aminterface
This commit is contained in:
parent
a065884a8b
commit
ee0fda775e
|
@ -376,11 +376,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
public function myShowPage() {
|
||||
$request = $_REQUEST;
|
||||
$action = !empty($request['action']) ? $request['action'] : '';
|
||||
/*
|
||||
if ($this->sccpvalues['sccp_compatible']['data'] >= '433') {
|
||||
$this->sccp_metainfo = $this->srvinterface->getGlobalsFromMetaData('general');
|
||||
}
|
||||
*/
|
||||
|
||||
if (!empty($this->sccpvalues['displayconfig'])) {
|
||||
if (!empty($this->sccpvalues['displayconfig']['data']) && ($this->sccpvalues['displayconfig']['data'] == 'sccpsimple')) {
|
||||
$this->pagedata = array(
|
||||
|
@ -517,11 +513,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$request = $_REQUEST;
|
||||
$action = !empty($request['action']) ? $request['action'] : '';
|
||||
$inputform = !empty($request['tech_hardware']) ? $request['tech_hardware'] : '';
|
||||
/*
|
||||
if ($this->sccpvalues['sccp_compatible']['data'] >= '433') {
|
||||
$this->sccp_metainfo = $this->srvinterface->getGlobalsFromMetaData('device');
|
||||
}
|
||||
*/
|
||||
|
||||
if (empty($this->pagedata)) {
|
||||
switch ($inputform) {
|
||||
case "cisco":
|
||||
|
@ -699,7 +691,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
//$this->createDefaultSccpConfig();
|
||||
$this->createDefaultSccpXml();
|
||||
|
||||
$res = $this->srvinterface->sccp_reload();
|
||||
$res = $this->aminterface->core_sccp_reload();
|
||||
$msg [] = 'Config Saved: ' . $res['Response'];
|
||||
$msg [] = 'Info :' . $res['data'];
|
||||
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
|
||||
|
@ -744,7 +736,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$this->dbinterface->write('sccpdevice', array('name' => $idv), 'delete', "name");
|
||||
$this->dbinterface->write('sccpbuttons', array(), 'delete', '', $idv);
|
||||
$this->deleteSccpDeviceXML($idv); // Концы в вводу !!
|
||||
$this->srvinterface->sccpDeviceReset($idv);
|
||||
$this->aminterface->sccpDeviceReset($idv, 'reset');
|
||||
}
|
||||
}
|
||||
return array('status' => true, 'table_reload' => true, 'message' => 'Hardware device has been deleted! ');
|
||||
|
@ -789,24 +781,23 @@ 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_reset_token($idv);
|
||||
|
||||
$res = $this->aminterface->sccpDeviceReset($idv, 'tokenack');
|
||||
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
|
||||
} else {
|
||||
$res = $this->srvinterface->sccpDeviceReset($idv);
|
||||
$res = $this->aminterface->sccpDeviceReset($idv, 'reset');
|
||||
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
|
||||
}
|
||||
}
|
||||
if ($idv == 'all') {
|
||||
$dev_list = $this->srvinterface->sccp_get_active_device();
|
||||
$dev_list = $this->aminterface->sccp_get_active_device();
|
||||
foreach ($dev_list as $key => $data) {
|
||||
if ($cmd_id == 'reset_token') {
|
||||
if (($data['token'] == 'Rej') || ($data['status'] == 'Token ')) {
|
||||
$res = $this->srvinterface->sccp_reset_token($idv);
|
||||
$res = $this->aminterface->sccpDeviceReset($idv, 'tokenack');
|
||||
$msgr[] = 'Send Token reset to :' . $key;
|
||||
}
|
||||
} else {
|
||||
$res = $this->srvinterface->sccpDeviceReset($idv);
|
||||
$res = $this->aminterface->sccpDeviceReset($idv, 'reset');
|
||||
$msgr[] = $res['Response'] . ' ' . $res['data'];
|
||||
}
|
||||
}
|
||||
|
@ -893,7 +884,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$id_name = $request['softkey'];
|
||||
unset($this->sccp_conf_init[$id_name]);
|
||||
$this->createDefaultSccpConfig();
|
||||
$msg = print_r($this->srvinterface->sccp_reload(), 1);
|
||||
$msg = print_r($this->aminterface->core_sccp_reload(), 1);
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
break;
|
||||
|
@ -910,7 +901,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
// !TODO!: -TODO-: Check SIP Support Enabled
|
||||
$this->createSccpXmlSoftkey();
|
||||
$msg = print_r($this->srvinterface->sccp_reload(), 1);
|
||||
$msg = print_r($this->aminterface->core_sccp_reload, 1);
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
break;
|
||||
|
@ -918,7 +909,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$result = array();
|
||||
$i = 0;
|
||||
$keyl = 'default';
|
||||
foreach ($this->srvinterface->sccp_list_keysets() as $keyl => $vall) {
|
||||
foreach ($this->aminterface->sccp_list_keysets() as $keyl => $vall) {
|
||||
$result[$i]['softkeys'] = $keyl;
|
||||
if ($keyl == 'default') {
|
||||
foreach ($this->extconfigs->getextConfig('keyset') as $key => $value) {
|
||||
|
@ -964,7 +955,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
if ($cmd_type == 'cisco-sip') {
|
||||
return $result;
|
||||
}
|
||||
$staus = $this->srvinterface->sccp_get_active_device();
|
||||
$staus = $this->aminterface->sccp_get_active_device();
|
||||
if (empty($result)) {
|
||||
$result = array();
|
||||
} else {
|
||||
|
@ -987,7 +978,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
foreach ($staus as $dev_ids) {
|
||||
$id_name = $dev_ids['name'];
|
||||
if (empty($dev_ids['news'])) {
|
||||
$dev_data = $this->srvinterface->sccp_getdevice_info($id_name);
|
||||
$dev_data = $this->aminterface->sccp_getdevice_info($id_name);
|
||||
if (!empty($dev_data['SCCP_Vendor']['model_id'])) {
|
||||
$dev_addon = $dev_data['SCCP_Vendor']['model_addon'];
|
||||
if (empty($dev_addon)) {
|
||||
|
@ -1302,9 +1293,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$this->dbinterface->write('sccpbuttons', $save_buttons, $update_hw, '', $name_dev);
|
||||
$this->createSccpDeviceXML($name_dev);
|
||||
if ($hw_id == 'new') {
|
||||
$this->srvinterface->sccpDeviceReset($name_dev);
|
||||
$this->aminterface->sccpDeviceReset($name_dev, 'reset');
|
||||
} else {
|
||||
$this->srvinterface->sccpDeviceRestart($name_dev);
|
||||
$this->aminterface->sccpDeviceReset($name_dev, 'restart');
|
||||
}
|
||||
|
||||
return $save_settings;
|
||||
|
@ -1728,7 +1719,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$this->sccppath["asterisk"] = $confDir;
|
||||
}
|
||||
}
|
||||
$ver_id = $this->srvinterface->get_compatible_sccp();
|
||||
$ver_id = $this->aminterface->get_compatible_sccp();
|
||||
if (!empty($this->sccpvalues['SccpDBmodel'])) {
|
||||
$ver_id = $this->sccpvalues['SccpDBmodel']['data'];
|
||||
}
|
||||
|
@ -1761,7 +1752,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
}
|
||||
|
||||
$hint = $this->srvinterface->sccp_list_hints();
|
||||
$hint = $this->aminterface->core_list_hints();
|
||||
foreach ($hint as $key => $value) {
|
||||
if ($this->hint_context['default'] != $value) {
|
||||
$this->hint_context[$key] = $value;
|
||||
|
@ -1774,7 +1765,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
*/
|
||||
|
||||
function createSccpXmlSoftkey() {
|
||||
foreach ($this->srvinterface->sccp_list_keysets() as $keyl => $vall) {
|
||||
foreach ($this->aminterface->sccp_list_keysets() as $keyl => $vall) {
|
||||
$this->xmlinterface->create_xmlSoftkeyset($this->sccp_conf_init, $this->sccppath, $keyl);
|
||||
}
|
||||
}
|
||||
|
@ -2021,9 +2012,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$dir_info['asterisk'] = $this->findAllFiles($amp_conf['ASTETCDIR']);
|
||||
$dir_info['tftpdir'] = $this->findAllFiles($this->sccppath["tftp_path"]);
|
||||
$dir_info['driver'] = $this->FreePBX->Core->getAllDriversInfo();
|
||||
$dir_info['core'] = $this->srvinterface->getSCCPVersion();
|
||||
$dir_info['realtime'] = $this->srvinterface->sccp_realtime_status();
|
||||
$dir_info['srvinterface'] = $this->srvinterface->info();
|
||||
$dir_info['core'] = $this->aminterface->getSCCPVersion();
|
||||
$dir_info['realtime'] = $this->aminterface->getRealTimeStatus();
|
||||
//$dir_info['srvinterface'] = $this->srvinterface->info();
|
||||
$dir_info['extconfigs'] = $this->extconfigs->info();
|
||||
$dir_info['dbinterface'] = $this->dbinterface->info();
|
||||
$dir_info['XML'] = $this->xmlinterface->info();
|
||||
|
@ -2196,7 +2187,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
if (empty($res)) {
|
||||
// Old Req get all hints
|
||||
$tmp_data = $this->srvinterface->sccp_list_all_hints();
|
||||
$tmp_data = $this->aminterface->core_list_all_hints();
|
||||
foreach ($tmp_data as $value) {
|
||||
$res[$value] = array('key' => $value, 'exten' => $this->before('@', $value), 'label' => $value);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,10 @@ class 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;
|
||||
$driver = __DIR__ . "/aminterface/" . $value;
|
||||
if (!class_exists($class, false)) {
|
||||
if (file_exists($driver)) {
|
||||
include(__DIR__ . "/" . $value);
|
||||
include(__DIR__ . "/aminterface/" . $value);
|
||||
} else {
|
||||
throw new \Exception("Class required but file not found " . $driver);
|
||||
}
|
||||
|
@ -69,6 +69,21 @@ class aminterface
|
|||
if ($this->_config['enabled']) {
|
||||
$this->load_subspace();
|
||||
}
|
||||
|
||||
if ($this->status()) {
|
||||
// Ami is not hard disabled in Amiinterface __construct line 54.
|
||||
if ($this->open()) {
|
||||
// Can open a connection. Now check compatibility with chan-sccp.
|
||||
// will return true if compatible.
|
||||
if (!$this->get_compatible_sccp(true)[1]) {
|
||||
// Close the open socket as will not use
|
||||
$this->close();
|
||||
} else {
|
||||
// is compatible so enable AMI mode
|
||||
$this->ami_mode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function status()
|
||||
|
@ -515,4 +530,35 @@ class aminterface
|
|||
}
|
||||
return $cmd_res;
|
||||
}
|
||||
|
||||
public function get_compatible_sccp($revNumComp=false) {
|
||||
// only called with args from installer to get revision and compatibility
|
||||
$res = $this->getSCCPVersion();
|
||||
if (empty($res)) {
|
||||
return 0;
|
||||
}
|
||||
switch ($res["vCode"]) {
|
||||
case 0:
|
||||
$retval = 0;
|
||||
break;
|
||||
case 433:
|
||||
$retval = 433;
|
||||
break;
|
||||
case 432:
|
||||
$retval = 430;
|
||||
break;
|
||||
case 431:
|
||||
$retval = 431;
|
||||
break;
|
||||
default:
|
||||
$retval = 430;
|
||||
}
|
||||
if ($res['RevisionNum'] < 11063) {
|
||||
$this->useAmiInterface = false;
|
||||
}
|
||||
if ($revNumComp) {
|
||||
return array($retval, true);
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
}
|
|
@ -1,525 +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;
|
||||
|
||||
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();
|
||||
// Below added for compatibility with AMI result and modified server.info
|
||||
$ast_res = ['sccp' => ['message' => 'default value', 'realm' => '', 'status' => 'ERROR']];
|
||||
$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;
|
||||
} elseif ($version_parts[1] == "2") {
|
||||
$result["vCode"] = 420;
|
||||
} elseif ($version_parts[1] >= "3") {
|
||||
if ($version_parts[2] == "3"){
|
||||
$result["vCode"] = 433;
|
||||
} else {
|
||||
$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, $address, $devname, $status, $token, $junk) = explode(";|", implode(";|", $line_arr));
|
||||
|
||||
// list ($descr, $address, $devname, $status, $junk) = $line_arr;
|
||||
// if (strlen($ast_key[$devname]) < 1) {
|
||||
if (strlen($devname) > 1) {
|
||||
$ast_key[$devname] = array('name' => $devname, 'status' => $status, 'address' => $address, 'descr' => $descr, 'token' => $token);
|
||||
}
|
||||
/*
|
||||
if (isset($ast_key[$devname])) {
|
||||
if (strlen($ast_key[$devname]) < 1) {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $address, 'descr' => $descr, 'token' => $descr);
|
||||
}
|
||||
} else {
|
||||
$ast_key[$devname] = Array('name' => $devname, 'status' => $status, 'address' => $address, '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 = $this->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 getGlobalsFromMetaData($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;
|
||||
}
|
||||
}
|
|
@ -1,350 +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;
|
||||
|
||||
class srvinterface {
|
||||
|
||||
var $error;
|
||||
var $_info;
|
||||
var $ami_mode = false;
|
||||
var $useAmiInterface = true;
|
||||
|
||||
public function __construct($parent_class = null) {
|
||||
$this->paren_class = $parent_class;
|
||||
if ($this->paren_class == null) {
|
||||
$this->paren_class = $this;
|
||||
}
|
||||
$this->error = "";
|
||||
$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 {
|
||||
throw new \Exception("Class required but file not found " . $driver);
|
||||
}
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
if (is_null($this->$key)) {
|
||||
if (class_exists($class, false)) {
|
||||
$this->$key = new $class($this->paren_class);
|
||||
$this->_info [] = $this->$key->info();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->aminterface->status()) {
|
||||
// Ami is not hard disabled in Amiinterface __construct line 54.
|
||||
if ($this->aminterface->open()) {
|
||||
// Can open a connection. Now check compatibility with chan-sccp.
|
||||
// will return true if compatible.
|
||||
if (!$this->get_compatible_sccp(true)[1]) {
|
||||
// Close the open socket as will not use
|
||||
$this->aminterface->close();
|
||||
} else {
|
||||
// is compatible so enable AMI mode
|
||||
$this->ami_mode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 sccpDeviceReset($id = '') {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccpDeviceReset($id, 'reset');
|
||||
} else {
|
||||
return $this->oldinterface->sccp_core_commands(array('cmd' => 'reset_phone', 'name' => $id));
|
||||
}
|
||||
}
|
||||
|
||||
public function sccpDeviceRestart($id = '') {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccpDeviceReset($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->sccpDeviceReset($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->sccpDeviceReset($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) {
|
||||
return $this->oldinterface->sccp_core_commands($params);
|
||||
}
|
||||
|
||||
if (!empty($params['cmd'])) {
|
||||
switch ($params['cmd']) {
|
||||
case 'reset_phone':
|
||||
return $this->aminterface->sccpDeviceReset($params['name'], 'reset');
|
||||
break;
|
||||
case 'restart_phone':
|
||||
return $this->aminterface->sccpDeviceReset($params['name'], 'restart');
|
||||
break;
|
||||
case 'reload_phone':
|
||||
return $this->aminterface->sccpDeviceReset($params['name'], 'full');
|
||||
break;
|
||||
case 'reset_token':
|
||||
return $this->aminterface->sccpDeviceReset($params['name'], 'tokenack');
|
||||
break;
|
||||
case 'reload_line':
|
||||
// return $this->aminterface->sccpDeviceReset($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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function sccp_getdevice_info($dev_id) {
|
||||
if (empty($dev_id)) {
|
||||
return array();
|
||||
}
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_getdevice_info($dev_id);
|
||||
} else {
|
||||
return $this->oldinterface->sccp_getdevice_info($dev_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_list_hints() {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->core_list_hints();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_list_hints();
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_list_all_hints() {
|
||||
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->core_list_all_hints();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_list_all_hints();
|
||||
}
|
||||
}
|
||||
|
||||
public function sccp_realtime_status() {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->getRealTimeStatus();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_realtime_status();
|
||||
}
|
||||
}
|
||||
|
||||
public function get_compatible_sccp($revNumComp=false) {
|
||||
// only called with args from installer to get revision and compatibility
|
||||
$res = $this->getSCCPVersion();
|
||||
if (empty($res)) {
|
||||
return 0;
|
||||
}
|
||||
switch ($res["vCode"]) {
|
||||
case 0:
|
||||
$retval = 0;
|
||||
break;
|
||||
case 433:
|
||||
$retval = 433;
|
||||
break;
|
||||
case 432:
|
||||
$retval = 430;
|
||||
break;
|
||||
case 431:
|
||||
$retval = 431;
|
||||
break;
|
||||
default:
|
||||
$retval = 430;
|
||||
}
|
||||
if ($res['RevisionNum'] < 11063) {
|
||||
$this->useAmiInterface = false;
|
||||
}
|
||||
if ($revNumComp) {
|
||||
return array($retval, $this->useAmiInterface);
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
public function getSCCPVersion() {
|
||||
$res = $this->getChanSCCPVersion();
|
||||
if (empty($res)) {
|
||||
$res = $this->oldinterface->getCoreSCCPVersion();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function sccp_list_keysets() {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_list_keysets();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_list_keysets();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function sccp_get_active_device() {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->sccp_get_active_device();
|
||||
} else {
|
||||
return $this->oldinterface->sccp_get_active_device();
|
||||
}
|
||||
}
|
||||
|
||||
function getChanSCCPVersion() {
|
||||
if ($this->ami_mode) {
|
||||
return $this->aminterface->getSCCPVersion();
|
||||
} else {
|
||||
return $this->oldinterface->getChanSCCPVersion();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------- 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) . " Response :" . ($time_resp - $time_logoff) . "\r\n\r\n ";
|
||||
// print_r(fgets($fp));
|
||||
// print_r('<br>');
|
||||
// echo fgets($fp, 128);
|
||||
}
|
||||
fclose($fp);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
}
|
12
install.php
12
install.php
|
@ -15,17 +15,17 @@ global $db;
|
|||
global $amp_conf;
|
||||
global $astman;
|
||||
global $version;
|
||||
global $srvinterface;
|
||||
global $aminterface;
|
||||
global $mobile_hw;
|
||||
global $useAmiForSoftKeys;
|
||||
$mobile_hw = '0';
|
||||
|
||||
$class = "\\FreePBX\\Modules\\Sccp_manager\\srvinterface";
|
||||
$class = "\\FreePBX\\Modules\\Sccp_manager\\aminterface";
|
||||
if (!class_exists($class, false)) {
|
||||
include(__DIR__ . "/Sccp_manager.inc/srvinterface.class.php");
|
||||
include(__DIR__ . "/Sccp_manager.inc/aminterface/amiinterface.class.php");
|
||||
}
|
||||
if (class_exists($class, false)) {
|
||||
$srvinterface = new $class();
|
||||
$aminterface = new $class();
|
||||
}
|
||||
function Get_DB_config($sccp_compatible)
|
||||
{
|
||||
|
@ -447,12 +447,12 @@ function CheckAsteriskVersion()
|
|||
function CheckChanSCCPCompatible()
|
||||
{
|
||||
global $chanSCCPWarning;
|
||||
global $srvinterface, $astman;
|
||||
global $aminterface, $astman;
|
||||
if (!$astman) {
|
||||
ie_freepbx('No asterisk manager connection provided!. Installation Failed');
|
||||
}
|
||||
// calling with true returns array with compatibility and RevisionNumber
|
||||
return $srvinterface->get_compatible_sccp(true);
|
||||
return $aminterface->get_compatible_sccp(true);
|
||||
}
|
||||
|
||||
function InstallDB_Buttons()
|
||||
|
|
|
@ -42,10 +42,10 @@ $sofkey_list = array();
|
|||
$model_list = array();
|
||||
$device_list = array();
|
||||
$dialplan_list = array();
|
||||
|
||||
|
||||
//$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();
|
||||
//$sofkey_list = \FreePBX::Sccp_manager()-> aminterface->sccp_list_keysets();
|
||||
//$model_list = \FreePBX::Sccp_manager()->dbinterface->HWextension_db_SccpTableData("HWDevice");
|
||||
//$extension_list = \FreePBX::Sccp_manager()->dbinterface->HWextension_db_SccpTableData("HWextension");
|
||||
//$device_list = \FreePBX::Sccp_manager()->dbinterface->HWextension_db_SccpTableData("SccpDevice");
|
||||
|
@ -109,24 +109,24 @@ foreach ($items as $child) {
|
|||
if (!empty($child ->class)) {
|
||||
$res_sec_class = (string)$child ->class;
|
||||
}
|
||||
|
||||
|
||||
if (empty($child->nameseparator)) {
|
||||
$child->nameseparator = ' / ';
|
||||
}
|
||||
$i = 0;
|
||||
|
||||
|
||||
echo '<!-- Begin '.$child->label.' -->';
|
||||
|
||||
|
||||
?>
|
||||
<div class="element-container">
|
||||
<div class="row"> <div class="form-group <?php echo $res_sec_class; ?>">
|
||||
<div class="row"> <div class="form-group <?php echo $res_sec_class; ?>">
|
||||
<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">
|
||||
<?php
|
||||
|
||||
|
||||
foreach ($child->xpath('input') as $value) {
|
||||
$res_n = (string)$value->name;
|
||||
$res_name = $npref . $res_n;
|
||||
|
@ -209,7 +209,7 @@ foreach ($items as $child) {
|
|||
$res_value = array((string) $child->default);
|
||||
// $res_value = explode('/', (string) $child->default);
|
||||
}
|
||||
|
||||
|
||||
echo '<!-- Begin '.$child->label.' -->';
|
||||
?>
|
||||
<div class="element-container">
|
||||
|
@ -221,7 +221,7 @@ foreach ($items as $child) {
|
|||
<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">
|
||||
<?php
|
||||
if (!empty($child->cbutton)) {
|
||||
|
@ -250,7 +250,7 @@ foreach ($items as $child) {
|
|||
}
|
||||
$opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" ';
|
||||
}
|
||||
|
||||
|
||||
if (!empty($value->option_disabled)) {
|
||||
$opt_class .= " sccp_button_disabled";
|
||||
$opt_hide = ' data-vhide="'.$value->option_disabled.'" data-btn="checkbox" data-clhide="'.$value->option_disabled['class'].'" ';
|
||||
|
@ -259,7 +259,7 @@ foreach ($items as $child) {
|
|||
if (!empty($value->class)) {
|
||||
$opt_class .= " ".(string)$value->class;
|
||||
}
|
||||
|
||||
|
||||
echo '<span class="'.$opt_class.'"'.$opt_hide.'><button type="button" class="btn '.$res_vf.'" data-color="primary">';
|
||||
echo '<i class="state-icon '. (($res_vf == 'active')?'glyphicon glyphicon-check"':'glyphicon glyphicon-uncheck'). '"></i> ';
|
||||
echo $value.'</button><input type="checkbox" name="'. $res_n.'" class="hidden" '. (($res_vf == 'active')?'checked="checked"':'') .'/></span>';
|
||||
|
@ -271,10 +271,10 @@ foreach ($items as $child) {
|
|||
$opt_class .= " ".(string)$child->class;
|
||||
}
|
||||
echo '<div class = "'.$opt_class.'">';
|
||||
|
||||
|
||||
foreach ($res_value as $dat_v) {
|
||||
?>
|
||||
<div class = "<?php echo $res_id;?> form-group form-inline" data-nextid=<?php echo $i+1;?> >
|
||||
<div class = "<?php echo $res_id;?> form-group form-inline" data-nextid=<?php echo $i+1;?> >
|
||||
<?php
|
||||
$res_vf = explode('/', $dat_v);
|
||||
$i2 = 0;
|
||||
|
@ -286,7 +286,7 @@ foreach ($items as $child) {
|
|||
$opt_at[$fields_id]['class']='form-control ' .(string)$value->class;
|
||||
}
|
||||
$opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator'];
|
||||
|
||||
|
||||
echo '<input type="text" name="'. $res_n.'" class="'.$opt_at[$fields_id]['class'].'" value="'.$res_vf[$i2].'"';
|
||||
if (isset($value->options)) {
|
||||
foreach ($value->options ->attributes() as $optkey => $optval) {
|
||||
|
@ -304,7 +304,7 @@ foreach ($items as $child) {
|
|||
$i++;
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
</div>
|
||||
<?php
|
||||
if (!empty($child->addbutton)) {
|
||||
|
@ -325,7 +325,7 @@ foreach ($items as $child) {
|
|||
<?php
|
||||
echo '<!-- END '.$child->label.' -->';
|
||||
}
|
||||
|
||||
|
||||
if ($child['type'] == 'IS') {
|
||||
$res_n = (string)$child->name;
|
||||
$res_id = $npref.$child->name;
|
||||
|
@ -334,17 +334,17 @@ foreach ($items as $child) {
|
|||
$child->help = $metainfo[$res_n]['Description'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Add Hiden option
|
||||
$res_sec_class ='';
|
||||
if (!empty($child ->class)) {
|
||||
$res_sec_class = (string)$child ->class;
|
||||
}
|
||||
|
||||
|
||||
echo '<!-- Begin '.$child->label.' -->';
|
||||
?>
|
||||
<div class="element-container">
|
||||
<div class="row"><div class="form-group <?php echo $res_sec_class;?>">
|
||||
<div class="row"><div class="form-group <?php echo $res_sec_class;?>">
|
||||
<div class="col-md-3 radioset">
|
||||
<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>
|
||||
|
@ -364,7 +364,7 @@ foreach ($items as $child) {
|
|||
if (!empty($fvalues[$res_n])) {
|
||||
if (($fvalues[$res_n]['data'] != '') ) {
|
||||
$res_v = (string)$fvalues[$res_n]['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($child->option_hide)) {
|
||||
$opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" ';
|
||||
|
@ -390,7 +390,7 @@ foreach ($items as $child) {
|
|||
echo '<label for="' . $res_id. '_' . $i . '">' . _($value) . '</label>';
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
</div></div>
|
||||
<div class="row"><div class="col-md-12">
|
||||
|
@ -401,7 +401,7 @@ foreach ($items as $child) {
|
|||
<?php
|
||||
echo '<!-- END '.$child->label.' -->';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Input element Select SLD - Date format
|
||||
* SLZ - Time Zone
|
||||
|
@ -420,11 +420,11 @@ foreach ($items as $child) {
|
|||
$child->help = $metainfo[$res_n]['Description'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($child->class)) {
|
||||
$child->class = 'form-control';
|
||||
}
|
||||
|
||||
|
||||
if ($child['type'] == 'SLD') {
|
||||
$select_opt= $day_format;
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ foreach ($items as $child) {
|
|||
}
|
||||
if ($child['type'] == 'SLK') {
|
||||
if (empty($sofkey_list)) {
|
||||
$sofkey_list = \FreePBX::Sccp_manager()-> srvinterface -> sccp_list_keysets();
|
||||
$sofkey_list = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets();
|
||||
}
|
||||
$select_opt= $sofkey_list;
|
||||
}
|
||||
|
@ -455,8 +455,8 @@ foreach ($items as $child) {
|
|||
|
||||
?>
|
||||
<div class="element-container">
|
||||
<div class="row"> <div class="form-group">
|
||||
|
||||
<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>
|
||||
|
@ -488,7 +488,7 @@ foreach ($items as $child) {
|
|||
/*
|
||||
* Input element Select SLS - System Language
|
||||
*/
|
||||
|
||||
|
||||
if ($child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SLA' || $child['type'] == 'SLZ') {
|
||||
// $value = $child -> select;
|
||||
$res_n = (string)$child ->name;
|
||||
|
@ -526,28 +526,28 @@ foreach ($items as $child) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)) {
|
||||
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="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>
|
||||
|
@ -592,7 +592,7 @@ foreach ($items as $child) {
|
|||
$child->help = $metainfo[$res_n]['Description'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($child ->class)) {
|
||||
$child->class = 'form-control';
|
||||
}
|
||||
|
@ -600,8 +600,8 @@ foreach ($items as $child) {
|
|||
|
||||
?>
|
||||
<div class="element-container">
|
||||
<div class="row"> <div class="form-group">
|
||||
|
||||
<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>
|
||||
|
@ -626,7 +626,7 @@ foreach ($items as $child) {
|
|||
echo '>' . (string)$value. '</option>';
|
||||
}
|
||||
?> </select>
|
||||
|
||||
|
||||
</div> </div>
|
||||
</div></div>
|
||||
<div class="row"><div class="col-md-12">
|
||||
|
@ -653,7 +653,7 @@ foreach ($items as $child) {
|
|||
$child->help = $metainfo[$res_n]['Description'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($child->class)) {
|
||||
$child->class = 'form-control';
|
||||
}
|
||||
|
@ -697,8 +697,8 @@ foreach ($items as $child) {
|
|||
|
||||
?>
|
||||
<div class="element-container">
|
||||
<div class="row"> <div class="form-group">
|
||||
|
||||
<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>
|
||||
|
@ -724,7 +724,7 @@ foreach ($items as $child) {
|
|||
$key = $fvalues[$res_n]['data'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($select_opt as $data) {
|
||||
echo '<option value="' . $data[$fld] . '"';
|
||||
if ($key == $data[$fld]) {
|
||||
|
@ -772,7 +772,7 @@ foreach ($items as $child) {
|
|||
$res_value = array((string) $child->default);
|
||||
// $res_value = explode('/', (string) $child->default);
|
||||
}
|
||||
|
||||
|
||||
echo '<!-- Begin '.$res_id.' -->';
|
||||
?>
|
||||
<table class="table table-striped" id="dp-table-<?php echo $res_id;?>">
|
||||
|
@ -786,7 +786,7 @@ foreach ($items as $child) {
|
|||
|
||||
$res_vf = explode('/', $dat_v);
|
||||
$i2 = 0;
|
||||
|
||||
|
||||
foreach ($child->xpath('element') as $value) {
|
||||
$fields_id = (string)strtolower($value['field']);
|
||||
$res_n = $res_id.'['.$i.']['.$fields_id.']';
|
||||
|
@ -794,7 +794,7 @@ foreach ($items as $child) {
|
|||
|
||||
$opt_at[$fields_id]['display_prefix']=(string)$value['display_prefix'];
|
||||
$opt_at[$fields_id]['display_sufix']=(string)$value['display_sufix'];
|
||||
|
||||
|
||||
if (empty($value->options->class)) {
|
||||
$opt_at[$fields_id]['options']['class']='form-control';
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ foreach ($items as $child) {
|
|||
$res_opt['addon'] .=' '.$optkey.'="'.$optval.'"';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo '<td class="">';
|
||||
$res_opt['inp_st'] = '<div class="input-group"> <span class="input-group-addon" id="basep_'.$res_n.'">'.$opt_at[$fields_id]['display_prefix'].'</span>';
|
||||
$res_opt['inp_end'] = '<span class="input-group-addon" id="bases_'.$res_n.'">'.$opt_at[$fields_id]['display_sufix'].'</span></div>';
|
||||
|
@ -849,14 +849,14 @@ foreach ($items as $child) {
|
|||
if ($i > 0) {
|
||||
echo '<input type="button" id="'.$res_id.'-btndel" data-id="'.($i).'" data-for="'.$res_id.'" class="table-js-del" value="-" />';
|
||||
}
|
||||
|
||||
|
||||
echo '</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
echo '</table>';
|
||||
echo '<!-- END '.$res_id.' -->';
|
||||
}
|
||||
|
||||
|
||||
if ($child['type'] == 'HLP') {
|
||||
$res_n = (string)$child ->name;
|
||||
$res_id = $npref.$res_n;
|
||||
|
@ -866,10 +866,10 @@ foreach ($items as $child) {
|
|||
echo '<!-- Begin '.$child->label.' -->';
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-info-circle"></i> <nbsp> <?php echo _($child->label);?>
|
||||
<h3 class="panel-title"><i class="fa fa-info-circle"></i> <nbsp> <?php echo _($child->label);?>
|
||||
<a data-toggle="collapse" href="<?php echo '#'.$res_id;?>"><i class="fa fa-plus pull-right"></i></a></h3>
|
||||
</div>
|
||||
<div class="panel-body collapse" id="<?php echo $res_id;?>">
|
||||
|
@ -926,14 +926,14 @@ foreach ($items as $child) {
|
|||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
</div><!-- /.modal -->
|
||||
<?php
|
||||
echo '<!-- END '.$child->label.' -->';
|
||||
}
|
||||
/*
|
||||
* Input element Select SLTZN - System Time Zone
|
||||
*/
|
||||
|
||||
|
||||
if ($child['type'] == 'SLTZN') {
|
||||
// $value = $child -> select;
|
||||
$res_n = (string)$child ->name;
|
||||
|
@ -952,29 +952,29 @@ foreach ($items as $child) {
|
|||
$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="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>
|
||||
|
@ -998,7 +998,7 @@ foreach ($items as $child) {
|
|||
if ($optgroup !== '') {
|
||||
echo '</optgroup>';
|
||||
}
|
||||
|
||||
|
||||
?> </select>
|
||||
<!-- </div> --> </div>
|
||||
</div></div>
|
||||
|
@ -1017,4 +1017,3 @@ if ($h_show==1) {
|
|||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ $test_ami = 0;
|
|||
$test_any = 0;
|
||||
|
||||
$driver = $this->FreePBX->Core->getAllDriversInfo();
|
||||
$core = $this->srvinterface->getSCCPVersion();
|
||||
$ast_realtime = $this->srvinterface->sccp_realtime_status();
|
||||
$core = $this->aminterface->getSCCPVersion();
|
||||
$ast_realtime = $this->aminterface->getRealTimeStatus();
|
||||
|
||||
//$ast_realm = (empty($ast_realtime['sccp']) ? '' : 'sccp');
|
||||
|
||||
|
@ -26,20 +26,22 @@ foreach ($ast_realtime as $key => $value) {
|
|||
$conf_realtime = $this->extconfigs->validate_RealTime($ast_realm);
|
||||
$db_Schema = $this->dbinterface->validate();
|
||||
$mysql_info = $this->dbinterface->get_db_sysvalues();
|
||||
$compatible = $this->srvinterface->get_compatible_sccp();
|
||||
$compatible = $this->aminterface->get_compatible_sccp();
|
||||
$info = array();
|
||||
|
||||
$info['srvinterface'] = $this->srvinterface->info();
|
||||
//$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']);
|
||||
/*
|
||||
if (!$this->srvinterface->useAmiInterface) {
|
||||
$info['aminterface']['about'] .= ' -- Disabled';
|
||||
$info['Core_sccp'] = array('Version' => $core['Version'], 'about' => 'Sccp ver.' . $core['Version'] . ' r' . $core['vCode'] . ' Revision :' . $core['RevisionNum'] . ' Hash :' . $core['RevisionHash'] . ' ----Warning: Upgrade chan_sccp to use full ami functionality');
|
||||
}
|
||||
*/
|
||||
$info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.');
|
||||
|
||||
|
||||
|
@ -123,333 +125,12 @@ if ($cisco_tz['offset'] == 0) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
|
||||
// ************************************************************************************
|
||||
print_r("<br> Help Info:<br><pre>");
|
||||
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(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 Response :');
|
||||
print_r($time_ami);
|
||||
print_r('<br>PBX Response :');
|
||||
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->HWextension_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->getHintInformation());
|
||||
// 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(" ");
|
||||
/* */
|
||||
// ************************************************************************************
|
||||
// $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)) {
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue