Переглянути джерело

Unset the prepared statements used in the app_defaults.php files.

Mark Crane 11 роки тому
батько
коміт
890f82a086

+ 3 - 0
core/databases/app_defaults.php

@@ -49,6 +49,7 @@ if ($domains_processed == 1) {
 			$db->exec(check_sql($sql));
 			unset($sql);
 		}
+		unset($prep_statement, $result);
 
 	//replace the backslash with a forward slash
 		$db_path = str_replace("\\", "/", $db_path);
@@ -62,6 +63,7 @@ if ($domains_processed == 1) {
 			if ($prep_statement) {
 				$prep_statement->execute();
 				$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
+				unset($prep_statement);
 				if ($row['num_rows'] > 0) {
 					$odbc_num_rows = $row['num_rows'];
 
@@ -95,6 +97,7 @@ if ($domains_processed == 1) {
 				foreach ($result as &$row) {
 					$recordings_dir = $row["default_setting_value"];
 				}
+				unset($prep_statement, $result);
 			}
 
 		//config.lua

+ 2 - 0
core/default_settings/app_defaults.php

@@ -60,6 +60,7 @@ if ($domains_processed == 1) {
 				$db->exec(check_sql($sql));
 				unset($sql);
 			}
+			unset($prep_statement, $row);
 		}
 
 	//ensure that the default password length and strength are set
@@ -109,6 +110,7 @@ if ($domains_processed == 1) {
 				$db->exec(check_sql($sql));
 				unset($sql);
 			}
+			unset($prep_statement, $row);
 		}
 
 //set the sip_profiles directory for older installs

+ 1 - 0
core/menu/app_defaults.php

@@ -116,6 +116,7 @@
 						}
 				}
 		}
+		unset($prep_statement);
 	}
 
 ?>

+ 1 - 0
core/notifications/app_defaults.php

@@ -47,6 +47,7 @@ if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
 					$db->exec(check_sql($sql));
 					unset($sql);
 				}
+				unset($prep_statement, $row);
 			}
 	}
 }

+ 3 - 1
core/upgrade/app_defaults.php

@@ -73,6 +73,7 @@ if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
 					$db->exec(check_sql($sql));
 					unset($sql);
 				}
+				unset($prep_statement, $row);
 			}
 
 		//ensure the login message is set, if new message exists
@@ -84,6 +85,7 @@ if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
 			if ($prep_statement) {
 				$prep_statement->execute();
 				$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
+				unset($prep_statement);
 				if ($row['num_rows'] == 0) {
 
 					// insert message
@@ -141,8 +143,8 @@ if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
 								unset($sql);
 							}
 						}
+						unset($prep_statement, $result);
 					}
-					unset($sql, $result);
 				}
 			}
 

+ 33 - 32
core/users/app_defaults.php

@@ -76,8 +76,8 @@
 				}
 			}
 		}
+		unset($prep_statement, $sub_result);
 	}
-	unset($prep_statement, $sub_result);
 
 //if there are no permissions listed in v_group_permissions then set the default permissions
 	$sql = "select count(*) as count from v_group_permissions ";
@@ -129,13 +129,38 @@
 	$sql .= "and user_uuid is null; ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	if ($prep_statement) {
-			$prep_statement->execute();
-			$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
-			foreach($result as $row) {
-				if (strlen($row['username']) > 0) {
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach($result as $row) {
+			if (strlen($row['username']) > 0) {
+				//get the user_uuid
+					$sql = "select user_uuid from v_users ";
+					$sql .= "where username = '".$row['username']."' ";
+					$sql .= "and user_enabled = 'true' ";
+					$prep_statement_sub = $db->prepare($sql);
+					$prep_statement_sub->execute();
+					$sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC);
+					unset ($prep_statement_sub);
+					$user_uuid = $sub_result['user_uuid'];
+				//set the user uuid
+					$sql = "update v_group_users set ";
+					$sql .= "user_uuid = '".$user_uuid."' ";
+					$sql .= "where username = '".$row['username']."'; ";
+					$db->exec($sql);
+					unset($sql);
+			}
+			else {
+				//get the number of users
+					$sql = "select count(*) as num_rows from v_users ";
+					$sql .= "where user_enabled = 'true' ";
+					$prep_statement_sub = $db->prepare($sql);
+					$prep_statement_sub->execute();
+					$sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC);
+					unset ($prep_statement_sub);
+					$num_rows = $sub_result['num_rows'];
+				if ($num_rows == 1) {
 					//get the user_uuid
 						$sql = "select user_uuid from v_users ";
-						$sql .= "where username = '".$row['username']."' ";
 						$sql .= "and user_enabled = 'true' ";
 						$prep_statement_sub = $db->prepare($sql);
 						$prep_statement_sub->execute();
@@ -145,36 +170,12 @@
 					//set the user uuid
 						$sql = "update v_group_users set ";
 						$sql .= "user_uuid = '".$user_uuid."' ";
-						$sql .= "where username = '".$row['username']."'; ";
 						$db->exec($sql);
 						unset($sql);
 				}
-				else {
-					//get the number of users
-						$sql = "select count(*) as num_rows from v_users ";
-						$sql .= "where user_enabled = 'true' ";
-						$prep_statement_sub = $db->prepare($sql);
-						$prep_statement_sub->execute();
-						$sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC);
-						unset ($prep_statement_sub);
-						$num_rows = $sub_result['num_rows'];
-					if ($num_rows == 1) {
-						//get the user_uuid
-							$sql = "select user_uuid from v_users ";
-							$sql .= "and user_enabled = 'true' ";
-							$prep_statement_sub = $db->prepare($sql);
-							$prep_statement_sub->execute();
-							$sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC);
-							unset ($prep_statement_sub);
-							$user_uuid = $sub_result['user_uuid'];
-						//set the user uuid
-							$sql = "update v_group_users set ";
-							$sql .= "user_uuid = '".$user_uuid."' ";
-							$db->exec($sql);
-							unset($sql);
-					}
-				}
 			}
+		}
+		unset ($prep_statement);
 	}
 
 //if there are no permissions listed in v_group_permissions then set the default permissions