tuned filename presentation a bit
[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); /*
ca88871f 3Harvie's JuKe!Box
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)
15 * 0.1 - All functions works - TODO: bugfix & replace ugly code
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)
ca88871f 79$current_dir = ereg_replace('/+', '/', '/'.$_GET['dir'].'/');
1c6591f3
H
80if(eregi('(/|\\\\)\\.\\.(/|\\\\)', $current_dir)) { //check for directory traversal ;)
81 header('Location: ?');
82 die('Error - directory not found!');
83}
ca88871f
H
84$dir = $music_dir.$current_dir;
85$url = $music_dir_url.$current_dir;
86$parent_dir = dirname($current_dir);
87
88//FCs
89function serve_download($filename) {
90 header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
91 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
92 header('Pragma: no-cache');
93
94 //header('Content-Type: application/force-download');
95 header('Content-Type: audio/x-mpegurl');
96 header("Content-Disposition: attachment; filename={$filename}");
97 header('Content-Transfer-Encoding: binary');
98
99 header('X-PHP-Application: Harvie\'s JuKe!Box');
100}
101
1c6591f3
H
102$nchars_f = array('Á','Ä','Č','Ç','Ď','É','Ě','Ë','Í','Ň','Ó','Ö','Ř','Š','Ť','Ú','Ů','Ü','Ý','Ž','á','ä','č','ç','ď','é','ě','ë','í','ň','ó','ö','ř','š','ť','ú','ů','ü','ý','ž');
103$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');
104
105function unational($text) {
106 if(!$GLOBALS['national_characters']) return $text;
107 return(str_replace($GLOBALS['nchars_f'], $GLOBALS['nchars_t'], $text));
108}
109
110function generate_m3u($dir, $prefix='', $recursive=0, $nl="\r\n", $doubleenc=0) {
ca88871f 111 $dir = $dir . '/';
1c6591f3
H
112 if(isset($_GET['newline'])) $nl = $_GET['newline'];
113 if(!isset($_GET['search'])) {
114 $dd = opendir($dir);
115 while(($item = readdir($dd)) != false) {
116 if($item == '.' || $item == '..') continue;
117 if( is_file($dir.$item) && eregi(('\.('.$GLOBALS['m3u_exts'].')$'), $item) ) {
118 if($GLOBALS['sort'] > 0) {
119 $temp[] = $item;
120 } else {
121 $item=($prefix.'/'.str_replace('%2F', '/', (rawurlencode($dir.$item))).$nl);
122 if($doubleenc) $item = rawurlencode($item);
123 echo($item);
124 }
125 }
126 if($recursive && is_dir($dir.$item)) {
127 generate_m3u($dir.$item, $prefix, $recursive, $nl, $doubleenc);
128 }
129 }
130 } else {
131 if(!($searchfp = fopen($GLOBALS['search_cache'], 'r')))
132 die("Cannot read cache from $outfile<br />Refresh cache or set permissions properly!<br />\n");
133 while(!feof($searchfp)) {
134 $line = trim(fgets($searchfp));
135 if(@eregi(str_replace(' ', '(.*)', unational($_GET['search'])), unational($line))) {
136 $line=(dirname($GLOBALS['music_dir_url']).'/'.str_replace('%2F', '/', (rawurlencode($line))).$nl);
137 if($doubleenc) $line = rawurlencode($line);
138 echo($line);
ca88871f
H
139 }
140 }
ca88871f 141 }
1c6591f3 142
ca88871f
H
143 if($GLOBALS['sort'] > 0) {
144 @sort($temp);
1c6591f3
H
145 foreach($temp as $item) {
146 $temp=($prefix.'/'.str_replace('%2F', '/', (rawurlencode($dir.$item))).$nl);
147 if($doubleenc) $temp = rawurlencode($temp);
148 echo($temp);
149 }
ca88871f
H
150 }
151}
152
153function write_search_cache($dir, $outfp) {
154 $dir = $dir . '/';
155 $dd = opendir($dir);
156 while($item = readdir($dd)) {
157 if($item == '.' || $item == '..') continue;
158 if( is_file($dir.$item) && eregi(('\.('.$GLOBALS['m3u_exts'].')$'), $item) ) {
159 fwrite($outfp, $dir.$item."\n");
160 }
161 if(is_dir($dir.$item)) {
162 write_search_cache($dir.$item, $outfp);
163 }
164 }
165}
166
167function generate_search_cache($dir, $outfile) {
168 echo("Generating search cache. Please wait...<br />\n"); flush();
169 @chmod($outfile, 0755); //At least i tryed ;D
170 if(!($outfp = fopen($outfile, 'w')))
171 die("Cannot write cache to $outfile<br />You probably haven't set the permissions properly!<br />\n");
172 write_search_cache($dir, $outfp);
173 fclose($outfp);
174 $osize = filesize($outfile); clearstatcache();
175 if($GLOBALS['sort'] > 2) {
176 echo("Sorting search cache. Please wait...<br />\n"); flush();
177
178 $items = file($outfile); @sort($items);
179 $total = ' ('.sizeof($items).' files)';
180 file_put_contents($outfile, @implode('', $items));
181 unset($items);
182 if(abs(filesize($outfile)-$osize) > 2)
183 die('ERROR! Please disable sorting of search cache ($sort < 3)<br />'."\nSorted only ".
184 filesize($outfile).' of '.$osize.' bytes!!!\n');
185 }
186 echo('Total: '.filesize($outfile).' of '.$osize.' bytes'.$total.' <a href="?">DONE!</a>'.'<br /><META http-equiv="refresh" content="2;URL=?">'."\n");
187}
188
189function render_file_line($dir, $item, $dir_url, $index, $filesize, $parent = false) {
1c6591f3 190 $parclass=($index%2?'even':'odd'); $parcolor=($index%2?'lightblue':'white');
ca88871f
H
191 $temp=str_replace('&', '%26', dirname($dir_url)).'/'.str_replace('%2F', '/', (rawurlencode($dir.$item)));
192 if(is_numeric($filesize)) $filesize = round($filesize/(1024*1024), 2);
1c6591f3
H
193 echo("<tr class=\"$parclass\" bgcolor=\"$parcolor\">".'<td><a href="#up">'.$index.'</a></td><td class="btntd">');
194 echo('<a href="?download&song='.rawurlencode($temp).'" class="icon iplay">P</a>');
ca88871f
H
195 if($parent) {
196 echo('/<a href="?dir='.
197 substr(str_replace(array('&','%2F'), array('%26','/'), (rawurlencode(dirname($dir.$item)))), strlen($GLOBALS['music_dir'])).
1c6591f3 198 '" class="icon ifolder">D</a>');
ca88871f 199 }
1c6591f3
H
200 if($GLOBALS['useflash'] && eregi(('\.('.$GLOBALS['m3u_exts'].')$'), $item)) {
201 echo('/<a href="?f&song='.rawurlencode($temp).
202 '" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifplay">F</a>/'.
203 '<a href="?blank" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifstop">S</a>');
ca88871f 204 }
d09c0b59
H
205 echo('&nbsp;</td><td class="maximize-width"><a href="'.$temp.'">'.unxss(str_replace('-',' - ',str_replace('_', ' ',
206$item))).'</a></td><td>'.$filesize."&nbsp;MiB&nbsp;</td></tr>\n");
1c6591f3
H
207}
208
4e7a2682
H
209function render_dir_line($current_dir, $item, $i) {
210 $parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white');
aa3a0f32
H
211 $temp=str_replace('%2F', '/', rawurlencode($current_dir)).rawurlencode($item);
212 echo("<tr class=\"$parclass directory\" bgcolor=\"$parcolor\">".
213 '<td><a href="#up">'.$i.'</a></td><td class="btntd"><a href="?download&playlist&dir='.$temp.'" class="icon iplay">P</a>/'.
214 '<a href="?download&recursive&playlist&dir='.$temp.'" class="icon irplay">R</a>');
215 if($GLOBALS['useflash']) echo('/<a href="?f&playlist&dir='.$temp.'" target="'.$GLOBALS['flash_player_frame'].'" class="icon ifplay">F</a>');
53d2c31c 216 echo('</td><td colspan="100%" class="maximize-width"><span class="icon ifolder">[DIR] </span><a href="?dir='.$temp.'">'.unxss(str_replace('_', ' ', $item)).
aa3a0f32
H
217 "</a></td></tr>\n");
218}
219
1c6591f3
H
220function render_tr_playframe_show() {
221 if($GLOBALS['flash_player_frame'] == 'playframe-show' && $GLOBALS['useflash']) { ?>
222<tr id="playframe-tr">
223<td><a href="?blank" target="playframe-show" title="Stop playback">S</a></td>
224<td colspan="100%">
225<iframe
226src="?blank"
227name="playframe-show"
228width="100%"
229height="24"
230style="border: none;"
231transparentpagebg="yes"
232></iframe></td></tr>
233 <?php }
234}
235
236function render_footer() {
237 $quotes = array(
238 'This is NOT advertisments. This is just good text to think about... Remove it if you want!',
239 'Downloading without sharing and other forms of leeching equals STEALING! ;P',
240 'Do NOT support Microsoft!!! Use Linux! ;D',
241 'Don\'t steal! Steal and share!!! ;P',
242 'Linux is not matter of price, it\'s matter of freedom!',
243 'This software brought to you by <a href="http://blog.Harvie.cz">Harvie</a> free of charge! Of course...',
244 'Don\'t be looser, use GNU/Linux! ;P',
245 'Make love and not war!',
246 'Take your chance! Prove yourself!',
247 'This software is free of charge. If you wan\'t to donate, please send some money to children in Africa/etc...'
248 );
249
250 echo('<span id="quote" style="float: left;"><i><small>'.$quotes[rand(0,sizeof($quotes)-1)]."</small></i></span>\n");
251 echo('<span id="exectime" style="float: right;"><small>Page was generated in '.(round(microtime(true), 3) - $GLOBALS['exec_time']).'
252seconds</small></span>');
253 @readfile($GLOBALS['footer_file']);
254 echo('</body></html>');
ca88871f
H
255}
256
257function unxss($string) {
1c6591f3
H
258 return htmlspecialchars($string);
259}
260
261function explode_path($dir) {
262 $dir = substr($dir, strlen($GLOBALS['music_dir'])+1);
263 $temp = split('/', ereg_replace('/+', '/', $dir));
264 $out = '';
265 for($j=sizeof($temp)-1;$j>0;$j--) {
266 $dir = '';
267 for($i=0;$i<(sizeof($temp)-$j);$i++) {
268 $dir.=$temp[$i].'/';
269 }
270 $out.='<a href="?dir='.rawurlencode($dir).'">'.unxss($temp[$i-1]).'</a>/';
271 }
272 return('<a href="?">.</a>/'.$out);
273}
274
275function flash_mp3_player() {
276 ?>
277<html><head><title><?=$GLOBALS['title']?>: Flash Music Player Plugin</title>
278<style> * { margin: 0; padding: 0; border: 0; } </style></head><body>
279<object width="100%" height="344">
280 <embed src="<?php
281 echo($GLOBALS['flash_player_swf'].$GLOBALS['flash_player_options']);
282 if(isset($_GET['song'])) echo(rawurlencode($_GET['song']));
283 if(isset($_GET['playlist'])) generate_m3u($GLOBALS['dir'], dirname($GLOBALS['music_dir_url']), isset($_GET['recursive']), ',', true);
284 ?>"
285 type="application/x-shockwave-flash"
286 allowscriptaccess="never"
287 allowfullscreen="true"
288 transparentpagebg="yes"
289 quality="low"
290 width="100%" height="24px"
291 >You need Adobe Flash enabled browser to play records directly in website.</embed>
292</object></body></html>
293<?php die();
ca88871f
H
294}
295
296//GET
297if(isset($_GET['download'])) serve_download($playlist_name);
1c6591f3
H
298if(isset($_GET['f'])) flash_mp3_player();
299if(isset($_GET['song'])) {
300 die($_GET['song']."\r\n");
301}
302
303
ca88871f
H
304
305if($_POST['cache-refresh'] == $cache_passwd) {
306 generate_search_cache($music_dir, $search_cache);
307 die("\n");
308}
309
310if(isset($_GET['playlist'])) {
1c6591f3
H
311 generate_m3u($dir, dirname($music_dir_url), isset($_GET['recursive']));
312 die();
ca88871f
H
313}
314
315if(isset($_GET['random'])) {
316 $flen = 0;
317 if(!($searchfp = fopen($search_cache, 'r')))
318 die("Cannot read cache from $outfile<br />Refresh cache or set permissions properly!<br />\n");
319 while(!feof($searchfp)) { fgets($searchfp); $flen++; }
320 for($i=0; $i<$_GET['random']; $i++) {
321 rewind($searchfp);
322 for($j=0; $j<rand(0, $flen-1); $j++) fgets($searchfp);
323 echo(dirname($music_dir_url).'/'.str_replace('%2F', '/', (rawurlencode(trim(fgets($searchfp)))))."\r\n");
324 }
1c6591f3
H
325 die();
326}
327
328if(isset($_GET['blank'])) {
329 ?>
330 <link rel="stylesheet" type="text/css" href="<?=$css_file?>" />
331 <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>
332 <?php die();
ca88871f
H
333}
334
335?>
336<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1c6591f3
H
337<meta http-equiv="Content-Type" content="text/html; charset=<?=$charset?>" />
338<html>
339 <head>
340 <link rel="stylesheet" type="text/css" href="<?=$css_file?>" />
341 <link rel="shortcut icon" href="<?=$favicon_file?>" />
342 <link href="<?=$favicon_file?>" rel="icon" type="image/gif" />
343 </head>
344 <body>
ca88871f 345
00f09b5d 346<div align="right" style="position: absolute; top: 5px; right: 5px;">
1c6591f3 347 <a name="up"></a>
a74cdde6 348 <iframe src="about:blank" name="playframe-hide" width="0" height="0" style="border: none;" class="hide"></iframe><!-- -----------???--------------- -->
1c6591f3
H
349 <span class="icon">&lt;</span> <a href="javascript: history.go(-1)" class="icon iback">BACK</a>
350 | <a href="?"><span class="icon ihome">HOME</span> (<?=$music_dir?>)</a>
351 | <a href="?help" class="icon ihelp">ABOUT/HELP</a>
352 | <a href="?logout" class="icon ilogout">LOGOUT</a>
ca88871f
H
353</div>
354
355<?php
356if(isset($_GET['help'])) {
357 ?><h1>About/Help</h1><?php
358 readfile($bonus_dir.'/help.html');
359 die();
360}
361
1c6591f3 362
ca88871f 363if(!isset($_GET['search'])) {
1c6591f3
H
364 echo('<title>'.$title.': '.unxss($dir).'</title>');
365 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
366} else {
367 echo('<title>'.$title.': '.unxss($_GET['search']).'</title>');
1c6591f3 368 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
369
370?>
371
1c6591f3
H
372<?php
373}
374
375?>
376<span style="float: right;">
ca88871f
H
377 <form action="?" method="GET" align="right" style="display: inline;">
378 <input type="hidden" name="download" value="" />
a6ec3d5f
H
379 <input type="number" min="1" name="random" value="<?=$default_random_count?>" style="width:4em;" title="how many randomly selected tracks should be in
380playlist?"
381/>
ca88871f
H
382 <input type="submit" value="random" title="Generate random music playlist..." />
383 </form>
384 <form action="?" method="GET" align="right" style="display: inline;">
c40ae8c7 385 <span class="icon isearch"></span><input type="search" name="search" autofocus placeholder="search regexp..."
ca88871f
H
386 title="Search in music/google/lyrics/mp3/youtube; Hint: You can use regular expressions in search query..."
387 value="<?=unxss($_GET['search'])?>"
388 />
389 <input type="submit" value="search" title="Search in this JuKe!Box..." />
390 </form>
1c6591f3 391</span><?php
ca88871f 392
1c6591f3
H
393if(!isset($_GET['search'])) {
394 echo('<br style="clear: both;" />');
395} else {
ca88871f 396
1c6591f3
H
397?>
398<span style="float: right;">
ca88871f 399 <form action="?" method="POST" align="right">
a6ec3d5f 400 <input type="password" name="cache-refresh" value="" style="width:5em;" title="Password for refreshing - good for avoiding DoS Attacks!!!" />
ca88871f 401 <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 402 &nbsp;
ca88871f 403 </form>
1c6591f3
H
404</span>
405<div align="right" style="clear: right;" title="Aditional search engines...">
406<br />
407<?php
408 $search_prefix = 0;
409 foreach($search_engines as $search_desc => $search_link) {
410 if(!$search_prefix) {
411 echo(unxss($_GET['search'])." @\n");
412 $search_prefix = 1;
413 }
414 echo('<a href="'.$search_link.rawurlencode($_GET['search']).'">'.$search_desc."</a>;\n");
415 }
416?>
417</div><br style="clear: both;" />
418<?php
419echo('<small>Search DB size: '.(filesize($search_cache)/1024)." kB<br /></small>\n");
ca88871f
H
420
421if(!($searchfp = fopen($search_cache, 'r')))
422 die("Cannot read cache from $outfile<br />Refresh cache or set permissions properly!<br />\n");
423
424$i = 0;
425echo('<table border="1" width="100%">');
1c6591f3
H
426render_tr_playframe_show();
427echo('<tr><td>S</td><td><a href="?download&playlist&search='.unxss($_GET['search']).'">P</a>');
428if($GLOBALS['useflash']) echo('/<a href="?f&playlist&search='.unxss($_GET['search']).'" target="'.$GLOBALS['flash_player_frame'].'">F</a>');
429echo('</td><td colspan="100%">Search: '.unxss($_GET['search']).'</td></tr>');
430
ca88871f
H
431while(!feof($searchfp)) {
432 $line = trim(fgets($searchfp));
1c6591f3
H
433 $parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white');
434 if(@eregi(str_replace(' ', '(.*)', unational($_GET['search'])), unational($line))) {
ca88871f 435 $i++;
ca88871f
H
436 $filesize = 0; if($i <= $access_limit) $filesize = filesize($line); else $filesize = 'n/a';
437 render_file_line('', $line, $music_dir_url, $i, $filesize, true);
ca88871f
H
438 }
439}
1c6591f3
H
440echo('<tr><td colspan="100%">Total: '.$i.' results...</td></tr></table>');
441render_footer(); die();
ca88871f
H
442
443}
444@readfile($header_file);
445foreach($indexlist as $index) @readfile($dir.$index);
446?>
447<br />
448<table border="1" width="100%">
1c6591f3
H
449<?php render_tr_playframe_show(); ?>
450
451<tr class="directory"><td>&gt;</td>
a74cdde6
H
452<td><a href="?download&playlist&dir=<?=str_replace('%2F', '/', rawurlencode($current_dir))?>" class="icon iplay">P</a>/<a
453href="?download&recursive&playlist&dir=<?=str_replace('%2F', '/', rawurlencode($current_dir))?>" class="icon irplay">R</a><?php
454if($GLOBALS['useflash']) echo('/<a href="?f&playlist&dir='.str_replace('%2F', '/', rawurlencode($current_dir)).'" target="'.$GLOBALS['flash_player_frame'].'"
455class="icon ifplay">F</a>'); ?>
1c6591f3
H
456</td>
457<td colspan="100%"><?=unxss($dir)?></td></tr>
2721a24c
H
458<tr><td>^</td><td>&nbsp;</td><td colspan="100%" class="directory"><span class="icon ifolder">[DIR] </span><a href="?dir=<?=rawurlencode($parent_dir)?>">..
459(<?=$parent_dir?>)</a></td></tr>
ca88871f
H
460<?php
461
462$i = 0;
463$dd = opendir($dir);
464for($s=2;$s;$s--) { while(($item = readdir($dd)) != false) {
465 if($item == '.' || $item == '..') continue;
466 if(($s==2 && is_file($dir.$item)) || ($s!=2 && is_dir($dir.$item))) continue;
467 $i++;
aa3a0f32
H
468 //$parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white');
469 if($sort > 1) {
ca88871f 470 if(is_file($dir.$item)) {
aa3a0f32
H
471 $i--;
472 $itemsf[] = $item;
ca88871f
H
473 }
474 if(is_dir($dir.$item)) {
aa3a0f32
H
475 $i--;
476 $itemsd[] = $item;
477 }
478 } else {
479 if(is_file($dir.$item)) {
480 render_file_line($dir, $item, $music_dir_url, $i, filesize($dir.$item));
ca88871f 481 }
aa3a0f32 482 if(is_dir($dir.$item)) {
4e7a2682 483 render_dir_line($current_dir, $item, $i);
aa3a0f32
H
484 }
485 }
ca88871f 486} rewinddir($dd); }
aa3a0f32 487
ca88871f 488if($sort > 1) {
aa3a0f32
H
489 @sort($itemsf);
490 @sort($itemsd);
491 foreach($itemsd as $item) {
492 $i++;
4e7a2682 493 render_dir_line($current_dir, $item, $i);
aa3a0f32
H
494 }
495 foreach($itemsf as $item) {
ca88871f
H
496 $i++;
497 render_file_line($dir, $item, $music_dir_url, $i, filesize($dir.$item));
498 }
499}
500
501?></table>
502
503<?php
1c6591f3 504render_footer();
This page took 0.549182 seconds and 4 git commands to generate.