$pl->generate($_GET['random_play_type'], $_GET['random_play_number'], $_GET['random_play_genre']); $timer = round(microtime_float() - $timer, 2); if ($_GET['random_play_genre'] != "") { writeLogData('playback', "generated random playlist of " . $_GET['random_play_number'] . " tracks from genre '" . $_GET['random_play_genre'] . "' in {$timer} seconds."); } else { writeLogData('playback', "generated random playlist of " . $_GET['random_play_number'] . " tracks in {$timer} seconds."); } $pl->play(); exit; break; case "download": writeLogData("messages", "Index: Beginning a file download for: " . $_GET['jz_path']); //while (@ob_end_flush()); if ($_GET['type'] == "track" && $single_download_mode == "raw") { $el =& new jzMediaTrack($_GET['jz_path']); if (!checkStreamLimit($el)) { // TODO: AJAX this so we don't come to a page, but get a Javascript alert. echo word('Sorry, you have reached your download limit.'); exit; } // Are they downloading something resampled? if (stristr($_GET['jz_path'], "data/resample")) { $name = $el->getPath(); $name = $name[sizeof($name) - 1]; sendMedia($_GET['jz_path'], $name, $resample, true); } else { $el->increaseDownloadCount(); $name = $el->getPath(); $name = $name[sizeof($name) - 1]; sendMedia($el->getFileName("host"), $name, $resample, true); }
function download() { global $include_path; include_once $include_path . 'lib/jzcomp.lib.php'; include_once $include_path . 'lib/general.lib.php'; $pl = $this; if ($pl->getPlType() == "dynamic") { $pl->handleRules(); } $list = $pl->getList(); if (sizeof($list) == 0) { return; } // Can we download it? if (!checkStreamLimit($list)) { echo word('Sorry, you have reached your download limit.'); exit; } foreach ($list as $el) { $el->increaseDownloadCount(); } $pl->flatten(); $list = $pl->getList(); $i = 0; $files = array(); $m3u = ""; $oldPath = ""; $onepath = true; foreach ($list as $track) { $files[$i] = $track->getFileName("host"); // Let's also create the m3u playlist for all this $tArr = explode("/", $files[$i]); $m3u .= "./" . $tArr[count($tArr) - 1] . "\n"; $i++; // Now let's get the path and make sure we only see 1 unique path // If we see only one path we'll add art IF we can $pArr = $track->getPath(); unset($pArr[count($pArr) - 1]); $path = implode("/", $pArr); if ($path != $oldPath and $oldPath != "") { $onepath = false; } else { $oldPath = $path; } } $name = $this->getName(); if ($name === false || $name == "") { $name = "Playlist"; } // Now should we add art? if ($onepath) { // Ok, let's create the node so we can get the art $artNode = new jzMediaNode($oldPath); if ($artNode->getMainArt() != "") { $i++; $files[$i] = $artNode->getMainArt(); } } // Silly to send a 1 element playlist if (sizeof($files) > 1) { // Now let's write that to the temp dir $fileName = $include_path . "temp/playlist.m3u"; $handle = @fopen($fileName, "w"); @fwrite($handle, $m3u); @fclose($handle); $files[$i + 1] = $fileName; } // Now let's send it sendFileBundle($files, $name); }