voici l'entièreté du code livredor.php. Merci:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta http-equiv="Expires" content="Mon, 31 Dec 2001 20:01:00 GMT">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<title>Livre d'Or</title>
</head>
<?php
require("livredor.txt" );
$pass = "***";
$webmaster = "***";
$ext = "php";
function UpCaseAllSp($s)
{
$s=ereg_replace("à","A",$s);
$s=ereg_replace("â","A",$s);
$s=ereg_replace("ä","A",$s);
$s=ereg_replace("é","E",$s);
$s=ereg_replace("è","E",$s);
$s=ereg_replace("ê","E",$s);
$s=ereg_replace("ë","E",$s);
$s=ereg_replace("î","I",$s);
$s=ereg_replace("ï","I",$s);
$s=ereg_replace("ô","O",$s);
$s=ereg_replace("ö","O",$s);
$s=ereg_replace("ù","U",$s);
$s=ereg_replace("ü","U",$s);
$s=ereg_replace("û","U",$s);
$s=ereg_replace(";",".,",$s);
$s=strtoupper($s);
return $s;
}
function stringpos($c,$s)
{
global $ext;
$posi=strpos($s,$c);
if ($ext!='php3') {
if ($posi===FALSE) {
$posi=-1;
}
}
else {
if (is_string($posi) && !$posi) {
$posi=-1;
}
}
return $posi;
}
function stringalignsx($s)
{
$res=chr(ord($s)-1);
return $res;
}
function stringalignsy($s)
{
$res=chr(ord($s)+1);
return $res;
}
function stringcopy($s,$p,$l)
{
$res=substr($s,$p-1,$l);
return $res;
}
function stringlength($s)
{
$res=strlen($s);
return $res;
}
function conv0($t)
{
if (strlen($t) == 1) {
$t="0".$t;
}
return $t;
}
function GetString(&$r)
{
if (stringpos("+",$r)>=0) {
$res=stringcopy($r,1,stringpos("+",$r)-1);
$r=stringcopy($r,stringpos("+",$r)+1,stringlength($r));
}
else {
$res=$r;
$r="";
}
return $res;
}
function MakeLstMots($s)
{
if ($s!="" ) {
$s=ltrim($s);
while (($s!="" ) && (stringpos(" ",$s)>=0)) {
$LstMots[]=UpCaseAllSp(stringcopy($s,1,stringpos(" ",$s)-1));
$s=stringcopy($s,stringpos(" ",$s)+1,stringlength($s));
}
if ($s!="" ) {$LstMots[]=UpCaseAllSp($s);}
}
return $LstMots;
}
function search($don,$mots)
{
if ($mots!="" ) { $LstMots=MakeLstMots($mots); }
if (file_exists($don)) {
$fic=file($don);
reset($fic);
$i=0;
while ($val=each($fic)) {
$ligne=$val[1];
$i++;
if ($mots=="" ) { $found=true; }
else {
$found=false;
$foundm=false;
for ($l=0;$l<count($LstMots);$l++) {
if (stringpos("+",$LstMots[$l])>=0) {
$inter=$LstMots[$l];
$foundm=true;
while (($inter!="" ) && $foundm) {
$foundm=$foundm && (stringpos(GetString($inter),UpCaseAllSp($ligne))>=0);
}
}
else {
$foundm=$foundm ||
(stringpos($LstMots[$l],
UpCaseAllSp($ligne))>=0);
}
}
$found=$foundm;
}
if ($found) { $SearchResult[]=$ligne.";".$i; }
}
}
return $SearchResult;
}
function stringcopysx($s)
{
$sd='';
for ($i=1;$i<=strlen($s);$i++) {
if (stringcopy($s,$i,1)=='"') {
$sd=$sd.stringcopy($s,$i,1);
}
else {
if (stringcopy($s,$i,2)=='\!') {
$sd=$sd.'!';
$i++;
}
else {
if (stringcopy($s,$i,2)=='\&') {
$sd=$sd.'&';
$i++;
}
else {
$sd=$sd.stringalignsx(stringcopy($s,$i,1));
}
}
}
}
return $sd;
}
function secure($chaine)
{
return htmlspecialchars($chaine);
}
function HTMLEncode($text)
{
$searcharray = array(
"'([-_\w\d.]+@[-_\w\d.]+)'",
"'((?
?!://).{3}|^.{0,2}))(www\.[-\d\w\.\/\?=&]+)'",
"'(http[s]?:\/\/[-_~\w\d\.\/\?=&]+)'" );
$replacearray = array(
"<a href=\"mailto:\\1\">\\1</a>",
"\\1http://\\2",
"<a href=\"\\1\" target=\"new\">\\1</a>" );
return nl2br(preg_replace($searcharray, $replacearray,
stripslashes($text) ));
}
function TexteEncode($texte)
{
$texte=str_replace(".,",";",$texte);
$texte=str_replace("|:-)","<img src=\"livredor/sm01.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|:-(","<img src=\"livredor/sm02.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|;-)","<img src=\"livredor/sm03.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|;-)","<img src=\"livredor/sm03.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|8-0","<img src=\"livredor/sm04.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|:-p","<img src=\"livredor/sm05.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/-(","<img src=\"livredor/sm06.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/M/","<img src=\"livredor/sm07.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/B/","<img src=\"livredor/sm08.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/-@","<img src=\"livredor/sm09.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/I/","<img src=\"livredor/sm10.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/-/","<img src=\"livredor/sm11.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/+/","<img src=\"livredor/sm12.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/?/","<img src=\"livredor/sm13.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|/!/","<img src=\"livredor/sm14.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|00/","<img src=\"livredor/sm15.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|01/","<img src=\"livredor/sm16.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|02/","<img src=\"livredor/sm17.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|03/","<img src=\"livredor/sm18.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|04/","<img src=\"livredor/sm19.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|05/","<img src=\"livredor/sm20.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|06/","<img src=\"livredor/sm21.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|07/","<img src=\"livredor/sm22.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|08/","<img src=\"livredor/sm23.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|09/","<img src=\"livredor/sm24.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|10/","<img src=\"livredor/sm25.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|11/","<img src=\"livredor/sm26.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|12/","<img src=\"livredor/sm27.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|13/","<img src=\"livredor/sm28.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|14/","<img src=\"livredor/sm29.gif\" align=\"absmiddle\">",$texte);
$texte=str_replace("|15/","<img src=\"livredor/sm30.gif\" align=\"absmiddle\">",$texte);
$texte=HTMLEncode($texte);
return $texte;
}
function PrepPage(&$Ficw)
{
$s="=q!bmjho>\"dfoufs\"?=b!isfg>\"iuuq;00";
$s=$s."gbobufl/gsff/gs\"!ubshfu>\"ofx\"?";
$Ficw[]=stringcopysx($s);
$s="=jnh!tsd>\"iuuq;00gbobufl/gsff/gs";
$s=$s."0jnbhft0mjwsfeps/hjg\"";
$s=$s."!cpsefs>1!ujumf>\"Wfof{!ufmfdibshfs!df!mjwsf!e(Ps!hsb";
$s=$s."uvju!fu!jotubmmf{.mf!tvs!wpusf!tjuf!fo!rvfmrvft!njovuft\"?=0b?=0q?";
$Ficw[]=stringcopysx($s);
$s="=0CPEZ0IUNM?";
$Ficw[]=stringcopysx(stringcopy($s,1,6)."?" );
$Ficw[]=stringcopysx("=".stringcopy($s,7,6));
}
function CountPages(&$Ficw,$nmestot,$nmes,&$npag,$mot,$nofb,$nof,$Idx)
{
global $ext,$fnnpg,$ftnpg,$fcnpg,$fnpgc,$ftpgc,$fcpgc;
$s0='';$nn=3;
if ($nmestot>$nmes) {
if ($npag=="" ) { $npag=1; }
$nbpage=$nmestot/$nmes;
if (($nmestot%$nmes)!=0) { $nbpage++; }
$Ficw[]="<CENTER>";
$Ficw[]="<TABLE WIDTH=90% BORDER=1 CELLPADDING=4 CELLSPACING=0 FRAME=HSIDES>";
$Ficw[]="<COL WIDTH=256*>";
$Ficw[]="<TR>";
$Ficw[]="<TD WIDTH=100%>";
$Ficw[]="<P ALIGN=CENTER>";
if ($mot=="" ) { $adr="livredor.$ext?action=readall";}
else {$adr="livredor.$ext?action=read&mots=$mots";}
$fnpag="<FONT FACE=$fnnpg><FONT SIZE=\"$ftnpg\"><FONT COLOR=\"$fcnpg\">";
$fpagc="<FONT FACE=$fnpgc><FONT SIZE=\"$ftpgc\"><FONT COLOR=\"$fcpgc\"><B>";
$Ficw[]=$fpagc."Page ".$nofb;
$pgsuiv=$npag+1;
$pgprec=$npag-1;
if ($npag!=1) {
$Ficw[]="<a href=\"$adr&npag=$pgprec\">".$fnpag."<<".$nof."</a> ";
}
for ($i=1;$i<=$nbpage;$i++) {
if ($i!=$npag) {
$Ficw[]="<a href=\"$adr&npag=$i\">".$fnpag.$i.$nof."</a> ";
}
else {
$Ficw[]=$fpagc."$i ".$nofb;
}
}
if ($npag!=$nbpage) {
$Ficw[]=" <a href=\"$adr&npag=$pgsuiv\">".$fnpag.">>".$nof."</a>";
}
$Ficw[]="</P>";
$Ficw[]="</TD>";
$Ficw[]="</TR>";
$Ficw[]="</TABLE>";
$Ficw[]="</CENTER>";
$Ficw[]="<BR>";
}
else {
$fnpag="<FONT FACE=$fnnpg><FONT SIZE=\"$ftnpg\"><FONT COLOR=\"$fcnpg\">";
$fpagc="<FONT FACE=$fnpgc><FONT SIZE=\"$ftpgc\"><FONT COLOR=\"$fcpgc\"><B>";}
if ($Idx!=0) {
for ($i=0;$i<=$nn;$i++) {
$Ficw[]=$Ficw[$Idx+$i];
$Ficw[$Idx+$i]=$s0;
}
$ficw[]=$fpagc."Page ".$nofb;
$ficw[]="</P>";
$ficw[]="</TD>";
$ficw[]="</TR>";
$ficw[]="</TABLE>";
$ficw[]="</CENTER>";
$ficw[]="<BR>";
}
}
function limit($s,$max)
{
$split=split(" ",$s);
$nmots=count($split);
$so="";
for ($i=0;$i<$nmots;$i++) {
$url=($i>0) && ($split[$i-1]=="<a" ) &&
(stringpos("href=",$split[$i])==0);
if ((!$url) && (strlen($split[$i])>$max)) {
$nbm=(strlen($split[$i])/$max)+1;
$mot=stringcopy($split[$i],1,$max);
for ($j=1;$j<=$nbm;$j++) {
$mot=$mot." ".stringcopy($split[$i],$j*$max+1,$max);
}
$split[$i]=$mot;
}
if ($i==0) {$so=$split[$i];}
else {$so=$so." ".$split[$i];}
}
return $so;
}
function CreatePage($mots,$res,$SearchResult,$npag)
{
global $ltab,$tbord,$nmes,$nmax,
$tbcel1,$lcel2,$tbcel2,$lcel3,$tbcel3,$tbcel4,
$cfond,$cbord,$cbclair,$cbfonce,$cbbckimg,$cfdat,$cbdat,$cbcdat,$cbfdat,
$cfnom,$cbnom,$cbcnom,$cbfnom,$cfurl,$cburl,$cbcurl,$cbfurl,
$cftxt,$cbtxt,$cbctxt,$cbftxt,
$fccompt,$ftcompt,$fncompt,$fcsign,$ftsign,$fnsign,
$fcnom,$ftnom,$fnnom,$fcurl,$fturl,$fnurl,
$fctxt,$fttxt,$fntxt,$anbm,$fcnumm,$fnnumm,$ftnumm,
$fcnpg,$ftnpg,$fnnpg,$fcpgc,$ftpgc,$fnpgc,$ext,$webmaster;
$ac="bob";$bc="ff/gs";$Ficw=file($res);$s="g".$ac."ufl/gs".$bc."\"!ubshfu>\"ofx\"?";
end($Ficw);$s="=q!bmjho>\"dfoufs\"?=b!isfg>\"iuuq;00".$s;$Idx=count($Ficw);
$Ficw[]=stringcopysx($s);$s="=jnh!tsd>\"iuuq;00g".stringcopy($ac,1,2)."bufl/gs".$bc;
$s=$s."0jnbhft0mjwsfeps/hjg\"";$s=$s."!cpsefs>1!ujumf>\"Wfof{!ufmfdibshfs!df!mjwsf!e(Ps!hsb";
$s=$s."uvju!fu!jotubmmf{.mf!tvs!wpusf!tjuf!fo!rvfmrvft!njovuft\"?=0b?=0q?";
$Ficw[]=stringcopysx($s);
$s="=0CPEZ?=0IUNM?";
$Ficw[]=stringcopysx(stringcopy($s,1,7));
$Ficw[]=stringcopysx(stringcopy($s,8,7));
if ($mots!="" ) {
$Ficw[]="<P ALIGN=LEFT STYLE=\"text-decoration: none\"><FONT COLOR=\"$fccompt\">".
"<FONT FACE=\"$fncompt\"><FONT SIZE=$ftcompt><B>Recherche de :";
$Ficw[]=$mots." </B></FONT></FONT></FONT></P>";
}
$Ficw[]="<P ALIGN=$anbm STYLE=\"text-decoration: none\"><FONT COLOR=\"$fccompt\">".
"<FONT FACE=\"$fncompt\"><FONT SIZE=$ftcompt><B>".count($SearchResult);
if ($mots!="" ) {$Ficw[]=" messages trouvés</B></FONT></FONT></FONT></P>"; }
else {$Ficw[]=" messages</B></FONT></FONT></FONT></P>"; }
$nofb="</B></FONT></FONT></FONT>";
$nof="</FONT></FONT></FONT>";
$fsign="<FONT FACE=$fnsign><FONT SIZE=\"$ftsign\"><FONT COLOR=\"$fcsign\">";
$fnumm="<FONT FACE=$fnnumm><FONT SIZE=\"$ftnumm\"><FONT COLOR=\"$fcnumm\">";
$fnom="<FONT FACE=$fnnom><FONT SIZE=\"$ftnom\"><FONT COLOR=\"$fcnom\"><B>";
$fip="<FONT FACE=$fnnom><FONT SIZE=\"0\"><FONT COLOR=\"$fcnom\">";
$furl="<FONT FACE=$fnurl><FONT SIZE=\"$fturl\"><FONT COLOR=\"$fcurl\"><B>";
$ftxt="<FONT FACE=\"$fntxt\"><FONT SIZE=$fttxt><FONT COLOR=\"$fctxt\">";
$ptab="border=\"$tbord\" width=\"$ltab\" bgcolor=\"$cfond\" bordercolor=\"$cbord\"
bordercolordark=\"$cbfonce\" bordercolorlight=\"$cbclair\"";
//no background
$pcel1="bgcolor=\"$cfdat\" bordercolor=\"$cbdat\"
bordercolordark=\"$cbfdat\" bordercolorlight=\"$cbcdat\"";
$pcel23="bgcolor=\"$cfnom\" bordercolor=\"$cbnom\"
bordercolordark=\"$cbfnom\" bordercolorlight=\"$cbcnom\"";
$pcel2="width=\"$lcel2\" bgcolor=\"$cfnom\" bordercolor=\"$cbnom\"
bordercolordark=\"$cbfnom\" bordercolorlight=\"$cbcnom\"";
$pcel3="width=\"$lcel3\" bgcolor=\"$cfurl\" bordercolor=\"$cburl\"
bordercolordark=\"$cbfurl\" bordercolorlight=\"$cbcurl\"";
$pcel4="width=\"100%\" bgcolor=\"$cftxt\" bordercolor=\"$cbtxt\"
bordercolordark=\"$cbftxt\" bordercolorlight=\"$cbctxt\"";
$nmestot=count($SearchResult);
CountPages($Ficw,$nmestot,$nmes,$npag,$mot,$nofb,$nof,$idx);
$bi=($npag-1)*$nmes;
$bs=$npag*$nmes;
for ($i=$nmestot-1;$i>=0;$i--) {
$ii=$nmestot-$i;
if ( ($npag=="" ) || (($bi<$ii) && ($ii<=$bs)) ) {
$atab=split(";",$SearchResult[$i],13);
$date=$atab[0];
$nom=str_replace(".,",";",$atab[1]);
$email=str_replace(".,",";",$atab[2]);
$url=str_replace(".,",";",$atab[3]);
$texte=TexteEncode($atab[4]);
$nom=limit($nom,40);
$texte=limit($texte,90);
$ip=""; //no ip
$wmtexte=TexteEncode($atab[6]);
$num=$atab[12];
$href="http://www.fisenne.be/fichiers/livredor/livredor.$ext?action=edit&numligne=$num";
$Ficw[]="<CENTER>";
$Ficw[]="<table $ptab>";
$Ficw[]="<tr>";
$Ficw[]="<td width=\"$lcel2\" $pcel1><p align=\"left\">".$fsign.$date.$nof."</p></td>";
$Ficw[]="<td width=\"$lcel3\" $pcel1><p align=\"right\">"."<a href=$href>".$fnumm.$num.$nof."</a></p></td>";
$Ficw[]="</tr>";
$Ficw[]="<tr>";
if (strtoupper($url)=="HTTP://" ) {$url="";}
$ucnom=UpCaseAllSp($nom);
if (($ucnom==UpCaseAllSp($webmaster)) || ($ucnom=="WEBMASTER" )) {
$wmi="<img src=\"http://www.fisenne.be/fichiers/livredor/webmaster.gif\" align=\"absmiddle\"> ";
$ip=""; //masquage IP webmaster
}
else {
$wmi="";
}
if ($ip!="" ) {
$iptab=explode(".",$ip);
$ip=$fip." (".$iptab[0].".".$iptab[1].".".$iptab[2].".---)".$nof;
}
if ($url!="" ) {
if (stringpos("HTTP://",strtoupper($url))!=0) {
$url="http://".$url;
}
$urltxt=limit($url,40);
if ($email!="" ) {
$Ficw[]="<td $pcel2>".$wmi."<a href=mailto:$email><img src=\"http://www.fisenne.be/fichiers/livredor/email.gif\" align=\"absmiddle\" border=0 title=\"Envoyez-moi un email - Send me an email\"></a> <a href=mailto:$email>".$fnom.$nom.$nofb."</a>".$ip."</td>";
}
else {
$Ficw[]="<td $pcel2>".$wmi.$fnom.$nom.$nofb.$ip."</td>";
}
$Ficw[]="<td $pcel3><a href=\"$url\" target=\"new\"><img src=\"http://www.fisenne.be/fichiers/livredor/www.gif\" align=\"absmiddle\" border=0 title=\"Visitez mon site - Visit my website\"></a> <a href=\"$url\" target=\"new\">".$furl.$urltxt.$nofb."</a></td>";
}
else {
if ($email!="" ) {
$Ficw[]="<td colspan=\"2\" $pcel23>".$wmi."<a href=mailto:$email><img src=\"http://www.fisenne.be/fichiers/livredor/email.gif\" align=\"absmiddle\" border=0 title=\"Envoyez-moi un email - Send me an email\"></a> <a href=mailto:$email>".$fnom.$nom.$nofb."</a>".$ip."</td>";
}
else {
$Ficw[]="<td colspan=\"2\" $pcel23>".$wmi.$fnom.$nom.$nofb.$ip."</td>";
}
}
$Ficw[]="</tr>";
$Ficw[]="<tr>";
if ($wmtexte=="" ) {
$Ficw[]="<td colspan=\"2\" $pcel4>".$ftxt.$texte.$nof."</td>";
}
else {
$Ficw[]="<td colspan=\"2\" $pcel4>".$ftxt.$texte."<BR><HR><I><B>$webmaster : </B>".$wmtexte.$nof."</I></td>";
}
$Ficw[]="</tr>";
$Ficw[]="</table>";
$Ficw[]="</CENTER>";
$Ficw[]="<BR>";
}
}
CountPages($Ficw,$nmestot,$nmes,$npag,$mot,$nofb,$nof,$Idx);
return $Ficw;
}
function convert($ligne,$secureit,$wm)
{
$inter="";
if ($ligne!="" ) {
$bold=false;$under=false;$ital=false;
if ($secureit) {$ligne=secure($ligne);}
for ($i=0;$i<stringlength($ligne);$i++) {
$add=$ligne[$i];
if ($ligne[$i]==";" ) {
$add=".,";
}
if ($ligne[$i]=="\r" ) {
$add="<BR>";
if ($bold) { $add="</B>" .$add; $bold=false; }
if ($under) { $add="</U>" .$add; $under=false; }
if ($ital) { $add="</EM>".$add; $ital=false; }
$i++; // pour sauter le #10
}
if ($ligne[$i]=="$" ) {
$i++;
$c=strtoupper($ligne[$i]);
if ($c=="G" ) { $add="<B>" ; $bold=true; }
if ($c=="S" ) { $add="<U>" ;$under=true; }
if ($c=="I" ) { $add="<EM>"; if (!$wm) {$ital=true;} }
if (($c!="G" )&&($c!="S" )&&($c!="I" )) { $add="$";$i--; }
}
if ($ligne[$i]==" " ) {
if ($bold) { $add="</B>" .$add; $bold=false; }
if ($under) { $add="</U>" .$add; $under=false; }
if ($ital) { $add="</EM>".$add; $ital=false; }
}
$inter=$inter.$add;
}
$add="";
if ($bold) { $add="</B>" ; $bold=false; }
if ($under) { $add="</U>" ; $under=false; }
if ($ital) { $add="</EM>"; $ital=false; }
$inter=$inter.$add;
$inter=StripSlashes($inter);
}
return $inter;
}
function produceHTML($f)
{
$fic=file($f);
reset($fic);
while ($val=each($fic)) {
echo "$val[1]";
}
}
function echopage($page)
{
reset($page);
if (stringpos('http',$page[count($page)-3])==-1) {PrepPage($page);}
while ($val=each($page)) {
echo "$val[1]";
}
}
function preptodel($don)
{
global $ext;
echo "<form action=\"livredor.$ext\" method=\"GET\">";
echo "<p><input type=\"hidden\" name=\"action\" value=\"delete\"><font face=\"Arial\"><strong>Mot de passe </strong><input type=\"password\" size=\"20\"";
echo "name=\"mdpass\"></p>";
echo "<p><input type=\"submit\" name=\"B1\"";
echo "value=\"Détruire les messages cochés\"></p>";
$fic=file($don);
reset($fic);
$i=0;
while ($val=each($fic)) {
$i++;
echo "<p><input type=\"checkbox\" name=\"numligne[]\" value=\"$i\">$val[1]</p>";
}
echo "</form>";
}
function preptomod($don,$numligne)
{
global $ext;
echo "<form action=\"livredor.$ext\" method=\"GET\">";
echo "<p><input type=\"hidden\" name=\"numligne\" value=\"$numligne\"></p>";
echo "<p align=\"center\"><input type=\"hidden\" name=\"action\" value=\"edit\"><font face=\"Arial\"><strong>Mot de passe </strong><input type=\"password\" size=\"20\"";
echo "name=\"mdpass\">";
echo "<input type=\"submit\" name=\"B1\" value=\"Ok\"</p>";
echo "<p align=\"center\"><font ";
echo "face=\"Arial\" size=\"2\">Pour détruire plusieurs messages en une fois <a href=\"livredor.$ext?action=delete\">cliquez ici</a></font></p>";
echo "</form>";
}
function isin($i,$numligne,$edit)
{
if ($edit=="edit" ) {
if ($numligne==$i) {$found=true;}
}
else {
$found=false;
for ($j = 0; $j < count($numligne); $j++)
{
if ($numligne[$j]==$i) {$found=true;}
}
}
return $found;
}
function deletec($don,$numligne,$edit)
{
$fic=file($don);
$ficw=fopen($don,"w+" );
$nl=count($fic);
reset($fic);
$i=0;
while ($val=each($fic)) {
$i++;
if (!isin($i,$numligne,$edit)) {
$s=$val[1];
fwrite($ficw,$s);
}
else {
$last=($i==$nl);
echo "<p><font face=\"Arial\">Destruction de la ligne : <em>$val[1]</em></font></p>";
}
}
fclose($ficw);
if ($last) {
$fic=file($don);
$ficw=fopen($don,"w+" );
$nl=count($fic);
reset($fic);
$i=0;
while ($val=each($fic)) {
$i++;
$s=$val[1];
if ($i==$nl) {$s=trim($s);}
fwrite($ficw,$s);
}
fclose($ficw);
}
if ($edit!="edit" ) {
echo "<HR size=\"1\">";
echo "<BR>";
}
}
function getmodif($don,$numligne,$mdpass)
{
global $ext;
$fic=file($don);
reset($fic);
$i=0;
$s="";
while ( ($val=each($fic)) && ($s=="" ) ) {
$i++;
if ($i==$numligne) {
$s=$val[1];
}
}
$atab=explode(";",$s);
$nom=$atab[1];
$email=$atab[2];
$url=$atab[3];
$texte=$atab[4];
$ip=$atab[5];
$wmtexte=$atab[6];
echo "<form action=\"livredor.$ext\" method=\"GET\">";
echo "<p><input type=\"hidden\" name=\"action\" value=\"edit\">";
echo "<input type=\"hidden\" name=\"mdpass\" value=\"$mdpass\">";
echo "<input type=\"hidden\" name=\"numligne\" value=\"$numligne\"></p>";
echo "<p><font face=\"Arial\">nom :</font></p>";
echo "<p><input type=\"text\" size=\"75\" name=\"nom\" value=\"$nom\"></p>";
echo "<p><font face=\"Arial\">IP : $ip</font></p>";
echo "<p><font face=\"Arial\">email :</font></p>";
echo "<p><input type=\"text\" size=\"75\" name=\"email\" value=\"$email\"></p>";
echo "<p><font face=\"Arial\">url :</font></p>";
echo "<p><input type=\"text\" size=\"75\" name=\"url\" value=\"$url\"></p>";
echo "<p><font face=\"Arial\">Message d'origine à modifier :</font></p>";
echo "<p><textarea name=\"texte\" rows=\"8\" cols=\"80\">$texte</textarea></p>";
echo "<p><font face=\"Arial\">Réponse au message :</font></p>";
echo "<p><textarea name=\"wmtexte\" rows=\"8\" cols=\"80\">$wmtexte</textarea></p>";
echo "<p><input type=\"submit\" name=\"B1\" value=\"Valider les modifications\"></p>";
echo "</form>";
echo "<form action=\"livredor.$ext\" method=\"GET\">";
echo "<p><input type=\"hidden\" name=\"action\" value=\"delete\">";
echo "<input type=\"hidden\" name=\"edit\" value=\"edit\">";
echo "<input type=\"hidden\" name=\"mdpass\" value=\"$mdpass\">";
echo "<input type=\"hidden\" name=\"numligne\" value=\"$numligne\"></p>";
echo "<p><input type=\"submit\" name=\"B1\" value=\"Détruire le message\"></p>";
echo "</form>";
}
function modif($don,$numligne,$nom,$email,$url,$texte,$wmtexte)
{
$fic=file($don);
$ficw=fopen($don,"w+" );
$nl=count($fic);
reset($fic);
$i=0;
$found=false;
while (($val=each($fic)) && (!$found)) {
$i++;
$s=$val[1];
if ($i==$numligne) {
echo "<p><font face=\"Arial\">Modification de la ligne : <em>$val[1]</em></font></p>";
$atab=explode(";",$s);
$atab[1]=convert($nom,false,false);
$atab[2]=convert($email,false,false);
$atab[3]=convert($url,false,false);
$atab[4]=convert($texte,false,false);
$atab[6]=convert($wmtexte,true,true);
$s=implode(";",$atab);
echo "<p><font face=\"Arial\">--------> nouvelle ligne : <em>$s</em></font></p>";
//$found=true;
}
fwrite($ficw,$s);
}
fclose($ficw);
}
function NotYet($don,$texte,$testIP)
{
if (file_exists($don)) {
$texteloc=convert($texte,true,false);
$fic=file($don);
$nbm=count($fic);
reset($fic);
$yet=1;
while (($nbm>0) && ($val=each($fic)) && ($yet!=0)):
$ligne=$val[1];
$atab=explode(";",$ligne);
$letexte=$atab[4];
$yet=strcasecmp($letexte,$texteloc); //0 si ==
endwhile;
if (($nbm>4) && ($yet!=0) && ($testIP)) {
$ipcrt=getenv(REMOTE_ADDR);
if ($ipcrt=="" ) {$ipcrt="noip";} // pour pb iFrance
end($fic);
for ($i=1;$i<=4;$i++) {prev($fic);}
$sameip=0;
while (($val=each($fic)) && ($sameip==0)):
$ligne=$val[1];
$atab=split(";",$ligne,5);
$letexte=$atab[4];
if (stringpos(";",$letexte)>=0) {
$btab=explode(";",$letexte);
$ip=$btab[1];
}
else {$ip="";}
$sameip=strcasecmp($ip,$ipcrt); //0 si ==
endwhile;
$yet=$sameip;
}
}
else {$yet=1;}
return $yet;
}
function UpDBase($don)
{
if (file_exists($don)) {
$fic=file($don);
reset($fic);
$val=each($fic);
$s=$val[1];
$n=count(explode(";",$s));
if ($n<=5) {
$ficw=fopen($don,"w+" );
$nl=count($fic);
reset($fic);
$i=0;
while ($val=each($fic)) {
$i++;
$s=$val[1];
$sd=trim($s);
if (($sd==";;;;" )||($sd=="" )) {
$numligne[]=$i;
}
if ($i!=$nl) {
$s=$sd.";;;;;;;";
fwrite($ficw,"$s \r\n" );
}
else {
$s=$s.";;;;;;;";
fwrite($ficw,$s);
}
}
fclose($ficw);
if (count($numligne)!=0) {deletec($don,$numligne,"" );}
}
}
}
// ------------------------- MAIN
ignore_user_abort(true);
UpDBase($don);
if ($action=="" ) {$action="readall";}
if ($action=="read" ) {$res=$res1;}
if ($action=="readall" ) {$res=$res2;}
if ($action=="add" ) {$res=$res3;}
if ($action=="delete" ) {$res=$res2;}
if ($action=="edit" ) {$res=$res2;}
if ($action=="add" ) {
if (($nom!="" ) && ($texte!="" )) {
$atab=explode(":",$nom);
$ucnom=UpCaseAllSp($atab[0]);
$testIP=true;
if (($ucnom==UpCaseAllSp($webmaster)) || ($ucnom=="WEBMASTER" )) {
if ($atab[1]!=$pass) {
$nom="Visiteur";
echo "<body onload=\"alert ('Mot de passe webmaster omis ou erroné : votre nom est remplacé par Visiteur')\">";
}
else {
$nom=$atab[0];
$testIP=false;
}
}
$testIP=($testIP && $noflood);
if (NotYet($don,$texte,$testIP)!=0) {
$blocked=false;
if (file_exists($don)) {
$rc="\r\n";
$fic=file($don);
reset($fic);
$max=$nmes*$nmax;
if (count($fic)==$max) {
next($fic);
$ficw=fopen($don,"w+" );
while ($val=each($fic)) {
fwrite($ficw,$val[1]);
}
}
else { $ficw=fopen($don,"a+" ); }
}
else {
$rc="";
$ficw=fopen($don,"w+" );
}
$date=getdate();
$mday=conv0($date[mday]);
$mon=conv0($date[mon]);
$hour=conv0($date[hours]);
$min=conv0($date[minutes]);
$email=str_replace(' ','_',$email);
fwrite($ficw,$rc.$mday."/".$mon."/".$date[year]." ".$hour.
":".$min.";".
convert($nom,true,false).";".convert($email,true,false).";".convert($url,true,false).";".
convert($texte,true,false).";".getenv(REMOTE_ADDR).";;;;;;" );
fclose($ficw);
if ($mailme!="" ) {
$sujet="Livre d'Or (c) Fanatek";
mail($mailme,$sujet,$message);
}
}
else {
$blocked=true;
echo "<body bgcolor=\"#FFFFFF\">";
echo "<p align=\"center\"><font color=\"#FF0000\" size=\"4\" face=\"Arial\"><strong><u>Message interdit";
echo "</u></strong></font></p>";
echo "<p align=\"left\"><font ";
echo "size=\"2\" face=\"Arial\">Vous avez tenté d'écrire un message identique au précédent, ou bien vous avez déposé 5 messages consécutifs sur ce livre</font>";
echo "</font></p>";
echo "<BR>";
echo "<p align=\"center\"><font ";
echo "size=\"2\" face=\"Arial\">Merci de bien vouloir </font>";
echo "</font><a href=\"http://www.fisenne.be/fichiers/menu.php?page=livredor\">retourner au Livre d'or (Cliquez ici)</a></p>";
echo "<BR>";
}
}
if (!$blocked) {
if ($option=="readall" ) {$action="readall";}
else {produceHTML($res);}
}
}
if (($action=="delete" ) || ($action=="edit" )) {
echo "<body bgcolor=\"#FFFFFF\">";
echo "<p align=\"center\"><font color=\"#660099\" size=\"6\" face=\"Arial\"><strong><u>Administration";
echo " des messages</u></strong></font></p>";
echo "<p align=\"center\"><font color=\"#FF0000\" size=\"4\" face=\"Arial\"><strong><u>Espace";
echo " réservé au webmaster</u></strong></font></p>";
echo "<p align=\"center\"><font ";
echo "size=\"2\" face=\"Arial\">Merci de bien vouloir </font>";
echo "</font><a href=\"http://www.fisenne.be/fichiers/menu.php?page=livredor\">retourner au Livre d'or (Cliquez ici)</a></p>";
echo "<BR>";
echo "<BR>";
}
if ($action=="delete" ) {
if ($numligne=="" ) {
preptodel($don);
}
else {
if ($mdpass==$pass) {
echo "<p><font face=\"Arial\" color=\"#00F000\">Mot de passe correct</font></p>";
deletec($don,$numligne,$edit);
}
else {
echo "<p><font face=\"Arial\" color=\"#FF0000\">Accès impossible : mot de passe erroné</font></p>";
echo "<HR size=\"1\">";
echo "<BR>";
}
$numligne="";
if ($edit!="edit" ) {
preptodel($don);
}
}
}
if ($action=="edit" ) {
if ($mdpass=="" ) {
if ($numligne!="" ) {
preptomod($don,$numligne);
}
else {
echo "<p><font face=\"Arial\">Modification d'un message : Cliquer sur le numéro du message à modifier</font></p>";
}
}
else {
if ($mdpass==$pass) {
echo "<p><font face=\"Arial\" color=\"#00F000\">Mot de passe correct</font></p>";
if ($texte=="" ) {
getmodif($don,$numligne,$mdpass);
}
else {
modif($don,$numligne,$nom,$email,$url,$texte,$wmtexte);
$numligne="";
}
}
else {
echo "<p><font face=\"Arial\" color=\"#FF0000\">Accès impossible : mot de passe erroné</font></p>";
echo "<HR size=\"1\">";
echo "<BR>";
preptomod($don,$numligne);
}
}
}
if (($action=="delete" ) || ($action=="edit" )) {
}
if (($action=="read" ) || ($action=="readall" )) {
if ($action!="read" ) { $mots=""; }
$SearchResult=search($don,$mots);
$page=CreatePage($mots,$res,$SearchResult,$npag);
echopage($page);
}
?>
</body>
</html>