Call Recordings: Updates for PHP 8.1

This commit is contained in:
fusionate 2023-06-02 18:26:50 +00:00
parent bc322e5cd6
commit 358c36ef2b
No known key found for this signature in database
2 changed files with 47 additions and 22 deletions

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018 - 2022
Portions created by the Initial Developer are Copyright (C) 2018 - 2023
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -190,9 +190,9 @@
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.($search ? "&search=".urlencode($search) : null)]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','collapse'=>'hide-xs']);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>($search == '' ? 'display: none;' : null),'collapse'=>'hide-xs']);
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=\"$('#btn_reset').hide(); $('#btn_search').show();\">";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>(empty($search) ? 'display: none;' : null),'collapse'=>'hide-xs']);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
@ -214,13 +214,13 @@
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
$col_count = 7;
$col_count = 8;
if ($show == "all" && permission_exists('call_recording_all')) {
$col_count++;
}
if (permission_exists('call_recording_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($call_recordings ?: "style='visibility: hidden;'").">\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($call_recordings) ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
$col_count++;
}

View File

@ -1,4 +1,28 @@
<?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) 2018 - 2023
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
/**
* call_recordings class
@ -57,7 +81,7 @@ if (!class_exists('call_recordings')) {
$x = 0;
foreach ($records as $record) {
//add to the array
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
//get the information to delete
$sql = "select call_recording_name, call_recording_path ";
$sql .= "from view_call_recordings ";
@ -118,7 +142,7 @@ if (!class_exists('call_recordings')) {
//get call recording from database
if (is_uuid($this->recording_uuid)) {
$sql = "select call_recording_name, call_recording_path ";
if ($_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') {
if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') {
$sql = ", call_recording_base64 ";
}
$sql .= "from view_call_recordings ";
@ -129,7 +153,7 @@ if (!class_exists('call_recordings')) {
if (is_array($row) && @sizeof($row) != 0) {
$call_recording_name = $row['call_recording_name'];
$call_recording_path = $row['call_recording_path'];
if ($_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') {
if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') {
file_put_contents($path.'/'.$call_recording_name, base64_decode($row['call_recording_base64']));
}
}
@ -137,18 +161,14 @@ if (!class_exists('call_recordings')) {
}
//set the path for the directory
$default_path = $_SESSION['switch']['call_recordings']['dir']."/".$_SESSION['domain_name'];
// $default_path = $_SESSION['switch']['call_recordings']['dir']."/".$_SESSION['domain_name'];
//build full path
$full_recording_path = $call_recording_path.'/'.$call_recording_name;
//download the file
if (file_exists($full_recording_path)) {
//content-range
if (isset($_SERVER['HTTP_RANGE']) && !$this->binary) {
$this->range_download($full_recording_path);
}
ob_clean();
if ($full_recording_path != '/' && file_exists($full_recording_path)) {
// ob_clean();
$fd = fopen($full_recording_path, "rb");
if ($this->binary) {
header("Content-Type: application/force-download");
@ -170,12 +190,17 @@ if (!class_exists('call_recordings')) {
if ($this->binary) {
header("Content-Length: ".filesize($full_recording_path));
}
ob_clean();
fpassthru($fd);
// ob_clean();
// fpassthru($fd);
//content-range
if (isset($_SERVER['HTTP_RANGE']) && !$this->binary) {
$this->range_download($full_recording_path);
}
}
//if base64, remove temp recording file
if ($_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') {
if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') {
@unlink($full_recording_path);
}
}
@ -204,7 +229,7 @@ if (!class_exists('call_recordings')) {
* (mediatype = mimetype)
* as well as a boundry header to indicate the various chunks of data.
*/
header("Accept-Ranges: 0-$length");
header("Accept-Ranges: 0-".$length);
// header('Accept-Ranges: bytes');
// multipart/byteranges
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
@ -227,7 +252,7 @@ if (!class_exists('call_recordings')) {
// If the range starts with an '-' we start from the beginning
// If not, we forward the file pointer
// And make sure to get the end byte if spesified
if ($range0 == '-') {
if ($range[0] == '-') {
// The n-number of the last bytes is requested
$c_start = $size - substr($range, 1);
}
@ -278,4 +303,4 @@ if (!class_exists('call_recordings')) {
} //class
}
?>
?>