Voilà j'ai trouvé une galerie photo en php et elle fonctionne plutôt bien.
EN fait, le soucis se situe au niveau de l'ajout de commentaires des photos : tout le monde même les visiteurs peuvent en ajouter.
Je voudrais juste que seul l'administrateur puisse en ajouter.
Quelle est la meilleure solution pour arriver à ce résultat ?
Voici le code php :
http://pastecode.net/?action=viewpost&tag=2601
Je vous remercie par avance.
oO Ce code est une horreur ><
C'est pas tout le code là, faudrait nous le donner entierement ^^
Voici la code de la galerie :
<?
/*
PhenHP Album
Auteur : Phenol Mod by Yoan
Version : 1.2.8 - Langue : Français - Language : PHP/HTML
Date : 12/2005
Dernière Modification : 20/12/2005
$version = '1.2.8';
/*
----- [ PARAMETRES A REGLER POUR LA PERSONNALISATION DE VOTRE ALBUM ] --------------------------
$titre_site = 'Mon Album'; // Nom de l'Album.
$url_site = 'http://www.monsite.com'; // URL de votre Site Internet (sans / à la fin).
$texte_en_tete = 'Bienvenue dans votre Album Photos intéractif.<BR>Pour créer des Galeries, créez des Répertoires contenant vos Photos. Les Galeries porteront le nom de vos Répertoires. Bonne utilisation ! - En cas de Bugs ou autres : <A
HREF="http://www.phpcs.com/code.aspx?ID=35173">Con
tactez-moi par Commentaire</A>.<BR><I>Ce texte est modifiable, éditez le fichier index.php et modifiez les variables qui le permettent.</I><BR><BR><B><A HREF="http://www.phpcs.com/code.aspx?ID=35173">[ TELECHARGER LE SCRIPT PHENHP ALBUM '.$version.' MAINTENANT ! ]</A></B>'; // Description de l'Album - En-tête de votre Album - Présentation.
/*
----- [ PARAMETRES PLUS SPECIFIQUES PERSONNALISABLES ] -----------------------------------------
$nb_miniatures_par_ligne = 4; // Nombre de Photos MINIATURES affichées par ligne.
$hauteur_miniatures = 100; // Hauteur (en pixel) des miniatures générés.
$reduire_originaux = 0; // Activer(1) ou non(0) la réduction des fichiers originaux
$hauteur_photos = 600; // Hauteur (en pixel) des originaux retaillés.
$largeur_maxi_taille_relle = 650; // Largeur Maxi. des Photos affichées en taille réelle.
$longueur_maxi_nom = 15; // Longueur maximale du Nom des Photos dans l'aperçu des Galleries.
$nom_script = 'index.php'; // Nom du Script PHP.
$rep_images_du_script = '_images'; // Nom du répertoire où sont stockées les images fonctionnelles du Script.
$fichier_style = 'style.css'; // Nom du fichier CSS (Design) du Script.
$fichier_parametres_gallerie = '_infos_gallerie.php'; // Fichier contentant les Informations sur chaque Gallerie (présent dans les Répertoires correspondant aux Galleries).
$rep_gals='.'; //Répertoire où se situent les galleries par défaut mettre . (point)
$rep1 = ; // Répertoires à ne pas prendre en compte
$rep2 = ;
$rep3 = ;
$rep4 = ;
/*
----- [ NE PLUS RIEN TOUCHER A PARTIR DE CET ENDROIT !!! - DISFONCTIONNEMENT POSSIBLE ] --------
session_start();
error_reporting (2039);
require('fonctions.inc.php');
// Security by phpSecure.info
if ($_GET["rep"]){ $_GET["rep"]="./".$_GET["rep"]; }
//End
$wstt = 'self.window.status=\'PhenHP Album '.$version.' - Par Phenol, Mod par Yoan.\';';
echo '<HTML><HEAD><SCRIPT>'.$wstt.'</SCRIPT><META HTTP-EQUIV="imagetoolbar" CONTENT="no"><TITLE>'.$titre_site;
if ($_GET['rep']) { echo ' : '.ucfirst(substr($_GET['rep'],2)); }
if ($_GET['photo']) { echo ' : '.ucfirst(substr(substr($_GET['photo'], 0, -4), 0, 15)); }
echo '</TITLE><LINK HREF="'.$fichier_style.'" TYPE="text/css" REL="stylesheet"></HEAD><BODY ONCONTEXTMENU=\'return false;\'><DIV CLASS="Centrer"><DIV CLASS="Titre_Gallerie"> <IMG
SRC="'.$rep_images_du_script.'/fleche_droite_bleue
.gif" BORDER="0" ALIGN="absmiddle"> Bienvenue sur '.$titre_site.'.</DIV><DIV
CLASS="Texte"><BR>'.$texte_en_tete.'<BR> </DI
V>';
$signature = 'Album généré par le Script PHP <A
HREF="http://www.phpcs.com/code.aspx?ID=35173"><B>
PhenHP Album '.$version.'</B></A>, créé par Phenol Mod par Yoan.';
switch ($_GET['action']) {
default:
?>
<SCRIPT LANGUAGE="JavaScript">
function ouvrir_gallerie(gal) {
if(gal != 'choix')
location.href = '<? echo $nom_script; ?>?action=voir_gallerie&rep='+gal;
}
</SCRIPT>
<?
if ($_GET['rep']) { header("Location:
".$nom_script."?action=voir_gallerie&rep=".$_GET['
rep']); exit(); } else {
echo '<DIV CLASS="Titre_Gallerie"> <IMG
SRC="'.$rep_images_du_script.'/fleche_droite_bleue
.gif" BORDER="0" ALIGN="absmiddle"> '.$titre_site.' : Liste des Galeries</DIV>';
echo '<DIV CLASS="AffMini"><CENTER><BR>Choisissez ci-dessous une Galerie à visionner.<BR><FORM NAME="choix_gallerie"><SELECT NAME="choix_gallerie" ONCHANGE="ouvrir_gallerie(this.value);"><OPTION VALUE="choix">Choix de la Galerie</OPTION>';
$nb_gal = 0;
$nbpt=0;
$files = array();
$handle = opendir($rep_gals);
while($file = readdir($handle)) {
if($file != "." && $file != ".." && $file!=$rep1 && $file !=$rep2 && $file !=$rep3 && $file !=$rep4) {
$files[] = $file;
}
}
closedir($handle);
natsort($files);
foreach($files as $v) {
if (is_dir($rep_gals.'/'.$v) && $v != $rep_gals.'/'.$rep_images_du_script) {
$nb_gal++;
$nbp='?';
if
(file_exists($rep_gals.'/'.$v.'/'.$fichier_paramet
res_gallerie)) {
include($rep_gals.'/'.$v.'/'.$fichier_parame
tres_gallerie);
$nbpt+=$nbp;
}
if ($Password) {
echo '<OPTION VALUE="'.$rep_gals.'/'.$v.'">'.ucfirst($v).' ('.$nbp.') »»» Privé ! «««</OPTION>';
} else {
echo '<OPTION VALUE="'.$rep_gals.'/'.$v.'">'.ucfirst($v).' ('.$nbp.')</OPTION>';
}
}
}
echo '</SELECT></FORM>Un total de <B>'.$nb_gal.'</B> Galerie(s) disponible(s) et <b>'.$nbpt.'</b> Photos.</CENTER><br><br></DIV>';
echo "<center>".$signature."<br>";
compteur();
echo "</center>";
}
break;
case "voir_gallerie":
echo '<DIV CLASS="Titre_Gallerie"> <IMG
SRC="'.$rep_images_du_script.'/fleche_droite_bleue
.gif" BORDER="0" ALIGN="absmiddle"> '.$titre_site.' : '.ucfirst(substr($_GET['rep'],2)).'</DIV>';
if
(file_exists($_GET['rep'].'/'.$fichier_parametres_
gallerie)) {
include($_GET['rep'].'/'.$fichier_parametres_ga
llerie);
}
if($Password){
if(!isset($_GET['pass']))
{
echo "<SCRIPT>var passa=prompt('Quel est le Mot de Passe de la Galerie ".$_GET['rep']." ?','Mot de Passe');";
echo "window.location =
\"".$nom_script."?action=voir_gallerie&rep=".$_GET
['rep']."&pass=\"+passa;</SCRIPT>\n";
}
if ($_GET['pass'] != $Password) {
echo "<SCRIPT>window.location = '".$nom_script."';</SCRIPT>\n";
exit();
}}
echo '<DIV CLASS="AffMini">';
if (!is_dir($_GET['rep'].'/miniatures')) { mkdir($_GET['rep'].'/miniatures'); }
if (!file_exists($_GET['rep'].'/index.php')) {
if($fp = fopen($_GET['rep'].'/index.php',"a")) {
fwrite($fp, "<?\nheader(\"Location: ../index.php\");\n?>");
fclose($fp);
}
}
if
(!file_exists($_GET['rep'].'/'.$fichier_parametres
_gallerie)) {
if($fp =
fopen($_GET['rep'].'/'.$fichier_parametres_galleri
e,"a")) {
fwrite($fp, "<?\n".'$Description'." = \"Ecrivez ici la Description de votre Galerie.\"; // Description de votre Galerie.\n".'$Password'." = \"\"; // UNIQUEMENT POUR PROTEGER UNE GALERIE PAR UN MOT DE PASSE !!!\n?>");
fclose($fp);
}
}
if
(!file_exists($_GET['rep'].'/miniatures/index.php'
)) {
if($fp = fopen($_GET['rep'].'/miniatures/index.php',"a")) {
fwrite($fp, "<?\nheader(\"Location: ../../index.php\");\n?>");
fclose($fp);
}
}
if
(file_exists($_GET['rep'].'/'.$fichier_parametres_
gallerie)) {
include($_GET['rep'].'/'.$fichier_parametres_ga
llerie);
if ($Description && $Description != 'Ecrivez ici la Description de votre Galerie.') { echo '<BR><B><IMG SRC="'.$rep_images_du_script.'/comments.gif" BORDER="0" ALIGN="absmiddle"> Informations sur la Galerie :</B><BR><BR>'.$Description.'<BR> '; } else { echo '<BR>'; }
} else {
echo '<BR>';
}
echo '<TABLE WIDTH="100%"><TR WIDTH="100%" HEIGHT="'.$hauteur_mini.'">';
$width = (100/$nb_miniatures_par_ligne);
$i = 0;
if (@opendir($_GET['rep'])) {
$dir = opendir($_GET['rep']);
$nb_photos = 0;
$_SESSION['Photos']=array();
while($f = readdir($dir)) {
if (strtolower(substr($f, -3)) == "jpg" || strtolower(substr($f, -3)) == "gif" || strtolower(substr($f, -3)) == "png" || strtolower(substr($f, -3)) == "wbmp") {
$f_reel = $f;
$fdesc=$_GET['rep'].'/'.substr($f,0, -3).'txt';
$nb_photos++;
$_SESSION['Photos'][$f]=$nb_photos;
$mini_f = str_replace('.', '_m.', $f);
$mini_f = strtolower($mini_f);
if
(!file_exists($_GET['rep'].'/miniatures/'.$mini_f)
) {
if($reduire_originaux==1){creer_miniature($f, $_GET['rep'].'/', , $hauteur_photos,1); }
creer_miniature($f, $_GET['rep'].'/', $_GET['rep'].'/miniatures/', $hauteur_miniatures,0);
}
$taille = filesize($_GET['rep'].'/'.$f);
$taille = $taille /1024;
$taille = round($taille, 2);
if (file_exists($fdesc))
{
$desc="<b>";
$desc.=file_get_contents($fdesc);
$desc.="</b>";
}
else $desc=ucfirst(substr(substr($f, 0, -4), 0, $longueur_maxi_nom));
$f = strtolower($f);
$nombre=0;
if ($i < $nb_miniatures_par_ligne) {
echo '<TD WIDHT="'.$width.'%" HEIGHT="'.$hauteur_miniatures.'"
onMouseOver="document.getElementById(\.$mini_f.'
\').style.display=\'block\'; return false;"
onMouseOut="document.getElementById(\.$mini_f.'\
').style.display=\'none\'; return false;"><CENTER><A
HREF="'.$nom_script.'?action=voir_photo&rep='.subs
tr($_GET['rep'],2).'&photo='.$f_reel.'"><IMG SRC="'.$_GET['rep'].'/miniatures/'.$mini_f.'" BORDER="1" ALIGN="absmiddle"><BR>'.$desc.'</A> ';
if
(file_exists($_GET['rep'].'/'.$f_reel.'.php')){inc
lude($_GET['rep'].'/'.$f_reel.'.php');
echo "<div id='".$mini_f."'
style='position:absolute;display:none;background:#
00CCFF;'><A
HREF='comm.php?rep=".$_GET['rep']."&photo=".$f_ree
l."' target=_blank>".$nombre." Com(s)</a></div>";}
echo '</CENTER></TD>';
$i++;
} else {
echo '</TR><TR WIDTH="100%" HEIGHT="'.$hauteur_miniatures.'"><TD WIDHT="'.$width.'%" HEIGHT="'.$hauteur_miniatures.'"
onMouseOver="document.getElementById(\.$mini_f.'
\').style.display=\'block\'; return false;"
onMouseOut="document.getElementById(\''.$mini_f.'\
').style.display=\'none\'; return false;"><CENTER><A
HREF="'.$nom_script.'?action=voir_photo&rep='.subs
tr($_GET['rep'],2).'&photo='.$f_reel.'"><IMG SRC="'.$_GET['rep'].'/miniatures/'.$mini_f.'" BORDER="1" ALIGN="absmiddle"><BR>'.$desc.'</A> ';
if
(file_exists($_GET['rep'].'/'.$f_reel.'.php')){inc
lude($_GET['rep'].'/'.$f_reel.'.php');
echo "<div id='".$mini_f."'
style='position:absolute;display:none;background:#
00CCFF;'><A
HREF='comm.php?rep=".$_GET['rep']."&photo=".$f_ree
l."' target=_blank>".$nombre." Com(s)</a></div>";}
echo '</CENTER></TD>';
$i = 1;
}
}
}
if (!isset($nbp) || $nbp!=$nb_photos){
if($fp =
fopen($_GET['rep'].'/'.$fichier_parametres_galleri
e,"a")) {
fwrite($fp, "<?\n".'$nbp'." = \"".$nb_photos."\"; // Nombre de Photos.\n?>");
fclose($fp);
}
}
echo '</TR></TABLE><BR>Soit un total de <B>'.$nb_photos.'</B> Photos disponibles dans la Galerie <B>'.ucfirst(substr($_GET['rep'],2)).'</B>.<A HREF="'.$nom_script.'">[ Retour à la Liste des Galeries ]</A></DIV>';
} else {
echo '<DIV CLASS="Msg_Erreur"><IMG SRC="'.$rep_images_du_script.'/croix.gif" BORDER="0" ALIGN="absmiddle">Cette Galerie (Répertoire) n\'existe pas ou plus.</DIV>';
}
break;
case "voir_photo":
?>
<SCRIPT LANGUAGE="JavaScript">
function aggrandir(titre,chemin) {
i1 = new Image;
i1.src = chemin;
html = '<HTML><HEAD><META HTTP-EQUIV="imagetoolbar" CONTENT="no"><TITLE>Aggrandissement : '+titre+'</TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER><a href="#" onClick="window.close()"><IMG SRC="'+chemin+'" BORDER=0 NAME=imageTest
onLoad="window.resizeTo(document.imageTest.width,d
ocument.imageTest.height)"></a>' ;
html2 = '</CENTER></BODY></HTML>';
popupImage =
window.open(,,'toolbar=0,location=0,directorie
s=0,menuBar=0,scrollbars=1,resizable=0,top=40,left
=40');
popupImage.document.open();
popupImage.document.write(html+html2);
popupImage.document.close()
};
</SCRIPT>
<?
$galtitre=substr($_GET['rep'],2);
$phototitre=ucfirst(substr(substr($_GET['photo']
, 0, -4), 0, 15));
if(file_exists($_GET['rep'].'/'.substr($_GET['ph
oto'],0,-3).'txt'))
{
$phototitre.=' -
'.file_get_contents($_GET['rep'].'/'.substr($_GET[
'photo'],0,-3).'txt');
}
echo '<DIV CLASS="Titre_Gallerie"> <IMG
SRC="'.$rep_images_du_script.'/fleche_droite_bleue
.gif" BORDER="0" ALIGN="absmiddle"> Photo : '.$phototitre.' ('.$galtitre.')</DIV>';
if (file_exists($_GET['rep'].'/'.$_GET['photo'])) {
$taille = getimagesize($_GET['rep'].'/'.$_GET['photo']);
$poids = filesize($_GET['rep'].'/'.$_GET['photo']);
$poids = $poids/1024;
$poids = round($poids, 2);
$fphoto=$_GET['photo'];
$_SESSION['iPhotos']=array_flip($_SESSION['Photo
s']);
$prec=$_SESSION['Photos'][$fphoto]-1;
$suiv=$_SESSION['Photos'][$fphoto]+1;
$f_prec=$_SESSION['iPhotos'][$prec];
$f_suiv=$_SESSION['iPhotos'][$suiv];
if
(file_exists($_GET['rep'].'/'.$_GET['photo'].'.php
')){include($_GET['rep'].'/'.$_GET['photo'].'.php'
);} else $nombre=0;
echo '<DIV CLASS="AffNormal"><A NAME="HAUT"><CENTER><BR>Ci-dessous, la Photo <B>'.$phototitre.'</B> (Cliquer sur la Photo pour la voir en taille réelle) :<BR><BR>';
if($f_prec!=) echo '<A
HREF="'.$nom_script.'?action=voir_photo&rep='.subs
tr($_GET['rep'],2).'&photo='.$f_prec.'">[ Photo Précédente ]</A>';
echo '<A
HREF="'.$nom_script.'?action=voir_gallerie&rep='.s
ubstr($_GET['rep'],2).'">[ Retour Gallerie]</A> <A HREF="#"
ONCLICK="aggrandir(\.ucfirst(substr(substr($_GET
['photo'], 0, -4), 0,
15)).'\',\.$_GET['rep'].'/'.crypter($_GET['photo
']).'\');">[ Agrandir ]</A>';
if($f_suiv!=) echo '<A
HREF="'.$nom_script.'?action=voir_photo&rep='.subs
tr($_GET['rep'],2).'&photo='.$f_suiv.'">[ Photo Suivante ]</A>';
echo '<BR><IMG SRC="'.$rep_images_du_script.'/dot.gif" BORDER="0"><BR><A HREF="#"
ONCLICK="aggrandir(\.ucfirst(substr($_GET['photo
'], 0,
-4)).'\',\.$_GET['rep'].'/'.crypter($_GET['photo
']).'\');"><IMG ALT="Agrandir la Photo"
SRC="'.$_GET['rep'].'/'.crypter($_GET['photo']).'"
BORDER="1"';
if ($taille[0] > $largeur_maxi_taille_relle) { echo ' WIDTH="'.$largeur_maxi_taille_relle.'"'; }
echo '></A><BR><IMG SRC="'.$rep_images_du_script.'/dot.gif" BORDER="0"><BR>Nom : <B>'.ucfirst(substr($_GET['photo'], 0, -4)).'</B><BR>Taille : '.$taille[1].'x'.$taille[0].' (pixels)<BR>Poids : '.$poids.' Ko<BR> <b><A
HREF="comm.php?rep='.$_GET['rep'].'&photo='.$_GET[
'photo'].'" target=_blank>['.$nombre.' Commentaire(s) ]</A></b><BR><BR><A HREF="#HAUT">[ Remonter ]</A></CENTER></DIV>';
} else {
echo '<DIV CLASS="Msg_Erreur"><IMG SRC="'.$rep_images_du_script.'/croix.gif" BORDER="0" ALIGN="absmiddle">Cette Photo n\'existe pas ou plus.</DIV>';
}
break;
}
echo '</DIV></BODY></HTML>';
/*
PhenHP Album
Auteur : Phenol <PhenMail@Sfr.fr> - Site Internet : Http://PhenHP.Ouaibe.net
Version : 1.2.8 - Langue : Français - Language : PHP/HTML
Date : 01/2004
Dernière Modification : 28/08/2006
?>
En fait je cherche juste une galerie photo simple avec la description des photos.
Celle-ci me paraît bien.
Désolé mais le site pastecode ne marche plus "internal error"
pastcode ^^
Salut.
C'est bizarre le site pastcode ne marche toujours pas. "internal error"
Vous n'en connaissez pas un autre pour coloriser le code ?
Sinon peut-être que vous connaissez une galerie pas trop "lourde" correspondant à mes attentes.
Celle-ci est bien mais je veux que seul l'admin puisse ajouter des commentaires sous chaque photo(et les supprimer)
Merci d'avance.
il fonctionne de nouveau ;)
En fait je crois que le code est trop long c'est pour ça.
C'est vraiment dommage car cette galerie correspond à mes attentes.
Seulement tout le monde peut poster des commentaires sur les photos or je veux juste que l'administrateur puisse le faire.
N'est-il pas possible de mettre un mot de passe ou quelque chose comme ça ?
Voici le code php pour la gestion des commentaires :
http://pastecode.net/?action=viewpost&tag=2601
Merci.
post le en 2 fois, là c'est simplement IMBUVABLE ![]()
fonction ajout commentaires : http://pastecode.net/?action=viewpost&tag=2601
galerie photo :
partie 1 : http://pastecode.net/?action=viewpost&tag=2614
partie 2 : http://pastecode.net/?action=viewpost&tag=2615
partie 3
: http://pastecode.net/?action=viewpost&tag=2616
Voilà j'espère que ça ira.
Merci d'avance pour votre aide.
Ok, sinon j'ai mangé une pomme, nan sérieux, c'est thymotep (thymos) !
J'aime pas ton code, il pu, @+ ok ?
C'étais un message de thymo, avec une pensée de ... jdis pas ![]()
C'est pas mon code d'abord
Non mais allez sérieux, ça fait plusieurs semaines que je cherche une galerie photo valable...
Merci.