Location: PHPKode > projects > MyOWNSpace > MyOWNspace_v8.2/www/myownjpeg.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 "".menu_options($go)."<H1>MyOwnJPEG</H1>";
echo '<form action="myownjpeg.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 action="myownjpeg.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="myownjpeg/".$go.".xml";
$playlisttags = array ('title', 'annotation', 'creator', 'info', 'location', 'license');
$tracktags = array('location', 'annotation','info','creator','title','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 JPEG catalog. <b>tip:To remove a picture, leave all info blank..</b>
		</div> 
    <form method="post" action="myownjpeg.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/myownjpeg/'.$go.'.mxl"><input type="hidden" name="playlistlocation" value="http://myownspace.fr/myownjpeg/'.$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>
    <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>
    <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>
    <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>
    <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']!=""){
if (!eregi("^http\:\/\/",$_GET['url']) )
$urll="http://dearcomputer.nl/gir/?q=".preg_replace("/ /", "+", $_GET['url']); /// not a URL => its a keyword for google search :)
else
$urll=$_GET['url']; // site to parse
echo "<h5>".$urll."</h5>";
$pattern = '/xspf/';
$filter = ".jpg";
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
if (isset($_GET['images'])){   /// IMAGES EXTRACTOR
$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";

$html = implode (' ', file ($urll));

preg_match_all ("'<img .*? src=\".*?\"'si", $html, $out);
//echo count($out[0]);
for ($i=1;$i<=count($out[0]);$i++){

preg_match("/src=\"?\"/i",$out[0][$i],$matches);
//echo $out[0][$i]."<br>";
if(eregi("src=['\"]([^'\"]+)['\"]", $out[0][$i], $regs1)) $location= $regs1[1];
if(eregi("alt=['\"]([^'\"]+)['\"]", $out[0][$i], $regs2)) $title= $regs2[1];
else $title="";
$xspf_code.= "		<track>\n"
	. "			<title>".$title."</title>\n"
	. "			<location>".$location."</location>\n"
  . "     <identifier>".$go."</identifier>\n"
	. "		</track>\n";
} 
} /// end IMAGE EXTRACTOR

if(isset($_GET['links'])){ ///// LINKED IMAGE EXTRACTOR
//if (!eregi("^http\:\/\/",$arrayLinks[$a]) )
/*$urll="http://dearcomputer.nl/gir/?q=".$_GET['url']; /// not a URL => its a keyword for google search :)
else
$urll=$_GET['url']; // site to parse*/
$arrayLinks = &linkExtractor( $urll, true );
$filter=".jpg";
	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 (eregi("^http\:\/\/",$arrayLinks[$a]) ){
			$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";
      }
    }
		} }  /// end LINK EXTRACTOR
$xspf_code.= "	</trackList>\n". "</playlist>\n";
writeTXT($filename,$xspf_code);
change_update($go);}
	}
else echo '<p style="color: green">'.$urll.' is not a well formated URL';  


/**/


/// 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($tags=='location'&&$_POST[$form]==''){$location=0;break;}else $location=1;
				if($_POST[$form]!="" ) $track.= "<".$tags.">".$_POST[$form]."</".$tags.">";
			}
if($track!=""&&$location==1) $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 <a id="mylink8" href="$myjpegimport?width=350" class="betterTip" title="How to import my own jpeg?">?</a></h1>

	

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

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

		  <img src="http://www.webjay.org/img/icon/info.gif" border="0">
		  !!dont forget training slash in the end (ex:<b>http://mywonsite.com/pic/</b>)!!
		  <li>Enter a link to a web page.  MyOwnJPEG will find any image file in the page.</li>
		  <li>choose options for best result.</li>
		  <li>enter a key word for a Google search</li>
		</div> 

	<form method="get" action="myownjpeg.php">
	Find images in page:
	  <input type="text" name="url" value="http://" size="31" maxlength="255" />
	  <br>
	  <br>import from: <input type="radio" name="images" >PAGE <input type="radio" name="links">FOLDER(jpeg only)
	  <input type="hidden" name="go" value="'.$go.'">
	  <input type="submit" value="&nbsp;&nbsp;Go&nbsp;&nbsp;">
	</form>
<div id="myjpegimport" style="display:none;" >
Enter the url of a page (ex: "<a href="">http://thewebsite.com</a>") <br>
  *option page: will fetch image inside the page<br>
  *option folder: will fetch image linked in the page<br><br>
If you dont know a url to fetch, you can enter keywords to make a google image search
</div> ';



}
//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: left;">

		  <img src="http://www.webjay.org/img/icon/info.gif" border="0">
		  Fill info, make your own PICTURE catalog.<br> <b>tip:To delete a picture , leave location info blank..</b>
      <br>-you can also use <a target="_blank" href="http://myownpic.com">Myownpic.com</a> service to store your own pictures'.
'<br><a href="showmyownjpeg.php?go='.$go.'" rel="gb_page[340, 260]" title="click to preview">Click top preview a demo!</a>'.

		'</div> 
    <form method="post" action="myownjpeg.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.= $tags.' : <b>'.$myownplaylist[$tags][1].'</b><br>';
				}
			}
		$page.='<H3>Pictures <a id="mylink8" href="$myplaylist?width=500" class="betterTip" title="How to use the picture list editor?">?</a></H3>';
			// Parse TRACK info
			echo "<br>";
			$page.="<table><tr><td>";
			preg_match_all("'<track>(.*?)</track>'si", $content, $out_trackinfo);
			//print_r($out_trackinfo[1]);
			for($i=0;$i<=count($out_trackinfo[1]); $i++)
			{
		$page.="</td></tr>";
			foreach($tracktags as $tags)
			{
		
				preg_match("'<$tags.*?>(.*?)</$tags>'si", $out_trackinfo[1][$i],$temp);

				$myowntracks[$tags] = $temp; 
				//if( $myowntracks['location'][1]!=""){
				if ($tags=='location') $page.='<tr><td><img src="'.$myowntracks['location'][1].'" height="120"></td><td>';
				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.="</td></tr></table>";
			$page.='<input type="hidden" name="edit" value="'.$i.'"><input type="submit" value="&nbsp;&nbsp;Go&nbsp;&nbsp;"></form>';
			$page.='';
      echo $page;
      
			}
}
}
include("myowntip.html");
include("footer.php");
?>
Return current item: MyOWNSpace