Location: PHPKode > projects > MyOWNSpace > MyOWNspace_v8.2/www/playlist.php
<?php
/// VŽrifie id

include "login.inc.php";
include "config.php";
////verifie quon adresse bien un ID pour designer la page
if(isset($_GET['go'])&&($_GET['go']!="")){
$go=$_GET['go']; }
else 
if(isset($_POST['go'])&&($_POST['go']!="")){
$go=$_POST['go']; }
else echo "BAD !!";
//***************
// AUTH
include("header.php");
if(checklogin()&&$myspace[$go]['owner']==$rawuser) {


loged($rawuser);
echo "<H4><a href=\"/".$go."\">Visit MyOwnSpace</a>&nbsp;|&nbsp;<a href=\"myownpic.php?go=".$go."\">MyOwnPicture Album</a>&nbsp;|&nbsp;<a href=\"myownfriend.php?go=".$go."\">MyOwnFriends Manager</a>&nbsp;|&nbsp;<a href=\"myownascii.php?go=".$go."\">MyOwnASCII ART Collection</a>&nbsp;<a href=\"myownstat.php?go=".$go."\">MyOwnSTATISTICS!</a>&nbsp;<a href=\"playlist.php?go=".$go."\">MyOwnMP3!</a></H4><hr>
<H1>MyOwnMP3</H1>";
echo '<form name="delete" action="playlist.php" method="GET"><input type="hidden" name="go" value="'.$go.'"><input type="hidden" name="delete"><input type="submit" value="Delete this playlist!" class="user"></form>';
echo '<form name="delete" action="playlist.php" method="GET"><input type="hidden" name="go" value="'.$go.'"><input type="hidden" name="create"><input type="submit" value="Create a playlist!" class="user"></form>';

//***************

$filename="myownmp3/".$go.".xml";
$playlisttags = array ('title', 'annotation', 'creator', 'info', 'location', 'license');
$tracktags = array('location', 'annotation', 'image','info','creator','title','album','identifier');

/// Fonction Delete
if(isset($_GET['delete'])){
unlink($filename);
}
/// Fonction Create
if(isset($_GET['create'])){

$page= '<div style="float: right; padding: 5px; margin-left: 5px; margin-bottom: 10px; width: 20em; border: 1px dotted; text-align: center;">

		  <img src="http://www.webjay.org/img/icon/info.gif" border="0">
		  Fill info, make your own MP3 playlist. <b>tip:To delete a track, leave all info blank..</b>
		</div> 
    <form method="post" action="playlist.php"><input type="hidden" name="go" value="'.$go.'">';

		$page.='<H3>Playlist</H3>
		
    title : '.$myspace[$go][artiste].'<input type="hidden" name="playlisttitle" value="'.$myspace[$go][artiste].'"><br>
    annotation : <input type="hidden" name="playlistannotation" value="'.$myspace[$go][titre].'"><br>
    creator : '.$myspace[$go][titre].'<input type="hidden" name="playlistcreator" value="MyOWNSpace"><br>
    <input size="50" type="hidden" name="playlistinfo" value="http://myownspace.fr/'.$go.'"><br>
    info location : <http://myownspace.fr/myownmp3/'.$go.'.mxl"><input type="hidden" name="playlistlocation" value="http://myownspace.fr/myownmp3/'.$go.'.mxl"><br>
    <input type="hidden" name="playlistlicense" value=""><br>';
    		
		$page.='<H3>Tracks</H3>
		location : <input size="50" type="text" name="tracklocation0" value="http://"><br>
    title : <input size="50" type="text" name="tracktitle0" value=""><br>
    creator : <input size="50" type="text" name="trackcreator0" value=""><br>
    album : <input size="50" type="text" name="trackalbum0" value=""><br>
    image : <input size="50" type="text" name="trackimage0" value="http://"><br />
    <input type="hidden" name="trackidentifier0" value="'.$go.'">
    <hr>
    location : <input size="50" type="text" name="tracklocation1" value="http://"><br>
    title : <input size="50" type="text" name="tracktitle1" value=""><br>
    creator : <input size="50" type="text" name="trackcreator1" value=""><br>
    album : <input size="50" type="text" name="trackalbum1" value=""><br>
    image : <input size="50" type="text" name="trackimage1" value="http://"><br>
    <input type="hidden" name="trackidentifier1" value="'.$go.'">
    <hr>
    location : <input size="50" type="text" name="tracklocation2" value="http://"><br>
    title : <input size="50" type="text" name="tracktitle2" value=""><br>
    creator : <input size="50" type="text" name="trackcreator2" value=""><br>
    album : <input size="50" type="text" name="trackalbum2" value=""><br>
    image : <input size="50" type="text" name="trackimage2" value="http://"><br>
    <input type="hidden" name="trackidentifier2" value="'.$go.'">
    <hr>
    location : <input size="50" type="text" name="tracklocation3" value="http://"><br>
    title : <input size="50" type="text" name="tracktitle3" value=""><br>
    creator : <input size="50" type="text" name="trackcreator3" value=""><br>
    album : <input size="50" type="text" name="trackalbum3" value=""><br>
    image : <input size="50" type="text" name="trackimage3" value="http://">
    <input type="hidden" name="trackidentifier4" value="'.$go.'">
    <br>
   <input type="hidden" name="edit" value="4"><input type="submit" value="&nbsp;&nbsp;Go&nbsp;&nbsp;"></form>';
		echo $page;	
}
/// Fonction Import
if(isset($_GET['url'])&&$_GET['url']!=""){

$urll=$_GET['url'];
$pattern = '/xspf/xml/';
$filter = ".mp3";
if (preg_match($pattern, $urll, $matches)) {
$xspf=implode ('', file($urll));
$xspf=str_replace("phpxml", "xml", $xspf);
writeTXT($filename,$xspf);
echo '<p style="color: green">Playlist added!</p>	  <br/>';
}
else{

// USE THIS FUNCTION TO USE AUTOMATICALLY LinkExtractor CLASS

$xspf_code= "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n"
."	<title>".$myspace[$go]['titre']."</title>\n"
. "	<info>http://myownspace.fr/".$go."</info>\n"
. "	<trackList>\n";
$urll=$_GET['url']; // site to parse

$arrayLinks = &linkExtractor( $urll, true );
$filter=".mp3";
if( $arrayLinks != false ) {
	for( $a = 0, $b = count( $arrayLinks ); $a < $b; $a++ ) {
			$ps = strpos(strtolower($arrayLinks[$a]), $filter);
		if (!($ps === false)) {  
		$title=str_replace("%20", " ", $arrayLinks[$a]);
		if ($pf = strpos(strtolower($arrayLinks[$a]), "http://")){
			$xspf_code.= "		<track>\n"
	. "			<title>".$title."</title>\n"
	. "			<location>".$arrayLinks[$a]."</location>\n"
  . "     <identifier>".$go."</identifier>\n"
	. "		</track>\n";}
		else{
			$xspf_code.= "		<track>\n"
	. "			<title>".$title."</title>\n"
	. "			<location>".$urll.$arrayLinks[$a]."</location>\n"
	. "     <identifier>".$go."</identifier>\n"
	. "		</track>\n";
      }
    }
		} 

$xspf_code.= "	</trackList>\n". "</playlist>\n";
writeTXT($filename,$xspf_code);
change_update($go);
	}
else echo '<p style="color: green">The web page at '.$urll.' has no music links that MyOWNmusic can find.</p>	';  

}





/*
That's it! You can feed this playlist to the SWF by setting this as it's 'file' 
parameter in your HTML page.
*/
//echo '<p style="color: green">Playlist created!</p>	  <br/>';
}
/**/


/// Fonction Edit
if(isset($_POST['edit'])&&$_POST['edit']!=""){

$XSPF='<?xml version="1.0" encoding="UTF-8" ?>
<playlist version="0" xmlns="http://xspf.org/ns/0/">';
$XSPF.= '<title>'.$_POST['playlisttitle'].'</title>
  <annotation>'.$_POST['playlistannotation'].'</annotation>
  <creator>'.$_POST['playlistcreator'].'</creator>
  <info>'.$_POST['playlistinfo'].'</info>
  <location>'.$_POST['playlistlocation'].'</location>
  <license>'.$_POST['playlistlicense'].'</license>
<trackList>   ';
for($i=0;$i<=$_POST['edit'];$i++){
$track="";
foreach($tracktags as $tags)
			{
			    
				$form='track'.$tags.$i;
				if($_POST[$form]!="" ) $track.= "<".$tags.">".$_POST[$form]."</".$tags.">";
			}
if($track!=""&&$pf = strpos(strtolower($track), ".mp3")) $XSPF.= '<track>'.$track.'</track>';
		
			}
$XSPF.= '  </trackList>
</playlist>';
writeTXT($filename,$XSPF); 
change_update($go);
}


/// VŽrifie playlist de cette id existe
if(!file_exists($filename)||filesize($filename)==0){

///si non menu import

echo '<div id="contents">

	<h1>Import</h1>

	

	<br/>
	<div style="text-align: center">	

		<div style="float: right; padding: 5px; margin-left: 5px; margin-bottom: 10px; width: 20em; border: 1px dotted; text-align: center;">

		  <img src="http://www.webjay.org/img/icon/info.gif" border="0">
		  !!dont forget training slash in the end (ex:http://mywonsite.com/mp3/)!!
		  <li>Enter a link to a web page.  MyOwnMUSIC will find any songs in the page.</li>
		  <li>Enter a link to a XSPF or RSS playlist file.</li>
		</div> 

	<form method="get" action="playlist.php">
	Find songs in page:
	  <input type="text" name="url" value="http://" size="31" maxlength="255" />
	  <input type="hidden" name="go" value="'.$go.'">
	  <input type="submit" value="&nbsp;&nbsp;Go&nbsp;&nbsp;">
	</form>';



}
//si oui menu edit

else { 

 $myownplaylist = array() ;
 $myowntracks = array() ;
			if ($f = @fopen($filename, 'r')) { //lecture du fichier
			$content = '';
		$page= '<img src="'.$myspace[$go]['image'].'" width="120">'.$myspace[$go]['titre']."(".$myspace[$go]['artiste'].')<pre>XSPF playlist at:<b><a href="http://myownspace.fr/'.$filename.'">http://myownspace.fr/'.$filename.'</a></b></pre>
		<div style="float: right; padding: 5px; margin-left: 5px; margin-bottom: 10px; width: 20em; border: 1px dotted; text-align: center;">

		  <img src="http://www.webjay.org/img/icon/info.gif" border="0">
		  Fill info, make your own MP3 playlist. <b>tip:To delete a track, leave all info blank..</b>
		</div> 
    <form method="post" action="playlist.php"><input type="hidden" name="go" value="'.$go.'">';
			while (!feof($f)) {
				$content .= fgets($f, 4096);
			}
			fclose($f);
			// Parse PLAYLIST info
			preg_match("'<playlist.*?>(.*?)</playlist>'si", $content, $out_playlistinfo);
		$page.="<H3>Playlist</H3>";

		
			foreach($playlisttags as $tags)
			{
				preg_match("'<$tags.*?>(.*?)</$tags>'si", $out_playlistinfo[1],$temp);
				
				if ($temp != '') {
				$myownplaylist[$tags] = $temp; // Set only if not empty
				$page.= $tags.' : <input size="50" type="text" name="playlist'.$tags.'" value="'.$myownplaylist[$tags][1].'"><br>';
				}
			}
		$page.="<H3>Tracks</H3>";
			// Parse TRACK info
			echo "<br>";
			preg_match_all("'<track>(.*?)</track>'si", $content, $out_trackinfo);
			//print_r($out_trackinfo[1]);
			for($i=0;$i<=count($out_trackinfo[1]); $i++)
			{
			foreach($tracktags as $tags)
			{
				preg_match("'<$tags.*?>(.*?)</$tags>'si", $out_trackinfo[1][$i],$temp);
				
				if ($temp != '') {
				$myowntracks[$tags] = $temp; // Set only if not empty
				if ($tags!='identifier')$page.= $tags.' : <input size="50" type="text" name="track'.$tags.$i.'" value="'.$myowntracks[$tags][1].'"><br>';
				else
				$page.='<input type="hidden" name="trackidentifier'.$i.'" value="'.$go.'">';
        }}
				$page.="<hr>";
			}
			$page.='<input type="hidden" name="edit" value="'.$i.'"><input type="submit" value="&nbsp;&nbsp;Go&nbsp;&nbsp;"></form>';
			echo $page;

			}
}
}
include("footer.php");
?>
Return current item: MyOWNSpace