home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / messages / greymatter / gm-comments.cgi < prev    next >
Encoding:
Text File  |  2003-02-13  |  16.9 KB  |  559 lines

  1. #!/usr/bin/perl
  2.  
  3. # =============================
  4. # GREYMATTER - Comments Module
  5. # Weblog/Journal Software
  6. # version one point two
  7. # Copyright (c)2000 Noah Grey
  8. # http://noahgrey.com/greysoft/
  9. # =============================
  10.  
  11. # ***  Your possession of this software indicates that you agree to the terms   ***
  12. # *** specified under the "Copyright & Usage" heading in the "manual.txt" file. ***
  13.  
  14. use CGI::Carp qw(fatalsToBrowser);
  15.  
  16. require "gm-library.cgi";
  17.  
  18. read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
  19. @pairs = split(/&/, $input);
  20. foreach $pair (@pairs) {
  21.     ($name, $value) = split(/=/, $pair);
  22.     $name =~ tr/+/ /;
  23.     $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  24.     $value =~ tr/+/ /;
  25.     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  26.     $IN{$name} = $value;
  27. }
  28.  
  29. $userip = $ENV{'REMOTE_ADDR'};
  30.  
  31. &gm_readconfig;
  32. &gm_readtemplates;
  33. &gm_readcounter;
  34.  
  35. if (($IN{'newcommentbody'} eq "") && ($IN{'newcommentauthor'} eq "") && ($IN{'gmsearch'} eq "")) {
  36.     print "Content-type: text/html\n\n";
  37.     &gm_dangermouse("No valid information was given.");
  38. }
  39.  
  40. if ($IN{'gmsearch'} ne "") { &gm_searchresults; }
  41.  
  42. $IN{'newcommentbody'} =~ s/\|\*\|/\n/g;
  43.  
  44. $IN{'newcommentauthor'} =~ s/<(([^ >]|\n)*)>//g;
  45. $IN{'newcommentemail'} =~ s/<(([^ >]|\n)*)>//g;
  46. $IN{'newcommenthomepage'} =~ s/<(([^ >]|\n)*)>//g;
  47.  
  48. $IN{'newcommentauthor'} =~ s/{/(/g;
  49. $IN{'newcommentemail'} =~ s/{/(/g;
  50. $IN{'newcommenthomepage'} =~ s/{/(/g;
  51. $IN{'newcommentbody'} =~ s/{/(/g;
  52. $IN{'newcommentauthor'} =~ s/}/)/g;
  53. $IN{'newcommentemail'} =~ s/}/)/g;
  54. $IN{'newcommenthomepage'} =~ s/}/)/g;
  55. $IN{'newcommentbody'} =~ s/}/)/g;
  56. $IN{'newcommentauthor'} =~ s/{/(/g;
  57. $IN{'newcommentemail'} =~ s/{/(/g;
  58. $IN{'newcommenthomepage'} =~ s/{/(/g;
  59. $IN{'newcommentbody'} =~ s/{/(/g;
  60. $IN{'newcommentauthor'} =~ s/}/)/g;
  61. $IN{'newcommentemail'} =~ s/}/)/g;
  62. $IN{'newcommenthomepage'} =~ s/}/)/g;
  63. $IN{'newcommentbody'} =~ s/}/)/g;
  64.  
  65. $IN{'newcommentauthor'} =~ s/\|//g;
  66. $IN{'newcommentemail'} =~ s/\|//g;
  67. $IN{'newcommenthomepage'} =~ s/\|//g;
  68. $IN{'newcommentbody'} =~ s/\|//g;
  69.  
  70. $IN{'newcommentauthor'} =~ s/"/\"/g;
  71. $IN{'newcommentemail'} =~ s/"/\"/g;
  72. $IN{'newcommenthomepage'} =~ s/"/\"/g;
  73. $IN{'newcommentbody'} =~ s/"/\"/g;
  74.  
  75. $IN{'newcommentauthor'} =~ s/^\s+//;
  76. $IN{'newcommentauthor'} =~ s/\s+$//;
  77. $IN{'newcommentemail'} =~ s/^\s+//;
  78. $IN{'newcommentemail'} =~ s/\s+$//;
  79. $IN{'newcommenthomepage'} =~ s/^\s+//;
  80. $IN{'newcommenthomepage'} =~ s/\s+$//;
  81. $IN{'newcommentbody'} =~ s/^\s+//;
  82. $IN{'newcommentbody'} =~ s/\s+$//;
  83.  
  84. $IN{'newcommentauthor'} =~ s/\n//g;
  85. $IN{'newcommentemail'} =~ s/\n//g;
  86. $IN{'newcommenthomepage'} =~ s/\n//g;
  87. $IN{'newcommentauthor'} =~ s/\r//g;
  88. $IN{'newcommentemail'} =~ s/\r//g;
  89. $IN{'newcommenthomepage'} =~ s/\r//g;
  90.  
  91. $IN{'newcommentbody'} =~ s/\r//g;
  92. $IN{'newcommentbody'} =~ s/\n/\|\*\|/g;
  93. $IN{'newcommentbody'} =~ s/(\|\*\|\|\*\|){2,}/\|\*\|\|\*\|/g;
  94. $IN{'newcommentbody'} =~ s/\|\*\|\|\*\|\|\*\|/\|\*\|\|\*\|/g;
  95.  
  96. $temphomepageprefix = substr($IN{'newcommenthomepage'}, 0, 7);
  97. if ($temphomepageprefix ne "http://") { $IN{'newcommenthomepage'} = "http://$IN{'newcommenthomepage'}"; }
  98.  
  99. if ($IN{'newcommenthomepage'} eq "http://") { $IN{'newcommenthomepage'} = ""; }
  100.  
  101. &gm_commentbancheck;
  102. &gm_phphackcheck;
  103.  
  104. $newcommententrynumberpadded = sprintf ("%8d", $IN{'newcommententrynumber'});
  105. $newcommententrynumberpadded =~ tr/ /0/;
  106.  
  107. open (FUNNYFEET, "$EntriesPath/$newcommententrynumberpadded.cgi") || &gm_dangermouse("Can't open $EntriesPath/$newcommententrynumberpadded.cgi.  Please make sure your paths are configured correctly and that your entries/archives directory is CHMODed to 777.");
  108. @entrylines = <FUNNYFEET>;
  109. close (FUNNYFEET);
  110.  
  111. $gmcounter = 0;
  112.  
  113. foreach (@entrylines) {
  114.     chomp ($entrylines[$gmcounter]);
  115.     $gmcounter++;
  116. }
  117.  
  118. ($thisentrynumber, $thisentryauthor, $thisentrysubject, $thisentryweekdaynumber, $thisentrymonth, $thisentryday, $thisentryyearyear, $thisentryhour, $thisentryminute, $thisentrysecond, $thisentryampm, $thisentrypositivekarma, $thisentrynegativekarma, $thisentrycommentsnumber, $thisentryallowkarma, $thisentryallowcomments, $thisentryopenstatus) = split (/\|/, $entrylines[0]);
  119.  
  120. &gm_allowedcheck;
  121. &gm_blankcheck;
  122.  
  123. if ($IN{'gmpostpreview'} ne "") {
  124.     &gm_previewcomment;
  125. } else {
  126.     &gm_addcomment;
  127.     &gm_freshenaftercomment;
  128. }
  129.  
  130. # -------------
  131. # check for ban
  132. # -------------
  133.  
  134. sub gm_commentbancheck {
  135.  
  136. open (FUNNYFEET, "gm-banlist.cgi") || &gm_dangermouse("Can't read the banlist file.  Please make sure that gm-banlist.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files.");
  137. @gmbanlist = <FUNNYFEET>;
  138. close (FUNNYFEET);
  139.  
  140. if ($gmbanlist[0] ne "") {
  141.     foreach $gmbanlistline (@gmbanlist) {
  142.         chomp ($gmbanlistline);
  143.         ($checkthisip, $checkthisiphost, $checkthisperson) = split (/\|/, $gmbanlistline);
  144.         if ($userip =~ m/$checkthisip/i) {
  145.  
  146.             if (($keeplog eq "yes") && ($logkarmaandcomments eq "yes")) {
  147.                 &date;
  148.                 open (FUNNYFEET, ">>gm-cplog.cgi") || &gm_dangermouse("Can't write to the control panel log.  Please make sure that gm-cplog.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files.");
  149.                 print FUNNYFEET "<FONT SIZE=1>[$basedate] [$userip]</FONT> <FONT COLOR=\"#FF0000\"><B>A banned IP ($checkthisip/$checkthisiphost";
  150.                 if ($checkthisperson ne "") { print FUNNYFEET ", \"$checkthisperson\""; }
  151.                 if ($IN{'gmsearch'} ne "") {
  152.                     print FUNNYFEET ") attempted to search for \"$IN{'gmsearch'}\"</FONT>\n";
  153.                 } else {
  154.                     print FUNNYFEET ") attempted to post a comment to entry #$IN{'newcommententrynumber'}</B> ($IN{'newcommentauthor'}: $IN{'newcommentbody'})</FONT>\n";
  155.                 }
  156.                 close (FUNNYFEET);
  157.             }
  158.  
  159. print "Content-type: text/html\n\n";
  160.  
  161. print<<GMBANNEDNOTICE;
  162.  
  163. $gmheadtag
  164.  
  165. $gmframetop
  166. You have been banned from using this site.<BR>(IP: $userip)
  167. $gmframebottom
  168.  
  169. </BODY>
  170. </HTML>
  171.  
  172. GMBANNEDNOTICE
  173.  
  174. exit;
  175.  
  176.         }
  177.     }
  178. }
  179.  
  180. }
  181.  
  182. # -------------------------------
  183. # check if comments can be posted
  184. # -------------------------------
  185.  
  186. sub gm_allowedcheck {
  187.  
  188. if (($posttoarchives eq "no") && ($thisentrynumber <= $newarchivenumber)) {
  189.  
  190. if (($keeplog eq "yes") && ($logkarmaandcomments eq "yes")) {
  191.     &date;
  192.     open (FUNNYFEET, ">>gm-cplog.cgi") || &gm_dangermouse("Can't write to the control panel log.  Please make sure that gm-cplog.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files.");
  193.     print FUNNYFEET "<FONT SIZE=1>[$basedate] [$userip]</FONT> A comment was blocked from being added to archived entry #$IN{'newcommententrynumber'} ($IN{'newcommentauthor'}: $IN{'newcommentbody'})\n";
  194.     close (FUNNYFEET);
  195. }
  196.  
  197. print "Content-type: text/html\n\n";
  198.  
  199. print<<GMARCHIVEDISALLOWEDNOTICE;
  200.  
  201. $gmheadtag
  202.  
  203. $gmframetop
  204. SorryĆ¹comments cannot be posted to archived entries.  Please use your browser's Back button to return.
  205. $gmframebottom
  206.  
  207. </BODY>
  208. </HTML>
  209.  
  210. GMARCHIVEDISALLOWEDNOTICE
  211.  
  212. exit;
  213.  
  214. }
  215.  
  216. if (($thisentryallowcomments eq "no") || ($generateentrypages eq "no") || ($thisentryopenstatus eq "closed") || ($allowkarmaorcomments eq "karma") || ($allowkarmaorcomments eq "neither")) {
  217.  
  218. if (($keeplog eq "yes") && ($logkarmaandcomments eq "yes")) {
  219.     &date;
  220.     open (FUNNYFEET, ">>gm-cplog.cgi") || &gm_dangermouse("Can't write to the control panel log.  Please make sure that gm-cplog.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files.");
  221.     print FUNNYFEET "<FONT SIZE=1>[$basedate] [$userip]</FONT> A comment was blocked from being added to entry #$IN{'newcommententrynumber'} ($IN{'newcommentauthor'}: $IN{'newcommentbody'})\n";
  222.     close (FUNNYFEET);
  223. }
  224.  
  225. print "Content-type: text/html\n\n";
  226.  
  227. print<<GMCOMMENTBLOCKEDNOTICE;
  228.  
  229. $gmheadtag
  230.  
  231. $gmframetop
  232. SorryĆ¹comments cannot be posted to this entry.  Please use your browser's Back button to return.
  233. $gmframebottom
  234.  
  235. </BODY>
  236. </HTML>
  237.  
  238. GMCOMMENTBLOCKEDNOTICE
  239.  
  240. exit;
  241.  
  242. }
  243.  
  244. }
  245.  
  246. # ------------------------------
  247. # check if subj or body is blank
  248. # ------------------------------
  249.  
  250. sub gm_blankcheck {
  251.  
  252. if (($IN{'newcommentauthor'} eq "") || ($IN{'newcommentbody'} eq "")) {
  253.  
  254. print "Content-type: text/html\n\n";
  255.  
  256. print<<GMBLANKNOTICE;
  257.  
  258. $gmheadtag
  259.  
  260. $gmframetop
  261. You left either your name or your comments blank.  Please use your browser's Back button to return.
  262. $gmframebottom
  263.  
  264. </BODY>
  265. </HTML>
  266.  
  267. GMBLANKNOTICE
  268.  
  269. exit;
  270.  
  271. }
  272.  
  273. }
  274.  
  275. # ------------------------------
  276. # preview comment before posting
  277. # ------------------------------
  278.  
  279. sub gm_previewcomment {
  280.  
  281. &date;
  282.  
  283. if ($thisentrymorebody ne "") {
  284.     if ($thisentrynumber <= $newarchivenumber) {
  285.         $commentpreviewpage = $gmmorearchiveentrypagetemplate;
  286.     } else {
  287.         $commentpreviewpage = $gmmoreentrypagetemplate;
  288.     }
  289. } else {
  290.     if ($thisentrynumber <= $newarchivenumber) {
  291.         $commentpreviewpage = $gmarchiveentrypagetemplate;
  292.     } else {
  293.         $commentpreviewpage = $gmentrypagetemplate;
  294.     }
  295. }
  296.  
  297. &gm_getentryvariables($IN{'newcommententrynumber'});
  298.  
  299. $thisentrycomments = "";
  300. $thisentrycommentsnumber = 1;
  301. $thispreviewcounter = $thisentrycommentsnumber + 3;
  302.  
  303. $IN{'newcommentauthor'} =~ s/\"/"/g;
  304. $IN{'newcommentemail'} =~ s/\"/"/g;
  305. $IN{'newcommenthomepage'} =~ s/\"/"/g;
  306. $IN{'newcommentbody'} =~ s/\"/"/g;
  307. $IN{'newcommentbody'} =~ s/\|\*\|/\n/g;
  308.  
  309. $entrylines[$thispreviewcounter] = "$IN{'newcommentauthor'}|$userip|$IN{'newcommentemail'}|$IN{'newcommenthomepage'}|$wday|$mon|$mday|$JSYear|$hour|$min|$sec|$AMPM|$IN{'newcommentbody'}";
  310.  
  311. $IN{'newcommentauthor'} =~ s/"/\"/g;
  312. $IN{'newcommentemail'} =~ s/"/\"/g;
  313. $IN{'newcommenthomepage'} =~ s/"/\"/g;
  314. $IN{'newcommentbody'} =~ s/"/\"/g;
  315. $IN{'newcommentbody'} =~ s/\n/\|\*\|/g;
  316.  
  317. $previewcommentauthor = $IN{'newcommentauthor'};
  318. $previewcommentemail = $IN{'newcommentemail'};
  319. $previewcommenthomepage = $IN{'newcommenthomepage'};
  320. $previewcommentbody = $IN{'newcommentbody'};
  321.  
  322. &gm_collatecomments;
  323.  
  324. $commentpreviewpage =~ s/{{commentdivider}}/$gmcommentpreviewdividertemplate/gi;
  325. $commentpreviewpage =~ s/{{entrycommentsform}}/$gmcommentpreviewformtemplate/gi;
  326. $commentpreviewpage =~ s/{{previewcommentauthor}}/$previewcommentauthor/gi;
  327. $commentpreviewpage =~ s/{{previewcommentemail}}/$previewcommentemail/gi;
  328. $commentpreviewpage =~ s/{{previewcommenthomepage}}/$previewcommenthomepage/gi;
  329. $commentpreviewpage =~ s/{{previewcommentbody}}/$previewcommentbody/gi;
  330.  
  331. &gm_formatentry($commentpreviewpage);
  332.  
  333. print "Content-type: text/html\n\n";
  334.  
  335. print<<PREVIEWCOMMENT;
  336.  
  337. $entryreturn
  338.  
  339. PREVIEWCOMMENT
  340.  
  341. exit;
  342.  
  343. }
  344.  
  345. # --------------------------
  346. # so add the comment already
  347. # --------------------------
  348.  
  349. sub gm_addcomment {
  350.  
  351. $thisentrycommentsnumber++;
  352.  
  353. $entrylines[0] = "$thisentrynumber|$thisentryauthor|$thisentrysubject|$thisentryweekdaynumber|$thisentrymonth|$thisentryday|$thisentryyearyear|$thisentryhour|$thisentryminute|$thisentrysecond|$thisentryampm|$thisentrypositivekarma|$thisentrynegativekarma|$thisentrycommentsnumber|$thisentryallowkarma|$thisentryallowcomments|$thisentryopenstatus";
  354.  
  355. $gmcounter = 0;
  356.  
  357. &date;
  358.  
  359. open (FUNNYFEET, ">$EntriesPath/$newcommententrynumberpadded.cgi") || &gm_dangermouse("Can't write to $EntriesPath/$newcommententrynumberpadded.cgi.  Please make sure that your paths are configured correctly and that your entries/archives directory is CHMODed to 777.");
  360. foreach $entrynewline (@entrylines) { print FUNNYFEET "$entrynewline\n"; }
  361. print FUNNYFEET "$IN{'newcommentauthor'}|$userip|$IN{'newcommentemail'}|$IN{'newcommenthomepage'}|$wday|$mon|$mday|$JSYear|$hour|$min|$sec|$AMPM|$IN{'newcommentbody'}\n";
  362. close (FUNNYFEET);
  363.  
  364. }
  365.  
  366. # ------------------------
  367. # primp, preen, take a bow
  368. # ------------------------
  369.  
  370. sub gm_freshenaftercomment {
  371.  
  372. $newalltimecommentstotalnumber++;
  373. &gm_writecounter;
  374.  
  375. $aftermath = "$EntriesWebPath/$newcommententrynumberpadded.$entrysuffix#comments";
  376.  
  377. &gm_getentryvariables($IN{'newcommententrynumber'});
  378.  
  379. if ($thisentrymorebody ne "") {
  380.     if ($thisentrynumber <= $newarchivenumber) {
  381.         &gm_formatentry($gmmorearchiveentrypagetemplate);
  382.     } else {
  383.         &gm_formatentry($gmmoreentrypagetemplate);
  384.     }
  385. } else {
  386.     if ($thisentrynumber <= $newarchivenumber) {
  387.         &gm_formatentry($gmarchiveentrypagetemplate);
  388.     } else {
  389.         &gm_formatentry($gmentrypagetemplate);
  390.     }
  391. }
  392.  
  393. open (THISFILE, ">$EntriesPath/$thisentrynumberpadded.$entrysuffix") || &gm_dangermouse("Can't write to $EntriesPath/thisentrynumberpadded.$entrysuffix.  Please make sure that your paths are configured correctly and that your entries/archives directory is CHMODed to 777.");;
  394. print THISFILE $entryreturn;
  395. close (THISFILE);
  396.  
  397. if ($thisentrynumber <= $newarchivenumber) {
  398.     &gm_readcounter;
  399.     $stoppednumber = $newarchivenumber;
  400.     do { &gm_generatearchive($stoppednumber); } until $stoppednumber <= 1;
  401. } else {
  402.     &gm_generatemainindex;
  403. }
  404.  
  405. &gm_readconfig;
  406.  
  407. if (($NotifyForStatus eq "comments") || ($NotifyForStatus eq "both")) {
  408. if ($NotifyEmail ne "") {
  409.  
  410. $formattedcomment = $IN{'newcommentbody'};
  411. $formattedcomment =~ s/\|\*\|/\n/g;
  412. $sendithere = "$mailprog -t";
  413.  
  414. @sendestinations = split (/;/, $NotifyEmail);
  415.  
  416. &gm_getentryvariables($IN{'newcommententrynumber'});
  417.  
  418. foreach $destinationow (@sendestinations) {
  419.  
  420. open (MAIL, "|$sendithere") || &gm_dangermouse("Can't open the mail program at $mailprog.  Please make sure you have this configured correctly.");
  421. print MAIL <<__MAILNOTIFY__;
  422. To: $destinationow
  423. From: Greymatter <$destinationow>
  424. Subject: [Greymatter] Notice: Comment Posted
  425.  
  426. A comment has just been posted to entry #$IN{'newcommententrynumber'} ($thisentrysubject).
  427.  
  428. Name: $IN{'newcommentauthor'} (IP: $userip)
  429. E-Mail: $IN{'newcommentemail'}
  430. Homepage: $IN{'newcommenthomepage'}
  431.  
  432. Comments: $formattedcomment
  433.  
  434. Posted to: $aftermath
  435.  
  436. -----
  437. Greymatter $gmversion
  438. http://noahgrey.com/greysoft/
  439.  
  440. __MAILNOTIFY__
  441.  
  442. close(MAIL);
  443.  
  444. }
  445.  
  446. }
  447. }
  448.  
  449. if (($keeplog eq "yes") && ($logkarmaandcomments eq "yes")) {
  450.     &date;
  451.     open (FUNNYFEET, ">>gm-cplog.cgi") || &gm_dangermouse("Can't write to the control panel log.  Please make sure that gm-cplog.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files.");
  452.     print FUNNYFEET "<FONT SIZE=1>[$basedate] [$userip]</FONT> <I>$IN{'newcommentauthor'} added a comment to entry #$IN{'newcommententrynumber'} ($thisentrysubject)</I>\n";
  453.     close (FUNNYFEET);
  454. }
  455.  
  456. print "Location: $aftermath\n\n";
  457.  
  458. }
  459.  
  460. # --------------
  461. # search results
  462. # --------------
  463.  
  464. sub gm_searchresults {
  465.  
  466. $searchmatchescount = 0;
  467. $searchresultbody = "";
  468.  
  469. $IN{'gmsearch'} =~ s/\|//g;
  470.  
  471. &gm_readconfig;
  472. &gm_readcounter;
  473. &gm_readtemplates;
  474.  
  475. $countfromhere = $newentrynumber;
  476.  
  477. do {
  478.  
  479.     &gm_getentryvariables($countfromhere);
  480.  
  481.     unless ($thisentryopenstatus eq "closed") {
  482.  
  483.         if (($thisentrysubject =~ m/$IN{'gmsearch'}/i) || ($thisentryauthor =~ m/$IN{'gmsearch'}/i) || ($thisentrymainbody =~ m/$IN{'gmsearch'}/i) || ($thisentrymorebody =~ m/$IN{'gmsearch'}/i) || ($thisentrycomments =~ m/$IN{'gmsearch'}/i)) {
  484.  
  485.             &gm_formatentry($gmsearchresultsentrytemplate);
  486.             $searchresultbody .= $entryreturn;
  487.             $searchmatchescount++;
  488.  
  489.         }
  490.  
  491.     }
  492.  
  493.     $countfromhere--;
  494.  
  495. } until $countfromhere eq "0";
  496.  
  497. $searchpage = $gmsearchresultspagetemplate;
  498. $searchpage =~ s/{{searchterm}}/$IN{'gmsearch'}/g;
  499. $searchpage =~ s/{{searchmatches}}/$searchmatchescount/g;
  500. $searchpage =~ s/{{searchresults}}/$searchresultbody/g;
  501. &gm_formatentry($searchpage);
  502.  
  503. print "Content-type: text/html\n\n";
  504.  
  505. print<<SHOWSEARCHRESULTS;
  506.  
  507. $entryreturn
  508.  
  509. SHOWSEARCHRESULTS
  510.  
  511. if (($keeplog eq "yes") && ($logkarmaandcomments eq "yes")) {
  512.     &date;
  513.     open (FUNNYFEET, ">>gm-cplog.cgi") || &gm_dangermouse("Can't write to the control panel log.  Please make sure that gm-cplog.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files.");
  514.     print FUNNYFEET "<FONT SIZE=1>[$basedate] [$userip]</FONT> <I>A search was performed for \"$IN{'gmsearch'}\" ($searchmatchescount matches)</I>\n";
  515.     close (FUNNYFEET);
  516. }
  517.  
  518. exit;
  519.  
  520. #### script kiddie check added by linear 2/10/2003 
  521. # ------------------------------ 
  522. # check if there's a lame PHP tag attempt 
  523. # ------------------------------ 
  524.  
  525. sub gm_phphackcheck { 
  526.  
  527. if ( ($IN{'newcommentauthor'} =~ /<\?/ ) || ($IN{'newcommentbody'} =~ /<\?/ ) || ($IN{'newcommentemail'} =~ /<\?/ ) || ($IN{'newcommenthomepage'} =~ /<\?/ )) { 
  528. &date; 
  529. print "Content-type: text/html\n\n"; 
  530.  
  531. print<<GMHACKNOTICE; 
  532.  
  533. $gmheadtag 
  534.  
  535. $gmframetop 
  536. We don't take kindly to that sort of activity here. Your attempt to break the script has been logged and the administrators have been notified. 
  537. <br>[$basedate] [$userip] 
  538.  
  539. $gmframebottom 
  540.  
  541. </BODY> 
  542. </HTML> 
  543.  
  544. GMHACKNOTICE
  545. $keepphphackloglog = 1; # set to 0 if you just don't care 
  546.  
  547. if ($keepphphacklog) { 
  548.    open (BOZO, ">>gm-phphacklog.cgi") || &gm_dangermouse("Can't write to the dumbass h4x0r log.  Please make sure that gm-dumbasslog.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files."); 
  549.    print BOZO "[$basedate] [$userip] A hacker was blocked from a PHP attack against archived entry #$IN{'newcommententrynumber'} ($IN{'newcommentauthor'}: $IN{'newcommentbody'})\n"; 
  550.    close (BOZO); 
  551.  
  552.  
  553. exit; 
  554.  
  555. }
  556. }
  557.