Php freeware sous conditions à lire dans le fichier lisezmoi.txt!!! // --------------- // web : http://fanatek.free.fr // email : fanatek@free.Fr // ----------------------------------------------------------------------- require("livredor.txt"); // IMPORTANT !!! changer le mot de passe ci-dessous !!! $pass = "umdppdul"; $webmaster = "webmaster"; $ext = "php"; // --------------------------------------------------------------------------- // -----------------!!! Ne rien toucher après cette ligne !!!----------------- // --------------------------------------------------------------------------- // -------- Début du script 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=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( "\\1", "\\1http://\\2", "\\1"); return nl2br(preg_replace($searcharray, $replacearray, stripslashes($text) )); } function TexteEncode($texte) { $texte=str_replace(".,",";",$texte); $texte=str_replace("|:-)","",$texte); $texte=str_replace("|:-(","",$texte); $texte=str_replace("|;-)","",$texte); $texte=str_replace("|;-)","",$texte); $texte=str_replace("|8-0","",$texte); $texte=str_replace("|:-p","",$texte); $texte=str_replace("|/-(","",$texte); $texte=str_replace("|/M/","",$texte); $texte=str_replace("|/B/","",$texte); $texte=str_replace("|/-@","",$texte); $texte=str_replace("|/I/","",$texte); $texte=str_replace("|/-/","",$texte); $texte=str_replace("|/+/","",$texte); $texte=str_replace("|/?/","",$texte); $texte=str_replace("|/!/","",$texte); $texte=str_replace("|00/","",$texte); $texte=str_replace("|01/","",$texte); $texte=str_replace("|02/","",$texte); $texte=str_replace("|03/","",$texte); $texte=str_replace("|04/","",$texte); $texte=str_replace("|05/","",$texte); $texte=str_replace("|06/","",$texte); $texte=str_replace("|07/","",$texte); $texte=str_replace("|08/","",$texte); $texte=str_replace("|09/","",$texte); $texte=str_replace("|10/","",$texte); $texte=str_replace("|11/","",$texte); $texte=str_replace("|12/","",$texte); $texte=str_replace("|13/","",$texte); $texte=str_replace("|14/","",$texte); $texte=str_replace("|15/","",$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[]="
"; $Ficw[]=""; $Ficw[]=""; $Ficw[]=""; $Ficw[]=""; $Ficw[]=""; $Ficw[]="
"; $Ficw[]="

"; if ($mot=="") { $adr="livredor.$ext?action=readall";} else {$adr="livredor.$ext?action=read&mots=$mots";} $fnpag=""; $fpagc=""; $Ficw[]=$fpagc."Page ".$nofb; $pgsuiv=$npag+1; $pgprec=$npag-1; if ($npag!=1) { $Ficw[]="".$fnpag."<<".$nof." "; } for ($i=1;$i<=$nbpage;$i++) { if ($i!=$npag) { $Ficw[]="".$fnpag.$i.$nof." "; } else { $Ficw[]=$fpagc."$i ".$nofb; } } if ($npag!=$nbpage) { $Ficw[]=" ".$fnpag.">>".$nof.""; } $Ficw[]="

"; $Ficw[]="
"; $Ficw[]="
"; $Ficw[]="
"; } else { $fnpag=""; $fpagc="";} if ($Idx!=0) { for ($i=0;$i<=$nn;$i++) { $Ficw[]=$Ficw[$Idx+$i]; $Ficw[$Idx+$i]=$s0; } $ficw[]=$fpagc."Page ".$nofb; $ficw[]="

"; $ficw[]=""; $ficw[]=""; $ficw[]=""; $ficw[]=""; $ficw[]="
"; } } function limit($s,$max) { $split=split(" ",$s); $nmots=count($split); $so=""; for ($i=0;$i<$nmots;$i++) { $url=($i>0) && ($split[$i-1]=="\"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[]="

". "Recherche de :"; $Ficw[]=$mots."

"; } $Ficw[]="

". "".count($SearchResult); if ($mots!="") {$Ficw[]=" messages trouvés

"; } else {$Ficw[]=" messages

"; } $nofb="
"; $nof=""; $fsign=""; $fnumm=""; $fnom=""; $fip=""; $furl=""; $ftxt=""; $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="livredor.$ext?action=edit&numligne=$num"; $Ficw[]="
"; $Ficw[]=""; $Ficw[]=""; $Ficw[]=""; $Ficw[]=""; $Ficw[]=""; $Ficw[]=""; if (strtoupper($url)=="HTTP://") {$url="";} $ucnom=UpCaseAllSp($nom); if (($ucnom==UpCaseAllSp($webmaster)) || ($ucnom=="WEBMASTER")) { $wmi=" "; $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[]=""; } else { $Ficw[]=""; } $Ficw[]=""; } else { if ($email!="") { $Ficw[]=""; } else { $Ficw[]=""; } } $Ficw[]=""; $Ficw[]=""; if ($wmtexte=="") { $Ficw[]=""; } else { $Ficw[]=""; } $Ficw[]=""; $Ficw[]="

".$fsign.$date.$nof."

"."".$fnumm.$num.$nof."

".$wmi." ".$fnom.$nom.$nofb."".$ip."".$wmi.$fnom.$nom.$nofb.$ip." ".$furl.$urltxt.$nofb."".$wmi." ".$fnom.$nom.$nofb."".$ip."".$wmi.$fnom.$nom.$nofb.$ip."
".$ftxt.$texte.$nof."".$ftxt.$texte."

$webmaster : ".$wmtexte.$nof."
"; $Ficw[]="
"; $Ficw[]="
"; } } 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"; echo "

Mot de passe

"; echo "

"; $fic=file($don); reset($fic); $i=0; while ($val=each($fic)) { $i++; echo "

$val[1]

"; } echo ""; } function preptomod($don,$numligne) { global $ext; echo "

Webmaster, veuillez entre le mot de passe d'administration de votre livre d'Or (voir logiciel de paramètrage)

"; echo "
"; echo "

"; echo "

Mot de passe "; echo ""; echo "

Pour détruire plusieurs messages en une fois cliquez ici

"; echo ""; } 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 "

Destruction de la ligne : $val[1]

"; } } 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 "
"; echo "
"; } } 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 "
"; echo "

"; echo ""; echo "

"; echo "

nom :

"; echo "

"; echo "

IP : $ip

"; echo "

email :

"; echo "

"; echo "

url :

"; echo "

"; echo "

Message d'origine à modifier :

"; echo "

"; echo "

Réponse au message :

"; echo "

"; echo "

"; echo "
"; echo "
"; echo "

"; echo ""; echo ""; echo "

"; echo "

"; echo "
"; } 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 "

Modification de la ligne : $val[1]

"; $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 "

--------> nouvelle ligne : $s

"; //$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 ""; } 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 ""; echo "

Message interdit - Forbidden message"; echo "

"; echo "

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"; echo "

"; echo "

You try to write the same message that the last one, or you wrote the last 5 messages on this guestbook"; echo "

"; echo "
"; echo "

retour au Livre d'Or (cliquer ici)

"; echo "

go back to the guestbook (clic here)

"; echo "
"; echo "
"; echo "

"; } } if (!$blocked) { if ($option=="readall") {$action="readall";} else {produceHTML($res);} } } if (($action=="delete") || ($action=="edit")) { echo ""; echo "

Administration"; echo " des messages

"; echo "

Version 5.0

"; echo "

Visiteur, cette page est réservée au webmaster de ce site, merci de bien vouloir "; echo "retourner au Livre d'Or (cliquer ici)

"; echo "

Visitor, this page is for the webmaster of this website only, please "; echo "go back to guestbook (clic here).

"; echo "
"; echo "
"; echo "
"; } if ($action=="delete") { if ($numligne=="") { preptodel($don); } else { if ($mdpass==$pass) { echo "

Mot de passe correct

"; deletec($don,$numligne,$edit); } else { echo "

Accès impossible : mot de passe erroné

"; echo "
"; echo "
"; } $numligne=""; if ($edit!="edit") { preptodel($don); } } } if ($action=="edit") { if ($mdpass=="") { if ($numligne!="") { preptomod($don,$numligne); } else { echo "

Modification d'un message : Cliquer sur le numéro du message à modifier

"; } } else { if ($mdpass==$pass) { echo "

Mot de passe correct

"; if ($texte=="") { getmodif($don,$numligne,$mdpass); } else { modif($don,$numligne,$nom,$email,$url,$texte,$wmtexte); $numligne=""; } } else { echo "

Accès impossible : mot de passe erroné

"; echo "
"; echo "
"; preptomod($don,$numligne); } } } if (($action=="delete") || ($action=="edit")) { echo "
"; echo "
"; echo "

"; } if (($action=="read") || ($action=="readall")) { if ($action!="read") { $mots=""; } $SearchResult=search($don,$mots); $page=CreatePage($mots,$res,$SearchResult,$npag); echopage($page); } ?>