Fix all PHP 8.1 messages for upgrade.php

This commit is contained in:
markjcrane
2023-05-17 10:07:49 -06:00
parent 6816921f47
commit 6d7e125743
22 changed files with 215 additions and 152 deletions

View File

@@ -25,7 +25,7 @@
*/
//if the recordings directory doesn't exist then create it
if (is_array($_SESSION['switch']['recordings']) && !empty($_SESSION['switch']['recordings']['dir']."/".$domain_name)) {
if (!empty($_SESSION['switch']['recordings']) && !empty($_SESSION['switch']['recordings']['dir']."/".$domain_name)) {
if (!is_readable($_SESSION['switch']['recordings']['dir']."/".$domain_name)) {
mkdir($_SESSION['switch']['recordings']['dir']."/".$domain_name, 0770, true);
}
@@ -35,7 +35,7 @@
if ($domains_processed == 1) {
//if base64, populate from existing recording files, then remove
if (is_array($_SESSION['recordings']['storage_type']) && $_SESSION['recordings']['storage_type']['text'] == 'base64') {
if (!empty($_SESSION['recordings']['storage_type']) && $_SESSION['recordings']['storage_type']['text'] == 'base64') {
//get recordings without base64 in db
$sql = "select recording_uuid, domain_uuid, recording_filename ";
$sql .= "from v_recordings ";
@@ -45,11 +45,14 @@
$result = $database->select($sql, null, 'all');
if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as &$row) {
$recording_uuid = $row['recording_uuid'];
$recording_domain_uuid = $row['domain_uuid'];
$recording_filename = $row['recording_filename'];
//set the variables
$recording_uuid = $row['recording_uuid'];
$recording_domain_uuid = $row['domain_uuid'];
$recording_filename = $row['recording_filename'];
//set recording directory
$recording_directory = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name;
//encode recording file (if exists)
if (file_exists($recording_directory.'/'.$recording_filename)) {
//build array
@@ -76,41 +79,49 @@
unset($sql, $result, $row);
}
//if not base64, decode to local files, remove base64 data from db
else if (is_array($_SESSION['recordings']['storage_type']) && $_SESSION['recordings']['storage_type']['text'] != 'base64') {
else if (!empty($_SESSION['recordings']['storage_type']) && $_SESSION['recordings']['storage_type']['text'] != 'base64') {
//get recordings with base64 in db
$sql = "select recording_uuid, domain_uuid, recording_filename, recording_base64 ";
$sql .= "from v_recordings ";
$sql .= "where recording_base64 is not null ";
$database = new database;
$result = $database->select($sql, null, 'all');
if (is_array($result) && @sizeof($result) != 0) {
if (!empty($result)) {
foreach ($result as &$row) {
$recording_uuid = $row['recording_uuid'];
$recording_domain_uuid = $row['domain_uuid'];
$recording_filename = $row['recording_filename'];
$recording_base64 = $row['recording_base64'];
//set the variables
$recording_uuid = $row['recording_uuid'];
$recording_domain_uuid = $row['domain_uuid'];
$recording_filename = $row['recording_filename'];
$recording_base64 = $row['recording_base64'];
//set recording directory
$recording_directory = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name;
//remove local file, if any
if (file_exists($recording_directory.'/'.$recording_filename)) {
@unlink($recording_directory.'/'.$recording_filename);
}
//decode base64, save to local file
$recording_decoded = base64_decode($recording_base64);
file_put_contents($recording_directory.'/'.$recording_filename, $recording_decoded);
//build array
$array['recordings'][0]['recording_uuid'] = $recording_uuid;
$array['recordings'][0]['domain_uuid'] = $recording_domain_uuid;
$array['recordings'][0]['recording_base64'] = null;
//grant temporary permissions
$p = new permissions;
$p->add('recording_edit', 'temp');
//update recording record
$database = new database;
$database->app_name = 'recordings';
$database->app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
$database->save($array, false);
unset($array);
//revoke temporary permissions
$p->delete('recording_edit', 'temp');
}