Update recordings.php
This commit is contained in:
parent
7429453f7e
commit
7153383535
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Portions created by the Initial Developer are Copyright (C) 2008-2016
|
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
||||||
the Initial Developer. All Rights Reserved.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
|
|
@ -146,8 +146,8 @@
|
||||||
message::add($text['message-uploaded'].": ".htmlentities($recording_filename));
|
message::add($text['message-uploaded'].": ".htmlentities($recording_filename));
|
||||||
|
|
||||||
//set the file name to be inserted as the recording description
|
//set the file name to be inserted as the recording description
|
||||||
$recording_description = base64_encode($_FILES['ulfile']['name']);
|
$recording_description = $_FILES['ulfile']['name'];
|
||||||
header("Location: recordings.php?rd=".$recording_description);
|
header("Location: recordings.php?rd=".urlencode($recording_description));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@
|
||||||
//file not found in db, add it
|
//file not found in db, add it
|
||||||
$recording_uuid = uuid();
|
$recording_uuid = uuid();
|
||||||
$recording_name = ucwords(str_replace('_', ' ', pathinfo($recording_filename, PATHINFO_FILENAME)));
|
$recording_name = ucwords(str_replace('_', ' ', pathinfo($recording_filename, PATHINFO_FILENAME)));
|
||||||
$recording_description = base64_decode($_GET['rd']);
|
$recording_description = $_GET['rd'];
|
||||||
//build array
|
//build array
|
||||||
$array['recordings'][0]['domain_uuid'] = $domain_uuid;
|
$array['recordings'][0]['domain_uuid'] = $domain_uuid;
|
||||||
$array['recordings'][0]['recording_uuid'] = $recording_uuid;
|
$array['recordings'][0]['recording_uuid'] = $recording_uuid;
|
||||||
|
|
@ -278,7 +278,7 @@
|
||||||
|
|
||||||
//prepare to page the results
|
//prepare to page the results
|
||||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||||
$param = "&order_by=".$order_by."&order=".$order;
|
$param = "&order_by=".urlencode($order_by)."&order=".urlencode($order);
|
||||||
$page = $_GET['page'];
|
$page = $_GET['page'];
|
||||||
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
||||||
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
|
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
|
||||||
|
|
@ -363,11 +363,11 @@
|
||||||
case "mp3" : $recording_type = "audio/mpeg"; break;
|
case "mp3" : $recording_type = "audio/mpeg"; break;
|
||||||
case "ogg" : $recording_type = "audio/ogg"; break;
|
case "ogg" : $recording_type = "audio/ogg"; break;
|
||||||
}
|
}
|
||||||
echo "<audio id='recording_audio_".escape($row['recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['recording_uuid'])."')\" onended=\"recording_reset('".escape($row['recording_uuid'])."');\" src=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&id=".escape($row['recording_uuid'])."\" type='".$recording_type."'></audio>";
|
echo "<audio id='recording_audio_".escape($row['recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['recording_uuid'])."')\" onended=\"recording_reset('".escape($row['recording_uuid'])."');\" src=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&id=".urlencode($row['recording_uuid'])."\" type='".$recording_type."'></audio>";
|
||||||
echo "<span id='recording_button_".escape($row['recording_uuid'])."' onclick=\"recording_play('".escape($row['recording_uuid'])."')\" title='".$text['label-play']." / ".$text['label-pause']."'>".$v_link_label_play."</span>";
|
echo "<span id='recording_button_".escape($row['recording_uuid'])."' onclick=\"recording_play('".escape($row['recording_uuid'])."')\" title='".$text['label-play']." / ".$text['label-pause']."'>".$v_link_label_play."</span>";
|
||||||
}
|
}
|
||||||
if (permission_exists('recording_download')) {
|
if (permission_exists('recording_download')) {
|
||||||
echo "<a href=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&t=bin&id=".escape($row['recording_uuid'])."\" title='".$text['label-download']."'>".$v_link_label_download."</a>";
|
echo "<a href=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&t=bin&id=".urlencode($row['recording_uuid'])."\" title='".$text['label-download']."'>".$v_link_label_download."</a>";
|
||||||
}
|
}
|
||||||
echo " </td>\n";
|
echo " </td>\n";
|
||||||
}
|
}
|
||||||
|
|
@ -410,97 +410,95 @@
|
||||||
//include the footer
|
//include the footer
|
||||||
require_once "resources/footer.php";
|
require_once "resources/footer.php";
|
||||||
|
|
||||||
|
//define the download function
|
||||||
|
function range_download($file) {
|
||||||
|
$fp = @fopen($file, 'rb');
|
||||||
|
|
||||||
function range_download($file) {
|
$size = filesize($file); // File size
|
||||||
$fp = @fopen($file, 'rb');
|
$length = $size; // Content length
|
||||||
|
$start = 0; // Start byte
|
||||||
$size = filesize($file); // File size
|
$end = $size - 1; // End byte
|
||||||
$length = $size; // Content length
|
// Now that we've gotten so far without errors we send the accept range header
|
||||||
$start = 0; // Start byte
|
/* At the moment we only support single ranges.
|
||||||
$end = $size - 1; // End byte
|
* Multiple ranges requires some more work to ensure it works correctly
|
||||||
// Now that we've gotten so far without errors we send the accept range header
|
* and comply with the spesifications: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
|
||||||
/* At the moment we only support single ranges.
|
*
|
||||||
* Multiple ranges requires some more work to ensure it works correctly
|
* Multirange support annouces itself with:
|
||||||
* and comply with the spesifications: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
|
* header('Accept-Ranges: bytes');
|
||||||
*
|
*
|
||||||
* Multirange support annouces itself with:
|
* Multirange content must be sent with multipart/byteranges mediatype,
|
||||||
* header('Accept-Ranges: bytes');
|
* (mediatype = mimetype)
|
||||||
*
|
* as well as a boundry header to indicate the various chunks of data.
|
||||||
* Multirange content must be sent with multipart/byteranges mediatype,
|
|
||||||
* (mediatype = mimetype)
|
|
||||||
* as well as a boundry header to indicate the various chunks of data.
|
|
||||||
*/
|
|
||||||
header("Accept-Ranges: 0-$length");
|
|
||||||
// header('Accept-Ranges: bytes');
|
|
||||||
// multipart/byteranges
|
|
||||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
|
|
||||||
if (isset($_SERVER['HTTP_RANGE'])) {
|
|
||||||
|
|
||||||
$c_start = $start;
|
|
||||||
$c_end = $end;
|
|
||||||
// Extract the range string
|
|
||||||
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
|
|
||||||
// Make sure the client hasn't sent us a multibyte range
|
|
||||||
if (strpos($range, ',') !== false) {
|
|
||||||
// (?) Shoud this be issued here, or should the first
|
|
||||||
// range be used? Or should the header be ignored and
|
|
||||||
// we output the whole content?
|
|
||||||
header('HTTP/1.1 416 Requested Range Not Satisfiable');
|
|
||||||
header("Content-Range: bytes $start-$end/$size");
|
|
||||||
// (?) Echo some info to the client?
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
// 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 == '-') {
|
|
||||||
// The n-number of the last bytes is requested
|
|
||||||
$c_start = $size - substr($range, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$range = explode('-', $range);
|
|
||||||
$c_start = $range[0];
|
|
||||||
$c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
|
|
||||||
}
|
|
||||||
/* Check the range and make sure it's treated according to the specs.
|
|
||||||
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
|
||||||
*/
|
*/
|
||||||
// End bytes can not be larger than $end.
|
header("Accept-Ranges: 0-$length");
|
||||||
$c_end = ($c_end > $end) ? $end : $c_end;
|
// header('Accept-Ranges: bytes');
|
||||||
// Validate the requested range and return an error if it's not correct.
|
// multipart/byteranges
|
||||||
if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
|
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
|
||||||
|
if (isset($_SERVER['HTTP_RANGE'])) {
|
||||||
|
|
||||||
header('HTTP/1.1 416 Requested Range Not Satisfiable');
|
$c_start = $start;
|
||||||
header("Content-Range: bytes $start-$end/$size");
|
$c_end = $end;
|
||||||
// (?) Echo some info to the client?
|
// Extract the range string
|
||||||
exit;
|
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
|
||||||
|
// Make sure the client hasn't sent us a multibyte range
|
||||||
|
if (strpos($range, ',') !== false) {
|
||||||
|
// (?) Shoud this be issued here, or should the first
|
||||||
|
// range be used? Or should the header be ignored and
|
||||||
|
// we output the whole content?
|
||||||
|
header('HTTP/1.1 416 Requested Range Not Satisfiable');
|
||||||
|
header("Content-Range: bytes $start-$end/$size");
|
||||||
|
// (?) Echo some info to the client?
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
// 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 == '-') {
|
||||||
|
// The n-number of the last bytes is requested
|
||||||
|
$c_start = $size - substr($range, 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$range = explode('-', $range);
|
||||||
|
$c_start = $range[0];
|
||||||
|
$c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
|
||||||
|
}
|
||||||
|
/* Check the range and make sure it's treated according to the specs.
|
||||||
|
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||||
|
*/
|
||||||
|
// End bytes can not be larger than $end.
|
||||||
|
$c_end = ($c_end > $end) ? $end : $c_end;
|
||||||
|
// Validate the requested range and return an error if it's not correct.
|
||||||
|
if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
|
||||||
|
|
||||||
|
header('HTTP/1.1 416 Requested Range Not Satisfiable');
|
||||||
|
header("Content-Range: bytes $start-$end/$size");
|
||||||
|
// (?) Echo some info to the client?
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$start = $c_start;
|
||||||
|
$end = $c_end;
|
||||||
|
$length = $end - $start + 1; // Calculate new content length
|
||||||
|
fseek($fp, $start);
|
||||||
|
header('HTTP/1.1 206 Partial Content');
|
||||||
}
|
}
|
||||||
$start = $c_start;
|
// Notify the client the byte range we'll be outputting
|
||||||
$end = $c_end;
|
header("Content-Range: bytes $start-$end/$size");
|
||||||
$length = $end - $start + 1; // Calculate new content length
|
header("Content-Length: $length");
|
||||||
fseek($fp, $start);
|
|
||||||
header('HTTP/1.1 206 Partial Content');
|
|
||||||
}
|
|
||||||
// Notify the client the byte range we'll be outputting
|
|
||||||
header("Content-Range: bytes $start-$end/$size");
|
|
||||||
header("Content-Length: $length");
|
|
||||||
|
|
||||||
// Start buffered download
|
// Start buffered download
|
||||||
$buffer = 1024 * 8;
|
$buffer = 1024 * 8;
|
||||||
while(!feof($fp) && ($p = ftell($fp)) <= $end) {
|
while(!feof($fp) && ($p = ftell($fp)) <= $end) {
|
||||||
|
if ($p + $buffer > $end) {
|
||||||
if ($p + $buffer > $end) {
|
// In case we're only outputtin a chunk, make sure we don't
|
||||||
|
// read past the length
|
||||||
// In case we're only outputtin a chunk, make sure we don't
|
$buffer = $end - $p + 1;
|
||||||
// read past the length
|
}
|
||||||
$buffer = $end - $p + 1;
|
set_time_limit(0); // Reset time limit for big files
|
||||||
|
echo fread($fp, $buffer);
|
||||||
|
flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
|
||||||
}
|
}
|
||||||
set_time_limit(0); // Reset time limit for big files
|
|
||||||
echo fread($fp, $buffer);
|
fclose($fp);
|
||||||
flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($fp);
|
?>
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue