Location: PHPKode > projects > MyOWNSpace > MyOWNspace_v8.2/www/randomplaylistuser.php
<?php
/// **RANDOM PLAYSIST v.2**
/// **NO OWNER REDUNDANCY**

include "login.inc.php";
include "config.php";

$page="";
$x=0;
$playlisttags = array ('title', 'annotation', 'creator', 'info', 'location', 'license');
$tracktags = array('location', 'annotation', 'image','info');
$tracktags1 = array('location', 'creator', 'image','info','album','title','annotation','identifier');
$track=array();
$randomtracks = array();
$owner=array();
$XSPF='<playlist version="1">';
$XSPF.= '
<title>MyOWNSPACE random playlist</title>
  <annotation>Self Generated Random Playlist of MyOwnSpace MUSIC</annotation>
  <creator>MyOWNSpace</creator>
  <info>http://myownspace.fr</info>
  <location>http://myownspace.fr/charts.php</location>
  <license>nopyright</license>
<trackList>   
';
if(isset($_GET['user'])) $user = $_GET['user'];
//echo "user:".$user;
/// verifie user
/// scanne l'ensemble des space
/// si user existe && si playlist existe : on garde une chanson

while (list($key2,$val2) = each($myspace)) {
if($myspace[$key2]['owner']==$user&&$myspace[$key2]['owner']!="")
{
$newowner=true;
$filename="myownmp3/".$key2.".xml";
$trackdata="";
$content = '';

//echo $filename;
if(file_exists($filename)&&filesize($filename)!=0){

if ($f = @fopen($filename, 'r')) { //lecture du fichier
//echo "reading".$filename."...<br>";
			while (!feof($f)) {
				$content .= fgets($f, 4096);
			}
			fclose($f);
			// Parse PLAYLIST info
}

preg_match_all("'<track>(.*?)</track>'si", $content, $out_trackinfo);
		$j=0;///variable pour comter les tracks dune playlist
		$count= count($out_trackinfo[1]);
		if($count>0){

		$track=array();
    foreach ($out_trackinfo[1] as $trackinfo)
			{
				
			foreach($tracktags1 as $tags)
			{			
				preg_match("'<$tags.*?>(.*?)</$tags>'si", $out_trackinfo[1][$j],$temp);
				
				if ($temp != '') {
				$myowntracks[$tags] = $temp; // Set only if not empty
				}
				}
				if(strstr($myowntracks[location][1],".mp3")==".mp3") {
				$track[$j][location]=$myowntracks[location][1];
				$track[$j][creator]=$myspace[$key2][artiste];
				$track[$j][info]='http://myownspace.fr/'.$key2;
				if($myspace[$key2][image]!="")$track[$j][image]=$myspace[$key2][image];
				else $track[$j][image]="http://myownspace.fr/images/unknown.gif";
				$track[$j][title]=$myowntracks[title][1];
				$track[$j][album]=$myspace[$key2][titre];
				$track[$j][annotation]=$track[$j][creator]." - ".$track[$j][titre]." (".$track[$j][album].") ";
				$track[$j][identifier]=$key2;
        }
    		$j++;	
			}
$key2 = rand(0,count($track));	
//echo "|".$track[$key2][title]."(".$track[$i][location].")<br>";

foreach($tracktags1 as $tags)
			{
			    
				if($track[$key2][location]!=""&&$track[$key2][location]!="http://webjay.org/audio/webjay44.mp3") {
				$trackdata.= "<".$tags.">".$track[$key2][$tags]."</".$tags.">
				";
				
				}		}
if($trackdata!="") $XSPF.= '<track>
'.$trackdata.'</track>
';		
  } 
  }

 }
      
}
 //END ELSE

$XSPF.= '  </trackList>
</playlist>';
$filename='myownmp3/random.xml';
//writeTXT($filename,$XSPF); 
header('Content-type: application/xml');
echo $XSPF;
?>
Return current item: MyOWNSpace