mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-05 03:03:49 +00:00
* Passing null to parameter #2 ($string) of type string is deprecated * Passing null to parameter #1 ($string) of type string is deprecated * php 8.1 fixes * php 8.1 fixes - replace strlen($var) > 0 with !empty($var) * php 8.1 fixes - replace ${var} with {$var} * php 8.1 fixes - replace ${var} with {$var} * php 8.1 fixes - replace ${var} with {$var} * php 8.1 fixes - replace ${var} with {$var} * php 8.1 fixes - strlower with null * php 8.1 fixes - strreplace with null * php 8.1 fixes - passing null to base64_decode * php 8.1 fixes - check for false and check for null on $this->dir * php 8.1 fixes - remove assignment of $db variable to modules object * php 8.1 fixes - avoid sending null to substr * php 8.1 fixes - change ${var} to {$var} * php 8.1 fixes - check for null before preg_replace * php 8.1 fixes - remove setting db variable on domains object * php 8.1 fixes - set empty string if $row['domain_setting_subcategory'] is null * php 8.1 fixes - set empty string if $_REQUEST['show'] is not available * php 8.1 fixes * php 8.1 fixes - correct $_POST checking syntax * php 8.1 fixes - correct $_POST variables * php 8.1 fixes * Use brackets consistently * Update user_setting_edit.php * Change to not empty * Update device.php * Update text.php --------- Co-authored-by: Tim Fry <tim@voipstratus.com> Co-authored-by: FusionPBX <markjcrane@gmail.com>
123 lines
5.1 KiB
PHP
123 lines
5.1 KiB
PHP
<?php
|
|
/*
|
|
FusionPBX
|
|
Version: MPL 1.1
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
the License. You may obtain a copy of the License at
|
|
http://www.mozilla.org/MPL/
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
for the specific language governing rights and limitations under the
|
|
License.
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
The Initial Developer of the Original Code is
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2016
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
Contributor(s):
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
*/
|
|
|
|
//if the recordings directory doesn't exist then create it
|
|
if (is_array($_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);
|
|
}
|
|
}
|
|
|
|
//process one time
|
|
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') {
|
|
//get recordings without base64 in db
|
|
$sql = "select recording_uuid, domain_uuid, recording_filename ";
|
|
$sql .= "from v_recordings ";
|
|
$sql .= "where recording_base64 is null ";
|
|
$sql .= "or recording_base64 = '' ";
|
|
$database = new database;
|
|
$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 recording directory
|
|
$recording_directory = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name;
|
|
//encode recording file (if exists)
|
|
if (file_exists($recording_directory.'/'.$recording_filename)) {
|
|
//build array
|
|
$recording_base64 = base64_encode(file_get_contents($recording_directory.'/'.$recording_filename));
|
|
$array['recordings'][0]['recording_uuid'] = $recording_uuid;
|
|
$array['recordings'][0]['domain_uuid'] = $recording_domain_uuid;
|
|
$array['recordings'][0]['recording_base64'] = $recording_base64;
|
|
//grant temporary permissions
|
|
$p = new permissions;
|
|
$p->add('recording_edit', 'temp');
|
|
//update recording record with base64
|
|
$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');
|
|
//remove local recording file
|
|
@unlink($recording_directory.'/'.$recording_filename);
|
|
}
|
|
}
|
|
}
|
|
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') {
|
|
//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) {
|
|
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 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');
|
|
}
|
|
}
|
|
unset($sql, $result, $row);
|
|
}
|
|
}
|
|
|
|
?>
|