Browse Source

Domains [Class]: Updates for PHP 8.1

fusionate 2 năm trước cách đây
mục cha
commit
315f7924b8
1 tập tin đã thay đổi với 31 bổ sung25 xóa
  1. 31 25
      resources/classes/domains.php

+ 31 - 25
resources/classes/domains.php

@@ -85,7 +85,7 @@ if (!class_exists('domains')) {
 							$d = 0;
 							$d = 0;
 							foreach ($records as $record) {
 							foreach ($records as $record) {
 								//add to the array
 								//add to the array
-									if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+									if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
 										//set the uuid
 										//set the uuid
 											$id = $record['uuid'];
 											$id = $record['uuid'];
 
 
@@ -202,38 +202,44 @@ if (!class_exists('domains')) {
 												}
 												}
 
 
 												//delete the gateways
 												//delete the gateways
-												if($dh = opendir($_SESSION['switch']['sip_profiles']['dir'])) {
-													$files = Array();
-													while($file = readdir($dh)) {
-														if($file != "." && $file != ".." && $file[0] != '.') {
-															if(is_dir($dir . "/" . $file)) {
-																//this is a directory do nothing
-															} else {
-																//check if file extension is xml
-																if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
-																	@unlink($_SESSION['switch']['sip_profiles']['dir']."/".$file);
+												if (!empty($_SESSION['switch']['sip_profiles']['dir'])) {
+													if ($dh = opendir($_SESSION['switch']['sip_profiles']['dir'])) {
+														$files = Array();
+														while ($file = readdir($dh)) {
+															if ($file != "." && $file != ".." && $file[0] != '.') {
+																if (is_dir($dir . "/" . $file)) {
+																	//this is a directory do nothing
+																}
+																else {
+																	//check if file extension is xml
+																	if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
+																		@unlink($_SESSION['switch']['sip_profiles']['dir']."/".$file);
+																	}
 																}
 																}
 															}
 															}
 														}
 														}
+														closedir($dh);
 													}
 													}
-													closedir($dh);
 												}
 												}
 
 
 												//delete the ivr menu
 												//delete the ivr menu
-												if($dh = opendir($_SESSION['switch']['conf']['dir']."/ivr_menus")) {
-													$files = Array();
-													while($file = readdir($dh)) {
-														if($file != "." && $file != ".." && $file[0] != '.') {
-															if(is_dir($dir . "/" . $file)) {
-																//this is a directory
-															} else {
-																if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
-																	@unlink($_SESSION['switch']['conf']['dir']."/ivr_menus/".$file);
+												if (!empty($_SESSION['switch']['conf']['dir'])) {
+													if ($dh = opendir($_SESSION['switch']['conf']['dir']."/ivr_menus")) {
+														$files = Array();
+														while ($file = readdir($dh)) {
+															if ($file != "." && $file != ".." && $file[0] != '.') {
+																if (!empty($dir) && !empty($file) && is_dir($dir."/".$file)) {
+																	//this is a directory
+																}
+																else {
+																	if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
+																		@unlink($_SESSION['switch']['conf']['dir']."/ivr_menus/".$file);
+																	}
 																}
 																}
 															}
 															}
 														}
 														}
+														closedir($dh);
 													}
 													}
-													closedir($dh);
 												}
 												}
 
 
 												//delete the recordings
 												//delete the recordings
@@ -302,7 +308,7 @@ if (!class_exists('domains')) {
 					if (is_array($records) && @sizeof($records) != 0) {
 					if (is_array($records) && @sizeof($records) != 0) {
 						//get current toggle state
 						//get current toggle state
 							foreach($records as $record) {
 							foreach($records as $record) {
-								if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+								if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
 									$uuids[] = "'".$record['uuid']."'";
 									$uuids[] = "'".$record['uuid']."'";
 								}
 								}
 							}
 							}
@@ -310,7 +316,7 @@ if (!class_exists('domains')) {
 								$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
 								$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
 								$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
 								$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
 								$database = new database;
 								$database = new database;
-								$rows = $database->select($sql, $parameters, 'all');
+								$rows = $database->select($sql, $parameters ?? null, 'all');
 								if (is_array($rows) && @sizeof($rows) != 0) {
 								if (is_array($rows) && @sizeof($rows) != 0) {
 									foreach ($rows as $row) {
 									foreach ($rows as $row) {
 										$states[$row['uuid']] = $row['toggle'];
 										$states[$row['uuid']] = $row['toggle'];
@@ -370,7 +376,7 @@ if (!class_exists('domains')) {
 
 
 						//get checked records
 						//get checked records
 							foreach($records as $record) {
 							foreach($records as $record) {
-								if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+								if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
 									$uuids[] = "'".$record['uuid']."'";
 									$uuids[] = "'".$record['uuid']."'";
 								}
 								}
 							}
 							}