Added experimental PATH_INFO support (will need further changes to make this realy...
[mirrors/JukeBox.git] / index.php
CommitLineData
ca88871f 1<?php require_once('./http_auth.php'); /*Delete this line to disable password protection*/ ?>
1c6591f3 2<?php $exec_time = round(microtime(true), 3); /*
6dcce3ff 3Harvie's JuKe!Box (2oo7-2o1o)
1c6591f3 4/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ca88871f 5Version info:
a9beee06 6 * 0.3.6 - Now sorting also directories and have icon link support in css
1c6591f3
H
7 * 0.3.5 - Fixed security bug - directory traversal in filelisting (upgrade recommended)
8 * 0.3.4 - Generating playlist for flashplayer, searching for bugs, cleaning code and preparing for new version release
9 * 0.3.3 - Shorter URLs for flashplayer (due to discussion at #skola ;o), nicer national characters handling
10 * 0.3.2 - Better support for national charsets, few small bugfixes, css improvements, modular search engines
11 * 0.3.1 - Buckfickses in m3u generation, better navigation, magic_quotes_gpc handled, css improvements
12 * 0.3 - Migrated to standalone WPAudioPlayer (better, nicer, with more functions)
13 * 0.2 - Few new functions (search playlist, random,...)
14 * 0.1.1 - Few little fixups, written help.html in Czech language ;o)
de30f731 15 * 0.1 - All functions are working - TODO: bugfix & replace ugly code
1c6591f3 16/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ca88871f
H
17*/
18
19//Config-basic
20$title = 'Harvie\'s&nbsp;JuKe!Box'; //Title of jukebox
21$music_dir = './music'; //Local path to directory with music
1c6591f3
H
22$music_dir_url = 'http://your-server.net/jukebox/music'; //URL path to the same directory
23$cache_passwd = 'renew123'; //You need this passwd to refresh search cache
ca88871f 24$sort = 3; //Sort? 0 = none, 1 = playlists, 2 = 1+listings; 3 = 2+search-EXPERIMENTAL! (sorting could eat lot of memory)
1c6591f3
H
25$access_limit = 40; //How many files could be accessed without using cache (while searching)
26
27//Encoding settins
28$charset = 'UTF-8'; //Charset for page
29$national_characters = 1; //Support searching in filenames with national characters? 0 = no; 1 = yes; (may slowdown search a little)
ca88871f
H
30
31//Playlist settings
32$playlist_name = 'playlist.m3u'; //Name of downloaded pl
33$m3u_exts = 'ogg|mp[0-9]|wma|wmv|wav'; //Allow only these files
34$default_random_count = 30; //How many random songs by defaul?
35
36//External files
37$indexlist = array('index.html', 'index.txt'); //Search for this file in each directory
1c6591f3
H
38$bonus_dir = './jbx'; //Misc. files directory
39////
ca88871f 40$search_cache = $bonus_dir.'/cache.db'; //Database for searching music (php +rw) - .htaccess: Deny from all!!!
1c6591f3
H
41$css_file = $bonus_dir.'/themes/default/jukebox.css'; //CSS (Design)
42$favicon_file = './favicon.png'; //favicon
ca88871f
H
43$header_file = $bonus_dir.'/header.html'; //header file
44$footer_file = $bonus_dir.'/footer.html'; //footer file
45
1c6591f3
H
46//Search engines extend search experience
47$search_engines = array(
48 'Google.com' => 'http://google.com/search?q=',
49 'Images' => 'http://google.com/images?q=',
50 'Karaoke-Lyrics.net' => 'http://www.karaoke-lyrics.net/index.php?page=find&q=',
51 'Jyxo.cz multimedia' => 'http://jyxo.cz/s?d=mm&q=',
52 'Centrum.cz mp3' => 'http://search.centrum.cz/index.php?sec=mp3&q=',
53 'YOUTube.com' => 'http://youtube.com/results?search_query='
54);
55
56//Flash MusicPlayer (info about settings: http://wpaudioplayer.com/standalone)
57$flash_player_swf = $bonus_dir.'/player.swf'; //path to musicplayer
58$flash_player_frame = 'playframe-show'; //FlashPlayer Target (playframe-show|playframe-hide) - usefull for compatibility with old music player
59$flash_player_options = '?bg=000099&loader=000000&tracker=AAAAFF&skip=FFFFFF' //.'&leftbg=000077&rightbg=000077&righticon=999999'
60 .'&autostart=yes&initialvolume=100&soundFile='; //& arguments (urlencoded song url will be added)
61
ca88871f 62//Security
1c6591f3
H
63error_reporting(0); //This will disable error reporting, wich can pass sensitive data to users
64
65//External configuration file (overrides index.php configuration)
66@include('./_config.php');
67
68//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ca88871f
H
69
70//Init
71srand(time());
1c6591f3
H
72@ini_set('magic_quotes_gpc' , 'off');
73if(get_magic_quotes_gpc()) die("Error: magic_quotes_gpc needs to be disabled!\n");
74
75//Enable flash?
76$useflash = is_file($flash_player_swf);
77
78//Little magic with directories ;o)
74524fb0 79if($_SERVER['PATH_INFO']!='') $_GET['dir']=$_SERVER['PATH_INFO'];
ca88871f 80$current_dir = ereg_replace('/+', '/', '/'.$_GET['dir'].'/');
1c6591f3
H
81if(eregi('(/|\\\\)\\.\\.(/|\\\\)', $current_dir)) { //check for directory traversal ;)
82 header('Location: ?');
83 die('Error - directory not found!');
84}
ca88871f
H
85$dir = $music_dir.$current_dir;
86$url = $music_dir_url.$current_dir;
87$parent_dir = dirname($current_dir);
88
89//FCs
90function serve_download($filename) {
91 header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
92 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
93 header('Pragma: no-cache');
94
95 //header('Content-Type: application/force-download');
96 header('Content-Type: audio/x-mpegurl');
97 header("Content-Disposition: attachment; filename={$filename}");
98 header('Content-Transfer-Encoding: binary');
99
100 header('X-PHP-Application: Harvie\'s JuKe!Box');
101}
102
1c6591f3
H
103$nchars_f = array('Á','Ä','Č','Ç','Ď','É','Ě','Ë','Í','Ň','Ó','Ö','Ř','Š','Ť','Ú','Ů','Ü','Ý','Ž','á','ä','č','ç','ď','é','ě','ë','í','ň','ó','ö','ř','š','ť','ú','ů','ü','ý','ž');
104$nchars_t = array('A','A','C','C','D','E','E','E','I','N','O','O','R','S','T','U','U','U','Y','Z','a','a','c','c','d','e','e','e','i','n','o','o','r','s','t','u','u','u','y','z');
105
106function unational($text) {
107 if(!$GLOBALS['national_characters']) return $text;
108 return(str_replace($GLOBALS['nchars_f'], $GLOBALS['nchars_t'], $text));
109}
110
111function generate_m3u($dir, $prefix='', $recursive=0, $nl="\r\n", $doubleenc=0) {
ca88871f 112 $dir = $dir . '/';
1c6591f3
H
113 if(isset($_GET['newline'])) $nl = $_GET['newline'];
114 if(!isset($_GET['search'])) {
115 $dd = opendir($dir);
116 while(($item = readdir($dd)) != false) {
117 if($item == '.' || $item == '..') continue;
118 if( is_file($dir.$item) && eregi(('\.('.$GLOBALS['m3u_exts'].')$'), $item) ) {
119 if($GLOBALS['sort'] > 0) {
120 $temp[] = $item;
121 } else {
122 $item=($prefix.'/'.str_replace('%2F', '/', (rawurlencode($dir.$item))).$nl);
123 if($doubleenc) $item = rawurlencode($item);
124 echo($item);
125 }
126 }
127 if($recursive && is_dir($dir.$item)) {
128 generate_m3u($dir.$item, $prefix, $recursive, $nl, $doubleenc);
129 }
130 }
131 } else {
132 if(!($searchfp = fopen($GLOBALS['search_cache'], 'r')))
133 die("Cannot read cache from $outfile<br />Refresh cache or set permissions properly!<br />\n");
134 while(!feof($searchfp)) {
135 $line = trim(fgets($searchfp));
136 if(@eregi(str_replace(' ', '(.*)', unational($_GET['search'])), unational($line))) {
137 $line=(dirname($GLOBALS['music_dir_url']).'/'.str_replace('%2F', '/', (rawurlencode($line))).$nl);
138 if($doubleenc) $line = rawurlencode($line);
139 echo($line);
ca88871f
H
140 }
141 }
ca88871f 142 }
1c6591f3 143
ca88871f
H
144 if($GLOBALS['sort'] > 0) {
145 @sort($temp);
1c6591f3
H
146 foreach($temp as $item) {
147 $temp=($prefix.'/'.str_replace('%2F', '/', (rawurlencode($dir.$item))).$nl);
148 if($doubleenc) $temp = rawurlencode($temp);
149 echo($temp);
150 }
ca88871f
H
151 }
152}
153
154function write_search_cache($dir, $outfp) {
155 $dir = $dir . '/';
156 $dd = opendir($dir);
157 while($item = readdir($dd)) {
158 if($item == '.' || $item == '..') continue;
159 if( is_file($dir.$item) && eregi(('\.('.$GLOBALS['m3u_exts'].')$'), $item) ) {
160 fwrite($outfp, $dir.$item."\n");
161 }
162 if(is_dir($dir.$item)) {
163 write_search_cache($dir.$item, $outfp);
164 }
165 }
166}
167
168function generate_search_cache($dir, $outfile) {
169 echo("Generating search cache. Please wait...<br />\n"); flush();
170 @chmod($outfile, 0755); //At least i tryed ;D
171 if(!($outfp = fopen($outfile, 'w')))
172 die("Cannot write cache to $outfile<br />You probably haven't set the permissions properly!<br />\n");
173 write_search_cache($dir, $outfp);
174 fclose($outfp);
175 $osize = filesize($outfile); clearstatcache();
176 if($GLOBALS['sort'] > 2) {
177 echo("Sorting search cache. Please wait...<br />\n"); flush();
178
179 $items = file($outfile); @sort($items);
180 $total = ' ('.sizeof($items).' files)';
181 file_put_contents($outfile, @implode('', $items));
182 unset($items);
183 if(abs(filesize($outfile)-$osize) > 2)
184 die('ERROR! Please disable sorting of search cache ($sort < 3)<br />'."\nSorted only ".
185 filesize($outfile).' of '.$osize.' bytes!!!\n');
186 }
187 echo('Total: '.filesize($outfile).' of '.$osize.' bytes'.$total.' <a href="?">DONE!</a>'.'<br /><META http-equiv="refresh" content="2;URL=?">'."\n");
188}
189
190function render_file_line($dir, $item, $dir_url, $index, $filesize, $parent = false) {
1c6591f3 191 $parclass=($index%2?'even':'odd'); $parcolor=($index%2?'lightblue':'white');
ca88871f
H
192 $temp=str_replace('&', '%26', dirname($dir_url)).'/'.str_replace('%2F', '/', (rawurlencode($dir.$item)));
193 if(is_numeric($filesize)) $filesize = round($filesize/(1024*1024), 2);
1c6591f3
H
194 echo("<tr class=\"$parclass\" bgcolor=\"$parcolor\">".'<td><a href="#up">'.$index.'</a></td><td class="btntd">');
195 echo('<a href="?download&song='.rawurlencode($temp).'" class="icon iplay">P</a>');
ca88871f
H
196 if($parent) {
197 echo('/<a href="?dir='.
198 substr(str_replace(array('&','%2F'), array('%26','/'), (rawurlencode(dirname($dir.$item)))), strlen($GLOBALS['music_dir'])).
1c6591f3 199 '" class="icon ifolder">D</a>');
ca88871f 200 }
1c6591f3
H
201 if($GLOBALS['useflash'] && eregi(('\.('.$GLOBALS['m3u_exts'].')$'), $item)) {
202 echo('/<a href="?f&song='.rawurlencode($temp).
203 '" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifplay">F</a>/'.
204 '<a href="?blank" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifstop">S</a>');
ca88871f 205 }
d09c0b59
H
206 echo('&nbsp;</td><td class="maximize-width"><a href="'.$temp.'">'.unxss(str_replace('-',' - ',str_replace('_', ' ',
207$item))).'</a></td><td>'.$filesize."&nbsp;MiB&nbsp;</td></tr>\n");
1c6591f3
H
208}
209
4e7a2682
H
210function render_dir_line($current_dir, $item, $i) {
211 $parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white');
aa3a0f32
H
212 $temp=str_replace('%2F', '/', rawurlencode($current_dir)).rawurlencode($item);
213 echo("<tr class=\"$parclass directory\" bgcolor=\"$parcolor\">".
214 '<td><a href="#up">'.$i.'</a></td><td class="btntd"><a href="?download&playlist&dir='.$temp.'" class="icon iplay">P</a>/'.
215 '<a href="?download&recursive&playlist&dir='.$temp.'" class="icon irplay">R</a>');
216 if($GLOBALS['useflash']) echo('/<a href="?f&playlist&dir='.$temp.'" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifplay">F</a>');
53d2c31c 217 echo('</td><td colspan="100%" class="maximize-width"><span class="icon ifolder">[DIR] </span><a href="?dir='.$temp.'">'.unxss(str_replace('_', ' ', $item)).
aa3a0f32
H
218 "</a></td></tr>\n");
219}
220
1c6591f3
H
221function render_tr_playframe_show() {
222 if($GLOBALS['flash_player_frame'] == 'playframe-show' && $GLOBALS['useflash']) { ?>
223<tr id="playframe-tr">
3df60b68 224<td><a href="?blank" target="playframe-show" title="Stop playback" class="icon ifstop">S</a></td>
1c6591f3
H
225<td colspan="100%">
226<iframe
227src="?blank"
228name="playframe-show"
229width="100%"
230height="24"
3df60b68 231style="border:none;"
1c6591f3
H
232transparentpagebg="yes"
233></iframe></td></tr>
234 <?php }
235}
236
237function render_footer() {
238 $quotes = array(
239 'This is NOT advertisments. This is just good text to think about... Remove it if you want!',
240 'Downloading without sharing and other forms of leeching equals STEALING! ;P',
241 'Do NOT support Microsoft!!! Use Linux! ;D',
242 'Don\'t steal! Steal and share!!! ;P',
243 'Linux is not matter of price, it\'s matter of freedom!',
244 'This software brought to you by <a href="http://blog.Harvie.cz">Harvie</a> free of charge! Of course...',
245 'Don\'t be looser, use GNU/Linux! ;P',
246 'Make love and not war!',
247 'Take your chance! Prove yourself!',
c081f974
H
248 'This software is free of charge. If you wan\'t to donate, please send some money to children in Africa/etc...',
249 'Fork <a href="http://github.com/harvie/jukebox">'.$GLOBALS['title'].'</a> on GIThub :-)<a href="http://github.com/harvie/jukebox"><img style="position: absolute; top: 0; left: 0; border: 0; height:120px; background-color:transparent;" src="http://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png" alt="Fork me on GitHub" /></a>'
1c6591f3
H
250 );
251
252 echo('<span id="quote" style="float: left;"><i><small>'.$quotes[rand(0,sizeof($quotes)-1)]."</small></i></span>\n");
253 echo('<span id="exectime" style="float: right;"><small>Page was generated in '.(round(microtime(true), 3) - $GLOBALS['exec_time']).'
254seconds</small></span>');
255 @readfile($GLOBALS['footer_file']);
256 echo('</body></html>');
ca88871f
H
257}
258
259function unxss($string) {
1c6591f3
H
260 return htmlspecialchars($string);
261}
262
263function explode_path($dir) {
264 $dir = substr($dir, strlen($GLOBALS['music_dir'])+1);
265 $temp = split('/', ereg_replace('/+', '/', $dir));
266 $out = '';
267 for($j=sizeof($temp)-1;$j>0;$j--) {
268 $dir = '';
269 for($i=0;$i<(sizeof($temp)-$j);$i++) {
270 $dir.=$temp[$i].'/';
271 }
272 $out.='<a href="?dir='.rawurlencode($dir).'">'.unxss($temp[$i-1]).'</a>/';
273 }
274 return('<a href="?">.</a>/'.$out);
275}
276
277function flash_mp3_player() {
278 ?>
279<html><head><title><?=$GLOBALS['title']?>: Flash Music Player Plugin</title>
280<style> * { margin: 0; padding: 0; border: 0; } </style></head><body>
281<object width="100%" height="344">
282 <embed src="<?php
283 echo($GLOBALS['flash_player_swf'].$GLOBALS['flash_player_options']);
284 if(isset($_GET['song'])) echo(rawurlencode($_GET['song']));
285 if(isset($_GET['playlist'])) generate_m3u($GLOBALS['dir'], dirname($GLOBALS['music_dir_url']), isset($_GET['recursive']), ',', true);
286 ?>"
287 type="application/x-shockwave-flash"
288 allowscriptaccess="never"
289 allowfullscreen="true"
290 transparentpagebg="yes"
291 quality="low"
292 width="100%" height="24px"
293 >You need Adobe Flash enabled browser to play records directly in website.</embed>
294</object></body></html>
295<?php die();
ca88871f
H
296}
297
298//GET
6cded674 299if(isset($_GET['dj'])) { ?><title><?php echo "DJ MODE @ $title"; ?></title><frameset cols="*,*"><frame name="dj-left" src="./"><frame name="dj-right" src="./"></frameset><?php die(); }
ca88871f 300if(isset($_GET['download'])) serve_download($playlist_name);
1c6591f3
H
301if(isset($_GET['f'])) flash_mp3_player();
302if(isset($_GET['song'])) {
303 die($_GET['song']."\r\n");
304}
305
306
ca88871f
H
307
308if($_POST['cache-refresh'] == $cache_passwd) {
309 generate_search_cache($music_dir, $search_cache);
310 die("\n");
311}
312
313if(isset($_GET['playlist'])) {
1c6591f3
H
314 generate_m3u($dir, dirname($music_dir_url), isset($_GET['recursive']));
315 die();
ca88871f
H
316}
317
318if(isset($_GET['random'])) {
319 $flen = 0;
320 if(!($searchfp = fopen($search_cache, 'r')))
321 die("Cannot read cache from $outfile<br />Refresh cache or set permissions properly!<br />\n");
322 while(!feof($searchfp)) { fgets($searchfp); $flen++; }
323 for($i=0; $i<$_GET['random']; $i++) {
324 rewind($searchfp);
325 for($j=0; $j<rand(0, $flen-1); $j++) fgets($searchfp);
326 echo(dirname($music_dir_url).'/'.str_replace('%2F', '/', (rawurlencode(trim(fgets($searchfp)))))."\r\n");
327 }
1c6591f3
H
328 die();
329}
330
331if(isset($_GET['blank'])) {
332 ?>
333 <link rel="stylesheet" type="text/css" href="<?=$css_file?>" />
334 <body class="blank"><div class="blank"><b>Music player</b> <small><i>(click 'F' link next to the song name to start, 'S' to stop...)</i></small></div></body>
335 <?php die();
ca88871f
H
336}
337
338?>
4df85024 339<!DOCTYPE html>
1c6591f3
H
340<meta http-equiv="Content-Type" content="text/html; charset=<?=$charset?>" />
341<html>
342 <head>
4df85024 343 <meta charset="<?=$charset?>" />
1c6591f3
H
344 <link rel="stylesheet" type="text/css" href="<?=$css_file?>" />
345 <link rel="shortcut icon" href="<?=$favicon_file?>" />
346 <link href="<?=$favicon_file?>" rel="icon" type="image/gif" />
347 </head>
348 <body>
ca88871f 349
00f09b5d 350<div align="right" style="position: absolute; top: 5px; right: 5px;">
1c6591f3 351 <a name="up"></a>
a74cdde6 352 <iframe src="about:blank" name="playframe-hide" width="0" height="0" style="border: none;" class="hide"></iframe><!-- -----------???--------------- -->
1c6591f3 353 <span class="icon">&lt;</span> <a href="javascript: history.go(-1)" class="icon iback">BACK</a>
6cded674 354 | <a href="?" target="_parent" class="icon ihome">HOME&nbsp;(<?=$music_dir?>)</a>
5cf5c6eb 355 | <a href="?dj" class="icon idjmode">DJ</a>
1c6591f3
H
356 | <a href="?help" class="icon ihelp">ABOUT/HELP</a>
357 | <a href="?logout" class="icon ilogout">LOGOUT</a>
ca88871f
H
358</div>
359
360<?php
361if(isset($_GET['help'])) {
362 ?><h1>About/Help</h1><?php
363 readfile($bonus_dir.'/help.html');
364 die();
365}
366
1c6591f3 367
ca88871f 368if(!isset($_GET['search'])) {
1c6591f3
H
369 echo('<title>'.$title.': '.unxss($dir).'</title>');
370 echo('<a href="?" style="color: black;"><h1 style="float: left;">'.$title.'</h1></a><h2 style="clear: left; display: inline; float: left;">Index of: '.explode_path($dir).'</h2>');
ca88871f
H
371} else {
372 echo('<title>'.$title.': '.unxss($_GET['search']).'</title>');
1c6591f3 373 echo('<a href="?" style="color: black;"><h1 style="float: left;">'.$title.'</h1></a><h2 style="clear: left; display: inline; float: left;">Searching for: '.unxss($_GET['search']).'</h2>');
ca88871f
H
374
375?>
376
1c6591f3
H
377<?php
378}
379
380?>
381<span style="float: right;">
ca88871f
H
382 <form action="?" method="GET" align="right" style="display: inline;">
383 <input type="hidden" name="download" value="" />
a6ec3d5f
H
384 <input type="number" min="1" name="random" value="<?=$default_random_count?>" style="width:4em;" title="how many randomly selected tracks should be in
385playlist?"
386/>
ca88871f
H
387 <input type="submit" value="random" title="Generate random music playlist..." />
388 </form>
389 <form action="?" method="GET" align="right" style="display: inline;">
c40ae8c7 390 <span class="icon isearch"></span><input type="search" name="search" autofocus placeholder="search regexp..."
ca88871f
H
391 title="Search in music/google/lyrics/mp3/youtube; Hint: You can use regular expressions in search query..."
392 value="<?=unxss($_GET['search'])?>"
393 />
394 <input type="submit" value="search" title="Search in this JuKe!Box..." />
395 </form>
1c6591f3 396</span><?php
ca88871f 397
1c6591f3
H
398if(!isset($_GET['search'])) {
399 echo('<br style="clear: both;" />');
400} else {
ca88871f 401
1c6591f3
H
402?>
403<span style="float: right;">
ca88871f 404 <form action="?" method="POST" align="right">
a6ec3d5f 405 <input type="password" name="cache-refresh" value="" style="width:5em;" title="Password for refreshing - good for avoiding DoS Attacks!!!" />
ca88871f 406 <input type="submit" value="refresh cache" title="You should refresh cache each time when you add new music or upgrade to newer version of JuKe!Box !!!" />
1c6591f3 407 &nbsp;
ca88871f 408 </form>
1c6591f3
H
409</span>
410<div align="right" style="clear: right;" title="Aditional search engines...">
411<br />
412<?php
413 $search_prefix = 0;
414 foreach($search_engines as $search_desc => $search_link) {
415 if(!$search_prefix) {
416 echo(unxss($_GET['search'])." @\n");
417 $search_prefix = 1;
418 }
419 echo('<a href="'.$search_link.rawurlencode($_GET['search']).'">'.$search_desc."</a>;\n");
420 }
421?>
422</div><br style="clear: both;" />
423<?php
424echo('<small>Search DB size: '.(filesize($search_cache)/1024)." kB<br /></small>\n");
ca88871f
H
425
426if(!($searchfp = fopen($search_cache, 'r')))
427 die("Cannot read cache from $outfile<br />Refresh cache or set permissions properly!<br />\n");
428
429$i = 0;
430echo('<table border="1" width="100%">');
1c6591f3 431render_tr_playframe_show();
37c84adf
H
432echo('<tr class="directory"><td>S</td><td><a href="?download&playlist&search='.unxss($_GET['search']).'" class="icon iplay">P</a>');
433if($GLOBALS['useflash']) echo('/<a href="?f&playlist&search='.unxss($_GET['search']).'" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifplay">F</a>');
1c6591f3
H
434echo('</td><td colspan="100%">Search: '.unxss($_GET['search']).'</td></tr>');
435
ca88871f
H
436while(!feof($searchfp)) {
437 $line = trim(fgets($searchfp));
1c6591f3
H
438 $parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white');
439 if(@eregi(str_replace(' ', '(.*)', unational($_GET['search'])), unational($line))) {
ca88871f 440 $i++;
ca88871f
H
441 $filesize = 0; if($i <= $access_limit) $filesize = filesize($line); else $filesize = 'n/a';
442 render_file_line('', $line, $music_dir_url, $i, $filesize, true);
ca88871f
H
443 }
444}
1c6591f3
H
445echo('<tr><td colspan="100%">Total: '.$i.' results...</td></tr></table>');
446render_footer(); die();
ca88871f
H
447
448}
449@readfile($header_file);
450foreach($indexlist as $index) @readfile($dir.$index);
451?>
452<br />
453<table border="1" width="100%">
1c6591f3
H
454<?php render_tr_playframe_show(); ?>
455
456<tr class="directory"><td>&gt;</td>
a74cdde6
H
457<td><a href="?download&playlist&dir=<?=str_replace('%2F', '/', rawurlencode($current_dir))?>" class="icon iplay">P</a>/<a
458href="?download&recursive&playlist&dir=<?=str_replace('%2F', '/', rawurlencode($current_dir))?>" class="icon irplay">R</a><?php
459if($GLOBALS['useflash']) echo('/<a href="?f&playlist&dir='.str_replace('%2F', '/', rawurlencode($current_dir)).'" target="'.$GLOBALS['flash_player_frame'].'"
460class="icon ifplay">F</a>'); ?>
1c6591f3
H
461</td>
462<td colspan="100%"><?=unxss($dir)?></td></tr>
2721a24c
H
463<tr><td>^</td><td>&nbsp;</td><td colspan="100%" class="directory"><span class="icon ifolder">[DIR] </span><a href="?dir=<?=rawurlencode($parent_dir)?>">..
464(<?=$parent_dir?>)</a></td></tr>
ca88871f
H
465<?php
466
467$i = 0;
468$dd = opendir($dir);
469for($s=2;$s;$s--) { while(($item = readdir($dd)) != false) {
470 if($item == '.' || $item == '..') continue;
471 if(($s==2 && is_file($dir.$item)) || ($s!=2 && is_dir($dir.$item))) continue;
472 $i++;
aa3a0f32
H
473 //$parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white');
474 if($sort > 1) {
ca88871f 475 if(is_file($dir.$item)) {
aa3a0f32
H
476 $i--;
477 $itemsf[] = $item;
ca88871f
H
478 }
479 if(is_dir($dir.$item)) {
aa3a0f32
H
480 $i--;
481 $itemsd[] = $item;
482 }
483 } else {
484 if(is_file($dir.$item)) {
485 render_file_line($dir, $item, $music_dir_url, $i, filesize($dir.$item));
ca88871f 486 }
aa3a0f32 487 if(is_dir($dir.$item)) {
4e7a2682 488 render_dir_line($current_dir, $item, $i);
aa3a0f32
H
489 }
490 }
ca88871f 491} rewinddir($dd); }
aa3a0f32 492
ca88871f 493if($sort > 1) {
aa3a0f32
H
494 @sort($itemsf);
495 @sort($itemsd);
496 foreach($itemsd as $item) {
497 $i++;
4e7a2682 498 render_dir_line($current_dir, $item, $i);
aa3a0f32
H
499 }
500 foreach($itemsf as $item) {
ca88871f
H
501 $i++;
502 render_file_line($dir, $item, $music_dir_url, $i, filesize($dir.$item));
503 }
504}
505
506?></table>
507
508<?php
1c6591f3 509render_footer();
This page took 0.477607 seconds and 4 git commands to generate.