diff --git a/install.php b/install.php
index 21e78b4..7c3cf4f 100644
--- a/install.php
+++ b/install.php
@@ -98,6 +98,7 @@ if ($chanSCCPWarning) {
Setup_RealTime();
addDriver($sccp_compatible);
checkTftpServer();
+getConfigMetaData('general');
outn("
");
outn("Install Complete !");
outn("
");
@@ -293,7 +294,10 @@ function Get_DB_config($sccp_compatible)
'_autocall_select' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
'_backgroundImageAccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
'_callLogBlfEnabled' => array('create' => "enum('3','2') NOT NULL default '2'", 'modify' => "enum('3','2')")
- )
+ ),
+ 'sccpsettings' => array (
+ 'systemdefault' => array('create' => "VARCHAR(255) NULL default ''")
+ )
);
if ($sccp_compatible >= 433) {
@@ -305,6 +309,7 @@ function Get_DB_config($sccp_compatible)
if ($sccp_compatible >= 433) {
$db_config_v4['sccpdevice'] = array_merge($db_config_v4['sccpdevice'],$db_config_v5['sccpdevice']);
$db_config_v4['sccpline'] = array_merge($db_config_v4['sccpline'],$db_config_v5['sccpline']);
+ $db_config_v4['sccpsettings'] = $db_config_v5['sccpsettings'];
}
return $db_config_v4;
}
@@ -456,6 +461,8 @@ function InstallDB_updateSchema($db_config)
}
}
if (!empty($sql_update)) {
+ outn("
" . _("Updating table rows :") . $affected_rows . "");
+ dbug('create', $sql_update);
$sql_update = 'BEGIN; ' . $sql_update . ' COMMIT;';
sql($sql_update);
$affected_rows = $db->affectedRows();
@@ -463,16 +470,17 @@ function InstallDB_updateSchema($db_config)
}
if (!empty($sql_create)) {
- outn("" . _("Adding new FILTER_VALIDATE_INT") . "");
+ outn("" . _("Adding new columns ...") . "");
$sql_create = "ALTER TABLE {$tabl_name} " .substr($sql_create, 0, -2);
+ dbug('create', $sql_create);
try {
$check = $db->query($sql_create);
} catch (\Exception $e) {
- die_freepbx("Can add column to {$tabl_name}. SQL: {$sql_create} \n");
+ die_freepbx("Can't add column to {$tabl_name}. SQL: {$sql_create} \n");
}
}
if (!empty($sql_modify)) {
- outn("" . _("Modifying table ") . $tabl_name ."");
+ outn("" . _("Modifying table columns") . $tabl_name ."");
$sql_modify = "ALTER TABLE {$tabl_name} " . substr($sql_modify, 0, -2);
try {
@@ -881,6 +889,7 @@ function addDriver($sccp_compatible) {
}
}
function checkTftpServer() {
+ outn("" . _("Checking TFTP server path and availability ...") . "");
global $db;
global $cnf_int;
global $settingsFromDb;
@@ -928,6 +937,7 @@ function checkTftpServer() {
}
$settingsToDb['asterisk_etc_path'] =array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir);
+ $settingsFromDb['asterisk_etc_path']['data'] = $confDir;
foreach ($settingsToDb as $settingToSave) {
$sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});";
@@ -941,6 +951,7 @@ function checkTftpServer() {
$settingsToDb = $extconfigs->updateTftpStructure($settingsFromDb);
foreach ($settingsToDb as $settingKey => $settingVal) {
+ $settingsFromDb[$settingKey]['data'] = $settingVal;
$sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingKey}', '{$settingVal}', 20, 0)";
$results = $db->query($sql);
if (DB::IsError($results)) {
@@ -950,4 +961,26 @@ function checkTftpServer() {
return;
}
+function getConfigMetaData($segment) {
+ global $aminterface;
+ global $db;
+ global $settingsFromDb;
+ $sysConfiguration = $aminterface->getSCCPConfigMetaData($segment);
+ foreach ($sysConfiguration['Options'] as $key => $valueArray) {
+ if ($valueArray['Flags'][0] == 'Obsolete' || $valueArray['Flags'][0] == 'Deprecated') {
+ continue;
+ }
+ $sysConfiguration[$valueArray['Name']] = $valueArray;
+ if (array_key_exists($valueArray['Name'],$settingsFromDb)) {
+ if (!empty($sysConfiguration[$valueArray['Name']]['DefaultValue'])) {
+ $sql = "REPLACE INTO sccpsettings (keyword, systemdefault) VALUES ('{$valueArray['Name']}', '{$valueArray['DefaultValue']}');";
+ $results = $db->query($sql);
+ }
+ }
+ unset($sysConfiguration[$key]);
+ }
+ unset($sysConfiguration['Options']);
+ dbug('sysconfig', $sysConfiguration);
+}
+
?>
diff --git a/sccpManClasses/aminterface.class.php b/sccpManClasses/aminterface.class.php
index dac5f47..742c326 100644
--- a/sccpManClasses/aminterface.class.php
+++ b/sccpManClasses/aminterface.class.php
@@ -431,14 +431,19 @@ class aminterface
}
return $result;
}
+ function getSCCPConfigMetaData($segment = '') {
+ if ($this->_connect_state) {
+ $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPConfigMetaDataAction($segment);
+ $metadata = $this->send($_action)->getResult();
+ }
+ return $metadata;
+ }
+
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();
- }
+ $metadata = $this->getSCCPConfigMetaData();
if (isset($metadata['Version'])) {
$result['Version'] = $metadata['Version'];
diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php
index 5a2e138..3c2611f 100644
--- a/sccpManTraits/helperFunctions.php
+++ b/sccpManTraits/helperFunctions.php
@@ -179,11 +179,21 @@ trait helperfunctions {
$ret = "";
// fetch file content
- $numbytes = socket_recvfrom($socket, $buffer, 84, MSG_WAITALL, $host, $port);
+ $count = 0;
+ while ( 0 == $numbytes = socket_recvfrom($socket, $buffer, 84, MSG_DONTWAIT, $host, $port)) {
+ sleep(1);
+ $count ++;
+ if ($count > 5) {
+ break;
+ }
+ };
// unpack the returned buffer and discard the first two bytes
- $pkt = unpack("nopcode/nblockno/a*data", $buffer);
-
+ try {
+ $pkt = unpack("nopcode/nblockno/a*data", $buffer);
+ } catch (\Exception $e) {
+ die_freepbx("TFTP server is not responding. Check that it is running and then reload this page \n");
+ }
// send ack
$packet = chr(4) . chr($pkt["blockno"]);
socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, $port);