diff --git a/app/voicemail_greetings/app_config.php b/app/voicemail_greetings/app_config.php index 278703529f..22491de008 100644 --- a/app/voicemail_greetings/app_config.php +++ b/app/voicemail_greetings/app_config.php @@ -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"; diff --git a/app/voicemail_greetings/app_defaults.php b/app/voicemail_greetings/app_defaults.php index 369030e94f..a5966cb23e 100644 --- a/app/voicemail_greetings/app_defaults.php +++ b/app/voicemail_greetings/app_defaults.php @@ -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 "; diff --git a/app/voicemail_greetings/resources/classes/voicemail_greetings.php b/app/voicemail_greetings/resources/classes/voicemail_greetings.php index d872bfeac8..b8ae36fb28 100644 --- a/app/voicemail_greetings/resources/classes/voicemail_greetings.php +++ b/app/voicemail_greetings/resources/classes/voicemail_greetings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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']; diff --git a/app/voicemail_greetings/voicemail_greeting_edit.php b/app/voicemail_greetings/voicemail_greeting_edit.php index d9be9a7639..8c0c189bee 100644 --- a/app/voicemail_greetings/voicemail_greeting_edit.php +++ b/app/voicemail_greetings/voicemail_greeting_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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 "; diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php index 34ee972198..efb1eb66bc 100644 --- a/app/voicemail_greetings/voicemail_greetings.php +++ b/app/voicemail_greetings/voicemail_greetings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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 ""; } 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 " \n"; echo "
\n"; @@ -383,7 +387,7 @@ $col_count = 0; if (permission_exists('voicemail_greeting_delete')) { echo " \n"; - echo " \n"; + echo " \n"; echo " \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 "".$text['label-size']."\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 "".$text['label-uploaded']."\n"; $col_count++; } @@ -427,7 +431,7 @@ echo "\n"; if (permission_exists('voicemail_greeting_delete')) { echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; } @@ -444,7 +448,7 @@ echo escape($row['greeting_name']); } echo " \n"; - if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { + if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { echo " ".escape($row['greeting_filename'])."\n"; } if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) { @@ -466,7 +470,7 @@ } echo " \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 " ".$file_size."\n"; } @@ -477,7 +481,7 @@ echo " ".$file_date."\n"; } echo " ".escape($row['greeting_description'])." \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 " "; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo " \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); } -?> +?> \ No newline at end of file