Location: PHPKode > projects > Axis Groupware > musiclib/unused/musiclib/randompls.php
<?
$phpgw_info["flags"] = array ("currentapp" => "musiclib",
							 "enable_nextmatchs_class" => True,
 							 "noheader" => True );

include ("../header.inc.php"); #PHP Groupware header
include ("tunez.inc.php");
include ("config.inc.php");

// get random songs from database
$kweerie = "SELECT * from phpgw_musiclib_songs ORDER BY RAND()";
$result = mysql_db_query($db_name, $kweerie);

$random_playlist_file = $tunez_root_dir.$pls_dir."random.pls";
system ("rm -f '$random_playlist'");

$random_playlist = fopen($random_playlist_file,"w") or die ("could not open file");
fwrite ($random_playlist, "[playlist]\n");
fwrite ($random_playlist, "NumberOfEntries=$playlist_size\n");
fclose ($random_playlist);

for ($i = 1; $i <= $playlist_size; $i++) {
	$row = mysql_fetch_array($result);
	$filename = $row["filename"];

	$filenameSplitted = split("/", $filename);
	$artist = substr($filenameSplitted[2],0);
	$album = substr($filenameSplitted[3],0);
	$filenameWithoutPath = $filenameSplitted[ sizeOf($filenameSplitted)-1];
	$splittedSong = split($separator, $filenameWithoutPath);
	$trackno = substr($splittedSong[0], 0);
	if ($filename_format == 1) { $songtitle = substr($splittedSong[2], 0, -4); }
	if ($filename_format == 2) { $songtitle = substr($splittedSong[1], 0, -4); }

	$album20 = str_replace(" ","%20",$album);
	$artist20 = str_replace(" ","%20",$artist);
	$songtitle20 = str_replace(" ","%20",$songtitle);
	$separator20 = str_replace(" ","%20",$separator);
	if ($filename_format == 1) { $filename20 = $mp3_url.$artist20."/".$album20."/".$trackno.$separator20.$artist20.$separator20.$songtitle20.".mp3"; }
	if ($filename_format == 2) { $filename20 = $mp3_url.$artist20."/".$album20."/".$trackno.$separator20.$songtitle20.".mp3"; }
	$filename20 = str_replace("\\","",$filename20);

	$random_playlist  = fopen($random_playlist_file,"a") or die ("could not append file");
	fwrite ($random_playlist, "File".$i."=".$filename20."\n");
	fclose ($random_playlist);
}

Header('Location: '.$GLOBALS['phpgw']->link("/musiclib".$pls_dir."random.pls"));
?>
Return current item: Axis Groupware