diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index bef26980f9..977123e628 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -291,7 +291,7 @@ //filter out unchecked sip profiles 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']."'"; } } @@ -411,7 +411,7 @@ //filter out unchecked sip profiles foreach ($records as $x => $record) { - if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { //build the delete array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x]['voicemail_uuid'] = $this->voicemail_uuid; @@ -458,7 +458,7 @@ //filter out unchecked sip profiles foreach ($records as $x => $record) { - if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { //build the delete array $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x]['voicemail_uuid'] = $this->voicemail_uuid; @@ -507,7 +507,7 @@ //filter out unchecked sip profiles 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']."'"; } } @@ -748,7 +748,7 @@ $path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$this->voicemail_id; //prepare base64 content from db, if enabled - if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') { + if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') { $sql = "select message_base64 "; $sql .= "from "; $sql .= "v_voicemail_messages as m, "; @@ -799,11 +799,6 @@ return false; } - //content-range - if (isset($_SERVER['HTTP_RANGE']) && $this->type != 'bin') { - $this->range_download($file_path); - } - $fd = fopen($file_path, "rb"); if ($this->type == 'bin') { header("Content-Type: application/force-download"); @@ -830,10 +825,16 @@ header("Content-Length: ".filesize($file_path)); } ob_end_clean(); + + //content-range + if (isset($_SERVER['HTTP_RANGE']) && $this->type != 'bin') { + $this->range_download($file_path); + } + fpassthru($fd); //if base64, remove temp file - if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') { + if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') { @unlink($path.'/msg_'.$this->voicemail_message_uuid.'.'.$file_ext); } @@ -884,7 +885,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); } diff --git a/app/voicemails/resources/dashboard/voicemails.php b/app/voicemails/resources/dashboard/voicemails.php index 8a01522499..4206425ca5 100644 --- a/app/voicemails/resources/dashboard/voicemails.php +++ b/app/voicemails/resources/dashboard/voicemails.php @@ -120,7 +120,7 @@ if (is_uuid($voicemail_uuid)) { $tr_link = "href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php?id=".(permission_exists('voicemail_view') ? $voicemail_uuid : $row['ext'])."'"; echo ""; - echo " ".$row['ext'].""; + echo " ".$row['ext'].""; echo " ".$row['new'].""; echo " ".$row['total'].""; echo ""; diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index c5301cada3..63393e24b4 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -74,7 +74,7 @@ if (!empty($_POST)) { //process the http post data by submitted action - if ($_POST['action'] != '' && is_uuid($_POST['voicemail_uuid'])) { + if (!empty($_POST['action']) && is_uuid($_POST['voicemail_uuid'])) { $array[0]['checked'] = 'true'; $array[0]['uuid'] = $_POST['voicemail_uuid']; @@ -98,16 +98,16 @@ $voicemail_options = $_POST["voicemail_options"]; $voicemail_alternate_greet_id = $_POST["voicemail_alternate_greet_id"]; $voicemail_mail_to = $_POST["voicemail_mail_to"]; - $voicemail_sms_to = $_POST["voicemail_sms_to"]; - $voicemail_transcription_enabled = $_POST["voicemail_transcription_enabled"]; + $voicemail_sms_to = $_POST["voicemail_sms_to"] ?? null; + $voicemail_transcription_enabled = $_POST["voicemail_transcription_enabled"] ?? null; $voicemail_file = $_POST["voicemail_file"]; $voicemail_local_after_email = $_POST["voicemail_local_after_email"]; $voicemail_destination = $_POST["voicemail_destination"]; $voicemail_enabled = $_POST["voicemail_enabled"] ?? 'false'; $voicemail_description = $_POST["voicemail_description"]; $voicemail_tutorial = $_POST["voicemail_tutorial"]; - $voicemail_options_delete = $_POST["voicemail_options_delete"]; - $voicemail_destinations_delete = $_POST["voicemail_destinations_delete"]; + $voicemail_options_delete = $_POST["voicemail_options_delete"] ?? null; + $voicemail_destinations_delete = $_POST["voicemail_destinations_delete"] ?? null; //remove the space $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); @@ -211,7 +211,7 @@ $array['voicemail_options'][$x]['voicemail_option_order'] = $voicemail_option['voicemail_option_order']; $array['voicemail_options'][$x]['voicemail_option_description'] = $voicemail_option['voicemail_option_description']; } - if (is_array($array['voicemail_options']) && @sizeof($array['voicemail_options']) != 0) { + if (!empty($array['voicemail_options']) && is_array($array['voicemail_options']) && @sizeof($array['voicemail_options']) != 0) { //grant temporary permission $p->add('voicemail_option_add', 'temp'); } @@ -540,7 +540,7 @@ echo "\n"; echo " \n"; - if (strlen(htmlspecialchars($voicemail_option_order))> 0) { + if (strlen(htmlspecialchars($voicemail_option_order ?? ''))> 0) { echo " \n"; } $i = 0; diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 052e96de7a..806f74f258 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.php @@ -41,7 +41,7 @@ ) { $voicemail = new voicemail; $voicemail->domain_uuid = $_SESSION['domain_uuid']; - $voicemail->type = $_REQUEST['t']; + $voicemail->type = $_REQUEST['t'] ?? null; $voicemail->voicemail_id = $_REQUEST['id']; $voicemail->voicemail_uuid = $_REQUEST['voicemail_uuid']; $voicemail->voicemail_message_uuid = $_REQUEST['uuid']; @@ -64,11 +64,14 @@ exit; } +//set the back button url + $_SESSION['back'][$_SERVER['PHP_SELF']] = !empty($_GET['back']) ? urldecode($_GET['back']) : ($_SESSION['back'][$_SERVER['PHP_SELF']] ?? PROJECT_PATH.'/app/voicemails/voicemails.php'); + //set the voicemail_uuid - if (is_uuid($_REQUEST['id'])) { + if (!empty($_REQUEST['id']) && is_uuid($_REQUEST['id'])) { $voicemail_uuid = $_REQUEST['id']; } - else if (is_numeric($_REQUEST['id'])) { + else if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $voicemail_id = $_REQUEST['id']; } @@ -105,7 +108,7 @@ if (is_array($voicemail_messages) && @sizeof($voicemail_messages) != 0) { $messages_toggled = 0; foreach ($voicemail_messages as $voicemail_message) { - if ($voicemail_message['checked'] == 'true' && is_uuid($voicemail_message['uuid']) && is_uuid($voicemail_message['voicemail_uuid'])) { + if (!empty($voicemail_message['checked']) && $voicemail_message['checked'] == 'true' && is_uuid($voicemail_message['uuid']) && is_uuid($voicemail_message['voicemail_uuid'])) { //delete voicemail message $voicemail = new voicemail; $voicemail->db = $db; @@ -129,7 +132,7 @@ if (is_array($voicemail_messages) && @sizeof($voicemail_messages) != 0) { $messages_deleted = 0; foreach ($voicemail_messages as $voicemail_message) { - if ($voicemail_message['checked'] == 'true' && is_uuid($voicemail_message['uuid']) && is_uuid($voicemail_message['voicemail_uuid'])) { + if (!empty($voicemail_message['checked']) && $voicemail_message['checked'] == 'true' && is_uuid($voicemail_message['uuid']) && is_uuid($voicemail_message['voicemail_uuid'])) { //delete voicemail message $voicemail = new voicemail; $voicemail->db = $db; @@ -172,10 +175,10 @@ //get the voicemail $vm = new voicemail; $vm->domain_uuid = $_SESSION['domain_uuid']; - if (is_uuid($voicemail_uuid)) { + if (!empty($voicemail_uuid) && is_uuid($voicemail_uuid)) { $vm->voicemail_uuid = $voicemail_uuid; } - else if (is_numeric($voicemail_id)) { + else if (!empty($voicemail_id) && is_numeric($voicemail_id)) { $vm->voicemail_id = $voicemail_id; } $vm->order_by = $order_by; @@ -209,11 +212,12 @@ echo "
\n"; echo "
".$text['title-voicemail_messages']." (".$num_rows.")
\n"; echo "
\n"; + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>$_SESSION['back'][$_SERVER['PHP_SELF']]]); if ($num_rows) { - echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'name'=>'btn_toggle','collapse'=>'hide-xs','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); + echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','collapse'=>'hide-xs','style'=>'margin-left: 15px; display: none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); } if (permission_exists('voicemail_message_delete') && $num_rows) { - echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','collapse'=>'hide-xs','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','collapse'=>'hide-xs','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo "
\n"; echo "
\n"; @@ -268,7 +272,7 @@ $col_count = 0; if (permission_exists('voicemail_message_delete')) { echo " \n"; - echo " 0 ?: "style='visibility: hidden;'").">\n"; + echo " 0 ?: "style='visibility: hidden;'").">\n"; echo " \n"; $col_count++; } @@ -282,7 +286,7 @@ $col_count++; echo th_order_by('message_length', $text['label-message_length'], $order_by, $order, null, "class='hide-xs right pct-15'"); $col_count++; - if (!empty($_SESSION['voicemail']['storage_type']['text']) != 'base64') { + if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { echo "".$text['label-message_size']."\n"; $col_count++; } @@ -300,7 +304,7 @@ $list_row_url = "javascript:recording_play('".escape($row['voicemail_message_uuid'])."');"; echo "\n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -316,7 +320,7 @@ } echo " \n"; echo " ".escape($row['message_length_label'])."\n"; - if (!empty($_SESSION['voicemail']['storage_type']['text']) != 'base64') { + if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') { echo " ".escape($row['file_size_label'])."\n"; } echo "\n"; @@ -372,4 +376,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index f4ee910519..675581e739 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -307,7 +307,7 @@ } if (permission_exists('voicemail_message_view')) { $tmp_voicemail_string = (array_key_exists($row['voicemail_uuid'], $voicemails_count)) ? " (" . $voicemails_count[$row['voicemail_uuid']] . ")" : " (0)"; - echo " ".$text['label-messages'].$tmp_voicemail_string."\n"; + echo " ".$text['label-messages'].$tmp_voicemail_string."\n"; } echo " \n"; }