Add new permissions to be used by the superadmin group music_on_hold_default_view, add, and delete. Enforce the new permissions. Add underscore to a few more variable names.

This commit is contained in:
Mark Crane 2012-10-20 16:54:16 +00:00
parent 17d428a0b7
commit c80d98880f
3 changed files with 171 additions and 148 deletions

View File

@ -37,6 +37,15 @@
$apps[$x]['menu'][0]['groups'][] = 'admin';
//permission details
$apps[$x]['permissions'][0]['name'] = 'music_on_hold_default_view';
$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
$apps[$x]['permissions'][1]['name'] = 'music_on_hold_default_add';
$apps[$x]['permissions'][1]['groups'][] = 'superadmin';
$apps[$x]['permissions'][2]['name'] = 'music_on_hold_default_delete';
$apps[$x]['permissions'][2]['groups'][] = 'superadmin';
$apps[$x]['permissions'][0]['name'] = 'music_on_hold_view';
$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
$apps[$x]['permissions'][0]['groups'][] = 'admin';
@ -48,4 +57,5 @@
$apps[$x]['permissions'][2]['name'] = 'music_on_hold_delete';
$apps[$x]['permissions'][2]['groups'][] = 'superadmin';
$apps[$x]['permissions'][1]['groups'][] = 'admin';
?>

View File

@ -27,7 +27,7 @@
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('music_on_hold_view')) {
if (permission_exists('music_on_hold_view') || permission_exists('music_on_hold_default_view')) {
//access granted
}
else {
@ -38,18 +38,18 @@ else {
require_once "includes/paging.php";
$sampling_rate_dirs = Array(8000, 16000, 32000, 48000);
$dir_music_on_hold = $_SESSION['switch']['sounds']['dir'].'/music';
$music_on_hold_dir = $_SESSION['switch']['sounds']['dir'].'/music';
ini_set(max_execution_time,7200);
$order_by = $_GET["order_by"];
$order = $_GET["order"];
if ($_GET['a'] == "download") {
$category_folder = $_GET['category'];
$category_dir = $_GET['category'];
$sampling_rate_dir = $_GET['sampling_rate'];
if ($category_folder != '') {
$path_mod = $category_folder."/";
if ($category_dir != '') {
$path_mod = $category_dir."/";
if (count($_SESSION['domains']) > 1) {
$path_mod = $_SESSION["domain_name"]."/".$path_mod;
@ -58,17 +58,17 @@ if ($_GET['a'] == "download") {
session_cache_limiter('public');
if ($_GET['type'] = "moh") {
if (file_exists($dir_music_on_hold."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['filename']))) {
$fd = fopen($dir_music_on_hold."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['filename']), "rb");
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");
header('Content-Disposition: attachment; filename="'.base64_decode($_GET['filename']).'"');
header('Content-Disposition: attachment; file_name="'.base64_decode($_GET['file_name']).'"');
}
else {
$file_ext = substr(base64_decode($_GET['filename']), -3);
$file_ext = substr(base64_decode($_GET['file_name']), -3);
if ($file_ext == "wav") {
header("Content-Type: audio/x-wav");
}
@ -78,61 +78,62 @@ if ($_GET['a'] == "download") {
}
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($dir_music_on_hold."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['filename'])));
header("Content-Length: " . filesize($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name'])));
fpassthru($fd);
}
}
exit;
}
if (($_POST['submit'] == "Upload") && 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')) {
$new_file_name = str_replace(' ', '-', $_FILES['upload_file']['name']); // replace any spaces in the filename with dashes
$new_file_name = str_replace(' ', '-', $_FILES['upload_file']['name']); // replace any spaces in the file_name with dashes
$sampling_rate_dir = $_POST['upload_sampling_rate'] * 1000; // convert sampling rate from value passed by form
if (count($_SESSION['domains']) > 1) {
$path_mod = $_SESSION["domain_name"]."/"; // if multi-tenant, modify folder paths
$path_mod = $_SESSION["domain_name"]."/"; // if multi-tenant, modify directory paths
}
// 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($dir_music_on_hold."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) {
@mkdir($dir_music_on_hold."/".$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)) {
@mkdir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir, 0777, true);
}
if (is_dir($dir_music_on_hold."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) {
move_uploaded_file($_FILES['upload_file']['tmp_name'], $dir_music_on_hold."/".$path_mod.$new_category_name."/".$sampling_rate_dir."/".$new_file_name);
$target_folder = $dir_music_on_hold."/".$path_mod.$new_category_name."/".$sampling_rate_dir;
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 folder
// use existing category directory
else if ($_POST['upload_category'] != '' && $_POST['upload_category'] != '_NEW_CAT_') {
if (!is_dir($dir_music_on_hold."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) {
@mkdir($dir_music_on_hold."/".$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)) {
@mkdir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir, 0777, true);
}
if (is_dir($dir_music_on_hold."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) {
move_uploaded_file($_FILES['upload_file']['tmp_name'], $dir_music_on_hold."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir."/".$new_file_name);
$target_folder = $dir_music_on_hold."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir;
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 folder
// use default directory
else if ($_POST['upload_category'] == '') {
if (!is_dir($dir_music_on_hold."/".$sampling_rate_dir)) {
@mkdir($dir_music_on_hold."/".$sampling_rate_dir, 0777, true);
}
if (is_dir($dir_music_on_hold."/".$sampling_rate_dir)) {
move_uploaded_file($_FILES['upload_file']['tmp_name'], $dir_music_on_hold."/".$sampling_rate_dir."/".$new_file_name);
$target_folder = $dir_music_on_hold."/".$sampling_rate_dir;
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;
}
}
}
else { exit(); }
$savemsg = "Uploaded file to ".$target_folder."/".htmlentities($_FILES['upload_file']['name']);
$savemsg = "Uploaded file to ".$target_dir."/".htmlentities($_FILES['upload_file']['name']);
unset($_POST['txtCommand']);
}
}
@ -141,36 +142,44 @@ if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['upload_file']['t
if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) {
if ($_GET['type'] == 'moh') {
$sampling_rate_dir = $_GET['sampling_rate'];
$category_folder = $_GET['category'];
if ($category_folder != '') {
$path_mod = $category_folder."/";
$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;
}
}
unlink($dir_music_on_hold."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['filename']));
unlink($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']));
header("Location: music_on_hold.php");
exit;
}
if ($_GET['type'] == 'cat') {
$category_folder = $_GET['category'];
$category_dir = $_GET['category'];
if (strlen($category_dir) > 0) {
if (count($_SESSION['domains']) > 1) {
$path_mod = $_SESSION["domain_name"]."/";
}
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 sampling rate folders (if any)
foreach ($sampling_rate_dirs as $sampling_rate_dir) {
rmdir($dir_music_on_hold."/".$path_mod.(base64_decode($category_folder))."/".$sampling_rate_dir);
}
// remove category folder
if (rmdir($dir_music_on_hold."/".$path_mod.(base64_decode($category_folder)))) {
sleep(5); // allow time for the OS to catch up (at least Windows, anyway)
// 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)
}
}
header("Location: music_on_hold.php");
@ -230,28 +239,30 @@ if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) {
echo " </td>\n";
echo " <td nowrap>Category<br>\n";
echo " <select id='upload_category' name='upload_category' class='formfld' style='width: auto;' onchange=\"if (this.options[this.selectedIndex].value == '_NEW_CAT_') { this.style.display='none'; document.getElementById('upload_category_new').style.display=''; document.getElementById('upload_category_return').style.display=''; document.getElementById('upload_category_new').focus(); }\">\n";
echo " <option value='' style='font-style: italic;'>Default</option>\n";
if (permission_exists('music_on_hold_default_add')) {
echo " <option value='' style='font-style: italic;'>Default</option>\n";
}
if (count($_SESSION['domains']) > 1) {
$dir_music_on_hold_category_parent_folder = $dir_music_on_hold."/".$_SESSION['domain_name'];
$music_on_hold_category_parent_dir = $music_on_hold_dir."/".$_SESSION['domain_name'];
}
else {
$dir_music_on_hold_category_parent_folder = $dir_music_on_hold;
$music_on_hold_category_parent_dir = $music_on_hold_dir;
}
if ($handle = opendir($dir_music_on_hold_category_parent_folder)) {
while (false !== ($folder = readdir($handle))) {
if ($handle = opendir($music_on_hold_category_parent_dir)) {
while (false !== ($directory = readdir($handle))) {
if (
$folder != "." &&
$folder != ".." &&
$folder != "8000" &&
$folder != "16000" &&
$folder != "32000" &&
$folder != "48000" &&
is_dir($dir_music_on_hold_category_parent_folder."/".$folder)
$directory != "." &&
$directory != ".." &&
$directory != "8000" &&
$directory != "16000" &&
$directory != "32000" &&
$directory != "48000" &&
is_dir($music_on_hold_category_parent_dir."/".$directory)
) {
echo "<option value='".$folder."'>".(str_replace('_', ' ', $folder))."</option>\n";
$category_folders[] = $folder; // array used to output category folder contents below
echo "<option value='".$directory."'>".(str_replace('_', ' ', $directory))."</option>\n";
$category_dirs[] = $directory; // array used to output category directory contents below
}
}
closedir($handle);
@ -275,103 +286,106 @@ if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) {
//begin default moh section ********************************************************************************************************************************************
echo "<b><i>Default</i></b>\n";
if (count($_SESSION['domains']) > 1) {
echo "&nbsp;&nbsp;- Available to All Domains\n";
}
echo "<br><br>\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-bottom: 3px;\">\n";
echo " <tr>\n";
echo " <th width=\"30%\" class=\"listhdrr\">Download</th>\n";
echo " <th width=\"30%\" class=\"listhdrr\">Play</th>\n";
echo " <th width=\"30%\" class=\"listhdr\">Uploaded</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap>File Size</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap>Sampling</th>\n";
echo " <td width='22px' align=\"center\"></td>\n";
echo " </tr>";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
foreach ($sampling_rate_dirs as $sampling_rate_dir) {
if ($handle = opendir($dir_music_on_hold."/".$sampling_rate_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($dir_music_on_hold."/".$sampling_rate_dir."/".$file)) {
$tmp_filesize = filesize($dir_music_on_hold."/".$sampling_rate_dir."/".$file);
$tmp_filesize = byte_convert($tmp_filesize);
echo "<tr>\n";
echo " <td class='".$row_style[$c]."'><a href=\"music_on_hold.php?a=download&sampling_rate=".$sampling_rate_dir."&type=moh&t=bin&filename=".base64_encode($file)."\">".$file."</a></td>\n";
echo " <td class='".$row_style[$c]."'>\n";
echo " <a href=\"javascript:void(0);\" onclick=\"window.open('music_on_hold_play.php?a=download&sampling_rate=".$sampling_rate_dir."&type=moh&filename=".base64_encode($file)."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
$tmp_file_array = explode("\.",$file);
echo " ".$tmp_file_array[0];
echo " </a>";
echo " </td>\n";
echo " <td class='".$row_style[$c]."'>".date ("F d Y H:i:s", filemtime($dir_music_on_hold."/".$sampling_rate_dir."/".$file))."</td>\n";
echo " <td class='".$row_style[$c]."'>".$tmp_filesize."</td>\n";
echo " <td class='".$row_style[$c]."'>".($sampling_rate_dir / 1000)." kHz</td>\n";
echo " <td align=\"center\" width='22' nowrap class=\"list\">\n";
if (permission_exists('music_on_hold_delete')) {
echo " <a href=\"music_on_hold.php?type=moh&act=del&sampling_rate=".$sampling_rate_dir."&filename=".base64_encode($file)."\" onclick=\"return confirm('Do you really want to delete this file?')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
$c = ($c==0) ? 1 : 0;
}
}
closedir($handle);
if (permission_exists('music_on_hold_default_view')) {
echo "<b><i>Default</i></b>\n";
if (count($_SESSION['domains']) > 1) {
echo "&nbsp;&nbsp;- Available to All Domains\n";
}
}
echo "</table>\n";
if ($v_path_show) {
echo "<div style='font-size: 10px; text-align: right; margin-right: 25px;'><b>Location:</b> ".$dir_music_on_hold."</div>\n";
}
echo "<br><br><br><br>\n";
//begin moh categories ********************************************************************************************************************************************
foreach ($category_folders as $category_number => $category_folder) {
$c = 0;
echo "<b>".(str_replace('_', ' ', $category_folder))."</b>\n";
echo "<br><br>\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-bottom: 3px;\">\n";
echo " <tr>\n";
echo " <th width=\"30%\" class=\"listhdrr\">Download</th>\n";
echo " <th width=\"30%\" class=\"listhdrr\">Play</th>\n";
echo " <th width=\"30%\" class=\"listhdr\">Uploaded</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap>File Size</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap>Sampling</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap=\"nowrap\">File Size</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap=\"nowrap\">Sampling</th>\n";
echo " <td width='22px' align=\"center\"></td>\n";
echo " </tr>";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
foreach ($sampling_rate_dirs as $sampling_rate_dir) {
if ($handle = opendir($music_on_hold_dir."/".$sampling_rate_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($music_on_hold_dir."/".$sampling_rate_dir."/".$file)) {
$file_size = filesize($music_on_hold_dir."/".$sampling_rate_dir."/".$file);
$file_size = byte_convert($file_size);
echo "<tr>\n";
echo " <td class='".$row_style[$c]."'><a href=\"music_on_hold.php?a=download&sampling_rate=".$sampling_rate_dir."&type=moh&t=bin&file_name=".base64_encode($file)."\">".$file."</a></td>\n";
echo " <td class='".$row_style[$c]."'>\n";
echo " <a href=\"javascript:void(0);\" onclick=\"window.open('music_on_hold_play.php?a=download&sampling_rate=".$sampling_rate_dir."&type=moh&file_name=".base64_encode($file)."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
$tmp_file_array = explode("\.",$file);
echo " ".$tmp_file_array[0];
echo " </a>";
echo " </td>\n";
echo " <td class='".$row_style[$c]."'>".date ("F d Y H:i:s", filemtime($music_on_hold_dir."/".$sampling_rate_dir."/".$file))."</td>\n";
echo " <td class='".$row_style[$c]."'>".$file_size."</td>\n";
echo " <td class='".$row_style[$c]."'>".($sampling_rate_dir / 1000)." kHz</td>\n";
echo " <td align=\"center\" width='22' nowrap=\"nowrap\" class=\"list\">\n";
if (permission_exists('music_on_hold_default_delete')) {
echo " <a href=\"music_on_hold.php?type=moh&act=del&sampling_rate=".$sampling_rate_dir."&file_name=".base64_encode($file)."\" onclick=\"return confirm('Do you really want to delete this file?')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
$c = ($c==0) ? 1 : 0;
}
}
closedir($handle);
}
}
}
echo "</table>\n";
if ($v_path_show) {
echo "<div style='font-size: 10px; text-align: right; margin-right: 25px;'><b>Location:</b> ".$music_on_hold_dir."</div>\n";
}
echo "<br><br><br><br>\n";
//begin moh categories ********************************************************************************************************************************************
foreach ($category_dirs as $category_number => $category_dir) {
$c = 0;
echo "<b>".(str_replace('_', ' ', $category_dir))."</b>\n";
echo "<br><br>\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-bottom: 3px;\">\n";
echo " <tr>\n";
echo " <th width=\"30%\" class=\"listhdrr\">Download</th>\n";
echo " <th width=\"30%\" class=\"listhdrr\">Play</th>\n";
echo " <th width=\"30%\" class=\"listhdr\">Uploaded</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap=\"nowrap\">File Size</th>\n";
echo " <th width=\"10%\" class=\"listhdr\" nowrap=\"nowrap\">Sampling</th>\n";
echo " <td width='22px' align=\"center\" style=\"padding: 2px;\"><span id='category_".$category_number."_delete_icon'></span></td>\n";
echo " </tr>";
$moh_found = false;
foreach ($sampling_rate_dirs as $sampling_rate_dir) {
if ($handle = opendir($dir_music_on_hold_category_parent_folder."/".$category_folder."/".$sampling_rate_dir)) {
if ($handle = opendir($music_on_hold_category_parent_dir."/".$category_dir."/".$sampling_rate_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($dir_music_on_hold_category_parent_folder."/".$category_folder."/".$sampling_rate_dir."/".$file)) {
if ($file != "." && $file != ".." && is_file($music_on_hold_category_parent_dir."/".$category_dir."/".$sampling_rate_dir."/".$file)) {
$tmp_filesize = filesize($dir_music_on_hold_category_parent_folder."/".$category_folder."/".$sampling_rate_dir."/".$file);
$tmp_filesize = byte_convert($tmp_filesize);
$file_size = filesize($music_on_hold_category_parent_dir."/".$category_dir."/".$sampling_rate_dir."/".$file);
$file_size = byte_convert($file_size);
echo "<tr>\n";
echo " <td class='".$row_style[$c]."'><a href=\"music_on_hold.php?a=download&category=".$category_folder."&sampling_rate=".$sampling_rate_dir."&type=moh&t=bin&filename=".base64_encode($file)."\">".$file."</a></td>\n";
echo " <td class='".$row_style[$c]."'><a href=\"music_on_hold.php?a=download&category=".$category_dir."&sampling_rate=".$sampling_rate_dir."&type=moh&t=bin&file_name=".base64_encode($file)."\">".$file."</a></td>\n";
echo " <td class='".$row_style[$c]."'>\n";
echo " <a href=\"javascript:void(0);\" onclick=\"window.open('music_on_hold_play.php?a=download&category=".$category_folder."&sampling_rate=".$sampling_rate_dir."&type=moh&filename=".base64_encode($file)."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
$tmp_file_array = explode("\.",$file);
echo " <a href=\"javascript:void(0);\" onclick=\"window.open('music_on_hold_play.php?a=download&category=".$category_dir."&sampling_rate=".$sampling_rate_dir."&type=moh&file_name=".base64_encode($file)."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
$tmp_file_array = explode("\.",$file);
echo " ".$tmp_file_array[0];
echo " </a>";
echo " </td>\n";
echo " <td class='".$row_style[$c]."'>".date ("F d Y H:i:s", filemtime($dir_music_on_hold_category_parent_folder."/".$category_folder."/".$sampling_rate_dir."/".$file))."</td>\n";
echo " <td class='".$row_style[$c]."'>".$tmp_filesize."</td>\n";
echo " <td class='".$row_style[$c]."'>".date ("F d Y H:i:s", filemtime($music_on_hold_category_parent_dir."/".$category_dir."/".$sampling_rate_dir."/".$file))."</td>\n";
echo " <td class='".$row_style[$c]."'>".$file_size."</td>\n";
echo " <td class='".$row_style[$c]."'>".($sampling_rate_dir / 1000)." kHz</td>\n";
echo " <td align=\"center\" width='22' nowrap class=\"list\">\n";
echo " <td align=\"center\" width='22' nowrap=\"nowrap\" class=\"list\">\n";
if (permission_exists('music_on_hold_delete')) {
echo " <a href=\"music_on_hold.php?type=moh&act=del&category=".$category_folder."&sampling_rate=".$sampling_rate_dir."&filename=".base64_encode($file)."\" onclick=\"return confirm('Do you really want to delete this file?')\">$v_link_label_delete</a>\n";
echo " <a href=\"music_on_hold.php?type=moh&act=del&category=".$category_dir."&sampling_rate=".$sampling_rate_dir."&file_name=".base64_encode($file)."\" onclick=\"return confirm('Do you really want to delete this file?')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
@ -388,15 +402,14 @@ if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) {
echo "<tr>\n";
echo " <td colspan='5' align='left' class='".$row_style[$c]."'>\n";
echo " No files found.";
echo " <script>document.getElementById('category_".$category_number."_delete_icon').innerHTML = \"<a href='music_on_hold.php?type=cat&act=del&category=".base64_encode($category_folder)."' title='Delete Category'>".$v_link_label_delete."</a>\";</script>\n";
echo " <script>document.getElementById('category_".$category_number."_delete_icon').innerHTML = \"<a href='music_on_hold.php?type=cat&act=del&category=".base64_encode($category_dir)."' title='Delete Category'>".$v_link_label_delete."</a>\";</script>\n";
echo " </td>\n";
echo "</tr>\n";
}
echo "</table>\n";
if ($v_path_show) {
echo "<div style='font-size: 10px; text-align: right; margin-right: 25px;'><b>Location:</b> ".$dir_music_on_hold_category_parent_folder."/".$category_folder."</div>\n";
echo "<div style='font-size: 10px; text-align: right; margin-right: 25px;'><b>Location:</b> ".$music_on_hold_category_parent_dir."/".$category_dir."</div>\n";
}
echo "<br><br>\n";

View File

@ -35,10 +35,10 @@ else {
exit;
}
$filename = base64_decode($_GET['filename']);
$file_name = base64_decode($_GET['file_name']);
$type = $_GET['type']; //moh //rec
$category_folder = $_GET['category'];
$samplingrate_folder = $_GET['samplingrate'];
$category_dir = $_GET['category'];
$sampling_rate_dir = $_GET['sampling_rate'];
?>
@ -50,23 +50,23 @@ $samplingrate_folder = $_GET['samplingrate'];
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align='center'>
<b>file: <?php echo $filename ?></b>
<b>file: <?php echo $file_name ?></b>
</td>
</tr>
<tr>
<td align='center'>
<?php
$file_ext = substr($filename, -3);
$file_ext = substr($file_name, -3);
if ($file_ext == "wav") {
//HTML5 method
echo "<audio src=\"http://localhost:8000/mod/music_on_hold/music_on_hold.php?a=download&category=".$category_folder."&samplingrate=".$samplingrate_folder."&type=".$type."&filename=".base64_encode($filename)."\" autoplay=\"autoplay\">";
echo "<audio src=\"http://localhost:8000/mod/music_on_hold/music_on_hold.php?a=download&category=".$category_dir."&sampling_rate=".$sampling_rate_dir."&type=".$type."&file_name=".base64_encode($file_name)."\" autoplay=\"autoplay\">";
echo "</audio>";
echo "<embed src=\"music_on_hold.php?a=download&category=".$category_folder."&samplingrate=".$samplingrate_folder."&type=".$type."&filename=".base64_encode($filename)."\" autostart=\"true\" width=\"200\" height=\"40\" name=\"sound_".$filename."\" enablejavascript=\"true\">\n";
echo "<embed src=\"music_on_hold.php?a=download&category=".$category_dir."&sampling_rate=".$sampling_rate_dir."&type=".$type."&file_name=".base64_encode($file_name)."\" autostart=\"true\" width=\"200\" height=\"40\" name=\"sound_".$file_name."\" enablejavascript=\"true\">\n";
}
if ($file_ext == "mp3") {
echo "<object type=\"application/x-shockwave-flash\" width=\"400\" height=\"17\" data=\"slim.swf?autoplay=true&song_title=".urlencode($filename)."&song_url=music_on_hold.php?a=download&category=".$category_folder."&samplingrate=".$samplingrate_folder."&type=".$type."&filename=".base64_encode($filename)."\">\n";
echo "<param name=\"movie\" value=\"slim.swf?autoplay=true&song_url=music_on_hold.php?a=download&category=".$category_folder."&samplingrate=".$samplingrate_folder."&type=".$type."&filename=".base64_encode($filename)."\" />\n";
echo "<object type=\"application/x-shockwave-flash\" width=\"400\" height=\"17\" data=\"slim.swf?autoplay=true&song_title=".urlencode($file_name)."&song_url=music_on_hold.php?a=download&category=".$category_dir."&sampling_rate=".$sampling_rate_dir."&type=".$type."&file_name=".base64_encode($file_name)."\">\n";
echo "<param name=\"movie\" value=\"slim.swf?autoplay=true&song_url=music_on_hold.php?a=download&category=".$category_dir."&sampling_rate=".$sampling_rate_dir."&type=".$type."&file_name=".base64_encode($file_name)."\" />\n";
echo "<param name=\"quality\" value=\"high\"/>\n";
echo "<param name=\"bgcolor\" value=\"#E6E6E6\"/>\n";
echo "</object>\n";