Gateways [Class]: Updates for PHP 8.1

This commit is contained in:
fusionate
2023-05-17 21:00:49 +00:00
parent c3018b6ae2
commit 662d6e71de

View File

@@ -76,17 +76,17 @@ if (!class_exists('gateways')) {
}
//start the checked gateways
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
//filter out unchecked gateways, build where clause for below
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']."'";
}
}
//get necessary gateway details
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, gateway, profile, enabled from v_".$this->table." ";
if (permission_exists('gateway_all')) {
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
@@ -97,8 +97,8 @@ if (!class_exists('gateways')) {
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$rows = $database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['name'] = $row['gateway'];
$gateways[$row['uuid']]['profile'] = $row['profile'];
@@ -108,7 +108,7 @@ if (!class_exists('gateways')) {
unset($sql, $parameters, $rows, $row);
}
if (is_array($gateways) && @sizeof($gateways) != 0) {
if (!empty($gateways) && is_array($gateways) && @sizeof($gateways) != 0) {
//create the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
@@ -131,7 +131,7 @@ if (!class_exists('gateways')) {
}
//set message
if (is_array($responses) && @sizeof($responses) != 0) {
if (!empty($responses) && is_array($responses) && @sizeof($responses) != 0) {
$message = $text['message-gateway_started'];
foreach ($responses as $response) {
$message .= "<br><strong>".$response['gateway']."</strong>: ".$response['message'];
@@ -164,17 +164,17 @@ if (!class_exists('gateways')) {
}
//stop the checked gateways
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
//filter out unchecked gateways, build where clause for below
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']."'";
}
}
//get necessary gateway details
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, gateway, profile, enabled from v_".$this->table." ";
if (permission_exists('gateway_all')) {
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
@@ -185,7 +185,7 @@ if (!class_exists('gateways')) {
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['name'] = $row['gateway'];
@@ -196,7 +196,7 @@ if (!class_exists('gateways')) {
unset($sql, $parameters, $rows, $row);
}
if (is_array($gateways) && @sizeof($gateways) != 0) {
if (!empty($gateways) && is_array($gateways) && @sizeof($gateways) != 0) {
//create the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
@@ -209,7 +209,7 @@ if (!class_exists('gateways')) {
}
}
//set message
if (is_array($responses) && @sizeof($responses) != 0) {
if (!empty($responses) && is_array($responses) && @sizeof($responses) != 0) {
$message = $text['message-gateway_stopped'];
foreach ($responses as $response) {
$message .= "<br><strong>".$response['gateway']."</strong>: ".$response['message'];
@@ -242,17 +242,17 @@ if (!class_exists('gateways')) {
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
//filter out unchecked gateways, build where clause for below
foreach ($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//get necessary gateway details
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, gateway, profile from v_".$this->table." ";
if (permission_exists('gateway_all')) {
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
@@ -263,8 +263,8 @@ if (!class_exists('gateways')) {
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$rows = $database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['name'] = $row['gateway'];
$gateways[$row['uuid']]['profile'] = $row['profile'];
@@ -274,7 +274,7 @@ if (!class_exists('gateways')) {
}
//create the event socket connection
if (!$fp) {
if (!isset($fp)) {
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
}
@@ -286,7 +286,7 @@ if (!class_exists('gateways')) {
unset($_SESSION['gateways'][$gateway_uuid]);
//remove the xml file (if any)
if ($_SESSION['switch']['sip_profiles']['dir'] != '') {
if (!empty($_SESSION['switch']['sip_profiles']['dir'])) {
$gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir']."/".$gateway['profile']."/v_".$gateway_uuid.".xml";
if (file_exists($gateway_xml_file)) {
unlink($gateway_xml_file);
@@ -307,7 +307,7 @@ if (!class_exists('gateways')) {
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
@@ -382,15 +382,15 @@ if (!class_exists('gateways')) {
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
//get current toggle state
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']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as state, gateway, profile from v_".$this->table." ";
if (permission_exists('gateway_all')) {
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
@@ -401,8 +401,8 @@ if (!class_exists('gateways')) {
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$rows = $database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['state'] = $row['state'];
$gateways[$row['uuid']]['name'] = $row['gateway'];
@@ -421,7 +421,7 @@ if (!class_exists('gateways')) {
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
@@ -439,7 +439,7 @@ if (!class_exists('gateways')) {
unset($_SESSION['gateways'][$gateway_uuid]);
//remove the xml file (if any)
if ($_SESSION['switch']['sip_profiles']['dir'] != '') {
if (!empty($_SESSION['switch']['sip_profiles']['dir'])) {
$gateway_xml_file = $_SESSION['switch']['sip_profiles']['dir']."/".$gateway['profile']."/v_".$gateway_uuid.".xml";
if (file_exists($gateway_xml_file)) {
unlink($gateway_xml_file);
@@ -513,17 +513,17 @@ if (!class_exists('gateways')) {
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
//get checked records
foreach($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
foreach ($records as $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//create insert array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
if (permission_exists('gateway_all')) {
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
@@ -534,8 +534,8 @@ if (!class_exists('gateways')) {
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$rows = $database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
$primary_uuid = uuid();
@@ -565,7 +565,7 @@ if (!class_exists('gateways')) {
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
@@ -575,7 +575,7 @@ if (!class_exists('gateways')) {
unset($array);
//add new gateways to session variables
if (is_array($gateways) && @sizeof($gateways) != 0) {
if (!empty($gateways) && is_array($gateways) && @sizeof($gateways) != 0) {
foreach ($gateways as $gateway_uuid => $gateway) {
$_SESSION['gateways'][$gateway_uuid] = $gateway['name'];
}
@@ -603,4 +603,4 @@ if (!class_exists('gateways')) {
}
}
?>
?>