From 48041fc62c79594c61e42b3e3bb45b460c1e3123 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 28 Jan 2021 10:25:02 +0100 Subject: [PATCH] Cleaned up messages Improved message readability. Atom removed extraneous white spaces and lines --- .../aminterface/Message.class.php | 2 +- .../aminterface/Response.class.php | 19 ++++++++---------- .../aminterface/aminterface.class.php | 8 ++++---- Sccp_manager.inc/extconfigs.class.php | 20 +++++++++---------- views/server.info.php | 20 +++++++++---------- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Sccp_manager.inc/aminterface/Message.class.php b/Sccp_manager.inc/aminterface/Message.class.php index f52178b..aedabc4 100644 --- a/Sccp_manager.inc/aminterface/Message.class.php +++ b/Sccp_manager.inc/aminterface/Message.class.php @@ -12,7 +12,7 @@ class AMIException extends \Exception { - + } abstract class Message diff --git a/Sccp_manager.inc/aminterface/Response.class.php b/Sccp_manager.inc/aminterface/Response.class.php index c4bd495..2b524bf 100644 --- a/Sccp_manager.inc/aminterface/Response.class.php +++ b/Sccp_manager.inc/aminterface/Response.class.php @@ -72,7 +72,6 @@ public function setActionId($actionId) $this->setKey('ActionId', $actionId); } - public function getVariable($_rawContent, $_fields = '') { $lines = explode(Message::EOL, $_rawContent); @@ -119,7 +118,6 @@ public function __construct($rawContent) class Command_Response extends Response { private $_temptable; - public function __construct($rawContent) { // print_r('
---- r --
'); @@ -127,7 +125,6 @@ public function __construct($rawContent) // print_r('
---- re --
'); $this->_temptable = array(); parent::__construct($rawContent); - $lines = explode(Message::EOL, $rawContent); foreach ($lines as $line) { $content = explode(':', $line); @@ -148,7 +145,7 @@ public function __construct($rawContent) if (!empty($this->_temptable)) { $this->setKey('output', 'array'); } - + $this->_completed = $this->isSuccess(); // return $this->isSuccess(); } @@ -165,7 +162,7 @@ public function getResult() class SCCPGeneric_Response extends Response { - + protected $_tables; private $_temptable; @@ -208,7 +205,7 @@ public function addEvent($event) $this->_completed = true; } } - + protected function ConvertTableData($_tablename, $_fkey, $_fields) { $_rawtable = $this->Table2Array($_tablename); @@ -278,8 +275,8 @@ protected function ConvertEventData($_fkey, $_fields) } return $result; } - - + + public function hasTable() { if (is_array($this->_tables)) { @@ -291,7 +288,7 @@ public function getTableNames() { return (is_array($this->_tables)) ? array_keys($this->_tables) : null; } - + public function Table2Array($tablename = '') { $result =array(); @@ -324,7 +321,7 @@ public function Events2Array() return false; } } - + public function getTable($tablename) { if ($this->hasTable() && array_key_exists($tablename, $this->_tables)) { @@ -349,7 +346,7 @@ public function __construct($rawContent) // $this->getVariable($rawContent, $_fields); $this->_completed = !$this->isList(); } - + public function getResult() { if ($this->getKey('JSON') != null) { diff --git a/Sccp_manager.inc/aminterface/aminterface.class.php b/Sccp_manager.inc/aminterface/aminterface.class.php index 31d24e7..cbbb102 100644 --- a/Sccp_manager.inc/aminterface/aminterface.class.php +++ b/Sccp_manager.inc/aminterface/aminterface.class.php @@ -55,8 +55,8 @@ public function __construct($parent_class = null) $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')); @@ -259,7 +259,7 @@ public function process() $response = $this->findResponse($event); // print_r($response); // print_r('
--- E2 Response Type 2 ----------
'); - + if ($response === false || $response->isComplete()) { $this->dispatch($event); // не работает } else { @@ -409,7 +409,7 @@ protected function dispatch($message) $listener = $data[0]; $predicate = $data[1]; print_r($data); - + if (is_callable($predicate) && !call_user_func($predicate, $message)) { continue; } diff --git a/Sccp_manager.inc/extconfigs.class.php b/Sccp_manager.inc/extconfigs.class.php index c04eda7..58665c9 100644 --- a/Sccp_manager.inc/extconfigs.class.php +++ b/Sccp_manager.inc/extconfigs.class.php @@ -45,11 +45,11 @@ public function getextConfig($id = '', $index = '') $tmp_dt = new \DateTime(null, new \DateTimeZone($index)); $tmp_ofset = $tmp_dt->getOffset(); return $tmp_ofset / 60; - + break; case 'sccp_timezone': // Sccp manafer: 1400 (+ Id) :2007 (+ Id) $result = array(); - + if (empty($index)) { return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich'); } @@ -57,7 +57,7 @@ public function getextConfig($id = '', $index = '') 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')); @@ -109,7 +109,7 @@ public function getextConfig($id = '', $index = '') 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(); @@ -464,14 +464,14 @@ public function validate_RealTime($realm = '') $res['extconfig'] = 'OK'; if (empty($res['sccpdevice'])) { - $res['extconfig'] = ' Options "Sccpdevice" not config '; + $res['extconfig'] = ' Option "Sccpdevice" is not configured '; } if (empty($res['sccpline'])) { - $res['extconfig'] = ' Options "Sccpline" not config '; + $res['extconfig'] = ' Option "Sccpline" is not configured '; } if (empty($res['extconfigfile'])) { - $res['extconfig'] = 'File extconfig.conf not exist'; + $res['extconfig'] = 'File extconfig.conf does not exist'; } @@ -483,10 +483,10 @@ public function validate_RealTime($realm = '') if (file_exists($dir . '/res_mysql.conf')) { $res_conf = $cnf_read->getConfig('res_mysql.conf'); if (empty($res_conf[$realm])) { - $res['mysqlconfig'] = 'Not Config in file: res_mysql.conf'; + $res['mysqlconfig'] = 'Config not found in file: res_mysql.conf'; } else { if ($res_conf[$realm]['dbsock'] != $def_bd_config['dbsock']) { - $res['mysqlconfig'] = 'Mysql Soket Error in file: res_mysql.conf'; + $res['mysqlconfig'] = 'Mysql Socket Error in file: res_mysql.conf'; } } if (empty($res['mysqlconfig'])) { @@ -500,7 +500,7 @@ public function validate_RealTime($realm = '') $res['mysqlconfig'] = 'Not Config in file: res_config_mysql.conf'; } else { if ($res_conf[$realm]['dbsock'] != $def_bd_config['dbsock']) { - $res['mysqlconfig'] = 'Mysql Soket Error in file: res_config_mysql.conf'; + $res['mysqlconfig'] = 'Mysql Socket Error in file: res_config_mysql.conf'; } } if (empty($res['mysqlconfig'])) { diff --git a/views/server.info.php b/views/server.info.php index b227895..2785b4c 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -14,6 +14,7 @@ $ast_realm = (empty($ast_realtime['sccp']) ? '' : 'sccp'); +// if there are multiple connections, this will only return the first. foreach ($ast_realtime as $key => $value) { if (empty($ast_realm)) { if ($value['status'] == 'OK') { @@ -61,7 +62,7 @@ } if (empty($ast_realtime)) { - $info['RealTime'] = array('Version' => 'Error', 'about' => '
No found Real Time connections
'); + $info['RealTime'] = array('Version' => 'Error', 'about' => '
No RealTime connections found
'); } else { $rt_info = ''; $rt_sccp = 'Failed'; @@ -82,7 +83,7 @@ } if (empty($conf_realtime)) { - $info['ConfigsRealTime'] = array('Version' => 'Error', 'about' => '
No found Real Time Configs
'); + $info['ConfigsRealTime'] = array('Version' => 'Error', 'about' => '
Realtime configuration was not found
'); } else { $rt_info = ''; foreach ($conf_realtime as $key => $value) { @@ -135,7 +136,7 @@ //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)) { @@ -157,7 +158,7 @@ } } } - + print_r("
"); //print_r($time_set); print_r($this->sccpvalues['ntp_timezone']); @@ -443,12 +444,12 @@ //print_r($this->dbinterface->info()); if (!empty($this->info_warning)) { - ?> + ?>

Sccp Manager Warning

-
+

There are Warning in the SCCP Module:
                         info_warning as $key => $value) {
@@ -472,12 +473,12 @@
 }
 
 if (!empty($this->class_error)) {
-    ?>    
+    ?>
     

Diagnostic information about SCCP Manager errors

-
+

There is an error in the :
     class_error); ?>
                     
@@ -493,7 +494,7 @@

Sccp Manager V.sccp_manager_ver); ?> Info

-
+
@@ -517,4 +518,3 @@ showGroup('sccp_info', 0); ?> -