| 1 | <?php
|
|---|
| 2 | include('../global.php');
|
|---|
| 3 | // Omezen� na online/offline u�ivatele
|
|---|
| 4 |
|
|---|
| 5 | $DbResult = $Database->query('SELECT id FROM hosts WHERE online=1 AND block=0 AND user>0');
|
|---|
| 6 | $Vyber = '';
|
|---|
| 7 | $Podminka = '';
|
|---|
| 8 | while ($Row = $DbResult->fetch_array())
|
|---|
| 9 | $Vyber .= $Row['id'].',';
|
|---|
| 10 | $Podminka .= ' AND (host IN ('.substr($Vyber,0,-1).'))';
|
|---|
| 11 | //echo($Podminka.'<br>');
|
|---|
| 12 |
|
|---|
| 13 | $Database->select_db('share');
|
|---|
| 14 |
|
|---|
| 15 | // Maxim�ln� vno�en�
|
|---|
| 16 | $MaxNesting = 20;
|
|---|
| 17 |
|
|---|
| 18 | // Najde cestu ke ke�enu
|
|---|
| 19 | function PlnaCesta($Row)
|
|---|
| 20 | {
|
|---|
| 21 | global $MaxNesting, $Database;
|
|---|
| 22 |
|
|---|
| 23 | // Vyhled�n� cesty
|
|---|
| 24 | $Otec = $Row['parent'];
|
|---|
| 25 | $Cesta = ''; //$Row['name'];
|
|---|
| 26 | $i = 0;
|
|---|
| 27 | while (($Otec>1)&&($i<$MaxNesting))
|
|---|
| 28 | {
|
|---|
| 29 | $DbResult = $Database->query("SELECT id,name,parent FROM items WHERE id=$Otec");
|
|---|
| 30 | $Row = $DbResult->fetch_array();
|
|---|
| 31 | $Cesta = $Row['name'].'\\'.$Cesta;
|
|---|
| 32 | $Otec = $Row['parent'];
|
|---|
| 33 | $i++;
|
|---|
| 34 | }
|
|---|
| 35 | if ($i >= $MaxNesting) $Cesta = '?'.'\\'.$Cesta;
|
|---|
| 36 | return '\\\\'.$Cesta;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | function mime_content_type($FileName)
|
|---|
| 40 | {
|
|---|
| 41 | //$FileInfo = new finfo(FILEINFO_MIME);
|
|---|
| 42 | //return $FileInfo->file($FileName);
|
|---|
| 43 | return '';
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | $Name = 'playlist.m3u';
|
|---|
| 47 | Header('Content-type: audio/x-mpegurl');
|
|---|
| 48 | Header('Content-Disposition: attachment; filename='.$Name);
|
|---|
| 49 | echo("#EXTM3U\n");
|
|---|
| 50 | $Parent = '0';
|
|---|
| 51 | $Dir = '';
|
|---|
| 52 | $DbResult = $Database->select('items', '*', 'ext="mp3"'.$Podminka); //.' LIMIT 0,1000');
|
|---|
| 53 | while ($Row = $DbResult->fetch_array())
|
|---|
| 54 | {
|
|---|
| 55 | if ($Parent != $Row['parent']) $Dir = PlnaCesta($Row); //echo('d'.PlnaCesta($Row)."\n");
|
|---|
| 56 | $Parent = $Row['parent'];
|
|---|
| 57 | echo($Dir.$Row['name'].'.'.$Row['ext']."\n");
|
|---|
| 58 | }
|
|---|