Flash mp3 player optimized for better user experience
[mirrors/JukeBox.git] / index.php
index bae54eb72f847c3030423cd8c4b590f3b2998f66..08e8329a9c604030891017b76d829410bc5784cc 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -18,7 +18,8 @@ Version info:
 
 //Config-basic
 $title =               'Harvie\'s JuKe!Box'; //Title of jukebox
-$music_dir =           './music'; //Local path to directory with music
+$music_dir =           'music'; //Local path to directory with music
+$base_url =            preg_replace('/[^\/]*$/', '', $_SERVER['SCRIPT_NAME']); //URL of this directory (always ends with slash)
 $music_dir_url =       'http://your-server.net/jukebox/music'; //URL path to the same directory
 $cache_passwd =        'renew123'; //You need this passwd to refresh search cache
 $sort =                        3; //Sort? 0 = none, 1 = playlists, 2 = 1+listings; 3 = 2+search-EXPERIMENTAL! (sorting could eat lot of memory)
@@ -35,11 +36,11 @@ $default_random_count =     30; //How many random songs by defaul?
 
 //External files
 $indexlist =           array('index.html', 'index.txt'); //Search for this file in each directory
-$bonus_dir =           './jbx'; //Misc. files directory
+$bonus_dir =           'jbx'; //Misc. files directory
 ////
 $search_cache =        $bonus_dir.'/cache.db'; //Database for searching music (php +rw) - .htaccess: Deny from all!!!
-$css_file =            $bonus_dir.'/themes/default/jukebox.css'; //CSS (Design)
-$favicon_file =                './favicon.png'; //favicon
+$css_file =            $base_url.$bonus_dir.'/themes/default/jukebox.css'; //CSS (Design)
+$favicon_file =                $base_url.'favicon.png'; //favicon
 $header_file =         $bonus_dir.'/header.html'; //header file
 $footer_file =         $bonus_dir.'/footer.html'; //footer file
 
@@ -57,7 +58,7 @@ $search_engines = array(
 $flash_player_swf =    $bonus_dir.'/player.swf'; //path to musicplayer
 $flash_player_frame =  'playframe-show'; //FlashPlayer Target (playframe-show|playframe-hide) - usefull for compatibility with old music player
 $flash_player_options = '?bg=000099&loader=000000&tracker=AAAAFF&skip=FFFFFF' //.'&leftbg=000077&rightbg=000077&righticon=999999'
-                        .'&autostart=yes&initialvolume=100&soundFile='; //& arguments (urlencoded song url will be added)
+                        .'&autostart=yes&initialvolume=100&buffer=30&animation=no&soundFile='; //& arguments (urlencoded song url will be added)
 
 //Security
 error_reporting(0); //This will disable error reporting, wich can pass sensitive data to users
@@ -76,6 +77,7 @@ if(get_magic_quotes_gpc()) die("Error: magic_quotes_gpc needs to be disabled!\n"
 $useflash = is_file($flash_player_swf);
 
 //Little magic with directories ;o)
+if($_SERVER['PATH_INFO']!='') $_GET['dir']=$_SERVER['PATH_INFO'];
 $current_dir = ereg_replace('/+', '/', '/'.$_GET['dir'].'/');
 if(eregi('(/|\\\\)\\.\\.(/|\\\\)', $current_dir)) { //check for directory traversal ;)
        header('Location: ?');
@@ -202,8 +204,8 @@ function render_file_line($dir, $item, $dir_url, $index, $filesize, $parent = fa
                        '" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifplay">F</a>/'.
                        '<a href="?blank" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifstop">S</a>');
        }
-       echo('&nbsp;</td><td class="maximize-width"><a href="'.$temp.'">'.unxss(str_replace('-',' - ',str_replace('_', ' ', 
-$item))).'</a></td><td>'.$filesize."&nbsp;MiB&nbsp;</td></tr>\n");                     
+       echo('&nbsp;</td><td class="maximize-width"><a href="'.$temp.'">'.unxss(str_replace('-',' - ',str_replace('_', ' ', $item))).
+       '</a></td><td>'.$filesize."&nbsp;MiB&nbsp;</td></tr>\n");
 }
 
 function render_dir_line($current_dir, $item, $i) {
@@ -213,7 +215,7 @@ function render_dir_line($current_dir, $item, $i) {
        '<td><a href="#up">'.$i.'</a></td><td class="btntd"><a href="?download&playlist&dir='.$temp.'" class="icon iplay">P</a>/'.
        '<a href="?download&recursive&playlist&dir='.$temp.'" class="icon irplay">R</a>');
        if($GLOBALS['useflash']) echo('/<a href="?f&playlist&dir='.$temp.'" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifplay">F</a>');
-       echo('</td><td colspan="100%" class="maximize-width"><span class="icon ifolder">[DIR] </span><a href="?dir='.$temp.'">'.unxss(str_replace('_', ' ', $item)).
+       echo('</td><td colspan="100%" class="maximize-width"><span class="icon ifolder">[DIR] </span><a href="?dir='.$temp.'">'.unxss(str_replace('-',' - ',str_replace('_', ' ', $item))).
        "</a></td></tr>\n");
 }
 
@@ -279,7 +281,7 @@ function flash_mp3_player() {
 <style> * { margin: 0; padding: 0; border: 0; } </style></head><body>
 <object width="100%" height="344">
         <embed src="<?php
-               echo($GLOBALS['flash_player_swf'].$GLOBALS['flash_player_options']);
+               echo($GLOBALS['base_url'].$GLOBALS['flash_player_swf'].$GLOBALS['flash_player_options']);
                if(isset($_GET['song'])) echo(rawurlencode($_GET['song']));
                if(isset($_GET['playlist'])) generate_m3u($GLOBALS['dir'], dirname($GLOBALS['music_dir_url']), isset($_GET['recursive']), ',', true);
        ?>"
This page took 0.157703 seconds and 4 git commands to generate.