Przeglądaj źródła

Update header.php

Fix indentation and create a new database object only if it is not defined.
FusionPBX 1 rok temu
rodzic
commit
6f42dc701b
1 zmienionych plików z 13 dodań i 11 usunięć
  1. 13 11
      resources/header.php

+ 13 - 11
resources/header.php

@@ -34,15 +34,14 @@
 				//show the apply settings prompt
 				//show the apply settings prompt
 			}
 			}
 			else {
 			else {
-				//create the event socket connection
-					$esl = event_socket::create();
 				//reload the access control list this also runs reloadxml
 				//reload the access control list this also runs reloadxml
-					$response = event_socket::api('reloadxml');
-					$_SESSION["reload_xml"] = '';
-					unset($_SESSION["reload_xml"]);
-					usleep(500);
+				$response = event_socket::api('reloadxml');
+				$_SESSION["reload_xml"] = '';
+				unset($_SESSION["reload_xml"]);
+				usleep(500);
+
 				//clear the apply settings reminder
 				//clear the apply settings reminder
-					$_SESSION["reload_xml"] = false;
+				$_SESSION["reload_xml"] = false;
 			}
 			}
 		}
 		}
 	}
 	}
@@ -61,7 +60,7 @@
 //start the output buffer
 //start the output buffer
 	ob_start();
 	ob_start();
 
 
-// get the content
+//get the content
 	if (isset($_GET["c"])) {
 	if (isset($_GET["c"])) {
 		$content = $_GET["c"]; //link
 		$content = $_GET["c"]; //link
 	}
 	}
@@ -69,13 +68,17 @@
 		$content = '';
 		$content = '';
 	}
 	}
 
 
+//connect to the database if not initialized
+	if (!($database instanceof database)) {
+		$database = new database();
+	}
+
 //get the parent id
 //get the parent id
 	$sql = "select menu_item_parent_uuid from v_menu_items ";
 	$sql = "select menu_item_parent_uuid from v_menu_items ";
 	$sql .= "where menu_uuid = :menu_uuid ";
 	$sql .= "where menu_uuid = :menu_uuid ";
 	$sql .= "and menu_item_link = :menu_item_link ";
 	$sql .= "and menu_item_link = :menu_item_link ";
 	$parameters['menu_uuid'] = $_SESSION['domain']['menu']['uuid'];
 	$parameters['menu_uuid'] = $_SESSION['domain']['menu']['uuid'];
 	$parameters['menu_item_link'] = $_SERVER["SCRIPT_NAME"];
 	$parameters['menu_item_link'] = $_SERVER["SCRIPT_NAME"];
-	$database = new database;
 	$_SESSION["menu_item_parent_uuid"] = $database->select($sql, $parameters, 'column');
 	$_SESSION["menu_item_parent_uuid"] = $database->select($sql, $parameters, 'column');
 	unset($sql, $parameters);
 	unset($sql, $parameters);
 
 
@@ -92,7 +95,6 @@
 		$sql .= "order by rss_order asc ";
 		$sql .= "order by rss_order asc ";
 		$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
 		$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
 		$parameters['content'] = empty($content) ? $_SERVER["PHP_SELF"] : $content;
 		$parameters['content'] = empty($content) ? $_SERVER["PHP_SELF"] : $content;
-		$database = new database;
 		$content_result = $database->select($sql, $parameters, 'all');
 		$content_result = $database->select($sql, $parameters, 'all');
 		if (is_array($content_result) && @sizeof($content_result) != 0) {
 		if (is_array($content_result) && @sizeof($content_result) != 0) {
 			foreach($content_result as $content_row) {
 			foreach($content_result as $content_row) {
@@ -145,4 +147,4 @@
 		require_once("app/translate/translate_header.php");
 		require_once("app/translate/translate_header.php");
 	}
 	}
 
 
-?>
+?>