<?
// include_once "admin/file_browser.php";


function dispAdminPhotos () {

if ($_SESSION["user_right"] < $GLOBALS["EPTV"] )
{
	return("T'es ouf");
}

	get_time();


$result_prod = getPhotosByType("eptvprod");
$result_bonus = getPhotosByType("eptvbonus");
$result_adm = getPhotosByType("eptv.adm");

	

$str = '
		
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
		<td bgcolor="#000000">
		<table width="100%" border="0" cellspacing="1" cellpadding="2">
			<tr>
			<td>
				<b>
				<font color="#ffffff">
				&nbsp a l l &nbsp p h o t o s
				</font>
				</b> 
			</td>
			</tr>
			<tr>
			   <td width=150>
				<FORM name="new_photo" method="post" action="index.php?section=AdminHome&section_admin=AdminAddPhotos&vid_id='.$vid_id.'">
				<INPUT class="button" TYPE="submit" NAME="action" VALUE="  NOUVEl ALBUM PHOTO  "><BR> </TD>
				</FORM>
			   </td>
			   <td>
				<FORM name="new_photo" method="post" action="index.php?section=AdminHome&section_admin=AdminPhotosSolos&vid_id='.$vid_id.'">
				<INPUT class="button" TYPE="submit" NAME="action" VALUE="LISTE ALBUMS PHOTOS SOLOS"><BR> </TD>
				</FORM>
			   </td>

			</tr>
		</table>
		</td>
		</tr>
	</table>
	<BR>';







	if (mysql_num_rows($result_prod)) {
		$str .= dispAdminPhotosByType($result_prod, "&nbsp;e p t v &nbsp; p r o d u c t i o n");	
	}
	
	if (mysql_num_rows($result_bonus)) {
		$str .= dispAdminPhotosByType($result_bonus, "&nbsp;e p t v &nbsp b o n u s");
	}

	if (mysql_num_rows($result_adm)) {
		$str .= dispAdminPhotosByType($result_adm, "&nbsp;e p t v . a d m");
	}

return $str;

}




function dispAdminPhotosByType($result, $photo_type) {
 
	$str = '		
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
		<td bgcolor="#000000">
		<table width="100%" border="0" cellspacing="1" cellpadding="2">
			<tr>
			<td>
				<b>
				<font color="#ffffff">
				'.$photo_type.'
				</font>
				</b> 
			</td>
			</tr>
			
			<tr>
			<td bgcolor="#d3d3df">
			<table cellpadding="0" cellspacing="0" width="100%">
				<tr>
				<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="4">

		';

		while ($photo = mysql_fetch_array($result)) {
 
			$vid_id = $photo["photo_id"];

			$str .= dispWhenTendu($photo["photo_tendu"]);

			$str .= '
		
				<a href="
					'.$photo["photo_path"].'
					" class="texte_link">
					'.$photo["photo_name"].'
				</TD>
				<TD>
					'.$photo["photo_date"].'
				</TD>
				<TD align=center>
					'.$photo["photo_size"].' Img
				</TD>
			';

				if ($photo["photo_user_id"] == $_SESSION["user_id"] || $_SESSION["user_right"] == $GLOBALS["ROOT"]){
					$str .= '
						<TD width=10% align=right>
							<FORM name="update_photo" method="post" action="index.php?section=AdminHome&section_admin=AdminModifPhotos&vid_id='.$vid_id.'">
							<INPUT class="small_button" TYPE="submit" NAME="action" VALUE=" MODIF "> 
							</FORM>
						</TD>
						<TD width=10% align=right>
							<FORM name="supp_photo" method="post" action="index.php?section=AdminHome&section_admin=AdminDelPhotos&vid_id='.$vid_id.'">
							<INPUT class="small_button" TYPE="submit" NAME="action" VALUE=" SUPP ">
							</FORM>	
						</TD>
					';
				}


			$str .= '</TR>';
		}

$str .= '
					</table>
					</td>
					</tr>
				</table>
				</td>
				</tr>
			</table>
			</td>
			</tr>
		</table>
		<br>
	';

	return ($str);

}







function dispAdminPhotosSolos () {

   $rep_def = "photos/";

   if ($_SESSION["user_right"] < $GLOBALS["REPORTER"] )
   {
	return("T'es ouf");
   }


   // Files on BDD

   $result = getAllphotos();

   while ($photo = mysql_fetch_array($result)) {
	$tab_path_bdd[] = $photo["photo_path"];
   }


   // Files on Serveur

   $tab_path_local = find_reccur_file($rep_def);



   for ($cpt_local = 0; $tab_path_local[$cpt_local]; $cpt_local++)
   {
	for ($cpt_bdd = 0; $tab_path_bdd[$cpt_bdd] && $tab_path_bdd[$cpt_bdd] != $tab_path_local[$cpt_local]; $cpt_bdd++)
	{
		;
	}
	if (!$tab_path_bdd[$cpt_bdd])
	{
		$tab_solo[] = $tab_path_local[$cpt_local];
	}

   }




   $str = '
		
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
		<td bgcolor="#000000">
		<table width="100%" border="0" cellspacing="1" cellpadding="2">
			<tr>
			<td>
				<b>
				<font color="#ffffff">
				&nbsp p h o t o s &nbsp; s o l o s
				</font>
				</b> 
			</td>
			</tr>
						
			<tr>
			<td bgcolor="#d3d3df">
			<table cellpadding="0" cellspacing="0" width="100%">
				<tr>
				<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="4">
				';


				for ($i = 0; $tab_solo[$i]; $i++)
				{
				
			$str .= '

				<TR>

				<TD width = 380>
					'.$tab_solo[$i].'
			 	</TD>

				<TD  align=left>
					<FORM name="update_photo" method="post" action="index.php?section=AdminHome&section_admin=AdminAddPhotos&vid_path='.$tab_solo[$i].'">
					<INPUT class="small_button" TYPE="submit" NAME="action" VALUE=" Ajouter "> 
					</FORM>
				</TD>

				</TR>
			';

				}

			$str .= '

				</table>
				</td>
				</tr>
			</table>
			</td>
			</tr>
		</table>
		</td>
		</tr>
	</table>
	
   ';




   return $str;

}




function dispAdminAddPhotos () {

   $date = get_date();
   $vid_path = "";

   if (isset($_GET['vid_path']))
   {
	$vid_path = $_GET['vid_path'];
   }


 $str = '		
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp a d d &nbsp p h o t o &nbsp a l b u m &nbsp t o &nbsp d a t a b a s e
			</font>
			</b> 
		</td>
		</tr>					
	<tr>
	<td bgcolor="#d3d3df">
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>	
		    <form name="saisie" method="post" action="index.php?section=AdminHome&section_admin=AddPhoto&vid_id='.$vid_id.'">
		    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">


 			    <TR>
			    <TD> Path de l\'album photo </TD>
			    <TD>
		';

			if (isset($_REQUEST['file']))
			{
				$str .= '<INPUT TYPE="text" NAME="photo_get_path" VALUE="'.$_REQUEST['file'].'" SIZE="50" MAXLENGTH="150">';
			}
			else
			{
				$str .= '<INPUT TYPE="text" NAME="photo_get_path" VALUE="'.$vid_path.'" SIZE="50" MAXLENGTH="150">';
			}


		$str .= "
<a href=\"#\" onClick=\"window.open('admin/file_browser_photos.php','_blank','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,copyhistory=0,menuBar=0,width=600,height=300');\"> Browser... </a>";

	
		
		$str .= '
			    <TR>
			    <TD> Nom de l\'album photo: </TD>
			    <TD> <INPUT TYPE="text" NAME="photo_get_name" VALUE="" SIZE="50" MAXLENGTH="52"> </TD>
			    </TR>
			    <TR>
			    <TD> Nombre de photos: </TD>
			    <TD> <INPUT TYPE="text" NAME="photo_get_size" VALUE="" SIZE="50" MAXLENGTH="52"> </TD>
			    </TR>
    
			';
 

		
$str .='
			    </TD>
			    </TR>
   	 
			    <TR><TD> Date de d&eacute;pot: </TD>
			    <TD> <INPUT TYPE="text" NAME="photo_get_date" VALUE="'.$date.'" SIZE="8" MAXLENGTH="10"> </TD>
			    </TR>
    
			    <TR><TD>Cat&eacute;gorie</TD>
			    <TD>
			    <TABLE CELLSPACING"0" CELLPADDING="1" BORDER="0">
			   	 <TR> <TD>
				    <select name="photo_type">
				    <option value="eptvprod">EPTv Production</option>
				    <option value="eptv.adm">EPTv.Adm</option>
				    <option value="eptvbonus">EPTv Bonus</option>
				    </TD></TR>
			    </TABLE>
			    </TD>
			    </TR>

			    <TR><TD>Commentaire: </TD>
			    <TD>
			    <TEXTAREA rows="3" cols="38" name="photo_comment" ONFOCUS=""></textarea>
			    </TD>
			    </TR>
    
			    <TR><TD>Groupe Photo</TD>
			    <TD>
			    <TABLE CELLSPACING"0" CELLPADDING="1" BORDER="0">
				<TR> <TD>
				    <select name="photo_tendu">
				    <option value=0>Public</option>
				    <option value=1>Tendu</option>
				    <option value=2>Priv&eacute;e</option>
				</TD></TR>
			    </TABLE>
			    </TD>
			    </TR>

			    <TR>
				    <TD>News</TD>
				    <TD>
				    <INPUT TYPE="checkbox" NAME="auto_www_news" VALUE = 1 checked> Poster une news automatique sur le site. (nom de l\'album photo + date + commentaire + groupe)
				    </TD>
			    </TR>

			    <TR>
				    <TD> </TD>
				    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  UPLOADER  "> </TD>
			    </TR>
			    <TR>
			 	   <TD> </TD>
				   <TD> <INPUT class="button" TYPE="reset" NAME="action" VALUE=" RESET "> </TD>
			    </TR>
		    </TABLE>
		</FORM>
		</TR>
	</TABLE>
	</TD>
	</TR>
</TABLE>
';


return $str;
}


function dispAdminModifPhotos () {
  
$vid_id =$_GET['vid_id'];

$result = getOnePhoto($vid_id);

$str = '		
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp m o d i f y &nbsp a l b u m &nbsp p h o t o
			</font>
			</b> 
		</td>
		</tr>					
	<tr>
	<td bgcolor="#d3d3df">
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>	
	';

  if (mysql_num_rows($result)){
    $photo = mysql_fetch_array($result);    
  }

  $str .= '
    <form name="saisie" method="post" action="index.php?section=AdminHome&section_admin=ModifPhoto&vid_id='.$vid_id.'">
	    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
	   

			    <TR>
			    <TD> Path de l\'album photo: </TD>
			    <TD>
		';

			if (isset($_REQUEST['file']))
			{
				$str .= '<INPUT TYPE="text" NAME="photo_get_path" VALUE="'.$_REQUEST['file'].'" SIZE="50" MAXLENGTH="150">';
			}
			else
			{
				$str .= '<INPUT TYPE="text" NAME="photo_get_path" VALUE="'.$photo["photo_path"].'" SIZE="50" MAXLENGTH="150">';
			}


		$str .= "
<a href=\"#\" onClick=\"window.open('admin/file_browser_photos.php','_blank','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,copyhistory=0,menuBar=0,width=600,height=300');\"> Browser... </a>";
 
$str .= '


 		   <TR><TD> Nom de l\'album photo: </TD>
		    <TD> <INPUT TYPE="text" NAME="photo_get_upname" VALUE="'.$photo["photo_name"].'" SIZE="50" MAXLENGTH="52"> </TD>
		    </TR>
    
 		   <TR><TD> Nombre de photos: </TD>
		    <TD> <INPUT TYPE="text" NAME="photo_get_size" VALUE="'.$photo["photo_size"].'" SIZE="50" MAXLENGTH="52"> </TD>
		    </TR>
    
		    <TR><TD> Date de d&eacute;pot: </TD>
		    <TD> <INPUT TYPE="text" NAME="photo_get_date" VALUE="'.$photo["photo_date"].'" SIZE="8" MAXLENGTH="10"> </TD>
		    </TR>
    
		    <TR><TD>Cat&eacute;gorie</TD>
		    <TD>
		    <TABLE CELLSPACING"0" CELLPADDING="1" BORDER="0">
			    <TR> <TD>
			    <select name="photo_get_type">
			    <option value="eptvprod" '.get_selected_option("eptvprod",$photo["photo_type"]).' >EPTv Production</option>
			    <option value="eptv.adm" '.get_selected_option("eptv.adm",$photo["photo_type"]).' >EPTv.Adm</option>
			    <option value="eptvbonus" '.get_selected_option("eptvbonus",$photo["photo_type"]).' >EPTv Bonus</option>
			    </TD></TR>
		    </TABLE>
		    </TD>
		    </TR>

		    <TR><TD>Commentaire: </TD>
		    <TD>
		    <TEXTAREA rows="3" cols="38" name="photo_get_comment" ONFOCUS="">'.$photo["photo_comment"].'</textarea>
		    </TD>
		    </TR>
    
		    <TR><TD>Groupe Photos</TD>
		    <TD>
		    <TABLE CELLSPACING"0" CELLPADDING="1" BORDER="0">
			    <TR> <TD>
				    <select name="photo_get_tendu">
				    <option value="0" '.get_selected_option(0, $photo["photo_tendu"]).' >Public</option>
				    <option value="1" '.get_selected_option(1, $photo["photo_tendu"]).' >Tendu</option>
				    <option value="2" '.get_selected_option(2, $photo["photo_tendu"]).' >Priv&eacute;e</option>
			    </TD></TR>
	    	    </TABLE>
	    	    </TD>
	    	    </TR>
	';


	$str .= '    
		    <TR><TD>Post&eacute;e par: </TD>
		    <TD>
		    ';

		$id_user = getOneUserById($photo["photo_user_id"]);

		if (mysql_num_rows($id_user)){
		    $id_user = mysql_fetch_array($id_user);    
		}

		$str .= $id_user["user_pseudo"].'</TD></TR>


	    <TR>
	    <TD> </TD>
	    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  UPDATE  "> </TD>
	    </TR>
	    <TR>
	    <TD> </TD>
	    <TD> <INPUT class="button" TYPE="reset" NAME="action" VALUE=" RESET "> </TD>
	    </TR>
 
    	</TABLE>
	</FORM>
	</TR>
   </TABLE>
   </TD>
   </TR>
</TABLE>
 
';

return $str;
}


function dispAdminDelPhotos () {

  $vid_id =$_GET['vid_id'];

  $result = getOnePhoto($vid_id);


$str = '		
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp d e l e t e &nbsp a l b u m &nbsp p h o t o
			</font>
			</b> 
		</td>
		</tr>					
	<tr>
	<td bgcolor="#d3d3df">
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>	
	';

	  if (mysql_num_rows($result)){
	    $photo = mysql_fetch_array($result);    
	  }

	  $str .= '
	    <form name="saisie" method="post" action="index.php?section=AdminHome&section_admin=DelPhoto&vid_id='.$vid_id.'">
	    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
   
		    <TR><TD> Nom de l\'album photo: </TD>
		    <TD>'.$photo["photo_name"].'</TD>
		    </TR>
		    <TR><TD> Nombre de photos: </TD>
		    <TD>'.$photo["photo_size"].'</TD>
		    </TR>
    
		    <TR>
		    <TD> Path de l\'album photo: </TD>
		    <TD>
       
		     ' .$photo["photo_path"].'
      
		    </TD>
		    </TR>
    
		    <TR><TD> Date de d&eacute;pot: </TD>
		    <TD> '.$photo["photo_date"].' à  '.$photo["photo_time"] .' </TD>
		    </TR>

		    <TR><TD>Cat&eacute;gorie: </TD>
		    <TD>
		    '.$photo["photo_type"].'   

		    </TD>
		    </TR>

		    <TR><TD>Commentaire: </TD>
		    <TD>
		    '.$photo["photo_comment"].'
		    </TD>
		    </TR>
    
		    <TR><TD>Groupe Photos: </TD>
		    <TD>';

		  if ($photo["photo_tendu"] == 0){
		    $str .= 'Public</TD></TR>';
		  }
		  else if ($photo["photo_tendu"] == 1){
		    $str .= 'Tendu</TD></TR>';
		  }
		  else if ($photo["photo_tendu"] == 2){
		    $str .= 'Priv&eacute;e</TD></TR>';
		  }

		$str .= '    
		    <TR><TD>Post&eacute;e par: </TD>
		    <TD>
		    ';

		$id_user = getOneUserById($photo["photo_user_id"]);

		if (mysql_num_rows($id_user)){
		    $id_user = mysql_fetch_array($id_user);    
		}

		$str .= $id_user["user_pseudo"].'</TD></TR>';

		$str .= '
		    <TR>
		    <TD> </TD>
		    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  SUPPRIMER  "> </TD>
		    </TR>  
    	</TABLE>
	</FORM>
	</TR>
   </TABLE>
   </TD>
   </TR>
</TABLE>

';

return $str;
}


?>