Location: PHPKode > projects > FTLS PHP GuestBook > ftls-php-guestbook/guestbook.php
<HTML><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW">
<META HTTP-EQUIV="Content-Language" CONTENT="En">
<META NAME="Description" CONTENT="Guestbook made by FTLS (http://www.ftls.org)">
<META NAME="Keywords" CONTENT="none">
<META NAME="Author" CONTENT="FTLS (TYNDIUK Frederic,  http://www.ftls.org/)">
<META NAME="Cenerator" CONTENT="Emacs">
<META NAME="revisit-after" CONTENT="31 days">
<TITLE>FTLS's PHP Guestbook</TITLE></HEAD>
<BODY BGCOLOR="white">

<BR><BR><P ALIGN="Center"><FONT FACE="Arial, helvetica" SIZE="+2" COLOR="#336699"><STRONG><EM>Guestbook</EM></STRONG></FONT></P><BR>

<?php
// En: Begin PHP code  / Fr: debut code PHP
/******************************************************************************\
* PHP GuestBook                                Version 1.0                     *
* Copyright 2000 Frederic TYNDIUK (FTLS)       All Rights Reserved.            *
* E-Mail: hide@address.com                     Script License: GPL             *
* Created  02/28/2000                          Last Modified 02/28/2000        *
* Scripts Archive at:                          http://www.ftls.org/php/        *
*******************************************************************************/
// Necessary Variables:

$GUEST_FILE = "/Absolute/Path/to/guestbook.html";
	// En: Real path to guest book file.
	// Fr:  Chemain complet vers le fichier guestbook.html .

$MOTIF = "<!-- Value_Add_Comments -->";
	// En: Comment were should I had news messages.
	// Fr: Commantair indicant ou ajouter le nouveau message.

$REFERERS = array('essais.dom', 'www.essais.dom'); // wihout http://
	// En: URL(s) of serveur you can use this script.
	// Fr: Liste des serveurs a partir desquels on peut utiliser ce script.

$LANGUAGE = "EN";
	// En: Chose your langage.
	// Fr: $LANGUAGE = "Fr" pour avoir la confirmation en fran├žais.

// End  Necessary Variables section
/******************************************************************************/

function error($error_message) {
	echo $error_message."<BR>";
	exit;
}

function check_referer () {
	global $REFERERS, $HTTP_REFERER;
	if ($HTTP_REFERER != "")
		while (list($val, $ref) = each($REFERERS))
			if (preg_match("/^http:\/\/$ref/", $HTTP_REFERER))
				return;
	error("Unauthorized access to: $HTTP_REFERER"); 
}

check_referer();

if ($action == write) {

	$date = date("d/m/Y");

	$file_arry = file($GUEST_FILE); // or error("Can not open \$GUEST_FILE");

	$file = join ("", $file_arry);

	$name = htmlspecialchars($Name);
	$email = htmlspecialchars($EMail);
	$title = htmlspecialchars($Title);
	$comment = htmlspecialchars($Comment);

	$add = $MOTIF;
	$add .= "\n<DL><DT><A HREF=\"mailto:$email\">$name</A><DD><B>$title</B><BR>$comment<BR>Date : $date</DL>\n";

	$file = preg_replace("/$MOTIF/", $add, $file);

	$fp = fopen("$GUEST_FILE", "w"); //or error("Can not write \$GUEST_FILE");
	flock($fp, 1);
	fputs($fp, $file);                                                     
	flock($fp, 3);
	fclose($fp);

	if ($LANGUAGE == "FR") {
		echo "$add<BR>Merci d'avoit ajouter ces quelques mots &agrave; mon gestbook";
	} else {
		echo "$add<BR>Thanks to add somme words to my gestbook";
	}
}
?>


<BR><BR>
<CENTER>
	<B><A HREF="guestbook.html">Back / Retour</A></B>

<BR><BR>
	<FONT FACE="Arial" SIZE=-2>
	<EM>&copy Copyright 2000 <A HREF="http://www.ftls.org/">FTLS</A> (Tyndiuk Fr&eacute;d&eacute;ric). All rights reserved.
	<BR>FTLS's PHP Scripts Archive : <A HREF="http://www.ftls.org/php/">http://www.ftls.org/php/</A></EM></FONT>
</CENTER>
</BODY></HTML>
Return current item: FTLS PHP GuestBook