Skip to content

Commit

Permalink
Cleaned up messages
Browse files Browse the repository at this point in the history
Improved message readability. Atom removed extraneous white spaces and lines
  • Loading branch information
steve-lad committed Jan 28, 2021
1 parent 80fbf7b commit 48041fc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Sccp_manager.inc/aminterface/Message.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class AMIException extends \Exception
{

}

abstract class Message
Expand Down
19 changes: 8 additions & 11 deletions Sccp_manager.inc/aminterface/Response.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function setActionId($actionId)
$this->setKey('ActionId', $actionId);
}


public function getVariable($_rawContent, $_fields = '')
{
$lines = explode(Message::EOL, $_rawContent);
Expand Down Expand Up @@ -119,15 +118,13 @@ public function __construct($rawContent)
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);
Expand All @@ -148,7 +145,7 @@ public function __construct($rawContent)
if (!empty($this->_temptable)) {
$this->setKey('output', 'array');
}

$this->_completed = $this->isSuccess();
// return $this->isSuccess();
}
Expand All @@ -165,7 +162,7 @@ public function getResult()

class SCCPGeneric_Response extends Response
{

protected $_tables;
private $_temptable;

Expand Down Expand Up @@ -208,7 +205,7 @@ public function addEvent($event)
$this->_completed = true;
}
}

protected function ConvertTableData($_tablename, $_fkey, $_fields)
{
$_rawtable = $this->Table2Array($_tablename);
Expand Down Expand Up @@ -278,8 +275,8 @@ protected function ConvertEventData($_fkey, $_fields)
}
return $result;
}


public function hasTable()
{
if (is_array($this->_tables)) {
Expand All @@ -291,7 +288,7 @@ public function getTableNames()
{
return (is_array($this->_tables)) ? array_keys($this->_tables) : null;
}

public function Table2Array($tablename = '')
{
$result =array();
Expand Down Expand Up @@ -324,7 +321,7 @@ public function Events2Array()
return false;
}
}

public function getTable($tablename)
{
if ($this->hasTable() && array_key_exists($tablename, $this->_tables)) {
Expand All @@ -349,7 +346,7 @@ public function __construct($rawContent)
// $this->getVariable($rawContent, $_fields);
$this->_completed = !$this->isList();
}

public function getResult()
{
if ($this->getKey('JSON') != null) {
Expand Down
8 changes: 4 additions & 4 deletions Sccp_manager.inc/aminterface/aminterface.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -259,7 +259,7 @@ public function process()
$response = $this->findResponse($event);
// print_r($response);
// print_r('<br>--- E2 Response Type 2 ----------<br>');

if ($response === false || $response->isComplete()) {
$this->dispatch($event); // не работает
} else {
Expand Down Expand Up @@ -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;
}
Expand Down
20 changes: 10 additions & 10 deletions Sccp_manager.inc/extconfigs.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ 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');
}
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'));
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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';
}


Expand All @@ -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'])) {
Expand All @@ -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'])) {
Expand Down
20 changes: 10 additions & 10 deletions views/server.info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -61,7 +62,7 @@
}

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 RealTime connections found</div>');
} else {
$rt_info = '';
$rt_sccp = 'Failed';
Expand All @@ -82,7 +83,7 @@
}

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"> Realtime configuration was not found</div>');
} else {
$rt_info = '';
foreach ($conf_realtime as $key => $value) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -157,7 +158,7 @@
}
}
}

print_r("<br>");
//print_r($time_set);
print_r($this->sccpvalues['ntp_timezone']);
Expand Down Expand Up @@ -443,12 +444,12 @@
//print_r($this->dbinterface->info());

if (!empty($this->info_warning)) {
?>
?>
<div class="fpbx-container container-fluid">
<div class="row">
<div class="container">
<h2 style="border:2px solid Tomato;color:Tomato;" >Sccp Manager Warning</h2>
<div class="table-responsive">
<div class="table-responsive">
<br> There are Warning in the SCCP Module:<br><pre>
<?php
foreach ($this->info_warning as $key => $value) {
Expand All @@ -472,12 +473,12 @@
}

if (!empty($this->class_error)) {
?>
?>
<div class="fpbx-container container-fluid">
<div class="row">
<div class="container">
<h2 style="border:2px solid Tomato;color:Tomato;" >Diagnostic information about SCCP Manager errors</h2>
<div class="table-responsive">
<div class="table-responsive">
<br> There is an error in the :<br><pre>
<?php print_r($this->class_error); ?>
</pre>
Expand All @@ -493,7 +494,7 @@
<div class="row">
<div class="container">
<h2>Sccp Manager V.<?php print_r($this->sccp_manager_ver); ?> Info </h2>
<div class="table-responsive">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
Expand All @@ -517,4 +518,3 @@
</div>
</div>
<?php echo $this->showGroup('sccp_info', 0); ?>

0 comments on commit 48041fc

Please sign in to comment.