Bug fix Reported by @MarcusRobichon

This commit is contained in:
PhantomVl 2019-01-11 12:48:49 +03:00
parent 28a051e01a
commit f457ce8259
10 changed files with 338 additions and 315 deletions

View file

@ -96,7 +96,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
private $tftpLang = array();
// private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
private $hint_context = array('default' => '@ext-local'); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
private $val_null = 'NONE'; /// REPLACE to null Field
public $sccp_model_list = array();
private $cnf_wr = null;
@ -104,7 +103,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
public $sccpvalues = array();
public $sccp_conf_init = array();
public $xml_data;
public $class_error; //error construct
public function __construct($freepbx = null) {
@ -384,7 +382,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
),
);
}
}
if (empty($this->pagedata)) {
@ -415,7 +412,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
"page" => 'views/server.info.php'
),
);
}
if (!empty($this->pagedata)) {
foreach ($this->pagedata as &$page) {
@ -436,7 +432,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
"name" => _("General SCCP Settings"),
"page" => 'views/server.info.php'
),
);
foreach ($this->pagedata as &$page) {
@ -447,7 +442,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
}
return $this->pagedata;
}
public function AdvServerShowPage() {
@ -898,21 +892,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
break;
// ------------------------------- Old deviece suport - In the development---
case 'backupsettings':
global $amp_conf;
$backup_files = array( $amp_conf['ASTETCDIR'].'/sccp.conf', $amp_conf['ASTETCDIR'].'/extensions_additional.conf', $amp_conf['ASTETCDIR'].'/extconfig.conf');
$result = $this->dbinterface->dump_sccp_tables($this->sccppath["tftp_path"],$amp_conf['AMPDBNAME'], $amp_conf['AMPDBUSER'], $amp_conf['AMPDBPASS']);
$backup_files[] = $result;
$zip = new \ZipArchive();
$filename = $result.".zip";
if ($zip->open($filename, \ZIPARCHIVE::CREATE)) {
foreach ($backup_files as $file) {
$zip->addFile($file);
}
$zip->close();
}
$filename = $this->sccp_create_sccp_backup();
$file_name = basename($filename);
header("Content-Type: application/zip");
@ -920,12 +900,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
header("Content-Length: " . filesize($filename));
readfile($filename);
unlink($result);
unlink($filename);
// return array('status' => false, 'message' => $result);
// return $result;
break;
}
}
@ -981,7 +960,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$value = $hw_prefix . $value;
}
$name_dev = $value;
}
break;
case 'disallow':
@ -1270,7 +1248,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
return;
}
public function getMyConfig($var = null, $id = "noid") {
// $final = false;
switch ($var) {
@ -1419,6 +1396,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
function Sccp_manager_get_config($engine) {
$this->debugdata($engine);
}
/*
function soundlang_hookGet_config($engine) {
@ -1438,6 +1416,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
}
}
*/
/**
* Retrieve Active Codecs
* return fiends Lag pack
@ -1689,7 +1668,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$data_value['tftp_path'] = $this->sccppath["tftp_path"];
$this->xmlinterface->create_default_XML($this->sccppath["tftp_path_store"], $data_value, $model_information, $lang_data);
}
/*
@ -1740,7 +1718,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
// return $this->sccppath["tftp_path_store"];
return $this->xmlinterface->create_SEP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data);
}
function sccp_delete_device_XML($dev_id = '') {
@ -1765,6 +1742,31 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
}
}
private function sccp_create_sccp_backup() {
global $amp_conf;
$backup_files = array($amp_conf['ASTETCDIR'] . '/sccp', $amp_conf['ASTETCDIR'] . '/extensions', $amp_conf['ASTETCDIR'] . '/extconfig',
$amp_conf['ASTETCDIR'] . '/res_config_mysql', $amp_conf['ASTETCDIR'] . '/res_mysql');
$backup_ext = array('.conf', '_additional.conf', '_custom.conf');
$result = $this->dbinterface->dump_sccp_tables($this->sccppath["tftp_path"], $amp_conf['AMPDBNAME'], $amp_conf['AMPDBUSER'], $amp_conf['AMPDBPASS']);
$zip = new \ZipArchive();
$filename = $result . ".zip";
if ($zip->open($filename, \ZIPARCHIVE::CREATE)) {
$zip->addFile($result);
foreach ($backup_files as $file) {
foreach ($backup_ext as $b_ext) {
if (file_exists($file . $b_ext)) {
$zip->addFile($file . $b_ext);
}
}
}
$zip->close();
}
unlink($result);
return $filename;
}
function sccp_create_sccp_init() {
// Make sccp.conf data
// [general]
@ -1902,7 +1904,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} else { // if not exist in system hints ..... ???????
$res[$name_l . $default_hint] = array('hint' => $name_l . $default_hint, 'name' => $name_l, 'label' => $value['label']);
}
}
// Update info from sip DB
/* !TODO!: Update Hint info from sip DB ??? */
@ -1995,25 +1996,35 @@ private function find_all_files($dir, $file_mask=null, $mode='full'){
$root = scandir($dir);
foreach ($root as $value) {
if($value === '.' || $value === '..') {continue;}
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;}
if (strpos(strtolower($value), strtolower($k)) !== false) {
$filter = true;
}
}
} else {
if (strpos(strtolower($value), strtolower($file_mask)) !== false) {$filter = true;}
if (strpos(strtolower($value), strtolower($file_mask)) !== false) {
$filter = true;
}
}
} else {
$filter = true;
}
} else {$filter = true;}
if ($filter) {
if ($mode == 'fileonly') {
$result[] = "$value";
} else {
$result[] = "$dir/$value";
}
} else {$result[]=null;}
} else {
$result[] = null;
}
continue;
}
$sub_fiend = $this->find_all_files("$dir/$value", $file_mask, $mode);

View file

@ -10,7 +10,6 @@ class extconfigs {
public function __construct($parent_class = null) {
$this->paren_class = $parent_class;
}
public function info() {
@ -212,7 +211,6 @@ class extconfigs {
'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight')
);
public function validate_init_path($confDir = '', $db_vars, $sccp_driver_replace = '') {
// global $db;
// global $amp_conf;
@ -358,6 +356,7 @@ class extconfigs {
$cnf_wr = \FreePBX::WriteConfig();
$cnf_read = \FreePBX::LoadConfig();
$def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => 'mysql,sccp,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');
@ -369,21 +368,33 @@ class extconfigs {
$res_conf = '';
$ext_conf = '';
if (file_exists($dir . '/extconfig.conf')) {
$ext_conf = $cnf_read->getConfig('extconfig.conf');
if (empty($ext_conf['settings']['sccpdevice'])) {
$res['extconfig'] = ' Options "Sccpdevice" not config ';
foreach ($backup_ext as $fext) {
if (file_exists($dir . '/extconfig' . $fext)) {
$ext_conf = $cnf_read->getConfig('extconfig' . $fext);
if (!empty($ext_conf['settings']['sccpdevice'])) {
$res['sccpdevice'] = 'OK';
$res['extconfigfile'] = 'extconfigfile'. $fext;
}
if (empty($ext_conf['settings']['sccpline'])) {
$res['extconfig'] .= ' Options "Sccpline" not config ';
$res['sccpline'] = 'OK';
}
if (empty($res['extconfig'])) {
}
}
$res['extconfig'] = 'OK';
if (empty($res['sccpdevice'])) {
$res['extconfig'] = ' Options "Sccpdevice" not config ';
}
} else {
if (empty($res['sccpline'])) {
$res['extconfig'] = ' Options "Sccpline" not config ';
}
if (empty($res['extconfigfile'])) {
$res['extconfig'] = 'File extconfig.conf not exist';
}
if (!empty($res_conf_sql)) {
if (file_exists($res_conf_sql)) {
$def_bd_config['dbsock'] = $res_conf_sql;
@ -414,7 +425,6 @@ class extconfigs {
if (empty($res['mysqlconfig'])) {
$res['mysqlconfig'] = 'OK';
}
}
if (empty($res['mysqlconfig'])) {
$res['mysqlconfig'] = 'Realtime Error: not found res_config_mysql.conf or res_mysql.conf configutation on the path :' . $dir;
@ -422,6 +432,4 @@ class extconfigs {
return $res;
}
}

View file

@ -608,8 +608,10 @@ class srvinterface {
fputs ($fp,"Events: on\r\n\r\n");
fputs ($fp,"Action: SCCPShowDevices\r\n");
fputs ($fp,"ResultFormat: command\r\n");
// $params = array('Segment' => 'device', 'ResultFormat'=>'command' );
// fputs ($fp,"Action: SCCPConfigMetaData\r\n");
// fputs ($fp,"Segment: device\r\n");
// fputs ($fp,"ResultFormat: command\r\n");
fputs ($fp,"\r\n");
/*

View file

@ -138,7 +138,7 @@ and open the template in the editor. Base Version before all crash :-)
<button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help>
</item>
<item type="IS" id="6" seq="20">
<item type="IS" id="6" seq="98">
<name>displayconfig</name>
<label>SCCP Config Mode </label>
<default>sccpgeneral</default>

View file

@ -139,7 +139,7 @@ and open the template in the editor. Base Version before all crash :-)
<button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help>
</item>
<item type="IS" id="6" seq="20">
<item type="IS" id="6" seq="98">
<name>displayconfig</name>
<label>SCCP Config Mode </label>
<default>sccpgeneral</default>

View file

@ -256,7 +256,7 @@ and open the template in the editor. Base Version before all crash :-)
<button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help>
</item>
<item type="IS" id="6" seq="20">
<item type="IS" id="6" seq="98">
<name>displayconfig</name>
<label>SCCP Config Mode </label>
<default>sccpgeneral</default>

View file

@ -258,7 +258,7 @@ and open the template in the editor. Base Version before all crash :-)
<button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help>
</item>
<item type="IS" id="6" seq="20">
<item type="IS" id="6" seq="98">
<name>displayconfig</name>
<label>SCCP Config Mode </label>
<default>sccpgeneral</default>

View file

@ -1,8 +1,8 @@
<?php
/*
* Hand DB Change :
ALTER TABLE `sccpline` CHANGE COLUMN `transfer` `transfer` ENUM('on','off') NULL DEFAULT NULL ;
ALTER TABLE `sccpdevice` CHANGE COLUMN `transfer` `transfer` ENUM('on','off') NULL DEFAULT NULL;
ALTER TABLE `asterisk`.`sccpline` CHANGE COLUMN `transfer` `transfer` ENUM('on','off') NULL DEFAULT NULL ;
ALTER TABLE `asterisk`.`sccpdevice` CHANGE COLUMN `transfer` `transfer` ENUM('on','off') NULL DEFAULT NULL;
*
*
*/
@ -654,6 +654,8 @@ function Setup_RealTime() {
$cnf_int = \FreePBX::Config();
$cnf_wr = \FreePBX::WriteConfig();
$cnf_read = \FreePBX::LoadConfig();
$backup_ext = array('_custom.conf', '.conf');
$def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline');
$def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'],
'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'],
@ -664,8 +666,13 @@ function Setup_RealTime() {
$res_conf_sql = ini_get('pdo_mysql.default_socket');
$res_conf = '';
$ext_conf = '';
if (file_exists($dir . '/extconfig.conf')) {
$ext_conf = $cnf_read->getConfig('extconfig.conf');
$ext_conf_file = 'extconfig.conf';
foreach ($backup_ext as $value) {
if (file_exists($dir . '/extconfig' . $value)) {
$ext_conf_file = 'extconfig' . $value;
$ext_conf = $cnf_read->getConfig($ext_conf_file);
break;
}
}
if (!empty($res_conf_sql)) {
if (file_exists($res_conf_sql)) {
@ -713,7 +720,7 @@ function Setup_RealTime() {
// $res_conf['general']['dbsock'] = $def_bd_config['dbsock'];
$cnf_wr->writeConfig('res_config_mysql.conf', $res_conf, false);
}
$cnf_wr->writeConfig('extconfig.conf', $ext_conf, false);
$cnf_wr->writeConfig($ext_conf_file, $ext_conf, false);
}
CheckSCCPManagerDBTables($table_req);

View file

@ -27,9 +27,6 @@ ksort($data_sort);
foreach ($data_sort as $key => $value) {
$hint_list[$value] = $hint_list1[$value];
}
//print_r($hint_list);
//ksort($hint_list);
//natsort($hint_list);
@ -100,9 +97,9 @@ if (!empty($_REQUEST['new_id'])) {
$defaul_tv = (empty($db_buttons[$line_id])) ? "empty": $db_buttons[$line_id]['type'];
$defaul_btn = (empty($db_buttons[$line_id])) ? "": $db_buttons[$line_id]['name'];
$defaul_opt = (empty($db_buttons[$line_id])) ? array(''): explode(',',$db_buttons[$line_id]['options']);
// print_r($defaul_btn);
// print_r($defaul_opt);
$show_form_mode = $defaul_tv;
$def_hint = '';
$def_silent = '';
@ -128,18 +125,17 @@ if (!empty($_REQUEST['new_id'])) {
}
foreach ($defaul_opt as $data_i) {
if (strpos($data_i,'@')>0) {
$defaul_btn = strtok($data_i,'@');
$test_btn = strtok($data_i,'@');
$def_hint = 'checked';
if ($defaul_btn == $defaul_opt[0]) {
$defaul_btn = $data_i;
if ($test_btn == $defaul_opt[0]) {
foreach ($lines_list as $data){
if ($data['name']==$defaul_btn) {
if ($data['name']==$test_btn) {
$show_form_mode = 'line';
$defaul_tv = 'monitor';
break;
}
}
} else {
$defaul_btn = $data_i;
}
}
}

View file

@ -62,7 +62,7 @@ if (empty($conf_realtime)) {
} else {
$rt_info = '';
foreach ($conf_realtime as $key => $value) {
if ($value != 'OK') {
if (($value != 'OK') && ($key != 'extconfigfile')) {
$rt_info .= '<div> Found error in section '.$key.' :'. $value. '</div>';
}
}
@ -71,20 +71,19 @@ if (empty($conf_realtime)) {
}
}
/*
global $amp_conf;
//global $amp_conf;
print_r("<br> Request:<br><pre>");
$json = '';
print_r("<br>");
//print_r($conf_realtime);
print_r("<br>");
print_r("<br>");
print_r($amp_conf);
print_r("DIRECT START");
//print_r($amp_conf);
// print_r("DIRECT START");
print_r("<br>");
// print_r($this->srvinterface->t_get_meta_data());
//print_r($this->extconfigs->validate_RealTime());
print("</pre>");
*/
// $lang_arr = $this->extconfigs->getextConfig('sccp_lang','sk_SK');
// print_r('<br>');
// print_r(timezone_identifiers_list());