home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / Annotate.php < prev    next >
Encoding:
Text File  |  2001-07-02  |  2.2 KB  |  55 lines

  1. //**************************************
  2.     //     
  3.     // Name: Annotate
  4.     // Description:Very simple module to let
  5.     //     your users post their comments on your W
  6.     //     eb pages. Does not require SQL. Does req
  7.     //     uire a writeable directory. by Steve Yel
  8.     //     vington
  9.     // By: PHP Code Exchange
  10.     //**************************************
  11.     //     
  12.     
  13.     <?
  14.     /*
  15.     annotate.php3 
  16.     This is a module that can be placed on any php3 page to allow users to add
  17.     their comments. The comments are stored in a file in the current directory,
  18.     whose name is constructed by adding ".comment" to the calling page's name,
  19.     and merged into the calling page dynamically. (The calling page is not
  20.     modified.)
  21.     I wrote this because I wanted a simple way to add this functionality to my
  22.     pages without requiring that mySQL be available.
  23.     In the message input, blank lines are converted to paragraph tags. No other
  24.     conversions are applied. If you don't want your users to be able to input
  25.     html, uncomment the "strip_tags" line.
  26.     Note that the directory must be writable by the web server.
  27.     Put this module in some convenient location and then embed it in your pages
  28.     like so:
  29.     require("/some/full/path/annotate.php3");
  30.     or, relative to the docroot:
  31.     require($DOCUMENT_ROOT . "/relativepath/php3");
  32.     Steve Yelvington <steve@yelvington.com>
  33.     */
  34.     if ($message)
  35.         {
  36.         /* uncomment the next two lines to strip out html from input */
  37.         /* $name = strip_tags($name); */
  38.         /* $message = strip_tags($message); */
  39.         $message = ereg_replace("\r\n\r\n", "\n<P>", $message);
  40.         $date = date("l, F j Y, h:i a");
  41.         $message = "<B>$name </B> -- $date<P> $message <BR><HR>";
  42.         $fp = fopen (basename($PHP_SELF) . ".comment", "a");
  43.         fwrite ($fp, $message);
  44.         fclose ($fp);
  45.         }
  46.     @readfile(basename(($PHP_SELF . ".comment")));
  47.     ?>
  48.     <FORM method="post">
  49.     <b>Your name:</b><BR><INPUT name="name" type="text" size="55"><BR>
  50.     <b>Your comment:</b><BR><TEXTAREA name="message" rows=10 cols=55 wrap=virtual>
  51.     </TEXTAREA><BR>
  52.     <INPUT name="submit" type="submit" value="Post your comments">
  53.     </FORM>
  54.  
  55.