MOH: Updates for PHP 8.1
This commit is contained in:
parent
2a2a705f6a
commit
1e391aad4f
|
|
@ -123,13 +123,9 @@
|
||||||
|
|
||||||
//download the file
|
//download the file
|
||||||
if (file_exists($stream_full_path)) {
|
if (file_exists($stream_full_path)) {
|
||||||
//content-range
|
|
||||||
if (isset($_SERVER['HTTP_RANGE']) && $_GET['t'] != "bin") {
|
|
||||||
range_download($stream_full_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$fd = fopen($stream_full_path, "rb");
|
$fd = fopen($stream_full_path, "rb");
|
||||||
if ($_GET['t'] == "bin") {
|
if (!empty($_GET['t']) && $_GET['t'] == "bin") {
|
||||||
header("Content-Type: application/force-download");
|
header("Content-Type: application/force-download");
|
||||||
header("Content-Type: application/octet-stream");
|
header("Content-Type: application/octet-stream");
|
||||||
header("Content-Type: application/download");
|
header("Content-Type: application/download");
|
||||||
|
|
@ -146,10 +142,16 @@
|
||||||
header('Content-Disposition: attachment; filename="'.$stream_file.'"');
|
header('Content-Disposition: attachment; filename="'.$stream_file.'"');
|
||||||
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
||||||
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||||
if ($_GET['t'] == "bin") {
|
if (!empty($_GET['t']) && $_GET['t'] == "bin") {
|
||||||
header("Content-Length: ".filesize($stream_full_path));
|
header("Content-Length: ".filesize($stream_full_path));
|
||||||
}
|
}
|
||||||
ob_clean();
|
ob_clean();
|
||||||
|
|
||||||
|
//content-range
|
||||||
|
if (isset($_SERVER['HTTP_RANGE']) && (empty($_GET['t']) || $_GET['t'] != "bin")) {
|
||||||
|
range_download($stream_full_path);
|
||||||
|
}
|
||||||
|
|
||||||
fpassthru($fd);
|
fpassthru($fd);
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
|
|
@ -659,7 +661,7 @@
|
||||||
// If the range starts with an '-' we start from the beginning
|
// If the range starts with an '-' we start from the beginning
|
||||||
// If not, we forward the file pointer
|
// If not, we forward the file pointer
|
||||||
// And make sure to get the end byte if spesified
|
// And make sure to get the end byte if spesified
|
||||||
if ($range0 == '-') {
|
if (!empty($range0) && $range0 == '-') {
|
||||||
// The n-number of the last bytes is requested
|
// The n-number of the last bytes is requested
|
||||||
$c_start = $size - substr($range, 1);
|
$c_start = $size - substr($range, 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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) 2010-2019
|
Portions created by the Initial Developer are Copyright (C) 2010-2023
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
|
|
@ -336,13 +336,14 @@ if (!class_exists('switch_music_on_hold')) {
|
||||||
if (is_array($records) && @sizeof($records) != 0) {
|
if (is_array($records) && @sizeof($records) != 0) {
|
||||||
|
|
||||||
//filter checked records
|
//filter checked records
|
||||||
|
// view_array($records, 0);
|
||||||
foreach ($records as $music_on_hold_uuid => $record) {
|
foreach ($records as $music_on_hold_uuid => $record) {
|
||||||
if (is_uuid($music_on_hold_uuid)) {
|
if (is_uuid($music_on_hold_uuid)) {
|
||||||
if ($record['checked'] == 'true') {
|
if ($record['checked'] == 'true') {
|
||||||
$moh[$music_on_hold_uuid]['delete'] = true;
|
$moh[$music_on_hold_uuid]['delete'] = true;
|
||||||
}
|
}
|
||||||
foreach ($record as $key => $array) {
|
foreach ($record as $key => $array) {
|
||||||
if (is_numeric($key) && is_array($array) && @sizeof($array) != 0 && $array['checked'] == 'true') {
|
if (is_numeric($key) && is_array($array) && @sizeof($array) != 0 && !empty($array['checked']) && $array['checked'] == 'true') {
|
||||||
$moh[$music_on_hold_uuid][] = $array['file_name'];
|
$moh[$music_on_hold_uuid][] = $array['file_name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,6 +371,7 @@ if (!class_exists('switch_music_on_hold')) {
|
||||||
|
|
||||||
//delete files, folders, build delete array
|
//delete files, folders, build delete array
|
||||||
$x = 0;
|
$x = 0;
|
||||||
|
// view_array($moh);
|
||||||
foreach ($moh as $music_on_hold_uuid => $row) {
|
foreach ($moh as $music_on_hold_uuid => $row) {
|
||||||
|
|
||||||
//prepare path
|
//prepare path
|
||||||
|
|
@ -387,7 +389,7 @@ if (!class_exists('switch_music_on_hold')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete name rate
|
//delete name rate
|
||||||
if ($row['delete']) {
|
if (!empty($row['delete']) && $row['delete'] == true) {
|
||||||
|
|
||||||
//build delete array
|
//build delete array
|
||||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $music_on_hold_uuid;
|
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $music_on_hold_uuid;
|
||||||
|
|
@ -411,7 +413,7 @@ if (!class_exists('switch_music_on_hold')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete the moh records
|
//delete the moh records
|
||||||
if (is_array($array) && @sizeof($array) != 0) {
|
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
|
||||||
|
|
||||||
//execute delete
|
//execute delete
|
||||||
$database = new database;
|
$database = new database;
|
||||||
|
|
@ -427,7 +429,7 @@ if (!class_exists('switch_music_on_hold')) {
|
||||||
unset($records, $moh);
|
unset($records, $moh);
|
||||||
|
|
||||||
//post delete
|
//post delete
|
||||||
if ($moh_deleted || $files_deleted) {
|
if ((!empty($moh_deleted) && $moh_deleted == true) || $files_deleted != 0) {
|
||||||
//clear the cache
|
//clear the cache
|
||||||
$cache = new cache;
|
$cache = new cache;
|
||||||
$cache->delete("configuration:local_stream.conf");
|
$cache->delete("configuration:local_stream.conf");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue