Browse Source

The goal is to increase confidence in fusionpbx, one step is to run by default with error_reporting (E_ALL ^ E_NOTICE);

So, please find in this set numerous small changes which eliminate numerous php warning messages.

Also, a small bug fix in an sql statistics routine, naming a count(*) field as count, so displaying correct detail.

If any of the proposed changes are omitted, the relevant page will experience php warnings.

There are no doubt fusionpbx pages I've yet to visit that still generate warnings, this set is nearly certainly not comprehensive.
Harry G. Coin 9 years ago
parent
commit
46942a8884

+ 1 - 1
core/menu/menu_item_list.php

@@ -84,7 +84,7 @@ function build_db_child_menu_list ($db, $menu_item_level, $menu_item_uuid, $c) {
 					foreach ($sub_result as &$sub_row) {
 					foreach ($sub_result as &$sub_row) {
 						$group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null);
 						$group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null);
 					}
 					}
-					$group_list = implode(', ', $group_list);
+					$group_list = isset($group_list) ? implode(', ', $group_list) : '';
 					unset ($sub_prep_statement);
 					unset ($sub_prep_statement);
 				//display the main body of the list
 				//display the main body of the list
 					switch ($menu_item_category) {
 					switch ($menu_item_category) {

+ 1 - 1
core/users/usersupdate.php

@@ -565,7 +565,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
 		foreach($result as $field) {
 		foreach($result as $field) {
 			if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; }	//only show the superadmin group to other superadmins
 			if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; }	//only show the superadmin group to other superadmins
 			if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; }	//only show the admin group to other admins
 			if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; }	//only show the admin group to other admins
-			if (!in_array($field["group_uuid"], $assigned_groups)) {
+			if (isset($assigned_groups) && !in_array($field["group_uuid"], $assigned_groups)) {
 				echo "	<option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
 				echo "	<option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
 			}
 			}
 		}
 		}

+ 1 - 1
index.php

@@ -56,7 +56,7 @@ include "root.php";
 	require_once "resources/require.php";
 	require_once "resources/require.php";
 
 
 // if logged in, redirect to login destination
 // if logged in, redirect to login destination
-	if (strlen($_SESSION["username"]) > 0) {
+	if (isset($_SESSION["username"]) and (strlen($_SESSION["username"]) > 0)) {
 		if (strlen($_SESSION['login']['destination']['url']) > 0) {
 		if (strlen($_SESSION['login']['destination']['url']) > 0) {
 			header("Location: ".$_SESSION['login']['destination']['url']);
 			header("Location: ".$_SESSION['login']['destination']['url']);
 		} elseif (file_exists($_SERVER["PROJECT_ROOT"]."/core/user_settings/user_dashboard.php")) {
 		} elseif (file_exists($_SERVER["PROJECT_ROOT"]."/core/user_settings/user_dashboard.php")) {

+ 1 - 1
logout.php

@@ -29,7 +29,7 @@ require_once "resources/require.php";
 
 
 //check for login return preference
 //check for login return preference
 	if ($_SESSION["user_uuid"] != '') {
 	if ($_SESSION["user_uuid"] != '') {
-		if ($_SESSION['login']['destination_last']['boolean'] == 'true') {
+		if (isset($_SESSION['login']['destination_last']) && ($_SESSION['login']['destination_last']['boolean'] == 'true')) {
 			if ($_SERVER['HTTP_REFERER'] != '') {
 			if ($_SERVER['HTTP_REFERER'] != '') {
 				//convert to relative path
 				//convert to relative path
 					$referrer = substr($_SERVER['HTTP_REFERER'], strpos($_SERVER['HTTP_REFERER'], $_SERVER["HTTP_HOST"]) + strlen($_SERVER["HTTP_HOST"]));
 					$referrer = substr($_SERVER['HTTP_REFERER'], strpos($_SERVER['HTTP_REFERER'], $_SERVER["HTTP_HOST"]) + strlen($_SERVER["HTTP_HOST"]));

+ 2 - 2
resources/classes/destinations.php

@@ -29,7 +29,7 @@ class destinations {
 			}
 			}
 			$i = 0;
 			$i = 0;
 			foreach ($apps as $x => &$app) {
 			foreach ($apps as $x => &$app) {
-				foreach ($app['destinations'] as &$row) {
+				if (isset($app['destinations'])) foreach ($app['destinations'] as &$row) {
 					$this->destinations[] = $row;
 					$this->destinations[] = $row;
 				}
 				}
 			}
 			}
@@ -277,4 +277,4 @@ echo $obj->select('ivr', 'example5', '');
 echo $obj->select('ivr', 'example6', '');
 echo $obj->select('ivr', 'example6', '');
 */
 */
 
 
-?>
+?>

+ 1 - 1
resources/classes/domains.php

@@ -138,7 +138,7 @@ if (!class_exists('domains')) {
 				}
 				}
 
 
 			//get the user settings
 			//get the user settings
-				if (strlen($_SESSION["domain_uuid"]) > 0 && strlen($_SESSION["user_uuid"]) > 0) {
+				if (array_key_exists("domain_uuid",$_SESSION) and array_key_exists("user_uuid",$_SESSION) and strlen($_SESSION["domain_uuid"]) > 0 && strlen($_SESSION["user_uuid"]) > 0) {
 					$sql = "select * from v_user_settings ";
 					$sql = "select * from v_user_settings ";
 					$sql .= "where domain_uuid = '" . $_SESSION["domain_uuid"] . "' ";
 					$sql .= "where domain_uuid = '" . $_SESSION["domain_uuid"] . "' ";
 					$sql .= "and user_uuid = '" . $_SESSION["user_uuid"] . "' ";
 					$sql .= "and user_uuid = '" . $_SESSION["user_uuid"] . "' ";

+ 2 - 2
resources/classes/menu.php

@@ -203,7 +203,7 @@ if (!class_exists('menu')) {
 				//if there are no groups listed in v_menu_item_groups under menu_item_uuid then add the default groups
 				//if there are no groups listed in v_menu_item_groups under menu_item_uuid then add the default groups
 					foreach($apps as $app) {
 					foreach($apps as $app) {
 						foreach ($app['menu'] as $sub_row) {
 						foreach ($app['menu'] as $sub_row) {
-							foreach ($sub_row['groups'] as $group) {
+							if (isset($sub_row['groups'])) foreach ($sub_row['groups'] as $group) {
 								$sql = "select count(*) as count from v_menu_item_groups ";
 								$sql = "select count(*) as count from v_menu_item_groups ";
 								$sql .= "where menu_item_uuid = '".$sub_row['uuid']."' ";
 								$sql .= "where menu_item_uuid = '".$sub_row['uuid']."' ";
 								$sql .= "and menu_uuid = '".$this->menu_uuid."' ";
 								$sql .= "and menu_uuid = '".$this->menu_uuid."' ";
@@ -547,7 +547,7 @@ if (!class_exists('menu')) {
 				//set the default menu_uuid
 				//set the default menu_uuid
 					$this->menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286';
 					$this->menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286';
 				//check to see if any menu exists
 				//check to see if any menu exists
-					$sql = "select count(*) from v_menus ";
+					$sql = "select count(*) as count from v_menus ";
 					$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
 					$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
 					$prep_statement = $this->db->prepare(check_sql($sql));
 					$prep_statement = $this->db->prepare(check_sql($sql));
 					$prep_statement->execute();
 					$prep_statement->execute();

+ 7 - 8
resources/classes/switch_settings.php

@@ -67,15 +67,14 @@ if (!class_exists('switch_settings')) {
 					}
 					}
 				}
 				}
 
 
-			//connect to event socket
-				$esl = new event_socket;
-				$esl->connect($this->event_socket_ip_address, $this->event_socket_port, $this->event_socket_password);
+				{ 	//connect to event socket
+					$esl = new event_socket;
+					$esl->connect($this->event_socket_ip_address, $this->event_socket_port, $this->event_socket_password);
 
 
-			//run the api command
-				$result = $esl->request('api global_getvar');
+					//run the api command
+					$result = $esl->request('api global_getvar');
+				}	//close event socket
 
 
-			//close event socket
-				fclose($fp);
 
 
 			//set the result as a named array
 			//set the result as a named array
 				$vars = array();
 				$vars = array();
@@ -284,4 +283,4 @@ if (!class_exists('switch_settings')) {
 	}
 	}
 }
 }
 
 
-?>
+?>

+ 2 - 2
resources/functions.php

@@ -843,7 +843,7 @@ function format_string ($format, $data) {
 	function format_phone($phone_number) {
 	function format_phone($phone_number) {
 		$phone_number = trim($phone_number, "+");
 		$phone_number = trim($phone_number, "+");
 		if (is_numeric($phone_number)) {
 		if (is_numeric($phone_number)) {
-			foreach ($_SESSION["format"]["phone"] as &$format) {
+			if (isset($_SESSION["format"]["phone"])) foreach ($_SESSION["format"]["phone"] as &$format) {
 				$format_count = substr_count($format, 'x');
 				$format_count = substr_count($format, 'x');
 				$format_count = $format_count + substr_count($format, 'R');
 				$format_count = $format_count + substr_count($format, 'R');
 				$format_count = $format_count + substr_count($format, 'r');
 				$format_count = $format_count + substr_count($format, 'r');
@@ -1148,7 +1148,7 @@ function number_pad($number,$n) {
 					}
 					}
 				}
 				}
 			}
 			}
-			ksort($dir_array, SORT_STRING);
+			if (isset($dir_array)) ksort($dir_array, SORT_STRING);
 			closedir($dir_list);
 			closedir($dir_list);
 		}
 		}
 	}
 	}

+ 3 - 3
resources/require.php

@@ -42,7 +42,7 @@
 	}
 	}
 
 
 //class auto loader
 //class auto loader
-	if (!class_exists(auto_loader)) {
+	if (!class_exists('auto_loader')) {
 		class auto_loader {
 		class auto_loader {
 			public function __construct() {
 			public function __construct() {
 				spl_autoload_register(array($this, 'loader'));
 				spl_autoload_register(array($this, 'loader'));
@@ -76,7 +76,7 @@
 	require_once "resources/switch.php";
 	require_once "resources/switch.php";
 
 
 //change language on the fly - for translate tool (if available)
 //change language on the fly - for translate tool (if available)
-	if ($_REQUEST['view_lang_code'] != '') {
+	if (isset($_REQUEST['view_lang_code']) && ($_REQUEST['view_lang_code']) != '') {
 		$_SESSION['domain']['language']['code'] = $_REQUEST['view_lang_code'];
 		$_SESSION['domain']['language']['code'] = $_REQUEST['view_lang_code'];
 	}
 	}
-?>
+?>

+ 3 - 3
themes/default/template.php

@@ -57,7 +57,7 @@
 	$background_images_enabled = false;
 	$background_images_enabled = false;
 	if ($default_login) {
 	if ($default_login) {
 		//try using login background images/colors
 		//try using login background images/colors
-		if ($_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) {
+		if (isset($_SESSION['theme']) && $_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) {
 			$background_images_enabled = true;
 			$background_images_enabled = true;
 			$background_images = $_SESSION['theme']['login_background_image'];
 			$background_images = $_SESSION['theme']['login_background_image'];
 		}
 		}
@@ -79,7 +79,7 @@
 	}
 	}
 	else {
 	else {
 		//use standard background images/colors
 		//use standard background images/colors
-		if ($_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) {
+		if (isset($_SESSION['theme']) && isset($_SESSION['theme']['background_image_enabled']) && $_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) {
 			$background_images_enabled = true;
 			$background_images_enabled = true;
 			$background_images = $_SESSION['theme']['background_image'];
 			$background_images = $_SESSION['theme']['background_image'];
 		}
 		}
@@ -96,7 +96,7 @@
 
 
 		if (count($background_images) > 0) {
 		if (count($background_images) > 0) {
 
 
-			if (strlen($_SESSION['background_image']) == 0) {
+			if ((!isset($_SESSION['background_image'])) or strlen($_SESSION['background_image']) == 0) {
 				$_SESSION['background_image'] = $background_images[array_rand($background_images)];
 				$_SESSION['background_image'] = $background_images[array_rand($background_images)];
 				$background_image = $_SESSION['background_image'];
 				$background_image = $_SESSION['background_image'];
 			}
 			}