2020-11-29 11:25:34 +01:00
< ? php
/*
Name : goldbook . php
Author : NicoSoft
Création : 14 / 08 / 01
MAJ : 23 / 09 / 01
*/
include_once " include/standard.inc.php " ;
extract ( $_POST );
2024-02-12 20:46:07 +01:00
if ( isset ( $GoldbookFile ) && $GoldbookFile != " " ) {
$GoldbookFile = " default " ;
}
2020-11-29 11:25:34 +01:00
$Cpt = 0 ;
echo " <form method='post' action=' " ;
2024-02-12 20:46:07 +01:00
echo " /livre.html'> \n " ;
2020-11-29 11:25:34 +01:00
2024-02-12 20:46:07 +01:00
echo " <div class='center'><table border='0'><tr><td>
2020-11-29 11:25:34 +01:00
< input type = 'hidden' name = 'param' value = 'postgb' />
< input name = 'GoldBookFile' value = '".$GoldbookFile."' type = 'hidden' />
< i > Nom / Pseudo ( facultatif ) </ i >:< input name = \ " VName \" type='text' size='20' value= \" \" /></td><td>
< i > e - mail ( facultatif ) </ i >:< input name = \ " VEmail \" type='text' size='20' value= \" \" /></td></tr>
< tr >< td >< div class = 'center' >< i > Message </ i >:< textarea name = 'VMessage' cols = '50' rows = '12' ></ textarea ></ div ></ td ></ tr >
< input name = 'piejacon' value = 'piejacon' class = 'piejacon' />
< tr >< td class = 'right' >< input name = \ " Ecrire \" value='Ecrire' type='submit' /></td><td><input name= \" Effacer \" value= \" Effacer \" type= \" reset \" /></td></tr></table></div></form>
< h6 >< i > Notes </ i >: Les balises HTML ne sont pas autorisés dans la boite de saisie . Les messages sont modérés , ils n 'apparaitront donc pas immédiatement sur le livre d' or .</ h6 > \n " ;
2024-02-12 20:46:07 +01:00
// <hr></td></tr>\n";
2020-11-29 11:25:34 +01:00
unset ( $File );
// si le fichier n'existe pas, on le crée:
2024-02-12 20:46:07 +01:00
if ( ! ( file_exists ( " modules/goldbook/ $GoldbookFile .csv " ))) {
$goldbook = fopen ( " modules/goldbook/ $GoldbookFile .csv " , " w+ " );
fclose ( $goldbook );
2020-11-29 11:25:34 +01:00
}
// ajout des messages
2024-11-03 21:50:57 +01:00
if ( isset ( $param ) && $param == " postgb " ) {
2024-02-12 20:46:07 +01:00
if ( $VMessage != " " && isset ( $_POST [ 'piejacon' ])) {
2024-03-30 21:59:38 +01:00
$date = date_format ( date_create (), " d/m/Y " );
2024-02-12 20:46:07 +01:00
$iheure = date ( " H:i " );
2024-11-03 21:50:57 +01:00
$VMessage = str_replace ( " < " , " < " , $VMessage );
$VMessage = str_replace ( " > " , " > " , $VMessage );
2024-02-12 20:46:07 +01:00
$VMessage = parse_string ( stripcslashes ( $VMessage ));
2024-11-03 21:50:57 +01:00
$VMessage = str_replace ( " \n " , " <br /> " , $VMessage );
$VMessage = str_replace ( " & " , " & " , $VMessage );
2024-02-12 20:46:07 +01:00
$gbline = sprintf ( " \" " . $date . " \" , \" " . $iheure . " \" , \" " . htmlspecialchars ( $VName ) . " \" , \" " . $VEmail . " \" , \" " . $VMessage . " \" \n " );
2024-11-03 22:10:58 +01:00
// $goldbook = fopen("modules/goldbook/$GoldbookFile.csv", "a");
// fwrite($goldbook, $gbline);
// fclose($goldbook);
2024-02-12 20:46:07 +01:00
mail ( " n@tourmentine.com " , " [TMA] post livre d'or " , $VMessage , " From: " . $VName . " < " . $VEmail . " > \r \n X-Mailer: PHP/ " . phpversion ());
//unlink("$GoldbookFile.dat");
}
2020-11-29 11:25:34 +01:00
}
// lecture des messages
2024-02-12 20:46:07 +01:00
$goldbook = fopen ( " modules/goldbook/ $GoldbookFile .csv " , " r " );
while ( $data = fgetcsv ( $goldbook , 1000 , " , " )) {
$VisitorDate [ $Cpt ] = $data [ 0 ];
$VisitorTime [ $Cpt ] = $data [ 1 ];
$VisitorName [ $Cpt ] = stripcslashes ( $data [ 2 ]);
$VisitorEmail [ $Cpt ] = $data [ 3 ];
$VisitorMessage [ $Cpt ++ ] = stripcslashes ( $data [ 4 ]);
2020-11-29 11:25:34 +01:00
}
fclose ( $goldbook );
unset ( $data );
unset ( $goldbook );
// si $NbMaxPost n'est pas défini, ou si il est plus grand que le nombre d'éléments, on l'ajuste à ce nombre
2024-02-12 20:46:07 +01:00
if (( ! isset ( $NbMaxPost )) || ( $NbMaxPost > $Cpt )) {
$NbMaxPost = $Cpt ;
2020-11-29 11:25:34 +01:00
}
// affichage des messages
echo " <hr /><div class='left'> " ;
2024-02-12 20:46:07 +01:00
if ( $NbMaxPost ) {
2024-09-14 21:20:01 +02:00
for ( $i = 0 ; $i <= $NbMaxPost - 1 ; $i ++ ) {
2024-02-12 20:46:07 +01:00
if ( $VisitorName [ $i ] == " " ) {
$VisitorName [ $i ] = " Anonyme " ;
}
2020-11-29 11:25:34 +01:00
2024-02-12 20:46:07 +01:00
if ( $VisitorEmail [ $i ] != " " ) {
$Visiteur = " <a href='mailto: " . $VisitorEmail [ $i ] . " '> " . $VisitorName [ $i ] . " </a> " ;
} else {
$Visiteur = $VisitorName [ $i ];
}
2020-11-29 11:25:34 +01:00
2024-02-12 20:46:07 +01:00
echo " <i>Posté le " . $VisitorDate [ $i ] . " à " . $VisitorTime [ $i ] . " par <b> " . $Visiteur . " </b></i>:
2020-11-29 11:25:34 +01:00
< br /> « " . $VisitorMessage[$i] . " » < br /> " ;
2024-02-12 20:46:07 +01:00
if ( $i != ( $NbMaxPost - 1 )) {
echo " <hr /> " ;
}
}
2020-11-29 11:25:34 +01:00
}
echo " </div> " ;
$footerbox = 0 ;
//$footerboxtext = "Retour au menu";
//$footerlien = "/";