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,15 +96,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
private $tftpLang = array(); private $tftpLang = array();
// private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! // private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
private $hint_context = array('default' => '@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 private $val_null = 'NONE'; /// REPLACE to null Field
public $sccp_model_list = array(); public $sccp_model_list = array();
private $cnf_wr = null; private $cnf_wr = null;
public $sccppath = array(); public $sccppath = array();
public $sccpvalues = array(); public $sccpvalues = array();
public $sccp_conf_init = array(); public $sccp_conf_init = array();
public $xml_data; public $xml_data;
public $class_error; //error construct public $class_error; //error construct
public function __construct($freepbx = null) { public function __construct($freepbx = null) {
@ -142,17 +140,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$this->init_sccp_path(); $this->init_sccp_path();
$this->initVarfromDefs(); $this->initVarfromDefs();
$this->initTftpLang(); $this->initTftpLang();
if (!empty($this->sccpvalues['SccpDBmodel'])) { if (!empty($this->sccpvalues['SccpDBmodel'])) {
if ($this->sccpvalues['sccp_compatible']['data'] > $this->sccpvalues['SccpDBmodel']['data']) { if ($this->sccpvalues['sccp_compatible']['data'] > $this->sccpvalues['SccpDBmodel']['data']) {
$this->sccpvalues['sccp_compatible']['data'] = $this->sccpvalues['SccpDBmodel']['data'] ; $this->sccpvalues['sccp_compatible']['data'] = $this->sccpvalues['SccpDBmodel']['data'];
} }
} }
// Load Advanced Form Constuctor Data // Load Advanced Form Constuctor Data
if (empty($this->sccpvalues['displayconfig'])) { if (empty($this->sccpvalues['displayconfig'])) {
$xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v' . $this->sccpvalues['sccp_compatible']['data']; $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v' . $this->sccpvalues['sccp_compatible']['data'];
} else { } else {
$xml_vars = __DIR__ . '/conf/'.$this->sccpvalues['displayconfig']['data'].'.xml.v'.$this->sccpvalues['sccp_compatible']['data']; $xml_vars = __DIR__ . '/conf/' . $this->sccpvalues['displayconfig']['data'] . '.xml.v' . $this->sccpvalues['sccp_compatible']['data'];
} }
if (!file_exists($xml_vars)) { if (!file_exists($xml_vars)) {
$xml_vars = __DIR__ . '/conf/sccpgeneral.xml'; $xml_vars = __DIR__ . '/conf/sccpgeneral.xml';
@ -369,23 +367,22 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
if (!empty($this->sccpvalues['displayconfig'])) { if (!empty($this->sccpvalues['displayconfig'])) {
if (!empty($this->sccpvalues['displayconfig']['data']) && ($this->sccpvalues['displayconfig']['data'] == 'sccpsimple')) { if (!empty($this->sccpvalues['displayconfig']['data']) && ($this->sccpvalues['displayconfig']['data'] == 'sccpsimple')) {
$this->pagedata = array( $this->pagedata = array(
"general" => array( "general" => array(
"name" => _("General SCCP Settings"), "name" => _("General SCCP Settings"),
"page" => 'views/server.setting.php' "page" => 'views/server.setting.php'
), ),
"sccpdevice" => array( "sccpdevice" => array(
"name" => _("SCCP Device"), "name" => _("SCCP Device"),
"page" => 'views/server.device.php' "page" => 'views/server.device.php'
), ),
"sccpinfo" => array( "sccpinfo" => array(
"name" => _("SCCP info"), "name" => _("SCCP info"),
"page" => 'views/server.info.php' "page" => 'views/server.info.php'
), ),
); );
} }
}
}
if (empty($this->pagedata)) { if (empty($this->pagedata)) {
// $driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER'); // $driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER');
@ -415,7 +412,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
"page" => 'views/server.info.php' "page" => 'views/server.info.php'
), ),
); );
} }
if (!empty($this->pagedata)) { if (!empty($this->pagedata)) {
foreach ($this->pagedata as &$page) { foreach ($this->pagedata as &$page) {
@ -427,27 +423,25 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} }
return $this->pagedata; return $this->pagedata;
} }
public function InfoServerShowPage() { public function InfoServerShowPage() {
$request = $_REQUEST; $request = $_REQUEST;
$action = !empty($request['action']) ? $request['action'] : ''; $action = !empty($request['action']) ? $request['action'] : '';
$this->pagedata = array( $this->pagedata = array(
"general" => array( "general" => array(
"name" => _("General SCCP Settings"), "name" => _("General SCCP Settings"),
"page" => 'views/server.info.php' "page" => 'views/server.info.php'
), ),
);
);
foreach ($this->pagedata as &$page) { foreach ($this->pagedata as &$page) {
ob_start(); ob_start();
include($page['page']); include($page['page']);
$page['content'] = ob_get_contents(); $page['content'] = ob_get_contents();
ob_end_clean(); ob_end_clean();
} }
return $this->pagedata; return $this->pagedata;
} }
public function AdvServerShowPage() { public function AdvServerShowPage() {
@ -898,21 +892,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
break; break;
// ------------------------------- Old deviece suport - In the development--- // ------------------------------- Old deviece suport - In the development---
case 'backupsettings': case 'backupsettings':
global $amp_conf; $filename = $this->sccp_create_sccp_backup();
$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();
}
$file_name = basename($filename); $file_name = basename($filename);
header("Content-Type: application/zip"); header("Content-Type: application/zip");
@ -920,12 +900,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
header("Content-Length: " . filesize($filename)); header("Content-Length: " . filesize($filename));
readfile($filename); readfile($filename);
unlink($result);
unlink($filename); unlink($filename);
// return array('status' => false, 'message' => $result);
// return $result;
break;
// return array('status' => false, 'message' => $result);
// return $result;
break;
} }
} }
@ -976,12 +955,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$value = strtoupper(str_replace(array('.', '-', ':'), '', $value)); // Delete mac Seporated from string $value = strtoupper(str_replace(array('.', '-', ':'), '', $value)); // Delete mac Seporated from string
$value = sprintf("%012s", $value); $value = sprintf("%012s", $value);
if ($hw_prefix == 'VG') { if ($hw_prefix == 'VG') {
$value = $hw_prefix . $value.'0'; $value = $hw_prefix . $value . '0';
} else { } else {
$value = $hw_prefix . $value; $value = $hw_prefix . $value;
} }
$name_dev = $value; $name_dev = $value;
} }
break; break;
case 'disallow': case 'disallow':
@ -1015,7 +993,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
foreach ($vval as $vkey => $vval) { foreach ($vval as $vkey => $vval) {
switch ($vkey) { switch ($vkey) {
case 'inherit': case 'inherit':
if ($vval=='on') { if ($vval == 'on') {
$arr_clear = TRUE; $arr_clear = TRUE;
// Злобный ХАК // Злобный ХАК
if ($key == 'permit') { if ($key == 'permit') {
@ -1024,7 +1002,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} }
break; break;
case 'internal': case 'internal':
if ($vval=='on') { if ($vval == 'on') {
$tmp_data .= 'internal;'; $tmp_data .= 'internal;';
} }
break; break;
@ -1034,13 +1012,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} }
} }
if (strlen($tmp_data) > 2) { if (strlen($tmp_data) > 2) {
while (substr($tmp_data,-1)=='/') { while (substr($tmp_data, -1) == '/') {
$tmp_data = substr($tmp_data, 0, -1); $tmp_data = substr($tmp_data, 0, -1);
} }
$arr_data .= $tmp_data . ';'; $arr_data .= $tmp_data . ';';
} }
} }
while (substr($arr_data,-1)==';') { while (substr($arr_data, -1) == ';') {
$arr_data = substr($arr_data, 0, -1); $arr_data = substr($arr_data, 0, -1);
} }
if ($arr_clear) { if ($arr_clear) {
@ -1202,23 +1180,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
switch ($vkey) { switch ($vkey) {
case 'inherit': case 'inherit':
case 'internal': case 'internal':
if ($vval=='on') { if ($vval == 'on') {
$tmp_data .= 'internal;'; $tmp_data .= 'internal;';
} }
break; break;
default: default:
$tmp_data .= $vval . '/'; $tmp_data .= $vval . '/';
break; break;
} }
} }
if (strlen($tmp_data) > 2) { if (strlen($tmp_data) > 2) {
while (substr($tmp_data,-1)=='/') { while (substr($tmp_data, -1) == '/') {
$tmp_data = substr($tmp_data, 0, -1); $tmp_data = substr($tmp_data, 0, -1);
} }
$arr_data .= $tmp_data. ';'; $arr_data .= $tmp_data . ';';
} }
} }
while (substr($arr_data,-1)==';') { while (substr($arr_data, -1) == ';') {
$arr_data = substr($arr_data, 0, -1); $arr_data = substr($arr_data, 0, -1);
} }
if (!($this->sccpvalues[$key1]['data'] == $arr_data)) { if (!($this->sccpvalues[$key1]['data'] == $arr_data)) {
@ -1270,7 +1248,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
return; return;
} }
public function getMyConfig($var = null, $id = "noid") { public function getMyConfig($var = null, $id = "noid") {
// $final = false; // $final = false;
switch ($var) { switch ($var) {
@ -1419,25 +1396,27 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
function Sccp_manager_get_config($engine) { function Sccp_manager_get_config($engine) {
$this->debugdata($engine); $this->debugdata($engine);
} }
/*
function soundlang_hookGet_config($engine) {
global $core_conf; /*
$this->debugdata($engine); function soundlang_hookGet_config($engine) {
global $core_conf;
$this->debugdata($engine);
switch ($engine) {
case "asterisk":
// if (isset($core_conf) && is_a($core_conf, "core_conf")) {
// $language = FreePBX::Soundlang()->getLanguage();
// if ($language != "") {
// $core_conf->addSipGeneral('language', $language);
// $core_conf->addIaxGeneral('language', $language);
// }
// }
break;
}
}
*/
switch ($engine) {
case "asterisk":
// if (isset($core_conf) && is_a($core_conf, "core_conf")) {
// $language = FreePBX::Soundlang()->getLanguage();
// if ($language != "") {
// $core_conf->addSipGeneral('language', $language);
// $core_conf->addIaxGeneral('language', $language);
// }
// }
break;
}
}
*/
/** /**
* Retrieve Active Codecs * Retrieve Active Codecs
* return fiends Lag pack * return fiends Lag pack
@ -1449,7 +1428,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
private function initTftpLang() { private function initTftpLang() {
$result = array(); $result = array();
if (empty($this->sccppath["tftp_path"]) || empty($this->sccppath["tftp_lang_path"]) ) { if (empty($this->sccppath["tftp_path"]) || empty($this->sccppath["tftp_lang_path"])) {
return; return;
} }
$dir = $this->sccppath["tftp_lang_path"]; $dir = $this->sccppath["tftp_lang_path"];
@ -1495,14 +1474,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
*/ */
// !TODO!: -TODO-: This function is getting a little big. Might be possible to sperate tftp work into it's own file/class. Initially, you need to remove the not working section and commented out section // !TODO!: -TODO-: This function is getting a little big. Might be possible to sperate tftp work into it's own file/class. Initially, you need to remove the not working section and commented out section
function init_sccp_path() { function init_sccp_path() {
global $db; global $db;
global $amp_conf; global $amp_conf;
$driver_revision = array('0' => '', '430' => '.v431', '431' => '.v432', '432' => '.v432', '433' => '.v433'); $driver_revision = array('0' => '', '430' => '.v431', '431' => '.v432', '432' => '.v432', '433' => '.v433');
$confDir = $amp_conf["ASTETCDIR"]; $confDir = $amp_conf["ASTETCDIR"];
if (empty($this->sccppath["asterisk"])) { if (empty($this->sccppath["asterisk"])) {
if (strlen($confDir) < 1) { if (strlen($confDir) < 1) {
$this->sccppath["asterisk"] = "/etc/asterisk"; $this->sccppath["asterisk"] = "/etc/asterisk";
@ -1510,30 +1489,30 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$this->sccppath["asterisk"] = $confDir; $this->sccppath["asterisk"] = $confDir;
} }
} }
$ver_id = $this->srvinterface->get_compatible_sccp(); $ver_id = $this->srvinterface->get_compatible_sccp();
if (!empty($this->sccpvalues['SccpDBmodel'])) { if (!empty($this->sccpvalues['SccpDBmodel'])) {
$ver_id =$this->sccpvalues['SccpDBmodel']['data']; $ver_id = $this->sccpvalues['SccpDBmodel']['data'];
} }
$driver = $this->FreePBX->Core->getAllDriversInfo(); $driver = $this->FreePBX->Core->getAllDriversInfo();
$sccp_driver_replace= ''; $sccp_driver_replace = '';
if (empty($driver['sccp'])) { if (empty($driver['sccp'])) {
$sccp_driver_replace = 'yes'; $sccp_driver_replace = 'yes';
} else { } else {
if (empty($driver['sccp']['Version'])) { if (empty($driver['sccp']['Version'])) {
$sccp_driver_replace = 'yes'; $sccp_driver_replace = 'yes';
} else { } else {
if ($driver['sccp']['Version'] != $this->sccp_driver_ver.$driver_revision[$ver_id]) { if ($driver['sccp']['Version'] != $this->sccp_driver_ver . $driver_revision[$ver_id]) {
$sccp_driver_replace = 'yes'; $sccp_driver_replace = 'yes';
} }
} }
} }
// $this->sccpvalues['sccp_compatible'] = '11'; // $this->sccpvalues['sccp_compatible'] = '11';
$this->sccpvalues['sccp_compatible'] = array('keyword' => 'compatible', 'data' => $ver_id, 'type' => '1', 'seq' => '99'); $this->sccpvalues['sccp_compatible'] = array('keyword' => 'compatible', 'data' => $ver_id, 'type' => '1', 'seq' => '99');
$this->sccppath = $this->extconfigs->validate_init_path($confDir, $this->sccpvalues, $sccp_driver_replace); $this->sccppath = $this->extconfigs->validate_init_path($confDir, $this->sccpvalues, $sccp_driver_replace);
$driver = $this->FreePBX->Core->getAllDriversInfo(); // ?????? $driver = $this->FreePBX->Core->getAllDriversInfo(); // ??????
$read_config = $this->cnf_read->getConfig('sccp.conf'); $read_config = $this->cnf_read->getConfig('sccp.conf');
@ -1548,10 +1527,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$hint = $this->srvinterface->sccp_list_hints(); $hint = $this->srvinterface->sccp_list_hints();
foreach ($hint as $key => $value) { foreach ($hint as $key => $value) {
if ($this->hint_context['default'] != $value) { if ($this->hint_context['default'] != $value) {
$this->hint_context[$key] = $value; $this->hint_context[$key] = $value;
} }
} }
} }
/* /*
@ -1689,7 +1668,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$data_value['tftp_path'] = $this->sccppath["tftp_path"]; $data_value['tftp_path'] = $this->sccppath["tftp_path"];
$this->xmlinterface->create_default_XML($this->sccppath["tftp_path_store"], $data_value, $model_information, $lang_data); $this->xmlinterface->create_default_XML($this->sccppath["tftp_path_store"], $data_value, $model_information, $lang_data);
} }
/* /*
@ -1711,23 +1689,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$data_value['server_if_list'] = $this->getIP_information(); $data_value['server_if_list'] = $this->getIP_information();
$dev_config['tftp_path'] = $this->sccppath["tftp_path"]; $dev_config['tftp_path'] = $this->sccppath["tftp_path"];
$dev_config['tftp_firmware'] = ''; $dev_config['tftp_firmware'] = '';
/* if (!empty($this->sccpvalues['tftp_rewrite'])) { /* if (!empty($this->sccpvalues['tftp_rewrite'])) {
if ( $this->sccpvalues['tftp_rewrite']['data'] == 'internal' ) { if ( $this->sccpvalues['tftp_rewrite']['data'] == 'internal' ) {
$dir_list = $this->find_all_files($dev_config['tftp_path'], $dev_config['loadimage']); $dir_list = $this->find_all_files($dev_config['tftp_path'], $dev_config['loadimage']);
foreach ($dir_list as $filek){ foreach ($dir_list as $filek){
if (!empty($filek)) { if (!empty($filek)) {
$fnd_path= ''; $fnd_path= '';
$fnd_path = str_replace($dev_config['tftp_path'],'',$filek); $fnd_path = str_replace($dev_config['tftp_path'],'',$filek);
$fnd_path = substr($fnd_path,1,strpos($fnd_path, $dev_config['loadimage'])-1); $fnd_path = substr($fnd_path,1,strpos($fnd_path, $dev_config['loadimage'])-1);
if (!empty($fnd_path)) { if (!empty($fnd_path)) {
$dev_config['tftp_firmware'] = $fnd_path; $dev_config['tftp_firmware'] = $fnd_path;
} }
break; break;
} }
} }
} }
} }
*/ */
$dev_config['addon_info'] = array(); $dev_config['addon_info'] = array();
if (!empty($dev_config['addon'])) { if (!empty($dev_config['addon'])) {
$hw_addon = explode(',', $dev_config['addon']); $hw_addon = explode(',', $dev_config['addon']);
@ -1738,9 +1716,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} }
$lang_data = $this->extconfigs->getextConfig('sccp_lang'); $lang_data = $this->extconfigs->getextConfig('sccp_lang');
// return $this->sccppath["tftp_path_store"]; // 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); 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 = '') { 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() { function sccp_create_sccp_init() {
// Make sccp.conf data // Make sccp.conf data
// [general] // [general]
@ -1805,12 +1807,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$search_mode = ''; $search_mode = '';
if (!empty($this->sccpvalues['tftp_rewrite'])) { if (!empty($this->sccpvalues['tftp_rewrite'])) {
$search_mode = $this->sccpvalues['tftp_rewrite']['data']; $search_mode = $this->sccpvalues['tftp_rewrite']['data'];
if ( $search_mode == 'pro' ) { if ($search_mode == 'pro') {
$dir_list = $this->find_all_files($dir, $file_ext, 'fileonly'); $dir_list = $this->find_all_files($dir, $file_ext, 'fileonly');
} else { } else {
$dir_list = $this->find_all_files($dir, $file_ext); $dir_list = $this->find_all_files($dir, $file_ext);
} }
} else { } else {
$dir_list = $this->find_all_files($dir, $file_ext, 'fileonly'); $dir_list = $this->find_all_files($dir, $file_ext, 'fileonly');
} }
@ -1821,8 +1823,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$raw_settings[$i]['validate'] = '-;-'; $raw_settings[$i]['validate'] = '-;-';
if (!empty($raw_settings[$i]['loadimage'])) { if (!empty($raw_settings[$i]['loadimage'])) {
$raw_settings[$i]['validate'] = 'no;'; $raw_settings[$i]['validate'] = 'no;';
if ((strtolower($raw_settings[$i]['vendor'] == 'cisco')) || !empty($dir_list)) { if ((strtolower($raw_settings[$i]['vendor'] == 'cisco')) || !empty($dir_list)) {
foreach ($dir_list as $filek){ foreach ($dir_list as $filek) {
switch ($search_mode) { switch ($search_mode) {
case 'pro': case 'pro':
case 'on': case 'on':
@ -1832,12 +1834,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} }
break; break;
case 'internal2': case 'internal2':
break; break;
case 'off': case 'off':
default: // Place in root TFTP dir default: // Place in root TFTP dir
// $raw_settings[$i]['buttons'] = $dir.'/'.$raw_settings[$i]['loadimage']; // $raw_settings[$i]['buttons'] = $dir.'/'.$raw_settings[$i]['loadimage'];
if (strpos(strtolower($filek), strtolower($dir.'/'.$raw_settings[$i]['loadimage'])) !== false) { if (strpos(strtolower($filek), strtolower($dir . '/' . $raw_settings[$i]['loadimage'])) !== false) {
// if (strpos(strtolower($filek), strtolower($raw_settings[$i]['loadimage'])) !== false) { // if (strpos(strtolower($filek), strtolower($raw_settings[$i]['loadimage'])) !== false) {
$raw_settings[$i]['validate'] = 'yes;'; $raw_settings[$i]['validate'] = 'yes;';
} }
@ -1845,26 +1847,26 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
} }
} }
} }
/* OLD search /* OLD search
$file = $dir . '/' . $raw_settings[$i]['loadimage']; $file = $dir . '/' . $raw_settings[$i]['loadimage'];
if (is_dir($file)) { if (is_dir($file)) {
$file .= '/' . $raw_settings[$i]['loadimage']; $file .= '/' . $raw_settings[$i]['loadimage'];
} }
$raw_settings[$i]['validate'] = 'no;'; $raw_settings[$i]['validate'] = 'no;';
if (strtolower($raw_settings[$i]['vendor']) == 'cisco') { if (strtolower($raw_settings[$i]['vendor']) == 'cisco') {
foreach ($file_ext as $value) { foreach ($file_ext as $value) {
if (file_exists($file . $value)) { if (file_exists($file . $value)) {
$raw_settings[$i]['validate'] = 'yes;'; $raw_settings[$i]['validate'] = 'yes;';
break; break;
} }
} }
} else { } else {
if (file_exists($file)) { if (file_exists($file)) {
$raw_settings[$i]['validate'] = 'yes;'; $raw_settings[$i]['validate'] = 'yes;';
} }
} }
* *
*/ */
} else { } else {
$raw_settings[$i]['validate'] = '-;'; $raw_settings[$i]['validate'] = '-;';
} }
@ -1887,29 +1889,28 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$res = array(); $res = array();
$default_hint = '@ext-local'; $default_hint = '@ext-local';
// get all hints [101@ext-local] => 101@ext-local // get all hints [101@ext-local] => 101@ext-local
$tmp_data = $this->srvinterface->sccp_list_all_hints(); $tmp_data = $this->srvinterface->sccp_list_all_hints();
foreach ($tmp_data as $value) { foreach ($tmp_data as $value) {
/* !TODO!: Add Hint Filtred List */ /* !TODO!: Add Hint Filtred List */
$res[$value] = array('hint' => $value, 'name' => before('@', $value), 'label' => $value ); $res[$value] = array('hint' => $value, 'name' => before('@', $value), 'label' => $value);
} }
// Update info from sccp_db // Update info from sccp_db
$tmp_data = $this->dbinterface->get_db_SccpTableData('SccpExtension'); $tmp_data = $this->dbinterface->get_db_SccpTableData('SccpExtension');
foreach ($tmp_data as $value) { foreach ($tmp_data as $value) {
$name_l = $value['name']; $name_l = $value['name'];
if (!empty($res[$name_l.$default_hint])) { if (!empty($res[$name_l . $default_hint])) {
$res[$name_l.$default_hint]['name'] = $name_l; $res[$name_l . $default_hint]['name'] = $name_l;
$res[$name_l.$default_hint]['label'] = $value['label']; $res[$name_l . $default_hint]['label'] = $value['label'];
} else { // if not exist in system hints ..... ??????? } else { // if not exist in system hints ..... ???????
$res[$name_l.$default_hint] = array('hint' => $name_l.$default_hint, 'name' => $name_l, 'label' => $value['label'] ); $res[$name_l . $default_hint] = array('hint' => $name_l . $default_hint, 'name' => $name_l, 'label' => $value['label']);
} }
} }
// Update info from sip DB // Update info from sip DB
/* !TODO!: Update Hint info from sip DB ??? */ /* !TODO!: Update Hint info from sip DB ??? */
return $res; return $res;
} }
function getIP_information() { function getIP_information() {
$interfaces['auto'] = array('0.0.0.0', 'All', '0'); $interfaces['auto'] = array('0.0.0.0', 'All', '0');
@ -1968,64 +1969,74 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
// $dom = dom_import_simplexml($node); // $dom = dom_import_simplexml($node);
// $dom->parentNode->removeChild($dom); // $dom->parentNode->removeChild($dom);
// } // }
private function strpos_array($haystack, $needles) { private function strpos_array($haystack, $needles) {
if (is_array($needles)) { if (is_array($needles)) {
foreach ($needles as $str) { foreach ($needles as $str) {
if (is_array($str)) { if (is_array($str)) {
$pos = strpos_array($haystack, $str); $pos = strpos_array($haystack, $str);
} else { } else {
$pos = strpos($haystack, $str); $pos = strpos($haystack, $str);
}
if ($pos !== FALSE) {
return $pos;
}
} }
if ($pos !== FALSE) { } else {
return $pos; return strpos($haystack, $needles);
}
return FALSE;
}
private function find_all_files($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->find_all_files("$dir/$value", $file_mask, $mode);
if (!empty($sub_fiend)) {
foreach ($sub_fiend as $sub_value) {
if (!empty($sub_value)) {
$result[] = $sub_value;
}
}
} }
} }
} else {
return strpos($haystack, $needles);
}
return FALSE;
}
private function find_all_files($dir, $file_mask=null, $mode='full'){
$result = NULL;
if (empty($dir) || (!file_exists($dir))) {
return $result; 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->find_all_files("$dir/$value",$file_mask,$mode);
if (!empty($sub_fiend)) {
foreach($sub_fiend as $sub_value) {
if (!empty($sub_value)) {
$result[]=$sub_value;
}
}
}
}
return $result;
}
} }

View file

@ -9,8 +9,7 @@ namespace FreePBX\modules\Sccp_manager;
class extconfigs { class extconfigs {
public function __construct($parent_class = null) { public function __construct($parent_class = null) {
$this->paren_class = $parent_class; $this->paren_class = $parent_class;
} }
public function info() { public function info() {
@ -212,30 +211,29 @@ class extconfigs {
'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight') 'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight')
); );
public function validate_init_path($confDir = '', $db_vars, $sccp_driver_replace = '') {
public function validate_init_path($confDir = '', $db_vars, $sccp_driver_replace='') {
// global $db; // global $db;
// global $amp_conf; // global $amp_conf;
// *** Setings for Provision Sccp // *** Setings for Provision Sccp
$adv_config = Array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings', $adv_config = Array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings',
'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates'); 'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates');
$adv_tree['pro'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales'); $adv_tree['pro'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales');
// $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => ''); // $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'); $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'); $base_tree = Array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware');
if (empty($confDir)) { if (empty($confDir)) {
return array('error' => 'empty СonfDir' ); return array('error' => 'empty СonfDir');
} }
$base_config = Array( 'asterisk' => $confDir, 'sccp_conf' => $confDir . '/sccp.conf', 'tftp_path' => ''); $base_config = Array('asterisk' => $confDir, 'sccp_conf' => $confDir . '/sccp.conf', 'tftp_path' => '');
// Test Base dir (/tftproot) // Test Base dir (/tftproot)
if (!empty($db_vars["tftp_path"])) { if (!empty($db_vars["tftp_path"])) {
if (file_exists($db_vars["tftp_path"]["data"])) { if (file_exists($db_vars["tftp_path"]["data"])) {
$base_config["tftp_path"] = $db_vars["tftp_path"]["data"]; $base_config["tftp_path"] = $db_vars["tftp_path"]["data"];
} }
} }
if (empty($base_config["tftp_path"])) { if (empty($base_config["tftp_path"])) {
@ -247,25 +245,25 @@ class extconfigs {
if (!empty($this->paren_class)) { if (!empty($this->paren_class)) {
$this->paren_class->class_error['tftp_path'] = 'Tftp path not defined'; $this->paren_class->class_error['tftp_path'] = 'Tftp path not defined';
} }
return array('error' => 'empty tftp_path' ); return array('error' => 'empty tftp_path');
} }
if (!is_writeable($base_config["tftp_path"])) { if (!is_writeable($base_config["tftp_path"])) {
if (!empty($this->paren_class)) { if (!empty($this->paren_class)) {
$this->paren_class->class_error['tftp_path'] = 'No write permision on tftp DIR'; $this->paren_class->class_error['tftp_path'] = 'No write permision on tftp DIR';
} }
return array('error' => 'No write permision on tftp DIR' ); return array('error' => 'No write permision on tftp DIR');
} }
// END Test Base dir (/tftproot) // END Test Base dir (/tftproot)
if (!empty($db_vars['tftp_rewrite_path'])) { if (!empty($db_vars['tftp_rewrite_path'])) {
$adv_ini = $db_vars['tftp_rewrite_path']["data"]; $adv_ini = $db_vars['tftp_rewrite_path']["data"];
} }
$adv_tree_mode = 'def'; $adv_tree_mode = 'def';
if (empty($db_vars["tftp_rewrite"])) { if (empty($db_vars["tftp_rewrite"])) {
$db_vars["tftp_rewrite"]["data"] = "off"; $db_vars["tftp_rewrite"]["data"] = "off";
} }
$adv_config['tftproot'] = $base_config["tftp_path"]; $adv_config['tftproot'] = $base_config["tftp_path"];
if ($db_vars["tftp_rewrite"]["data"] == 'pro') { if ($db_vars["tftp_rewrite"]["data"] == 'pro') {
$adv_tree_mode = 'pro'; $adv_tree_mode = 'pro';
@ -282,9 +280,9 @@ class extconfigs {
} }
foreach ($adv_tree[$adv_tree_mode] as $key => $value) { foreach ($adv_tree[$adv_tree_mode] as $key => $value) {
if (!empty($adv_config[$key])) { if (!empty($adv_config[$key])) {
if (!empty($value)) { if (!empty($value)) {
if (substr($adv_config[$key],0,1) != "/") { if (substr($adv_config[$key], 0, 1) != "/") {
$adv_config[$key] = $adv_config[$value].'/'.$adv_config[$key]; $adv_config[$key] = $adv_config[$value] . '/' . $adv_config[$key];
} }
} else { } else {
$adv_config[$key] = $adv_config['tftproot']; $adv_config[$key] = $adv_config['tftproot'];
@ -295,33 +293,33 @@ class extconfigs {
$base_config[$key] = $adv_config[$value]; $base_config[$key] = $adv_config[$value];
if (!file_exists($base_config[$key])) { if (!file_exists($base_config[$key])) {
if (!mkdir($base_config[$key], 0777, true)) { if (!mkdir($base_config[$key], 0777, true)) {
die('Error creating dir : '. $base_config[$key]); die('Error creating dir : ' . $base_config[$key]);
} }
} }
} }
// $base_config['External_ini'] = $adv_config; // $base_config['External_ini'] = $adv_config;
// $base_config['External_mode'] = $adv_tree_mode; // $base_config['External_mode'] = $adv_tree_mode;
/* /*
if (!empty($this->sccppath["tftp_path"])) { if (!empty($this->sccppath["tftp_path"])) {
$this->sccppath["tftp_DP"] = $this->sccppath["tftp_path"] . '/Dialplan'; $this->sccppath["tftp_DP"] = $this->sccppath["tftp_path"] . '/Dialplan';
if (!file_exists($this->sccppath["tftp_DP"])) { if (!file_exists($this->sccppath["tftp_DP"])) {
if (!mkdir($this->sccppath["tftp_DP"], 0777, true)) { if (!mkdir($this->sccppath["tftp_DP"], 0777, true)) {
die('Error creating DialPlan template dir'); die('Error creating DialPlan template dir');
} }
} }
} }
*/ */
// TFTP -REWrite double model // TFTP -REWrite double model
if (empty($_SERVER['DOCUMENT_ROOT'])) { if (empty($_SERVER['DOCUMENT_ROOT'])) {
if (!empty($this->paren_class)) { if (!empty($this->paren_class)) {
$this->paren_class->class_error['DOCUMENT_ROOT'] = 'Empty DOCUMENT_ROOT'; $this->paren_class->class_error['DOCUMENT_ROOT'] = 'Empty DOCUMENT_ROOT';
} }
$base_config['error'] = 'Empty DOCUMENT_ROOT'; $base_config['error'] = 'Empty DOCUMENT_ROOT';
return $base_config; return $base_config;
} }
if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) { if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) {
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/';
$dst_path = $base_config["tftp_templates"] . '/'; $dst_path = $base_config["tftp_templates"] . '/';
@ -329,7 +327,7 @@ class extconfigs {
copy($filename, $dst_path . basename($filename)); copy($filename, $dst_path . basename($filename));
} }
} }
$dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php'; $dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php';
if (!file_exists($dst) || $sccp_driver_replace == 'yes') { if (!file_exists($dst) || $sccp_driver_replace == 'yes') {
@ -340,24 +338,25 @@ class extconfigs {
$src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst); $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst);
copy($src_path, $dst); copy($src_path, $dst);
} }
} }
if (!file_exists($base_config["sccp_conf"])) { // System re Config if (!file_exists($base_config["sccp_conf"])) { // System re Config
$sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf'); $sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf');
file_put_contents($base_config["sccp_conf"], $sccpfile); file_put_contents($base_config["sccp_conf"], $sccpfile);
} }
return $base_config; return $base_config;
} }
public function validate_RealTime() { public function validate_RealTime() {
global $amp_conf; global $amp_conf;
$res = Array(); $res = Array();
$cnf_int = \FreePBX::Config(); $cnf_int = \FreePBX::Config();
$cnf_wr = \FreePBX::WriteConfig(); $cnf_wr = \FreePBX::WriteConfig();
$cnf_read = \FreePBX::LoadConfig(); $cnf_read = \FreePBX::LoadConfig();
$def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline'); $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'], $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'],
'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], 'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'],
'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock'); 'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock');
@ -369,22 +368,34 @@ class extconfigs {
$res_conf = ''; $res_conf = '';
$ext_conf = ''; $ext_conf = '';
if (file_exists($dir . '/extconfig.conf')) { foreach ($backup_ext as $fext) {
$ext_conf = $cnf_read->getConfig('extconfig.conf'); if (file_exists($dir . '/extconfig' . $fext)) {
if (empty($ext_conf['settings']['sccpdevice'])) { $ext_conf = $cnf_read->getConfig('extconfig' . $fext);
$res['extconfig'] = ' Options "Sccpdevice" not config '; if (!empty($ext_conf['settings']['sccpdevice'])) {
$res['sccpdevice'] = 'OK';
$res['extconfigfile'] = 'extconfigfile'. $fext;
}
if (empty($ext_conf['settings']['sccpline'])) {
$res['sccpline'] = 'OK';
}
} }
if (empty($ext_conf['settings']['sccpline'])) { }
$res['extconfig'] .= ' Options "Sccpline" not config ';
} $res['extconfig'] = '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'; $res['extconfig'] = 'File extconfig.conf not exist';
} }
if (!empty($res_conf_sql)) {
if (!empty($res_conf_sql)) {
if (file_exists($res_conf_sql)) { if (file_exists($res_conf_sql)) {
$def_bd_config['dbsock'] = $res_conf_sql; $def_bd_config['dbsock'] = $res_conf_sql;
} }
@ -394,7 +405,7 @@ class extconfigs {
if (empty($res_conf[$def_bd_sec])) { if (empty($res_conf[$def_bd_sec])) {
$res['mysqlconfig'] = 'Not Config in file: res_mysql.conf'; $res['mysqlconfig'] = 'Not Config in file: res_mysql.conf';
} else { } else {
if ($res_conf[$def_bd_sec]['dbsock'] != $def_bd_config['dbsock']) { if ($res_conf[$def_bd_sec]['dbsock'] != $def_bd_config['dbsock']) {
$res['mysqlconfig'] = 'Mysql Soket Error in file: res_mysql.conf'; $res['mysqlconfig'] = 'Mysql Soket Error in file: res_mysql.conf';
} }
} }
@ -407,21 +418,18 @@ class extconfigs {
if (empty($res_conf[$def_bd_sec])) { if (empty($res_conf[$def_bd_sec])) {
$res['mysqlconfig'] = 'Not Config in file: res_config_mysql.conf'; $res['mysqlconfig'] = 'Not Config in file: res_config_mysql.conf';
} else { } else {
if ($res_conf[$def_bd_sec]['dbsock'] != $def_bd_config['dbsock']) { if ($res_conf[$def_bd_sec]['dbsock'] != $def_bd_config['dbsock']) {
$res['mysqlconfig'] = 'Mysql Soket Error in file: res_config_mysql.conf'; $res['mysqlconfig'] = 'Mysql Soket Error in file: res_config_mysql.conf';
} }
} }
if (empty($res['mysqlconfig'])) { if (empty($res['mysqlconfig'])) {
$res['mysqlconfig'] = 'OK'; $res['mysqlconfig'] = 'OK';
} }
} }
if (empty($res['mysqlconfig'])) { if (empty($res['mysqlconfig'])) {
$res['mysqlconfig'] = 'Realtime Error: not found res_config_mysql.conf or res_mysql.conf configutation on the path :'. $dir ; $res['mysqlconfig'] = 'Realtime Error: not found res_config_mysql.conf or res_mysql.conf configutation on the path :' . $dir;
} }
return $res; return $res;
} }
} }

View file

@ -587,7 +587,7 @@ class srvinterface {
} }
} }
} else { } else {
return $result; return $result;
return array(); return array();
} }
} }
@ -608,8 +608,10 @@ class srvinterface {
fputs ($fp,"Events: on\r\n\r\n"); fputs ($fp,"Events: on\r\n\r\n");
fputs ($fp,"Action: SCCPShowDevices\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"); 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> <button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help> <help>Debug: Enable debugging level in SCCP module.</help>
</item> </item>
<item type="IS" id="6" seq="20"> <item type="IS" id="6" seq="98">
<name>displayconfig</name> <name>displayconfig</name>
<label>SCCP Config Mode </label> <label>SCCP Config Mode </label>
<default>sccpgeneral</default> <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> <button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help> <help>Debug: Enable debugging level in SCCP module.</help>
</item> </item>
<item type="IS" id="6" seq="20"> <item type="IS" id="6" seq="98">
<name>displayconfig</name> <name>displayconfig</name>
<label>SCCP Config Mode </label> <label>SCCP Config Mode </label>
<default>sccpgeneral</default> <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> <button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help> <help>Debug: Enable debugging level in SCCP module.</help>
</item> </item>
<item type="IS" id="6" seq="20"> <item type="IS" id="6" seq="98">
<name>displayconfig</name> <name>displayconfig</name>
<label>SCCP Config Mode </label> <label>SCCP Config Mode </label>
<default>sccpgeneral</default> <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> <button value="all">All</button>
<help>Debug: Enable debugging level in SCCP module.</help> <help>Debug: Enable debugging level in SCCP module.</help>
</item> </item>
<item type="IS" id="6" seq="20"> <item type="IS" id="6" seq="98">
<name>displayconfig</name> <name>displayconfig</name>
<label>SCCP Config Mode </label> <label>SCCP Config Mode </label>
<default>sccpgeneral</default> <default>sccpgeneral</default>

View file

@ -1,8 +1,8 @@
<?php <?php
/* /*
* Hand DB Change : * Hand DB Change :
ALTER TABLE `sccpline` 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 `sccpdevice` 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_int = \FreePBX::Config();
$cnf_wr = \FreePBX::WriteConfig(); $cnf_wr = \FreePBX::WriteConfig();
$cnf_read = \FreePBX::LoadConfig(); $cnf_read = \FreePBX::LoadConfig();
$backup_ext = array('_custom.conf', '.conf');
$def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline'); $def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline');
$def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'], $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'],
'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], '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_sql = ini_get('pdo_mysql.default_socket');
$res_conf = ''; $res_conf = '';
$ext_conf = ''; $ext_conf = '';
if (file_exists($dir . '/extconfig.conf')) { $ext_conf_file = 'extconfig.conf';
$ext_conf = $cnf_read->getConfig('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 (!empty($res_conf_sql)) {
if (file_exists($res_conf_sql)) { if (file_exists($res_conf_sql)) {
@ -713,7 +720,7 @@ function Setup_RealTime() {
// $res_conf['general']['dbsock'] = $def_bd_config['dbsock']; // $res_conf['general']['dbsock'] = $def_bd_config['dbsock'];
$cnf_wr->writeConfig('res_config_mysql.conf', $res_conf, false); $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); CheckSCCPManagerDBTables($table_req);

View file

@ -27,9 +27,6 @@ ksort($data_sort);
foreach ($data_sort as $key => $value) { foreach ($data_sort as $key => $value) {
$hint_list[$value] = $hint_list1[$value]; $hint_list[$value] = $hint_list1[$value];
} }
//print_r($hint_list); //print_r($hint_list);
//ksort($hint_list); //ksort($hint_list);
//natsort($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_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_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']); $defaul_opt = (empty($db_buttons[$line_id])) ? array(''): explode(',',$db_buttons[$line_id]['options']);
// print_r($defaul_btn);
// print_r($defaul_opt); // print_r($defaul_opt);
$show_form_mode = $defaul_tv; $show_form_mode = $defaul_tv;
$def_hint = ''; $def_hint = '';
$def_silent = ''; $def_silent = '';
@ -127,19 +124,18 @@ if (!empty($_REQUEST['new_id'])) {
// print_r($defaul_fcod); // print_r($defaul_fcod);
} }
foreach ($defaul_opt as $data_i) { foreach ($defaul_opt as $data_i) {
if (strpos($data_i,'@') >0) { if (strpos($data_i,'@')>0) {
$defaul_btn = strtok($data_i,'@'); $test_btn = strtok($data_i,'@');
$def_hint = 'checked'; $def_hint = 'checked';
if ($defaul_btn == $defaul_opt[0]) { $defaul_btn = $data_i;
if ($test_btn == $defaul_opt[0]) {
foreach ($lines_list as $data){ foreach ($lines_list as $data){
if ($data['name']==$defaul_btn) { if ($data['name']==$test_btn) {
$show_form_mode = 'line'; $show_form_mode = 'line';
$defaul_tv = 'monitor'; $defaul_tv = 'monitor';
break; break;
} }
} }
} else {
$defaul_btn = $data_i;
} }
} }
} }

View file

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