Revert to stable version
This commit is contained in:
parent
96cf1ca87c
commit
f84499c8b0
Binary file not shown.
Before Width: | Height: | Size: 762 KiB |
Binary file not shown.
Before Width: | Height: | Size: 762 KiB |
Binary file not shown.
Before Width: | Height: | Size: 762 KiB |
Binary file not shown.
Before Width: | Height: | Size: 762 KiB |
Binary file not shown.
Before Width: | Height: | Size: 79 KiB |
|
@ -550,8 +550,7 @@ $(document).ready(function () {
|
|||
}
|
||||
if ($(this).data('id') === 'model_apply') {
|
||||
var dev_cmd = 'model_update';
|
||||
//var dev_fld = ["model", "loadimage", "nametemplate"];
|
||||
var dev_fld = ["model", "vendor", "dns", "buttons", "loadimage", "loadinformationid", "nametemplate"];
|
||||
var dev_fld = ["model", "loadimage", "nametemplate"];
|
||||
datas = '';
|
||||
for (var i = 0; i < dev_fld.length; i++) {
|
||||
datas = datas + dev_fld[i] + '=' + $('#editd_' + dev_fld[i]).val() + '&';
|
||||
|
|
|
@ -1,206 +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\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->_completed = false;
|
||||
}
|
||||
}
|
||||
|
||||
class UnknownEvent extends Event
|
||||
{
|
||||
public function __construct($rawContent = '')
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
// This is a list of tables, each table is an entry
|
||||
protected $_data;
|
||||
}
|
||||
|
||||
class ExtensionStatus_Event extends Event
|
||||
{
|
||||
// this is a list of tables, each table is an entry
|
||||
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
|
||||
{
|
||||
// This is a list of tables, each table is an entry
|
||||
}
|
||||
|
||||
class SCCPShowDevice_Event extends Event
|
||||
{
|
||||
// This is a list of tables
|
||||
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 SCCPDeviceButtonEntry_Event extends Event
|
||||
{
|
||||
}
|
||||
class SCCPDeviceFeatureEntry_Event extends Event
|
||||
{
|
||||
// Returned by SCCPShowDevice
|
||||
}
|
||||
class SCCPVariableEntry_Event extends Event
|
||||
{
|
||||
// Returned by SCCPShowDevice
|
||||
}
|
||||
class SCCPDeviceLineEntry_Event extends Event
|
||||
{
|
||||
}
|
||||
class SCCPDeviceStatisticsEntry_Event extends Event
|
||||
{
|
||||
}
|
||||
class SCCPDeviceSpeeddialEntry_Event extends Event
|
||||
{
|
||||
}
|
||||
abstract class ClosingEvent extends Event
|
||||
{
|
||||
public function __construct($message) {
|
||||
parent::__construct($message);
|
||||
$this->_completed = true;
|
||||
}
|
||||
public function getListItems() {
|
||||
return intval($this->getKey('ListItems'));
|
||||
}
|
||||
|
||||
}
|
||||
class ResponseComplete_Event extends ClosingEvent
|
||||
{
|
||||
// dummy event to avoid unnecessary testing
|
||||
public function listCorrectlyReceived($_message, $_eventCount){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class SCCPShowDeviceComplete_Event extends ClosingEvent
|
||||
{
|
||||
public function listCorrectlyReceived($_message, $_eventCount){
|
||||
// Have end of list event. Check with number of lines received and send true if match.
|
||||
// Remove 9 for the start and end events, and then 4.
|
||||
if ($this->getKey('listitems') === substr_count( $_message, "\n") -13) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
class SCCPShowDevicesComplete_Event extends ClosingEvent
|
||||
{
|
||||
public function listCorrectlyReceived($_message, $_eventCount) {
|
||||
// Have end of list event. Check with number of events received and send true if match.
|
||||
// Remove 9 for the lines in the list start and end, and the 2 blank lines.
|
||||
if ($this->getKey('listitems') === substr_count( $_message, "\n") -11) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
class ExtensionStateListComplete_Event extends ClosingEvent
|
||||
{
|
||||
public function listCorrectlyReceived($_message, $_eventCount){
|
||||
// Have end of list event. Check with number of events received and send true if match.
|
||||
// Remove 1 as the closing event is included in the count.
|
||||
if ($this->getKey('listitems') === $_eventCount -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class SCCPShowSoftKeySetsComplete_Event extends ClosingEvent
|
||||
{
|
||||
public function listCorrectlyReceived($_message, $_eventCount){
|
||||
// Have the end of list event. Check the number of lines received and
|
||||
// return true if match. Remove 8 for the complete event.
|
||||
if ($this->getKey('listitems') === substr_count( $_message, "\n") -11) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,428 +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\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 __construct()
|
||||
{
|
||||
$this->lines = array();
|
||||
$this->variables = array();
|
||||
$this->keys = array();
|
||||
$this->createdDate = time();
|
||||
}
|
||||
|
||||
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;
|
||||
} elseif (is_numeric($value)) {
|
||||
$prefered_type = 'numeric';
|
||||
} elseif (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;
|
||||
} elseif (filter_var($value, FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE)) {
|
||||
return (string) $value;
|
||||
} elseif (filter_var($value, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_NULL_ON_FAILURE)) {
|
||||
return (string) htmlspecialchars($value, ENT_QUOTES);
|
||||
} else {
|
||||
throw new AMIException("Incoming String is not sanitary. Skipping: '" . $value . "'\n");
|
||||
}
|
||||
break;
|
||||
case 'numeric':
|
||||
if (!isset($value) || $value === null || strlen($value) == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (filter_var($value, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX | FILTER_FLAG_ALLOW_OCTAL)) {
|
||||
return intval($value, 0);
|
||||
} elseif (filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND | FILTER_FLAG_ALLOW_SCIENTIFIC)) {
|
||||
return (float) $value;
|
||||
} else {
|
||||
return (double) $value;
|
||||
}
|
||||
default:
|
||||
throw new AMIException("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');
|
||||
}
|
||||
}
|
||||
|
||||
abstract class IncomingMessage extends Message
|
||||
{
|
||||
|
||||
protected $rawContent;
|
||||
|
||||
public function getEventList()
|
||||
{
|
||||
return $this->getKey('EventList');
|
||||
}
|
||||
|
||||
public function getRawContent()
|
||||
{
|
||||
return $this->rawContent;
|
||||
}
|
||||
|
||||
public function isComplete()
|
||||
{
|
||||
return $this->_completed;
|
||||
}
|
||||
|
||||
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("Generic");
|
||||
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("SCCPJSON");
|
||||
}
|
||||
}
|
|
@ -1,429 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* Response class definitions
|
||||
*
|
||||
*/
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
// ************************************************************************** Response *********************************************
|
||||
|
||||
abstract class Response extends IncomingMessage
|
||||
{
|
||||
|
||||
protected $_events;
|
||||
protected $_completed;
|
||||
protected $keys;
|
||||
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
|
||||
parent::__construct($rawContent);
|
||||
$this->_events = array();
|
||||
// this logic is false - even if we have an error, we will not get anymore data, so is completed.
|
||||
$this->_completed = $this->isSuccess();
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
$ret = parent::__sleep();
|
||||
$ret[] = '_completed';
|
||||
$ret[] = '_events';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getEvents()
|
||||
{
|
||||
return $this->_events;
|
||||
}
|
||||
public function getClosingEvent() {
|
||||
return $this->_events['ClosingEvent'];
|
||||
}
|
||||
public function removeClosingEvent() {
|
||||
unset($this->_events['ClosingEvent']);
|
||||
}
|
||||
public function getCountOfEvents() {
|
||||
return count($this->_events);
|
||||
}
|
||||
|
||||
public function isSuccess()
|
||||
{
|
||||
// returns true if response message does not contain error
|
||||
return stristr($this->getKey('Response'), 'Error') === false;
|
||||
}
|
||||
|
||||
public function isList()
|
||||
{
|
||||
if ($this->getKey('EventList') === 'start' ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class GenericResponse extends Response
|
||||
{
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// There are two types of Response messages returned by AMI
|
||||
// Self contained responses which include any data requested;
|
||||
// List Responses which contain the data in event messages that follow
|
||||
// the response message.Response and Event
|
||||
// Following are the self contained Response classes.
|
||||
//****************************************************************************
|
||||
|
||||
class Generic_Response extends Response
|
||||
{
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
// Only used for self contained responses.
|
||||
parent::__construct($rawContent);
|
||||
// add dummy closing event
|
||||
$this->_events['ClosingEvent'] = new ResponseComplete_Event($rawContent);
|
||||
$this->_completed = true;
|
||||
$this->eventListIsCompleted = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Login_Response extends Generic_Response
|
||||
{
|
||||
}
|
||||
|
||||
class Command_Response extends Generic_Response
|
||||
{
|
||||
private $_temptable;
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
$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 'actionid':
|
||||
$this->_temptable['ActionID'] = trim($content[1]);
|
||||
break;
|
||||
case 'response':
|
||||
$this->_temptable['Response'] = trim($content[1]);
|
||||
break;
|
||||
case 'privilege':
|
||||
$this->_temptable['Privilege'] = trim($content[1]);
|
||||
break;
|
||||
case 'output':
|
||||
// included for backward compatibility with earlier versions of chan_sccp_b. AMI api does not precede command output with Output
|
||||
$this->_temptable['Output'] = explode(PHP_EOL,str_replace(PHP_EOL.'--END COMMAND--', '',trim($content[1])));
|
||||
break;
|
||||
default:
|
||||
$this->_temptable['Output'] = explode(PHP_EOL,str_replace(PHP_EOL.'--END COMMAND--', '', trim($line)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getResult()
|
||||
{
|
||||
return $this->_temptable;
|
||||
}
|
||||
}
|
||||
|
||||
class SCCPJSON_Response extends Generic_Response
|
||||
{
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
parent::__construct($rawContent);
|
||||
$this->getVariable($rawContent, array("DataType" => "DataType:", "JSONRAW" => "JSON:"));
|
||||
if (null !== $this->getKey('JSONRAW')) {
|
||||
$this->setKey('Response', 'Success');
|
||||
}
|
||||
}
|
||||
public function getResult()
|
||||
{
|
||||
if (($json = json_decode($this->getKey('JSON'), true)) != false) {
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************//
|
||||
// Following are the Response classes where the data is contained in a series.
|
||||
// of event messages.
|
||||
|
||||
class SCCPGeneric_Response extends Response
|
||||
{
|
||||
protected $_tables;
|
||||
private $_temptable;
|
||||
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
parent::__construct($rawContent);
|
||||
// Confirm that there is a list following. This overrides any setting
|
||||
// made in one of the parent constructs.
|
||||
$this->_completed = !$this->isList();
|
||||
}
|
||||
|
||||
public function addEvent($event)
|
||||
{
|
||||
// Start of list is handled by the isList function in the Constructor
|
||||
// which also defines the list end event
|
||||
|
||||
if ( empty($thisSetEventEntryType)) {
|
||||
// This is empty as soon as we have received a TableStart.
|
||||
// The next message is the first of the data sets
|
||||
// We use this variable in the switch to add set entries
|
||||
if (strpos($event->getName(), 'Entry')) {
|
||||
$thisSetEventEntryType = $event->getName();
|
||||
} else {
|
||||
$thisSetEventEntryType = 'undefinedAsThisIsNotASet';
|
||||
}
|
||||
}
|
||||
// Unknown events will cause an exception.
|
||||
// All event classes must be defined within Event.class.
|
||||
if (get_class($event) === 'FreePBX\modules\Sccp_manager\aminterface\UnknownEvent') {
|
||||
$this->_events[] = $event;
|
||||
return;
|
||||
}
|
||||
switch ( $event->getName()) {
|
||||
case $thisSetEventEntryType :
|
||||
$this->_temptable['Entries'][] = $event;
|
||||
break;
|
||||
case 'TableStart':
|
||||
//initialise
|
||||
$this->_temptable = array();
|
||||
$this->_temptable['Name'] = $event->getTableName();
|
||||
$this->_temptable['Entries'] = array();
|
||||
$thisSetEventEntryType = '';
|
||||
break;
|
||||
case 'TableEnd':
|
||||
//Close
|
||||
if (!is_array($this->_tables)) {
|
||||
$this->_tables = array();
|
||||
}
|
||||
$this->_tables[$event->getTableName()] = $this->_temptable;
|
||||
$this->_temptable = array();
|
||||
$thisSetEventEntryType = 'undefinedAsThisIsNotASet';
|
||||
|
||||
// Finished the table. Now check to see if everything was received
|
||||
// If counts do not match return false and table will not be
|
||||
//loaded
|
||||
if ($event->getKey('TableEntries') != count($this->_tables[$event->getTableName()]['Entries'])) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
//case $eventListEndEvent;
|
||||
case $this->getKey('eventListEndEvent');
|
||||
// Have the list end event. The correct number of entries is verified in the event constructor
|
||||
$this->_events['ClosingEvent'] = $event;
|
||||
$this->eventListEndEvent = null;
|
||||
//return $this->_completed = true;
|
||||
break;
|
||||
default:
|
||||
// add regular list event
|
||||
$this->_events[] = $event;
|
||||
}
|
||||
}
|
||||
|
||||
protected function ConvertTableData( $_tablename, array $_fkey, array $_fields)
|
||||
{
|
||||
$result = array();
|
||||
$_rawtable = $this->Table2Array($_tablename);
|
||||
// Check that there is actually data to be converted
|
||||
if (empty($_rawtable)) { return $result;}
|
||||
foreach ($_rawtable as $_row) {
|
||||
$all_key_ok = true;
|
||||
// No need to test if $_fkey is array as array required
|
||||
foreach ($_fkey as $_fid) {
|
||||
if (empty($_row[$_fid])) {
|
||||
$all_key_ok = false;
|
||||
} else {
|
||||
$set_name[$_fid] = $_row[$_fid];
|
||||
}
|
||||
}
|
||||
$Data = &$result;
|
||||
|
||||
if ($all_key_ok) {
|
||||
foreach ($set_name as $value_id) {
|
||||
$Data = &$Data[$value_id];
|
||||
}
|
||||
// Label converter in case labels and keys are different
|
||||
foreach ($_fields as $value_key => $value_id) {
|
||||
$Data[$value_id] = $_row[$value_key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function ConvertEventData(array $_fkey, array $_fields)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($this->_events as $_row) {
|
||||
$all_key_ok = true;
|
||||
$tmp_result = $_row->getKeys();
|
||||
$set_name = array();
|
||||
// No need to test if $_fkey is arrray as array required
|
||||
foreach ($_fkey as $_fid) {
|
||||
if (empty($tmp_result[$_fid])) {
|
||||
$all_key_ok = false;
|
||||
} else {
|
||||
$set_name[$_fid] = $tmp_result[$_fid];
|
||||
}
|
||||
}
|
||||
$Data = &$result;
|
||||
if ($all_key_ok) {
|
||||
foreach ($set_name as $value_id) {
|
||||
$Data = &$Data[$value_id];
|
||||
}
|
||||
// Label converter in case labels and keys are different - not actually required.
|
||||
foreach ($_fields as $value_id) {
|
||||
$Data[$value_id] = $tmp_result[$value_id];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function Table2Array( $tablename )
|
||||
{
|
||||
$result =array();
|
||||
if (empty($tablename) || !is_array($this->_tables)) {
|
||||
return $result;
|
||||
}
|
||||
foreach ($this->_tables[$tablename]['Entries'] as $trow) {
|
||||
$result[]= $trow->getKeys();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getResult()
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class SCCPShowSoftkeySets_Response extends SCCPGeneric_Response
|
||||
{
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
parent::__construct($rawContent);
|
||||
$this->setKey('eventlistendevent', 'SCCPShowSoftKeySetsComplete');
|
||||
}
|
||||
public function getResult()
|
||||
{
|
||||
return $this->ConvertTableData(
|
||||
'SoftKeySets',
|
||||
array('set','mode'),
|
||||
array('description'=>'description','label'=>'label','lblid'=>'lblid')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SCCPShowDevices_Response extends SCCPGeneric_Response
|
||||
{
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
parent::__construct($rawContent);
|
||||
$this->setKey('eventlistendevent', 'SCCPShowDevicesComplete');
|
||||
}
|
||||
public function getResult()
|
||||
{
|
||||
return $this->ConvertTableData(
|
||||
'Devices',
|
||||
array('mac'),
|
||||
array('mac'=>'name','address'=>'address','descr'=>'descr','regstate'=>'status',
|
||||
'token'=>'token','act'=>'act', 'lines'=>'lines','nat'=>'nat','regtime'=>'regtime')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SCCPShowDevice_Response extends SCCPGeneric_Response
|
||||
{
|
||||
public function __construct($rawContent)
|
||||
{
|
||||
parent::__construct($rawContent);
|
||||
$this->setKey('eventlistendevent', 'SCCPShowDeviceComplete');
|
||||
}
|
||||
public function getResult()
|
||||
{
|
||||
// This object has a list of events _events, and a list of tables _tables.
|
||||
$result = array();
|
||||
|
||||
foreach ($this->_events as $trow) {
|
||||
$result = array_merge($result, $trow->getKeys());
|
||||
}
|
||||
// Now handle label changes so that keys from AMI correspond to db keys in _tables
|
||||
$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(
|
||||
'SpeeddialButtons',
|
||||
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);
|
||||
$this->setKey('eventlistendevent', 'ExtensionStateListComplete');
|
||||
}
|
||||
public function getResult()
|
||||
{
|
||||
$result = $this->ConvertEventData(array('exten','context'), array('exten','context','hint','status','statustext'));
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -1,520 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class aminterface
|
||||
{
|
||||
|
||||
var $_socket;
|
||||
var $_error;
|
||||
var $_config;
|
||||
var $_test;
|
||||
private $_connect_state;
|
||||
private $_lastActionClass;
|
||||
private $_lastActionId;
|
||||
private $_lastRequestedResponseHandler;
|
||||
private $_ProcessingMessage;
|
||||
private $_DumpMessage;
|
||||
private $debug_level = 1;
|
||||
private $_incomingRawMessage;
|
||||
private $eventListEndEvent;
|
||||
|
||||
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__ . "/amInterfaceClasses/" . $value;
|
||||
if (!class_exists($class, false)) {
|
||||
if (file_exists($driver)) {
|
||||
include(__DIR__ . "/amInterfaceClasses/" . $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' => true
|
||||
);
|
||||
$this->_eventListeners = array();
|
||||
$this->_incomingMsgObjectList = array();
|
||||
$this->_lastActionId = false;
|
||||
$this->_incomingRawMessage = array();
|
||||
$this->eventListEndEvent = '';
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
if ($this->_config['enabled']) {
|
||||
// Ami is not hard disabled in __construct line 63.
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 socket 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);
|
||||
}
|
||||
/*
|
||||
* Send action message to ami, and wait for Response
|
||||
*/
|
||||
public function send($message)
|
||||
{
|
||||
$_incomingRawMessage = array();
|
||||
$messageToSend = $message->serialize();
|
||||
$length = strlen($messageToSend);
|
||||
$this->_DumpMessage = '';
|
||||
$this->_lastActionId = $message->getActionID();
|
||||
$this->_lastRequestedResponseHandler = $message->getResponseHandler();
|
||||
$this->_lastActionClass = $message;
|
||||
$this->_incomingRawMessage[$this->_lastActionId] = '';
|
||||
$this->eventListIsCompleted = array();
|
||||
if (@fwrite($this->_socket, $messageToSend) < $length) {
|
||||
$this->_errorException('Could not send message');
|
||||
return false;
|
||||
}
|
||||
// Have sent a message and now have to wait for and read the reply
|
||||
// The below infinite loop waits for $this->completed to be true.
|
||||
// The loop calls readBuffer, which calls GetMessages, which calls Process
|
||||
// This loop then continues until we have _thisComplete as an object variable
|
||||
$this->eventListIsCompleted[$this->_lastActionId] = false;
|
||||
while (true) {
|
||||
stream_set_timeout($this->_socket, 1);
|
||||
$this->readBuffer();
|
||||
$info = stream_get_meta_data($this->_socket);
|
||||
if ($info['timed_out'] == true) {
|
||||
$this->_errorException("Read waittime: " . ($this->socket_param['timeout']) . " exceeded (timeout).\n");
|
||||
return false;
|
||||
}
|
||||
if ($this->eventListIsCompleted[$this->_lastActionId]) {
|
||||
$response = $this->_incomingMsgObjectList[$this->_lastActionId];
|
||||
// need to test that the list was successfully completed here
|
||||
$allReceived = $response->getClosingEvent()
|
||||
->listCorrectlyReceived($this->_incomingRawMessage[$this->_lastActionId],
|
||||
$response->getCountOfEvents());
|
||||
// now tidy up removing any temp variables or objects
|
||||
$response->removeClosingEvent();
|
||||
unset($_incomingRawMessage[$this->_lastActionId]);
|
||||
unset($this->_incomingMsgObjectList[$this->_lastActionId]);
|
||||
unset($this->_lastActionId);
|
||||
if ($allReceived) {
|
||||
return $response;
|
||||
}
|
||||
// Something is missing from the events list received via AMI, or
|
||||
// the control parameter at the end of the list has changed.
|
||||
// This will cause an exception as returning a boolean instead of a Response
|
||||
// Maybe should handle better, but
|
||||
// need to break out of the loop as nothing more coming.
|
||||
try {
|
||||
throw new \invalidArgumentException("Counts do not match on returned AMI Result");
|
||||
} catch ( \invalidArgumentException $e) {
|
||||
echo substr(strrchr(get_class($response), '\\'), 1), " ", $e->getMessage(), "\n";
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function readBuffer ()
|
||||
{
|
||||
$read = @fread($this->_socket, 65535);
|
||||
// AMI never returns EOF
|
||||
if ($read === false ) {
|
||||
$this->_errorException('Error reading');
|
||||
}
|
||||
// Do not return empty Messages
|
||||
while ($read == "" ) {
|
||||
$read = @fread($this->_socket, 65535);
|
||||
}
|
||||
// Add read to the rest of buffer from previous read
|
||||
$this->_ProcessingMessage .= $read;
|
||||
$this->getMessages();
|
||||
}
|
||||
|
||||
protected function getMessages()
|
||||
{
|
||||
$msgs = array();
|
||||
// Extract any complete messages and leave remainder for next 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;
|
||||
}
|
||||
$this->process($msgs);
|
||||
}
|
||||
|
||||
public function process(array $msgs)
|
||||
{
|
||||
foreach ($msgs as $aMsg) {
|
||||
// 2 types of message; Response or Event. Response only incudes data
|
||||
// for JSON response and Command response. All other responses expect
|
||||
// data in an event list - these events need to be attached to the response.
|
||||
$resPos = strpos($aMsg, 'Response: '); // Have a Response message. This may not be 0.
|
||||
$evePos = strpos($aMsg, 'Event: '); // Have an Event Message. This should always be 0.
|
||||
// Add the incoming message to a string that can be checked
|
||||
// against the completed message event when it is received.
|
||||
$this->_incomingRawMessage[$this->_lastActionId] .= "\r\n\r\n" . $aMsg;
|
||||
if (($resPos !== false) && (($resPos < $evePos) || $evePos === false)) {
|
||||
$response = $this->_responseObjFromMsg($aMsg); // resp Ok
|
||||
$this->eventListEndEvent = $response->getKey('eventlistendevent');
|
||||
$this->_incomingMsgObjectList[$this->_lastActionId] = $response;
|
||||
$this->eventListIsCompleted[$this->_lastActionId] = $response->isComplete();
|
||||
} elseif ($evePos === 0) { // Event must be at the start of the msg.
|
||||
$event = $this->_eventObjFromMsg($aMsg); // Event Ok
|
||||
$this->eventListIsCompleted[$this->_lastActionId] = $event->isComplete();
|
||||
$this->_incomingMsgObjectList[$this->_lastActionId]->addEvent($event);
|
||||
} else {
|
||||
// broken ami most probably through changes in chan_sccp_b.
|
||||
// AMI is sending a message which is neither a response nor an event.
|
||||
$this->_msgToDebug(1, 'resp broken ami');
|
||||
$bMsg = 'Event: ResponseEvent' . "\r\n";
|
||||
$bMsg .= 'ActionId: ' . $this->_lastActionId . "\r\n" . $aMsg;
|
||||
$event = $this->_eventObjFromMsg($bMsg);
|
||||
$this->_incomingMsgObjectList[$this->_lastActionId]->addEvent($event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _msgToDebug($level, $msg)
|
||||
{
|
||||
if ($level > $this->debug_level) {
|
||||
return;
|
||||
}
|
||||
print_r('<br> level: '.$level.' ');
|
||||
print_r($msg);
|
||||
print_r('<br>');
|
||||
}
|
||||
|
||||
private function _responseObjFromMsg($message)
|
||||
{
|
||||
$_className = false;
|
||||
|
||||
$responseClass = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\Generic_Response';
|
||||
if ($this->_lastRequestedResponseHandler != false) {
|
||||
$_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . $this->_lastRequestedResponseHandler . '_Response';
|
||||
}
|
||||
if ($_className) {
|
||||
if (class_exists($_className, true)) {
|
||||
$responseClass = $_className;
|
||||
} elseif ($responseHandler != false) {
|
||||
$this->_errorException('Response Class ' . $_className . ' requested via responseHandler, could not be found');
|
||||
}
|
||||
}
|
||||
$response = new $responseClass($message);
|
||||
$actionId = $response->getActionID();
|
||||
if ($actionId === null) {
|
||||
$response->setActionId($this->_lastActionId);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
public function _eventObjFromMsg($message)
|
||||
{
|
||||
$eventType = explode(aminterface\Message::EOL,$message,2);
|
||||
$name = trim(explode(':',$eventType[0],2)[1]);
|
||||
$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);
|
||||
}
|
||||
|
||||
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);
|
||||
} elseif (is_array($listener)) {
|
||||
$listener[0]->$listener[1]($message);
|
||||
} else {
|
||||
$listener->handle($message);
|
||||
}
|
||||
}
|
||||
print_r("<br>------------E dispatch----------<br>");
|
||||
}
|
||||
//-------------------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();
|
||||
$_res = $this->send($_action)->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();
|
||||
$_res = $this->send($_action)->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();
|
||||
$result = $this->send($_action)->getResult();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function sccp_getdevice_info($devicename)
|
||||
{
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDeviceAction($devicename);
|
||||
$result = $this->send($_action)->getResult();
|
||||
$result['MAC_Address'] = $result['macaddress'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function sccpDeviceReset($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');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//------------------- Core Comands ----
|
||||
function core_sccp_reload()
|
||||
{
|
||||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\ReloadAction('chan_sccp');
|
||||
$result = ['Response' => $this->send($_action)->getMessage(), 'data' => ''];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function getSCCPVersion()
|
||||
{
|
||||
//Initialise result array
|
||||
$result = array( 'RevisionHash' => '', 'vCode' => 0, 'RevisionNum' => 0, 'futures' => '', 'Version' => 0);
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPConfigMetaDataAction();
|
||||
$metadata = $this->send($_action)->getResult();
|
||||
}
|
||||
|
||||
if (isset($metadata['Version'])) {
|
||||
$result['Version'] = $metadata['Version'];
|
||||
$version_parts = explode('.', $metadata['Version']);
|
||||
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;
|
||||
if($version_parts[2] == 3){
|
||||
$result['vCode'] = 433;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$result['vCode'] = 400;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("RevisionHash", $metadata)) {
|
||||
$result['RevisionHash'] = $metadata["RevisionHash"];
|
||||
}
|
||||
if (isset($metadata['RevisionNum'])) {
|
||||
if ($metadata['RevisionNum'] >= 11063) { // new method, RevisionNum is incremental
|
||||
$result['vCode'] = 433;
|
||||
}
|
||||
$result['RevisionNum'] = $metadata["RevisionNum"];
|
||||
}
|
||||
if (isset($metadata['ConfigureEnabled'])) {
|
||||
$result['futures'] = implode(';', $metadata['ConfigureEnabled']);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getRealTimeStatus()
|
||||
{
|
||||
// Initialise array with default values to eliminate testing later
|
||||
$result = array();
|
||||
$cmd_res = array();
|
||||
$cmd_res = ['sccp' => ['message' => 'default value', 'realm' => '', 'status' => 'ERROR']];
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\CommandAction('realtime mysql status');
|
||||
$result = $this->send($_action)->getResult();
|
||||
}
|
||||
if (is_array($result['Output'])) {
|
||||
foreach ($result['Output'] as $aline) {
|
||||
if (strlen($aline) > 3) {
|
||||
$temp_strings = explode(' ', $aline);
|
||||
$cmd_res_key = $temp_strings[0];
|
||||
foreach ($temp_strings as $test_string) {
|
||||
if (strpos($test_string, '@')) {
|
||||
$this_realm = $test_string;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$cmd_res[$cmd_res_key] = array('message' => $aline, 'realm' => $this_realm, 'status' => strpos($aline, 'connected') ? 'OK' : 'ERROR');
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ($res['RevisionNum'] < 11063) {
|
||||
$this->useAmiInterface = false;
|
||||
}
|
||||
if ($revNumComp) {
|
||||
return array($res['vCode'], true);
|
||||
}
|
||||
return $res['vCode'];
|
||||
}
|
||||
}
|
|
@ -1,391 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class dbinterface
|
||||
{
|
||||
|
||||
private $val_null = 'NONE'; /// REPLACE to null Field
|
||||
|
||||
public function __construct($parent_class = null)
|
||||
{
|
||||
$this->paren_class = $parent_class;
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
$Ver = '13.0.2'; // This should be updated
|
||||
return array('Version' => $Ver,
|
||||
'about' => 'Data access interface ver: ' . $Ver);
|
||||
}
|
||||
|
||||
/*
|
||||
* Core Access Function
|
||||
*/
|
||||
public function get_db_SccpTableByID($dataid, $data = array(), $indexField = '')
|
||||
{
|
||||
$result = array();
|
||||
$raw = $this->HWextension_db_SccpTableData($dataid, $data);
|
||||
if (empty($raw) || empty($indexField)) {
|
||||
return $raw;
|
||||
}
|
||||
foreach ($raw as $value) {
|
||||
$id = $value[$indexField];
|
||||
$result[$id] = $value;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function HWextension_db_SccpTableData($dataid, $data = array())
|
||||
{
|
||||
// $stmt is a single row fetch, $stmts is a fetchAll.
|
||||
$dbh = \FreePBX::Database();
|
||||
$stmt = '';
|
||||
$stmts = '';
|
||||
if ($dataid == '') {
|
||||
return false;
|
||||
}
|
||||
switch ($dataid) {
|
||||
case 'SccpExtension':
|
||||
if (empty($data['name'])) {
|
||||
$stmts = $dbh->prepare('SELECT * FROM sccpline ORDER BY name');
|
||||
} else {
|
||||
$stmts = $dbh->prepare('SELECT * FROM sccpline WHERE name = :name');
|
||||
$stmts->bindParam(':name', $data['name'],\PDO::PARAM_STR);
|
||||
}
|
||||
break;
|
||||
case 'SccpDevice':
|
||||
if (empty($data['fields'])) {
|
||||
$fld = 'name, name as mac, type, button, addon, _description as description';
|
||||
} else {
|
||||
switch ($data['fields']) {
|
||||
case "all":
|
||||
$fld ='*';
|
||||
break;
|
||||
case "sip_ext":
|
||||
$fld ='button as sip_lines, description as description, addon';
|
||||
break;
|
||||
default:
|
||||
$fld = $data['fields'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($data['name'])) { //either filter by name or by type
|
||||
$stmt = $dbh->prepare('SELECT ' . $fld . ' FROM sccpdeviceconfig WHERE name = :name ORDER BY name');
|
||||
$stmt->bindParam(':name', $data['name'],\PDO::PARAM_STR);
|
||||
} elseif (!empty($data['type'])) {
|
||||
switch ($data['type']) {
|
||||
case "cisco-sip":
|
||||
$stmts = $dbh->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE TYPE LIKE '%-sip' ORDER BY name");
|
||||
break;
|
||||
case "cisco": // Fall through to default intentionally
|
||||
default:
|
||||
$stmts = $dbh->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE TYPE not LIKE '%-sip' ORDER BY name");
|
||||
break;
|
||||
}
|
||||
} else { //no filter and no name provided - return all
|
||||
$stmts = $dbh->prepare("SELECT {$fld} FROM sccpdeviceconfig ORDER BY name");
|
||||
}
|
||||
break;
|
||||
case 'HWSipDevice':
|
||||
$raw_settings = $this->getDb_model_info($get = "sipphones", $format_list = "model");
|
||||
break;
|
||||
case 'HWDevice':
|
||||
$raw_settings = $this->getDb_model_info($get = "ciscophones", $format_list = "model");
|
||||
break;
|
||||
case 'HWextension':
|
||||
$raw_settings = $this->getDb_model_info($get = "extension", $format_list = "model");
|
||||
break;
|
||||
case 'get_columns_sccpdevice':
|
||||
$stmts = $dbh->prepare('DESCRIBE sccpdevice');
|
||||
break;
|
||||
case 'get_columns_sccpuser':
|
||||
$stmts = $dbh->prepare('DESCRIBE sccpuser');
|
||||
break;
|
||||
case 'get_sccpdevice_byid':
|
||||
$stmt = $dbh->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate,
|
||||
addon.buttons as addon_buttons FROM sccpdevice AS t1
|
||||
LEFT JOIN sccpdevmodel as types ON t1.type=types.model
|
||||
LEFT JOIN sccpdevmodel as addon ON t1.addon=addon.model WHERE name = :name');
|
||||
$stmt->bindParam(':name', $data['id'],\PDO::PARAM_STR);
|
||||
break;
|
||||
case 'get_sccpuser':
|
||||
$stmt = $dbh->prepare('SELECT * FROM sccpuser WHERE name = :name');
|
||||
$stmt->bindParam(':name', $data['id'],\PDO::PARAM_STR);
|
||||
break;
|
||||
case 'get_sccpdevice_buttons':
|
||||
$sql = '';
|
||||
if (!empty($data['buttontype'])) {
|
||||
$sql .= 'buttontype = :buttontype';
|
||||
}
|
||||
if (!empty($data['id'])) {
|
||||
$sql .= (empty($sql)) ? 'ref = :ref' : ' and ref = :ref';
|
||||
}
|
||||
if (!empty($sql)) {
|
||||
$stmts = $dbh->prepare("SELECT * FROM sccpbuttonconfig WHERE {$sql} ORDER BY instance");
|
||||
// Now bind labels - only bind label if it exists or bind will create exception.
|
||||
// can only bind once have prepared, so need to test again.
|
||||
if (!empty($data['buttontype'])) {
|
||||
$stmts->bindParam(':buttontype', $data['buttontype'],\PDO::PARAM_STR);
|
||||
}
|
||||
if (!empty($data['id'])) {
|
||||
$stmts->bindParam(':ref', $data['id'],\PDO::PARAM_STR);
|
||||
}
|
||||
} else {
|
||||
$raw_settings = array();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!empty($stmt)) {
|
||||
$stmt->execute();
|
||||
$raw_settings = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
} elseif (!empty($stmts)) {
|
||||
$stmts->execute();
|
||||
$raw_settings = $stmts->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
return $raw_settings;
|
||||
}
|
||||
|
||||
public function get_db_SccpSetting()
|
||||
{
|
||||
$dbh = \FreePBX::Database();
|
||||
$stmt = $dbh->prepare('SELECT keyword, data, type, seq FROM sccpsettings ORDER BY type, seq');
|
||||
$stmt->execute();
|
||||
foreach ($stmt->fetchAll() as $var) {
|
||||
$mysccpvalues[$var['keyword']] = array('keyword' => $var['keyword'], 'data' => $var['data'], 'seq' => $var['seq'], 'type' => $var['type']);
|
||||
}
|
||||
return $mysccpvalues;
|
||||
}
|
||||
|
||||
public function get_db_sysvalues()
|
||||
{
|
||||
$dbh = \FreePBX::Database();
|
||||
$stmt = $dbh->prepare('SHOW VARIABLES LIKE \'%group_concat%\'');
|
||||
$stmt->execute();
|
||||
return $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get Sccp Device Model information
|
||||
*/
|
||||
|
||||
function getDb_model_info($get = 'all', $format_list = 'all', $filter = array())
|
||||
{
|
||||
$dbh = \FreePBX::Database();
|
||||
$sel_inf = '*, 0 as validate';
|
||||
if ($format_list === 'model') {
|
||||
$sel_inf = 'model, vendor, dns, buttons, 0 as validate';
|
||||
}
|
||||
switch ($get) {
|
||||
case 'byciscoid':
|
||||
if (!empty($filter)) {
|
||||
if (!empty($filter['model'])) {
|
||||
if (!strpos($filter['model'], 'loadInformation')) {
|
||||
$filter['model'] = 'loadInformation' . $filter['model'];
|
||||
}
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (loadinformationid = :model ) ORDER BY model");
|
||||
$stmt->bindParam(':model', $filter['model'], \PDO::PARAM_STR);
|
||||
} else {
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'byid':
|
||||
if (!empty($filter)) {
|
||||
if (!empty($filter['model'])) {
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE model = :model ORDER BY model");
|
||||
$stmt->bindParam(':model', $filter['model'],\PDO::PARAM_STR);
|
||||
} else {
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'extension':
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model");
|
||||
break;
|
||||
case 'enabled':
|
||||
//$stmt = $db->prepare('SELECT ' . {$sel_inf} . ' FROM sccpdevmodel WHERE enabled = 1 ORDER BY model'); //previously this fell through to phones.
|
||||
//break; // above includes expansion modules but was not original behaviour so commented out. Falls through to phones.
|
||||
case 'phones':
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) ORDER BY model");
|
||||
break;
|
||||
case 'ciscophones':
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor NOT LIKE '%-sip' ORDER BY model");
|
||||
break;
|
||||
case 'sipphones':
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor LIKE '%-sip' ORDER BY model");
|
||||
break;
|
||||
case 'all': // Fall through to default
|
||||
default:
|
||||
$stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
|
||||
break;
|
||||
}
|
||||
$stmt->execute();
|
||||
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
function write($table_name = "", $save_value = array(), $mode = 'update', $key_fld = "", $hwid = "")
|
||||
{
|
||||
// mode clear - Empty table before update
|
||||
// mode update - update / replace record
|
||||
$dbh = \FreePBX::Database();
|
||||
$result = false;
|
||||
$delete_value = array();
|
||||
switch ($table_name) {
|
||||
case 'sccpsettings':
|
||||
if ($mode == 'replace') { // Change mode name to be more transparent
|
||||
$dbh->prepare('TRUNCATE sccpsettings')->execute();
|
||||
$stmt = $dbh->prepare('INSERT INTO sccpsettings (keyword, data, seq, type) VALUES (:keyword,:data,:seq,:type)');
|
||||
} else {
|
||||
$stmt = $dbh->prepare('REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES (:keyword,:data,:seq,:type)');
|
||||
}
|
||||
foreach ($save_value as $key => $dataArr) {
|
||||
if (!empty($dataArr) && isset($dataArr['data'])) {
|
||||
if ($dataArr['data'] == $this->val_null) {
|
||||
$delete_value[] = $save_value[$key]['keyword'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$stmt->bindParam(':keyword',$dataArr['keyword'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':data',$dataArr['data'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':seq',$dataArr['seq'],\PDO::PARAM_INT);
|
||||
$stmt->bindParam(':type',$dataArr['type'],\PDO::PARAM_INT);
|
||||
$result = $stmt->execute();
|
||||
}
|
||||
if (!empty($delete_value)) {
|
||||
$stmt = $dbh->prepare('DELETE FROM sccpsettings WHERE keyword = :keyword');
|
||||
foreach ($delete_value as $del_key) {
|
||||
$stmt->bindParam(':keyword',$del_key,\PDO::PARAM_STR);
|
||||
$result = $stmt->execute();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'sccpdevmodel': // Fall through to next intentionally
|
||||
case 'sccpdevice': // Fall through to next intentionally
|
||||
case 'sccpuser':
|
||||
$sql_key = "";
|
||||
$sql_var = "";
|
||||
foreach ($save_value as $key_v => $data) {
|
||||
if (!empty($sql_var)) {
|
||||
$sql_var .= ', ';
|
||||
}
|
||||
if ($data === $this->val_null) {
|
||||
$sql_var .= $key_v . '= NULL';
|
||||
} else {
|
||||
$sql_var .= $key_v . ' = \'' . $data . '\''; //quote data as normally is string
|
||||
}
|
||||
if ($key_v === $key_fld) {
|
||||
$sql_key = $key_v . ' = \'' . $data . '\''; //quote data as normally is string
|
||||
}
|
||||
}
|
||||
if (!empty($sql_var)) {
|
||||
switch ($mode) {
|
||||
case 'delete':
|
||||
$stmt = $dbh->prepare("DELETE FROM {$table_name} WHERE {$sql_key}");
|
||||
break;
|
||||
case 'update':
|
||||
$stmt = $dbh->prepare("UPDATE {$table_name} SET {$sql_var} WHERE {$sql_key}");
|
||||
break;
|
||||
case 'replace':
|
||||
$stmt = $dbh->prepare("REPLACE INTO {$table_name} SET {$sql_var}");
|
||||
break;
|
||||
// no default mode - must be explicit.
|
||||
}
|
||||
}
|
||||
$result = $stmt->execute();
|
||||
break;
|
||||
case 'sccpbuttons':
|
||||
switch ($mode) {
|
||||
case 'delete':
|
||||
$sql = 'DELETE FROM sccpbuttonconfig WHERE ref = :hwid';
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->bindParam(':hwid', $hwid,\PDO::PARAM_STR);
|
||||
$result = $stmt->execute();
|
||||
break;
|
||||
case 'replace':
|
||||
foreach ($save_value as $button_array) {
|
||||
$stmt = $dbh->prepare('UPDATE sccpbuttonconfig SET name =:name WHERE ref = :ref AND reftype =:reftype AND instance = :instance AND buttontype = :buttontype');
|
||||
$stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
|
||||
$stmt->bindParam(':buttontype', $button_array['type'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
|
||||
$result= $dbh->execute();
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
foreach ($save_value as $button_array) {
|
||||
$stmt = $dbh->prepare('INSERT INTO sccpbuttonconfig (ref, reftype, instance, buttontype, name, options) VALUES (:ref, :reftype, :instance, :buttontype, :name, :options)');
|
||||
$stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
|
||||
$stmt->bindParam(':buttontype', $button_array['type'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
|
||||
$stmt->bindParam(':options', $button_array['options'],\PDO::PARAM_STR);
|
||||
$result = $stmt->execute();
|
||||
}
|
||||
break;
|
||||
case 'clear';
|
||||
// Clear is equivalent of delete + insert.
|
||||
$this->write('sccpbuttons', '', $mode = 'delete','', $hwid);
|
||||
$this->write('sccpbuttons', $save_value, $mode = 'add','', $hwid);
|
||||
break;
|
||||
// No default case - must be specific in request.
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Maybe Replace by SccpTables ??!
|
||||
*
|
||||
*/
|
||||
public function dump_sccp_tables($data_path, $database, $user, $pass)
|
||||
{
|
||||
$filename = $data_path.'/sccp_backup_'.date('G_a_m_d_y').'.sql';
|
||||
$result = exec('mysqldump '.$database.' --password='.$pass.' --user='.$user.' --single-transaction >'.$filename, $output);
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check Table structure
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
$dbh = \FreePBX::Database();
|
||||
$result = 0;
|
||||
$check_fields = [
|
||||
'430' => ['_hwlang' => "varchar(12)"],
|
||||
'431' => ['private'=> "enum('on','off')"],
|
||||
'433' => ['directed_pickup'=>'']
|
||||
];
|
||||
$stmt = $dbh->prepare('DESCRIBE sccpdevice');
|
||||
$stmt->execute();
|
||||
foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $value) {
|
||||
$id_result[$value['Field']] = $value['Type'];
|
||||
}
|
||||
foreach ($check_fields as $key => $value) {
|
||||
if (!empty(array_intersect_assoc($value, $id_result))) {
|
||||
$result = $key;
|
||||
} else {
|
||||
// no match but maybe checking against an empty string so just need to check key does not exist
|
||||
foreach ($value as $skey => $svalue) {
|
||||
if (empty($svalue) && (!isset($id_result[$skey]))) {
|
||||
$result = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -1,505 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class extconfigs
|
||||
{
|
||||
|
||||
public function __construct($parent_class = null)
|
||||
{
|
||||
$this->paren_class = $parent_class;
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
$Ver = '13.0.3';
|
||||
return array('Version' => $Ver,
|
||||
'about' => 'Default Setings and Enums ver: ' . $Ver);
|
||||
}
|
||||
|
||||
public function getextConfig($id = '', $index = '')
|
||||
{
|
||||
switch ($id) {
|
||||
case 'keyset':
|
||||
$result = $this->keysetdefault;
|
||||
break;
|
||||
case 'sccp_lang':
|
||||
$result = $this->cisco_language;
|
||||
break;
|
||||
case 'sccpDefaults':
|
||||
$result = $this->sccpDefaults;
|
||||
break;
|
||||
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 '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'));
|
||||
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:
|
||||
return array('noId');
|
||||
break;
|
||||
}
|
||||
if (empty($index)) {
|
||||
return $result;
|
||||
} else {
|
||||
if (isset($result[$index])) {
|
||||
return $result[$index];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
"deny" => '0.0.0.0/0.0.0.0',
|
||||
"permit" => '0.0.0.0/0.0.0.0', # !TODO!: please change this to 'internal' which would mean:
|
||||
# permit:127.0.0.0/255.0.0.0,permit:10.0.0.0/255.0.0.0,permit:172.0.0.0/255.224.0.0,permit:192.168.0.0/255.255.0.0"
|
||||
"dateformat" => 'D.M.Y',
|
||||
"disallow" => 'all', "allow" => 'alaw;ulaw',
|
||||
"hotline_enabled" => 'off',
|
||||
"hotline_context" => 'default', # !TODO!: Should this not be from-internal on FreePBX ?
|
||||
"hotline_extension" => '*60', # !TODO!: Is this a good default extension to dial for hotline ?
|
||||
"hotline_label" => 'hotline',
|
||||
"devicetable" => 'sccpdevice',
|
||||
"linetable" => 'sccpline',
|
||||
"tftp_path" => '/tftpboot'
|
||||
);
|
||||
private $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,cfwdbusy,cfwdnoanswer,pickup,gpickup,dnd,private',
|
||||
'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert,monitor',
|
||||
'onhold' => 'resume,newcall,endcall,transfer,conflist,select,dirtrfr,idivert,meetme',
|
||||
'ringin' => 'answer,endcall,transvm,idivert',
|
||||
'offhook' => 'redial,endcall,private,cfwdall,cfwdbusy,cfwdnoanswer,pickup,gpickup,meetme,barg',
|
||||
'conntrans' => 'hold,endcall,transfer,conf,park,select,dirtrfr,monitor,vidmode,meetme,cfwdal',
|
||||
'digitsfoll' => 'back,endcall,dial',
|
||||
'connconf' => 'conflist,newcall,endcall,hold,vidmode,monitor',
|
||||
'ringout' => 'empty,endcall,transfer',
|
||||
'offhookfeat' => 'resume,newcall,endcall',
|
||||
'onhint' => 'redial,newcall,pickup,gpickup',
|
||||
'onstealable' => 'redial,newcall,barge,intrcpt,cfwdall,pickup,gpickup,dnd',
|
||||
'holdconf' => 'resume,newcall,endcall,join',
|
||||
'uriaction' => 'default');
|
||||
// Cisco Language Code / Directory
|
||||
//
|
||||
private $cisco_language = array('ar_SA' => array('code' => 'ar', 'language' => 'Arabic', 'locale' => 'Arabic_Saudi_Arabia', 'codepage' => 'ISO8859-1'),
|
||||
'bg_BG' => array('code' => 'bg', 'language' => 'Bulgarian', 'locale' => 'Bulgarian_Bulgaria', 'codepage' => 'ISO8859-1'),
|
||||
'cz_CZ' => array('code' => 'cz', 'language' => 'Czech', 'locale' => 'Czech_Czech_Republic', 'codepage' => 'ISO8859-1'),
|
||||
'da_DK' => array('code' => 'da', 'language' => 'Danish', 'locale' => 'Danish_Denmark', 'codepage' => 'ISO8859-1'),
|
||||
'de_DE' => array('code' => 'de', 'language' => 'German', 'locale' => 'German_Germany', 'codepage' => 'ISO8859-1'),
|
||||
'el_GR' => array('code' => 'el', 'language' => 'Greek', 'locale' => 'Greek_Greece', 'codepage' => 'ISO8859-1'),
|
||||
'en_AU' => array('code' => 'en', 'language' => 'English', 'locale' => 'AU_English_United_States', 'codepage' => 'ISO8859-1'),
|
||||
'en_GB' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_Kingdom', 'codepage' => 'ISO8859-1'),
|
||||
'en_US' => array('code' => 'en', 'language' => 'English', 'locale' => 'English_United_States', 'codepage' => 'ISO8859-1'),
|
||||
'es_ES' => array('code' => 'es', 'language' => 'Spanish', 'locale' => 'Spanish_Spain', 'codepage' => 'ISO8859-1'),
|
||||
'et_EE' => array('code' => 'et', 'language' => 'Estonian', 'locale' => 'Estonian_Estonia', 'codepage' => 'ISO8859-1'),
|
||||
'fi_FI' => array('code' => 'fi', 'language' => 'Finnish', 'locale' => 'Finnish_Finland', 'codepage' => 'ISO8859-1'),
|
||||
'fr_CA' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_Canada', 'codepage' => 'ISO8859-1'),
|
||||
'fr_FR' => array('code' => 'fr', 'language' => 'French', 'locale' => 'French_France', 'codepage' => 'ISO8859-1'),
|
||||
'he_IL' => array('code' => 'he', 'language' => 'Hebrew', 'locale' => 'Hebrew_Israel', 'codepage' => 'ISO8859-1'),
|
||||
'hr_HR' => array('code' => 'hr', 'language' => 'Croatian', 'locale' => 'Croatian_Croatia', 'codepage' => 'ISO8859-1'),
|
||||
'hu_HU' => array('code' => 'hu', 'language' => 'Hungarian', 'locale' => 'Hungarian_Hungary', 'codepage' => 'ISO8859-1'),
|
||||
'it_IT' => array('code' => 'it', 'language' => 'Italian', 'locale' => 'Italian_Italy', 'codepage' => 'ISO8859-1'),
|
||||
'ja_JP' => array('code' => 'ja', 'language' => 'Japanese', 'locale' => 'Japanese_Japan', 'codepage' => 'ISO8859-1'),
|
||||
'ko_KO' => array('code' => 'ko', 'language' => 'Korean', 'locale' => 'Korean_Korea_Republic', 'codepage' => 'ISO8859-1'),
|
||||
'lt_LT' => array('code' => 'lt', 'language' => 'Lithuanian', 'locale' => 'Lithuanian_Lithuania', 'codepage' => 'ISO8859-1'),
|
||||
'lv_LV' => array('code' => 'lv', 'language' => 'Latvian', 'locale' => 'Latvian_Latvia', 'codepage' => 'ISO8859-1'),
|
||||
'nl_NL' => array('code' => 'nl', 'language' => 'Dutch', 'locale' => 'Dutch_Netherlands', 'codepage' => 'ISO8859-1'),
|
||||
'no_NO' => array('code' => 'no', 'language' => 'Norwegian', 'locale' => 'Norwegian_Norway', 'codepage' => 'ISO8859-1'),
|
||||
'pl_PL' => array('code' => 'pl', 'language' => 'Polish', 'locale' => 'Polish_Poland', 'codepage' => 'ISO8859-1'),
|
||||
'pt_BR' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Brazil', 'codepage' => 'ISO8859-1'),
|
||||
'pt_PT' => array('code' => 'pt', 'language' => 'Portuguese', 'locale' => 'Portuguese_Portugal', 'codepage' => 'ISO8859-1'),
|
||||
'ro_RO' => array('code' => 'ro', 'language' => 'Romanian', 'locale' => 'Romanian_Romania', 'codepage' => 'ISO8859-1'),
|
||||
'ru_RU' => array('code' => 'ru', 'language' => 'Russian', 'locale' => 'Russian_Russian_Federation', 'codepage' => 'CP1251'),
|
||||
'sk_SK' => array('code' => 'sk', 'language' => 'Slovakian', 'locale' => 'Slovak_Slovakia', 'codepage' => 'ISO8859-1'),
|
||||
'sl_SL' => array('code' => 'sl', 'language' => 'Slovenian', 'locale' => 'Slovenian_Slovenia', 'codepage' => 'ISO8859-1'),
|
||||
'sr_ME' => array('code' => 'sr', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Montenegro', 'codepage' => 'ISO8859-1'),
|
||||
'sr_RS' => array('code' => 'rs', 'language' => 'Serbian', 'locale' => 'Serbian_Republic_of_Serbia', 'codepage' => 'ISO8859-1'),
|
||||
'sv_SE' => array('code' => 'sv', 'language' => 'Swedish', 'locale' => 'Swedish_Sweden', 'codepage' => 'ISO8859-1'),
|
||||
'th_TH' => array('code' => 'th', 'language' => 'Thailand', 'locale' => 'Thai_Thailand', 'codepage' => 'ISO8859-1'),
|
||||
'tr_TR' => array('code' => 'tr', 'language' => 'Turkish', 'locale' => 'Turkish_Turkey', 'codepage' => 'ISO8859-1'),
|
||||
'zh_CN' => array('code' => 'cn', 'language' => 'Chinese', 'locale' => 'Chinese_China', 'codepage' => 'ISO8859-1'),
|
||||
'zh_TW' => array('code' => 'zh', 'language' => 'Chinese', 'locale' => 'Chinese_Taiwan', 'codepage' => 'ISO8859-1')
|
||||
);
|
||||
private $cisco_timezone = array(
|
||||
'Dateline' => array('offset' => '-720', 'daylight' => ''),
|
||||
'Samoa' => array('offset' => '-660', 'daylight' => ''),
|
||||
'Hawaiian' => array('offset' => '-600', 'daylight' => ''),
|
||||
'Alaskan' => array('offset' => '-540', 'daylight' => 'Daylight'),
|
||||
'Pacific' => array('offset' => '-480', 'daylight' => 'Daylight'),
|
||||
'Mountain' => array('offset' => '-420', 'daylight' => 'Daylight'),
|
||||
'US Mountain' => array('offset' => '-420', 'daylight' => ''),
|
||||
'Central' => array('offset' => '-360', 'daylight' => 'Daylight'),
|
||||
'Mexico' => array('offset' => '-360', 'daylight' => 'Daylight'),
|
||||
'Canada Central' => array('offset' => '-360', 'daylight' => ''),
|
||||
'SA Pacific' => array('offset' => '-300', 'daylight' => ''),
|
||||
'Eastern' => array('offset' => '-300', 'daylight' => 'Daylight'),
|
||||
'US Eastern' => array('offset' => '-300', 'daylight' => ''),
|
||||
'Atlantic' => array('offset' => '-240', 'daylight' => 'Daylight'),
|
||||
'SA Western' => array('offset' => '-240', 'daylight' => ''),
|
||||
'Pacific SA' => array('offset' => '-240', 'daylight' => ''),
|
||||
'Newfoundland' => array('offset' => '-210', 'daylight' => 'Daylight'),
|
||||
'E. South America' => array('offset' => '-180', 'daylight' => 'Daylight'),
|
||||
'SA Eastern' => array('offset' => '-180', 'daylight' => ''),
|
||||
'Pacific SA' => array('offset' => '-180', 'daylight' => 'Daylight'),
|
||||
'Mid-Atlantic' => array('offset' => '-120', 'daylight' => 'Daylight'),
|
||||
'Azores' => array('offset' => '-060', 'daylight' => 'Daylight'),
|
||||
'GMT' => array('offset' => '00', 'daylight' => 'Daylight'),
|
||||
'Greenwich' => array('offset' => '00', 'daylight' => ''),
|
||||
'W. Europe' => array('offset' => '60', 'daylight' => 'Daylight'),
|
||||
'GTB' => array('offset' => '60', 'daylight' => 'Daylight'),
|
||||
'Egypt' => array('offset' => '60', 'daylight' => 'Daylight'),
|
||||
'E. Europe' => array('offset' => '60', 'daylight' => 'Daylight'),
|
||||
'Romance' => array('offset' => '120', 'daylight' => 'Daylight'),
|
||||
'Central Europe' => array('offset' => '120', 'daylight' => 'Daylight'),
|
||||
'South Africa' => array('offset' => '120', 'daylight' => ''),
|
||||
'Jerusalem' => array('offset' => '120', 'daylight' => 'Daylight'),
|
||||
'Saudi Arabia' => array('offset' => '180', 'daylight' => ''),
|
||||
/* Russian Regions */
|
||||
'Russian/Kaliningrad' => array('offset' => '120', 'daylight' => '', 'cisco_code' => 'South Africa Standard Time'),
|
||||
'Russian/Moscow' => array('offset' => '180', 'daylight' => '', 'cisco_code' => 'Russian Standard Time'),
|
||||
'Russian/St.Peterburg' => array('offset' => '180', 'daylight' => '', 'cisco_code' => 'Russian Standard Time'),
|
||||
'Russian/Samara' => array('offset' => '240', 'daylight' => '', 'cisco_code' => 'Arabian Standard Time'),
|
||||
'Russian/Novosibirsk' => array('offset' => '300', 'daylight' => '', 'cisco_code' => 'Ekaterinburg Standard Time'),
|
||||
'Russian/Ekaterinburg' => array('offset' => '300', 'daylight' => '', 'cisco_code' => 'Ekaterinburg Standard Time'),
|
||||
'Russian/Irkutsk' => array('offset' => '480', 'daylight' => '', 'cisco_code' => 'China Standard Time'),
|
||||
'Russian/Yakutsk' => array('offset' => '540', 'daylight' => '', 'cisco_code' => 'Tokyo Standard Time'),
|
||||
'Russian/Khabarovsk' => array('offset' => '600', 'daylight' => '', 'cisco_code' => 'West Pacific Standard Time'),
|
||||
'Russian/Vladivostok' => array('offset' => '600', 'daylight' => '', 'cisco_code' => 'West Pacific Standard Time'),
|
||||
'Russian/Sakhalin' => array('offset' => '660', 'daylight' => '', 'cisco_code' => 'Central Pacific Standard Time'),
|
||||
'Russian/Magadan' => array('offset' => '660', 'daylight' => '', 'cisco_code' => 'Central Pacific Standard Time'),
|
||||
'Russian/Kamchatka' => array('offset' => '720', 'daylight' => '', 'cisco_code' => 'Fiji Standard Time'),
|
||||
/* EnD - Russian Regions */
|
||||
'Iran' => array('offset' => '210', 'daylight' => 'Daylight'),
|
||||
'Caucasus' => array('offset' => '240', 'daylight' => 'Daylight'),
|
||||
'Arabian' => array('offset' => '240', 'daylight' => ''),
|
||||
'Afghanistan' => array('offset' => '270', 'daylight' => ''),
|
||||
'West Asia' => array('offset' => '300', 'daylight' => ''),
|
||||
'India' => array('offset' => '330', 'daylight' => ''),
|
||||
'Central Asia' => array('offset' => '360', 'daylight' => ''),
|
||||
'SE Asia' => array('offset' => '420', 'daylight' => ''),
|
||||
'China' => array('offset' => '480', 'daylight' => ''),
|
||||
'Taipei' => array('offset' => '480', 'daylight' => ''),
|
||||
'Tokyo' => array('offset' => '540', 'daylight' => ''),
|
||||
'Cen. Australia' => array('offset' => '570', 'daylight' => 'Daylight'),
|
||||
'AUS Central' => array('offset' => '570', 'daylight' => ''),
|
||||
'E. Australia' => array('offset' => '600', 'daylight' => ''),
|
||||
'AUS Eastern' => array('offset' => '600', 'daylight' => 'Daylight'),
|
||||
'West Pacific' => array('offset' => '600', 'daylight' => ''),
|
||||
'Tasmania' => array('offset' => '600', 'daylight' => 'Daylight'),
|
||||
'Central Pacific' => array('offset' => '660', 'daylight' => ''),
|
||||
'Fiji' => array('offset' => '720', 'daylight' => ''),
|
||||
'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight')
|
||||
);
|
||||
|
||||
public function validate_init_path($confDir = '', $db_vars, $sccp_driver_replace = '')
|
||||
{
|
||||
// global $db;
|
||||
// global $amp_conf;
|
||||
// *** Setings for Provision Sccp
|
||||
$adv_config = array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings',
|
||||
'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates', 'dialplan' => 'dialplan', 'softkey' => 'softkey');
|
||||
// 'pro' /tftpboot - root dir
|
||||
// /tftpboot/locales/locales/%Languge_name%
|
||||
// /tftpboot/settings/XMLdefault.cnf.xml
|
||||
// /tftpboot/settings/SEP[MAC].cnf.xml
|
||||
// /tftpboot/firmware/79xx/SCCPxxxx.loads
|
||||
$adv_tree['pro'] = array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales', 'dialplan' => 'tftproot', 'softkey' => 'tftproot');
|
||||
|
||||
// 'def' /tftpboot - root dir
|
||||
// /tftpboot/languages/%Languge_name%
|
||||
// /tftpboot/XMLdefault.cnf.xml
|
||||
// /tftpboot/SEP[MAC].cnf.xml
|
||||
// /tftpboot/SCCPxxxx.loads
|
||||
$adv_tree['def'] = array('templates' => 'tftproot', 'settings' => '', 'locales' => '', 'firmware' => '', 'languages' => 'tftproot', 'dialplan' => '', 'softkey' => '');
|
||||
// $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => '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');
|
||||
|
||||
if (empty($confDir)) {
|
||||
return array('error' => 'empty СonfDir');
|
||||
}
|
||||
|
||||
$base_config = array('asterisk' => $confDir, 'sccp_conf' => $confDir . '/sccp.conf', 'tftp_path' => '');
|
||||
|
||||
// Test Base dir (/tftproot)
|
||||
if (!empty($db_vars["tftp_path"])) {
|
||||
if (file_exists($db_vars["tftp_path"]["data"])) {
|
||||
$base_config["tftp_path"] = $db_vars["tftp_path"]["data"];
|
||||
}
|
||||
}
|
||||
if (empty($base_config["tftp_path"])) {
|
||||
if (file_exists($this->getextConfig('sccpDefaults', "tftp_path"))) {
|
||||
$base_config["tftp_path"] = $this->getextConfig('sccpDefaults', "tftp_path");
|
||||
}
|
||||
}
|
||||
if (empty($base_config["tftp_path"])) {
|
||||
if (!empty($this->paren_class)) {
|
||||
$this->paren_class->class_error['tftp_path'] = 'Tftp path not exist or not defined';
|
||||
}
|
||||
return array('error' => 'empty tftp_path');
|
||||
}
|
||||
if (!is_writeable($base_config["tftp_path"])) {
|
||||
if (!empty($this->paren_class)) {
|
||||
$this->paren_class->class_error['tftp_path'] = 'No write permission on tftp DIR';
|
||||
}
|
||||
return array('error' => 'No write permission on tftp DIR');
|
||||
}
|
||||
// END Test Base dir (/tftproot)
|
||||
|
||||
if (!empty($db_vars['tftp_rewrite_path'])) {
|
||||
$adv_ini = $db_vars['tftp_rewrite_path']["data"];
|
||||
}
|
||||
|
||||
$adv_tree_mode = 'def';
|
||||
if (empty($db_vars["tftp_rewrite"])) {
|
||||
$db_vars["tftp_rewrite"]["data"] = "off";
|
||||
}
|
||||
|
||||
$adv_config['tftproot'] = $base_config["tftp_path"];
|
||||
if ($db_vars["tftp_rewrite"]["data"] == 'pro') {
|
||||
$adv_tree_mode = 'pro';
|
||||
if (!empty($adv_ini)) { // something found in external conflicts
|
||||
$adv_ini .= '/index.cnf';
|
||||
if (file_exists($adv_ini)) {
|
||||
$adv_ini_array = parse_ini_file($adv_ini);
|
||||
$adv_config = array_merge($adv_config, $adv_ini_array);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($db_vars["tftp_rewrite"]["data"] == 'on') {
|
||||
$adv_tree_mode = 'def';
|
||||
}
|
||||
foreach ($adv_tree[$adv_tree_mode] as $key => $value) {
|
||||
if (!empty($adv_config[$key])) {
|
||||
if (!empty($value)) {
|
||||
if (substr($adv_config[$key], 0, 1) != "/") {
|
||||
$adv_config[$key] = $adv_config[$value] . '/' . $adv_config[$key];
|
||||
}
|
||||
} else {
|
||||
$adv_config[$key] = $adv_config['tftproot'];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($base_tree as $key => $value) {
|
||||
$base_config[$key] = $adv_config[$value];
|
||||
if (!file_exists($base_config[$key])) {
|
||||
if (!mkdir($base_config[$key], 0777, true)) {
|
||||
die('Error creating dir : ' . $base_config[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
print_r($base_config, 1);
|
||||
// die(print_r($base_config,1));
|
||||
// $base_config['External_ini'] = $adv_config;
|
||||
// $base_config['External_mode'] = $adv_tree_mode;
|
||||
|
||||
/*
|
||||
if (!empty($this->sccppath["tftp_path"])) {
|
||||
$this->sccppath["tftp_DP"] = $this->sccppath["tftp_path"] . '/Dialplan';
|
||||
if (!file_exists($this->sccppath["tftp_DP"])) {
|
||||
if (!mkdir($this->sccppath["tftp_DP"], 0777, true)) {
|
||||
die('Error creating DialPlan template dir');
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
// TFTP -REWrite double model
|
||||
if (empty($_SERVER['DOCUMENT_ROOT'])) {
|
||||
if (!empty($this->paren_class)) {
|
||||
$this->paren_class->class_error['DOCUMENT_ROOT'] = 'Empty DOCUMENT_ROOT';
|
||||
}
|
||||
$base_config['error'] = 'Empty DOCUMENT_ROOT';
|
||||
return $base_config;
|
||||
}
|
||||
|
||||
if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) {
|
||||
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/';
|
||||
$dst_path = $base_config["tftp_templates"] . '/';
|
||||
foreach (glob($src_path . '*.*_template') as $filename) {
|
||||
copy($filename, $dst_path . basename($filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php';
|
||||
if (!file_exists($dst) || $sccp_driver_replace == 'yes') {
|
||||
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst) . '.v' . $db_vars['sccp_compatible']['data'];
|
||||
if (file_exists($src_path)) {
|
||||
copy($src_path, $dst);
|
||||
} else {
|
||||
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst);
|
||||
copy($src_path, $dst);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($base_config["sccp_conf"])) { // System re Config
|
||||
$sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf');
|
||||
file_put_contents($base_config["sccp_conf"], $sccpfile);
|
||||
}
|
||||
|
||||
return $base_config;
|
||||
}
|
||||
// Type declaration in below function is incompatible with PHP 5
|
||||
public function validate_RealTime( $connector )
|
||||
{
|
||||
// This method only checks that asterisk is correctly configured for Realtime
|
||||
// It is preventative and does not change anything for Sccp_manager
|
||||
global $amp_conf;
|
||||
$res = array();
|
||||
/* if (empty($connector)) {
|
||||
$connector = 'sccp';
|
||||
}
|
||||
$cnf_int = \FreePBX::Config();
|
||||
$cnf_wr = \FreePBX::WriteConfig();
|
||||
*/
|
||||
$cnf_read = \FreePBX::LoadConfig();
|
||||
|
||||
// We are running inside FreePBX so must use the same database
|
||||
$def_config = array('sccpdevice' => 'mysql,' . $amp_conf['AMPDBNAME'] . ',sccpdeviceconfig', 'sccpline' => 'mysql,' . $amp_conf['AMPDBNAME'] . ',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'],
|
||||
'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock'
|
||||
);
|
||||
$dir = $amp_conf['ASTETCDIR'];
|
||||
$res_conf_sql = ini_get('pdo_mysql.default_socket');
|
||||
$res_conf = '';
|
||||
$ext_conf = '';
|
||||
|
||||
foreach ($backup_ext as $fext) {
|
||||
if (file_exists($dir . '/extconfig' . $fext)) {
|
||||
$ext_conf = $cnf_read->getConfig('extconfig' . $fext);
|
||||
if (!empty($ext_conf['settings']['sccpdevice'])) {
|
||||
if ($ext_conf['settings']['sccpdevice'] === $def_config['sccpdevice']) {
|
||||
$res['sccpdevice'] = 'OK';
|
||||
$res['extconfigfile'] = 'extconfig' . $fext;
|
||||
} else {
|
||||
$res['sccpdevice'] .= ' Error in line sccpdevice ';
|
||||
}
|
||||
}
|
||||
if (!empty($ext_conf['settings']['sccpline'])) {
|
||||
if ($ext_conf['settings']['sccpline'] === $def_config['sccpline']) {
|
||||
$res['sccpline'] = 'OK';
|
||||
} else {
|
||||
$res['sccpline'] .= ' Error in line sccpline ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res['extconfig'] = 'OK';
|
||||
|
||||
if (empty($res['sccpdevice'])) {
|
||||
$res['extconfig'] = ' Option "Sccpdevice" is not configured ';
|
||||
}
|
||||
if (empty($res['sccpline'])) {
|
||||
$res['extconfig'] = ' Option "Sccpline" is not configured ';
|
||||
}
|
||||
|
||||
if (empty($res['extconfigfile'])) {
|
||||
$res['extconfig'] = 'File extconfig.conf does not exist';
|
||||
}
|
||||
|
||||
if (!empty($res_conf_sql)) {
|
||||
if (file_exists($res_conf_sql)) {
|
||||
$def_bd_config['dbsock'] = $res_conf_sql;
|
||||
}
|
||||
}
|
||||
// Check for mysql config files - should only be one depending on version
|
||||
$mySqlConfigFiles = [ 'res_mysql.conf', 'res_config_mysql.conf' ];
|
||||
foreach ($mySqlConfigFiles as $sqlConfigFile) {
|
||||
if (file_exists( $dir . '/' . $sqlConfigFile )) {
|
||||
$res_conf = $cnf_read->getConfig($sqlConfigFile);
|
||||
if (empty($res_conf[$connector])) {
|
||||
$res['mysqlconfig'] = 'Config not found in file: ' . $sqlConfigFile;
|
||||
} else {
|
||||
if ($res_conf[$connector]['dbsock'] != $def_bd_config['dbsock']) {
|
||||
$res['mysqlconfig'] = 'Mysql Socket Error in file: ' . $sqlConfigFile;
|
||||
}
|
||||
}
|
||||
if (empty($res['mysqlconfig'])) {
|
||||
$res['mysqlconfig'] = 'OK';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($res['mysqlconfig'])) {
|
||||
$res['mysqlconfig'] = 'Realtime Error: neither res_config_mysql.conf nor res_mysql.conf found in the path : ' . $dir;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class sipconfigs
|
||||
{
|
||||
// protected $database;
|
||||
// protected $freepbx;
|
||||
|
||||
public function __construct($parent_class = null)
|
||||
{
|
||||
$this->paren_class = $parent_class;
|
||||
// $freepbx
|
||||
// $this->database = $freepbx->Database;
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
$Ver = '13.0.4';
|
||||
return array('Version' => $Ver,
|
||||
'about' => 'Sip Setings ver: ' . $Ver);
|
||||
}
|
||||
|
||||
public function get_db_sip_TableData($dataid, $data = array())
|
||||
{
|
||||
global $db;
|
||||
if ($dataid == '') {
|
||||
return false;
|
||||
}
|
||||
switch ($dataid) {
|
||||
case "Device":
|
||||
$sql = "SELECT * FROM sip ORDER BY `id`";
|
||||
$tech = array();
|
||||
try {
|
||||
$raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
|
||||
foreach ($raw_settings as $value) {
|
||||
if (empty($tech[$value['id']]['id'])) {
|
||||
$tech[$value['id']]['id']= $value['id'];
|
||||
}
|
||||
$tech[$value['id']][$value['keyword']]=$value['data'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
return $tech;
|
||||
case "DeviceById":
|
||||
$sql = "SELECT keyword,data FROM sip WHERE id = ?";
|
||||
$sth = $db->prepare($sql);
|
||||
$tech = array();
|
||||
try {
|
||||
$id = $data['id'];
|
||||
$sth->execute(array($id));
|
||||
$tech = $sth->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP);
|
||||
foreach ($tech as &$value) {
|
||||
$value = $value[0];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
return $tech;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSipConfig()
|
||||
{
|
||||
$result = array();
|
||||
// $def_sip_proto = 'sip';
|
||||
// $def_proto = 'tcp';
|
||||
// $supp_proto = '';
|
||||
|
||||
// $result['sipport'] = \FreePBX::Sipsettings()->getConfig('bindport');
|
||||
// $result['tlsport'] = \FreePBX::Sipsettings()->getConfig('tlsbindport');
|
||||
// $tmp_sipsetigs = \FreePBX::Sipsettings()->getChanSipSettings();
|
||||
$tmp_binds = \FreePBX::Sipsettings()->getBinds();
|
||||
$if_list = $this->paren_class ->getIpInformation('ip4');
|
||||
|
||||
/*
|
||||
$tmp_bind_ip = !empty($tmp_sipsetigs['externhost_val']) ? $tmp_sipsetigs['externhost_val'] : '';
|
||||
$tmp_bind_ip = !empty($tmp_sipsetigs['externip_val']) ? $tmp_sipsetigs['externip_val'] : $tmp_bind_ip;
|
||||
$tmp_bind_ip = !empty($tmp_sipsetigs['bindaddr']) ? $tmp_sipsetigs['bindaddr'] : $tmp_bind_ip;
|
||||
*/
|
||||
$tmp_binds = is_array($tmp_binds) ? $tmp_binds: array();
|
||||
$result = array();
|
||||
foreach ($tmp_binds as $f_protocol => $f_bind) {
|
||||
foreach ($f_bind as $f_ip => $f_port) {
|
||||
if (($f_ip == '0.0.0.0') || ($f_ip == '[::]')) {
|
||||
foreach ($if_list as $f_if => $f_data) {
|
||||
if ($f_data['ip'] == "127.0.0.1") {
|
||||
continue;
|
||||
}
|
||||
if (empty($result[$f_protocol][$f_data['ip']])) {
|
||||
$result[$f_protocol][$f_data['ip']]= $f_port;
|
||||
} else {
|
||||
$result[$f_protocol][$f_data['ip']]= array_merge($result[$f_protocol][$f_data['ip']],$f_port);
|
||||
}
|
||||
$result[$f_protocol][$f_data['ip']]['ip']=$f_data['ip'];
|
||||
}
|
||||
} else {
|
||||
$result[$f_protocol][$f_ip]=$f_port;
|
||||
$result[$f_protocol][$f_ip]['ip']=$f_ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
/*
|
||||
// $result['sipbind'] = $tmp_bind_ip;
|
||||
if (empty($tmp_sip_binds[$def_sip_proto])){
|
||||
$def_proto = 'pjsip';
|
||||
}
|
||||
return $result;
|
||||
|
||||
foreach ($tmp_sip_binds[$def_sip_proto] as $key => $value) {
|
||||
if (empty($value[$def_proto])) {
|
||||
$def_proto = 'udp';
|
||||
$supp_proto = 'udp';
|
||||
} else {
|
||||
$supp_proto = !empty($value['udp']) ? 'tcp;udp' : 'tcp';
|
||||
}
|
||||
if (empty($def_key)) {
|
||||
$def_key = $key;
|
||||
}
|
||||
if ($key != '0.0.0.0') {
|
||||
$tmp_bind_ip = $key;
|
||||
}
|
||||
$result['sipbindport'] = $value[$def_proto];
|
||||
}
|
||||
$result['sipbind'] = $tmp_bind_ip;
|
||||
$result['sipsuportproto'] = $supp_proto;
|
||||
|
||||
$binds= array();
|
||||
$driver = \FreePBX::Config()->get_conf_setting('ASTSIPDRIVER');
|
||||
if ($driver == "both" || $driver == "chan_pjsip") {
|
||||
$b = \FreePBX::Sipsettings()->getConfig("binds");
|
||||
$b = is_array($b) ? $b : array();
|
||||
foreach($b as $protocol => $bind) {
|
||||
foreach($bind as $ip => $state) {
|
||||
if($state != "on") {
|
||||
continue;
|
||||
}
|
||||
$p = \FreePBX::Sipsettings()->getConfig($protocol."port-".$ip);
|
||||
$result['nb3'.$protocol] = $p;
|
||||
if ($flatten) {
|
||||
$binds['pjsip']['[::]'][$protocol] = $p;
|
||||
} else {
|
||||
$binds['pjsip'][$ip][$protocol] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$binds['pjsip'] = array("0.0.0.0" => array());
|
||||
}
|
||||
|
||||
$result['nd'] = $driver;
|
||||
|
||||
$result['nb'] = $binds;
|
||||
$result['nb2'] = $b;
|
||||
return $result;
|
||||
*
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -1,789 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
*
|
||||
*/
|
||||
/* !TODO!: -TODO-: Would you like to use my XSD file to check if the provided template file is a correct cisco cnf.xml file ?
|
||||
* !TODO!: -TODO-: I just don't understand how to use it here.. To check the incoming pattern ? To check the result of my script ?
|
||||
* !TODO!: -TODO-: The most correct variant is to generate xml based on XSD template.
|
||||
*/
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class xmlinterface
|
||||
{
|
||||
|
||||
private $val_null = 'NONE'; /// REPLACE to null Field
|
||||
|
||||
public function __construct($parent_class = null)
|
||||
{
|
||||
$this->paren_class = $parent_class;
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
$Ver = '13.0.5';
|
||||
return array('Version' => $Ver,
|
||||
'about' => 'Create XML data interface ver: ' . $Ver);
|
||||
}
|
||||
|
||||
function create_default_XML($store_path = '', $data_values = array(), $model_information = array(), $lang_info = array())
|
||||
{
|
||||
$data_path = $data_values['tftp_path'];
|
||||
if (empty($store_path) || empty($data_path) || empty($data_values)) {
|
||||
return;
|
||||
}
|
||||
$def_xml_fields = array('authenticationURL', 'informationURL', 'messagesURL', 'servicesURL', 'directoryURL',
|
||||
'secureauthenticationURL', 'secureinformationURL', 'securemessagesURL', 'secureservicesURL', 'securedirectoryURL', 'secureidleURL',
|
||||
'proxyServerURL', 'idleTimeout', 'idleURL');
|
||||
$def_xml_locale = array('userLocale', 'networkLocaleInfo', 'networkLocale');
|
||||
$xml_name = $store_path . '/XMLDefault.cnf.xml';
|
||||
$xml_template = $data_values['tftp_path'] . '/templates/XMLDefault.cnf.xml_template';
|
||||
|
||||
if (file_exists($xml_template)) {
|
||||
$xml_work = simplexml_load_file($xml_template);
|
||||
$xnode = &$xml_work->callManagerGroup->members;
|
||||
$bind_tmp = $this->get_server_sccp_bind($data_values);
|
||||
//error_log("bind_tmp:".print_r($bind_tmp, true), 0);
|
||||
$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);
|
||||
}
|
||||
$ifc++;
|
||||
}
|
||||
|
||||
$this->replaceSimpleXmlNode($xml_work->callManagerGroup->members, $xnode);
|
||||
|
||||
foreach ($def_xml_fields as $value) {
|
||||
if (!empty($data_values['dev_' . $value])) {
|
||||
$xml_work->$value = trim($data_values['dev_' . $value]);
|
||||
} else {
|
||||
$node = $xml_work->$value;
|
||||
if (!empty($node)) {
|
||||
unset($node[0][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($def_xml_locale as $key) {
|
||||
if (!empty($xml_work->$key)) {
|
||||
$xnode = &$xml_work->$key;
|
||||
switch ($key) {
|
||||
case 'userLocale':
|
||||
case 'networkLocaleInfo':
|
||||
if ($key == 'networkLocaleInfo') {
|
||||
$lang = $data_values['netlang'];
|
||||
} else {
|
||||
$lang = $data_values['devlang'];
|
||||
}
|
||||
if (isset($lang_info[$lang])) {
|
||||
$xnode->name = $lang_info[$lang]['locale'];
|
||||
$xnode->langCode = $lang_info[$lang]['code'];
|
||||
} else {
|
||||
$xnode->name = '';
|
||||
$xnode->langCode = '';
|
||||
}
|
||||
break;
|
||||
case 'networkLocale':
|
||||
$lang = $data_values['netlang'];
|
||||
if (isset($lang_info[$lang])) {
|
||||
$xnode = $lang_info[$lang]['language'];
|
||||
} else {
|
||||
$xnode = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($model_information as $var) {
|
||||
if (!empty($var['loadinformationid'])) {
|
||||
$node = $xml_work->addChild($var['loadinformationid'], $var['loadimage']);
|
||||
$node->addAttribute('model', $var['vendor'] . ' ' . $var['model']);
|
||||
}
|
||||
}
|
||||
$xml_work->asXml($xml_name); // Save XMLDefault1.cnf.xml
|
||||
}
|
||||
}
|
||||
|
||||
function create_SEP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array())
|
||||
{
|
||||
$var_xml_general_fields = array('authenticationurl' => 'dev_authenticationURL', 'informationurl' => 'dev_informationURL', 'messagesurl' => 'dev_messagesURL',
|
||||
'servicesurl' => 'dev_servicesURL', 'directoryurl' => 'dev_directoryURL', 'idleurl' => 'dev_idleURL',
|
||||
'secureauthenticationurl' => 'dev_secureauthenticationURL',
|
||||
'secureinformationurl' => 'dev_secureinformationURL', 'securemessagesurl'=>'dev_securemessagesURL',
|
||||
'secureservicesurl'=>'dev_secureservicesURL', 'securedirectoryurl'=>'dev_securedirectoryURL', 'secureidleurl' => 'dev_secureidleURL',
|
||||
'proxyserverurl' => 'dev_proxyServerURL', 'idletimeout' => 'dev_idleTimeout',
|
||||
'sshuserid' => 'dev_sshUserId', 'sshpassword' => 'dev_sshPassword', 'deviceprotocol' => 'dev_deviceProtocol',
|
||||
'phonepersonalization' => 'phonePersonalization'
|
||||
);
|
||||
$var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList' => 'null', 'mobility' => 'null',
|
||||
'phoneServices' => 'null', 'certHash' => 'null',
|
||||
'deviceSecurityMode' => '1');
|
||||
|
||||
if (empty($dev_config)) {
|
||||
return false;
|
||||
}
|
||||
$data_path = $dev_config['tftp_path'];
|
||||
|
||||
if (empty($store_path) || empty($data_path) || empty($data_values) || empty($dev_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($dev_config['nametemplate'])) {
|
||||
$xml_template = $data_path . '/templates/' . $dev_config['nametemplate'];
|
||||
} else {
|
||||
$xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_template';
|
||||
}
|
||||
$xml_name = $store_path . '/' . $dev_id . '.cnf.xml';
|
||||
if (file_exists($xml_template)) {
|
||||
$xml_work = simplexml_load_file($xml_template);
|
||||
|
||||
foreach ($var_xml_general_vars as $key => $data) {
|
||||
if (isset($xml_work->$key)) {
|
||||
if ($data != 'null') {
|
||||
$xml_work->$key = $data;
|
||||
} else {
|
||||
$node = $xml_work->$key;
|
||||
unset($node[0][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($xml_work as $key => $data) {
|
||||
// Set System global Values
|
||||
$key_l = strtolower($key);
|
||||
if (!empty($var_xml_general_fields[$key_l])) {
|
||||
$xml_work->$key = $data_values[$var_xml_general_fields[$key_l]];
|
||||
}
|
||||
// Set section Values
|
||||
$xml_node = $xml_work->$key;
|
||||
switch ($key_l) {
|
||||
case 'devicepool':
|
||||
$xml_node = $xml_work->$key;
|
||||
foreach ($xml_work->$key->children() as $dkey => $ddata) {
|
||||
switch (strtolower($dkey)) {
|
||||
case 'datetimesetting':
|
||||
$xnode = &$xml_node->$dkey;
|
||||
$tz_id = $data_values['ntp_timezone'];
|
||||
$TZdata = $data_values['ntp_timezone_id'];
|
||||
if (empty($TZdata)) {
|
||||
$TZdata = array('offset' => '0', 'daylight' => '', 'cisco_code' => 'Greenwich Standard Time');
|
||||
}
|
||||
$xnode->name = $tz_id;
|
||||
$xnode->dateTemplate = $data_values['dateformat'];
|
||||
$xnode->timeZone = $TZdata['cisco_code'];
|
||||
// $xnode->timeZone = $tz_id.' Standard'.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']).' Time';
|
||||
|
||||
if ($data_values['ntp_config_enabled'] == 'on') {
|
||||
$xnode->ntps->ntp->name = $data_values['ntp_server'];
|
||||
$xnode->ntps->ntp->ntpMode = $data_values['ntp_server_mode'];
|
||||
} else {
|
||||
$xnode->ntps = null;
|
||||
}
|
||||
// Ntp Config
|
||||
break;
|
||||
case 'srstinfo':
|
||||
if ($data_values['srst_Option'] == 'user') {
|
||||
break;
|
||||
}
|
||||
$xnode = &$xml_node->$dkey;
|
||||
$xnode->name = $data_values['srst_Name'];
|
||||
$xnode->srstOption = $data_values['srst_Option'];
|
||||
$xnode->userModifiable = $data_values['srst_userModifiable'];
|
||||
$xnode->isSecure = $data_values['srst_isSecure'];
|
||||
|
||||
$srst_fld = array('srst_ip' => array('ipAddr', 'port'));
|
||||
foreach ($srst_fld as $srst_pro => $srs_put) {
|
||||
if (empty($data_values[$srst_pro]) || ($data_values['srst_Option'] == 'disable') ) {
|
||||
$srst_data =array();
|
||||
} else {
|
||||
$srst_data = explode(';', $data_values[$srst_pro]);
|
||||
}
|
||||
$si = 1;
|
||||
foreach ($srst_data as $value) {
|
||||
$srs_val = explode('/', $value);
|
||||
$nod = $srs_put[0] . $si;
|
||||
$xnode->$nod = $srs_val[0];
|
||||
$nod = $srs_put[1] . $si;
|
||||
$xnode->$nod = ((empty($srs_val[1])) ? "2000": $srs_val[1]);
|
||||
$si++;
|
||||
}
|
||||
while ($si < 4) {
|
||||
$nod = $srs_put[0] . $si;
|
||||
$xnode->$nod = '';
|
||||
$nod = $srs_put[1] . $si;
|
||||
$xnode->$nod = '';
|
||||
$si++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'connectionmonitorduration':
|
||||
$xml_node->$dkey = strval(intval(intval($data_values['keepalive']) * 0.75));
|
||||
break;
|
||||
case 'callmanagergroup':
|
||||
$xnode = &$xml_node->$dkey->members;
|
||||
$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'];
|
||||
if (!is_null($xnode_obj->callManager->description)) {
|
||||
$xnode_obj->callManager->description = $data_values['servername'];
|
||||
}
|
||||
$xnode_obj->callManager->ports->ethernetPhonePort = $bind_value['port'];
|
||||
$xnode_obj->callManager->processNodeName = $bind_value['ip'];
|
||||
if (!empty($xnode_obj->callManager->ports->mgcpPorts)) {
|
||||
unset($xnode_obj->callManager->ports->mgcpPorts);
|
||||
}
|
||||
|
||||
if ($ifc === 0) {
|
||||
$this->replaceSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
}
|
||||
$ifc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->replaceSimpleXmlNode($xml_work->$key, $xml_node);
|
||||
break;
|
||||
case 'vendorconfig':
|
||||
$xml_node = $xml_work->$key;
|
||||
foreach ($xml_work->$key->children() as $dkey => $ddata) {
|
||||
$dkey_l = strtolower($dkey);
|
||||
$vtmp_key = $key_l.'_'.$dkey_l;
|
||||
if (isset($data_values[$vtmp_key])) {
|
||||
$vtmp_data = $data_values[$vtmp_key];
|
||||
if ((!empty($vtmp_data)) || ($vtmp_data == "0")) {
|
||||
$xml_node->$dkey = $vtmp_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->replaceSimpleXmlNode($xml_work->$key, $xml_node);
|
||||
break;
|
||||
|
||||
case 'versionstamp':
|
||||
$xml_work->$key = time();
|
||||
break;
|
||||
case 'loadinformation':
|
||||
// Set Path Image ????
|
||||
if (isset($dev_config["tftp_firmware"])) {
|
||||
$xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : '';
|
||||
} else {
|
||||
$xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : '';
|
||||
}
|
||||
if (!empty($dev_config['addon'])) {
|
||||
$xnode = $xml_work->addChild('addOnModules');
|
||||
$ti = 1;
|
||||
$hw_addon = explode(',', $dev_config['addon']);
|
||||
foreach ($hw_addon as $add_key) {
|
||||
if (!empty($dev_config['addon_info'][$add_key])) {
|
||||
$add_val = $dev_config['addon_info'][$add_key];
|
||||
$xnode_obj = $xnode->addChild('addOnModule');
|
||||
$xnode_obj->addAttribute('idx', $ti);
|
||||
$xnode_obj->addChild('loadInformation', $add_val);
|
||||
$ti++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'commonprofile':
|
||||
$xml_node->phonePassword = $data_values['dev_sshPassword'];
|
||||
$xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] == 'on') || ($data_values['backgroundImageAccess'] == 'true') ) ? 'true' : 'false';
|
||||
$xml_node->callLogBlfEnabled = $data_values['callLogBlfEnabled'];
|
||||
break;
|
||||
|
||||
case 'userlocale':
|
||||
case 'networklocaleinfo':
|
||||
case 'networklocale':
|
||||
$hwlang = '';
|
||||
$lang = '';
|
||||
if (!empty($dev_config["_hwlang"])) {
|
||||
$hwlang = explode(':', $dev_config["_hwlang"]);
|
||||
}
|
||||
if (($key_l == 'networklocaleinfo') || ($key_l == 'networklocale')) {
|
||||
$lang = (empty($hwlang[0])) ? $data_values['netlang'] : $hwlang[0];
|
||||
} else {
|
||||
$lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1];
|
||||
}
|
||||
if (($lang != 'null') && (!empty($lang))) {
|
||||
if ($key_l == 'networklocale') {
|
||||
$xml_work->$key = $lang;
|
||||
} else {
|
||||
if (isset($lang_info[$lang])) {
|
||||
$xml_node->name = $lang_info[$lang]['locale'];
|
||||
$xml_node->langCode = $lang_info[$lang]['code'];
|
||||
if ($key_l == 'userlocale') {
|
||||
$xml_node->winCharSet = $lang_info[$lang]['codepage'];
|
||||
}
|
||||
$this->replaceSimpleXmlNode($xml_work->$key, $xml_node);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$xml_work->$key = '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// print_r($xml_work);
|
||||
$xml_work->asXml($xml_name); // Save
|
||||
} else {
|
||||
die('Error Hardware template :' . $xml_template . ' not found');
|
||||
}
|
||||
return time();
|
||||
}
|
||||
|
||||
private function get_server_sccp_bind($data_values = array())
|
||||
{
|
||||
$res = array();
|
||||
if ($data_values['bindaddr'] !== '0.0.0.0') {
|
||||
$rkey = $data_values['bindaddr'];
|
||||
$res[$rkey] = array('ip' => $data_values['bindaddr'], 'port' => $data_values['port']);
|
||||
return $res;
|
||||
}
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
function create_SEP_SIP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array())
|
||||
{
|
||||
|
||||
$var_xml_general_fields = array('authenticationURL' => 'dev_authenticationURL', 'informationURL' => 'dev_informationURL', 'messagesURL' => 'dev_messagesURL',
|
||||
'servicesURL' => 'dev_servicesURL', 'directoryURL' => 'dev_directoryURL', 'proxyServerURL' => 'dev_proxyServerURL', 'idleTimeout' => 'dev_idleTimeout',
|
||||
'idleURL' => 'dev_idleURL', 'sshUserId' => 'dev_sshUserId', 'sshPassword' => 'dev_sshPassword',
|
||||
'phonePersonalization' => 'phonePersonalization'
|
||||
);
|
||||
$var_xml_sipProfile = array('phoneLabel' => 'description',
|
||||
'transferOnhookEnabled' => 'transferOnhookEnabled', 'enableVad' => 'enableVad', 'voipControlPort' => 'sipport'
|
||||
);
|
||||
$var_xml_sipline = array('name' => 'account', 'featureLabel' => 'account', 'displayName' => 'callerid', 'contact' => 'account',
|
||||
'authName' => 'account', 'authPassword' => 'secret');
|
||||
$var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList' => 'null', 'mobility' => 'null',
|
||||
'phoneServices' => 'null', 'certHash' => 'null', 'deviceProtocol' => 'SIP',
|
||||
'deviceSecurityMode' => '1');
|
||||
|
||||
// $var_hw_config = $this->dbinterface->HWextension_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id));
|
||||
|
||||
if (empty($dev_config)) {
|
||||
return false;
|
||||
}
|
||||
$data_path = $dev_config['tftp_path'];
|
||||
|
||||
if (empty($store_path) || empty($data_path) || empty($data_values) || empty($dev_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($dev_config['nametemplate'])) {
|
||||
$xml_template = $data_path . '/templates/' . $dev_config['nametemplate'];
|
||||
if (!file_exists($xml_template)) {
|
||||
$xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_sip_template';
|
||||
}
|
||||
} else {
|
||||
$xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_sip_template';
|
||||
}
|
||||
$xml_name = $store_path . '/' . $dev_id . '.cnf.xml';
|
||||
//$sip_bind = $this->get_server_sip_bind($data_values);
|
||||
$sip_bind = $data_values['sbind'];
|
||||
$bind_proto = 'tcp';
|
||||
$bind_ip_def = '';
|
||||
foreach ($sip_bind as $key => $value) {
|
||||
if (empty($bind_ip_def)) {
|
||||
$bind_ip_def = $key;
|
||||
$bind_proto = (isset($value['tcp'])) ? 'tcp' : 'udp';
|
||||
}
|
||||
}
|
||||
if (file_exists($xml_template)) {
|
||||
$xml_work = simplexml_load_file($xml_template);
|
||||
|
||||
foreach ($var_xml_general_vars as $key => $data) {
|
||||
if (isset($xml_work->$key)) {
|
||||
if ($data != 'null') {
|
||||
$xml_work->$key = $data;
|
||||
} else {
|
||||
$node = $xml_work->$key;
|
||||
unset($node[0][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($xml_work as $key => $data) {
|
||||
// Set System global Values
|
||||
if (!empty($var_xml_general_fields[$key])) {
|
||||
$xml_work->$key = $data_values[$var_xml_general_fields[$key]];
|
||||
}
|
||||
// Set section Values
|
||||
$xml_node = $xml_work->$key;
|
||||
switch ($key) {
|
||||
case 'devicePool':
|
||||
$xml_node = $xml_work->$key;
|
||||
foreach ($xml_work->$key->children() as $dkey => $ddata) {
|
||||
switch ($dkey) {
|
||||
case 'dateTimeSetting':
|
||||
$xnode = &$xml_node->$dkey;
|
||||
$tz_id = $data_values['ntp_timezone'];
|
||||
$TZdata = $data_values['ntp_timezone_id'];
|
||||
if (empty($TZdata)) {
|
||||
$TZdata = array('offset' => '0', 'daylight' => '', 'cisco_code' => 'Greenwich Standard Time');
|
||||
}
|
||||
$xnode->dateTemplate = $data_values['dateformat'];
|
||||
$xnode->timeZone = $TZdata['cisco_code'];
|
||||
|
||||
if ($data_values['ntp_config_enabled'] == 'on') {
|
||||
$xnode->ntps->ntp->name = $data_values['ntp_server'];
|
||||
$xnode->ntps->ntp->ntpMode = $data_values['ntp_server_mode'];
|
||||
} else {
|
||||
$xnode->ntps = null;
|
||||
}
|
||||
// Ntp Config
|
||||
break;
|
||||
case 'callManagerGroup':
|
||||
$xnode = &$xml_node->$dkey->members;
|
||||
$ifc = 0;
|
||||
foreach ($sip_bind as $bind_ip => $bind_value) {
|
||||
$xnode_obj = clone $xnode->member;
|
||||
$xnode_obj['priority'] = $ifc;
|
||||
$xnode_obj->callManager->name = $data_values['servername'];
|
||||
$xnode_obj->callManager->ports->sipPort = $bind_value[$bind_proto];
|
||||
// $xnode_obj->callManager->ports->securedSipPort = $bind_value['tlsport'];
|
||||
$xnode_obj->callManager->processNodeName = $bind_ip;
|
||||
if ($ifc === 0) {
|
||||
$this->replaceSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->member, $xnode_obj);
|
||||
}
|
||||
$ifc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->replaceSimpleXmlNode($xml_work->$key, $xml_node);
|
||||
break;
|
||||
case 'sipProfile':
|
||||
$xml_node = $xml_work->$key;
|
||||
foreach ($xml_work->$key->children() as $dkey => $ddata) {
|
||||
if (!empty($var_xml_sipProfile[$dkey])) {
|
||||
if (!empty($data_values[$var_xml_sipProfile[$dkey]])) {
|
||||
$xml_node->$dkey = $data_values[$var_xml_sipProfile[$dkey]];
|
||||
} else {
|
||||
$xml_node->$dkey = null;
|
||||
}
|
||||
}
|
||||
switch ($dkey) {
|
||||
case 'sipProxies':
|
||||
$xnode = &$xml_node->$dkey;
|
||||
$xnode->backupProxy = $bind_ip_def;
|
||||
$xnode->backupProxyPort = $sip_bind[$bind_ip_def][$bind_proto];
|
||||
$xnode->emergencyProxy = $bind_proto;
|
||||
$xnode->emergencyProxyPort = $sip_bind[$bind_ip_def][$bind_proto];
|
||||
$xnode->outboundProxy = $bind_proto;
|
||||
$xnode->outboundProxyPort = $sip_bind[$bind_ip_def][$bind_proto];
|
||||
$xnode->registerWithProxy = "true";
|
||||
|
||||
break;
|
||||
case 'sipLines':
|
||||
$xnode = &$xml_node->$dkey;
|
||||
$ifc = 0;
|
||||
if (!empty($data_values['siplines'])) {
|
||||
foreach ($data_values['siplines'] as $spkey => $spvalue) {
|
||||
// if $spvalue[]
|
||||
$xnode_obj = clone $xnode->line;
|
||||
$xnode_obj['button'] = $ifc + 1;
|
||||
$xnode_obj['lineIndex'] = $ifc + 1;
|
||||
//$xnode_obj->proxy = $data_values['bindaddr'];
|
||||
$xnode_obj->featureID = "9";
|
||||
if ($xnode_obj->proxy != 'USECALLMANAGER') {
|
||||
$xnode_obj->proxy = $bind_proto;
|
||||
$xnode_obj->port = $sip_bind[$bind_ip_def][$bind_proto];
|
||||
}
|
||||
|
||||
foreach ($var_xml_sipline as $line_key => $line_val) {
|
||||
$xnode_obj->$line_key = $spvalue[$line_val];
|
||||
}
|
||||
|
||||
if ($ifc === 0) {
|
||||
$this->replaceSimpleXmlNode($xnode->line, $xnode_obj);
|
||||
} else {
|
||||
$this->appendSimpleXmlNode($xnode->line, $xnode_obj);
|
||||
}
|
||||
$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>';
|
||||
$xnode_obj = simplexml_load_string($xmlstr);
|
||||
$this->appendSimpleXmlNode($xnode->line, $xnode_obj);
|
||||
$ifc++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'softKeyFile':
|
||||
case 'dialTemplate': // Доработать !
|
||||
$xml_ext_file = '';
|
||||
$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');
|
||||
}
|
||||
if (empty($xml_ext_file) || !file_exists($templet_path . '/' . $xml_ext_file)) {
|
||||
$xml_ext_file = (($dkey == 'softKeyFile') ? 'softkeydefault.xml' : 'dialplan.xml');
|
||||
}
|
||||
if (file_exists($templet_path . '/' . $xml_ext_file)) {
|
||||
$xml_node->$dkey = $xml_ext_file;
|
||||
} else {
|
||||
$xml_node->$dkey = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->replaceSimpleXmlNode($xml_work->$key, $xml_node);
|
||||
break;
|
||||
|
||||
case 'versionStamp':
|
||||
$xml_work->$key = time();
|
||||
break;
|
||||
case 'loadInformation':
|
||||
// Set Path Image ????
|
||||
if (isset($dev_config["tftp_firmware"])) {
|
||||
$xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : '';
|
||||
} else {
|
||||
$xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : '';
|
||||
}
|
||||
if (!empty($dev_config['addon'])) {
|
||||
$xnode = $xml_work->addChild('addOnModules');
|
||||
$ti = 1;
|
||||
foreach ($dev_config['addon_info'] as $add_key => $add_val) {
|
||||
$xnode_obj = $xnode->addChild('addOnModule');
|
||||
$xnode_obj->addAttribute('idx', $ti);
|
||||
$xnode_obj->addChild('loadInformation', $add_val);
|
||||
$ti++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'commonProfile':
|
||||
$xml_node->phonePassword = $data_values['dev_sshPassword'];
|
||||
$xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] == 'on') || ($data_values['backgroundImageAccess'] == 'true') ) ? 'true' : 'false';
|
||||
$xml_node->callLogBlfEnabled = $data_values['callLogBlfEnabled'];
|
||||
break;
|
||||
|
||||
case 'userLocale':
|
||||
case 'networkLocaleInfo':
|
||||
case 'networkLocale':
|
||||
$hwlang = '';
|
||||
$lang = '';
|
||||
if (!empty($dev_config["_hwlang"])) {
|
||||
$hwlang = explode(':', $dev_config["_hwlang"]);
|
||||
}
|
||||
if (($key == 'networkLocaleInfo') || ($key == 'networkLocale')) {
|
||||
$lang = (empty($hwlang[0])) ? $data_values['netlang'] : $hwlang[0];
|
||||
} else {
|
||||
$lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1];
|
||||
}
|
||||
if (($lang != 'null') && (!empty($lang))) {
|
||||
if ($key == 'networkLocale') {
|
||||
$xml_work->$key = $lang;
|
||||
} else {
|
||||
if (isset($lang_info[$lang])) {
|
||||
$xml_node->name = $lang_info[$lang]['locale'];
|
||||
$xml_node->langCode = $lang_info[$lang]['code'];
|
||||
if ($key == 'userLocale') {
|
||||
$xml_node->winCharSet = $lang_info[$lang]['codepage'];
|
||||
}
|
||||
$this->replaceSimpleXmlNode($xml_work->$key, $xml_node);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$xml_work->$key = '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$xml_work->asXml($xml_name); // Save
|
||||
} else {
|
||||
die('Error Hardware template :' . $xml_template . ' not found');
|
||||
}
|
||||
return time();
|
||||
}
|
||||
|
||||
function saveDialPlan($confDir, $get_settings)
|
||||
{
|
||||
$xmlstr = "<DIALTEMPLATE>\n";
|
||||
$xmlstr .= "<versionStamp>" . time() . "</versionStamp>\n";
|
||||
$dialFelds = array('match', 'timeout', 'rewrite', 'tone'); //str -to lo !
|
||||
|
||||
$hdr_prefix = 'sccp_dial_';
|
||||
$hdr_arprefix = 'sccp_dial-ar_';
|
||||
$save_data = array();
|
||||
$integer_msg = _("%s must be a non-negative integer");
|
||||
$errors = array();
|
||||
foreach ($get_settings[$hdr_arprefix . 'dialtemplate'] as $key => $value) {
|
||||
$xmlstr .= '<TEMPLATE';
|
||||
if (!empty($value['match'])) {
|
||||
foreach ($dialFelds as $fld) {
|
||||
if (isset($value[$fld])) {
|
||||
if ($value[$fld] == 'empty' || $value[$fld] == '') {
|
||||
|
||||
} else {
|
||||
$xmlstr .= ' ' . $fld . '="' . (string) $value[$fld] . '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$errors = array('Fields need to match !!');
|
||||
}
|
||||
$xmlstr .= "/>\n";
|
||||
}
|
||||
$xmlstr .= '</DIALTEMPLATE>';
|
||||
if (!empty($get_settings['idtemplate'])) {
|
||||
if ($get_settings['idtemplate'] == '*new*') {
|
||||
if (!empty($get_settings[$hdr_prefix . 'dialtemplate_name'])) {
|
||||
$put_file = (string) $get_settings[$hdr_prefix . 'dialtemplate_name'];
|
||||
} else {
|
||||
$errors = array('Fields Dial Plan Name is requered !!');
|
||||
}
|
||||
} else {
|
||||
$put_file = (string) $get_settings['idtemplate'];
|
||||
}
|
||||
} else {
|
||||
$errors = array('Fields Dial Plan Name is requered !!');
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
$put_file = str_replace(array("\n", "\r", "\t", "/", "\\", ".", ","), '', $put_file);
|
||||
$file = $confDir . '/dial' . $put_file . '.xml';
|
||||
file_put_contents($file, $xmlstr);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function create_xmlSoftkeyset($config, $confDir, $name)
|
||||
{
|
||||
if (empty($config[$name])) {
|
||||
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();
|
||||
} else {
|
||||
return array('error' => 'Invalid softkey Name' . $name);
|
||||
}
|
||||
}
|
||||
$errors = array();
|
||||
$xmlstr = "<softKeyCfg>\n";
|
||||
$xmlstr .= "<versionStamp>" . time() . "</versionStamp>\n";
|
||||
$typeSoft = $confDir["tftp_templates"] . '/SIPTypeSoftKey.xml_template';
|
||||
$read_soft = "";
|
||||
if (file_exists($typeSoft)) {
|
||||
$f_read = fopen($typeSoft, 'r');
|
||||
while (!feof($f_read)) {
|
||||
$read_soft .= fread($f_read, 8192);
|
||||
}
|
||||
fclose($f_read);
|
||||
}
|
||||
$xmlstr .= $read_soft;
|
||||
$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>\n";
|
||||
}
|
||||
$xmlstr .= " </softKeySets>\n";
|
||||
|
||||
$xmlstr .= '</softKeyCfg>';
|
||||
if (empty($errors)) {
|
||||
$file = $confDir["tftp_softkey"] . '/softkey' . $name . '.xml';
|
||||
file_put_contents($file, $xmlstr);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
private function replaceSimpleXmlNode($xml, $element = SimpleXMLElement)
|
||||
{
|
||||
$dom = dom_import_simplexml($xml);
|
||||
$import = $dom->ownerDocument->importNode(
|
||||
dom_import_simplexml($element),
|
||||
true
|
||||
);
|
||||
$dom->parentNode->replaceChild($import, $dom);
|
||||
}
|
||||
|
||||
private function appendSimpleXmlNode($xml, $element = SimpleXMLElement)
|
||||
{
|
||||
|
||||
$dom = dom_import_simplexml($xml);
|
||||
$import = $dom->ownerDocument->importNode(
|
||||
dom_import_simplexml($element),
|
||||
true
|
||||
);
|
||||
$dom->parentNode->appendChild($import->cloneNode(true));
|
||||
}
|
||||
}
|
|
@ -1,384 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\sccpManTraits;
|
||||
|
||||
trait ajaxHelper {
|
||||
|
||||
public function ajaxRequest($req, &$setting) {
|
||||
// Called first by BMO. Must return true or request will be aborted.
|
||||
// See https://wiki.freepbx.org/display/FOP/BMO+Ajax+Calls
|
||||
switch ($req) {
|
||||
case 'backupsettings':
|
||||
case 'savesettings':
|
||||
case 'save_hardware':
|
||||
case 'save_sip_hardware':
|
||||
case 'save_ruser':
|
||||
case 'save_dialplan_template':
|
||||
case 'delete_hardware':
|
||||
case 'getPhoneGrid':
|
||||
case 'getExtensionGrid':
|
||||
case 'getDeviceModel':
|
||||
case 'getUserGrid':
|
||||
case 'getSoftKey':
|
||||
case 'getDialTemplate':
|
||||
case 'create_hw_tftp':
|
||||
case 'reset_dev':
|
||||
case 'reset_token':
|
||||
case 'model_enabled':
|
||||
case 'model_disabled':
|
||||
case 'model_update':
|
||||
case 'model_add':
|
||||
case 'model_delete':
|
||||
case 'update_button_label':
|
||||
case 'updateSoftKey':
|
||||
case 'deleteSoftKey':
|
||||
case 'delete_dialplan':
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ajaxHandler is called after ajaxRequest returns true
|
||||
public function ajaxHandler() {
|
||||
$request = $_REQUEST;
|
||||
$msg = array();
|
||||
$cmd_id = $request['command'];
|
||||
switch ($cmd_id) {
|
||||
case 'savesettings':
|
||||
$action = isset($request['sccp_createlangdir']) ? $request['sccp_createlangdir'] : '';
|
||||
if ($action == 'yes') {
|
||||
$this->initializeTFtpLanguagePath();
|
||||
}
|
||||
$this->handleSubmit($request);
|
||||
// $this->saveSccpSettings();
|
||||
//$this->createDefaultSccpConfig();
|
||||
$this->createDefaultSccpXml();
|
||||
|
||||
$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)
|
||||
return array('status' => true, 'message' => $msg, 'reload' => true);
|
||||
break;
|
||||
case 'save_sip_hardware':
|
||||
case 'save_hardware':
|
||||
$this->saveSccpDevice($request);
|
||||
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice');
|
||||
|
||||
break;
|
||||
case 'save_ruser':
|
||||
//$res = $request;
|
||||
$res = $this->handleRoamingUsers($request);
|
||||
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'general');
|
||||
break;
|
||||
case 'save_dialplan_template':
|
||||
/* !TODO!: -TODO-: dialplan templates should be removed (only required for very old devices (like ATA) */
|
||||
// ------------------------------- Old + Sip device support - In the development---
|
||||
$res = $this->saveDialPlan($request);
|
||||
//public
|
||||
if (empty($res)) {
|
||||
return array('status' => true, 'search' => '?display=sccp_adv', 'hash' => 'sccpdialplan');
|
||||
} else {
|
||||
return array('status' => false, 'message' => print_r($res));
|
||||
}
|
||||
break;
|
||||
case 'delete_dialplan':
|
||||
if (!empty($request['dialplan'])) {
|
||||
$get_file = $request['dialplan'];
|
||||
$res = $this->deleteDialPlan($get_file);
|
||||
return array('status' => true, 'message' => 'Dial Template has been deleted ! ', 'table_reload' => true);
|
||||
} else {
|
||||
return array('status' => false, 'message' => print_r($res));
|
||||
}
|
||||
break;
|
||||
// ------------------------------- Old device support - In the development---
|
||||
case 'delete_hardware':
|
||||
if (!empty($request['idn'])) {
|
||||
foreach ($request['idn'] as $idv) {
|
||||
if ($this->strpos_array($idv, array('SEP', 'ATA', 'VG')) !== false) {
|
||||
$this->dbinterface->write('sccpdevice', array('name' => $idv), 'delete', "name");
|
||||
$this->dbinterface->write('sccpbuttons', array(), 'delete', '', $idv);
|
||||
$this->deleteSccpDeviceXML($idv); // Концы в вводу !!
|
||||
$this->aminterface->sccpDeviceReset($idv, 'reset');
|
||||
}
|
||||
}
|
||||
return array('status' => true, 'table_reload' => true, 'message' => 'Hardware device has been deleted! ');
|
||||
}
|
||||
break;
|
||||
case 'create_hw_tftp':
|
||||
$ver_id = ' Test !';
|
||||
if (!empty($request['idn'])) {
|
||||
$models = array();
|
||||
foreach ($request['idn'] as $idv) {
|
||||
$this->deleteSccpDeviceXML($idv);
|
||||
$models [] = array('name' => $idv);
|
||||
}
|
||||
} else {
|
||||
$this->deleteSccpDeviceXML('all');
|
||||
$models = $this->dbinterface->HWextension_db_SccpTableData("SccpDevice");
|
||||
}
|
||||
|
||||
$this->createDefaultSccpXml(); // Default XML
|
||||
$ver_id = ' on found active model !';
|
||||
foreach ($models as $data) {
|
||||
$ver_id = $this->createSccpDeviceXML($data['name']);
|
||||
if ($ver_id == -1) {
|
||||
return array('status' => false, 'message' => 'Error Create Configuration Divice :' . $data['name']);
|
||||
}
|
||||
};
|
||||
|
||||
if ($this->sccpvalues['siptftp']['data'] == 'on') { // Check SIP Support Enabled
|
||||
$this->createSccpXmlSoftkey(); // Create Softkey Sets for SIP
|
||||
}
|
||||
// !TODO!: -TODO-: Do these returned message strings work with i18n ?
|
||||
return array('status' => true, 'message' => 'Create new config files (version:' . $ver_id . ')');
|
||||
|
||||
break;
|
||||
case 'reset_token':
|
||||
case 'reset_dev':
|
||||
$msg = '';
|
||||
$msgr = array();
|
||||
$msgr[] = 'Reset command send';
|
||||
if (!empty($request['name'])) {
|
||||
foreach ($request['name'] as $idv) {
|
||||
$msg = strpos($idv, 'SEP-');
|
||||
if (!(strpos($idv, 'SEP') === false)) {
|
||||
if ($cmd_id == 'reset_token') {
|
||||
$res = $this->aminterface->sccpDeviceReset($idv, 'tokenack');
|
||||
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
|
||||
} else {
|
||||
$res = $this->aminterface->sccpDeviceReset($idv, 'reset');
|
||||
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
|
||||
}
|
||||
}
|
||||
if ($idv == 'all') {
|
||||
$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->aminterface->sccpDeviceReset($idv, 'tokenack');
|
||||
$msgr[] = 'Send Token reset to :' . $key;
|
||||
}
|
||||
} else {
|
||||
$res = $this->aminterface->sccpDeviceReset($idv, 'reset');
|
||||
$msgr[] = $res['Response'] . ' ' . $res['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array('status' => true, 'message' => $msgr, 'reload' => true);
|
||||
break;
|
||||
case 'update_button_label':
|
||||
$msg = '';
|
||||
$hw_list = array();
|
||||
if (!empty($request['name'])) {
|
||||
foreach ($request['name'] as $idv) {
|
||||
if (!(strpos($idv, 'SEP') === false)) {
|
||||
$hw_list[] = array('name' => $idv);
|
||||
}
|
||||
if ($idv == 'all') {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$res = $this->updateSccpButtons($hw_list);
|
||||
$msg .= $res['Response'] . ' raw: ' . $res['data'] . ' ';
|
||||
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');
|
||||
$upd_mode = 'replace';
|
||||
case 'model_update':
|
||||
if ($request['command'] == 'model_update') {
|
||||
$key_name = array('model','vendor','dns', 'buttons', 'loadimage', 'loadinformationid', 'nametemplate');
|
||||
$upd_mode = 'update';
|
||||
}
|
||||
if (!empty($request['model'])) {
|
||||
foreach ($key_name as $key => $value) {
|
||||
if (!empty($request[$value])) {
|
||||
$save_settings[$value] = $request[$value];
|
||||
} else {
|
||||
$save_settings[$value] = $this->val_null; // null
|
||||
}
|
||||
}
|
||||
$this->dbinterface->write('sccpdevmodel', $save_settings, $upd_mode, "model");
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
return $save_settings;
|
||||
break;
|
||||
case 'model_enabled':
|
||||
$model_set = '1'; // fall through intentionally
|
||||
case 'model_disabled':
|
||||
if ($request['command'] == 'model_disabled') {
|
||||
$model_set = '0';
|
||||
}
|
||||
$msg = '';
|
||||
$save_settings = array();
|
||||
if (!empty($request['model'])) {
|
||||
foreach ($request['model'] as $idv) {
|
||||
$this->dbinterface->write('sccpdevmodel', array('model' => $idv, 'enabled' => $model_set), 'update', "model");
|
||||
}
|
||||
}
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
break;
|
||||
case 'model_delete':
|
||||
if (!empty($request['model'])) {
|
||||
$this->dbinterface->write('sccpdevmodel', array('model' => $request['model']), 'delete', "model");
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
break;
|
||||
case 'getDeviceModel':
|
||||
switch ($request['type']) {
|
||||
case 'all':
|
||||
case 'extension':
|
||||
case 'enabled':
|
||||
$devices = $this->getSccpModelInformation($request['type'], $validate = true);
|
||||
break;
|
||||
}
|
||||
if (empty($devices)) {
|
||||
return array();
|
||||
}
|
||||
return $devices;
|
||||
break;
|
||||
|
||||
case 'deleteSoftKey':
|
||||
if (!empty($request['softkey'])) {
|
||||
$id_name = $request['softkey'];
|
||||
unset($this->sccp_conf_init[$id_name]);
|
||||
$this->createDefaultSccpConfig();
|
||||
$msg = print_r($this->aminterface->core_sccp_reload(), 1);
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
break;
|
||||
case 'updateSoftKey':
|
||||
if (!empty($request['id'])) {
|
||||
$id_name = preg_replace('/[^A-Za-z0-9]/', '', $request['id']);
|
||||
$this->sccp_conf_init[$id_name]['type'] = "softkeyset";
|
||||
foreach ($this->extconfigs->getextConfig('keyset') as $keyl => $vall) {
|
||||
if (!empty($request[$keyl])) {
|
||||
$this->sccp_conf_init[$id_name][$keyl] = $request[$keyl];
|
||||
}
|
||||
}
|
||||
$this->createDefaultSccpConfig();
|
||||
|
||||
// !TODO!: -TODO-: Check SIP Support Enabled
|
||||
$this->createSccpXmlSoftkey();
|
||||
$msg = print_r($this->aminterface->core_sccp_reload, 1);
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
}
|
||||
break;
|
||||
case 'getSoftKey':
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$keyl = 'default';
|
||||
foreach ($this->aminterface->sccp_list_keysets() as $keyl => $vall) {
|
||||
$result[$i]['softkeys'] = $keyl;
|
||||
if ($keyl == 'default') {
|
||||
foreach ($this->extconfigs->getextConfig('keyset') as $key => $value) {
|
||||
$result[$i][$key] = str_replace(',', '<br>', $value);
|
||||
}
|
||||
} else {
|
||||
foreach ($this->getMyConfig('softkeyset', $keyl) as $key => $value) {
|
||||
$result[$i][$key] = str_replace(',', '<br>', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
return $result;
|
||||
break;
|
||||
case 'getExtensionGrid':
|
||||
$result = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension');
|
||||
if (empty($result)) {
|
||||
return array();
|
||||
}
|
||||
return $result;
|
||||
break;
|
||||
case 'getPhoneGrid':
|
||||
$cmd_type = !empty($request['type']) ? $request['type'] : '';
|
||||
|
||||
$result = $this->dbinterface->HWextension_db_SccpTableData('SccpDevice', array('type' => $cmd_type));
|
||||
if ($cmd_type == 'cisco-sip') {
|
||||
return $result;
|
||||
}
|
||||
$staus = $this->aminterface->sccp_get_active_device();
|
||||
if (empty($result)) {
|
||||
$result = array();
|
||||
} else {
|
||||
foreach ($result as &$dev_id) {
|
||||
$id_name = $dev_id['name'];
|
||||
if (!empty($staus[$id_name])) {
|
||||
$dev_id['description'] = $staus[$id_name]['descr'];
|
||||
$dev_id['status'] = $staus[$id_name]['status'];
|
||||
$dev_id['address'] = $staus[$id_name]['address'];
|
||||
$dev_id['new_hw'] = 'N';
|
||||
$staus[$id_name]['news'] = 'N';
|
||||
} else {
|
||||
$dev_id['description'] = '- -';
|
||||
$dev_id['status'] = 'not connected';
|
||||
$dev_id['address'] = '- -';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($staus)) {
|
||||
foreach ($staus as $dev_ids) {
|
||||
$id_name = $dev_ids['name'];
|
||||
if (empty($dev_ids['news'])) {
|
||||
$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)) {
|
||||
$dev_addon = null;
|
||||
}
|
||||
$dev_schema = $this->getSccpModelInformation('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id']));
|
||||
if (empty($dev_schema)) {
|
||||
$dev_schema[0]['model'] = "ERROR in Model Schema";
|
||||
}
|
||||
$result[] = array(
|
||||
'name' => $id_name,
|
||||
'mac' => $id_name,
|
||||
'button' => '---',
|
||||
'type' => $dev_schema[0]['model'],
|
||||
'new_hw' => 'Y',
|
||||
'description' => '*NEW* ' . $dev_ids['descr'],
|
||||
'status' => '*NEW* ' . $dev_ids['status'],
|
||||
'address' => $dev_ids['address'],
|
||||
'addon' => $dev_addon
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
break;
|
||||
case 'getDialTemplate':
|
||||
// ------------------------------- Old device support - In the development---
|
||||
$result = $this->getDialPlanList();
|
||||
if (empty($result)) {
|
||||
$result = array();
|
||||
}
|
||||
return $result;
|
||||
break;
|
||||
case 'backupsettings':
|
||||
// ------------------------------- Old device support - In the development---
|
||||
$filename = $this->createSccpBackup();
|
||||
$file_name = basename($filename);
|
||||
|
||||
header("Content-Type: application/zip");
|
||||
header("Content-Disposition: attachment; filename=$file_name");
|
||||
header("Content-Length: " . filesize($filename));
|
||||
|
||||
readfile($filename);
|
||||
unlink($filename);
|
||||
|
||||
// return array('status' => false, 'message' => $result);
|
||||
return $result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,122 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\sccpManTraits;
|
||||
|
||||
trait bmoFunctions {
|
||||
/* unused but FPBX API requires it */
|
||||
|
||||
public function doConfigPageInit($page) {
|
||||
$this->doGeneralPost();
|
||||
}
|
||||
|
||||
/* unused but FPBX API requires it */
|
||||
|
||||
public function install() {
|
||||
|
||||
}
|
||||
|
||||
/* unused but FPBX API requires it */
|
||||
|
||||
public function uninstall() {
|
||||
|
||||
}
|
||||
|
||||
/* unused but FPBX API requires it */
|
||||
|
||||
public function backup() {
|
||||
|
||||
}
|
||||
|
||||
/* unused but FPBX API requires it */
|
||||
|
||||
public function restore($backup) {
|
||||
|
||||
}
|
||||
|
||||
public function getActionBar($request) {
|
||||
$buttons = array();
|
||||
switch ($request['display']) {
|
||||
case 'sccp_adv':
|
||||
if (empty($request['tech_hardware'])) {
|
||||
break;
|
||||
}
|
||||
$buttons = array(
|
||||
'submit' => array(
|
||||
'name' => 'ajaxsubmit',
|
||||
'id' => 'ajaxsubmit',
|
||||
'value' => _("Save")
|
||||
),
|
||||
'Save' => array(
|
||||
'name' => 'ajaxsubmit2',
|
||||
'id' => 'ajaxsubmit2',
|
||||
'stayonpage' => 'yes',
|
||||
'value' => _("Save + Continue")
|
||||
),
|
||||
'cancel' => array(
|
||||
'name' => 'cancel',
|
||||
'id' => 'ajaxcancel',
|
||||
'data-search' => '?display=sccp_adv',
|
||||
'data-hash' => 'sccpdialplan',
|
||||
'value' => _("Cancel")
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'sccp_phone':
|
||||
if (empty($request['tech_hardware'])) {
|
||||
break;
|
||||
}
|
||||
$buttons = array(
|
||||
'submit' => array(
|
||||
'name' => 'ajaxsubmit',
|
||||
'id' => 'ajaxsubmit',
|
||||
'value' => _("Save")
|
||||
),
|
||||
'Save' => array(
|
||||
'name' => 'ajaxsubmit2',
|
||||
'id' => 'ajaxsubmit2',
|
||||
'stayonpage' => 'yes',
|
||||
'value' => _("Save + Continue")
|
||||
),
|
||||
'cancel' => array(
|
||||
'name' => 'cancel',
|
||||
'id' => 'ajaxcancel',
|
||||
'data-search' => '?display=sccp_phone',
|
||||
'data-hash' => 'sccpdevice',
|
||||
'value' => _("Cancel")
|
||||
),
|
||||
);
|
||||
|
||||
break;
|
||||
case 'sccpsettings':
|
||||
$buttons = array(
|
||||
'submit' => array(
|
||||
'name' => 'ajaxsubmit',
|
||||
'id' => 'ajaxsubmit',
|
||||
'value' => _("Submit")
|
||||
),
|
||||
'reset' => array(
|
||||
'name' => 'reset',
|
||||
'id' => 'ajaxcancel',
|
||||
'data-reload' => 'reload',
|
||||
'value' => _("Reset")
|
||||
),
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
public function getRightNav($request) {
|
||||
if (isset($request['tech_hardware']) && ($request['tech_hardware'] == 'cisco')) {
|
||||
return load_view(__DIR__ . "/views/hardware.rnav.php", array('request' => $request));
|
||||
}
|
||||
}
|
||||
|
||||
public function doGeneralPost() {
|
||||
if (!isset($_REQUEST['Submit'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,124 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\sccpManTraits;
|
||||
|
||||
trait helperfunctions {
|
||||
|
||||
function getIpInformation($type = '') {
|
||||
$interfaces = array();
|
||||
switch ($type) {
|
||||
case 'ip4':
|
||||
exec("/sbin/ip -4 -o addr", $result, $ret);
|
||||
break;
|
||||
case 'ip6':
|
||||
exec("/sbin/ip -6 -o addr", $result, $ret);
|
||||
break;
|
||||
|
||||
default:
|
||||
exec("/sbin/ip -o addr", $result, $ret);
|
||||
break;
|
||||
}
|
||||
foreach ($result as $line) {
|
||||
$vals = preg_split("/\s+/", $line);
|
||||
if ($vals[3] == "mtu") {
|
||||
continue;
|
||||
}
|
||||
if ($vals[2] != "inet" && $vals[2] != "inet6") {
|
||||
continue;
|
||||
}
|
||||
if (preg_match("/(.+?)(?:@.+)?:$/", $vals[1], $res)) {
|
||||
continue;
|
||||
}
|
||||
$ret = preg_match("/(\d*+.\d*+.\d*+.\d*+)[\/(\d*+)]*/", $vals[3], $ip);
|
||||
|
||||
$interfaces[$vals[1] . ':' . $vals[2]] = array('name' => $vals[1], 'type' => $vals[2], 'ip' => ((empty($ip[1]) ? '' : $ip[1])));
|
||||
}
|
||||
return $interfaces;
|
||||
}
|
||||
|
||||
private function before($thing, $inthat) {
|
||||
return substr($inthat, 0, strpos($inthat, $thing));
|
||||
}
|
||||
|
||||
private function array_key_exists_recursive($key, $arr) {
|
||||
if (array_key_exists($key, $arr)) {
|
||||
return true;
|
||||
}
|
||||
foreach ($arr as $currentKey => $value) {
|
||||
if (is_array($value)) {
|
||||
return $this->array_key_exists_recursive($key, $value);
|
||||
}
|
||||
}
|
||||
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 findAllFiles($dir, $file_mask = null, $mode = 'full') {
|
||||
$result = null;
|
||||
if (empty($dir) || (!file_exists($dir))) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$root = scandir($dir);
|
||||
foreach ($root as $value) {
|
||||
if ($value === '.' || $value === '..') {
|
||||
continue;
|
||||
}
|
||||
if (is_file("$dir/$value")) {
|
||||
$filter = false;
|
||||
if (!empty($file_mask)) {
|
||||
if (is_array($file_mask)) {
|
||||
foreach ($file_mask as $k) {
|
||||
if (strpos(strtolower($value), strtolower($k)) !== false) {
|
||||
$filter = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (strpos(strtolower($value), strtolower($file_mask)) !== false) {
|
||||
$filter = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$filter = true;
|
||||
}
|
||||
if ($filter) {
|
||||
if ($mode == 'fileonly') {
|
||||
$result[] = "$value";
|
||||
} else {
|
||||
$result[] = "$dir/$value";
|
||||
}
|
||||
} else {
|
||||
$result[] = null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$sub_fiend = $this->findAllFiles("$dir/$value", $file_mask, $mode);
|
||||
if (!empty($sub_fiend)) {
|
||||
foreach ($sub_fiend as $sub_value) {
|
||||
if (!empty($sub_value)) {
|
||||
$result[] = $sub_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"rawname": "sccp_manager",
|
||||
"repo": "extended",
|
||||
"name": "Sccp Manager",
|
||||
"version": "14.2.0.2",
|
||||
"publisher": "Steve Lad",
|
||||
"license": "GPL",
|
||||
"licenselink": "http://www.gnu.org/licenses/gpl.txt",
|
||||
"changelog": [
|
||||
"*14.2.0.2* First release of new version without old interface",
|
||||
"*13.0.0.1* Packaging of ver 1.0.0.1",
|
||||
"*12.0.0.1* Packaging of ver 1.0.0.1"
|
||||
],
|
||||
"category": "Settings",
|
||||
"description": "The Cisco Manager module lets you manage the chan-sccp module.",
|
||||
"depends": {
|
||||
"version": "14.0",
|
||||
},
|
||||
"supported": {
|
||||
"version": "13.0"
|
||||
},
|
||||
"location": "https://github.com/chan-sccp/sccp_manager/archive/refs/tags/V14.2.0.2.tar.gz",
|
||||
"md5sum": "885935a928b29927a2f9006eda20b549",
|
||||
"packaged": "3362963"
|
||||
}
|
|
@ -99,6 +99,7 @@
|
|||
<span id="new_dns-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="new_buttons"><?php echo _('Model Line Buttons');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="new_buttons"></i>
|
||||
|
@ -109,6 +110,7 @@
|
|||
<span id="new_buttons-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="new_loadimage"><?php echo _('Load Image');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="new_loadimage"></i>
|
||||
|
@ -147,6 +149,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="edit_model" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
|
@ -155,6 +159,7 @@
|
|||
<h4 class="modal-title" id="gridSystemModalLabel"><?php echo _('Modal title');?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="editd_model"><?php echo _('Device Model');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="editd_model"></i>
|
||||
|
@ -165,44 +170,10 @@
|
|||
<span id="editd_model-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="editd_vendor"><?php echo _('Vendor name');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="editd_vendor"></i>
|
||||
</div><div class="col-md-9">
|
||||
<input type="text" class="form-control" id="editd_vendor" name="editd_vendor" value="CISCO">
|
||||
</div> </div></div>
|
||||
<div class="row"><div class="col-md-12">
|
||||
<span id="editd_vendor-help" class="help-block fpbx-help-block">Use "CISCO" for the Skinny Client Control Protocol and "CISCO-SIP" for the CISCO Sip Protocol</span>
|
||||
</div></div></div>
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="editd_dns"><?php echo _('Expansion Module');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="editd_dns"></i>
|
||||
</div><div class="col-md-9">
|
||||
<select name="editd_dns" id="editd_dns">
|
||||
<option value="1" selected='selected'>Phone - no sidecars.</option>
|
||||
<option value="2">Phone - one sidecar.</option>
|
||||
<option value="3">Phone - two sidecars.</option>
|
||||
<option value="0">Sidecar</option>
|
||||
</select>
|
||||
</div> </div></div>
|
||||
<div class="row"><div class="col-md-12">
|
||||
<span id="editd_dns-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="editd_buttons"><?php echo _('Model Line Buttons');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="editd_buttons"></i>
|
||||
</div><div class="col-md-9">
|
||||
<input type="number" min="1" min="96" class="form-control" id="editd_buttons" name="editd_buttons" value="1">
|
||||
</div> </div></div>
|
||||
<div class="row"><div class="col-md-12">
|
||||
<span id="editd_buttons-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="editd_loadimage"><?php echo _('Load Image');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="editd_loadimage"></i>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="edit_devimage"></i>
|
||||
</div><div class="col-md-9">
|
||||
<input type="text" class="form-control" id="editd_loadimage" name="editd_loadimage" value="">
|
||||
</div> </div></div>
|
||||
|
@ -210,16 +181,6 @@
|
|||
<span id="editd_loadimage-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="editd_loadinformationid"><?php echo _('Load Information ID');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="editd_loadinformationid"></i>
|
||||
</div><div class="col-md-9">
|
||||
<input type="text" class="form-control" id="editd_loadinformationid" name="editd_loadinformationid" value="">
|
||||
</div> </div></div>
|
||||
<div class="row"><div class="col-md-12">
|
||||
<span id="editd_loadinformationid-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
<div class="element-container"><div class="row"> <div class="form-group"><div class="col-md-3">
|
||||
<label class="control-label" for="editd_nametemplate"><?php echo _('Model template XML');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="editd_nametemplate"></i>
|
||||
|
@ -229,6 +190,8 @@
|
|||
<div class="row"><div class="col-md-12">
|
||||
<span id="editd_nametemplate-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div></div></div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo _('Close');?></button>
|
||||
|
@ -263,13 +226,13 @@
|
|||
|
||||
function SetColColorFirm(value, row, index) {
|
||||
if (row['validate'].split(';')[0] === 'no') {
|
||||
return 'Not found '+ value;
|
||||
return 'No found '+ value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function SetColColorTempl(value, row, index) {
|
||||
if (row['validate'].split(';')[1] === 'no') {
|
||||
return 'Not found ' + value ;
|
||||
return 'No found ' + value ;
|
||||
}
|
||||
return value;
|
||||
|
||||
|
@ -297,10 +260,6 @@
|
|||
document.getElementById("editd_model").value = clr;
|
||||
document.getElementById("editd_loadimage").value = drow['loadimage'];
|
||||
document.getElementById("editd_nametemplate").value = drow['nametemplate'];
|
||||
document.getElementById("editd_loadinformationid").value = drow['loadinformationid'];
|
||||
document.getElementById("editd_dns").value = drow['dns'];
|
||||
document.getElementById("editd_vendor").value = drow['vendor'];
|
||||
document.getElementById("editd_buttons").value = drow['buttons'];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -28,12 +28,12 @@ $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-
|
|||
"D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA");
|
||||
$mysql_table = array("sccpdevice","sccpdeviceconfig");
|
||||
//$time_zone_name = timezone_identifiers_list();
|
||||
$time_zone = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9',
|
||||
'-08' => 'GMT -8', '-07' => 'GMT -7', '-06' => 'GMT -6', '-05' => 'GMT -5',
|
||||
'-04' => 'GMT -4', '-03' => 'GMT -3', '-02' => 'GMT -2', '-01' => 'GMT -1',
|
||||
'00' => 'GMT', '01' => 'GMT +1', '02' => 'GMT +2', '03' => 'GMT +3',
|
||||
'04' => 'GMT +4', '05' => 'GMT +5', '06' => 'GMT +6', '07' => 'GMT +7',
|
||||
'08' => 'GMT +8', '09' => 'GMT +9', '10' => 'GMT +10', '11'=> 'GMT +11', '12' => 'GMT +12');
|
||||
$time_zone = array('-12' => 'GTM -12', '-11' => 'GTM -11', '-10' => 'GTM -10', '-09' => 'GTM -9',
|
||||
'-08' => 'GTM -8', '-07' => 'GTM -7', '-06' => 'GTM -6', '-05' => 'GTM -5',
|
||||
'-04' => 'GTM -4', '-03' => 'GTM -3', '-02' => 'GTM -2', '-01' => 'GTM -1',
|
||||
'00' => 'GTM time', '01' => 'GTM +1', '02' => 'GTM +2', '03' => 'GTM +3',
|
||||
'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();
|
||||
|
@ -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()-> aminterface->sccp_list_keysets();
|
||||
//$sofkey_list = \FreePBX::Sccp_manager()-> srvinterface -> 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()->aminterface->sccp_list_keysets();
|
||||
$sofkey_list = \FreePBX::Sccp_manager()-> srvinterface -> 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,3 +1017,4 @@ if ($h_show==1) {
|
|||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ $test_ami = 0;
|
|||
$test_any = 0;
|
||||
|
||||
$driver = $this->FreePBX->Core->getAllDriversInfo();
|
||||
$core = $this->aminterface->getSCCPVersion();
|
||||
$ast_realtime = $this->aminterface->getRealTimeStatus();
|
||||
$core = $this->srvinterface->getSCCPVersion();
|
||||
$ast_realtime = $this->srvinterface->sccp_realtime_status();
|
||||
|
||||
//$ast_realm = (empty($ast_realtime['sccp']) ? '' : 'sccp');
|
||||
|
||||
|
@ -26,26 +26,20 @@ 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->aminterface->get_compatible_sccp();
|
||||
$compatible = $this->srvinterface->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']);
|
||||
/*
|
||||
$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.');
|
||||
|
||||
|
||||
|
@ -130,6 +124,333 @@ 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)) {
|
||||
?>
|
||||
<div class="fpbx-container container-fluid">
|
||||
|
|
Loading…
Reference in a new issue