= $num_songs) {
$anum = 0;
if (!is_array($_ad["$cnum"])) {
$cnum = 0;
}
$snum++;
$_outs["$snum"] = $_ad["$cnum"];
$cnum++;
}
$snum++;
$anum++;
}
$_song = $_outs;
$_outs = array();
unset($_outs);
}
jmRadioCounter($_post['id']);
}
elseif (isset($_post['mode']) && $_post['mode'] == 'video') {
$band_id = $_post['band_id'];
$video_id = $_post['video_id'];
$chk_id = 0;
if (is_numeric($band_id)) {
$chk_id = $band_id;
}
checkDeepLink($chk_id);
if (is_numeric($band_id) && is_numeric($video_id)) {
$_song = getVideoData($band_id,$video_id);
$_song = @array_values($_song);
if (!isset($_post['type']) || empty($_post['type'])) {
$_mext = getPlaylistExt($_song[0]["video_extension"]);
}
else {
$_mext = getPlaylistExt($_post['type']);
}
}
elseif (is_numeric($band_id) && $video_id == 'all') {
if (empty($_post['type'])) {
jmErrorPage('error - no type given for "all" mode - you must specify the extension i.e. wmv');
}
$_song = getVideoData($band_id,'all',$_post['type'],$_post['limit']);
$_song = @array_values($_song);
$_mext = getPlaylistExt($_post['type']);
if (!empty($_post['random'])) {
foreach(array_rand($_song,count($_song)) as $key => $val) {
$_news["$key"] = $_song["$val"];
}
$_song = $_news;
$_news = array();
unset($_news);
}
}
elseif (is_numeric($band_id) && !is_numeric($video_id)) {
$_song = getVideoData($band_id,$video_id);
$_song = @array_values($_song);
if (!isset($_post['type']) || empty($_post['type'])) {
$_mext = getPlaylistExt($_song[0]["video_extension"]);
}
else {
$_mext = getPlaylistExt($_post['type']);
}
}
elseif ($band_id == 'all' && $video_id == 'all') {
if (empty($_post['type'])) {
jmErrorPage('error - no type given for "all" mode - you must specify the extension i.e. wmv');
}
$_song = getVideoData('all','all',$_post['type'],$_post['limit']);
$_song = @array_values($_song);
$_mext = getPlaylistExt($_post['type']);
if (!empty($_post['random'])) {
foreach(array_rand($_song,count($_song)) as $key => $val) {
$_news["$key"] = $_song["$val"];
}
$_song = $_news;
$_news = array();
unset($_news);
}
}
elseif ($band_id == 'all' && is_array($video_id)) {
if (empty($_post['type'])) {
jmErrorPage('error - no type given for "all" mode - you must specify the extension i.e. wmv');
}
$_song = getVideoData('all',$video_id,$_post['type'],$_post['limit']);
$_mext = getPlaylistExt($_post['type']);
if (is_array($_song)) {
foreach ($video_id as $snum => $ssid) {
if (!is_array($_song["$ssid"])) {
continue;
}
$_news[] = $_song["$ssid"];
$_song["$ssid"] = array();
unset($_song["$ssid"]);
}
$_song = $_news;
$_news = array();
unset($_news);
}
}
if (!is_array($_song)) {
jmErrorPage("The playlist that was generated by your play.php request contained no data - verify usage");
}
}
else {
$band_id = $_post['band_id'];
$song_id = $_post['song_id'];
$chk_id = 0;
if (is_numeric($band_id)) {
$chk_id = $band_id;
}
checkDeepLink($chk_id);
if ((!isset($_post['mode']) || empty($_post['mode'])) || $_post['mode'] == 'song_hifi') {
$song_md = 'song_hifi';
$song_tp = 'hifi';
}
elseif (isset($_post['mode']) && $_post['mode'] == 'song_lofi') {
$song_md = 'song_lofi';
$song_tp = 'lofi';
}
else {
jmLogger(0,'MAJ',"(play.php) unable to determine play mode for song");
jmErrorPage("unable to determine play mode for song");
}
if (is_numeric($band_id) && is_numeric($song_id)) {
$_song = getStreamData($band_id,$song_id,$song_md);
$_song = @array_values($_song);
if (!isset($_post['type']) || empty($_post['type'])) {
$_mext = getPlaylistExt($_song[0]["{$song_tp}_extension"]);
}
else {
$_mext = getPlaylistExt($_post['type']);
}
}
elseif (is_numeric($band_id) && $song_id == 'all') {
if (empty($_post['type'])) {
jmErrorPage('error - no type given for "all" mode - you must specify the extension i.e. mp3');
}
$_song = getStreamData($band_id,'all',$song_md,$_post['type'],$_post['limit']);
$_song = @array_values($_song);
$_mext = getPlaylistExt($_post['type']);
if (!empty($_post['random'])) {
foreach(array_rand($_song,count($_song)) as $key => $val) {
$_news["$key"] = $_song["$val"];
}
$_song = $_news;
$_news = array();
unset($_news);
}
}
elseif (is_numeric($band_id) && !is_numeric($song_id)) {
$_song = getStreamData($band_id,$song_id,$song_md);
$_song = @array_values($_song);
if (!isset($_post['type']) || empty($_post['type'])) {
$_mext = getPlaylistExt($_song[0]["{$song_tp}_extension"]);
}
else {
$_mext = getPlaylistExt($_post['type']);
}
}
elseif ($band_id == 'all' && $song_id == 'all') {
if (empty($_post['type'])) {
jmErrorPage('error - no type given for "all" mode - you must specify the extension i.e. mp3');
}
$_song = getStreamData('all','all',$song_md,$_post['type'],$_post['limit']);
$_song = @array_values($_song);
$_mext = getPlaylistExt($_post['type']);
if (!empty($_post['random'])) {
foreach(array_rand($_song,count($_song)) as $key => $val) {
$_news["$key"] = $_song["$val"];
}
$_song = $_news;
$_news = array();
unset($_news);
}
}
elseif ($band_id == 'all' && is_array($song_id)) {
if (empty($_post['type'])) {
jmErrorPage('error - no type given for "all" mode - you must specify the extension i.e. mp3');
}
$_song = getStreamData('all',$song_id,$song_md,$_post['type'],$_post['limit']);
$_mext = getPlaylistExt($_post['type']);
if (is_array($_song)) {
foreach ($song_id as $snum => $ssid) {
if (!is_array($_song["$ssid"])) {
continue;
}
$_news[] = $_song["$ssid"];
$_song["$ssid"] = array();
unset($_song["$ssid"]);
}
$_song = $_news;
$_news = array();
unset($_news);
}
}
if (!is_array($_song)) {
jmErrorPage("The playlist that was generated by your play.php request contained no data - verify usage");
}
}
foreach ($_song as $key => $_val) {
if ((is_numeric($_val['quota_bandwidth']) && $_val['quota_bandwidth'] > 0) && (isset($_val['quota_bwtype']) && $_val['quota_bwtype'] == 1)) {
if (is_numeric($_val['artist_bytes']) && $_val['artist_bytes'] >= ($_val['quota_bandwidth'] * 1048576)) {
$_song["$key"] = array();
unset($_song["$key"]);
}
}
}
if (count($_song) == 0) {
if (is_file("{$jamroom['jm_dir']}/templates/interface/bandwidth_exceeded.tpl")) {
htmlShowTemplate("{$jamroom['jm_dir']}/templates/interface/bandwidth_exceeded.tpl",'null',"{$jamroom['jm_dir']}/templates/interface");
exit;
}
jmErrorPage("After removing songs that have exceeded their bandwidth allotment, there are no songs left in the playlist - exiting.");
}
if ((isset($_post['repeat']) && $_post['repeat'] == 'yes') || (isset($radio['radio_repeat']) && $radio['radio_repeat'] == 'yes')) {
$rep = 'yes';
}
if (empty($config['use_play_keys']) || $config['use_play_keys'] == 'yes') {
setMediaKeys($_song,$_post['mode']);
}
header("Accept-Range: bytes");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0, false");
header("Cache-control: private");
header("Pragma: no-cache");
header("Content-Type: {$_mext['mime']}");
header("Content-Disposition: inline; filename=\"playlist.{$_mext['extn']}\"");
if ($_mext['extn'] == 'm3u') {
ob_start();
echo "#EXTM3U\n";
foreach($_song as $song) {
$time = '-1';
if (!empty($song['length'])) {
$_len = explode(':',$song['length']);
if (count($_len) == 2) {
$time = ($_len[0] * 60) + $_len[1];
}
else {
$time = (($_len[0] * 60) * 60) + ($_len[1] * 60) + $_len[2];
}
}
$aurl = $jamroom['jm_htm'];
if (!empty($song['server_url']) && $song['server_id'] != 0) {
$aurl = $song['server_url'];
}
if ($config['use_play_keys'] == 'yes' && isset($song['media_key'])) {
$eurl = "&k={$song['media_key']}";
}
echo "#EXTINF:{$time},{$song['band_name']} - {$song['song_name']}\n";
echo "{$aurl}/stream.php?mode={$song_md}&band_id={$song['band_id']}&song_id={$song['song_id']}{$eurl}&ext=.". $song["{$song_tp}_extension"] ."\n";
}
ob_end_flush();
exit;
}
elseif ($_mext['extn'] == 'wax') {
ob_start();
echo "\n";
if (!empty($radio['name'])) {
echo "{$radio['name']}\n";
}
if ($rep == 'yes') {
echo "\n";
}
foreach($_song as $song) {
$aurl = $jamroom['jm_htm'];
if (!empty($song['server_url']) && $song['server_id'] != 0) {
$aurl = $song['server_url'];
}
if ($config['use_play_keys'] == 'yes' && isset($song['media_key'])) {
$eurl = "&k={$song['media_key']}";
}
echo "\n";
echo "{$song['band_name']}\n";
echo "Copyright ". strftime("%Y",$song['song_time']) ." by {$song['band_name']}\n";
echo "{$song['band_name']} - {$song['song_name']}\n";
echo "[\n";
echo "]\n";
}
if ($rep == 'yes') {
echo "\n";
}
echo "\n";
ob_end_flush();
exit;
}
elseif ($_mext['extn'] == 'asx') {
ob_start();
echo "\n";
if ($rep == 'yes') {
echo "\n";
}
foreach($_song as $song) {
$aurl = $jamroom['jm_htm'];
if (!empty($song['server_url']) && $song['server_id'] != 0) {
$aurl = $song['server_url'];
}
if ($config['use_play_keys'] == 'yes' && isset($song['media_key'])) {
$eurl = "&k={$song['media_key']}";
}
echo "\n";
echo "{$song['band_name']}\n";
echo "Copyright ". strftime("%Y",$song['video_updated']) ." by {$song['band_name']}\n";
echo "{$song['band_name']} - {$song['video_name']}\n";
echo "[\n";
echo "]\n";
}
if ($rep == 'yes') {
echo "\n";
}
echo "\n";
ob_end_flush();
exit;
}
elseif ($_mext['extn'] == 'pls')
{
ob_start();
echo "[playlist]\nversion=2\nNumberOfEntries=".count($_song)."\n";
$snum = 1;
foreach($_song as $song) {
$aurl = $jamroom['jm_htm'];
if (!empty($song['server_url']) && $song['server_id'] != 0) {
$aurl = $song['server_url'];
}
if ($config['use_play_keys'] == 'yes' && isset($song['media_key'])) {
$eurl = "&k={$song['media_key']}";
}
echo "Title{$snum}={$song['song_name']}\nLength{$snum}=-1\n";
jmSongCounter($band_id,$song_id,"{$song_tp}_scount");
$sext = $song["{$song_tp}_extension"];
echo "File{$snum}={$aurl}/{$config['song_dir']}/{$band_id}/{$song['song_id']}_{$song_tp}.{$sext}{$eurl}\n";
$snum++;
}
ob_end_flush();
exit;
}
elseif ($_mext['extn'] == 'wav') {
foreach($_song as $song) {
$aurl = $jamroom['jm_htm'];
if (!empty($song['server_url']) && $song['server_id'] != 0) {
$aurl = $song['server_url'];
}
header("Location: {$aurl}/download.php?band_id={$song['band_id']}&song_id={$song['song_id']}&mode={$song_md}");
}
exit;
}
elseif ($_mext['extn'] == 'xspf') {
ob_start();
echo "\n";
echo "\n";
echo "\n";
foreach($_song as $song) {
echo "\n";
}
echo "\n\n";
ob_end_flush();
exit;
}
?>