From ca411bd4251adfcf880cfb5a811394907df649cc Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sun, 23 Mar 2014 11:31:03 +0000 Subject: [PATCH] Fix the voicemail message size, and download link when using mp3 extension. --- app/voicemails/resources/classes/voicemail.php | 18 +++++++++++++++--- app/voicemails/voicemail_messages.php | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index 4f13e686a1..705300f490 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.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-2013 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -150,7 +150,13 @@ if ($result_count > 0) { foreach($result as &$row) { //set the greeting directory - $row['file_path'] = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id'].'/msg_'.$row['voicemail_message_uuid'].'.wav'; + $path = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id']; + if (file_exists($path.'/msg_'.$row['voicemail_message_uuid'].'.wav')) { + $row['file_path'] = $path.'/msg_'.$row['voicemail_message_uuid'].'.wav'; + } + if (file_exists($path.'/msg_'.$row['voicemail_message_uuid'].'.mp3')) { + $row['file_path'] = $path.'/msg_'.$row['voicemail_message_uuid'].'.mp3'; + } $row['file_size'] = filesize($row['file_path']); $row['file_size_label'] = byte_convert($row['file_size']); $row['file_ext'] = substr($row['file_path'], -3); @@ -261,7 +267,13 @@ session_cache_limiter('public'); //prepare and stream the file - $file_path = $_SESSION['switch']['storage']['dir']."/voicemail/default/".$_SESSION['domain_name']."/".$this->voicemail_id."/msg_".$this->voicemail_message_uuid.".wav"; + $path = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$this->voicemail_id; + if (file_exists($path.'/msg_'.$this->voicemail_message_uuid.'.wav')) { + $file_path = $path.'/msg_'.$this->voicemail_message_uuid.'.wav'; + } + if (file_exists($path.'/msg_'.$this->voicemail_message_uuid.'.mp3')) { + $file_path = $path.'/msg_'.$this->voicemail_message_uuid.'.mp3'; + } if (file_exists($file_path)) { $fd = fopen($file_path, "rb"); if ($_GET['t'] == "bin") { diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 38a2469f1f..e658de2ec3 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.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-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -49,7 +49,7 @@ else { if (check_str($_REQUEST["action"]) == "download") { $voicemail_message_uuid = check_str($_REQUEST["uuid"]); $voicemail_id = check_str($_REQUEST["id"]); - require_once "resources/classes/voicemail.php"; + //require_once "resources/classes/voicemail.php"; $voicemail = new voicemail; $voicemail->db = $db; $voicemail->domain_uuid = $_SESSION['domain_uuid'];