Voicemail Greetings: Updates for PHP 8.1
This commit is contained in:
parent
bd9a407ba5
commit
39cb1c3588
|
|
@ -30,6 +30,7 @@
|
|||
$apps[$x]['description']['uk-ua'] = "";
|
||||
|
||||
//permission details
|
||||
$y=0;
|
||||
$apps[$x]['permissions'][$y]['name'] = "voicemail_greeting_view";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "user";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "admin";
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ if ($domains_processed == 1) {
|
|||
}
|
||||
|
||||
//if not base64, decode to local files, remove base64 data from db
|
||||
else if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
else if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
//get greetings with base64 in db
|
||||
$sql = "select voicemail_greeting_uuid, domain_uuid, voicemail_id, greeting_filename, greeting_base64 ";
|
||||
$sql .= "from v_voicemail_greetings ";
|
||||
|
|
|
|||
|
|
@ -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) 2008-2019
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2023
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
@ -92,7 +92,7 @@ if (!class_exists('voicemail_greetings')) {
|
|||
|
||||
//filter out unchecked records
|
||||
foreach ($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ if (!class_exists('voicemail_greetings')) {
|
|||
$sql = "select ".$this->uuid_prefix."uuid as uuid, greeting_filename, greeting_id from v_".$this->table." ";
|
||||
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
$rows = $database->select($sql, $parameters ?? null, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$greeting_filenames[$row['uuid']] = $row['greeting_filename'];
|
||||
|
|
|
|||
|
|
@ -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) 2008-2020
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2023
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
@ -66,7 +66,7 @@ if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
|
|||
|
||||
//delete the voicemail greeting
|
||||
if (permission_exists('voicemail_greeting_delete')) {
|
||||
if ($_POST['action'] == 'delete' && is_uuid($voicemail_greeting_uuid)) {
|
||||
if (!empty($_POST['action']) && $_POST['action'] == 'delete' && is_uuid($voicemail_greeting_uuid)) {
|
||||
//prepare
|
||||
$array[0]['checked'] = 'true';
|
||||
$array[0]['uuid'] = $voicemail_greeting_uuid;
|
||||
|
|
@ -105,7 +105,7 @@ if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
|
|||
}
|
||||
|
||||
//update the database
|
||||
if ($_POST["persistformvar"] != "true" && permission_exists('voicemail_greeting_edit')) {
|
||||
if ((empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true") && permission_exists('voicemail_greeting_edit')) {
|
||||
//build update array
|
||||
$array['voicemail_greetings'][0]['voicemail_greeting_uuid'] = $voicemail_greeting_uuid;
|
||||
$array['voicemail_greetings'][0]['greeting_name'] = $greeting_name;
|
||||
|
|
@ -125,7 +125,7 @@ if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
|
|||
}
|
||||
|
||||
//pre-populate the form
|
||||
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
|
||||
if (count($_GET) > 0 && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) {
|
||||
$sql = "select * from v_voicemail_greetings ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and voicemail_greeting_uuid = :voicemail_greeting_uuid ";
|
||||
|
|
|
|||
|
|
@ -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) 2008-2022
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2023
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
$order = $_GET["order"] ?? '';
|
||||
|
||||
//set the back button url
|
||||
$_SESSION['back'][$_SERVER['PHP_SELF']] = ($_GET['back'] != '') ? urldecode($_GET['back']) : $_SESSION['back'][$_SERVER['PHP_SELF']];
|
||||
$_SESSION['back'][$_SERVER['PHP_SELF']] = !empty($_GET['back']) ? urldecode($_GET['back']) : $_SESSION['back'][$_SERVER['PHP_SELF']];
|
||||
|
||||
//define order by default
|
||||
if ($order_by == '') {
|
||||
|
|
@ -100,20 +100,16 @@
|
|||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$greeting_filename = $row['greeting_filename'];
|
||||
$greeting_id = $row['greeting_id'];
|
||||
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
|
||||
if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
|
||||
$greeting_decoded = base64_decode($row['greeting_base64']);
|
||||
file_put_contents($greeting_dir.'/'.$greeting_filename, $greeting_decoded);
|
||||
}
|
||||
}
|
||||
unset($sql, $row, $greeting_decoded);
|
||||
if (file_exists($greeting_dir.'/'.$greeting_filename)) {
|
||||
//content-range
|
||||
if (isset($_SERVER['HTTP_RANGE']) && $_GET['t'] != "bin") {
|
||||
range_download($greeting_dir.'/'.$greeting_filename);
|
||||
}
|
||||
|
||||
$fd = fopen($greeting_dir.'/'.$greeting_filename, "rb");
|
||||
if ($_GET['t'] == "bin") {
|
||||
if (!empty($_GET['t']) && $_GET['t'] == "bin") {
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Type: application/download");
|
||||
|
|
@ -130,15 +126,21 @@
|
|||
header('Content-Disposition: attachment; filename="'.$greeting_filename.'"');
|
||||
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
||||
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($greeting_dir.'/'.$greeting_filename));
|
||||
}
|
||||
ob_clean();
|
||||
|
||||
//content-range
|
||||
if (isset($_SERVER['HTTP_RANGE']) && (empty($_GET['t']) || $_GET['t'] != "bin")) {
|
||||
range_download($greeting_dir.'/'.$greeting_filename);
|
||||
}
|
||||
|
||||
fpassthru($fd);
|
||||
}
|
||||
|
||||
//if base64, remove temp greeting file (if not currently selected greeting)
|
||||
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
|
||||
if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
|
||||
if ($greeting_id != $selected_greeting_id) {
|
||||
@unlink($greeting_dir.'/'.$greeting_filename);
|
||||
}
|
||||
|
|
@ -182,7 +184,9 @@
|
|||
}
|
||||
|
||||
//move the uploaded greeting
|
||||
mkdir($greeting_dir, 0770, false);
|
||||
if (!empty($greeting_dir) && !file_exists($greeting_dir)) {
|
||||
mkdir($greeting_dir, 0770, false);
|
||||
}
|
||||
if ($file_ext == 'wav' || $file_ext == 'mp3') {
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $greeting_dir.'/'.$file_name);
|
||||
}
|
||||
|
|
@ -208,7 +212,7 @@
|
|||
$array['voicemail_greetings'][$x]['greeting_name'] = $text['label-greeting'].' '.$greeting_id;
|
||||
$array['voicemail_greetings'][$x]['greeting_filename'] = $file_name;
|
||||
$array['voicemail_greetings'][$x]['greeting_description'] = '';
|
||||
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
|
||||
if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') {
|
||||
$array['voicemail_greetings'][$x]['greeting_base64'] = base64_encode(file_get_contents($greeting_dir.'/'.$file));
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +365,7 @@
|
|||
echo "</form>";
|
||||
}
|
||||
if (permission_exists('voicemail_greeting_delete') && $greetings) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
}
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
|
|
@ -383,7 +387,7 @@
|
|||
$col_count = 0;
|
||||
if (permission_exists('voicemail_greeting_delete')) {
|
||||
echo " <th class='checkbox'>\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($greetings ?: "style='visibility: hidden;'").">\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($greetings) ? "style='visibility: hidden;'" : null).">\n";
|
||||
echo " </th>\n";
|
||||
$col_count++;
|
||||
}
|
||||
|
|
@ -393,7 +397,7 @@
|
|||
$col_count++;
|
||||
echo th_order_by('greeting_name', $text['label-name'], $order_by, $order, null, null, "id=".urlencode($voicemail_id));
|
||||
$col_count++;
|
||||
if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
echo th_order_by('greeting_filename', $text['label-filename'], $order_by, $order, null, "class='hide-sm-dn'", "id=".urlencode($voicemail_id));
|
||||
$col_count++;
|
||||
}
|
||||
|
|
@ -403,7 +407,7 @@
|
|||
}
|
||||
echo "<th class='center no-wrap hide-xs'>".$text['label-size']."</th>\n";
|
||||
$col_count++;
|
||||
if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
echo "<th class='center no-wrap hide-xs'>".$text['label-uploaded']."</th>\n";
|
||||
$col_count++;
|
||||
}
|
||||
|
|
@ -427,7 +431,7 @@
|
|||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('voicemail_greeting_delete')) {
|
||||
echo " <td class='checkbox'>\n";
|
||||
echo " <input type='checkbox' name='voicemail_greetings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
||||
echo " <input type='checkbox' name='voicemail_greetings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; } checkbox_on_change(this);\">\n";
|
||||
echo " <input type='hidden' name='voicemail_greetings[$x][uuid]' value='".escape($row['voicemail_greeting_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
|
|
@ -444,7 +448,7 @@
|
|||
echo escape($row['greeting_name']);
|
||||
}
|
||||
echo " </td>\n";
|
||||
if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
|
||||
echo " <td class='hide-sm-dn'>".escape($row['greeting_filename'])."</td>\n";
|
||||
}
|
||||
if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) {
|
||||
|
|
@ -466,7 +470,7 @@
|
|||
}
|
||||
echo " </td>\n";
|
||||
}
|
||||
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
|
||||
if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') {
|
||||
$file_size = byte_convert($row['greeting_size']);
|
||||
echo " <td class='center no-wrap hide-xs'>".$file_size."</td>\n";
|
||||
}
|
||||
|
|
@ -477,7 +481,7 @@
|
|||
echo " <td class='center no-wrap hide-xs'>".$file_date."</td>\n";
|
||||
}
|
||||
echo " <td class='description overflow hide-sm-dn'>".escape($row['greeting_description'])." </td>\n";
|
||||
if (permission_exists('voicemail_greeting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
if (permission_exists('voicemail_greeting_edit') && !empty($_SESSION['theme']['list_row_edit_button']['boolean']) && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
echo " <td class='action-button'>";
|
||||
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
|
||||
echo " </td>\n";
|
||||
|
|
@ -539,7 +543,7 @@
|
|||
// 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 (!empty($range0) && $range0 == '-') {
|
||||
// The n-number of the last bytes is requested
|
||||
$c_start = $size - substr($range, 1);
|
||||
}
|
||||
|
|
@ -587,4 +591,4 @@
|
|||
fclose($fp);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
Loading…
Reference in New Issue