Misc: Mitigate PHP 8.1 warnings.

This commit is contained in:
fusionate 2023-09-20 20:49:27 +00:00
parent 044b91ec6c
commit 518c32efe6
No known key found for this signature in database
5 changed files with 42 additions and 34 deletions

View File

@ -234,21 +234,27 @@
//get the variables from inside the { and } brackets
preg_match('/^\{([^}]+)\}/', $bridge_destination, $matches);
//create a variables array from the comma delimitted string
$variables = explode(",", $matches[1]);
if (!empty($matches) && is_array($matches) && @sizeof($matches) != 0) {
//strip the variables from the $bridge_destination variable
$bridge_destination = str_replace("{$matches[0]}", '', $bridge_destination);
//create a variables array from the comma delimitted string
$variables = explode(",", $matches[1]);
//strip the variables from the $bridge_destination variable
$bridge_destination = str_replace("{$matches[0]}", '', $bridge_destination);
}
//build a bridge variables data set
$x = 0;
foreach($variables as $variable) {
$pairs = explode("=", $variable);
$database_variables[$x]['name'] = $pairs[0];
$database_variables[$x]['value'] = $pairs[1];
$database_variables[$x]['label'] = ucwords(str_replace('_', ' ', $pairs[0]));
$database_variables[$x]['label'] = str_replace('Effective Caller Id', 'Caller ID', $database_variables[$x]['label']);
$x++;
if (!empty($variables) && is_array($variables)) {
foreach($variables as $variable) {
$pairs = explode("=", $variable);
$database_variables[$x]['name'] = $pairs[0];
$database_variables[$x]['value'] = $pairs[1];
$database_variables[$x]['label'] = ucwords(str_replace('_', ' ', $pairs[0]));
$database_variables[$x]['label'] = str_replace('Effective Caller Id', 'Caller ID', $database_variables[$x]['label']);
$x++;
}
}
}
@ -310,9 +316,9 @@
//get the gateways
$actions = explode(',', $bridge_destination);
foreach($actions as $action) {
foreach ($actions as $action) {
$action_array = explode('/',$action);
if ($action_array[1] == 'gateway') {
if (!empty($action_array) && is_array($action_array) && !empty($action_array[1]) && $action_array[1] == 'gateway') {
$bridge_gateways[] = $action_array[2];
$destination_number = $action_array[3];
}
@ -385,9 +391,11 @@
echo " ";
echo " }\n";
echo "\n";
echo " window.onload = function() {\n";
echo " action_control('".$bridge_action."');\n";
echo " };\n";
if (!empty($bridge_action)) {
echo " window.onload = function() {\n";
echo " action_control('".$bridge_action."');\n";
echo " };\n";
}
echo "</script>\n";
//show the content
@ -431,7 +439,7 @@
echo " <option value=''></option>\n";
$i = 0;
foreach($bridge_actions as $row) {
echo " <option value='".$row['action']."' ".($bridge_action == $row['action'] ? "selected='selected'" : null).">".$row['label']."</option>\n";
echo " <option value='".$row['action']."' ".(!empty($bridge_action) && $bridge_action == $row['action'] ? "selected='selected'" : null).">".$row['label']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
@ -465,7 +473,7 @@
echo " <select class='formfld' name='bridge_profile'>\n";
echo " <option value=''></option>\n";
foreach ($sip_profiles as $row) {
if ($bridge_profile == $row["sip_profile_name"]) {
if (!empty($bridge_profile) && $bridge_profile == $row["sip_profile_name"]) {
echo " <option value='".$row['sip_profile_name']."' selected='selected'>".escape($row["sip_profile_name"])."</option>\n";
}
else {
@ -485,9 +493,9 @@
echo "<td width='70%' class='vtable' style='position: relative;' align='left'>\n";
for ($x = 0; $x <= 2; $x++) {
if ($x > 0) { echo "<br />\n"; }
echo "<select name=\"bridge_gateways[]\" id=\"gateway\" class=\"formfld\" $onchange>\n";
echo "<select name='bridge_gateways[]' id='gateway' class='formfld' ".($onchange ?? '').">\n";
echo "<option value=''></option>\n";
echo "<optgroup label='".$text['label-gateway']."gateway'>\n";
echo "<optgroup label='".$text['label-bridge_gateways']."'>\n";
$previous_domain_uuid = '';
foreach($gateways as $row) {
if (permission_exists('outbound_route_any_gateway')) {
@ -503,7 +511,7 @@
echo "</optgroup>";
echo "<optgroup label='&nbsp; &nbsp;".$domain_name."'>\n";
}
if ($row['gateway_uuid'] == $bridge_gateways[$x]) {
if (!empty($bridge_gateways) && is_array($bridge_gateways) && $row['gateway_uuid'] == $bridge_gateways[$x]) {
echo "<option value=\"".escape($row['gateway_uuid']).":".escape($row['gateway'])."\" selected=\"selected\">".escape($row['gateway'])."</option>\n"; //." db:".$row['gateway_uuid']." bg:".$bridge_gateways[$x]
}
else {
@ -511,7 +519,7 @@
}
}
else {
if ($row['gateway_uuid'] == $bridge_gateways[$x]) {
if (!empty($bridge_gateways) && is_array($bridge_gateways) && $row['gateway_uuid'] == $bridge_gateways[$x]) {
echo "<option value=\"".escape($row['gateway_uuid']).":".escape($row['gateway'])."\" $onchange selected=\"selected\">".escape($row['gateway'])."</option>\n";
}
else {
@ -538,7 +546,7 @@
echo " ".$text['label-destination_number']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <textarea class='formfld' name='destination_number'>".escape($destination_number)."</textarea>\n";
echo " <textarea class='formfld' name='destination_number'>".escape($destination_number ?? '')."</textarea>\n";
echo "<br />\n";
echo $text['description-destination_number']."\n";
echo "</td>\n";

View File

@ -506,7 +506,7 @@ if (!class_exists('destinations')) {
if (isset($destination_key) && $key == $destination_key) {
foreach($value as $k => $row) {
$selected = ($row['destination'] == $destination_value) ? "selected='selected'" : '';
$uuid = isset($row[$this->singular($key).'_uuid']) ? $row[$this->singular($key).'_uuid'] : $row['uuid'];
$uuid = isset($row[$this->singular($key).'_uuid']) ? $row[$this->singular($key).'_uuid'] : ($row['uuid'] ?? '');
$response .= " <option id='{$uuid}' value='".$row['destination']."' $selected>".$row['label']."</option>\n";
}
}
@ -881,7 +881,7 @@ if (!class_exists('destinations')) {
$name = $row['name'];
$label = $row['label'];
$destination = $row['field']['destination'];
$destination = $row['field']['destination'] ?? null;
//add multi-lingual support
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) {
@ -889,7 +889,7 @@ if (!class_exists('destinations')) {
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name);
}
if (is_array($row['result']['data']) && !empty($row['select_value'][$destination_type])) {
if (isset($row['result']) && is_array($row['result']['data']) && !empty($row['select_value'][$destination_type])) {
$label2 = $label;
foreach ($row['result']['data'] as $data) {
$select_value = $row['select_value'][$destination_type];
@ -920,12 +920,12 @@ if (!class_exists('destinations')) {
}
}
else {
$select_value = str_replace("\${".$key."}", $data[$key], $select_value);
$select_value = str_replace("\${".$key."}", ($data[$key] ?? ''), $select_value);
if (empty($data['label'])) {
$select_label = str_replace("\${".$key."}", $data[$key], $select_label);
$select_label = str_replace("\${".$key."}", ($data[$key] ?? ''), $select_label);
}
else {
$label = $data['label'];
// $label = $data['label'];
$select_label = str_replace("\${".$key."}", $text2['option-'.$label], $select_label);
}
}
@ -949,7 +949,7 @@ if (!class_exists('destinations')) {
$select_label = str_replace("&#9993", 'email-icon', $select_label);
$select_label = escape(trim($select_label));
$select_label = str_replace('email-icon', '&#9993', $select_label);
if ($select_value == $destination_value) { $selected = "true' "; } else { $selected = 'false'; }
if (isset($destination_value) && $select_value == $destination_value) { $selected = "true' "; } else { $selected = 'false'; }
if ($label2 == 'destinations') { $select_label = format_phone($select_label); }
$array[$name][$i] = $data;
@ -959,7 +959,7 @@ if (!class_exists('destinations')) {
//$array[$name][$i]['select_value'] = $select_value;
//$array[$name][$i]['selected'] = $selected;
$array[$name][$i]['destination'] = $select_value;
$array[$name][$i]["extension"] = $data["extension"];
$array[$name][$i]["extension"] = $data["extension"] ?? null;
$i++;
}

View File

@ -46,7 +46,7 @@
}
else {
//use custom index, if present, otherwise use custom login, if present, otherwise use default login
if (file_exists($_SERVER["PROJECT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/index.php")) {
if (file_exists($_SERVER["PROJECT_ROOT"]."/themes/".($_SESSION['domain']['template']['name'] ?? '')."/index.php")) {
require_once "themes/".$_SESSION['domain']['template']['name']."/index.php";
}
else {

View File

@ -90,7 +90,7 @@ if (!class_exists('permissions')) {
}
if (empty($permissions)) {
$permissions = $_SESSION["permissions"];
$permissions = $_SESSION["permissions"] ?? [];
}
//set default to false

View File

@ -1211,7 +1211,7 @@ function number_pad($number,$n) {
else { //rgb(a)
$rgb = implode(',', $color);
if (!empty($alpha)) { $rgb .= ','.$alpha; $a = 'a'; }
if ($wrapper) { $rgb = 'rgb'.$a.'('.$rgb.')'; }
if ($wrapper) { $rgb = 'rgb'.($a ?? '').'('.$rgb.')'; }
return $rgb;
}
}