2012-06-04 16:58:40 +02:00
< ? php
/*
FusionPBX
Version : MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 ( the " License " ); you may not use this file except in compliance with
the License . You may obtain a copy of the License at
http :// www . mozilla . org / MPL /
Software distributed under the License is distributed on an " AS IS " basis ,
WITHOUT WARRANTY OF ANY KIND , either express or implied . See the License
for the specific language governing rights and limitations under the
License .
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane < markjcrane @ fusionpbx . com >
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2012
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
2012-11-25 00:23:20 +01:00
James Rose < james . o . rose @ gmail . com >
2012-06-04 16:58:40 +02:00
*/
2012-10-18 09:22:37 +02:00
2012-06-04 16:58:40 +02:00
include " root.php " ;
require_once " includes/require.php " ;
require_once " includes/checkauth.php " ;
2012-10-20 18:54:16 +02:00
if ( permission_exists ( 'music_on_hold_view' ) || permission_exists ( 'music_on_hold_default_view' )) {
2012-06-04 16:58:40 +02:00
//access granted
}
else {
echo " access denied " ;
exit ;
}
2012-11-25 00:23:20 +01:00
//add multi-lingual support
require_once " app_languages.php " ;
foreach ( $text as $key => $value ) {
$text [ $key ] = $value [ $_SESSION [ 'domain' ][ 'language' ][ 'code' ]];
}
2012-06-04 16:58:40 +02:00
require_once " includes/paging.php " ;
2012-10-20 17:50:32 +02:00
$sampling_rate_dirs = Array ( 8000 , 16000 , 32000 , 48000 );
2012-10-20 18:54:16 +02:00
$music_on_hold_dir = $_SESSION [ 'switch' ][ 'sounds' ][ 'dir' ] . '/music' ;
2012-06-04 16:58:40 +02:00
ini_set ( max_execution_time , 7200 );
$order_by = $_GET [ " order_by " ];
$order = $_GET [ " order " ];
if ( $_GET [ 'a' ] == " download " ) {
2012-10-20 18:54:16 +02:00
$category_dir = $_GET [ 'category' ];
2012-10-20 17:50:32 +02:00
$sampling_rate_dir = $_GET [ 'sampling_rate' ];
2012-10-18 09:22:37 +02:00
2012-10-20 18:54:16 +02:00
if ( $category_dir != '' ) {
$path_mod = $category_dir . " / " ;
2012-10-18 09:22:37 +02:00
if ( count ( $_SESSION [ 'domains' ]) > 1 ) {
$path_mod = $_SESSION [ " domain_name " ] . " / " . $path_mod ;
}
}
2012-06-04 16:58:40 +02:00
session_cache_limiter ( 'public' );
if ( $_GET [ 'type' ] = " moh " ) {
2012-10-20 18:54:16 +02:00
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 " );
2012-06-04 16:58:40 +02:00
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 " );
2012-10-20 18:54:16 +02:00
header ( 'Content-Disposition: attachment; file_name="' . base64_decode ( $_GET [ 'file_name' ]) . '"' );
2012-06-04 16:58:40 +02:00
}
else {
2012-10-20 18:54:16 +02:00
$file_ext = substr ( base64_decode ( $_GET [ 'file_name' ]), - 3 );
2012-06-04 16:58:40 +02:00
if ( $file_ext == " wav " ) {
header ( " Content-Type: audio/x-wav " );
}
if ( $file_ext == " mp3 " ) {
header ( " Content-Type: audio/mp3 " );
}
}
header ( " Cache-Control: no-cache, must-revalidate " ); // HTTP/1.1
header ( " Expires: Sat, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
2012-10-20 18:54:16 +02:00
header ( " Content-Length: " . filesize ( $music_on_hold_dir . " / " . $path_mod . $sampling_rate_dir . " / " . base64_decode ( $_GET [ 'file_name' ])));
2012-06-04 16:58:40 +02:00
fpassthru ( $fd );
}
}
exit ;
}
2012-10-20 17:50:32 +02:00
if (( $_POST [ 'submit' ] == " Upload " ) && is_uploaded_file ( $_FILES [ 'upload_file' ][ 'tmp_name' ])) {
$file_ext = strtolower ( pathinfo ( $_FILES [ 'upload_file' ][ 'name' ], PATHINFO_EXTENSION ));
2012-10-18 09:22:37 +02:00
if ( $file_ext == 'wav' || $file_ext == 'mp3' ) {
if ( $_POST [ 'type' ] == 'moh' && permission_exists ( 'music_on_hold_add' )) {
2012-10-20 21:37:47 +02:00
// replace any spaces in the file_name with dashes
2012-10-24 04:45:51 +02:00
$new_file_name = str_replace ( ' ' , '-' , $_FILES [ 'upload_file' ][ 'name' ]);
2012-10-18 09:22:37 +02:00
2012-10-20 21:37:47 +02:00
// convert sampling rate from value passed by form
2012-10-24 04:45:51 +02:00
$sampling_rate_dir = $_POST [ 'upload_sampling_rate' ] * 1000 ;
2012-10-18 09:22:37 +02:00
2012-10-20 21:37:47 +02:00
// if multi-tenant, modify directory paths
2012-10-24 04:45:51 +02:00
if ( count ( $_SESSION [ 'domains' ]) > 1 ) {
$path_mod = $_SESSION [ " domain_name " ] . " / " ;
}
2012-10-18 09:22:37 +02:00
// create new category, if necessary
2012-10-24 04:45:51 +02:00
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 ;
}
2012-10-18 09:22:37 +02:00
}
2012-10-20 18:54:16 +02:00
// use existing category directory
2012-10-24 04:45:51 +02:00
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 );
2012-10-20 18:54:16 +02:00
}
2012-10-24 04:45:51 +02:00
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 ;
2012-10-20 18:54:16 +02:00
}
2012-10-18 09:22:37 +02:00
}
2012-10-24 04:45:51 +02:00
// 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 ;
2012-10-20 21:37:47 +02:00
}
2012-10-24 04:45:51 +02:00
}
}
else {
exit ();
2012-10-20 21:37:47 +02:00
}
2012-10-24 04:45:51 +02:00
//build and save the XML
2012-10-23 08:01:23 +02:00
require_once " app/music_on_hold/resources/classes/switch_music_on_hold.php " ;
$moh = new switch_music_on_hold ;
2012-10-24 04:45:51 +02:00
$moh -> xml ();
$moh -> save ();
2012-10-23 08:01:23 +02:00
2012-10-20 21:37:47 +02:00
//set an upload message
$save_msg = " Uploaded file to " . $target_dir . " / " . htmlentities ( $_FILES [ 'upload_file' ][ 'name' ]);
2012-10-18 09:22:37 +02:00
}
2012-06-04 16:58:40 +02:00
}
}
if ( $_GET [ 'act' ] == " del " && permission_exists ( 'music_on_hold_delete' )) {
if ( $_GET [ 'type' ] == 'moh' ) {
2012-10-23 08:29:53 +02:00
//set the variables
$sampling_rate_dir = $_GET [ 'sampling_rate' ];
$category_dir = $_GET [ 'category' ];
2012-10-20 18:54:16 +02:00
//default category
2012-10-23 08:29:53 +02:00
if ( $category_dir == " " ) {
if ( ! permission_exists ( 'music_on_hold_default_delete' )) {
echo " access denied " ;
exit ;
}
2012-10-20 18:54:16 +02:00
}
//other categories
2012-10-23 08:29:53 +02:00
if ( $category_dir != " " ) {
$path_mod = $category_dir . " / " ;
2012-10-18 09:22:37 +02:00
2012-10-23 08:29:53 +02:00
if ( count ( $_SESSION [ 'domains' ]) > 1 ) {
$path_mod = $_SESSION [ " domain_name " ] . " / " . $path_mod ;
}
2012-10-18 09:22:37 +02:00
}
2012-10-23 08:29:53 +02:00
//remove the directory
unlink ( $music_on_hold_dir . " / " . $path_mod . $sampling_rate_dir . " / " . base64_decode ( $_GET [ 'file_name' ]));
2012-10-18 09:22:37 +02:00
2012-10-24 04:45:51 +02:00
//build and save the XML
2012-10-23 08:29:53 +02:00
require_once " app/music_on_hold/resources/classes/switch_music_on_hold.php " ;
$moh = new switch_music_on_hold ;
2012-10-24 04:45:51 +02:00
$moh -> xml ();
$moh -> save ();
2012-10-23 08:29:53 +02:00
//redirect the browser
header ( " Location: music_on_hold.php " );
exit ;
2012-10-18 09:22:37 +02:00
}
if ( $_GET [ 'type' ] == 'cat' ) {
2012-10-20 18:54:16 +02:00
$category_dir = $_GET [ 'category' ];
if ( strlen ( $category_dir ) > 0 ) {
2012-10-23 08:29:53 +02:00
// adjus the path for multiple domains
if ( count ( $_SESSION [ 'domains' ]) > 1 ) {
$path_mod = $_SESSION [ " domain_name " ] . " / " ;
}
2012-10-18 09:22:37 +02:00
2012-10-20 18:54:16 +02:00
// remove sampling rate directories (if any)
2012-10-23 08:29:53 +02:00
foreach ( $sampling_rate_dirs as $sampling_rate_dir ) {
rmdir ( $music_on_hold_dir . " / " . $path_mod . ( base64_decode ( $category_dir )) . " / " . $sampling_rate_dir );
}
2012-10-18 09:22:37 +02:00
2012-10-20 18:54:16 +02:00
// remove category directory
2012-10-23 08:29:53 +02:00
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)
}
2012-10-18 09:22:37 +02:00
}
2012-10-24 04:45:51 +02:00
//build and save the XML
2012-10-23 08:29:53 +02:00
require_once " app/music_on_hold/resources/classes/switch_music_on_hold.php " ;
$moh = new switch_music_on_hold ;
2012-10-24 04:45:51 +02:00
$moh -> xml ();
$moh -> save ();
2012-10-23 08:29:53 +02:00
//redirect the browser
header ( " Location: music_on_hold.php " );
exit ;
2012-06-04 16:58:40 +02:00
}
}
//include the header
require_once " includes/header.php " ;
2012-10-23 08:29:53 +02:00
//show the title and description
2012-10-18 09:22:37 +02:00
echo " <script language='JavaScript' type='text/javascript' src=' " . PROJECT_PATH . " /includes/javascript/reset_file_input.js'></script> \n " ;
2012-06-04 16:58:40 +02:00
echo " <script> \n " ;
echo " function EvalSound(soundobj) { \n " ;
echo " var thissound= eval( \" document. \" +soundobj); \n " ;
echo " thissound.Play(); \n " ;
echo " } \n " ;
echo " </script> " ;
2013-01-02 03:00:34 +01:00
echo " <br /> \n " ;
2012-10-18 09:22:37 +02:00
echo " <table width= \" 100% \" border= \" 0 \" cellpadding= \" 0 \" cellspacing= \" 0 \" > \n " ;
echo " <tr> \n " ;
echo " <td align='left'> \n " ;
echo " <p><span class= \" vexpl \" > \n " ;
2012-11-25 00:23:20 +01:00
echo " <strong> " . $text [ 'label-moh' ] . " </strong><br><br> \n " ;
echo " " . $text [ 'desc-moh' ] . " \n " ;
2012-10-18 09:22:37 +02:00
echo " </span></p> \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
echo " </table> \n " ;
2012-06-04 16:58:40 +02:00
echo " \n " ;
2012-10-18 09:22:37 +02:00
echo " <br><br> \n " ;
2012-06-04 16:58:40 +02:00
echo " \n " ;
2012-10-18 09:22:37 +02:00
2012-10-23 08:29:53 +02:00
//show the upload form
2012-06-04 16:58:40 +02:00
if ( permission_exists ( 'music_on_hold_add' )) {
2012-11-25 00:23:20 +01:00
echo " <b> " . $text [ 'label-upload-moh' ] . " </b> \n " ;
2012-10-18 09:22:37 +02:00
echo " <br><br> \n " ;
echo " <form action='' method='POST' enctype='multipart/form-data' name='frmUpload' id='frmUpload' onSubmit=''> \n " ;
echo " <input name='type' type='hidden' value='moh'> \n " ;
echo " <table cellpadding='0' cellspacing='0' border='0'> \n " ;
echo " <tr> \n " ;
echo " <td style='padding-right: 5px;' nowrap> \n " ;
2012-11-25 00:23:20 +01:00
echo " " . $text [ 'label-file-path' ] . " <br> \n " ;
echo " <input name='upload_file' type='file' class='button' size='50' id='upload_file'><input type='button' class='button' value=' " . $text [ 'button-clear' ] . " ' onclick= \" reset_file_input('upload_file'); \" > \n " ;
2012-10-18 09:22:37 +02:00
echo " </td> \n " ;
2012-11-25 00:23:20 +01:00
echo " <td style='padding-right: 5px;' nowrap> " . $text [ 'label-sampling' ] . " <br> \n " ;
2012-10-20 17:50:32 +02:00
echo " <select id='upload_sampling_rate' name='upload_sampling_rate' class='formfld' style='width: auto;'> \n " ;
2012-10-18 09:22:37 +02:00
echo " <option value='8'>8 kHz</option> \n " ;
echo " <option value='16'>16 kHz</option> \n " ;
echo " <option value='32'>32 kHz</option> \n " ;
echo " <option value='48'>48 kHz</option> \n " ;
echo " </select> \n " ;
echo " </td> \n " ;
2012-11-25 00:23:20 +01:00
echo " <td nowrap> " . $text [ 'label-category' ] . " <br> \n " ;
2012-10-20 17:50:32 +02:00
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 " ;
2012-10-20 18:54:16 +02:00
if ( permission_exists ( 'music_on_hold_default_add' )) {
2012-11-25 00:23:20 +01:00
echo " <option value='' style='font-style: italic;'> " . $text [ 'opt-default' ] . " </option> \n " ;
2012-10-20 18:54:16 +02:00
}
2012-06-04 16:58:40 +02:00
2012-10-18 09:22:37 +02:00
if ( count ( $_SESSION [ 'domains' ]) > 1 ) {
2012-10-20 18:54:16 +02:00
$music_on_hold_category_parent_dir = $music_on_hold_dir . " / " . $_SESSION [ 'domain_name' ];
2012-10-18 09:22:37 +02:00
}
else {
2012-10-20 18:54:16 +02:00
$music_on_hold_category_parent_dir = $music_on_hold_dir ;
2012-10-18 09:22:37 +02:00
}
2012-10-20 18:54:16 +02:00
if ( $handle = opendir ( $music_on_hold_category_parent_dir )) {
while ( false !== ( $directory = readdir ( $handle ))) {
2012-10-18 09:22:37 +02:00
if (
2012-10-20 18:54:16 +02:00
$directory != " . " &&
$directory != " .. " &&
$directory != " 8000 " &&
$directory != " 16000 " &&
$directory != " 32000 " &&
$directory != " 48000 " &&
is_dir ( $music_on_hold_category_parent_dir . " / " . $directory )
2012-10-18 09:22:37 +02:00
) {
2012-10-20 18:54:16 +02:00
echo " <option value=' " . $directory . " '> " . ( str_replace ( '_' , ' ' , $directory )) . " </option> \n " ;
$category_dirs [] = $directory ; // array used to output category directory contents below
2012-10-18 09:22:37 +02:00
}
}
closedir ( $handle );
2012-06-04 16:58:40 +02:00
}
2012-11-25 00:23:20 +01:00
echo " <option value='_NEW_CAT_' style='font-style: italic;'> " . $text [ 'opt-new' ] . " </option> \n " ;
2012-10-18 09:22:37 +02:00
echo " </select> \n " ;
2012-10-20 17:50:32 +02:00
echo " <input class='formfld' style='width: 150px; display: none;' type='text' name='upload_category_new' id='upload_category_new' maxlength='255' value=''> " ;
2012-10-18 09:22:37 +02:00
echo " </td> \n " ;
echo " <td> <br> \n " ;
2012-11-25 00:23:20 +01:00
echo " <input id='upload_category_return' type='button' class='button' style='display: none;' value='<' onclick= \" this.style.display='none'; document.getElementById('upload_category_new').style.display='none'; document.getElementById('upload_category_new').value=''; document.getElementById('upload_category').style.display=''; document.getElementById('upload_category').selectedIndex = 0; \" title=' " . $text [ 'message-click-select' ] . " '> " ;
2012-10-18 09:22:37 +02:00
echo " </td> \n " ;
echo " <td style='padding-left: 5px;'> <br> \n " ;
2012-11-25 00:23:20 +01:00
echo " <input name='submit' type='submit' class='btn' id='upload' value=' " . $text [ 'button-upload' ] . " '> \n " ;
2012-10-18 09:22:37 +02:00
echo " </td> \n " ;
2012-11-23 04:22:43 +01:00
echo " </tr> \n " ;
2012-10-18 09:22:37 +02:00
echo " </table> \n " ;
echo " </form> \n " ;
echo " <br><br> \n " ;
2012-06-04 16:58:40 +02:00
}
2012-11-23 04:22:43 +01:00
//set the row styles
$c = 0 ;
$row_style [ " 0 " ] = " row_style0 " ;
$row_style [ " 1 " ] = " row_style1 " ;
2012-10-23 08:29:53 +02:00
//show the default category
2012-10-20 18:54:16 +02:00
if ( permission_exists ( 'music_on_hold_default_view' )) {
2012-11-25 00:23:20 +01:00
echo " <b><i> " . $text [ 'label-default' ] . " </i></b> \n " ;
2012-10-20 18:54:16 +02:00
if ( count ( $_SESSION [ 'domains' ]) > 1 ) {
2012-11-25 00:23:20 +01:00
echo " - " . $text [ 'message-available-to-all' ] . " \n " ;
2012-10-20 18:54:16 +02:00
}
echo " <br><br> \n " ;
echo " <table width= \" 100% \" border= \" 0 \" cellpadding= \" 0 \" cellspacing= \" 0 \" style= \" margin-bottom: 3px; \" > \n " ;
echo " <tr> \n " ;
2012-11-25 00:23:20 +01:00
echo " <th width= \" 30% \" class= \" listhdrr \" > " . $text [ 'label-download' ] . " </th> \n " ;
echo " <th width= \" 30% \" class= \" listhdrr \" > " . $text [ 'label-play' ] . " </th> \n " ;
echo " <th width= \" 30% \" class= \" listhdr \" > " . $text [ 'label-uploaded' ] . " </th> \n " ;
echo " <th width= \" 10% \" class= \" listhdr \" nowrap= \" nowrap \" > " . $text [ 'label-file-size' ] . " </th> \n " ;
echo " <th width= \" 10% \" class= \" listhdr \" nowrap= \" nowrap \" > " . $text [ 'label-sampling' ] . " </th> \n " ;
2012-10-20 18:54:16 +02:00
echo " <td width='22px' align= \" center \" ></td> \n " ;
echo " </tr> " ;
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 ;
2012-10-18 09:22:37 +02:00
}
}
2012-10-20 18:54:16 +02:00
closedir ( $handle );
2012-06-04 16:58:40 +02:00
}
}
2012-11-23 04:22:43 +01:00
echo " </table> \n " ;
2012-06-04 16:58:40 +02:00
}
2012-11-23 04:22:43 +01:00
2012-10-18 09:22:37 +02:00
if ( $v_path_show ) {
2012-11-25 00:23:20 +01:00
echo " <div style='font-size: 10px; text-align: right; margin-right: 25px;'><b> " . $text [ 'label-location' ] . " :</b> " . $music_on_hold_dir . " </div> \n " ;
2012-10-18 09:22:37 +02:00
}
2012-10-23 08:38:27 +02:00
echo " <br><br> \n " ;
2012-06-04 16:58:40 +02:00
2012-10-23 08:29:53 +02:00
//show additional categories
2012-10-20 18:54:16 +02:00
foreach ( $category_dirs as $category_number => $category_dir ) {
2012-10-18 09:22:37 +02:00
$c = 0 ;
2012-10-20 18:54:16 +02:00
echo " <b> " . ( str_replace ( '_' , ' ' , $category_dir )) . " </b> \n " ;
2012-10-18 09:22:37 +02:00
echo " <br><br> \n " ;
echo " <table width= \" 100% \" border= \" 0 \" cellpadding= \" 0 \" cellspacing= \" 0 \" style= \" margin-bottom: 3px; \" > \n " ;
echo " <tr> \n " ;
2012-11-25 00:23:20 +01:00
echo " <th width= \" 30% \" class= \" listhdrr \" > " . $text [ 'label-download' ] . " </th> \n " ;
echo " <th width= \" 30% \" class= \" listhdrr \" > " . $text [ 'label-play' ] . " </th> \n " ;
echo " <th width= \" 30% \" class= \" listhdr \" > " . $text [ 'label-uploaded' ] . " </th> \n " ;
echo " <th width= \" 10% \" class= \" listhdr \" nowrap= \" nowrap \" > " . $text [ 'label-file-size' ] . " </th> \n " ;
echo " <th width= \" 10% \" class= \" listhdr \" nowrap= \" nowrap \" > " . $text [ 'label-sampling' ] . " </th> \n " ;
2012-10-18 09:22:37 +02:00
echo " <td width='22px' align= \" center \" style= \" padding: 2px; \" ><span id='category_ " . $category_number . " _delete_icon'></span></td> \n " ;
echo " </tr> " ;
$moh_found = false ;
2012-10-20 17:50:32 +02:00
foreach ( $sampling_rate_dirs as $sampling_rate_dir ) {
2012-10-20 18:54:16 +02:00
if ( $handle = opendir ( $music_on_hold_category_parent_dir . " / " . $category_dir . " / " . $sampling_rate_dir )) {
2012-10-18 09:22:37 +02:00
while ( false !== ( $file = readdir ( $handle ))) {
2012-10-20 18:54:16 +02:00
if ( $file != " . " && $file != " .. " && is_file ( $music_on_hold_category_parent_dir . " / " . $category_dir . " / " . $sampling_rate_dir . " / " . $file )) {
2012-10-18 09:22:37 +02:00
2012-10-20 18:54:16 +02:00
$file_size = filesize ( $music_on_hold_category_parent_dir . " / " . $category_dir . " / " . $sampling_rate_dir . " / " . $file );
$file_size = byte_convert ( $file_size );
2012-10-18 09:22:37 +02:00
echo " <tr> \n " ;
2012-10-20 18:54:16 +02:00
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 " ;
2012-10-18 09:22:37 +02:00
echo " <td class=' " . $row_style [ $c ] . " '> \n " ;
2012-10-20 18:54:16 +02:00
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 );
2012-10-18 09:22:37 +02:00
echo " " . $tmp_file_array [ 0 ];
echo " </a> " ;
echo " </td> \n " ;
2012-10-20 18:54:16 +02:00
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 " ;
2012-10-20 17:50:32 +02:00
echo " <td class=' " . $row_style [ $c ] . " '> " . ( $sampling_rate_dir / 1000 ) . " kHz</td> \n " ;
2012-10-20 18:54:16 +02:00
echo " <td align= \" center \" width='22' nowrap= \" nowrap \" class= \" list \" > \n " ;
2012-10-18 09:22:37 +02:00
if ( permission_exists ( 'music_on_hold_delete' )) {
2012-11-25 00:23:20 +01:00
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(' " . $text [ 'message-delete' ] . " ') \" > $v_link_label_delete </a> \n " ;
2012-10-18 09:22:37 +02:00
}
echo " </td> \n " ;
echo " </tr> \n " ;
$c = ( $c == 0 ) ? 1 : 0 ;
$moh_found = true ;
}
}
closedir ( $handle );
}
}
if ( ! $moh_found ) {
echo " <tr> \n " ;
echo " <td colspan='5' align='left' class=' " . $row_style [ $c ] . " '> \n " ;
2012-11-25 00:23:20 +01:00
echo " " . $text [ 'message-nofiles' ] . " " ;
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=' " . $text [ 'label-delete-category' ] . " '> " . $v_link_label_delete . " </a> \" ;</script> \n " ;
2012-10-18 09:22:37 +02:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
echo " </table> \n " ;
if ( $v_path_show ) {
2012-10-20 18:54:16 +02:00
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 " ;
2012-10-18 09:22:37 +02:00
}
echo " <br><br> \n " ;
}
2012-06-04 16:58:40 +02:00
//include the footer
require_once " includes/footer.php " ;
?>