Frytimo pr patches for php8.1 (#6630)

* Passing null to parameter #2 ($string) of type string is deprecated

* Passing null to parameter #1 ($string) of type string is deprecated

* php 8.1 fixes

* php 8.1 fixes - replace strlen($var) > 0 with !empty($var)

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - replace ${var} with {$var}

* php 8.1 fixes - strlower with null

* php 8.1 fixes - strreplace with null

* php 8.1 fixes - passing null to base64_decode

* php 8.1 fixes - check for false and check for null on $this->dir

* php 8.1 fixes - remove assignment of $db variable to modules object

* php 8.1 fixes - avoid sending null to substr

* php 8.1 fixes - change ${var} to {$var}

* php 8.1 fixes - check for null before preg_replace

* php 8.1 fixes - remove setting db variable on domains object

* php 8.1 fixes - set empty string if $row['domain_setting_subcategory'] is null

* php 8.1 fixes - set empty string if $_REQUEST['show'] is not available

* php 8.1 fixes

* php 8.1 fixes - correct $_POST checking syntax

* php 8.1 fixes - correct $_POST variables

* php 8.1 fixes

* Use brackets consistently

* Update user_setting_edit.php

* Change to not empty

* Update device.php

* Update text.php

---------

Co-authored-by: Tim Fry <tim@voipstratus.com>
Co-authored-by: FusionPBX <markjcrane@gmail.com>
This commit is contained in:
frytimo
2023-05-05 10:46:37 -06:00
committed by GitHub
co-authored by Tim Fry FusionPBX
parent ebbb2f1a72
commit fef8165be2
230 changed files with 1948 additions and 1937 deletions
+16 -16
View File
@@ -78,14 +78,14 @@
$dialplan_order = $_POST["dialplan_order"];
$dialplan_enabled = $_POST["dialplan_enabled"];
$dialplan_description = $_POST["dialplan_description"];
if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled
if (empty($dialplan_enabled)) { $dialplan_enabled = "true"; } //set default to enabled
}
//set the default
if (strlen($dialplan_context) == 0) { $dialplan_context = $_SESSION['domain_name']; }
if (empty($dialplan_context)) { $dialplan_context = $_SESSION['domain_name']; }
//add or update data from http post
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_POST)>0 && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
@@ -96,14 +96,14 @@
}
//check for all required data
if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (strlen($condition_field_1) == 0) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-field']."<br>\n"; }
if (strlen($condition_expression_1) == 0) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-expression']."<br>\n"; }
if (strlen($action_application_1) == 0) { $msg .= $text['message-required'].$text['label-action_1']."<br>\n"; }
//if (strlen($dialplan_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
//if (strlen($dialplan_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (empty($domain_uuid)) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
if (empty($dialplan_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (empty($condition_field_1)) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-field']."<br>\n"; }
if (empty($condition_expression_1)) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-expression']."<br>\n"; }
if (empty($action_application_1)) { $msg .= $text['message-required'].$text['label-action_1']."<br>\n"; }
//if (empty($dialplan_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
//if (empty($dialplan_description)) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
@@ -143,7 +143,7 @@
$array['dialplan_details'][0]['dialplan_detail_order'] = '1';
//add condition 2
if (strlen($condition_field_2) > 0) {
if (!empty($condition_field_2)) {
$dialplan_detail_uuid = uuid();
$array['dialplan_details'][1]['domain_uuid'] = $domain_uuid;
$array['dialplan_details'][1]['dialplan_uuid'] = $dialplan_uuid;
@@ -167,7 +167,7 @@
$array['dialplan_details'][2]['dialplan_detail_order'] = '3';
//add action 2
if (strlen($action_application_2) > 0) {
if (!empty($action_application_2)) {
$dialplan_detail_uuid = uuid();
$array['dialplan_details'][3]['domain_uuid'] = $domain_uuid;
$array['dialplan_details'][3]['dialplan_uuid'] = $dialplan_uuid;
@@ -335,7 +335,7 @@
echo " <td nowrap='nowrap'>\n";
echo " <select class='formfld' name='condition_field_1' id='condition_field_1' onchange='changeToInput_condition_field_1(this);this.style.visibility = \"hidden\";'>\n";
echo " <option value=''></option>\n";
if (strlen($condition_field_1) > 0) {
if (!empty($condition_field_1)) {
echo " <option value='".escape($condition_field_1)."' selected='selected'>".escape($condition_field_1)."</option>\n";
}
echo " <optgroup label='Field'>\n";
@@ -424,7 +424,7 @@
<?php
echo " <select class='formfld' name='condition_field_2' id='condition_field_2' onchange='changeToInput_condition_field_2(this);this.style.visibility = \"hidden\";'>\n";
echo " <option value=''></option>\n";
if (strlen($condition_field_2) > 0) {
if (!empty($condition_field_2)) {
echo " <option value='".escape($condition_field_2)."' selected>".escape($condition_field_2)."</option>\n";
}
echo " <optgroup label='Field'>\n";
@@ -506,7 +506,7 @@
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_order' class='formfld'>\n";
//echo " <option></option>\n";
if (strlen($dialplan_order) > 0) {
if (!empty($dialplan_order)) {
echo " <option selected='selected' value='".escape($dialplan_order)."'>".escape($dialplan_order)."</option>\n";
}
$i = 200;
+20 -20
View File
@@ -97,7 +97,7 @@
$previous_application = null;
foreach($raw_applications as $row) {
if (strlen($row) > 0) {
if (!empty($row)) {
$application_array = explode(",", $row);
$application = $application_array[0];
@@ -124,7 +124,7 @@
}
//process and save the data
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//get the dialplan uuid
if ($action == "update") {
@@ -183,13 +183,13 @@
//check for all required data
$msg = '';
if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (strlen($dialplan_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
if (strlen($dialplan_continue) == 0) { $msg .= $text['message-required'].$text['label-continue']."<br>\n"; }
if (strlen($dialplan_context) == 0) { $msg .= $text['message-required'].$text['label-context']."<br>\n"; }
if (strlen($dialplan_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
//if (strlen($dialplan_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (empty($dialplan_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (empty($dialplan_order)) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
if (empty($dialplan_continue)) { $msg .= $text['message-required'].$text['label-continue']."<br>\n"; }
if (empty($dialplan_context)) { $msg .= $text['message-required'].$text['label-context']."<br>\n"; }
if (empty($dialplan_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
//if (empty($dialplan_description)) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
@@ -242,8 +242,8 @@
$y = 0;
if (is_array($_POST["dialplan_details"])) {
foreach ($_POST["dialplan_details"] as $row) {
if (strlen($row["dialplan_detail_tag"]) > 0) {
if (strlen($row["dialplan_detail_uuid"]) > 0) {
if (!empty($row["dialplan_detail_tag"])) {
if (!empty($row["dialplan_detail_uuid"])) {
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = $row["dialplan_detail_uuid"];
}
if (!preg_match("/system/i", $row["dialplan_detail_type"])) {
@@ -323,7 +323,7 @@
header("Location: ?id=".escape($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".$app_uuid : null));
exit;
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
} //(count($_POST)>0 && empty($_POST["persistformvar"]))
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
@@ -348,13 +348,13 @@
}
//set the defaults
if (strlen($dialplan_context) == 0) {
if (empty($dialplan_context)) {
$dialplan_context = $_SESSION['domain_name'];
}
if (strlen($dialplan_order) == 0) {
if (empty($dialplan_order)) {
$dialplan_order = '200';
}
if (strlen($dialplan_destination) == 0) {
if (empty($dialplan_destination)) {
$dialplan_destination = 'false';
}
@@ -813,7 +813,7 @@
$dialplan_detail_enabled = $row['dialplan_detail_enabled'];
//default to enabled true
if (strlen($dialplan_detail_enabled) == 0) {
if (empty($dialplan_detail_enabled)) {
$dialplan_detail_enabled = 'true';
}
@@ -823,7 +823,7 @@
//begin the row
echo "<tr>\n";
//determine whether to hide the element
if (strlen($dialplan_detail_tag) == 0) {
if (empty($dialplan_detail_tag)) {
$element['hidden'] = false;
$element['visibility'] = "";
}
@@ -855,7 +855,7 @@
echo " <label id=\"label_dialplan_detail_type_".$x."\">".escape($dialplan_detail_type)."</label>\n";
}
echo " <select id='dialplan_detail_type_".$x."' name='dialplan_details[".$x."][dialplan_detail_type]' class='formfld' style='width: auto; ".$element['visibility']."' onchange='change_to_input(this);'>\n";
if (strlen($dialplan_detail_type) > 0) {
if (!empty($dialplan_detail_type)) {
echo " <optgroup label='selected'>\n";
echo " <option value=\"".escape($dialplan_detail_type)."\">".escape($dialplan_detail_type)."</option>\n";
echo " </optgroup>\n";
@@ -863,7 +863,7 @@
else {
echo " <option value=''></option>\n";
}
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") {
//if (empty($dialplan_detail_tag) || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") {
echo " <optgroup label='".$text['optgroup-condition_or_regex']."'>\n";
echo " <option value='ani'>".$text['option-ani']."</option>\n";
echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
@@ -892,7 +892,7 @@
echo " <option value='\${toll_allow}'>\${toll_allow}</option>\n";
echo " </optgroup>\n";
//}
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
//if (empty($dialplan_detail_tag) || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
echo " <optgroup label='".$text['optgroup-applications']."'>\n";
if (is_array($_SESSION['switch']['applications'])) {
foreach ($_SESSION['switch']['applications'] as $application) {
+1 -1
View File
@@ -52,7 +52,7 @@
$dialplan_xml = $_REQUEST['dialplan_xml'];
//process the HTTP POST
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
+4 -4
View File
@@ -189,7 +189,7 @@
$param = $params ? implode('&', $params) : null;
unset($params);
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
@@ -421,7 +421,7 @@
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']);
$params[] = "app_uuid=".urlencode($app_uuid);
$params[] = "app_uuid=".urlencode($app_uuid ?? '');
if ($order_by) { $params[] = "order_by=".urlencode($order_by); }
if ($order) { $params[] = "order=".urlencode($order); }
if ($_GET['show'] && permission_exists('dialplan_all')) { $params[] = "show=".urlencode($_GET['show']); }
@@ -555,7 +555,7 @@
echo " </td>\n";
}
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) {
if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) {
$domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name'];
}
else {
@@ -571,7 +571,7 @@
echo escape($row['dialplan_name']);
}
echo " </td>\n";
echo " <td>".((strlen($row['dialplan_number']) > 0) ? escape(format_phone($row['dialplan_number'])) : "&nbsp;")."</td>\n";
echo " <td>".((!empty($row['dialplan_number'])) ? escape(format_phone($row['dialplan_number'])) : "&nbsp;")."</td>\n";
if (permission_exists('dialplan_context')) {
echo " <td>".escape($row['dialplan_context'])."</td>\n";
}
+22 -22
View File
@@ -130,7 +130,7 @@
//build update array
$array['dialplans'][0]['dialplan_uuid'] = $this->dialplan_uuid;
$array['dialplans'][0]['dialplan_name'] = $this->dialplan_name;
if (strlen($this->dialplan_continue) > 0) {
if (!empty($this->dialplan_continue)) {
$array['dialplans'][0]['dialplan_continue'] = $this->dialplan_continue;
}
$array['dialplans'][0]['dialplan_order'] = $this->dialplan_order;
@@ -188,7 +188,7 @@
$xml_string = file_get_contents($xml_file);
//prepare the xml
if (strlen($xml_string) > 0) {
if (!empty($xml_string)) {
//replace the variables
$length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8;
$xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string);
@@ -200,7 +200,7 @@
//convert to an array
$dialplan = json_decode($json, true);
}
if (strlen($this->json) > 0) {
if (!empty($this->json)) {
//convert to an array
$dialplan = json_decode($json, true);
}
@@ -232,7 +232,7 @@
$xml_string = file_get_contents($xml_file);
//prepare the xml
if (strlen($xml_string) > 0) {
if (!empty($xml_string)) {
//replace the variables
$length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8;
$xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string);
@@ -248,7 +248,7 @@
$dialplan = json_decode($json, true);
}
if (strlen($this->json) > 0) {
if (!empty($this->json)) {
//convert to an array
$dialplan = json_decode($json, true);
}
@@ -302,14 +302,14 @@
$array['dialplans'][$x]['dialplan_name'] = $dialplan['@attributes']['name'];
$array['dialplans'][$x]['dialplan_number'] = $dialplan['@attributes']['number'];
$array['dialplans'][$x]['dialplan_context'] = $dialplan_context;
if (strlen($dialplan['@attributes']['destination']) > 0) {
if (!empty($dialplan['@attributes']['destination'])) {
$array['dialplans'][$x]['dialplan_destination'] = $dialplan['@attributes']['destination'];
}
if (strlen($dialplan['@attributes']['continue']) > 0) {
if (!empty($dialplan['@attributes']['continue'])) {
$array['dialplans'][$x]['dialplan_continue'] = $dialplan['@attributes']['continue'];
}
$array['dialplans'][$x]['dialplan_order'] = $dialplan['@attributes']['order'];
if (strlen($dialplan['@attributes']['enabled']) > 0) {
if (!empty($dialplan['@attributes']['enabled'])) {
$array['dialplans'][$x]['dialplan_enabled'] = $dialplan['@attributes']['enabled'];
}
else {
@@ -330,7 +330,7 @@
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $order;
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row['@attributes']['field'];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row['@attributes']['expression'];
if (strlen($row['@attributes']['break']) > 0) {
if (!empty($row['@attributes']['break'])) {
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_break'] = $row['@attributes']['break'];
}
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = $group;
@@ -367,7 +367,7 @@
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $order;
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row2['@attributes']['application'];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row2['@attributes']['data'];
if (strlen($row2['@attributes']['inline']) > 0) {
if (!empty($row2['@attributes']['inline'])) {
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_inline'] = $row2['@attributes']['inline'];
}
else {
@@ -394,7 +394,7 @@
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $order;
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row2['@attributes']['application'];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row2['@attributes']['data'];
if (strlen($row2['@attributes']['inline']) > 0) {
if (!empty($row2['@attributes']['inline'])) {
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_inline'] = $row2['@attributes']['inline'];
}
else {
@@ -522,7 +522,7 @@
$array[$x]['dialplan_order'] = $row['dialplan_order'];
$array[$x]['dialplan_enabled'] = $row['dialplan_enabled'];
$array[$x]['dialplan_description'] = $row['dialplan_description'];
if (strlen($row['dialplan_detail_uuid']) > 0) {
if (!empty($row['dialplan_detail_uuid'])) {
$array[$x]['dialplan_details'][$y]['dialplan_uuid'] = $row['dialplan_uuid'];
$array[$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = $row['dialplan_detail_uuid'];
$array[$x]['dialplan_details'][$y]['dialplan_detail_tag'] = $row['dialplan_detail_tag'];
@@ -714,7 +714,7 @@
//get the dialplan detail inline
$detail_inline = "";
if ($dialplan_detail_inline) {
if (strlen($dialplan_detail_inline) > 0) {
if (!empty($dialplan_detail_inline)) {
$detail_inline = " inline=\"" . $dialplan_detail_inline . "\"";
}
}
@@ -723,12 +723,12 @@
if ($dialplan_tag_status != "closed") {
if (($previous_dialplan_uuid != $dialplan_uuid) || ($previous_dialplan_detail_group != $dialplan_detail_group)) {
if ($condition_tag_status != "closed") {
if ($condition_attribute && (strlen($condition_attribute) > 0)) {
if ($condition_attribute && (!empty($condition_attribute))) {
$xml .= " <condition " . $condition_attribute . $condition_break . "/>\n";
$condition_attribute = "";
$condition_tag_status = "closed";
}
else if ($condition && (strlen($condition) > 0)) {
else if ($condition && (!empty($condition))) {
$xml .= " ".$condition . "/>";
$condition = "";
$condition_tag_status = "closed";
@@ -804,12 +804,12 @@
// finalize any previous pending condition statements
if ($condition_tag_status == "open") {
if (strlen($condition) > 0) {
if (!empty($condition)) {
$xml .= $condition . "/>\n";
$condition = '';
$condition_tag_status = "closed";
}
else if (strlen($condition_attribute) > 0 && $condition_tag_status == "open") {
else if (!empty($condition_attribute) && $condition_tag_status == "open") {
// previous condition(s) must have been of type time
// do not finalize if new condition is also of type time
if ($condition_type != 'time') {
@@ -828,7 +828,7 @@
//get the condition break attribute
$condition_break = "";
if ($dialplan_detail_break) {
if (strlen($dialplan_detail_break) > 0) {
if (!empty($dialplan_detail_break)) {
$condition_break = " break=\"" . $dialplan_detail_break . "\"";
}
}
@@ -854,11 +854,11 @@
if ($dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
if ($condition_tag_status == "open") {
if ($condition_attribute && (strlen($condition_attribute) > 0)) {
if ($condition_attribute && (!empty($condition_attribute))) {
$xml .= " <condition " . $condition_attribute . $condition_break . ">\n";
$condition_attribute = "";
}
else if ($condition && (strlen($condition) > 0)) {
else if ($condition && (!empty($condition))) {
$xml .= $condition . ">\n";
$condition = "";
}
@@ -923,10 +923,10 @@
//close the extension tag if it was left open
if ($dialplan_tag_status == "open") {
if ($condition_tag_status == "open") {
if ($condition_attribute and (strlen($condition_attribute) > 0)) {
if ($condition_attribute and (!empty($condition_attribute))) {
$xml .= " <condition " . $condition_attribute . $condition_break . "/>\n";
}
else if ($condition && (strlen($condition) > 0)) {
else if ($condition && (!empty($condition))) {
$xml .= $condition . "/>\n";
}
else {