Voici mon fichier index
<?php
error_reporting(E_ALL);
/******************** Fonction de création de miniature ***********************/
function thumb($fichierSource,$grand,$destination){
// Création du fichier
$source = ImageCreateFromJpeg('./img/'.$fichierSource);
// Dimantion
$largeurSource = imagesx($source);
$hauteurSource = imagesy($source);
// Calcule pour garder le raport largeur / hauteur
$rapport_dim = $largeurSource / $hauteurSource;
// Calcule pour garder le raport largeur / hauteur
if($largeurSource >= $hauteurSource){
$largeurDestination = $grand;
$hauteurDestination = $largeurDestination / $rapport_dim;
}else{
$hauteurDestination = $grand;
$largeurDestination = $hauteurDestination * $rapport_dim;
}
// Création de l'image
$im = ImageCreateTrueColor ($largeurDestination, $hauteurDestination) or die ('Erreur lors de la création de l\'image');
ImageCopyResampled($im, $source, 0, 0, 0, 0, $largeurDestination, $hauteurDestination, $largeurSource, $hauteurSource);
ImageJpeg($im, $destination.'/'.$fichierSource);
}
function knowdir($path){
$path = dirname($path);
$path = strrchr($path,'/');
return $path;
}
include ('../inc/config.php');
$dir = knowdir($_SERVER['PHP_SELF']);
$image_path = $path.'galerie/'.$dir;
//création du tableau des photos
$dir_connect = opendir('./img');
$table_id = 1;
while($file=readdir($dir_connect)) {
if($file !== '.' & $file !== '..'){
$photos_tab[$table_id]=$file;
$table_id++;
}
}
sort($photos_tab);
$dir_sans=str_replace(' ','%20',$dir);
echo '<br /><br /><br /><center>',"\n"
,'<a href="',$path,'galerie',$dir_sans,'/new.php" onclick="window.open(\"',$path,'galerie',$dir_sans,'/new.php\",\"new_photo\",\"status=no,scrollbars=yes,width=450,height=500,directories=no,location=no,resizable=yes,toolbar=no\");" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">Ajouter une nouvelle photo</a>',"\n"
,'<table style="border:0px; width:100%;"><tr>',"\n";
if(!isset($_GET['photo_id'])){
echo '<table style="color:',$table_color,';"><tr>';
$nb_maxi_img = 30;
$init=3;
$nb_page = round($table_id/$nb_maxi_img)-1;
if(!IsSet($_GET['page'])){
$table_read=1;
$begin = 1;
$_GET['page'] = 0;
}else{
$table_read=$nb_maxi_img*$_GET['page'];
$begin = $nb_maxi_img*$_GET['page'];
$nb_maxi_img = ($nb_maxi_img*$_GET['page'])+$nb_maxi_img-1;
}
$i=0;
for($table_read;$table_read<=$nb_maxi_img;$table_read++){
//while(@$file_photo=$photos_tab[$table_read]){
@$file_photo=$photos_tab[$table_read];
if($table_read >= $begin && !empty($file_photo)){
$i++;
if (!$redim){
$dim_thumb='';
$dim_thumb1='';
}else{
$hauteur_thumb1=3/4 * $dim_thumb1;
$dim_thumb='width:'.$dim_thumb1.'px; height:'.$hauteur_thumb1.'px;';
}
echo '<td style="padding-right:5px; padding-bottom:5px;">',"\n"
,'<div style="border-width:1px; border-style:solid; border-color:#C0C0C0; padding:1px 1px 1px 1px;">',"\n"
,'<a href="',$path,$nom_index,'galerie',$dir,'/index.php?photo_id=',$table_read,'" target="_blank">',"\n"
,'<img src="',$image_path,'/thumb/',$file_photo,'" style="border-width:1px; border-style:solid; border-color:#C0C0C0; ',$dim_thumb,'" /></a></div></td>',"\n\n\n";
if(!is_file('./thumb/'.$file_photo)){
thumb($file_photo,$dim_thumb1,'./thumb');
}
if(!is_file('./thumb2/'.$file_photo)){
thumb($file_photo,$dim_thumb2,'./thumb2');
}
if($init == $i){
$init=3+$i;
echo '</tr><tr>';
}
}
}
if($nb_page >= 1){
echo '<br /><div style="width:100%; text-align:center;">';
if($nb_page != $_GET['page']){
echo '<span style="float:right;"><a href="',$_SERVER['PHP_SELF'],'?page=',($_GET['page']+1),'" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">Suivant</a></span>';
}
if($_GET['page'] >= 1){
echo '<span style="float:left;"><a href="',$_SERVER['PHP_SELF'],'?page=',($_GET['page']-1),'" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">Précédent</a></span>';
}
echo '<a href="?page=0" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">1</a> ';
for($i=1;$i<=$nb_page;$i++){
echo '<a href="',$_SERVER['PHP_SELF'],'?page=',$i,'" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">',$i+1,'</a> ';
}
echo '</div><br />';
echo '<tr><td><br /></td><td></td><td></td></tr>';
echo '<tr><td>',"\r\n";
if($_GET['page'] >= 1){
echo '<a href="',$_SERVER['PHP_SELF'],'?page=',($_GET['page']-1),'" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">Précédent</a>';
}
echo '</td><td style="text-align:center;">'
,'<a href="?page=0" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">1</a> ';
for($i=1;$i<=$nb_page;$i++){
echo '<a href="',$_SERVER['PHP_SELF'],'?page=',$i,'" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">',$i+1,'</a> ';
}
echo '</td><td style="text-align:right;">',"\r\n";
if($nb_page != $_GET['page']){
echo '<a href="',$_SERVER['PHP_SELF'],'?page=',($_GET['page']+1),'" style="color:#000000;" onmouseover="this.style.color=\'#FF0000\';" onmouseout="this.style.color=\'#000000\';">Suivant</a>';
}
echo '</td></tr>',"\r\n";
}
echo '</table>';
}else{
$photo_id=$_GET['photo_id'];
$file_photo=$photos_tab[$photo_id];
if(!is_file('./thumb2/'.$file_photo)){
thumb($file_photo,$dim_thumb2,'./thumb2');
}
$link_file=str_replace(' ','%20',$file_photo);
echo '<td><center><a href="',$path,$nom_index,'galerie',$dir,'/index.php?photo_id=',$photo_id,'" ',"\n"
,'onclick="window.open(\"',$path,'galerie',$dir,'/img/',$link_file,'\");">',"\n"
,'<img src="',$image_path,'/img/',$file_photo,'" style="border:1px; border-style:solid;" /></a>',"\n"
,'<center></td>',"\n";
if(@$file_photo=$photos_tab[$photo_id+1]){
if (!is_file('./thumb/'.$file_photo)) {
thumb($file_photo,$dim_thumb1,'./thumb');
}
$photos_suiv=$photo_id+1;
echo '<td style="width:20%"><center><a href="',$path,$nom_index,'galerie',$dir,'/index.php?photo_id=',$photos_suiv,'"',"\n"
,'<img src="',$image_path,'/thumb/',$file_photo,'" style="border:0px;" /></a>',"\n"
,'<center></td>',"\n";
}
}
echo '</tr></table>';
?>