cs_mike501
Messages postés
88
Date d'inscription
dimanche 1 mai 2005
Statut
Membre
Dernière intervention
3 septembre 2007
8 août 2005 à 13:47
ou je me le code que tu ma donne dans le code suivant
<?php
error_reporting(E_ALL);
function thumb($photo,$grand,$destination){
$fichierSource = $photo;
$source = ImageCreateFromJpeg("./img/".$fichierSource);
$largeurSource = imagesx($source);
$hauteurSource = imagesy($source);
$rapport_dim= $largeurSource / $hauteurSource;
if ( $largeurSource >= $hauteurSource ) {
$largeurDestination = $grand;
$hauteurDestination = $largeurDestination / $rapport_dim;
}
else {
$hauteurDestination = $grand;
$largeurDestination = $hauteurDestination * $rapport_dim;
}
$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)) {
$photos_tab[$table_id]=$file;
$table_id++;
}
sort($photos_tab);
$dir_sans=str_replace(' ','%20',$dir);
echo '
<center>',"\n";
echo '[',$path,$nom_index,'galerie',$dir_sans,' Ajouter une nouvelle photo]',"\n";
echo '<table border="0" width="100%"><tr>',"\n";
if ( ! isset($_GET['photo_id'])) {
$table_read=2;
echo '<table color="',$table_color,'"><tr>';
while ( @$file_photo=$photos_tab[$table_read] ) {
if (!$redim) {
$dim_thumb='';
}
else {
$hauteur_thumb1=3/4 * $dim_thumb1;
$dim_thumb='width="'.$dim_thumb1.'" height="'.$hauteur_thumb1.'"';
}
echo '<td>',"\n";
echo '<center>[',$path,$nom_index,'galerie',$dir,'/index.php?photo_id=',$table_read,' ',"\n";
echo ']<center></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 ( intval(($table_read+($nb_photo_col-1))/$nb_photo_col) == ($table_read+($nb_photo_col-1))/$nb_photo_col and $table_read+2!=$nb_photo_col) {
echo '</tr><tr>';
}
$table_read ++;
}
}
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>[',$path,$nom_index,'galerie',$dir,'/index.php?photo_id=',$photo_id,' ',"\n";
echo ']',"\n";
echo '<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 width="20%"><center>',"\n";
echo '<center></td>',"\n";
}
}
?>