Ver Fonte

Fix all PHP 8.1 messages for upgrade.php

markjcrane há 2 anos atrás
pai
commit
48ed8e8156

+ 7 - 5
core/authentication/app_defaults.php

@@ -11,7 +11,7 @@
 		$array['email_templates'][$x]['template_category'] = 'authentication';
 		$array['email_templates'][$x]['template_subcategory'] = 'email';
 		$array['email_templates'][$x]['template_subject'] = 'Authentication Code';
-		$array['email_templates'][$x]['template_body'] .= "<html>\n";
+		$array['email_templates'][$x]['template_body'] = "<html>\n";
 		$array['email_templates'][$x]['template_body'] .= "	<body>\n";
 		$array['email_templates'][$x]['template_body'] .= "		<br />\n";
 		$array['email_templates'][$x]['template_body'] .= "		<br><strong>Security Code</strong><br><br>\n";
@@ -28,7 +28,7 @@
 		$array['email_templates'][$x]['template_category'] = 'authentication';
 		$array['email_templates'][$x]['template_subcategory'] = 'email';
 		$array['email_templates'][$x]['template_subject'] = 'Authentication Code';
-		$array['email_templates'][$x]['template_body'] .= "<html>\n";
+		$array['email_templates'][$x]['template_body'] = "<html>\n";
 		$array['email_templates'][$x]['template_body'] .= "	<body>\n";
 		$array['email_templates'][$x]['template_body'] .= "		<br />\n";
 		$array['email_templates'][$x]['template_body'] .= "		<br><strong>Security Code</strong><br><br>\n";
@@ -49,7 +49,7 @@
 		}
 
 		//add the email templates to the database
-		if (is_array($uuids) && @sizeof($uuids) != 0) {
+		if (!empty($uuids)) {
 			$sql = "select * from v_email_templates where ";
 			foreach ($uuids as $index => $uuid) {
 				$sql_where[] = "email_template_uuid = :email_template_uuid_".$index;
@@ -74,7 +74,7 @@
 		}
 
 		//add the missing email templates
-		if (is_array($array['email_templates']) && @sizeof($array['email_templates']) != 0) {
+		if (!empty($array['email_templates'])) {
 			//add the temporary permission
 			$p = new permissions;
 			$p->add("email_template_add", 'temp');
@@ -93,7 +93,9 @@
 		}
 
 		//remove the array
-		unset($array);
+		if (!empty($array)) {
+			unset($array);
+		}
 
 	}
 

+ 4 - 4
core/dashboard/app_defaults.php

@@ -15,7 +15,7 @@ if ($domains_processed == 1) {
 		$sql = "select * from v_groups ";
 		$sql .= "where domain_uuid is null ";
 		$database = new database;
-		$groups = $database->select($sql, $parameters, 'all');
+		$groups = $database->select($sql, null, 'all');
 
 	//get the dashboard
 		$sql = "select ";
@@ -27,7 +27,7 @@ if ($domains_processed == 1) {
 		$sql .= "dashboard_description ";
 		$sql .= "from v_dashboard ";
 		$database = new database;
-		$dashboard_widgets = $database->select($sql, $parameters, 'all');
+		$dashboard_widgets = $database->select($sql, null, 'all');
 		unset($sql, $parameters);
 
 	//add the dashboard widgets
@@ -60,7 +60,7 @@ if ($domains_processed == 1) {
 				$array['dashboard'][$x]['dashboard_enabled'] = $row['dashboard_enabled'];
 				$array['dashboard'][$x]['dashboard_description'] = $row['dashboard_description'];
 				$y = 0;
-				if (is_array($row['dashboard_groups'])) {
+				if (!empty($row['dashboard_groups'])) {
 					foreach ($row['dashboard_groups'] as $row) {
 						if (isset($row['group_name'])) {
 							foreach($groups as $field) {
@@ -84,7 +84,7 @@ if ($domains_processed == 1) {
 		$p->add('dashboard_group_add', 'temp');
 
 	//save the data
-		if (is_array($array)) {
+		if (!empty($array)) {
 			$database = new database;
 			$database->app_name = 'dashboard';
 			$database->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';

+ 2 - 2
core/software/app_defaults.php

@@ -33,7 +33,7 @@ if ($domains_processed == 1) {
 		$sql = "select software_version from v_software ";
 		$database = new database;
 		$software_version = $database->select($sql, null, 'column');
-		if ($software_version == '') {
+		if (empty($software_version)) {
 			$array['software'][0]['software_uuid'] = '7de057e7-333b-4ebf-9466-315ae7d44efd';
 			$array['software'][0]['software_name'] = 'FusionPBX';
 			$array['software'][0]['software_url'] = 'https://www.fusionpbx.com';
@@ -45,7 +45,7 @@ if ($domains_processed == 1) {
 		}
 
 	//save the data in the array
-		if (is_array($array) && count($array) > 0) {
+		if (!empty($array)) {
 			//add the temporary permission
 			$p = new permissions;
 			$p->add("software_add", 'temp');

+ 3 - 1
core/upgrade/app_defaults.php

@@ -27,7 +27,9 @@
 if ($domains_processed == 1) {
 
 	//remove smarty cache
-		system('rm '.sys_get_temp_dir().'/*.php');
+		foreach(glob(sys_get_temp_dir().'*.php') as $file) {
+			unlink($file);
+		}
 
 	//ensure the login message is set, if new message exists
 		$sql = "select count(*) as num_rows from v_default_settings ";

+ 27 - 15
resources/classes/database.php

@@ -1299,7 +1299,9 @@
 					$transaction_type = 'delete';
 
 				//get the UUIDs
-					$user_uuid = $_SESSION['user_uuid'];
+					if (!empty($_SESSION['user_uuid'])) {
+						$user_uuid = $_SESSION['user_uuid'];
+					}
 
 				//log the transaction results
 					if (file_exists($_SERVER["PROJECT_ROOT"]."/app/database_transactions/app_config.php")) {
@@ -2131,7 +2133,7 @@
 															}
 															elseif ($array_value === "user_uuid()") {
 																$sql .= ':'.$array_key.", ";
-																$params[$array_key] = $_SESSION['user_uuid'];
+																$params[$array_key] = $_SESSION['user_uuid'] ?? null;
 															}
 															elseif ($array_value === "remote_address()") {
 																$sql .= ':'.$array_key.", ";
@@ -2151,7 +2153,9 @@
 											$sql .= ");";
 
 											//add insert user parameter
-											$params['insert_user'] = $_SESSION['user_uuid'];
+											if (!empty($_SESSION['user_uuid'])) {
+												$params['insert_user'] = $_SESSION['uer_uuid'];
+											}
 
 											//set the error mode
 											$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -2230,7 +2234,7 @@
 														}
 														elseif ($array_value === "user_uuid()") {
 															$sql .= $array_key." = :".$array_key.", ";
-															$params[$array_key] = $_SESSION['user_uuid'];
+															$params[$array_key] = $_SESSION['user_uuid'] ?? null;
 														}
 														elseif ($array_value === "remote_address()") {
 															$sql .= $array_key." = :".$array_key.", ";
@@ -2245,16 +2249,20 @@
 											}
 
 											//add the modified date and user
-											$sql .= "update_date = now(), ";
-											$sql .= "update_user = :update_user ";
-											$params['update_user'] = $_SESSION['user_uuid'];
+											if (!empty($_SESSION['user_uuid'])) {
+												$sql .= "update_date = now(), ";
+												$sql .= "update_user = :update_user ";
+												$params['update_user'] = $_SESSION['user_uuid'];
+											}
 
 											//add the where with the parent name and value
 											$sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."'; ";
 											$sql = str_replace(", WHERE", " WHERE", $sql);
 
 											//add update user parameter
-											$params['update_user'] = $_SESSION['user_uuid'];
+											if (!empty($_SESSION['user_uuid'])) {
+												$params['update_user'] = $_SESSION['user_uuid'];
+											}
 
 											//set the error mode
 											$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -2277,7 +2285,7 @@
 												$message["details"][$m]["code"] = "200";
 												$message["details"][$m]["uuid"] = $parent_key_value;
 												$message["details"][$m]["sql"] = $sql;
-												if (is_array($params)) {
+												if (!empty($params)) {
 													$message["details"][$m]["params"] = $params;
 												}
 												unset($params);
@@ -2293,7 +2301,7 @@
 												$message["details"][$m]["message"] = $e->getMessage();
 												$message["details"][$m]["code"] = "400";
 												$message["details"][$m]["sql"] = $sql;
-												if (is_array($params)) {
+												if (!empty($params)) {
 													$message["details"][$m]["params"] = $params;
 												}
 												unset($params);
@@ -2416,7 +2424,7 @@
 																			}
 																			elseif ($v === "user_uuid()") {
 																				$sql .= $k." = :".$k.", ";
-																				$params[$k] = $_SESSION['user_uuid'];
+																				$params[$k] = $_SESSION['user_uuid'] ?? null;
 																			}
 																			elseif ($v === "remote_address()") {
 																				$sql .= $k." = :".$k.", ";
@@ -2433,7 +2441,7 @@
 																//add the modified date and user
 																$sql .= "update_date = now(), ";
 																$sql .= "update_user = :update_user ";
-																$params['update_user'] = $_SESSION['user_uuid'];
+																$params['update_user'] = $_SESSION['user_uuid'] ?? null;
 
 																//add the where with the parent name and value
 																$sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."' ";
@@ -2564,7 +2572,7 @@
 																			}
 																			elseif ($v === "user_uuid()") {
 																				$sql .= ':'.$k.", ";
-																				$params[$k] = $_SESSION['user_uuid'];
+																				$params[$k] = $_SESSION['user_uuid'] ?? null;
 																			}
 																			elseif ($v === "remote_address()") {
 																				$sql .= ':'.$k.", ";
@@ -2589,7 +2597,9 @@
 															$sql .= ");";
 
 															//add insert user parameter
-															$params['insert_user'] = $_SESSION['user_uuid'];
+															if (!empty($_SESSION['user_uuid'])) {
+																$params['insert_user'] = $_SESSION['user_uuid'];
+															}
 
 															//set the error mode
 															$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -2675,7 +2685,9 @@
 					}
 
 				//get the UUIDs
-					$user_uuid = $_SESSION['user_uuid'];
+					if (!empty($_SESSION['user_uuid'])) {
+						$user_uuid = $_SESSION['user_uuid'];
+					}
 
 				//log the transaction results
 					if ($transaction_save && file_exists($_SERVER["PROJECT_ROOT"]."/app/database_transactions/app_config.php")) {

+ 12 - 0
resources/classes/switch_settings.php

@@ -66,6 +66,18 @@ if (!class_exists('switch_settings')) {
 					}
 				}
 
+			//set defaults
+				$vars['base_dir'] = empty($vars['base_dir']) ?? '';
+				$vars['conf_dir'] = empty($vars['conf_dir']) ?? '';
+				$vars['db_dir'] = empty($vars['db_dir']) ?? '';
+				$vars['recordings_dir'] = empty($vars['recordings_dir']) ?? '';
+				$vars['script_dir'] = empty($vars['script_dir']) ?? '';
+				$vars['sounds_dir'] = empty($vars['sounds_dir']) ?? '';
+				$vars['storage_dir'] = empty($vars['storage_dir']) ?? '';
+				$vars['grammar_dir'] = empty($vars['grammar_dir']) ?? '';
+				$vars['log_dir'] = empty($vars['log_dir']) ?? '';
+				$vars['mod_dir'] = empty($vars['mod_dir']) ?? '';
+
 			//set the bin directory
 				if ($vars['base_dir'] == "/usr/local/freeswitch") {
 					$bin = "/usr/local/freeswitch/bin";