Pārlūkot izejas kodu

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 <[email protected]>
Co-authored-by: FusionPBX <[email protected]>
frytimo 2 gadi atpakaļ
vecāks
revīzija
a2ccf63dd5
57 mainītis faili ar 331 papildinājumiem un 327 dzēšanām
  1. 7 7
      core/authentication/resources/classes/authentication.php
  2. 3 2
      core/authentication/resources/classes/plugins/database.php
  3. 3 2
      core/authentication/resources/classes/plugins/email.php
  4. 2 2
      core/authentication/resources/classes/plugins/ldap.php
  5. 11 11
      core/dashboard/dashboard_edit.php
  6. 11 11
      core/databases/database_edit.php
  7. 12 12
      core/default_settings/default_setting_edit.php
  8. 14 10
      core/default_settings/default_settings.php
  9. 1 2
      core/default_settings/default_settings_reload.php
  10. 13 13
      core/domain_settings/domain_setting_edit.php
  11. 7 7
      core/domains/domain_edit.php
  12. 0 1
      core/domains/domains.php
  13. 1 1
      core/groups/app_defaults.php
  14. 8 8
      core/groups/group_edit.php
  15. 5 5
      core/groups/group_permissions.php
  16. 1 1
      core/groups/groupmemberadd.php
  17. 5 5
      core/menu/menu_edit.php
  18. 9 9
      core/menu/menu_item_edit.php
  19. 1 1
      core/user_logs/resources/classes/user_logs.php
  20. 1 1
      core/user_logs/user_log_edit.php
  21. 16 16
      core/user_settings/user_setting_edit.php
  22. 4 1
      core/user_settings/user_settings.php
  23. 1 1
      core/users/app_defaults.php
  24. 8 8
      core/users/user_edit.php
  25. 5 5
      core/users/user_imports.php
  26. 1 1
      resources/captcha/config.php
  27. 1 1
      resources/check_auth.php
  28. 1 1
      resources/classes/config.php
  29. 26 26
      resources/classes/database.php
  30. 14 14
      resources/classes/domains.php
  31. 4 4
      resources/classes/email.php
  32. 7 7
      resources/classes/menu.php
  33. 3 3
      resources/classes/message.php
  34. 1 1
      resources/classes/ringbacks.php
  35. 7 7
      resources/classes/schema.php
  36. 3 3
      resources/classes/switch_settings.php
  37. 13 14
      resources/classes/text.php
  38. 10 10
      resources/classes/vcard.php
  39. 2 2
      resources/footer.php
  40. 1 1
      resources/fpdi/pdf_parser.php
  41. 30 32
      resources/functions.php
  42. 5 5
      resources/header.php
  43. 4 4
      resources/login.php
  44. 6 6
      resources/paging.php
  45. 8 8
      resources/pdo.php
  46. 1 1
      resources/pdo_vm.php
  47. 2 2
      resources/phpmailer/class.phpmailer.php
  48. 2 2
      resources/pop3/mime_parser.php
  49. 1 1
      resources/pop3/pop3.php
  50. 1 1
      resources/pop3/rfc822_addresses.php
  51. 5 5
      resources/tcpdf/include/barcodes/pdf417.php
  52. 1 1
      resources/tcpdf/include/barcodes/qrcode.php
  53. 1 1
      resources/tcpdf/include/tcpdf_colors.php
  54. 4 4
      resources/tcpdf/include/tcpdf_fonts.php
  55. 6 6
      resources/tcpdf/include/tcpdf_static.php
  56. 10 10
      resources/tcpdf/tcpdf.php
  57. 1 1
      themes/default/css.php

+ 7 - 7
core/authentication/resources/classes/authentication.php

@@ -277,7 +277,7 @@ class authentication {
 						$sql = "select distinct(permission_name) from v_group_permissions ";
 						$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
 						foreach ($_SESSION["groups"] as $field) {
-							if (strlen($field['group_name']) > 0) {
+							if (!empty($field['group_name'])) {
 								$sql_where_or[] = "group_name = :group_name_".$x;
 								$parameters['group_name_'.$x] = $field['group_name'];
 								$x++;
@@ -310,8 +310,8 @@ class authentication {
 							$name = $row['user_setting_name'];
 							$category = $row['user_setting_category'];
 							$subcategory = $row['user_setting_subcategory'];
-							if (strlen($row['user_setting_value']) > 0) {
-								if (strlen($subcategory) == 0) {
+							if (!empty($row['user_setting_value'])) {
+								if (empty($subcategory)) {
 									//$$category[$name] = $row['domain_setting_value'];
 									if ($name == "array") {
 										$_SESSION[$category][] = $row['user_setting_value'];
@@ -365,7 +365,7 @@ class authentication {
 									foreach($result as $x => $row) {
 										//set the destination
 										$destination = $row['extension'];
-										if (strlen($row['number_alias']) > 0) {
+										if (!empty($row['number_alias'])) {
 											$destination = $row['number_alias'];
 										}
 
@@ -390,7 +390,7 @@ class authentication {
 
 				//set the time zone
 					if (!isset($_SESSION["time_zone"]["user"])) { $_SESSION["time_zone"]["user"] = null; }
-					if (strlen($_SESSION["time_zone"]["user"]) == 0) {
+					if (strlen($_SESSION["time_zone"]["user"] ?? '') === 0) {
 						//set the domain time zone as the default time zone
 						date_default_timezone_set($_SESSION['domain']['time_zone']['name']);
 					}
@@ -415,7 +415,7 @@ class authentication {
 
 		//get the domain name from the username
 			if ($_SESSION["users"]["unique"]["text"] != "global") {
-				$username_array = explode("@", $_REQUEST["username"]);
+				$username_array = explode("@", $_REQUEST["username"] ?? '');
 				if (count($username_array) > 1) {
 					//get the domain name
 						$domain_name =  $username_array[count($username_array) -1];
@@ -444,7 +444,7 @@ class authentication {
 			}
 
 		//get the domain name from the http value
-			if (strlen($_REQUEST["domain_name"]) > 0) {
+			if (!empty($_REQUEST["domain_name"] ?? '')) {
 				$this->domain_name = $_REQUEST["domain_name"];
 			}
 

+ 3 - 2
core/authentication/resources/classes/plugins/database.php

@@ -18,6 +18,7 @@ class plugin_database {
 	public $username;
 	public $password;
 	public $key;
+	public $debug;
 
 	/**
 	 * database checks the local database to authenticate the user or key
@@ -136,7 +137,7 @@ class plugin_database {
 			$sql .= "u.user_email, u.salt, u.api_key, u.domain_uuid, d.domain_name ";
 			$sql .= "from v_users as u, v_domains as d ";
 			$sql .= "where u.domain_uuid = d.domain_uuid ";
-			if (strlen($this->key) > 30) {
+			if (strlen($this->key ?? '') > 30) {
 				$sql .= "and u.api_key = :api_key ";
 				$parameters['api_key'] = $this->key;
 			}
@@ -199,7 +200,7 @@ class plugin_database {
 						$valid_password = true;
 					}
 					else if (substr($row["password"], 0, 1) === '$') {
-						if (isset($this->password) && strlen($this->password) > 0) {
+						if (isset($this->password) && !empty($this->password)) {
 							if (password_verify($this->password, $row["password"])) {
 								$valid_password = true;
 							}

+ 3 - 2
core/authentication/resources/classes/plugins/email.php

@@ -17,6 +17,7 @@ class plugin_email {
 	public $user_uuid;
 	public $user_email;
 	public $contact_uuid;
+	public $debug;
 
 	/**
 	 * time based one time password with email
@@ -119,7 +120,7 @@ class plugin_email {
 				unset($parameters);
 
 				//set class variables
-				//if (strlen($row["user_email"]) > 0) {
+				//if (!empty($row["user_email"])) {
 				//	$this->user_uuid = $row['user_uuid'];
 				//	$this->user_email = $row['user_email'];
 				//	$this->contact_uuid = $row['contact_uuid'];
@@ -132,7 +133,7 @@ class plugin_email {
 				$_SESSION["contact_uuid"] = $row["contact_uuid"];
 
 				//user email not found
-				if (strlen($row["user_email"]) == 0) {
+				if (empty($row["user_email"])) {
 					//build the result array
 					$result["plugin"] = "email";
 					$result["domain_name"] = $_SESSION["domain_name"];

+ 2 - 2
core/authentication/resources/classes/plugins/ldap.php

@@ -116,7 +116,7 @@ class plugin_ldap {
 			$user_authorized = false;
 
 		//provide backwards compatability
-			if (strlen($_SESSION["ldap"]["user_dn"]["text"]) > 0) {
+			if (!empty($_SESSION["ldap"]["user_dn"]["text"])) {
 				$_SESSION["ldap"]["user_dn"][] = $_SESSION["ldap"]["user_dn"]["text"];
 			}
 
@@ -127,7 +127,7 @@ class plugin_ldap {
 				//Note: As of 4/16, the call below will fail randomly. PHP debug reports ldap_bind
 				//called below with all arguments '*uninitialized*'. However, the debugger
 				//single-stepping just before the failing call correctly displays all the values.
-				if (strlen($bind_pw) > 0) {
+				if (!empty($bind_pw)) {
 					$bind = ldap_bind($connect, $bind_dn, $bind_pw);
 					if ($bind) {
 						//connected and authorized

+ 11 - 11
core/dashboard/dashboard_edit.php

@@ -84,7 +84,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"])) {
 		//validate the token
 			$token = new token;
 			if (!$token->validate($_SERVER['PHP_SELF'])) {
@@ -94,7 +94,7 @@
 			}
 
 		//process the http post data by submitted action
-			if ($_POST['action'] != '' && strlen($_POST['action']) > 0) {
+			if ($_POST['action'] != '' && !empty($_POST['action'])) {
 
 				//prepare the array(s)
 				//send the array to the database class
@@ -128,13 +128,13 @@
 
 		//check for all required data
 			$msg = '';
-			//if (strlen($dashboard_name) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_name']."<br>\n"; }
-			//if (strlen($dashboard_path) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_path']."<br>\n"; }
-			//if (strlen($dashboard_groups) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_groups']."<br>\n"; }
-			//if (strlen($dashboard_order) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_order']."<br>\n"; }
-			//if (strlen($dashboard_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_enabled']."<br>\n"; }
-			//if (strlen($dashboard_description) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_description']."<br>\n"; }
-			if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			//if (empty($dashboard_name)) { $msg .= $text['message-required']." ".$text['label-dashboard_name']."<br>\n"; }
+			//if (empty($dashboard_path)) { $msg .= $text['message-required']." ".$text['label-dashboard_path']."<br>\n"; }
+			//if (empty($dashboard_groups)) { $msg .= $text['message-required']." ".$text['label-dashboard_groups']."<br>\n"; }
+			//if (empty($dashboard_order)) { $msg .= $text['message-required']." ".$text['label-dashboard_order']."<br>\n"; }
+			//if (empty($dashboard_enabled)) { $msg .= $text['message-required']." ".$text['label-dashboard_enabled']."<br>\n"; }
+			//if (empty($dashboard_description)) { $msg .= $text['message-required']." ".$text['label-dashboard_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";
@@ -283,7 +283,7 @@
 	if (is_array($dashboard_groups) && sizeof($dashboard_groups) != 0) {
 		$assigned_groups = array();
 		foreach ($dashboard_groups as $field) {
-			if (strlen($field['group_name']) > 0) {
+			if (!empty($field['group_name'])) {
 				if (is_uuid($field['group_uuid'])) {
 					$assigned_groups[] = $field['group_uuid'];
 				}
@@ -356,7 +356,7 @@
 	if (is_array($dashboard_groups) && sizeof($dashboard_groups) != 0) {
 		echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
 		foreach($dashboard_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'>\n";
 				echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);

+ 11 - 11
core/databases/database_edit.php

@@ -78,7 +78,7 @@
 		$database_description = $_POST["database_description"];
 	}
 
-if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+if (count($_POST)>0 && empty($_POST["persistformvar"])) {
 
 	$msg = '';
 	if ($action == "update") {
@@ -109,16 +109,16 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 		}
 
 	//check for all required data
-		//if (strlen($database_driver) == 0) { $msg .= $text['message-required'].$text['label-driver']."<br>\n"; }
-		//if (strlen($database_type) == 0) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
-		//if (strlen($database_host) == 0) { $msg .= $text['message-required'].$text['label-host']."<br>\n"; }
-		//if (strlen($database_port) == 0) { $msg .= $text['message-required'].$text['label-port']."<br>\n"; }
-		//if (strlen($database_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
-		//if (strlen($database_username) == 0) { $msg .= $text['message-required'].$text['label-username']."<br>\n"; }
-		//if (strlen($database_password) == 0) { $msg .= $text['message-required'].$text['label-password']."<br>\n"; }
-		//if (strlen($database_path) == 0) { $msg .= $text['message-required'].$text['label-path']."<br>\n"; }
-		//if (strlen($database_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
-		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+		//if (empty($database_driver)) { $msg .= $text['message-required'].$text['label-driver']."<br>\n"; }
+		//if (empty($database_type)) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
+		//if (empty($database_host)) { $msg .= $text['message-required'].$text['label-host']."<br>\n"; }
+		//if (empty($database_port)) { $msg .= $text['message-required'].$text['label-port']."<br>\n"; }
+		//if (empty($database_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
+		//if (empty($database_username)) { $msg .= $text['message-required'].$text['label-username']."<br>\n"; }
+		//if (empty($database_password)) { $msg .= $text['message-required'].$text['label-password']."<br>\n"; }
+		//if (empty($database_path)) { $msg .= $text['message-required'].$text['label-path']."<br>\n"; }
+		//if (empty($database_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";

+ 12 - 12
core/default_settings/default_setting_edit.php

@@ -81,7 +81,7 @@
 	}
 
 //process the http post
-	if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+	if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
 
 		//set the default_setting_uuid
 			if ($action == "update") {
@@ -101,14 +101,14 @@
 
 		//check for all required data
 			$msg = '';
-			if (strlen($default_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
-			if (strlen($default_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."<br>\n"; }
-			if (strlen($default_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
-			//if (strlen($default_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
-			if (strlen($default_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
-			if (strlen($default_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
-			//if (strlen($default_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
-			if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			if (empty($default_setting_category)) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
+			if (empty($default_setting_subcategory)) { $msg .= $text['message-required'].$text['label-subcategory']."<br>\n"; }
+			if (empty($default_setting_name)) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
+			//if (empty($default_setting_value)) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
+			if (empty($default_setting_order)) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
+			if (empty($default_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
+			//if (empty($default_setting_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";
@@ -223,7 +223,7 @@
 					return;
 				}
 			} //if ($_POST["persistformvar"] != "true")
-	} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+	} //(count($_POST)>0 && empty($_POST["persistformvar"]))
 
 //pre-populate the form
 	if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
@@ -247,7 +247,7 @@
 	}
 
 //set the defaults
-	if (strlen($default_setting_enabled) == 0) { $default_setting_enabled = 'true'; }
+	if (empty($default_setting_enabled)) { $default_setting_enabled = 'true'; }
 
 //create token
 	$object = new token;
@@ -473,7 +473,7 @@
 				}
 				echo "		<optgroup label='".$category."'>\n";
 			}
-			if (strlen($val) > 0) {
+			if (!empty($val)) {
 				$time_zone_offset = get_time_zone_offset($val)/3600;
 				$time_zone_offset_hours = floor($time_zone_offset);
 				$time_zone_offset_minutes = ($time_zone_offset - $time_zone_offset_hours) * 60;

+ 14 - 10
core/default_settings/default_settings.php

@@ -46,12 +46,16 @@
 	$text = $language->get();
 
 //get the http post data
-	$search = $_REQUEST['search'];
-	$default_setting_category = $_REQUEST['default_setting_category'];
+	$search = $_REQUEST['search'] ?? '';
+	$default_setting_category = $_REQUEST['default_setting_category'] ?? '';
 	if (is_array($_POST['default_settings'])) {
 		$action = $_POST['action'];
 		$domain_uuid = $_POST['domain_uuid'];
 		$default_settings = $_POST['default_settings'];
+	} else {
+		$action = '';
+		$domain_uuid = '';
+		$default_settings = '';
 	}
 
 //sanitize the variables
@@ -102,7 +106,7 @@
 
 //get the count
 	$sql = "select count(default_setting_uuid) from v_default_settings ";
-	if (isset($search) && strlen($search) > 0) {
+	if (isset($search) && !empty($search)) {
 		$sql .= "where (";
 		$sql .= "	lower(default_setting_category) like :search ";
 		$sql .= "	or lower(default_setting_subcategory) like :search ";
@@ -112,7 +116,7 @@
 		$sql .= ") ";
 		$parameters['search'] = '%'.$search.'%';
 	}
-	if (isset($default_setting_category) && strlen($default_setting_category) > 0) {
+	if (isset($default_setting_category) && !empty($default_setting_category)) {
 		$sql .= (stripos($sql,'WHERE') === false) ? 'where ' : 'and ';
 		$sql .= "lower(default_setting_category) = :default_setting_category ";
 		$parameters['default_setting_category'] = strtolower($default_setting_category);
@@ -124,7 +128,7 @@
 	$sql = "select default_setting_uuid, default_setting_category, default_setting_subcategory, default_setting_name, ";
 	$sql .= "default_setting_value, cast(default_setting_enabled as text), default_setting_description ";
 	$sql .= "from v_default_settings ";
-	if (isset($search) && strlen($search) > 0) {
+	if (isset($search) && !empty($search)) {
 		$sql .= "where (";
 		$sql .= "	lower(default_setting_category) like :search ";
 		$sql .= "	or lower(default_setting_subcategory) like :search ";
@@ -134,13 +138,13 @@
 		$sql .= ") ";
 		$parameters['search'] = '%'.$search.'%';
 	}
-	if (isset($default_setting_category) && strlen($default_setting_category) > 0) {
+	if (isset($default_setting_category) && !empty($default_setting_category)) {
 		$sql .= (stripos($sql,'WHERE') === false) ? 'where ' : 'and ';
 		$sql .= "lower(default_setting_category) = :default_setting_category ";
 		$parameters['default_setting_category'] = strtolower($default_setting_category);
 	}
 	$sql .= order_by($order_by, $order, 'default_setting_category, default_setting_subcategory, default_setting_order', 'asc');
-	$sql .= limit_offset($rows_per_page, $offset);
+	//$sql .= limit_offset($rows_per_page, $offset ?? '');  //$offset is always null
 	$database = new database;
 	$default_settings = $database->select($sql, $parameters, 'all');
 	unset($sql, $parameters);
@@ -153,7 +157,7 @@
 	$sql .= "	count(d2.default_setting_category) ";
 	$sql .= "	from v_default_settings as d2 ";
 	$sql .= "	where d2.default_setting_category = d1.default_setting_category ";
-	if (isset($search) && strlen($search) > 0) {
+	if (!empty($search)) {
 		$sql .= "	and (";
 		$sql .= "		lower(d2.default_setting_category) like :search ";
 		$sql .= "		or lower(d2.default_setting_subcategory) like :search ";
@@ -345,7 +349,7 @@
 				if ($row['default_setting_value'] !== $field['default_setting_value']) {
 					$setting_bold = 'font-weight:bold;';
 				}
-				if (strlen($field['default_setting_value']) > 0) {
+				if (!empty($field['default_setting_value'])) {
 					$default_value = 'Default: '.$field['default_setting_value'];
 				}
 				else {
@@ -465,7 +469,7 @@
 				echo "		[...]\n";
 			}
 			else if ($subcategory == 'password' || substr_count($subcategory, '_password') > 0 || $category == "login" && $subcategory == "password_reset_key" && $name == "text" || substr_count($subcategory, '_secret') > 0) {
-				echo "		".str_repeat('*', strlen($row['default_setting_value']));
+				echo "		".str_repeat('*', strlen($row['default_setting_value'] ?? ''));
 			}
 			else if ($category == 'theme' && $subcategory == 'button_icons' && $name == 'text') {
 				echo "		".$text['option-button_icons_'.$row['default_setting_value']]."\n";

+ 1 - 2
core/default_settings/default_settings_reload.php

@@ -46,13 +46,12 @@ $language = new text;
 $text = $language->get();
 
 //set the variables
-$search = $_REQUEST['search'];
+$search = $_REQUEST['search'] ?? '';
 $domain_uuid = $_GET['id'];
 
 //reload default settings
 require "resources/classes/domains.php";
 $domain = new domains();
-$domain->db = $db;
 $domain->set();
 
 //add a message

+ 13 - 13
core/domain_settings/domain_setting_edit.php

@@ -89,7 +89,7 @@
 		$domain_setting_description = $_POST["domain_setting_description"];
 	}
 
-if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
 
 	$msg = '';
 	if ($action == "update") {
@@ -105,14 +105,14 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 		}
 
 	//check for all required/authorized data
-		if (strlen($domain_setting_category) == 0 || (is_array($allowed_categories) && sizeof($allowed_categories) > 0 && !in_array(strtolower($domain_setting_category), $allowed_categories))) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
-		if (strlen($domain_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."<br>\n"; }
-		if (strlen($domain_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
-		//if (strlen($domain_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
-		if (strlen($domain_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
-		if (strlen($domain_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
-		//if (strlen($domain_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
-		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+		if (empty($domain_setting_category) || (is_array($allowed_categories) && sizeof($allowed_categories) > 0 && !in_array(strtolower($domain_setting_category), $allowed_categories))) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
+		if (empty($domain_setting_subcategory)) { $msg .= $text['message-required'].$text['label-subcategory']."<br>\n"; }
+		if (empty($domain_setting_name)) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
+		//if (empty($domain_setting_value)) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
+		if (empty($domain_setting_order)) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
+		if (empty($domain_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
+		//if (empty($domain_setting_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";
@@ -232,7 +232,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 				}
 
 			//update time zone
-				if ($domain_setting_category == "domain" && $domain_setting_subcategory == "time_zone" && $domain_setting_name == "name" && strlen($domain_setting_value) > 0 ) {
+				if ($domain_setting_category == "domain" && $domain_setting_subcategory == "time_zone" && $domain_setting_name == "name" && !empty($domain_setting_value) ) {
 					$sql = "select * from v_dialplans ";
 					$sql .= "where app_uuid = '34dd307b-fffe-4ead-990c-3d070e288126' ";
 					$sql .= "and domain_uuid = :domain_uuid ";
@@ -349,7 +349,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 	}
 
 //set the defaults
-	if (strlen($domain_setting_enabled) == 0) { $domain_setting_enabled = 'true'; }
+	if (empty($domain_setting_enabled)) { $domain_setting_enabled = 'true'; }
 
 //create token
 	$object = new token;
@@ -455,7 +455,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 	echo "</td>\n";
 	echo "<td class='vtable' align='left'>\n";
 	$category = $row['domain_setting_category'];
-	$subcategory = $row['domain_setting_subcategory'];
+	$subcategory = $row['domain_setting_subcategory'] ?? '';
 	$name = $row['domain_setting_name'];
 	if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) {
 		echo "		<select class='formfld' id='domain_setting_value' name='domain_setting_value' style=''>\n";
@@ -524,7 +524,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 				}
 				echo "		<optgroup label='".escape($category)."'>\n";
 			}
-			if (strlen($val) > 0) {
+			if (!empty($val)) {
 				$time_zone_offset = get_time_zone_offset($val)/3600;
 				$time_zone_offset_hours = floor($time_zone_offset);
 				$time_zone_offset_minutes = ($time_zone_offset - $time_zone_offset_hours) * 60;

+ 7 - 7
core/domains/domain_edit.php

@@ -70,7 +70,7 @@
 	}
 
 //process the data
-	if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+	if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
 
 		//get the domain_uuid
 			if ($action == "update" && $_POST["domain_uuid"]) {
@@ -102,9 +102,9 @@
 
 		//check for all required data
 			$msg = '';
-			if (strlen($domain_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
-			//if (strlen($domain_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
-			if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			if (empty($domain_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
+			//if (empty($domain_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";
@@ -165,14 +165,14 @@
 							}
 
 						//create the recordings directory for the new domain.
-							if (isset($_SESSION['switch']['recordings']['dir']) && strlen($_SESSION['switch']['recordings']['dir']) > 0) {
+							if (isset($_SESSION['switch']['recordings']['dir']) && !empty($_SESSION['switch']['recordings']['dir'])) {
 								if (!file_exists($_SESSION['switch']['recordings']['dir']."/".$domain_name)) {
 									mkdir($_SESSION['switch']['recordings']['dir']."/".$domain_name, 0770);
 								}
 							}
 
 						//create the voicemail directory for the new domain.
-							if (isset($_SESSION['switch']['voicemail']['dir']) && strlen($_SESSION['switch']['voicemail']['dir']) > 0) {
+							if (isset($_SESSION['switch']['voicemail']['dir']) && !empty($_SESSION['switch']['voicemail']['dir'])) {
 								if (!file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$domain_name)) {
 									mkdir($_SESSION['switch']['voicemail']['dir']."/default/".$domain_name, 0770);
 								}
@@ -571,7 +571,7 @@
 	}
 
 //set the defaults
-	if (strlen($domain_enabled) == 0) { $domain_enabled = 'true'; }
+	if (empty($domain_enabled)) { $domain_enabled = 'true'; }
 
 //create token
 	$object = new token;

+ 0 - 1
core/domains/domains.php

@@ -76,7 +76,6 @@
 
 			//set the setting arrays
 				$domain = new domains();
-				$domain->db = $db;
 				$domain->set();
 
 			//redirect the user

+ 1 - 1
core/groups/app_defaults.php

@@ -37,7 +37,7 @@ if ($domains_processed == 1) {
 		$result = $database->select($sql, null, 'all');
 		if (is_array($result)) {
 			foreach($result as $row) {
-				if (strlen($row['group_name']) > 0) {
+				if (!empty($row['group_name'])) {
 					//get the group_uuid
 						$sql = "select group_uuid from v_groups ";
 						$sql .= "where group_name = :group_name ";

+ 8 - 8
core/groups/group_edit.php

@@ -67,7 +67,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($group_uuid)) {
@@ -103,12 +103,12 @@
 
 		//check for all required data
 			$msg = '';
-			if (strlen($group_name) == 0) { $msg .= $text['message-required']." ".$text['label-group_name']."<br>\n"; }
-			//if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
-			if (strlen($group_level) == 0) { $msg .= $text['message-required']." ".$text['label-group_level']."<br>\n"; }
-			//if (strlen($group_protected) == 0) { $msg .= $text['message-required']." ".$text['label-group_protected']."<br>\n"; }
-			//if (strlen($group_description) == 0) { $msg .= $text['message-required']." ".$text['label-group_description']."<br>\n"; }
-			if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			if (empty($group_name)) { $msg .= $text['message-required']." ".$text['label-group_name']."<br>\n"; }
+			//if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
+			if (empty($group_level)) { $msg .= $text['message-required']." ".$text['label-group_level']."<br>\n"; }
+			//if (empty($group_protected)) { $msg .= $text['message-required']." ".$text['label-group_protected']."<br>\n"; }
+			//if (empty($group_description)) { $msg .= $text['message-required']." ".$text['label-group_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";
@@ -259,7 +259,7 @@
 	echo "</td>\n";
 	echo "<td class='vtable' style='position: relative;' align='left'>\n";
 	echo "	<select class='formfld' name='domain_uuid'>\n";
-	if (strlen($domain_uuid) == 0) {
+	if (empty($domain_uuid)) {
 		echo "		<option value='' selected='selected'>".$text['label-global']."</option>\n";
 	}
 	else {

+ 5 - 5
core/groups/group_permissions.php

@@ -71,7 +71,7 @@
 				$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
 				$sql .= "and permission_assigned = 'true' ";
 				foreach ($_SESSION["groups"] as $field) {
-					if (strlen($field['group_name']) > 0) {
+					if (!empty($field['group_name'])) {
 						$sql_where_or[] = "group_name = :group_name_".$x;
 						$parameters['group_name_'.$x] = $field['group_name'];
 						$x++;
@@ -139,7 +139,7 @@
 	$group_permissions = $database->select($sql, $parameters, 'all');
 
 //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"])) {
 			$x = 0;
 			if (is_array($_POST['group_permissions'])) {
 				foreach($_POST['group_permissions'] as $row) {
@@ -210,10 +210,10 @@
 					
 					//build the array;
 						if ($action == "save") {
-							if (strlen($group_permission_uuid) == 0) {
+							if (empty($group_permission_uuid)) {
 								$group_permission_uuid = uuid();
 							}
-							if (isset($row['permission_name']) && strlen($row['permission_name']) > 0) {
+							if (isset($row['permission_name']) && !empty($row['permission_name'])) {
 								$array['save']['group_permissions'][$x]['group_permission_uuid'] = $group_permission_uuid;
 								$array['save']['group_permissions'][$x]['permission_name'] = $row['permission_name'];
 								$array['save']['group_permissions'][$x]['permission_protected'] = $row['permission_protected'] == 'true' ? "true" : 'false';
@@ -225,7 +225,7 @@
 						}
 
 						if ($action == "delete") {
-							if (isset($row['permission_name']) && strlen($row['permission_name']) > 0) {
+							if (isset($row['permission_name']) && !empty($row['permission_name'])) {
 								$array['delete']['group_permissions'][$x]['permission_name'] = $row['permission_name'];
 								$array['delete']['group_permissions'][$x]['group_uuid'] = $group_uuid;
 								$array['delete']['group_permissions'][$x]['group_name'] = $group_name;

+ 1 - 1
core/groups/groupmemberadd.php

@@ -62,7 +62,7 @@
 	}
 
 //add the user to the group
-	if (is_uuid($user_uuid) && is_uuid($group_uuid) && strlen($group_name) > 0) {
+	if (is_uuid($user_uuid) && is_uuid($group_uuid) && !empty($group_name)) {
 		$array['user_groups'][0]['user_group_uuid'] = uuid();
 		$array['user_groups'][0]['domain_uuid'] = $domain_uuid;
 		$array['user_groups'][0]['group_uuid'] = $group_uuid;

+ 5 - 5
core/menu/menu_edit.php

@@ -63,7 +63,7 @@
 	}
 
 //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;
@@ -75,10 +75,10 @@
 
 		//check for all required data
 			$msg = '';
-			//if (strlen($menu_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
-			//if (strlen($menu_language) == 0) { $msg .= $text['message-required'].$text['label-language']."<br>\n"; }
-			//if (strlen($menu_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
-			if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			//if (empty($menu_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
+			//if (empty($menu_language)) { $msg .= $text['message-required'].$text['label-language']."<br>\n"; }
+			//if (empty($menu_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";

+ 9 - 9
core/menu/menu_item_edit.php

@@ -94,7 +94,7 @@
 	$menu_item_link = preg_replace('#[^a-zA-Z0-9_:\-\.\&\=\?\/]#', '', $menu_item_link);
 
 //when a HTTP POST is available then process it
-	if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+	if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
 
 		if ($action == "update") {
 			$menu_item_uuid = $_POST["menu_item_uuid"];
@@ -110,10 +110,10 @@
 
 		//check for all required data
 			$msg = '';
-			if (strlen($menu_item_title) == 0) { $msg .= $text['message-required'].$text['label-title']."<br>\n"; }
-			if (strlen($menu_item_category) == 0) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
-			//if (strlen($menu_item_link) == 0) { $msg .= $text['message-required'].$text['label-link']."<br>\n"; }
-			if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			if (empty($menu_item_title)) { $msg .= $text['message-required'].$text['label-title']."<br>\n"; }
+			if (empty($menu_item_category)) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
+			//if (empty($menu_item_link)) { $msg .= $text['message-required'].$text['label-link']."<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";
@@ -213,7 +213,7 @@
 				unset($parameters);
 
 			//add a group to the menu
-				if ($_REQUEST["a"] != "delete" && strlen($group_uuid_name) > 0 && permission_exists('menu_add')) {
+				if ($_REQUEST["a"] != "delete" && !empty($group_uuid_name) && permission_exists('menu_add')) {
 					$group_data = explode('|', $group_uuid_name);
 					$group_uuid = $group_data[0];
 					$group_name = $group_data[1];
@@ -234,7 +234,7 @@
 				}
 
 			//add the menu item label
-				if ($_REQUEST["a"] != "delete" && strlen($menu_item_title) > 0 && permission_exists('menu_add')) {
+				if ($_REQUEST["a"] != "delete" && !empty($menu_item_title) && permission_exists('menu_add')) {
 					$sql = "select count(*) from v_menu_languages ";
 					$sql .= "where menu_item_uuid = :menu_item_uuid ";
 					$sql .= "and menu_language = :menu_language ";
@@ -351,7 +351,7 @@
 	if (is_array($menu_item_groups) && sizeof($menu_item_groups) != 0) {
 		$assigned_groups = array();
 		foreach ($menu_item_groups as $field) {
-			if (strlen($field['group_name']) > 0) {
+			if (!empty($field['group_name'])) {
 				if (is_uuid($field['group_uuid'])) {
 					$assigned_groups[] = $field['group_uuid'];
 				}
@@ -480,7 +480,7 @@
 	if (is_array($menu_item_groups) && sizeof($menu_item_groups) != 0) {
 		echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
 		foreach($menu_item_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);

+ 1 - 1
core/user_logs/resources/classes/user_logs.php

@@ -88,7 +88,7 @@ if (!class_exists('user_logs')) {
 				$database = new database;
 				$database->app_name = 'authentication';
 				$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
-				if (strlen($user_log_uuid)>0)
+				if (strlen($user_log_uuid ?? '')>0)
 					$database->uuid($user_log_uuid);
 				$database->save($array, false);
 				$message = $database->message;

+ 1 - 1
core/user_logs/user_log_edit.php

@@ -86,7 +86,7 @@
 	echo "</td>\n";
 	echo "<td class='vtable' style='position: relative;' align='left'>\n";
 	echo "	<select class='formfld' name='domain_uuid'>\n";
-	if (strlen($domain_uuid) == 0) {
+	if (empty($domain_uuid)) {
 		echo "		<option value='' selected='selected'>".$text['select-global']."</option>\n";
 	}
 	else {

+ 16 - 16
core/user_settings/user_setting_edit.php

@@ -79,17 +79,17 @@
 	}
 
 //get http post variables and set them to php variables
-	if (count($_REQUEST) > 0) {
-		$user_setting_category = strtolower($_REQUEST["user_setting_category"]);
-		$user_setting_subcategory = strtolower($_POST["user_setting_subcategory"]);
+	if (!empty($_REQUEST)) {
+		$user_setting_category = strtolower($_REQUEST["user_setting_category"] ?? '');
+		$user_setting_subcategory = strtolower($_POST["user_setting_subcategory"] ?? '');
 		$user_setting_name = strtolower($_POST["user_setting_name"]);
 		$user_setting_value = $_POST["user_setting_value"];
 		$user_setting_order = $_POST["user_setting_order"];
-		$user_setting_enabled = strtolower($_POST["user_setting_enabled"]);
+		$user_setting_enabled = strtolower($_POST["user_setting_enabled"] ?? '');
 		$user_setting_description = $_POST["user_setting_description"];
 	}
 
-if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+if (!empty($_POST) && empty($_POST["persistformvar"])) {
 
 	$msg = '';
 	if ($action == "update") {
@@ -105,14 +105,14 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 		}
 
 	//check for all required/authorized data
-		if (strlen($user_setting_category) == 0 || (is_array($allowed_categories) && sizeof($allowed_categories) > 0 && !in_array(strtolower($user_setting_category), $allowed_categories))) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
-		if (strlen($user_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."<br>\n"; }
-		if (strlen($user_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
-		//if (strlen($user_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
-		if (strlen($user_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
-		if (strlen($user_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
-		//if (strlen($user_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
-		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+		if (empty($user_setting_category) || (is_array($allowed_categories) && sizeof($allowed_categories) > 0 && !in_array(strtolower($user_setting_category), $allowed_categories))) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
+		if (empty($user_setting_subcategory)) { $msg .= $text['message-required'].$text['label-subcategory']."<br>\n"; }
+		if (empty($user_setting_name)) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
+		//if (empty($user_setting_value)) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
+		if (empty($user_setting_order)) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
+		if (empty($user_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
+		//if (empty($user_setting_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";
@@ -220,7 +220,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 				}
 
 			//update time zone
-				if ($user_setting_category == "domain" && $user_setting_subcategory == "time_zone" && $user_setting_name == "name" && strlen($user_setting_value) > 0 ) {
+				if ($user_setting_category == "domain" && $user_setting_subcategory == "time_zone" && $user_setting_name == "name" && !empty($user_setting_value) ) {
 					$sql = "select * from v_dialplans ";
 					$sql .= "where app_uuid = '34dd307b-fffe-4ead-990c-3d070e288126' ";
 					$sql .= "and domain_uuid = :domain_uuid ";
@@ -270,7 +270,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 									$array['dialplan_details'][0]['dialplan_detail_tag'] = 'action';
 									$array['dialplan_details'][0]['dialplan_detail_type'] = 'set';
 									$array['dialplan_details'][0]['dialplan_detail_data'] = 'timezone='.$user_setting_value;
-									$array['dialplan_details'][0]['dialplan_detail_group'] = strlen($dialplan_detail_group) > 0 ? $dialplan_detail_group : 'null';
+									$array['dialplan_details'][0]['dialplan_detail_group'] = !empty($dialplan_detail_group) ? $dialplan_detail_group : 'null';
 									$array['dialplan_details'][0]['dialplan_detail_order'] = '15';
 
 									$p = new permissions;
@@ -513,7 +513,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
 				}
 				echo "		<optgroup label='".$category."'>\n";
 			}
-			if (strlen($val) > 0) {
+			if (!empty($val)) {
 				$time_zone_offset = get_time_zone_offset($val)/3600;
 				$time_zone_offset_hours = floor($time_zone_offset);
 				$time_zone_offset_minutes = ($time_zone_offset - $time_zone_offset_hours) * 60;

+ 4 - 1
core/user_settings/user_settings.php

@@ -126,10 +126,13 @@
 	$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);
 		$offset = $rows_per_page * $page;
 	}
+	else {
+		$offset = 0;
+	}
 
 //get the list
 	$sql = "select user_setting_uuid, user_uuid, user_setting_category, user_setting_subcategory, user_setting_name, user_setting_value, cast(user_setting_enabled as text), user_setting_description ";

+ 1 - 1
core/users/app_defaults.php

@@ -91,7 +91,7 @@ if ($domains_processed == 1) {
 		$result = $database->select($sql, null, 'all');
 		if (is_array($result)) {
 			foreach($result as $row) {
-				if (strlen($row['group_name']) > 0) {
+				if (!empty($row['group_name'])) {
 					//get the group_uuid
 						$sql = "select group_uuid from v_groups ";
 						$sql .= "where group_name = :group_name ";

+ 8 - 8
core/users/user_edit.php

@@ -199,7 +199,7 @@
 				$invalid[] = $text['label-email'];
 			}
 
-			if (strlen($password) > 0) {
+			if (!empty($password)) {
 				if (is_numeric($required['length']) && $required['length'] != 0) {
 					if (strlen($password) < $required['length']) {
 						$invalid[] = $text['label-characters'];
@@ -634,7 +634,7 @@
 						$name = $row['user_setting_name'];
 						$category = $row['user_setting_category'];
 						$subcategory = $row['user_setting_subcategory'];
-						if (strlen($subcategory) == 0) {
+						if (empty($subcategory)) {
 							//$$category[$name] = $row['domain_setting_value'];
 							$user_settings[$category][$name] = $row['user_setting_value'];
 						}
@@ -648,7 +648,7 @@
 	}
 
 //set the defaults
-	if (strlen($user_enabled) == 0) { $user_enabled = "true"; }
+	if (empty($user_enabled)) { $user_enabled = "true"; }
 
 //create token
 	$object = new token;
@@ -914,7 +914,7 @@
 		echo "</select>\n";
 		echo "<br />\n";
 		echo $text['description-contact']."\n";
-		if (strlen($contact_uuid) > 0) {
+		if (!empty($contact_uuid)) {
 			echo "			<a href=\"".PROJECT_PATH."/app/contacts/contact_edit.php?id=".urlencode($contact_uuid)."\">".$text['description-contact_view']."</a>\n";
 		}
 		echo "		</td>";
@@ -963,7 +963,7 @@
 		if (is_array($user_groups)) {
 			echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
 			foreach($user_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 escape($field['group_name']).(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);
@@ -1040,7 +1040,7 @@
 		echo "		<td class='vncell' valign='top'>".$text['label-api_key']."</td>";
 		echo "		<td class='vtable'>\n";
 		echo "			<input type='text' class='formfld' style='width: 250px; display: none;' name='api_key' id='api_key' value=\"".escape($api_key)."\" >";
-		if (strlen($api_key) == 0) {
+		if (empty($api_key)) {
 			//generate api key
 			echo button::create(['type'=>'button',
 				'label'=>$text['button-generate'],
@@ -1069,7 +1069,7 @@
 					document.getElementById('button-api_key_view').style.display = 'inline';"]);
 
 		}
-		if (strlen($text['description-api_key']) > 0) {
+		if (!empty($text['description-api_key'])) {
 			echo "			<br />".$text['description-api_key']."<br />\n";
 		}
 		echo "		</td>";
@@ -1146,7 +1146,7 @@
 				'onclick'=>"document.getElementById('user_totp_secret').value = '';
 				document.getElementById('frm').submit();"]);
 		}
-		if (strlen($user_totp_secret) == 0) {
+		if (empty($user_totp_secret)) {
 			echo "	<br />".$text['description-user_totp_secret']."<br />\n";
 		}
 		else {

+ 5 - 5
core/users/user_imports.php

@@ -83,7 +83,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);
@@ -137,7 +137,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') {
 
 		//create token
 			$object = new token;
@@ -233,7 +233,7 @@
 	}
 
 //upload the csv
-	if (file_exists($_SESSION['file']) && $action == 'import') {
+	if (file_exists($_SESSION['file'] ?? '') && $action == 'import') {
 
 		//validate the token
 			$token = new token;
@@ -297,8 +297,8 @@
 									//}
 
 									//build the data array
-									if (strlen($table_name) > 0) {
-										if (strlen($parent) == 0) {
+									if (!empty($table_name)) {
+										if (empty($parent)) {
 											$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
 											$array[$table_name][$row_id][$field_name] = $result[$key];
 										}

+ 1 - 1
resources/captcha/config.php

@@ -64,7 +64,7 @@ $pathtofonts = "/captcha/fonts/"; //path from the root of the website
 
         //--- begin captcha verification ---------------------
           //ini_set("session.cookie_httponly", True); session_start(); //make sure sessions are started
-          if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || strlen($_SESSION["captcha"]) == 0) {
+          if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || empty($_SESSION["captcha"])) {
 
               echo "       <span class=\"h2\">Sorry!</span>\n";
               //echo "              <br><br>\n";

+ 1 - 1
resources/check_auth.php

@@ -49,7 +49,7 @@
 			unset($_SESSION["menu"]);
 
 		//clear the template only if the template has not been assigned by the superadmin
-			if (strlen($_SESSION['domain']['template']['name']) == 0) {
+			if (empty($_SESSION['domain']['template']['name'])) {
 				$_SESSION["template_content"] = '';
 			}
 

+ 1 - 1
resources/classes/config.php

@@ -89,7 +89,7 @@ class config {
 	 */
 	public function exists() {
 		$this->find();
-		if (strlen($this->config_path) > 0) {
+		if (!empty($this->config_path)) {
 			return true;
 		}
 		else {

+ 26 - 26
resources/classes/database.php

@@ -434,7 +434,7 @@
 					if (!isset($this->path) && isset($db_path)) { $this->path = $db_path; }
 
 				if ($this->driver == "sqlite") {
-					if (strlen($this->db_name) == 0) {
+					if (empty($this->db_name)) {
 						$server_name = $_SERVER["SERVER_NAME"];
 						$server_name = str_replace ("www.", "", $server_name);
 						$db_name_short = $server_name;
@@ -467,12 +467,12 @@
 				if ($this->driver == "mysql") {
 					try {
 						//mysql pdo connection
-							if (strlen($this->host) == 0 && strlen($this->port) == 0) {
+							if (strlen($this->host) == 0 && empty($this->port)) {
 								//if both host and port are empty use the unix socket
 								$this->db = new PDO("mysql:host=$this->host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$this->db_name", $this->username, $this->password);
 							}
 							else {
-								if (strlen($this->port) == 0) {
+								if (empty($this->port)) {
 									//leave out port if it is empty
 									$this->db = new PDO("mysql:host=$this->host;dbname=$this->db_name;", $this->username, $this->password, array(
 									PDO::ATTR_ERRMODE,
@@ -496,8 +496,8 @@
 				if ($this->driver == "pgsql") {
 					//database connection
 					try {
-						if (strlen($this->host) > 0) {
-							if (strlen($this->port) == 0) { $this->port = "5432"; }
+						if (!empty($this->host)) {
+							if (empty($this->port)) { $this->port = "5432"; }
 							if ($this->db_secure === true) {
 								$this->db = new PDO("pgsql:host=$this->host port=$this->port dbname=$this->db_name user=$this->username password=$this->password sslmode=verify-ca sslrootcert=$this->db_cert_authority");
 							}
@@ -593,7 +593,7 @@
 					}
 
 				//get the table info
-					if (strlen($this->table) == 0) { return false; }
+					if (empty($this->table)) { return false; }
 					if ($this->type == "sqlite") {
 						$sql = "PRAGMA table_info(".$this->table.");";
 					}
@@ -927,7 +927,7 @@
 						foreach($this->fields as $name => $value) {
 							$name = self::sanitize($name);
 							if ($field_count == $i) {
-								if (strlen($value) > 0) {
+								if (!empty($value)) {
 									//$sql .= "'".$value."' ";
 									$sql .= ":".$name." \n";
 									$params[$name] = trim($value);
@@ -937,7 +937,7 @@
 								}
 							}
 							else {
-								if (strlen($value) > 0) {
+								if (!empty($value)) {
 									//$sql .= "'".$value."', ";
 									$sql .= ":".$name.", \n";
 									$params[$name] = trim($value);
@@ -995,7 +995,7 @@
 						foreach($this->fields as $name => $value) {
 							$name = self::sanitize($name);
 							if (count($this->fields) == $i) {
-								if (strlen($name) > 0 && $value == null) {
+								if (!empty($name) && $value == null) {
 									$sql .= $name." = null ";
 								}
 								else {
@@ -1005,7 +1005,7 @@
 								}
 							}
 							else {
-								if (strlen($name) > 0 && $value == null) {
+								if (!empty($name) && $value == null) {
 									$sql .= $name." = null, ";
 								}
 								else {
@@ -1188,7 +1188,7 @@
 									}
 								}
 							}
-							if (strlen($field_value) > 0) {
+							if (!empty($field_value)) {
 								$results = $this->execute($sql, $parameters, 'all');
 								unset($parameters);
 								if (is_array($results)) {
@@ -1230,7 +1230,7 @@
 											}
 
 											//delete the child data
-											if (isset($row[$relation['field']]) && strlen($row[$relation['field']]) > 0) {
+											if (isset($row[$relation['field']]) && !empty($row[$relation['field']])) {
 												$sql = "delete from ".self::TABLE_PREFIX.$child_table." ";
 												$sql .= "where ".$relation['field']." = :".$relation['field'];
 												$parameters[$relation['field']] = $row[$relation['field']];
@@ -1320,7 +1320,7 @@
 						if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
 							$sql .= "app_uuid, ";
 						}
-						if (isset($this->app_name) && strlen($this->app_name) > 0) {
+						if (isset($this->app_name) && !empty($this->app_name)) {
 							$sql .= "app_name, ";
 						}
 						$sql .= "transaction_code, ";
@@ -1343,7 +1343,7 @@
 						if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
 							$sql .= ":app_uuid, ";
 						}
-						if (isset($this->app_name) && strlen($this->app_name) > 0) {
+						if (isset($this->app_name) && !empty($this->app_name)) {
 							$sql .= ":app_name, ";
 						}
 						$sql .= "'".$message["code"]."', ";
@@ -1371,7 +1371,7 @@
 						if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
 							$statement->bindParam(':app_uuid', $this->app_uuid);
 						}
-						if (isset($this->app_name) && strlen($this->app_name) > 0) {
+						if (isset($this->app_name) && !empty($this->app_name)) {
 							$statement->bindParam(':app_name', $this->app_name);
 						}
 						$statement->bindParam(':remote_address', $_SERVER['REMOTE_ADDR']);
@@ -2126,7 +2126,7 @@
 															$array_key != 'insert_date' &&
 															$array_key != 'update_user' && 
 															$array_key != 'update_date') {
-															if (strlen($array_value) == 0) {
+															if (empty($array_value)) {
 																$sql .= "null, ";
 															}
 															elseif ($array_value === "now()") {
@@ -2228,7 +2228,7 @@
 												foreach ($array as $array_key => $array_value) {
 													if (!is_array($array_value) && $array_key != $parent_key_name) {
 														$array_key = self::sanitize($array_key);
-														if (strlen($array_value) == 0) {
+														if (empty($array_value)) {
 															$sql .= $array_key." = null, ";
 														}
 														elseif ($array_value === "now()") {
@@ -2346,7 +2346,7 @@
 														$uuid_exists = false;
 														if (is_array($row)) foreach ($row as $k => $v) {
 															if ($child_key_name == $k) {
-																if (strlen($v) > 0) {
+																if (!empty($v)) {
 																	$child_key_value = trim($v);
 																	$uuid_exists = true;
 																	break;
@@ -2418,7 +2418,7 @@
 																	foreach ($row as $k => $v) {
 																		if (!is_array($v) && ($k != $parent_key_name || $k != $child_key_name)) {
 																			$k = self::sanitize($k);
-																			if (strlen($v) == 0) {
+																			if (empty($v)) {
 																				$sql .= $k." = null, ";
 																			}
 																			elseif ($v === "now()") {
@@ -2501,7 +2501,7 @@
 															else {
 																$retval = false;
 																$message["name"] = $child_name;
-																$message["message"] = "Forbidden, does not have '${child_name}_edit'";
+																$message["message"] = "Forbidden, does not have '{$child_name}_edit'";
 																$message["code"] = "403";
 																$message["line"] = __line__;
 																$this->message = $message;
@@ -2570,7 +2570,7 @@
 																			$k != 'insert_date' &&
 																			$k != 'update_user' && 
 																			$k != 'update_date') {
-																			if (strlen($v) == 0) {
+																			if (empty($v)) {
 																				$sql .= "null, ";
 																			}
 																			elseif ($v === "now()") {
@@ -2655,7 +2655,7 @@
 														else {
 															$retval = false;
 															$message["name"] = $child_name;
-															$message["message"] = "Forbidden, does not have '${child_name}_add'";
+															$message["message"] = "Forbidden, does not have '{$child_name}_add'";
 															$message["code"] = "403";
 															$message["line"] = __line__;
 															$this->message = $message;
@@ -2680,7 +2680,7 @@
 					$this->db->commit();
 
 				//set the action if not set
-					if (strlen($action) == 0) {
+					if (strlen($action ?? '') === 0) {
 						if (is_array($old_array)) {
 							$transaction_type = 'update';
 						}
@@ -2708,7 +2708,7 @@
 							if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
 								$sql .= "app_uuid, ";
 							}
-							if (isset($this->app_name) && strlen($this->app_name) > 0) {
+							if (isset($this->app_name) && !empty($this->app_name)) {
 								$sql .= "app_name, ";
 							}
 							$sql .= "transaction_code, ";
@@ -2734,7 +2734,7 @@
 							if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
 								$sql .= ":app_uuid, ";
 							}
-							if (isset($this->app_name) && strlen($this->app_name) > 0) {
+							if (isset($this->app_name) && !empty($this->app_name)) {
 								$sql .= ":app_name, ";
 							}
 							$sql .= "'".$message["code"]."', ";
@@ -2762,7 +2762,7 @@
 							if (isset($this->app_uuid) && is_uuid($this->app_uuid)) {
 								$statement->bindParam(':app_uuid', $this->app_uuid);
 							}
-							if (isset($this->app_name) && strlen($this->app_name) > 0) {
+							if (isset($this->app_name) && !empty($this->app_name)) {
 								$statement->bindParam(':app_name', $this->app_name);
 							}
 							$statement->bindParam(':remote_address', $_SERVER['REMOTE_ADDR']);

+ 14 - 14
resources/classes/domains.php

@@ -169,7 +169,7 @@ if (!class_exists('domains')) {
 											}
 
 										//delete the directories
-											if (strlen($domain_name) > 0) {
+											if (!empty($domain_name)) {
 												//set the needle
 												if (count($_SESSION["domains"]) > 1) {
 													$v_needle = 'v_'.$domain_name.'_';
@@ -180,24 +180,24 @@ if (!class_exists('domains')) {
 
 												//delete the dialplan
 												@unlink($_SESSION['switch']['dialplan']['dir'].'/'.$domain_name.'.xml');
-												if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) {
+												if (!empty($_SESSION['switch']['dialplan']['dir'])) {
 													system('rm -rf '.$_SESSION['switch']['dialplan']['dir'].'/'.$domain_name);
 												}
 
 												//delete the dialplan public
 												@unlink($_SESSION['switch']['dialplan']['dir'].'/public/'.$domain_name.'.xml');
-												if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) {
+												if (!empty($_SESSION['switch']['dialplan']['dir'])) {
 													system('rm -rf '.$_SESSION['switch']['dialplan']['dir'].'/public/'.$domain_name);
 												}
 
 												//delete the extension
 												@unlink($_SESSION['switch']['extensions']['dir'].'/'.$domain_name.'.xml');
-												if (strlen($_SESSION['switch']['extensions']['dir']) > 0) {
+												if (!empty($_SESSION['switch']['extensions']['dir'])) {
 													system('rm -rf '.$_SESSION['switch']['extensions']['dir'].'/'.$domain_name);
 												}
 
 												//delete fax
-												if (strlen($_SESSION['switch']['storage']['dir']) > 0) {
+												if (!empty($_SESSION['switch']['storage']['dir'])) {
 													system('rm -rf '.$_SESSION['switch']['storage']['dir'].'/fax/'.$domain_name);
 												}
 
@@ -237,12 +237,12 @@ if (!class_exists('domains')) {
 												}
 
 												//delete the recordings
-												if (strlen($_SESSION['switch']['recordings']['dir']) > 0) {
+												if (!empty($_SESSION['switch']['recordings']['dir'])) {
 													system('rm -rf '.$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$domain_name);
 												}
 
 												//delete voicemail
-												if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) {
+												if (!empty($_SESSION['switch']['voicemail']['dir'])) {
 													system('rm -rf '.$_SESSION['switch']['voicemail']['dir'].'/'.$domain_name);
 												}
 											}
@@ -460,7 +460,7 @@ if (!class_exists('domains')) {
 						$name = $row['default_setting_name'];
 						$category = $row['default_setting_category'];
 						$subcategory = $row['default_setting_subcategory'];
-						if (strlen($subcategory) == 0) {
+						if (empty($subcategory)) {
 							if ($name == "array") {
 								$_SESSION[$category][] = $row['default_setting_value'];
 							}
@@ -512,7 +512,7 @@ if (!class_exists('domains')) {
 						$name = $row['domain_setting_name'];
 						$category = $row['domain_setting_category'];
 						$subcategory = $row['domain_setting_subcategory'];
-						if (strlen($subcategory) == 0) {
+						if (empty($subcategory)) {
 							//$$category[$name] = $row['domain_setting_value'];
 							if ($name == "array") {
 								$_SESSION[$category][] = $row['domain_setting_value'];
@@ -549,8 +549,8 @@ if (!class_exists('domains')) {
 								$name = $row['user_setting_name'];
 								$category = $row['user_setting_category'];
 								$subcategory = $row['user_setting_subcategory'];
-								if (strlen($row['user_setting_value']) > 0) {
-									if (strlen($subcategory) == 0) {
+								if (!empty($row['user_setting_value'])) {
+									if (empty($subcategory)) {
 										//$$category[$name] = $row['domain_setting_value'];
 										if ($name == "array") {
 											$_SESSION[$category][] = $row['user_setting_value'];
@@ -575,7 +575,7 @@ if (!class_exists('domains')) {
 				}
 
 			//set the values from the session variables
-				if (strlen($_SESSION['domain']['time_zone']['name']) > 0) {
+				if (!empty($_SESSION['domain']['time_zone']['name'])) {
 					//server time zone
 					$_SESSION['time_zone']['system'] = date_default_timezone_get();
 					//domain time zone set in system settings
@@ -674,7 +674,7 @@ if (!class_exists('domains')) {
 							$name = $row['default_setting_name'];
 							$category = $row['default_setting_category'];
 							$subcategory = $row['default_setting_subcategory'];
-							if (strlen($subcategory) == 0) {
+							if (empty($subcategory)) {
 								if ($name == "array") {
 									$_SESSION[$category][] = $row['default_setting_value'];
 								}
@@ -699,7 +699,7 @@ if (!class_exists('domains')) {
 								$name = $row['domain_setting_name'];
 								$category = $row['domain_setting_category'];
 								$subcategory = $row['domain_setting_subcategory'];
-								if (strlen($subcategory) == 0) {
+								if (empty($subcategory)) {
 									//$$category[$name] = $row['domain_setting_value'];
 									$_SESSION[$category][$name] = $row['domain_setting_value'];
 								}

+ 4 - 4
resources/classes/email.php

@@ -162,7 +162,7 @@ if (!class_exists('email')) {
 					$body_part = $parts_array["BodyPart"];
 					$body_length = $parts_array["BodyLength"];
 
-					if (strlen($file) > 0) {
+					if (!empty($file)) {
 						//get the file information
 							$file_ext = pathinfo($file, PATHINFO_EXTENSION);
 							$file_name = substr($file, 0, (strlen($file) - strlen($file_ext))-1 );
@@ -417,10 +417,10 @@ if (!class_exists('email')) {
 					$smtp['validate_certificate'] = $_SESSION['email']['smtp_validate_certificate']['boolean'];
 					$smtp['crypto_method'] = $_SESSION['email']['smtp_crypto_method']['text'];
 
-					if (isset($_SESSION['voicemail']['smtp_from']) && strlen($_SESSION['voicemail']['smtp_from']['text']) > 0) {
+					if (isset($_SESSION['voicemail']['smtp_from']) && !empty($_SESSION['voicemail']['smtp_from']['text'])) {
 						$smtp['from'] = $_SESSION['voicemail']['smtp_from']['text'];
 					}
-					if (isset($_SESSION['voicemail']['smtp_from_name']) && strlen($_SESSION['voicemail']['smtp_from_name']['text']) > 0) {
+					if (isset($_SESSION['voicemail']['smtp_from_name']) && !empty($_SESSION['voicemail']['smtp_from_name']['text'])) {
 						$smtp['from_name'] = $_SESSION['voicemail']['smtp_from_name']['text'];
 					}
 
@@ -580,7 +580,7 @@ if (!class_exists('email')) {
 
 					//send the email
 					if (!$mail_status) {
-						if (isset($mail->ErrorInfo) && strlen($mail->ErrorInfo) > 0) {
+						if (isset($mail->ErrorInfo) && !empty($mail->ErrorInfo)) {
 							$this->error = $mail->ErrorInfo;
 						}
 						return false;

+ 7 - 7
resources/classes/menu.php

@@ -395,7 +395,7 @@ if (!class_exists('menu')) {
 						if (is_array($row['menu'])) {
 							foreach ($row['menu'] as $menu) {
 								//set the variables
-									if (strlen($menu['title'][$this->menu_language]) > 0) {
+									if (!empty($menu['title'][$this->menu_language])) {
 										$menu_item_title = $menu['title'][$this->menu_language];
 									}
 									else {
@@ -449,7 +449,7 @@ if (!class_exists('menu')) {
 												$array['menu_items'][$x]['menu_item_link'] = $menu_item_path;
 												$array['menu_items'][$x]['menu_item_category'] = $menu_item_category;
 												$array['menu_items'][$x]['menu_item_icon'] = $menu_item_icon;
-												if (strlen($menu_item_order) > 0) {
+												if (!empty($menu_item_order)) {
 													$array['menu_items'][$x]['menu_item_order'] = $menu_item_order;
 												}
 												if (is_uuid($menu_item_parent_uuid)) {
@@ -466,7 +466,7 @@ if (!class_exists('menu')) {
 										foreach ($language->languages as $menu_language) {
 											//set the menu item title
 												$menu_item_title = $menu["title"][$menu_language];
-												if (strlen($menu_item_title) == 0) {
+												if (empty($menu_item_title)) {
 													$menu_item_title = $menu["title"]['en-us'];
 												}
 
@@ -613,7 +613,7 @@ if (!class_exists('menu')) {
 						if (!isset($_SESSION["username"])) {
 							$_SESSION["username"] = '';
 						}
-						if (strlen($_SESSION["username"]) == 0) {
+						if (empty($_SESSION["username"])) {
 							$menu_html .= "<a $menu_tags style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''>".$menu_item_title."</h2></a>\n";
 						}
 						else {
@@ -621,7 +621,7 @@ if (!class_exists('menu')) {
 								//hide login and sign-up when the user is logged in
 							}
 							else {
-								if (strlen($submenu_item_link) == 0) {
+								if (empty($submenu_item_link)) {
 									$menu_html .= "<h2 align='center' style=''>".$menu_item_title."</h2>\n";
 								}
 								else {
@@ -767,7 +767,7 @@ if (!class_exists('menu')) {
 
 						//add the sub menus to the array
 							$menu_item_level = 0;
-							if (strlen($row['menu_item_uuid']) > 0) {
+							if (!empty($row['menu_item_uuid'])) {
 								$a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $row['menu_item_uuid']);
 							}
 
@@ -851,7 +851,7 @@ if (!class_exists('menu')) {
 							}
 
 						//get sub menu for children
-							if (strlen($menu_item_uuid) > 0) {
+							if (!empty($menu_item_uuid)) {
 								$a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $menu_item_uuid);
 							}
 

+ 3 - 3
resources/classes/message.php

@@ -50,9 +50,9 @@ if (!class_exists('message')) {
 		}
 
 		static function html($clear_messages = true, $spacer = "") {
-			$html = "${spacer}//render the messages\n";
+			$html = "{$spacer}//render the messages\n";
 			$spacer .="\t";
-			if (is_string($_SESSION['message']) && strlen(trim($_SESSION['message'])) > 0) {
+			if (is_string($_SESSION['message']) && !empty(trim($_SESSION['message']))) {
 				self::add($_SESSION['message'], $_SESSION['message_mood'], $_SESSION['message_delay']);
 				unset($_SESSION['message'], $_SESSION['message_mood'], $_SESSION['message_delay']);
 			}
@@ -60,7 +60,7 @@ if (!class_exists('message')) {
 				foreach ($_SESSION['messages'] as $message_mood => $message) {
 					$message_text = str_replace(array("\r\n", "\n", "\r"),'\\n',addslashes(join('<br/>', $message['message'])));
 					$message_delay = array_sum($message['delay'])/count($message['delay']);
-					$html .= "${spacer}display_message('$message_text', '$message_mood', '$message_delay');\n";
+					$html .= "{$spacer}display_message('$message_text', '$message_mood', '$message_delay');\n";
 				}
 			}
 			if ($clear_messages) {

+ 1 - 1
resources/classes/ringbacks.php

@@ -115,7 +115,7 @@ if (!class_exists('ringbacks')) {
 					foreach ($this->music_list as $row) {
 						if ($previous_name != $row['music_on_hold_name']) {
 							$name = '';
-							if (strlen($row['domain_uuid']) > 0) {
+							if (!empty($row['domain_uuid'])) {
 								$name = $row['domain_name'].'/';	
 							}
 							$name .= $row['music_on_hold_name'];

+ 7 - 7
resources/classes/schema.php

@@ -190,7 +190,7 @@ if (!class_exists('schema')) {
 
 		//get the table information
 			public function table_info($db_name, $table_name) {
-				if (strlen($table_name) == 0) { return false; }
+				if (empty($table_name)) { return false; }
 				if ($this->db_type == "sqlite") {
 					$sql = "PRAGMA table_info(".$table_name.");";
 				}
@@ -252,7 +252,7 @@ if (!class_exists('schema')) {
 
 		//database table information
 			private function db_table_info($db_name, $db_type, $table_name) {
-				if (strlen($table_name) == 0) { return false; }
+				if (empty($table_name)) { return false; }
 				if ($db_type == "sqlite") {
 					$sql = "PRAGMA table_info(".$table_name.");";
 				}
@@ -564,7 +564,7 @@ if (!class_exists('schema')) {
 									$table_name = $row['table'];
 								}
 							}
-							if (strlen($table_name) > 0) {
+							if (!empty($table_name)) {
 
 								//check if the table exists
 									if ($this->db_table_exists($db_type, $db_name, $table_name)) {
@@ -585,7 +585,7 @@ if (!class_exists('schema')) {
 											else {
 												$field_name = $field['name'];
 											}
-											if (strlen($field_name) > 0) {
+											if (!empty($field_name)) {
 												if ($this->db_column_exists ($db_type, $db_name, $table_name, $field_name)) {
 													//found
 													$apps[$x]['db'][$y]['fields'][$z]['exists'] = 'true';
@@ -690,7 +690,7 @@ if (!class_exists('schema')) {
 														$db_field_type = $this->db_column_data_type ($db_type, $db_name, $table_name, $field_name);
 														$field_type_array = explode("(", $field_type);
 														$field_type = $field_type_array[0];
-														if (trim($db_field_type) != trim($field_type) && strlen($db_field_type) > 0) {
+														if (trim($db_field_type) != trim($field_type) && !empty($db_field_type)) {
 															if ($db_type == "pgsql") {
 																if (strtolower($field_type) == "uuid") {
 																	$sql_update .= "ALTER TABLE ".$table_name." ALTER COLUMN ".$field_name." TYPE uuid USING\n";
@@ -790,7 +790,7 @@ if (!class_exists('schema')) {
 						//start the table
 							$response .= "<table width='100%' border='0' cellpadding='20' cellspacing='0'>\n";
 						//show the changes
-							if (strlen($sql_update) > 0) {
+							if (!empty($sql_update)) {
 								$response .= "<tr>\n";
 								$response .= "<td class='row_style1' colspan='3'>\n";
 								$response .= "<br />\n";
@@ -887,7 +887,7 @@ if (!class_exists('schema')) {
 
 					//loop line by line through all the lines of sql code
 						$x = 0;
-						if (strlen($sql_update) == 0 && $format == "text") {
+						if (empty($sql_update) && $format == "text") {
 							$response .= "	".$text['label-schema'].":			".$text['label-no_change']."\n";
 						}
 						else {

+ 3 - 3
resources/classes/switch_settings.php

@@ -26,7 +26,7 @@ if (!class_exists('switch_settings')) {
 
 			//define the variables
 				if (!isset($this->event_socket_ip_address)) {
-					if (strlen($_SESSION['event_socket_ip_address']) > 0) {
+					if (!empty($_SESSION['event_socket_ip_address'])) {
 						$this->event_socket_ip_address = $_SESSION['event_socket_ip_address'];
 					}
 					else {
@@ -34,7 +34,7 @@ if (!class_exists('switch_settings')) {
 					}
 				}
 				if (!isset($this->event_socket_port)) {
-					if (strlen($_SESSION['event_socket_port']) > 0) {
+					if (!empty($_SESSION['event_socket_port'])) {
 						$this->event_socket_port = $_SESSION['event_socket_port'];
 					}
 					else {
@@ -42,7 +42,7 @@ if (!class_exists('switch_settings')) {
 					}
 				}
 				if (!isset($this->event_socket_password)) {
-					if (strlen($_SESSION['event_socket_password']) > 0) {
+					if (!empty($_SESSION['event_socket_password'])) {
 						$this->event_socket_password = $_SESSION['event_socket_password'];
 					}
 					else {

+ 13 - 14
resources/classes/text.php

@@ -3,7 +3,6 @@
 /**
  * Get the text for the correct translation
  *
- * @method array get
  */
 class text {
 	public $languages;
@@ -72,9 +71,9 @@ class text {
 			else {
 				$lang_path = getcwd();
 			}
-			if (file_exists("${lang_path}/app_languages.php")) {
+			if (file_exists($lang_path."/app_languages.php")) {
 				if ($lang_path != 'resources' or $exclude_global) {
-					include "${lang_path}/app_languages.php";
+					include "{$lang_path}/app_languages.php";
 				}
 			}
 			//else {
@@ -100,7 +99,7 @@ class text {
 			if ($language_code != 'all') {
 				if (is_array($text)) {
 					foreach ($text as $key => $value) {
-						if (isset($value[$language_code]) && strlen($value[$language_code]) > 0) {
+						if (isset($value[$language_code]) && !empty($value[$language_code])) {
 							$text[$key] = $value[$language_code];
 						}
 						else {
@@ -177,7 +176,7 @@ class text {
 				if ($app_path == 'resources') {
 					foreach($this->languages as $language) {
 						$label = array_shift($text["language-$language"]);
-						if (strlen($label) == 0)
+						if (empty($label))
 							$label = $language;
 						$text["language-$language"]['en-us'] = $label;
 					}
@@ -200,7 +199,7 @@ class text {
 						if (strlen($target_lang) == 11)
 							$spacer = "   ";
 						$language_name = $this->escape_str(array_shift($text[$lang_label]));
-						if (strlen($language_name) == 0)
+						if (empty($language_name))
 							$language_name = $this->escape_str($target_lang);
 						fwrite($lang_file, "\$text['language-$target_lang'$spacer]['en-us'] = \"$language_name\";\n");
 					}
@@ -223,27 +222,27 @@ class text {
 										$spacer = "   ";
 									if (array_key_exists($lang_code, $text[$lang_label]))
 										$value = $text[$lang_label][$lang_code];
-									if (strlen($value) == 0 and array_key_exists($target_lang, $this->legacy_map)) {
+									if (empty($value) and array_key_exists($target_lang, $this->legacy_map)) {
 										$value = $text[$lang_label][$this->legacy_map[$target_lang]];
 									}
 									$base_code = substr($target_lang, 0, 2);
-									if (strlen($value) > 0
+									if (!empty($value)
 										and array_key_exists($base_code, $this->legacy_map )
 										and $this->legacy_map[$base_code] != $target_lang
 										and $value == $text[$lang_label][$this->legacy_map[$base_code]]
 									) {
 										$append = " //copied from ".$this->legacy_map[$base_code];
 									}
-									if (strlen($value) == 0) {
+									if (empty($value)) {
 										foreach($this->languages as $lang_code) {
-											if (substr($lang_code, 0, 2) == $base_code and strlen($text[$lang_label][$lang_code]) > 0) {
+											if (substr($lang_code, 0, 2) == $base_code and !empty($text[$lang_label][$lang_code])) {
 												$value = $text[$lang_label][$lang_code];
 												$append = " //copied from $lang_code";
 												continue;
 											}
 										}
 									}
-									if(strlen($append) == 0 && array_key_exists($comment, $lang_label) && array_key_exists($comment[$lang_label], $lang_code)) {
+									if(empty($append) && array_key_exists($comment, $lang_label) && array_key_exists($comment[$lang_label], $lang_code)) {
 										$append = " //$comment[$lang_label][$lang_code]";
 									}
 									fwrite($lang_file, "\$text['$lang_label']['$target_lang'$spacer] = \"".$this->escape_str($value)."\";$append\n");
@@ -319,7 +318,7 @@ class text {
 			foreach($text as $label_name => $values) {
 				$language_totals['languages']['total']++;
 				foreach ($this->languages as $language_code) {
-					if (strlen($values[$language_code]) > 0)
+					if (!empty($values[$language_code]))
 						$language_totals['languages'][$language_code]++;
 				}
 			}
@@ -342,12 +341,12 @@ class text {
 				foreach($app['menu'] as $menu_item) {
 					$language_totals['menu_items']['total']++;
 					foreach ($this->languages as $language_code) {
-						if (strlen($menu_item['title'][$language_code]) > 0)
+						if (!empty($menu_item['title'][$language_code]))
 							$language_totals['menu_items'][$language_code]++;
 					}
 				}
 				foreach ($this->languages as $language_code) {
-					if (strlen($app['description'][$language_code]) > 0) {
+					if (!empty($app['description'][$language_code])) {
 						$language_totals['app_descriptions'][$language_code]++;
 					}
 				}

+ 10 - 10
resources/classes/vcard.php

@@ -90,13 +90,13 @@ class vcard {
 		$this->card .= "N:";
 		$this->card .= $this->data['last_name'].";";
 		$this->card .= $this->data['first_name'];
-		if (strlen($this->data['additional_name']) > 0) {
+		if (!empty($this->data['additional_name'])) {
 			$this->card .= ";".$this->data['additional_name'];
 		}
-		if (strlen($this->data['name_prefix']) > 0) {
+		if (!empty($this->data['name_prefix'])) {
 			$this->card .= ";".$this->data['name_prefix'];
 		}
-		if (strlen($this->data['name_suffix']) > 0) {
+		if (!empty($this->data['name_suffix'])) {
 			$this->card .= ";".$this->data['name_suffix'];
 		}
 		$this->card .= "\r\n";
@@ -116,25 +116,25 @@ class vcard {
 			|| $this->data[$vcard_address_type_value.'_postal_code']
 			|| $this->data[$vcard_address_type_value.'_country']) {
 				$this->card .= "ADR;TYPE=".$vcard_address_type_value.":";
-				if (strlen($this->data[$vcard_address_type_value.'_po_box']) > 0) {
+				if (!empty($this->data[$vcard_address_type_value.'_po_box'])) {
 					$this->card .= $this->data[$vcard_address_type_value.'_po_box'].";";
 				}
-				if (strlen($this->data[$vcard_address_type_value.'_extended_address']) > 0) {
+				if (!empty($this->data[$vcard_address_type_value.'_extended_address'])) {
 					$this->card .= $this->data[$vcard_address_type_value.'_extended_address'].";";
 				}
-				if (strlen($this->data[$vcard_address_type_value.'_address']) > 0) {
+				if (!empty($this->data[$vcard_address_type_value.'_address'])) {
 					$this->card .= $this->data[$vcard_address_type_value.'_address'].";";
 				}
-				if (strlen($this->data[$vcard_address_type_value.'_city']) > 0) {
+				if (!empty($this->data[$vcard_address_type_value.'_city'])) {
 					$this->card .= $this->data[$vcard_address_type_value.'_city'].";";
 				}
-				if (strlen($this->data[$vcard_address_type_value.'_state']) > 0) {
+				if (!empty($this->data[$vcard_address_type_value.'_state'])) {
 					$this->card .= $this->data[$vcard_address_type_value.'_state'].";";
 				}
-				if (strlen($this->data[$vcard_address_type_value.'_postal_code']) > 0) {
+				if (!empty($this->data[$vcard_address_type_value.'_postal_code'])) {
 					$this->card .= $this->data[$vcard_address_type_value.'_postal_code'].";";
 				}
-				if (strlen($this->data[$vcard_address_type_value.'_country']) > 0) {
+				if (!empty($this->data[$vcard_address_type_value.'_country'])) {
 					$this->card .= $this->data[$vcard_address_type_value.'_country']."";
 				}
 				$this->card .= "\r\n";

+ 2 - 2
resources/footer.php

@@ -48,9 +48,9 @@
 	//}
 
 //set a default template
-	if (strlen($_SESSION["template_full_path"]) == 0) { //build template if session template has no length
+	if (empty($_SESSION["template_full_path"])) { //build template if session template has no length
 		$template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
-		if (strlen($template_rss_sub_category) > 0) {
+		if (!empty($template_rss_sub_category)) {
 			//this template was assigned by the content manager
 				//get the contents of the template and save it to the template variable
 				$template_full_path = $template_base_path.'/'.$template_rss_sub_category.'/template.php';

+ 1 - 1
resources/fpdi/pdf_parser.php

@@ -866,7 +866,7 @@ class pdf_parser
                 case '/Fl':
                     if (function_exists('gzuncompress')) {
                         $oStream = $stream;
-                        $stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
+                        $stream = (!empty($stream)) ? @gzuncompress($stream) : '';
                     } else {
                         throw new Exception(
                             sprintf('To handle %s filter, please compile php with zlib support.', $filter[1])

+ 30 - 32
resources/functions.php

@@ -60,7 +60,7 @@
 				else {
 					$tmp_str = mysqli_real_escape_string($db, $string);
 				}
-				if (strlen($tmp_str)) {
+				if (!empty($tmp_str)) {
 					$string = $tmp_str;
 				}
 				else {
@@ -82,7 +82,7 @@
 
 	if (!function_exists('check_cidr')) {
 		function check_cidr($cidr, $ip_address) {
-			if (isset($cidr) && strlen($cidr) > 0) {
+			if (isset($cidr) && !empty($cidr)) {
 				list ($subnet, $mask) = explode ('/', $cidr);
 				return ( ip2long ($ip_address) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet);
 			}
@@ -362,7 +362,7 @@
 			$result = $database->select($sql, null, 'all');
 			if (is_array($result) && @sizeof($result) != 0) {
 				foreach($result as $field) {
-					if (strlen($field[$field_name]) > 0) {
+					if (!empty($field[$field_name])) {
 						$html .= "<option value=\"".escape($field[$field_name])."\" ".($field_current_value == $field[$field_name] ? "selected='selected'" : null).">".escape($field[$field_name])."</option>\n";
 					}
 				}
@@ -391,7 +391,7 @@
 			$field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name);
 			$field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value);
 		
-			if (strlen($field_value) > 0) {
+			if (!empty($field_value)) {
 				$html .= "<select id=\"".$field_value."\" name=\"".$field_value."\" class='formfld' style='".$style."' ".($on_change != '' ? "onchange=\"".$on_change."\"" : null).">\n";
 				$html .= "	<option value=\"\"></option>\n";
 
@@ -408,9 +408,9 @@
 			$result = $database->select($sql, null, 'all');
 			if (is_array($result) && @sizeof($result) != 0) {
 				foreach($result as $field) {
-					if (strlen($field[$field_name]) > 0) {
+					if (!empty($field[$field_name])) {
 						$selected = $field_current_value == $field[$field_name] ? "selected='selected'" : null;
-						$array_key = strlen($field_value) > 0 ? $field_value : $field_name;
+						$array_key = empty($field_value) ? $field_name : $field_value;
 						$html .= "<option value=\"".urlencode($field[$array_key])."\" ".$selected.">".urlencode($field[$field_name])."</option>\n";
 					}
 				}
@@ -429,10 +429,10 @@
 			if (is_uuid($app_uuid) > 0) { $app_uuid = "&app_uuid=".urlencode($app_uuid); }	// accomodate need to pass app_uuid where necessary (inbound/outbound routes lists)
 
 			$field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name);
-			$field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value);
+			$field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value ?? '');
 
 			$sanitized_parameters = '';
-			if (isset($http_get_params) && strlen($http_get_params) > 0) {
+			if (isset($http_get_params) && !empty($http_get_params)) {
 				$parameters = explode('&', $http_get_params);
 				if (is_array($parameters)) {
 					foreach ($parameters as $parameter) {
@@ -440,11 +440,11 @@
 							$array = explode('=', $parameter);
 							$key = preg_replace('#[^a-zA-Z0-9_\-]#', '', $array['0']);
 							$value = urldecode($array['1']);
-							if ($key == 'order_by' && strlen($value) > 0) {
+							if ($key == 'order_by' && !empty($value)) {
 								//validate order by
 								$sanitized_parameters .= "&order_by=". preg_replace('#[^a-zA-Z0-9_\-]#', '', $value);
 							}
-							else if ($key == 'order' && strlen($value) > 0) {
+							else if ($key == 'order' && !empty($value)) {
 								//validate order
 								switch ($value) {
 									case 'asc':
@@ -455,7 +455,7 @@
 										break;
 								}
 							}
-							else if (strlen($value) > 0 && is_numeric($value)) {
+							else if (!empty($value) && is_numeric($value)) {
 								$sanitized_parameters .= "&".$key."=".$value;
 							}
 							else {
@@ -467,8 +467,8 @@
 			}
 
 			$html = "<th ".$css." nowrap='nowrap'>";
-			$description = (strlen($description) > 0) ? $description . ', ': '';
-			if (strlen($order_by) == 0) {
+			$description = empty($description) ? '' : $description . ', ';
+			if (empty($order_by)) {
 				$order = 'asc';
 			}
 			if ($order_by == $field_name) {
@@ -563,7 +563,7 @@
 			//find unique filename: check if file exists if it does then increment the filename
 				$i = 1;
 				while( file_exists($dest_dir.'/'.$file_name)) {
-					if (strlen($file_ext)> 0) {
+					if (!empty($file_ext)) {
 						$file_name = $file_name_base . $i .'.'. $file_ext;
 					}
 					else {
@@ -688,8 +688,8 @@
 	if (!function_exists('user_add')) {
 		function user_add($username, $password, $user_email = '') {
 			global $domain_uuid;
-			if (strlen($username) == 0) { return false; }
-			if (strlen($password) == 0) { return false; }
+			if (empty($username)) { return false; }
+			if (empty($password)) { return false; }
 			if (!username_exists($username)) {
 				//build user insert array
 					$user_uuid = uuid();
@@ -758,6 +758,10 @@ function switch_module_is_running($fp, $mod) {
 
 //format a number (n) replace with a number (r) remove the number
 function format_string($format, $data) {
+	//nothing to do so return
+	if(empty($format))
+		return $data;
+	
 	//preset values
 	$x=0;
 	$tmp = '';
@@ -783,7 +787,7 @@ function format_string($format, $data) {
 			}
 		}
 	}
-	if (strlen($tmp) == 0) {
+	if (empty($tmp)) {
 		return $data;
 	}
 	else {
@@ -1666,8 +1670,8 @@ function number_pad($number,$n) {
 					$string = "^\\+(".substr($string, 1).")$";
 				}
 			//add prefix
-				if (strlen($prefix) > 0) {
-					if (strlen($prefix) > 0 && strlen($prefix) < 4) {
+				if (!empty($prefix)) {
+					if (!empty($prefix) && strlen($prefix) < 4) {
 						$plus = (substr($string, 0, 1) == "+") ? '' : '\+?';
 						$prefix = $plus.$prefix.'?';
 					}
@@ -1888,16 +1892,9 @@ function number_pad($number,$n) {
 
 //escape user data
 	function escape($string) {
-		if (is_array($string)) {
-			return false;
-		}
-		elseif (isset($string) && strlen($string)) {
+		if (is_string($string))
 			return htmlentities($string, ENT_QUOTES | ENT_HTML5, 'UTF-8');
-		}
-		else {
-			return false;
-		}
-		//return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
+		return false;
 	}
 
 //output pre-formatted array keys and values
@@ -2010,8 +2007,9 @@ function number_pad($number,$n) {
 	if (!function_exists('order_by')) {
 		function order_by($col, $dir, $col_default = '', $dir_default = 'asc') {
 			$order_by = ' order by ';
-			$col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col);
-			$dir = strtolower($dir) == 'desc' ? 'desc' : 'asc';
+			$col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col ?? '');
+			if(!empty($dir))
+				$dir = strtolower($dir) == 'desc' ? 'desc' : 'asc';
 			if ($col != '') {
 				return $order_by.$col.' '.$dir.' ';
 			}
@@ -2037,7 +2035,7 @@ function number_pad($number,$n) {
 		function limit_offset($limit, $offset = 0) {
 			$regex = '#[^0-9]#';
 			$limit = preg_replace($regex, '', $limit);
-			$offset = preg_replace($regex, '', $offset);
+			$offset = preg_replace($regex, '', $offset ?? '');
 			if (is_numeric($limit) && $limit > 0) {
 				$clause = ' limit '.$limit;
 				$offset = is_numeric($offset) ? $offset : 0;
@@ -2152,7 +2150,7 @@ function number_pad($number,$n) {
 //get accountcode
 	if (!function_exists('get_accountcode')) {
 		function get_accountcode() {
-			if (strlen($accountcode = $_SESSION['domain']['accountcode']['text']) > 0) {
+			if (!empty($accountcode = $_SESSION['domain']['accountcode']['text'] ?? '')) {
 				if ($accountcode == "none") {
 					return;
 				}

+ 5 - 5
resources/header.php

@@ -33,7 +33,7 @@
 
 //if reloadxml then run the command
 	if (permission_exists('dialplan_edit') && isset($_SESSION["reload_xml"])) {
-		if (strlen($_SESSION["reload_xml"]) > 0) {
+		if (!empty($_SESSION["reload_xml"])) {
 			if ($_SESSION['apply_settings'] == "true") {
 				//show the apply settings prompt
 			}
@@ -95,23 +95,23 @@
 		$sql .= ") ";
 		$sql .= "order by rss_order asc ";
 		$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
-		$parameters['content'] = strlen($content) == 0 ? $_SERVER["PHP_SELF"] : $content;
+		$parameters['content'] = empty($content) ? $_SERVER["PHP_SELF"] : $content;
 		$database = new database;
 		$content_result = $database->select($sql, $parameters, 'all');
 		if (is_array($content_result) && @sizeof($content_result) != 0) {
 			foreach($content_result as $content_row) {
 				$template_rss_sub_category = $content_row['rss_sub_category'];
-				if (strlen($content_row['rss_group']) == 0) {
+				if (empty($content_row['rss_group'])) {
 					//content is public
 					$content_from_db = &$content_row['rss_description'];
-					if (strlen($content_row['rss_title']) > 0) {
+					if (!empty($content_row['rss_title'])) {
 						$page["title"] = $content_row['rss_title'];
 					}
 				}
 				else {
 					if (if_group($content_row[rss_group])) { //viewable only to designated group
 						$content_from_db = &$content_row[rss_description];
-						if (strlen($content_row['rss_title']) > 0) {
+						if (!empty($content_row['rss_title'])) {
 							$page["title"] = $content_row['rss_title'];
 						}
 					}

+ 4 - 4
resources/login.php

@@ -251,17 +251,17 @@
 
 //santize the login destination url and set a default value
 	if (isset($_SESSION['login']['destination']['text'])) {
-		$destination_path = parse_url($_SESSION['login']['destination']['text'])['path'];
-		$destination_query = parse_url($_SESSION['login']['destination']['text'])['query'];
+		$destination_path = parse_url($_SESSION['login']['destination']['text'])['path'] ?? '';
+		$destination_query = parse_url($_SESSION['login']['destination']['text'])['query'] ?? '';
 		$destination_path = preg_replace('#[^a-zA-Z0-9_\-\./]#', '', $destination_path);
 		$destination_query = preg_replace('#[^a-zA-Z0-9_\-\./&=]#', '', $destination_query);
-		$_SESSION['login']['destination']['text'] = (strlen($destination_query) > 0) ? $destination_path.'?'.$destination_query : $destination_path;
+		$_SESSION['login']['destination']['text'] = (!empty($destination_query)) ? $destination_path.'?'.$destination_query : $destination_path;
 	}
 	else {
 		$_SESSION['login']['destination']['text'] = PROJECT_PATH."/core/dashboard/";
 	}
 
-	if (strlen($_REQUEST['path']) > 0) {
+	if (!empty($_REQUEST['path'])) {
 		$_SESSION['redirect_path'] = $_REQUEST['path'];
 	}
 

+ 6 - 6
resources/paging.php

@@ -41,18 +41,18 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
 
 	//sanitize the parameters
 	$sanitized_parameters = '';
-	if (isset($param) && strlen($param) > 0) {
+	if (isset($param) && !empty($param)) {
 		$param_array = explode("&", $param);
 		if (is_array($param_array)) {
 			foreach($param_array as $row) {
 				$param_sub_array = explode("=", $row);
 				$key = preg_replace('#[^a-zA-Z0-9_\-]#', '', $param_sub_array['0']);
-				$value = urldecode($param_sub_array['1']);
-				if ($key == 'order_by' && strlen($value) > 0) {
+				$value = urldecode($param_sub_array['1'] ?? '');
+				if ($key === 'order_by' && !empty($value)) {
 					//validate order by
 					$sanitized_parameters .= "&order_by=". preg_replace('#[^a-zA-Z0-9_\-]#', '', $value);
 				}
-				else if ($key == 'order' && strlen($value) > 0) {
+				else if ($key == 'order' && !empty($value)) {
 					//validate order
 					switch ($value) {
 						case 'asc':
@@ -63,11 +63,11 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
 							break;
 					}
 				}
-				else if (strlen($value) > 0 && is_numeric($value)) {
+				else if (!empty($value) && is_numeric($value)) {
 					$sanitized_parameters .= "&".$key."=".$value;
 				}
 				else {
-					$sanitized_parameters .= "&".$key."=".urlencode($value);
+					$sanitized_parameters .= "&".$key."=".urlencode($value ?? '');
 				}
 			}
 		}

+ 8 - 8
resources/pdo.php

@@ -107,13 +107,13 @@ if (!function_exists('get_db_field_names')) {
 if ($db_type == "sqlite") {
 
 	//set the document_root
-		if (strlen($document_root) == 0) {
+		if (empty($document_root)) {
 			$document_root = $_SERVER["DOCUMENT_ROOT"];
 		}
 
 	//prepare the database connection
-		if (strlen($db_name) == 0) {
-			//if (strlen($_SERVER["SERVER_NAME"]) == 0) { $_SERVER["SERVER_NAME"] = "http://localhost"; }
+		if (empty($db_name)) {
+			//if (empty($_SERVER["SERVER_NAME"])) { $_SERVER["SERVER_NAME"] = "http://localhost"; }
 			$server_name = $_SERVER["SERVER_NAME"];
 			$server_name = str_replace ("www.", "", $server_name);
 			//$server_name = str_replace (".", "_", $server_name);
@@ -220,12 +220,12 @@ if ($db_type == "mysql") {
 				//$mysql_connection = mysqli_connect($db_host, $db_username, $db_password,$db_name) or die("Error " . mysqli_error($link));
 			}
 		//mysql pdo connection
-			if (strlen($db_host) == 0 && strlen($db_port) == 0) {
+			if (strlen($db_host) == 0 && empty($db_port)) {
 				//if both host and port are empty use the unix socket
 				$db = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$db_name;charset=utf8;", $db_username, $db_password);
 			}
 			else {
-				if (strlen($db_port) == 0) {
+				if (empty($db_port)) {
 					//leave out port if it is empty
 					$db = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8;", $db_username, $db_password, array(
 					PDO::ATTR_ERRMODE,
@@ -252,8 +252,8 @@ if ($db_type == "pgsql") {
 		if (!isset($db_secure)) {
 			$db_secure = false;
 		}
-		if (strlen($db_host) > 0) {
-			if (strlen($db_port) == 0) { $db_port = "5432"; }
+		if (!empty($db_host)) {
+			if (empty($db_port)) { $db_port = "5432"; }
 			if ($db_secure == true) {
 				$db = new PDO("pgsql:host=$db_host port=$db_port dbname=$db_name user=$db_username password=$db_password sslmode=verify-ca sslrootcert=$db_cert_authority");
 			}
@@ -354,7 +354,7 @@ if ($db_type == "odbc") {
 	}
 
 //set the domain_uuid variable from the session
-	if (strlen($_SESSION["domain_uuid"]) > 0) {
+	if (!empty($_SESSION["domain_uuid"])) {
 		$domain_uuid = $_SESSION["domain_uuid"];
 	}
 	else {

+ 1 - 1
resources/pdo_vm.php

@@ -60,7 +60,7 @@
 //database connection
 	try {
 		unset($db);
-		if (strlen($odbc_dsn) == 0) {
+		if (empty($odbc_dsn)) {
 			$db = new PDO('sqlite:'.$_SESSION['switch']['db']['dir'].'/voicemail_default.db'); //sqlite 3
 		}
 		else {

+ 2 - 2
resources/phpmailer/class.phpmailer.php

@@ -1924,7 +1924,7 @@ class PHPMailer
                         }
                         $buf = '';
                     }
-                    while (strlen($word) > 0) {
+                    while (!empty($word)) {
                         if ($length <= 0) {
                             break;
                         }
@@ -1939,7 +1939,7 @@ class PHPMailer
                         $part = substr($word, 0, $len);
                         $word = substr($word, $len);
 
-                        if (strlen($word) > 0) {
+                        if (!empty($word)) {
                             $message .= $part . sprintf('=%s', self::CRLF);
                         } else {
                             $buf = $part;

+ 2 - 2
resources/pop3/mime_parser.php

@@ -420,7 +420,7 @@ class mime_parser_class
 			{
 				$value = substr($remaining, 1, $quote - 1);
 				$p = trim(substr($remaining, $quote + 1));
-				if(strlen($p) > 0
+				if(!empty($p)
 				&& !strcmp($p[0], ';'))
 					$p = substr($p, 1);
 			}
@@ -967,7 +967,7 @@ class mime_parser_class
 								$decoded=base64_decode(substr($value, $start, $end - $start));
 								if($end <= $start
 								|| GetType($decoded) != 'string'
-								|| strlen($decoded) == 0)
+								|| empty($decoded))
 								{
 									$warning = 'the header specified an invalid base64 encoded text';
 									$warning_position = $part['Position'] + $start;

+ 1 - 1
resources/pop3/pop3.php

@@ -650,7 +650,7 @@ class pop3_class
 	{
 		if($this->state!="TRANSACTION")
 			return($this->SetError("cannot get the name of a POP3 connection that was not established and the user has logged in"));
-		if(strlen($this->connection_name) == 0)
+		if(empty($this->connection_name))
 			pop3_class::SetConnection(1, $this->connection_name, $this);
 		$connection_name = $this->connection_name;
 		return('');

+ 1 - 1
resources/pop3/rfc822_addresses.php

@@ -228,7 +228,7 @@ class rfc822_addresses_class
 
 				case 'b':
 					if($e <= $t
-					|| strlen($binary = base64_decode($data = substr($value, $t, $e - $t))) == 0
+					|| empty($binary = base64_decode($data = substr($value, $t, $e - $t)))
 					|| GetType($binary) != 'string')
 						return($this->SetPositionedWarning('invalid Q-encoding b encoded data', $p + $t));
 					$decoded .= $binary;

+ 5 - 5
resources/tcpdf/include/barcodes/pdf417.php

@@ -835,11 +835,11 @@ class PDF417 {
 					if ($txtseq[1] > 0) {
 						// extract byte sequence before the text sequence
 						$prevtxtseq = substr($prevseq, $txtoffset, ($txtseq[1] - $txtoffset));
-						if (strlen($prevtxtseq) > 0) {
+						if (!empty($prevtxtseq)) {
 							// add BYTE sequence
-							if ((strlen($prevtxtseq) == 1) AND ((count($sequence_array) > 0) AND ($sequence_array[(count($sequence_array) - 1)][0] == 900))) {
+							if ((!empty($prevtxtseq) == 1) AND ((count($sequence_array)) AND ($sequence_array[(count($sequence_array) - 1)][0] == 900))) {
 								$sequence_array[] = array(913, $prevtxtseq);
-							} elseif ((strlen($prevtxtseq) % 6) == 0) {
+							} elseif ((empty($prevtxtseq) % 6)) {
 								$sequence_array[] = array(924, $prevtxtseq);
 							} else {
 								$sequence_array[] = array(901, $prevtxtseq);
@@ -924,7 +924,7 @@ class PDF417 {
 			}
 			case 901:
 			case 924: { // Byte Compaction mode latch
-				while (($codelen = strlen($code)) > 0) {
+				while (($codelen = !empty($code))) {
 					if ($codelen > 6) {
 						$rest = substr($code, 6);
 						$code = substr($code, 0, 6);
@@ -960,7 +960,7 @@ class PDF417 {
 				break;
 			}
 			case 902: { // Numeric Compaction mode latch
-				while (($codelen = strlen($code)) > 0) {
+				while (($codelen = !empty($code))) {
 					if ($codelen > 44) {
 						$rest = substr($code, 44);
 						$code = substr($code, 0, 44);

+ 1 - 1
resources/tcpdf/include/barcodes/qrcode.php

@@ -1443,7 +1443,7 @@ class QRcode {
 	 * @return (int)
 	 */
 	 protected function splitString() {
-		while (strlen($this->dataStr) > 0) {
+		while (!empty($this->dataStr)) {
 			$mode = $this->identifyMode(0);
 			switch ($mode) {
 				case QR_MODE_NM: {

+ 1 - 1
resources/tcpdf/include/tcpdf_colors.php

@@ -314,7 +314,7 @@ class TCPDF_COLORS {
 				return array();
 			}
 		}
-		if (strlen($color) == 0) {
+		if (empty($color)) {
 			return $defcol;
 		}
 		// RGB ARRAY

+ 4 - 4
resources/tcpdf/include/tcpdf_fonts.php

@@ -1793,10 +1793,10 @@ class TCPDF_FONTS {
 	 * @public static
 	 */
 	public static function UTF8ArrSubString($strarr, $start='', $end='', $unicode=true) {
-		if (strlen($start) == 0) {
+		if (empty($start)) {
 			$start = 0;
 		}
-		if (strlen($end) == 0) {
+		if (empty($end)) {
 			$end = count($strarr);
 		}
 		$string = '';
@@ -1816,10 +1816,10 @@ class TCPDF_FONTS {
 	 * @public static
 	 */
 	public static function UniArrSubString($uniarr, $start='', $end='') {
-		if (strlen($start) == 0) {
+		if (empty($start)) {
 			$start = 0;
 		}
-		if (strlen($end) == 0) {
+		if (empty($end)) {
 			$end = count($uniarr);
 		}
 		$string = '';

+ 6 - 6
resources/tcpdf/include/tcpdf_static.php

@@ -230,7 +230,7 @@ class TCPDF_STATIC {
 					if (strpos($border, 'B') !== false) {
 						// remove bottom line
 						$newkey = str_replace('B', '', $border);
-						if (strlen($newkey) > 0) {
+						if (!empty($newkey)) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
@@ -241,7 +241,7 @@ class TCPDF_STATIC {
 					if (strpos($border, 'B') !== false) {
 						// remove bottom line
 						$newkey = str_replace('B', '', $border);
-						if (strlen($newkey) > 0) {
+						if (!empty($newkey)) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
@@ -250,7 +250,7 @@ class TCPDF_STATIC {
 					if (strpos($border, 'T') !== false) {
 						// remove bottom line
 						$newkey = str_replace('T', '', $border);
-						if (strlen($newkey) > 0) {
+						if (!empty($newkey)) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
@@ -261,7 +261,7 @@ class TCPDF_STATIC {
 					if (strpos($border, 'T') !== false) {
 						// remove bottom line
 						$newkey = str_replace('T', '', $border);
-						if (strlen($newkey) > 0) {
+						if (!empty($newkey)) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
@@ -281,7 +281,7 @@ class TCPDF_STATIC {
 	 * @public static
 	 */
 	public static function empty_string($str) {
-		return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
+		return (is_null($str) OR (is_string($str) AND (empty($str))));
 	}
 
 	/**
@@ -1799,7 +1799,7 @@ class TCPDF_STATIC {
 			$ret[] = "\n";
 			$subject = substr($subject, ($nl + 1));
 		}
-		if (strlen($subject) > 0) {
+		if (!empty($subject)) {
 			$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
 		}
 		return $ret;

+ 10 - 10
resources/tcpdf/tcpdf.php

@@ -6309,7 +6309,7 @@ class TCPDF {
 	public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $stretch=0, $firstline=false, $firstblock=false, $maxh=0, $wadj=0, $margin='') {
 		// check page for no-write regions and adapt page margins if necessary
 		list($this->x, $this->y) = $this->checkPageRegions($h, $this->x, $this->y);
-		if (strlen($txt) == 0) {
+		if (empty($txt)) {
 			// fix empty text
 			$txt = ' ';
 		}
@@ -10432,7 +10432,7 @@ class TCPDF {
 			$lnkdata = explode(',', $url);
 			if (isset($lnkdata[0]) ) {
 				$page = substr($lnkdata[0], 1);
-				if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
+				if (isset($lnkdata[1]) AND (!empty($lnkdata[1]))) {
 					$lnky = floatval($lnkdata[1]);
 				} else {
 					$lnky = 0;
@@ -13476,10 +13476,10 @@ class TCPDF {
 		$this->sig_obj_id = $this->n; // signature widget
 		++$this->n; // signature object ($this->sig_obj_id + 1)
 		$this->signature_data = array();
-		if (strlen($signing_cert) == 0) {
+		if (empty($signing_cert)) {
 			$this->Error('Please provide a certificate file and password!');
 		}
-		if (strlen($private_key) == 0) {
+		if (empty($private_key)) {
 			$private_key = $signing_cert;
 		}
 		$this->signature_data['signcert'] = $signing_cert;
@@ -13574,7 +13574,7 @@ class TCPDF {
 		if (!function_exists('curl_init')) {
 			$this->Error('Please enable cURL PHP extension!');
 		}
-		if (strlen($tsa_host) == 0) {
+		if (empty($tsa_host)) {
 			$this->Error('Please specify the host of Time Stamping Authority (TSA)!');
 		}
 		$this->tsa_data['tsa_host'] = $tsa_host;
@@ -16326,7 +16326,7 @@ class TCPDF {
 						if (preg_match('/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
 							// read CSS data file
 							$cssdata = TCPDF_STATIC::fileGetContents(trim($type[1]));
-							if (($cssdata !== FALSE) AND (strlen($cssdata) > 0)) {
+							if (($cssdata !== FALSE) AND (!empty($cssdata))) {
 								$css = array_merge($css, TCPDF_STATIC::extractCSSproperties($cssdata));
 							}
 						}
@@ -17604,7 +17604,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
 				}
 			}
 			// align lines
-			if ($this->newline AND (strlen($dom[$key]['value']) > 0) AND ($dom[$key]['value'] != 'td') AND ($dom[$key]['value'] != 'th')) {
+			if ($this->newline AND (!empty($dom[$key]['value'])) AND ($dom[$key]['value'] != 'td') AND ($dom[$key]['value'] != 'th')) {
 				$newline = true;
 				$fontaligned = false;
 				// we are at the beginning of a new line
@@ -18352,7 +18352,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
 						$startlinepage = $this->page;
 					}
 				}
-			} elseif (strlen($dom[$key]['value']) > 0) {
+			} elseif (!empty($dom[$key]['value'])) {
 				// print list-item
 				if (!TCPDF_STATIC::empty_string($this->lispacer) AND ($this->lispacer != '^')) {
 					$this->SetFont($pfontname, $pfontstyle, $pfontsize);
@@ -18501,7 +18501,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
 					}
 				}
 				$this->textindent = 0;
-				if (strlen($strrest) > 0) {
+				if (!empty($strrest)) {
 					// store the remaining string on the previous $key position
 					$this->newline = true;
 					if ($strrest == $dom[$key]['value']) {
@@ -18948,7 +18948,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
 							if (empty($page) OR ($page <= 0)) {
 								$page = $this->page;
 							}
-							if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
+							if (isset($lnkdata[1]) AND (!empty($lnkdata[1]))) {
 								$lnky = floatval($lnkdata[1]);
 							} else {
 								$lnky = 0;

+ 1 - 1
themes/default/css.php

@@ -81,7 +81,7 @@ header('Expires: '.gmdate('D, d M Y H:i:s',time()+3600).' GMT');
 
 		if (count($background_images) > 0) {
 
-			if ((!isset($_SESSION['background_image'])) or strlen($_SESSION['background_image']) == 0) {
+			if ((!isset($_SESSION['background_image'])) or empty($_SESSION['background_image'])) {
 				$_SESSION['background_image'] = $background_images[array_rand($background_images)];
 				$background_image = $_SESSION['background_image'];
 			}