This commit is contained in:
Christopher Cookman 2024-12-05 17:38:49 -07:00
parent 39ac99c600
commit df51d2b46d
10 changed files with 42 additions and 42 deletions

View file

@ -11,7 +11,7 @@ If you add/enable the 'callLogBlfEnabled' xml entry in SEPXXX.cnf.xml under comm
and you have added hints for your local extension in your dialplan, like: and you have added hints for your local extension in your dialplan, like:
exten => _XX.,hint,SCCP/${EXTEN} exten => _XX.,hint,SCCP/{$EXTEN}
Then the placed calls list will include the status of the remote extension, like this: Then the placed calls list will include the status of the remote extension, like this:

View file

@ -90,7 +90,7 @@ $(document).ready(function () {
} }
var newLocation = location.href; var newLocation = location.href;
newLocation = ('path' in data && data.path !== '') ? data.path : location.pathname; newLocation = ('path' in data && data.path !== '') ? data.path : location.pathname;
newLocation += ('search' in data && data.search !== '') ? `${data.search}` : `${location.search}`; newLocation += ('search' in data && data.search !== '') ? `{$data.search}` : `{$location.search}`;
// location.hash is set by (".change-tab") at line 198 for settings // location.hash is set by (".change-tab") at line 198 for settings
newLocation += ('hash' in data && data.hash !== '' ) ? data.hash : location.hash; newLocation += ('hash' in data && data.hash !== '' ) ? data.hash : location.hash;
if (data.message) { if (data.message) {

View file

@ -38,7 +38,7 @@ foreach ($requiredClasses as $className) {
include(__DIR__ . "/sccpManClasses/$className.class.php"); include(__DIR__ . "/sccpManClasses/$className.class.php");
} }
if (class_exists($class, false)) { if (class_exists($class, false)) {
${$className} = new $class(); {$$className} = new $class();
} }
} }
@ -356,36 +356,36 @@ function InstallDB_updateSchema($db_config)
foreach ($priorSchemaFields as $table => $fieldsArr) { foreach ($priorSchemaFields as $table => $fieldsArr) {
// First get any data in columns to be deleted ( _Column) // First get any data in columns to be deleted ( _Column)
$sqlMatch = array_reduce($fieldsArr, function($carry, $column) { $sqlMatch = array_reduce($fieldsArr, function($carry, $column) {
return "${carry} ${column} IS NOT NULL OR"; return "{$carry} {$column} IS NOT NULL OR";
}); });
unset($column); unset($column);
$sqlFields = array_reduce($fieldsArr, function($carry, $column) { $sqlFields = array_reduce($fieldsArr, function($carry, $column) {
return "${carry} ${column} AS " . ltrim($column,"_") .","; return "{$carry} {$column} AS " . ltrim($column,"_") .",";
}); });
$sqlMatch = rtrim($sqlMatch, "OR"); $sqlMatch = rtrim($sqlMatch, "OR");
$sqlFields = rtrim($sqlFields, ","); $sqlFields = rtrim($sqlFields, ",");
$stmt = $db->prepare("SELECT name, ${sqlFields} FROM ${table} WHERE ${sqlMatch}"); $stmt = $db->prepare("SELECT name, {$sqlFields} FROM {$table} WHERE {$sqlMatch}");
$stmt->execute(); $stmt->execute();
$dbResult = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); $dbResult = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
// Now move any data found from _Column to Column. This is safe as the two should not exist. // Now move any data found from _Column to Column. This is safe as the two should not exist.
if (!empty($dbResult)) { if (!empty($dbResult)) {
foreach ($dbResult as $name => $columnArr) { foreach ($dbResult as $name => $columnArr) {
$sqlVar = array_reduce(array_keys($columnArr), function($carry, $key) use ($columnArr){ $sqlVar = array_reduce(array_keys($columnArr), function($carry, $key) use ($columnArr){
$carry .= (isset($columnArr[$key])) ? "${key} = '${columnArr[$key]}'," : ""; $carry .= (isset($columnArr[$key])) ? "{$key} = '{$columnArr[$key]}'," : "";
return $carry; return $carry;
}); });
$sqlVar = rtrim($sqlVar, ","); $sqlVar = rtrim($sqlVar, ",");
$stmt = $db->prepare("UPDATE ${table} SET ${sqlVar} WHERE name = '${name}'"); $stmt = $db->prepare("UPDATE {$table} SET {$sqlVar} WHERE name = '{$name}'");
$stmt->execute(); $stmt->execute();
} }
} }
// Processed all _Column names; now safe to delete them // Processed all _Column names; now safe to delete them
$sqlDrop = array_reduce($fieldsArr, function($carry, $column) { $sqlDrop = array_reduce($fieldsArr, function($carry, $column) {
return "${carry} DROP COLUMN ${column},"; return "{$carry} DROP COLUMN {$column},";
}); });
$sqlDrop = rtrim($sqlDrop, ", "); $sqlDrop = rtrim($sqlDrop, ", ");
$stmt = $db->prepare("ALTER TABLE ${table} ${sqlDrop}"); $stmt = $db->prepare("ALTER TABLE {$table} {$sqlDrop}");
$stmt->execute(); $stmt->execute();
} }
@ -1007,7 +1007,7 @@ function checkTftpServer() {
// TODO: Depending on distro, do we have write permissions // TODO: Depending on distro, do we have write permissions
foreach ($possibleFtpDirs as $dirToTest) { foreach ($possibleFtpDirs as $dirToTest) {
if (is_dir($dirToTest) && is_writable($dirToTest)) { if (is_dir($dirToTest) && is_writable($dirToTest)) {
$tempFile = "${dirToTest}/{$remoteFileName}"; $tempFile = "{$dirToTest}/{$remoteFileName}";
file_put_contents($tempFile, $remoteFileContent); file_put_contents($tempFile, $remoteFileContent);
// try to pull the written file through tftp. // try to pull the written file through tftp.
@ -1233,11 +1233,11 @@ function cleanUpSccpSettings() {
$db_result = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); $db_result = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
foreach ($db_result as $key => $value) { foreach ($db_result as $key => $value) {
if (!empty($settingsFromDb[$key]['data'])) { if (!empty($settingsFromDb[$key]['data'])) {
$sql_modify .= "ALTER COLUMN ${key} SET DEFAULT '{$settingsFromDb[$key]['data']}', "; $sql_modify .= "ALTER COLUMN {$key} SET DEFAULT '{$settingsFromDb[$key]['data']}', ";
} }
} }
$sql_modify = rtrim($sql_modify, ', '); $sql_modify = rtrim($sql_modify, ', ');
$stmt = $db->prepare("ALTER TABLE {$table} ${sql_modify}"); $stmt = $db->prepare("ALTER TABLE {$table} {$sql_modify}");
$stmt->execute(); $stmt->execute();
} }

View file

@ -209,10 +209,10 @@ class Sccp extends \FreePBX\modules\Core\Driver {
//when called from extensions as delete, id can be a list of ids //when called from extensions as delete, id can be a list of ids
// TODO: Could be other buttons that refer this id (by name rather than id) - need to clear these as well. // TODO: Could be other buttons that refer this id (by name rather than id) - need to clear these as well.
foreach (array($id) as $clearId) { foreach (array($id) as $clearId) {
$this->cachedDeleteStatement[$clearId] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '${clearId}%' AND buttontype = 'line'"); $this->cachedDeleteStatement[$clearId] = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE '{$clearId}%' AND buttontype = 'line'");
$this->delId[] = $clearId; $this->delId[] = $clearId;
// Delete the line as requested - if edit will add again in addDevice // Delete the line as requested - if edit will add again in addDevice
$sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ${clearId}"); $sth = $this->database->prepare("DELETE FROM sccpline WHERE name = {$clearId}");
$sth->execute(); $sth->execute();
} }
return true; return true;

View file

@ -212,43 +212,43 @@ class dbinterface
if (!strpos($filter['model'], 'loadInformation')) { if (!strpos($filter['model'], 'loadInformation')) {
$filter['model'] = 'loadInformation' . $filter['model']; $filter['model'] = 'loadInformation' . $filter['model'];
} }
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (loadinformationid = :model ) ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (loadinformationid = :model ) ORDER BY model");
$stmt->bindParam(':model', $filter['model'], \PDO::PARAM_STR); $stmt->bindParam(':model', $filter['model'], \PDO::PARAM_STR);
} else { } else {
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
} }
break; break;
case 'byid': case 'byid':
if (isset($filter['model'])) { if (isset($filter['model'])) {
$stmtU = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE model = :model ORDER BY model"); $stmtU = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE model = :model ORDER BY model");
$stmtU->bindParam(':model', $filter['model'],\PDO::PARAM_STR); $stmtU->bindParam(':model', $filter['model'],\PDO::PARAM_STR);
} else { } else {
$stmtU = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel ORDER BY model"); $stmtU = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
} }
$stmtU->execute(); $stmtU->execute();
return $stmtU->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); return $stmtU->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
break; break;
case 'expansion': case 'expansion':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model");
break; break;
case 'enabled': case 'enabled':
//$stmt = $db->prepare('SELECT ' . {$sel_inf} . ' FROM sccpdevmodel WHERE enabled = 1 ORDER BY model'); //previously this fell through to phones. //$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. //break; // above includes expansion modules but was not original behaviour so commented out. Falls through to phones.
case 'phones': case 'phones':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 1) ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 1) ORDER BY model");
break; break;
case 'disabled': case 'disabled':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 0) ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 0) ORDER BY model");
break; break;
case 'ciscophones': case 'ciscophones':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) != '-sip' ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) != '-sip' ORDER BY model");
break; break;
case 'sipphones': case 'sipphones':
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) = '-sip' ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND RIGHT(vendor,4) = '-sip' ORDER BY model");
break; break;
case 'all': // Fall through to default case 'all': // Fall through to default
default: default:
$stmt = $this->db->prepare("SELECT ${sel_inf} FROM sccpdevmodel ORDER BY model"); $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model");
break; break;
} }
$stmt->execute(); $stmt->execute();
@ -288,7 +288,7 @@ class dbinterface
$formattedSQL = array_reduce( $formattedSQL = array_reduce(
array_keys($save_value), // pass in the array_keys instead of the array here array_keys($save_value), // pass in the array_keys instead of the array here
function ($carry, $key) use ($save_value) { // ... then 'use' the actual array here function ($carry, $key) use ($save_value) { // ... then 'use' the actual array here
return "${carry}${key} = '${save_value[$key]}', "; return "{$carry}{$key} = '{$save_value[$key]}', ";
}, },
); );
if (isset($formattedSQL)) { // if array is empty returns null if (isset($formattedSQL)) { // if array is empty returns null
@ -296,13 +296,13 @@ class dbinterface
switch ($mode) { switch ($mode) {
case 'delete': case 'delete':
if (array_key_exists($key_fld, $save_value)) { if (array_key_exists($key_fld, $save_value)) {
$sql_key = "${key_fld} = '${save_value[$key_fld]}'"; //quote data as normally is string $sql_key = "{$key_fld} = '{$save_value[$key_fld]}'"; //quote data as normally is string
$stmt = $this->db->prepare("DELETE FROM {$table_name} WHERE {$sql_key}"); $stmt = $this->db->prepare("DELETE FROM {$table_name} WHERE {$sql_key}");
} }
break; break;
case 'update': case 'update':
if (array_key_exists($key_fld, $save_value)) { if (array_key_exists($key_fld, $save_value)) {
$sql_key = "${key_fld} = '${save_value[$key_fld]}'"; //quote data as normally is string $sql_key = "{$key_fld} = '{$save_value[$key_fld]}'"; //quote data as normally is string
$stmt = $this->db->prepare("UPDATE {$table_name} SET {$formattedSQL} WHERE {$sql_key}"); $stmt = $this->db->prepare("UPDATE {$table_name} SET {$formattedSQL} WHERE {$sql_key}");
} }
break; break;
@ -364,7 +364,7 @@ class dbinterface
switch ($dataid) { switch ($dataid) {
case "DeviceById": case "DeviceById":
// TODO: This needs to be rewritten // TODO: This needs to be rewritten
$stmt = $this->db->prepare("SELECT keyword,data FROM sip WHERE id = '${line}'"); $stmt = $this->db->prepare("SELECT keyword,data FROM sip WHERE id = '{$line}'");
$stmt->execute(); $stmt->execute();
$tech = $stmt->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP); $tech = $stmt->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP);
foreach ($tech as &$value) { foreach ($tech as &$value) {

View file

@ -473,9 +473,9 @@ class formcreate
if (isset($currentValue[$i])) { if (isset($currentValue[$i])) {
$val_check = (($valToCheck == strtolower($currentValue[$i])) || ($valToCheck == '' && $currentValue[$i] == '' )) ? 'checked' : ''; $val_check = (($valToCheck == strtolower($currentValue[$i])) || ($valToCheck == '' && $currentValue[$i] == '' )) ? 'checked' : '';
} }
echo "<input type=checkbox name= ${res_id}_{$i} id=${res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>"; echo "<input type=checkbox name= {$res_id}_{$i} id={$res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
} else { } else {
echo "<input type=radio name= {$res_id} id=${res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>"; echo "<input type=radio name= {$res_id} id={$res_id}_{$i} value='{$value[@value]}' {$val_check} {$opt_hide} {$opt_disabled}>";
} }
echo "<label for= {$res_id}_{$i}>{$value}</label>"; echo "<label for= {$res_id}_{$i}>{$value}</label>";
$i++; $i++;

View file

@ -256,9 +256,9 @@ class xmlinterface
//Now have an array of srst addresses - maybe empty //Now have an array of srst addresses - maybe empty
foreach ($srst_addrs as $netKey => $netValue) { foreach ($srst_addrs as $netKey => $netValue) {
$nodeName = "ipAddr${netKey}"; $nodeName = "ipAddr{$netKey}";
$xnode->$nodeName = $netValue['ip']; $xnode->$nodeName = $netValue['ip'];
$nodeName = "port${netKey}"; $nodeName = "port{$netKey}";
$xnode->$nodeName = $netValue['port']; $xnode->$nodeName = $netValue['port'];
} }
break; break;

View file

@ -373,7 +373,7 @@ trait ajaxHelper {
} }
// Have default to be saved to db table default // Have default to be saved to db table default
$tableName_def = "{$tableName}_def"; $tableName_def = "{$tableName}_def";
if ((array_key_exists($key, ${$tableName_def})) && (${$tableName_def}[$key]['data'] == $value)) { if ((array_key_exists($key, {$$tableName_def})) && ({$$tableName_def}[$key]['data'] == $value)) {
// Value unchanged so ignore // Value unchanged so ignore
} else { } else {
$dbSaveArray[$key] = array('table' => $tableName, 'field' => $key, 'Default' => $value); $dbSaveArray[$key] = array('table' => $tableName, 'field' => $key, 'Default' => $value);
@ -556,7 +556,7 @@ trait ajaxHelper {
case 'daysdisplaynotactive' : case 'daysdisplaynotactive' :
$searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6']; $searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6'];
foreach ($searchArr as $settingsVal) { foreach ($searchArr as $settingsVal) {
$value .= (isset($get_settings["sccpdevice_${settingsVal}"])) ? $get_settings["sccpdevice_${settingsVal}"] . ',' : ''; $value .= (isset($get_settings["sccpdevice_{$settingsVal}"])) ? $get_settings["sccpdevice_{$settingsVal}"] . ',' : '';
} }
$value = rtrim($value,','); $value = rtrim($value,',');
break; break;
@ -618,16 +618,16 @@ trait ajaxHelper {
break; break;
default: default:
// handle vendor prefix // handle vendor prefix
if (!empty($get_settings["${hdr_vendPrefix}${key}"])) { if (!empty($get_settings["{$hdr_vendPrefix}{$key}"])) {
$value = $get_settings["${hdr_vendPrefix}${key}"]; $value = $get_settings["{$hdr_vendPrefix}{$key}"];
} }
// handle array prefix // handle array prefix
if (!empty($get_settings["${hdr_arprefix}${key}"])) { if (!empty($get_settings["{$hdr_arprefix}{$key}"])) {
// Only 3 types of array returned permit,deny, setvar // Only 3 types of array returned permit,deny, setvar
$arr_data = ''; $arr_data = '';
$arr_clear = false; $arr_clear = false;
$output = array(); $output = array();
foreach ($get_settings["${hdr_arprefix}${key}"] as $netValue) { foreach ($get_settings["{$hdr_arprefix}{$key}"] as $netValue) {
switch ($key) { switch ($key) {
case 'permit': case 'permit':
case 'deny'; case 'deny';

View file

@ -160,7 +160,7 @@ trait helperfunctions {
private function getTableEnums($table) { private function getTableEnums($table) {
$enumFields = array(); $enumFields = array();
$sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_${table}"); $sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}");
foreach ($sccpTableDesc as $key => $data) { foreach ($sccpTableDesc as $key => $data) {
$typeArray = explode('(', $data['Type']); $typeArray = explode('(', $data['Type']);
if ($typeArray[0] == 'enum') { if ($typeArray[0] == 'enum') {
@ -301,7 +301,7 @@ trait helperfunctions {
// write a sentinel to a tftp subdirectory to see if mapping is working // write a sentinel to a tftp subdirectory to see if mapping is working
if (is_dir($testFtpDir) && is_writable($testFtpDir)) { if (is_dir($testFtpDir) && is_writable($testFtpDir)) {
$tempFile = "${testFtpDir}/{$remoteFileName}"; $tempFile = "{$testFtpDir}/{$remoteFileName}";
file_put_contents($tempFile, $remoteFileContent); file_put_contents($tempFile, $remoteFileContent);
// try to pull the written file through tftp. // try to pull the written file through tftp.
// this way we can determine if mapping is active and using sccp_manager maps // this way we can determine if mapping is active and using sccp_manager maps

View file

@ -44,7 +44,7 @@ if (!empty($_REQUEST['id'])) {
if (array_key_exists($key, $enumFields)){ if (array_key_exists($key, $enumFields)){
// This field is (now) an enum. Check the current value is acceptable. // This field is (now) an enum. Check the current value is acceptable.
// Quote value as enum values are quoted. // Quote value as enum values are quoted.
if (in_array("'${val}'", $enumFields[$key])) { if (in_array("'{$val}'", $enumFields[$key])) {
// The value is valid so will keep // The value is valid so will keep
$def_val[$key] = array('keyword' => $key, 'data' => $val, 'seq' => 99); $def_val[$key] = array('keyword' => $key, 'data' => $val, 'seq' => 99);
} }