home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / skeptic / bibliography / comment.cgi < prev    next >
Text File  |  2009-08-26  |  2KB  |  71 lines

  1. #!/usr/bin/perl
  2.  
  3. # $rcs = ' $Id: comment.cgi,v 1.3 1998/06/20 03:54:24 fitz Exp $ ' ;
  4.  
  5. unshift(@INC, "lib");
  6.  
  7. require 'config.pl';
  8. require 'bib.pl';
  9. require 'web.pl';
  10. require 'cgi-lib.pl';
  11.  
  12. &ReadParse();
  13. print "Content-type: text/html\n\n";
  14.  
  15. ($id = $ENV{PATH_INFO}) =~ s!.*/!!;
  16. if ($id)
  17. {
  18.     (%entry) = &db::read_entry($id);
  19.     $title = "Comment about bibliography entry "<STRONG>$entry{TITLE}</STRONG>":"
  20. }
  21.  
  22. if (%in)
  23. {
  24.     &error("You must enter your email address.")
  25.       unless $in{from};
  26.  
  27.     &error("Invalid email format: $in{from}")
  28.       unless $in{from} =~ /.*@.*/;
  29.  
  30.     &error("You must enter a comment.")
  31.       unless length($in{comment}) > 3;
  32.  
  33.     if ($id)
  34.     {
  35.         $link = "http://$ENV{SERVER_NAME}$bib::cgi/display.cgi/$id";
  36.     }
  37.  
  38.     if ($in{to} eq "admin")
  39.     {
  40.         $to = $bib::email{admin};
  41.     }
  42.     elsif ($in{to} eq "webmaster")
  43.     {
  44.         $to = $bib::email{webmaster};
  45.     }
  46.     else
  47.     {
  48.         &error("No TO address selected.");
  49.     }
  50.  
  51.     unless (&bib::sendmail("<COMMENT>\n$in{comment}\n</COMMENT>\n\n$link\n$entry{TITLE}\n",
  52.                            "To: $to",
  53.                            "From: $in{from} ($in{name})",
  54.                            "Subject: comment from SKEPTIC bibliography",))
  55.     {
  56.         &error("Sendmail error: $bib::error");
  57.     }
  58.  
  59.     &success("Thank you, your comments were sent to <B>$to</B>.<P>" .
  60.              ($id ? "Return to: <A HREF=\"$link\">$entry{TITLE}</A>" : ""));
  61. }
  62.  
  63. # Create the HTML page
  64. print &bib::template("basic.html",
  65.                      "TITLE", "Comment",
  66.                      "DATA",
  67.                      &bib::template("comment.html",
  68.                                     "TITLE", $title));
  69.  
  70. exit 0;
  71.