diff --git a/app/music_on_hold/app_languages.php b/app/music_on_hold/app_languages.php index 323db809d0..185f2cb9ab 100644 --- a/app/music_on_hold/app_languages.php +++ b/app/music_on_hold/app_languages.php @@ -28,6 +28,20 @@ $text['message-nofiles']['fr-fr'] = "Pas de fichier trouvé."; $text['message-nofiles']['pt-br'] = "Não foram encontrados os arquivos"; $text['message-nofiles']['pl'] = "Nie znaleziono plików"; +$text['message-upload_completed']['en-us'] = "Upload Completed"; +$text['message-upload_completed']['es-cl'] = "Cargar Completado"; +$text['message-upload_completed']['pt-pt'] = "Carregar Concluído"; +$text['message-upload_completed']['fr-fr'] = "Upload terminé"; +$text['message-upload_completed']['pt-br'] = "Carregar Concluído"; +$text['message-upload_completed']['pl'] = "Prześlij Zakończony"; + +$text['message-unsupported_file_type']['en-us'] = "Unsupported File Type"; +$text['message-unsupported_file_type']['es-cl'] = "Tipo de archivo no compatible"; +$text['message-unsupported_file_type']['pt-pt'] = "Não suportado Tipo de Arquivo"; +$text['message-unsupported_file_type']['fr-fr'] = "Type de fichier non pris en charge"; +$text['message-unsupported_file_type']['pt-br'] = "Não suportado Tipo de Arquivo"; +$text['message-unsupported_file_type']['pl'] = "Nieobsługiwany typ pliku"; + $text['message-event-socket']['en-us'] = "Connection to Event Socket failed."; $text['message-event-socket']['es-cl'] = "Conexión a socket fallida."; $text['message-event-socket']['pt-pt'] = "A Conexão ao Event Socket falhou."; diff --git a/app/music_on_hold/music_on_hold.php b/app/music_on_hold/music_on_hold.php index e2b91963c5..3878266c30 100644 --- a/app/music_on_hold/music_on_hold.php +++ b/app/music_on_hold/music_on_hold.php @@ -44,7 +44,6 @@ else { require_once "resources/paging.php"; //set the music on hold directory - $sampling_rate_dirs = Array(8000, 16000, 32000, 48000); if (file_exists('/var/lib/fusionpbx/sounds/music')) { $music_on_hold_dir = $_SESSION['switch']['sounds']['dir'].'/music/fusionpbx'; } @@ -57,107 +56,178 @@ else { $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); -if ($_GET['a'] == "download") { - $slashes = array("/", "\\"); - $_GET['category'] = str_replace($slashes, "", $_GET['category']); - $_GET['file_name'] = str_replace($slashes, "", $_GET['file_name']); +//download moh file + if ($_GET['a'] == "download") { + $slashes = array("/", "\\"); + $_GET['category'] = str_replace($slashes, "", $_GET['category']); + $_GET['file_name'] = str_replace($slashes, "", $_GET['file_name']); - $category_dir = $_GET['category']; - $sampling_rate_dir = $_GET['sampling_rate']; + $category_dir = $_GET['category']; + $sampling_rate_dir = $_GET['sampling_rate']; - if ($category_dir != '') { - $path_mod = $category_dir."/"; - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/".$path_mod; - } - } - - session_cache_limiter('public'); - if ($_GET['type'] = "moh") { - if (file_exists($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']))) { - $fd = fopen($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']), "rb"); - if ($_GET['t'] == "bin") { - header("Content-Type: application/force-download"); - header("Content-Type: application/octet-stream"); - header("Content-Type: application/download"); - header("Content-Description: File Transfer"); + if ($category_dir != '') { + $path_mod = $category_dir."/"; + if (count($_SESSION['domains']) > 1) { + $path_mod = $_SESSION["domain_name"]."/".$path_mod; } - else { - $file_ext = substr(base64_decode($_GET['file_name']), -3); - if ($file_ext == "wav") { - header("Content-Type: audio/x-wav"); - } - if ($file_ext == "mp3") { - header("Content-Type: audio/mp3"); - } - } - header('Content-Disposition: attachment; filename="'.base64_decode($_GET['file_name']).'"'); - 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("Content-Length: " . filesize($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']))); - fpassthru($fd); } - } - exit; -} -if (is_uploaded_file($_FILES['upload_file']['tmp_name'])) { - $file_ext = strtolower(pathinfo($_FILES['upload_file']['name'], PATHINFO_EXTENSION)); - if ($file_ext == 'wav' || $file_ext == 'mp3') { - if ($_POST['type'] == 'moh' && permission_exists('music_on_hold_add')) { - - //remove the slashes - $slashes = array("/", "\\"); - $_POST['upload_category_new'] = str_replace($slashes, "", $_POST['upload_category_new']); - $_FILES['upload_file']['name'] = str_replace($slashes, "", $_FILES['upload_file']['name']); - - // replace any spaces in the file_name with dashes - $new_file_name = str_replace(' ', '-', $_FILES['upload_file']['name']); - - // convert sampling rate from value passed by form - $sampling_rate_dir = $_POST['upload_sampling_rate'] * 1000; - - // if multi-tenant, modify directory paths - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/"; - } - - // create new category, if necessary - if ($_POST['upload_category'] == '_NEW_CAT_' && $_POST['upload_category_new'] != '') { - $new_category_name = str_replace(' ', '_', $_POST['upload_category_new']); - if (!is_dir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) { - @mkdir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir, 0777, true); - } - if (is_dir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) { - move_uploaded_file($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir."/".$new_file_name); - $target_dir = $music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir; - } - } - // use existing category directory - else if ($_POST['upload_category'] != '' && $_POST['upload_category'] != '_NEW_CAT_') { - if (!is_dir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) { - @mkdir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir, 0777, true); - } - if (is_dir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) { - move_uploaded_file($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir."/".$new_file_name); - $target_dir = $music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir; - } - } - // use default directory - else if ($_POST['upload_category'] == '') { - if (permission_exists('music_on_hold_default_add')) { - if (!is_dir($music_on_hold_dir."/".$sampling_rate_dir)) { - @mkdir($music_on_hold_dir."/".$sampling_rate_dir, 0777, true); - } - if (is_dir($music_on_hold_dir."/".$sampling_rate_dir)) { - move_uploaded_file($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$sampling_rate_dir."/".$new_file_name); - $target_dir = $music_on_hold_dir."/".$sampling_rate_dir; - } - } + session_cache_limiter('public'); + if ($_GET['type'] = "moh") { + if (file_exists($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']))) { + $fd = fopen($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']), "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); } else { - exit(); + $file_ext = substr(base64_decode($_GET['file_name']), -3); + if ($file_ext == "wav") { + header("Content-Type: audio/x-wav"); + } + if ($file_ext == "mp3") { + header("Content-Type: audio/mpeg"); + } } + header('Content-Disposition: attachment; filename="'.base64_decode($_GET['file_name']).'"'); + 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("Content-Length: " . filesize($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']))); + fpassthru($fd); + } + } + exit; + } + +//upload moh file + if (is_uploaded_file($_FILES['upload_file']['tmp_name'])) { + $file_ext = strtolower(pathinfo($_FILES['upload_file']['name'], PATHINFO_EXTENSION)); + if ($file_ext == 'wav' || $file_ext == 'mp3') { + if ($_POST['type'] == 'moh' && permission_exists('music_on_hold_add')) { + + //remove the slashes + $slashes = array("/", "\\"); + $_POST['upload_category_new'] = str_replace($slashes, "", $_POST['upload_category_new']); + $_FILES['upload_file']['name'] = str_replace($slashes, "", $_FILES['upload_file']['name']); + + //replace any spaces in the file_name with dashes + $new_file_name = str_replace(' ', '-', $_FILES['upload_file']['name']); + + //convert sampling rate from value passed by form + if ($file_ext == 'mp3') { + $sampling_rate_dirs = Array(8000, 16000, 32000, 48000); + } + else { + $sampling_rate_dirs[] = $_POST['upload_sampling_rate'] * 1000; + } + + //if multi-tenant, modify directory paths + if (count($_SESSION['domains']) > 1) { + $path_mod = $_SESSION["domain_name"]."/"; + } + + //create new category, if necessary + if ($_POST['upload_category'] == '_NEW_CAT_' && $_POST['upload_category_new'] != '') { + $new_category_name = str_replace(' ', '_', $_POST['upload_category_new']); + //process sampling rate(s) + foreach ($sampling_rate_dirs as $sampling_rate_dir) { + if (!is_dir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) { + @mkdir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir, 0777, true); + } + if (is_dir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) { + copy($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir."/".$new_file_name); + $target_dir = $music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir; + } + } + //delete temp file + @unlink($_FILES['upload_file']['tmp_name']); + } + //use existing category directory + else if ($_POST['upload_category'] != '' && $_POST['upload_category'] != '_NEW_CAT_') { + //process sampling rate(s) + foreach ($sampling_rate_dirs as $sampling_rate_dir) { + if (!is_dir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) { + @mkdir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir, 0777, true); + } + if (is_dir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) { + copy($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir."/".$new_file_name); + $target_dir = $music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir; + } + } + //delete temp file + @unlink($_FILES['upload_file']['tmp_name']); + } + //use default directory + else if ($_POST['upload_category'] == '') { + if (permission_exists('music_on_hold_default_add')) { + //process sampling rate(s) + foreach ($sampling_rate_dirs as $sampling_rate_dir) { + if (!is_dir($music_on_hold_dir."/".$sampling_rate_dir)) { + @mkdir($music_on_hold_dir."/".$sampling_rate_dir, 0777, true); + } + if (is_dir($music_on_hold_dir."/".$sampling_rate_dir)) { + copy($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$sampling_rate_dir."/".$new_file_name); + $target_dir = $music_on_hold_dir."/".$sampling_rate_dir; + } + } + //delete temp file + @unlink($_FILES['upload_file']['tmp_name']); + } + } + else { + //delete temp file and exit + @unlink($_FILES['upload_file']['tmp_name']); + exit(); + } + + //build and save the XML + require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; + $moh = new switch_music_on_hold; + $moh->xml(); + $moh->save(); + + //set an upload message + $save_msg = "Uploaded file to ".$target_dir."/".htmlentities($_FILES['upload_file']['name']); + } + } + + $_SESSION['message'] = $text['message-upload_completed']; + header("Location: music_on_hold.php"); + exit; + } + +//define valid sampling rates + $sampling_rate_dirs = Array(8000, 16000, 32000, 48000); + +//delete moh file + if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) { + if ($_GET['type'] == 'moh') { + //remove the slashes + $slashes = array("/", "\\"); + $_GET['category'] = str_replace($slashes, "", $_GET['category']); + $_GET['file_name'] = str_replace($slashes, "", $_GET['file_name']); + //set the variables + $sampling_rate_dir = $_GET['sampling_rate']; + $category_dir = $_GET['category']; + //default category + if ($category_dir == "") { + if (!permission_exists('music_on_hold_default_delete')) { + echo "access denied"; + exit; + } + } + //other categories + if ($category_dir != "") { + $path_mod = $category_dir."/"; + + if (count($_SESSION['domains']) > 1) { + $path_mod = $_SESSION["domain_name"]."/".$path_mod; + } + } + //remove the directory + unlink($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name'])); //build and save the XML require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; @@ -165,86 +235,62 @@ if (is_uploaded_file($_FILES['upload_file']['tmp_name'])) { $moh->xml(); $moh->save(); - //set an upload message - $save_msg = "Uploaded file to ".$target_dir."/".htmlentities($_FILES['upload_file']['name']); + //redirect the browser + header("Location: music_on_hold.php"); + exit; } - } -} -if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) { - if ($_GET['type'] == 'moh') { - //remove the slashes - $slashes = array("/", "\\"); - $_GET['category'] = str_replace($slashes, "", $_GET['category']); - $_GET['file_name'] = str_replace($slashes, "", $_GET['file_name']); - //set the variables - $sampling_rate_dir = $_GET['sampling_rate']; + if ($_GET['type'] == 'cat') { $category_dir = $_GET['category']; - //default category - if ($category_dir == "") { - if (!permission_exists('music_on_hold_default_delete')) { - echo "access denied"; - exit; - } + if (strlen($category_dir) > 0) { + // adjus the path for multiple domains + if (count($_SESSION['domains']) > 1) { + $path_mod = $_SESSION["domain_name"]."/"; + } + + // remove sampling rate directory (if any) + foreach ($sampling_rate_dirs as $sampling_rate_dir) { + rmdir($music_on_hold_dir."/".$path_mod.(base64_decode($category_dir))."/".$sampling_rate_dir); + } + + // remove category directory + if (rmdir($music_on_hold_dir."/".$path_mod.(base64_decode($category_dir)))) { + sleep(5); // allow time for the OS to catch up (at least Windows, anyway) + } } - //other categories - if ($category_dir != "") { - $path_mod = $category_dir."/"; - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/".$path_mod; - } - } - //remove the directory - unlink($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name'])); + //build and save the XML + require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; + $moh = new switch_music_on_hold; + $moh->xml(); + $moh->save(); - //build and save the XML - require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; - $moh = new switch_music_on_hold; - $moh->xml(); - $moh->save(); - - //redirect the browser - header("Location: music_on_hold.php"); - exit; - } - - if ($_GET['type'] == 'cat') { - $category_dir = $_GET['category']; - if (strlen($category_dir) > 0) { - // adjus the path for multiple domains - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/"; - } - - // remove sampling rate directories (if any) - foreach ($sampling_rate_dirs as $sampling_rate_dir) { - rmdir($music_on_hold_dir."/".$path_mod.(base64_decode($category_dir))."/".$sampling_rate_dir); - } - - // remove category directory - if (rmdir($music_on_hold_dir."/".$path_mod.(base64_decode($category_dir)))) { - sleep(5); // allow time for the OS to catch up (at least Windows, anyway) - } + //redirect the browser + header("Location: music_on_hold.php"); + exit; } - - //build and save the XML - require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; - $moh = new switch_music_on_hold; - $moh->xml(); - $moh->save(); - - //redirect the browser - header("Location: music_on_hold.php"); - exit; } -} //include the header require_once "resources/header.php"; $document['title'] = $text['title-moh']; -//show the title and description + echo "\n"; echo "\n"; echo "
| \n"; echo " ".$text['label-file-path']; - echo " \n"; + echo " "; + echo "\n"; echo " | \n"; - echo "".$text['label-sampling'].""; + echo " | "; + echo " ".$text['label-sampling']; echo " |