Modified by: Daniel.Schneider@tecfa.unige.ch Modified by: Olivier.Clavel@laposte.net 18/06/2003 Changed $PHP_SELF to $_SERVER['PHP_SELF'] (php4 compatible) This is a module that can be placed on any php3 page to allow users to add their comments. The comments are stored in a file in the current directory, whose name is constructed by adding ".comment" to the calling page's name, and merged into the calling page dynamically. (The calling page is not modified.) In the message input, blank lines are converted to paragraph tags. No other conversions are applied. If you don't want your users to be able to input html, uncomment the "strip_tags" line. Note that the file.comment must be writable by the web server !! Put this module in some convenient location and then embed it in your pages like so: require("/some/full/path/annotate.inc"); or, relative to the docroot: require($DOCUMENT_ROOT . "/relativepath/annotate.inc"); */ $secret = "zap"; // by default we append at the end $mode = "a"; // the module can\'t be called by itself if ( basename($_SERVER['PHP_SELF']) == "annotate.php") { echo "you can't call this file directly"; exit; } // if the password is correct we overwrite if (array_key_exists('password',$_POST)) $password = $_POST['password']; else $password=""; if ($password == $secret) { $mode = "w"; $fp = fopen (basename($_SERVER['PHP_SELF']) . ".comment", $mode); fwrite ($fp, $message); fclose ($fp); } // if there is a message we append it to a file called file.comment // make sure that file.comment belongs to the server id (or world writable) if (array_key_exists('message',$_POST))$message = $_POST['message']; else $message=""; if (array_key_exists('name',$_POST))$name = $_POST['name']; else $name=""; if ($message) { /* uncomment the next two lines to strip out html from input */ /* $name = strip_tags($name); */ /* $message = strip_tags($message); */ $name = StripSlashes($name); $message = StripSlashes($message); $message = ereg_replace("\r\n\r\n", "\n

", $message); $date = date("l, F j Y, H:i"); $message = "$name -- $date

$message


\n"; $filename = basename($_SERVER['PHP_SELF']) . ".comment"; if (is_file($filename)) { $fp = fopen ($filename, $mode); fwrite ($fp, $message); fclose ($fp); } else echo "

There is a problem with the file name: " . $filename . "

"; } @readfile(basename(($_SERVER['PHP_SELF'] . ".comment"))); ?>
Votre nom:

Votre commentaire:


Pour tuer les anciens commentaires rentrez le mot de passe: