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 13:46:37 -03:00
committed by GitHub
parent ebbb2f1a72
commit fef8165be2
230 changed files with 1948 additions and 1937 deletions

View File

@@ -156,7 +156,7 @@
}
//normalize the mac address
if (isset($device_mac_address) && strlen($device_mac_address) > 0) {
if (isset($device_mac_address) && !empty($device_mac_address)) {
$device_mac_address = strtolower($device_mac_address);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
}

View File

@@ -162,19 +162,19 @@
//$device_setting_description = $_POST["device_setting_description"];
//normalize the mac address
if (isset($device_mac_address) && strlen($device_mac_address) > 0) {
if (!empty($device_mac_address)) {
$device_mac_address = strtolower($device_mac_address);
$device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
}
}
//use the mac address to get the vendor
if (strlen($device_vendor) == 0) {
if (empty($device_vendor)) {
$device_vendor = device::get_vendor($device_mac_address);
}
//add or update the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
@@ -186,17 +186,17 @@
//check for all required data
$msg = '';
if (strlen($device_mac_address) == 0) { $msg .= $text['message-required'].$text['label-device_mac_address']."<br>\n"; }
//if (strlen($device_label) == 0) { $msg .= "Please provide: Label<br>\n"; }
//if (strlen($device_vendor) == 0) { $msg .= "Please provide: Vendor<br>\n"; }
//if (strlen($device_model) == 0) { $msg .= "Please provide: Model<br>\n"; }
//if (strlen($device_firmware_version) == 0) { $msg .= "Please provide: Firmware Version<br>\n"; }
//if (strlen($device_enabled) == 0) { $msg .= "Please provide: Enabled<br>\n"; }
//if (strlen($device_template) == 0) { $msg .= "Please provide: Template<br>\n"; }
//if (strlen($device_username) == 0) { $msg .= "Please provide: Username<br>\n"; }
//if (strlen($device_password) == 0) { $msg .= "Please provide: Password<br>\n"; }
//if (strlen($device_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
if (strlen($msg) > 0) {
if (empty($device_mac_address)) { $msg .= $text['message-required'].$text['label-device_mac_address']."<br>\n"; }
//if (empty($device_label)) { $msg .= "Please provide: Label<br>\n"; }
//if (empty($device_vendor)) { $msg .= "Please provide: Vendor<br>\n"; }
//if (empty($device_model)) { $msg .= "Please provide: Model<br>\n"; }
//if (empty($device_firmware_version)) { $msg .= "Please provide: Firmware Version<br>\n"; }
//if (empty($device_enabled)) { $msg .= "Please provide: Enabled<br>\n"; }
//if (empty($device_template)) { $msg .= "Please provide: Template<br>\n"; }
//if (empty($device_username)) { $msg .= "Please provide: Username<br>\n"; }
//if (empty($device_password)) { $msg .= "Please provide: Password<br>\n"; }
//if (empty($device_description)) { $msg .= "Please provide: Description<br>\n"; }
if (!empty($msg)) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
@@ -291,7 +291,7 @@
if (permission_exists('device_line_edit')) {
$y = 0;
foreach ($device_lines as $row) {
if (strlen($row['line_number']) > 0) {
if (!empty($row['line_number'])) {
$new_line = false;
if (is_uuid($row["device_line_uuid"])) {
$device_line_uuid = $row["device_line_uuid"];
@@ -374,7 +374,7 @@
if (permission_exists('device_key_edit')) {
$y = 0;
foreach ($device_keys as $row) {
if (strlen($row['device_key_category']) > 0) {
if (!empty($row['device_key_category'])) {
if (is_uuid($row["device_key_uuid"])) {
$device_key_uuid = $row["device_key_uuid"];
}
@@ -413,7 +413,7 @@
if (permission_exists('device_setting_edit')) {
$y = 0;
foreach ($device_settings as $row) {
if (strlen($row['device_setting_subcategory']) > 0) {
if (!empty($row['device_setting_subcategory'])) {
if (is_uuid($row["device_setting_uuid"])) {
$device_setting_uuid = $row["device_setting_uuid"];
}
@@ -477,7 +477,7 @@
}
//write the provision files
if (strlen($_SESSION['provision']['path']['text']) > 0) {
if (!empty($_SESSION['provision']['path']['text'])) {
$prov = new provision;
$prov->domain_uuid = $domain_uuid;
$response = $prov->write();
@@ -502,7 +502,7 @@
}
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
if (!empty($_GET) && $_POST["persistformvar"] != "true") {
$sql = "select * from v_devices ";
$sql .= "where device_uuid = :device_uuid ";
$parameters['device_uuid'] = $device_uuid;
@@ -532,17 +532,17 @@
}
//set the defaults
if (strlen($device_enabled) == 0) { $device_enabled = 'true'; }
if (empty($device_enabled)) { $device_enabled = 'true'; }
//use the mac address to get the vendor
if (strlen($device_vendor) == 0) {
if (empty($device_vendor)) {
//get the device vendor using the mac address
$device_vendor = device::get_vendor($device_mac_address);
//if the vendor was not found using the mac address use an alternative method
if (strlen($device_vendor) == 0) {
$template_array = explode("/", $device_template);
$device_vendor = $template_array[0];
if (empty($device_vendor)) {
$template_array = explode("/", $device_template ?? '');
$device_vendor = $template_array[0] ?? '';
}
}
@@ -665,16 +665,16 @@
unset($sql, $parameters);
//use the mac address to get the vendor
if (strlen($device_vendor) == 0) {
if (empty($device_vendor)) {
$device_vendor = device::get_vendor($device_mac_address);
}
//get the device line info for provision button
foreach($device_lines as $row) {
if (strlen($row['user_id']) > 0) {
if (!empty($row['user_id'])) {
$user_id = $row['user_id'];
}
if (strlen($row['server_address']) > 0) {
if (!empty($row['server_address'])) {
$server_address = $row['server_address'];
}
}
@@ -747,7 +747,7 @@
if (permission_exists("device_line_password") && $device_template == "grandstream/wave") {
//set the mode
if (isset($_SESSION['theme']['qr_image'])) {
if (strlen($_SESSION['theme']['qr_image']) > 0) {
if (!empty($_SESSION['theme']['qr_image'])) {
$mode = '4';
}
else {
@@ -762,7 +762,7 @@
$row = $device_lines[0];
//set the outbound proxy settings
if (strlen($row['outbound_proxy_primary']) == 0) {
if (empty($row['outbound_proxy_primary'])) {
$outbound_proxy_primary = $row['server_address'];
}
else {
@@ -908,7 +908,7 @@
'id'=>'btn_copy',
'style'=>'float: right; margin-left: 15px;',
'collapse'=>'never',
'onclick'=>"modal_close(); if (document.getElementById('new_mac_address').value != '') { window.location='device_copy.php?id=".urlencode($device_uuid)."&mac=' + document.getElementById('new_mac_address').value; }"
'onclick'=>"modal_close(); if (document.getElementById('new_mac_address').value != '') { window.location='device_copy.php?id=".urlencode($device_uuid ?? '')."&mac=' + document.getElementById('new_mac_address').value; }"
]),
'onclose'=>"document.getElementById('new_mac_address').value = '';",
]);
@@ -933,15 +933,15 @@
echo "</td>\n";
echo "<td class='vtable' width='70%' align='left'>\n";
if (permission_exists('device_mac_address')) {
echo " <input class='formfld' type='text' name='device_mac_address' id='device_mac_address' maxlength='255' value=\"".escape($device_mac_address)."\"/>\n";
echo " <input class='formfld' type='text' name='device_mac_address' id='device_mac_address' maxlength='255' value=\"".escape($device_mac_address ?? '')."\"/>\n";
echo "<br />\n";
echo $text['description-device_mac_address']."\n";
}
else {
echo escape($device_mac_address);
echo escape($device_mac_address ?? '');
}
echo " <div style='display: none;' id='duplicate_mac_response'></div>\n";
echo " ".escape($device_provisioned_ip)."(<a href='http://".escape($device_provisioned_ip)."' target='_blank'>http</a>|<a href='https://".escape($device_provisioned_ip)."' target='_blank'>https</a>)\n";
echo " ".escape($device_provisioned_ip ?? '')."(<a href='http://".escape($device_provisioned_ip ?? '')."' target='_blank'>http</a>|<a href='https://".escape($device_provisioned_ip ?? '')."' target='_blank'>https</a>)\n";
echo "</td>\n";
echo "</tr>\n";
@@ -1111,11 +1111,11 @@
//set the defaults
if (!permission_exists('device_line_server_address')) {
if (strlen($row['server_address']) == 0) { $row['server_address'] = $_SESSION['domain_name']; }
if (empty($row['server_address'])) { $row['server_address'] = $_SESSION['domain_name']; }
}
if (strlen($row['sip_transport']) == 0) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; }
if (strlen($row['sip_port']) == 0) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; }
if (strlen($row['register_expires']) == 0) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; }
if (empty($row['sip_transport'])) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; }
if (empty($row['sip_port'])) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; }
if (empty($row['register_expires'])) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; }
//determine whether to hide the element
if (!is_uuid($device_line_uuid)) {
@@ -1302,7 +1302,7 @@
$x++;
}
echo " </table>\n";
if (strlen($text['description-lines']) > 0) {
if (!empty($text['description-lines'])) {
echo " <br>".$text['description-lines']."\n";
}
echo " </td>";
@@ -1397,7 +1397,7 @@
if (permission_exists('device_key_id')) {
echo " <td class='vtable'>".$text['label-device_key_id']."</td>\n";
}
if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) {
if ($vendor_count > 1 && !empty($row['device_key_vendor'])) {
echo " <td class='vtable'>".ucwords($row['device_key_vendor'])."</td>\n";
if ($show_key_subtype) {
echo " <td class='vtable'>".$text['label-device_key_subtype']."</td>\n";
@@ -1467,7 +1467,7 @@
echo " <option value='programmable'>".$text['label-programmable']."</option>\n";
}
if ($row['device_key_vendor'] !== "polycom") {
if (strlen($device_vendor) == 0) {
if (empty($device_vendor)) {
if ($row['device_key_category'] == "expansion") {
echo " <option value='expansion' selected='selected'>".$text['label-expansion']." 1</option>\n";
}
@@ -1571,7 +1571,7 @@
echo "<td align='left' nowrap='nowrap'>\n";
//echo " <input class='formfld' type='text' name='device_keys[".$x."][device_key_type]' style='width: 120px;' maxlength='255' value=\"$row['device_key_type']\">\n";
if (strlen($row['device_key_vendor']) > 0) {
if (!empty($row['device_key_vendor'])) {
$device_key_vendor = $row['device_key_vendor'];
}
else {
@@ -1585,7 +1585,7 @@
$previous_vendor = '';
$i=0;
foreach ($vendor_functions as $function) {
if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) {
if (empty($row['device_key_vendor']) && $function['vendor_name'] != $previous_vendor) {
if ($i > 0) { echo " </optgroup>\n"; }
echo " <optgroup label='".ucwords($function['vendor_name'])."'>\n";
}
@@ -1593,16 +1593,16 @@
if (strtolower($row['device_key_vendor']) == $function['vendor_name'] && $row['device_key_type'] == $function['value']) {
$selected = "selected='selected'";
}
if (strlen($row['device_key_vendor']) == 0) {
if (empty($row['device_key_vendor'])) {
echo " <option value='".$function['value']."' vendor='".$function['vendor_name']."' $selected >".$text['label-'.$function['type']]."</option>\n";
}
if (strlen($row['device_key_vendor']) > 0 && strtolower($row['device_key_vendor']) == $function['vendor_name']) {
if (!empty($row['device_key_vendor']) && strtolower($row['device_key_vendor']) == $function['vendor_name']) {
echo " <option value='".$function['value']."' vendor='".$function['vendor_name']."' $selected >".$text['label-'.$function['type']]."</option>\n";
}
$previous_vendor = $function['vendor_name'];
$i++;
}
if (strlen($row['device_key_vendor']) == 0) {
if (empty($row['device_key_vendor'])) {
echo " </optgroup>\n";
}
echo "</select>\n";
@@ -1663,7 +1663,7 @@
$x++;
}
echo " </table>\n";
if (strlen($text['description-keys']) > 0) {
if (!empty($text['description-keys'])) {
echo " <br>".$text['description-keys']."\n";
}
echo " </td>";
@@ -1745,7 +1745,7 @@
echo "</table>\n";
if (strlen($text['description-settings']) > 0) {
if (!empty($text['description-settings'])) {
echo "<br>".$text['description-settings']."\n";
}
@@ -1793,8 +1793,8 @@
echo "</td>\n";
echo "<td class='vtable' align='left' nowrap='nowrap'>\n";
$label = $device_alternate[0]['device_label'];
if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; }
if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; }
if (empty($label)) { $label = $device_alternate[0]['device_description']; }
if (empty($label)) { $label = $device_alternate[0]['device_mac_address']; }
echo " <table>\n";
echo " <tr>\n";
echo " <td><a href='?id=".escape($device_uuid_alternate)."' id='device_uuid_alternate_link'>".escape($label)."</a><input class='formfld' type='hidden' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"".escape($device_uuid_alternate)."\" />&nbsp;</td>";

View File

@@ -51,7 +51,7 @@
$fp = fopen("php://memory", 'r+');
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
fclose($fp);
return $data;
}
@@ -86,7 +86,7 @@
}
//get the schema
if (strlen($delimiter) > 0 && file_exists($_SESSION['file'])) {
if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '')) {
//get the first line
$line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line);
@@ -135,7 +135,7 @@
}
//match the column names to the field names
if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') {
if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '') && $action != 'import') {
//validate the token
$token = new token;
@@ -239,7 +239,7 @@
}
//upload the csv
if (file_exists($_SESSION['file']) && $action == 'import') {
if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
//validate the token
$token = new token;
@@ -316,8 +316,8 @@
}
//build the data array
if (strlen($table_name) > 0) {
if (strlen($parent) == 0) {
if (!empty($table_name)) {
if (empty($parent)) {
if ($field_name != "username") {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key];
@@ -450,7 +450,7 @@
//view_array($message);
}
if (strlen($_SESSION['provision']['path']['text']) > 0) {
if (!empty($_SESSION['provision']['path']['text'])) {
$prov = new provision;
$prov->domain_uuid = $domain_uuid;
$response = $prov->write();

View File

@@ -55,7 +55,7 @@
}
//process the user data and save it to the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//process the http post data by submitted action
if ($_POST['action'] != '' && is_uuid($_POST['device_profile_uuid'])) {
@@ -115,13 +115,13 @@
//check for all required data
$msg = '';
if (strlen($device_profile_name) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_name']."<br>\n"; }
//if (strlen($device_profile_keys) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_keys']."<br>\n"; }
//if (strlen($device_profile_settings) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_settings']."<br>\n"; }
//if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (strlen($device_profile_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_enabled']."<br>\n"; }
//if (strlen($device_profile_description) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (empty($device_profile_name)) { $msg .= $text['message-required']." ".$text['label-device_profile_name']."<br>\n"; }
//if (empty($device_profile_keys)) { $msg .= $text['message-required']." ".$text['label-device_profile_keys']."<br>\n"; }
//if (empty($device_profile_settings)) { $msg .= $text['message-required']." ".$text['label-device_profile_settings']."<br>\n"; }
//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (empty($device_profile_enabled)) { $msg .= $text['message-required']." ".$text['label-device_profile_enabled']."<br>\n"; }
//if (empty($device_profile_description)) { $msg .= $text['message-required']." ".$text['label-device_profile_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";
@@ -135,7 +135,7 @@
}
//add the device_profile_uuid
if (strlen($_POST["device_profile_uuid"]) == 0) {
if (empty($_POST["device_profile_uuid"])) {
$device_profile_uuid = uuid();
}
@@ -147,7 +147,7 @@
$array['device_profiles'][0]["device_profile_description"] = $device_profile_description;
$y = 0;
foreach ($device_profile_keys as $row) {
if (strlen($row['profile_key_vendor']) > 0 && strlen($row['profile_key_id']) > 0) {
if (strlen($row['profile_key_vendor']) > 0 && !empty($row['profile_key_id'])) {
$array['device_profiles'][0]['device_profile_keys'][$y]["domain_uuid"] = $domain_uuid;
$array['device_profiles'][0]['device_profile_keys'][$y]["device_profile_key_uuid"] = $row["device_profile_key_uuid"];
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_category"] = $row["profile_key_category"];
@@ -169,7 +169,7 @@
$y = 0;
if (permission_exists("device_profile_setting_edit")) {
foreach ($device_profile_settings as $row) {
if (strlen($row['profile_setting_name']) > 0 && strlen($row['profile_setting_enabled']) > 0) {
if (strlen($row['profile_setting_name']) > 0 && !empty($row['profile_setting_enabled'])) {
$array['device_profiles'][0]['device_profile_settings'][$y]["domain_uuid"] = $domain_uuid;
$array['device_profiles'][0]['device_profile_settings'][$y]["device_profile_setting_uuid"] = $row["device_profile_setting_uuid"];
$array['device_profiles'][0]['device_profile_settings'][$y]["profile_setting_name"] = $row["profile_setting_name"];
@@ -246,10 +246,10 @@
}
//set the defaults
if (strlen($device_profile_enabled) == 0) { $device_profile_enabled = 'true'; }
if (empty($device_profile_enabled)) { $device_profile_enabled = 'true'; }
//get the child data
if (strlen($device_profile_uuid) > 0) {
if (!empty($device_profile_uuid)) {
$sql = "select * from v_device_profile_keys ";
$sql .= "where device_profile_uuid = :device_profile_uuid ";
//$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
@@ -316,7 +316,7 @@
unset($sql);
//add the $device_profile_key_uuid
if (strlen($device_profile_key_uuid) == 0) {
if (empty($device_profile_key_uuid)) {
$device_profile_key_uuid = uuid();
}
@@ -348,7 +348,7 @@
}
//get the child data
if (strlen($device_profile_uuid) > 0) {
if (!empty($device_profile_uuid)) {
$sql = "select * from v_device_profile_settings ";
$sql .= "where device_profile_uuid = :device_profile_uuid ";
//$sql .= "and domain_uuid = '".$domain_uuid."' ";
@@ -361,7 +361,7 @@
}
//add the $device_profile_setting_uuid
if (strlen($device_profile_setting_uuid) == 0) {
if (empty($device_profile_setting_uuid)) {
$device_profile_setting_uuid = uuid();
}
@@ -536,7 +536,7 @@
}
echo " <option value='programmable' ".($row['profile_key_category'] == "programmable" ? "selected='selected'" : null).">".$text['label-programmable']."</option>\n";
if ($row['profile_key_vendor'] !== "polycom") {
if (strlen($row['profile_key_vendor']) == 0) {
if (empty($row['profile_key_vendor'])) {
echo " <option value='expansion' ".($row['profile_key_category'] == "expansion" ? "selected='selected'" : null).">".$text['label-expansion']."</option>\n";
echo " <option value='expansion-1' ".($row['profile_key_category'] == "expansion-1" ? "selected='selected'" : null).">".$text['label-expansion']." 1</option>\n";
echo " <option value='expansion-2' ".($row['profile_key_category'] == "expansion-2" ? "selected='selected'" : null).">".$text['label-expansion']." 2</option>\n";
@@ -577,7 +577,7 @@
if ($row['profile_key_vendor'] == $vendor['name']) {
$selected = "selected='selected'";
}
if (strlen($vendor['name']) > 0) {
if (!empty($vendor['name'])) {
echo " <option value='".escape($vendor['name'])."' $selected >".escape(ucwords($vendor['name']))."</option>\n";
}
}
@@ -591,7 +591,7 @@
$previous_vendor = '';
$i = 0;
foreach ($vendor_functions as $function) {
if (strlen($row['profile_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) {
if (empty($row['profile_key_vendor']) && $function['vendor_name'] != $previous_vendor) {
if ($i > 0) { echo " </optgroup>\n"; }
echo " <optgroup label='".escape(ucwords($function['vendor_name']))."'>\n";
}
@@ -599,16 +599,16 @@
if ($row['profile_key_vendor'] == $function['vendor_name'] && $row['profile_key_type'] == $function['value']) {
$selected = "selected='selected'";
}
if (strlen($row['profile_key_vendor']) == 0) {
if (empty($row['profile_key_vendor'])) {
echo " <option value='".escape($function['value'])."' vendor='".escape($function['vendor_name'])."' $selected >".$text['label-'.$function['type']]."</option>\n";
}
if (strlen($row['profile_key_vendor']) > 0 && $row['profile_key_vendor'] == $function['vendor_name']) {
if (!empty($row['profile_key_vendor']) && $row['profile_key_vendor'] == $function['vendor_name']) {
echo " <option value='".escape($function['value'])."' vendor='".escape($function['vendor_name'])."' $selected >".$text['label-'.$function['type']]."</option>\n";
}
$previous_vendor = $function['vendor_name'];
$i++;
}
if (strlen($row['profile_key_vendor']) == 0) {
if (empty($row['profile_key_vendor'])) {
echo " </optgroup>\n";
}
echo " </select>\n";

View File

@@ -88,7 +88,7 @@
$order = $_GET["order"];
//add the search term
if (strlen($search) > 0) {
if (!empty($search)) {
$sql_search = "and (";
$sql_search .= " lower(device_profile_name) like :search ";
$sql_search .= " or lower(device_profile_description) like :search ";
@@ -132,7 +132,7 @@
$param .= "&show=all";
}
$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); //bottom
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); //top
$offset = $rows_per_page * $page;
@@ -248,7 +248,7 @@
echo " </td>\n";
}
if ($_GET['show'] == "all" && permission_exists('device_profile_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 {

View File

@@ -62,7 +62,7 @@
}
//process the data
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//get the uuid
if ($action == "update") {
@@ -79,10 +79,10 @@
//check for all required data
$msg = '';
if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."<br>\n"; }
if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
//if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (empty($name)) { $msg .= $text['message-required']." ".$text['label-name']."<br>\n"; }
if (empty($enabled)) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
//if (empty($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";
@@ -141,7 +141,7 @@
}
//set the defaults
if (strlen($enabled) == 0) { $enabled = true; }
if (empty($enabled)) { $enabled = true; }
//create token
$object = new token;

View File

@@ -97,7 +97,7 @@
}
//process the http variables
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//get the uuid
if ($action == "update") {
@@ -114,12 +114,12 @@
//check for all required data
$msg = '';
//if (strlen($label) == 0) { $msg .= $text['message-required']." ".$text['label-label']."<br>\n"; }
if (strlen($type) == 0) { $msg .= $text['message-required']." ".$text['label-type']."<br>\n"; }
if (strlen($value) == 0) { $msg .= $text['message-required']." ".$text['label-value']."<br>\n"; }
if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
//if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
//if (empty($label)) { $msg .= $text['message-required']." ".$text['label-label']."<br>\n"; }
if (empty($type)) { $msg .= $text['message-required']." ".$text['label-type']."<br>\n"; }
if (empty($value)) { $msg .= $text['message-required']." ".$text['label-value']."<br>\n"; }
if (empty($enabled)) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
//if (empty($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";
@@ -241,7 +241,7 @@
//set the assigned_groups array
if (is_array($function_groups) && @sizeof($function_groups) != 0) {
foreach($function_groups as $field) {
if (strlen($field['group_name']) > 0) {
if (!empty($field['group_name'])) {
$assigned_groups[] = $field['group_uuid'];
}
}
@@ -325,7 +325,7 @@
if (is_array($function_groups) && @sizeof($function_groups) != 0) {
echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
foreach ($function_groups as $field) {
if (strlen($field['group_name']) > 0) {
if (!empty($field['group_name'])) {
echo "<tr>\n";
echo " <td class='vtable' style='white-space: nowrap; padding-right: 30px;' nowrap='nowrap'>";
echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);

View File

@@ -103,7 +103,7 @@
$param = "";
if (isset($_GET['page'])) {
$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);
$offset = $rows_per_page * $page;

View File

@@ -80,7 +80,7 @@
//add the search term
$search = strtolower($_GET["search"]);
if (strlen($search) > 0) {
if (!empty($search)) {
$sql_where = "where (";
$sql_where .= "lower(name) like :search ";
$sql_where .= "or lower(enabled) like :search ";
@@ -99,7 +99,7 @@
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "&search=".$search;
$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;

View File

@@ -53,8 +53,8 @@
}
//get the search
$search = strtolower($_REQUEST["search"]);
$fields = strtolower($_REQUEST["fields"]);
$search = strtolower($_REQUEST["search"] ?? '');
$fields = strtolower($_REQUEST["fields"] ?? '');
//process the http post data by action
if ($action != '' && is_array($devices) && @sizeof($devices) != 0) {
@@ -112,7 +112,7 @@
//prepare to page the results
$sql = "select count(*) from v_devices as d ";
if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) {
if (strlen($search) > 0) {
if (!empty($search)) {
$sql .= "where ";
}
}
@@ -123,12 +123,12 @@
$sql .= " or d.domain_uuid is null ";
}
$sql .= ") ";
if (strlen($search) > 0) {
if (!empty($search)) {
$sql .= "and ";
}
$parameters['domain_uuid'] = $domain_uuid;
}
if (strlen($search) > 0) {
if (!empty($search)) {
$sql .= "(";
$sql .= " lower(d.device_mac_address) like :search ";
$sql .= " or lower(d.device_label) like :search ";
@@ -178,7 +178,7 @@
$param .= "&show=all";
}
$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;
@@ -214,7 +214,7 @@
$sql .= "and d.device_user_uuid = :user_uuid ";
$parameters['user_uuid'] = $_SESSION['user_uuid'];
}
if (strlen($search) > 0) {
if (!empty($search)) {
$sql .= "and (";
$sql .= " lower(d.device_mac_address) like :search ";
$sql .= " or lower(d.device_label) like :search ";
@@ -250,7 +250,7 @@
$sql .= ") ";
$parameters['search'] = '%'.strtolower($search).'%';
}
if (strlen($order_by) == 0) {
if (empty($order_by)) {
$sql .= "order by d.device_label, d.device_description asc ";
}
else {
@@ -421,7 +421,7 @@
echo " </td>\n";
echo " <td>".escape($row['device_label'])."&nbsp;</td>\n";
if ($device_alternate) {
if (strlen($row['device_uuid_alternate']) > 0) {
if (!empty($row['device_uuid_alternate'])) {
echo " <td class='no-link'>\n";
echo " <a href='device_edit.php?id=".urlencode($row['device_uuid_alternate'])."'>".escape($row['alternate_label'])."</a>\n";
echo " </td>\n";

View File

@@ -57,7 +57,12 @@
return $this->domain_uuid;
}
public static function get_vendor($mac){
public static function get_vendor($mac) {
//return if the mac address is empty
if(empty($mac)) {
return '';
}
//use the mac address to find the vendor
$mac = preg_replace('#[^a-fA-F0-9./]#', '', $mac);
$mac = strtolower($mac);
@@ -226,7 +231,7 @@
//set the default template directory
if (PHP_OS == "Linux") {
//set the default template dir
if (strlen($this->template_dir) == 0) {
if (empty($this->template_dir)) {
if (file_exists('/usr/share/fusionpbx/templates/provision')) {
$this->template_dir = '/usr/share/fusionpbx/templates/provision';
}
@@ -240,7 +245,7 @@
}
elseif (PHP_OS == "FreeBSD") {
//if the FreeBSD port is installed use the following paths by default.
if (strlen($this->template_dir) == 0) {
if (empty($this->template_dir)) {
if (file_exists('/usr/local/share/fusionpbx/templates/provision')) {
$this->template_dir = '/usr/local/share/fusionpbx/templates/provision';
}
@@ -254,19 +259,19 @@
}
elseif (PHP_OS == "NetBSD") {
//set the default template_dir
if (strlen($this->template_dir) == 0) {
if (empty($this->template_dir)) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
elseif (PHP_OS == "OpenBSD") {
//set the default template_dir
if (strlen($this->template_dir) == 0) {
if (empty($this->template_dir)) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
else {
//set the default template_dir
if (strlen($this->template_dir) == 0) {
if (empty($this->template_dir)) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
@@ -346,7 +351,7 @@
$p->delete('device_key_delete', 'temp');
//write the provision files
if (strlen($_SESSION['provision']['path']['text']) > 0) {
if (!empty($_SESSION['provision']['path']['text'])) {
$prov = new provision;
$prov->domain_uuid = $_SESSION['domain_uuid'];
$response = $prov->write();
@@ -853,7 +858,7 @@
unset($array);
//write the provision files
if (strlen($_SESSION['provision']['path']['text']) > 0) {
if (!empty($_SESSION['provision']['path']['text'])) {
$prov = new provision;
$prov->domain_uuid = $_SESSION['domain_uuid'];
$response = $prov->write();

View File

@@ -66,7 +66,7 @@
unset($sql, $sql_where_or, $parameters);
//add or update the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//add or update the database
if ($_POST["persistformvar"] != "true") {
@@ -189,7 +189,7 @@
$device_key_vendor = $row["device_key_vendor"];
//process the profile keys
if (strlen($row["device_profile_uuid"]) > 0) {
if (!empty($row["device_profile_uuid"])) {
//get the profile key settings from the array
foreach ($device_profile_keys as &$field) {
if ($device_key_uuid == $field["device_key_uuid"]) {
@@ -213,10 +213,10 @@
//sql add or update
if (!is_uuid($device_key_uuid)) {
if (permission_exists('device_key_add') && strlen($device_key_type) > 0 && strlen($device_key_value) > 0) {
if (permission_exists('device_key_add') && strlen($device_key_type) > 0 && !empty($device_key_value)) {
//if the device_uuid is not in the array then get the device_uuid from the database
if (strlen($device_uuid) == 0) {
if (empty($device_uuid)) {
$sql = "select device_uuid from v_devices ";
$sql .= "where device_user_uuid = :device_user_uuid ";
$parameters['device_user_uuid'] = $_SESSION['user_uuid'];
@@ -281,7 +281,7 @@
}
//write the provision files
if (strlen($_SESSION['provision']['path']['text']) > 0) {
if (!empty($_SESSION['provision']['path']['text'])) {
$prov = new provision;
$prov->domain_uuid = $domain_uuid;
$response = $prov->write();
@@ -465,7 +465,7 @@
if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') {
echo " <tr class='list-header'>\n";
echo " <th class='shrink'>".$text['label-device_key_id']."</th>\n";
if (strlen($row['device_key_vendor']) > 0) {
if (!empty($row['device_key_vendor'])) {
echo " <th>".ucwords($row['device_key_vendor'])."</th>\n";
}
else {
@@ -480,7 +480,7 @@
}
//determine whether to hide the element
if (strlen($device_key_uuid) == 0) {
if (empty($device_key_uuid)) {
$element['hidden'] = false;
$element['visibility'] = "visibility:visible;";
}
@@ -490,7 +490,7 @@
}
//add the primary key uuid
if (strlen($row['device_key_uuid']) > 0) {
if (!empty($row['device_key_uuid'])) {
echo " <input name='device_keys[".$x."][device_key_uuid]' type='hidden' value=\"".$row['device_key_uuid']."\">\n";
}
@@ -518,7 +518,7 @@
else {
echo " <option value='programmable'>".$text['label-programmable']."</option>\n";
}
if (strlen($device_vendor) == 0) {
if (empty($device_vendor)) {
if ($row['device_key_category'] == "expansion") {
echo " <option value='expansion' selected='selected'>".$text['label-expansion']."</option>\n";
}
@@ -585,7 +585,7 @@
$i = 0;
if (is_array($vendor_functions)) {
foreach ($vendor_functions as $function) {
if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) {
if (empty($row['device_key_vendor']) && $function['vendor_name'] != $previous_vendor) {
if ($i > 0) {
echo " </optgroup>\n";
}
@@ -595,17 +595,17 @@
if ($row['device_key_vendor'] == $function['vendor_name'] && $row['device_key_type'] == $function['value']) {
$selected = "selected='selected'";
}
if (strlen($row['device_key_vendor']) == 0) {
if (empty($row['device_key_vendor'])) {
echo " <option value='".$function['value']."' $selected >".$text['label-'.$function['name']]."</option>\n";
}
if (strlen($row['device_key_vendor']) > 0 && $row['device_key_vendor'] == $function['vendor_name']) {
if (!empty($row['device_key_vendor']) && $row['device_key_vendor'] == $function['vendor_name']) {
echo " <option value='".$function['value']."' $selected >".$text['label-'.$function['name']]."</option>\n";
}
$previous_vendor = $function['vendor_name'];
$i++;
}
}
if (strlen($row['device_key_vendor']) == 0) {
if (empty($row['device_key_vendor'])) {
echo " </optgroup>\n";
}
echo " </select>\n";