home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / messages / greymatter / gm-library.cgi < prev    next >
Encoding:
Text File  |  2003-02-10  |  160.4 KB  |  3,728 lines

  1. ## Greymatter common subroutine library
  2.  
  3. # ===============================
  4. # GREYMATTER - Subroutine Library
  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. # Patch for weekdayshort and monthwordshort variables
  15. # provided by Rae (rae@tnir.org)
  16. # c&p'ed in by domesticat
  17. # (gmstuff@domesticat.net)
  18.  
  19. # -----------------
  20. # program variables
  21. # -----------------
  22.  
  23. $gmversion = "1.21d";
  24.  
  25. $gmfonttag = qq(<FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2>);
  26.  
  27. $gmheadtag = qq#<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  28. <HTML>
  29. <HEAD>
  30. <TITLE>Greymatter</TITLE>
  31. <META NAME="Generator" CONTENT="Greymatter $gmversion">
  32.  
  33. <STYLE TYPE="text/css">
  34. <!--
  35. .copynotice { text-decoration: none }
  36. .copynotice:hover { color: \#FFFFFF }
  37. .button { font-family: verdana, arial, helvetica; font-size: 13px; background: \#FFFFD0; border-color: \#000000 }
  38. .textinput { font-family: verdana, arial, helvetica; font-size: 13px; background-color: \#EEEEFF; border-color: \#000000 }
  39. .selectlist { font-family: verdana, arial, helvetica; font-size: 13px; background-color: \#EEEEFF; border-color: \#000000 }
  40. BODY { scrollbar-face-color: \#A0C0E0; scrollbar-shadow-color: \#000000; scrollbar-highlight-color: \#000000; scrollbar-3dlight-color: \#000000; scrollbar-darkshadow-color: \#000000; scrollbar-track-color: \#000000; scrollbar-arrow-color: \#000000 }
  41. input { font-family: verdana, arial, helvetica; font-size: 13px }
  42. textarea { font-size: 13px; font-family: verdana, arial, helvetica; background-color: \#EEEEFF; border-color: \#000000 }
  43. -->
  44. </STYLE>
  45.  
  46. <STYLE TYPE="text/css" MEDIA="all">
  47. <!--
  48. .button { width: 240; height: 26 }
  49. -->
  50. </STYLE>
  51.  
  52. <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
  53. <!--//
  54.  
  55. // Copyright (c) 1996-1997 Athenia Associates.
  56. // http://www.webreference.com/js/
  57. // License is granted if and only if this entire
  58. // copyright notice is included. By Tomer Shiran.
  59.  
  60. function setCookie(name, value, expires, path, domain, secure) {
  61. var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
  62. document.cookie = curCookie;
  63. }
  64.  
  65. function getCookie(name) {
  66. var prefix = name + "=";
  67. var nullstring = "";
  68. var cookieStartIndex = document.cookie.indexOf(prefix);
  69. if (cookieStartIndex == -1)
  70. return nullstring;
  71. var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
  72. if (cookieEndIndex == -1)
  73. cookieEndIndex = document.cookie.length;
  74. return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
  75. }
  76.  
  77. function deleteCookie(name, path, domain) {
  78. if (getCookie(name)) {
  79. document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"
  80. };
  81. }
  82.  
  83. function fixDate(date) {
  84. var base = new Date(0);
  85. var skew = base.getTime();
  86. if (skew > 0)
  87. date.setTime(date.getTime() - skew);
  88. }
  89. #;
  90.  
  91. $gmheadtagtwo = $gmheadtag;
  92.  
  93. $gmheadtag .= qq#
  94. //-->
  95. </SCRIPT>
  96.  
  97. </HEAD>
  98.  
  99. <BODY BGCOLOR=\"\#8080B0\" TEXT=\"\#000000\" LINK=\"\#000000\" VLINK=\"\#000000\" ALINK=\"\#000000\" MARGIN=\"10"\ TOPMARGIN=\"10\" LEFTMARGIN=\"10\" RIGHTMARGIN=\"10\" BOTTOMMARGIN=\"10\" MARGINHEIGHT=\"10\" MARGINWIDTH=\"10\">
  100. <BASE TARGET="_top">#;
  101.  
  102. $gmheadtagtwo .= qq#
  103. function gmshortcutkeys() {
  104.     if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == "Microsoft Internet Explorer")) {
  105.         if (event.ctrlKey != true) return;
  106.         gmselection = document.selection.createRange().text;
  107.         if (window.event.keyCode == 1) {
  108.             gminsertlink = prompt("What do you want to link to?", "http://")
  109.             if (gminsertlink == null) return;
  110.             document.selection.createRange().text = '<a href="' + gminsertlink + '">' + gmselection + '</a>';
  111.             return;
  112.         }
  113.         if (window.event.keyCode == 2) {
  114.             document.selection.createRange().text = '<b>' + gmselection + '</b>';
  115.             return;
  116.         }
  117.         if (window.event.keyCode == 9) {
  118.             document.selection.createRange().text = '<i>' + gmselection + '</i>';
  119.             return;
  120.         }
  121.         if (window.event.keyCode == 21) {
  122.             document.selection.createRange().text = '<u>' + gmselection + '</u>';
  123.             return;
  124.         }
  125.     }
  126. }
  127.  
  128. //-->
  129. </SCRIPT>
  130.  
  131. </HEAD>
  132.  
  133. <BODY BGCOLOR="\#8080B0" TEXT="\#000000" LINK="\#000000" VLINK="\#000000" ALINK="\#000000" MARGIN=10 TOPMARGIN=10 LEFTMARGIN=10 RIGHTMARGIN=10 BOTTOMMARGIN=10 MARGINHEIGHT=10 MARGINWIDTH=10 onKeyPress="gmshortcutkeys();">
  134. <BASE TARGET="_top">#;
  135.  
  136. $gmframetop = qq(<table border=0 cellpadding=0 cellspacing=0 width=100% height=100%><tr><td valign=middle align=center><table border=0 cellpadding=0 cellspacing=0><tr><td><p align=left>$gmfonttag<font color=#c0c0e0 size=4><b>greymatter</b></font></font></p><table border=0 cellpadding=2 cellspacing=0 bgcolor="#000000"><tr><td><table border=0 cellpadding=10 cellspacing=0 bgcolor="#ffffff"><tr><td valign=\"middle\" align=\"center\">$gmfonttag);
  137. $gmframetoptwo = qq(<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% HEIGHT=100%><TR><TD VALIGN=MIDDLE ALIGN=CENTER><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#000000"><TR><TD><TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0 BGCOLOR="#FFFFFF"><TR><TD VALIGN=MIDDLE ALIGN=CENTER>$gmfonttag);
  138. $gmframebottom = qq(</font></TD></TR></TABLE></TD></TR></TABLE><P ALIGN=RIGHT><FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=1><A HREF="http://noahgrey.com/greysoft/" CLASS="copynotice" TARGET="NEW">v$gmversion · ©2000-2001 Noah Grey</A></font></P></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE>);
  139. $gmframebottomtwo = qq(</font></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE>);
  140. $statusnote = "";
  141.  
  142. # ---------------
  143. # date subroutine
  144. # ---------------
  145.  
  146. sub date {
  147.  
  148. $adjustTime = time() + ($serveroffset * 3600);
  149.  
  150. ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($adjustTime);
  151.  
  152. $mon++;
  153.  
  154. @months = ("null", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  155. @weekdays = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
  156.  
  157. $fullmonth = $months[$mon];
  158. $fullweekday = $weekdays[$wday];
  159.  
  160. $JSYear = $year + 1900;
  161. $shortyear = substr($JSYear, -2, 2);
  162.  
  163. $mintwo = sprintf ("%2d", $min);
  164. $mintwo =~ tr/ /0/;
  165. $sectwo = sprintf ("%2d", $sec);
  166. $sectwo =~ tr/ /0/;
  167.  
  168. $militaryhour = $hour;
  169.  
  170. if ($hour < 12) {
  171.     $AMPM = "AM";
  172.     $AMPMDOT = "A.M.";
  173. }
  174.  
  175. if ($hour > 12) {
  176.     $hour = $hour - 12;
  177.     $AMPM = "PM";
  178.     $AMPMDOT = "P.M.";
  179.     $militaryhour = $militaryhour + 12;
  180. }
  181.  
  182. if ($hour == 12) {
  183.     $AMPM = "PM";
  184.     $AMPMDOT = "P.M.";
  185. }
  186.  
  187. if ($hour == 0) {
  188.     $hour = "12";
  189. }
  190.  
  191. $hourtwo = sprintf ("%2d", $hour);
  192. $hourtwo =~ tr/ /0/;
  193. $mintwo = sprintf ("%2d", $min);
  194. $mintwo =~ tr/ /0/;
  195. $montwo = sprintf ("%2d", $mon);
  196. $montwo =~ tr/ /0/;
  197. $mdaytwo = sprintf ("%2d", $mday);
  198. $mdaytwo =~ tr/ /0/;
  199.  
  200. if (($hour eq "12") && ($AMPM eq "AM")) { $militaryhour = "0"; }
  201.  
  202. $militaryhourtwo = sprintf ("%2d", $hour);
  203. $militaryhourtwo =~ tr/ /0/;
  204.  
  205.  
  206. $basedate = "$montwo\/$mdaytwo\/$shortyear $hourtwo\:$mintwo $AMPM";
  207.  
  208. }
  209.  
  210. # -------------------------
  211. # delouse for textarea edit
  212. # -------------------------
  213.  
  214. sub delouse {
  215. $_ = shift;
  216. $_ =~ s/\|\*\|/\n/g;
  217. $_ =~ s/&([A-Za-z0-9\#]+);/\|AMP\|$1;/g;
  218. $_ =~ s/</\</g;
  219. $_ =~ s/>/\>/g;
  220. $_ =~ s/"/\"/g;
  221. return($_);
  222. }
  223.  
  224. # ---------------------------
  225. # relouse after textarea edit
  226. # ---------------------------
  227.  
  228. sub relouse {
  229. $_ = shift;
  230. $_ =~ s/\n/\|\*\|/g;
  231. $_ =~ s/\r//g;
  232. $_ =~ s/\</</g;
  233. $_ =~ s/\>/>/g;
  234. $_ =~ s/\"/"/g;
  235. $_ =~ s/\|AMP\|([A-Za-z0-9\#]+);/&$1;/g;
  236. return($_);
  237. }
  238.  
  239. # ---------------------
  240. # configuration delouse
  241. # ---------------------
  242.  
  243. sub configdelouse {
  244. $_ = shift;
  245. $_ =~ s/\|//g;
  246. $_ =~ s/\n//g;
  247. $_ =~ s/\r//g;
  248. $_ =~ s/^\s+//;
  249. $_ =~ s/\s+$//;
  250. return($_);
  251. }
  252.  
  253. # ----------------
  254. # read the counter
  255. # ----------------
  256.  
  257. sub gm_readcounter {
  258.  
  259. open (FUNNYFEETKRACK, "gm-counter.cgi") || &gm_dangermouse("Can't read the counter file.  Please make sure that gm-counter.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  260. @entrycounters = <FUNNYFEETKRACK>;
  261. close (FUNNYFEETKRACK);
  262.  
  263. $newentrynumber = $entrycounters[0];
  264. $newarchivenumber = $entrycounters[1];
  265. $newstayattopnumber = $entrycounters[2];
  266. $newalltimepktotalnumber = $entrycounters[3];
  267. $newalltimenktotalnumber = $entrycounters[4];
  268. $newalltimecommentstotalnumber = $entrycounters[5];
  269. $newalltimeopenentriesnumber = $entrycounters[6];
  270. $newalltimeclosedentriesnumber = $entrycounters[7];
  271.  
  272. chomp ($newentrynumber);
  273. chomp ($newarchivenumber);
  274. chomp ($newstayattopnumber);
  275. chomp ($newalltimepktotalnumber);
  276. chomp ($newalltimenktotalnumber);
  277. chomp ($newalltimecommentstotalnumber);
  278. chomp ($newalltimeopenentriesnumber);
  279. chomp ($newalltimeclosedentriesnumber);
  280.  
  281. if ($newentrynumber eq "") { $newentrynumber = 0; }
  282. if ($newarchivenumber eq "") { $newarchivenumber = 0; }
  283. if ($newstayattopnumber eq "") { $newstayattopnumber = 0; }
  284. if ($newalltimepktotalnumber eq "") { $newalltimepktotalnumber = 0; }
  285. if ($newalltimenktotalnumber eq "") { $newalltimenktotalnumber = 0; }
  286. if ($newalltimeopenentriesnumber eq "") { $newalltimeopenentriesnumber = 0; }
  287. if ($newalltimeclosedentriesnumber eq "") { $newalltimeclosedentriesnumber = 0; }
  288.  
  289. }
  290.  
  291. # -----------------
  292. # write the counter
  293. # -----------------
  294.  
  295. sub gm_writecounter {
  296.  
  297. if ($newentrynumber eq "") { $newentrynumber = 0; }
  298. if ($newarchivenumber eq "") { $newarchivenumber = 0; }
  299. if ($newstayattopnumber eq "") { $newstayattopnumber = 0; }
  300. if ($newalltimepktotalnumber eq "") { $newalltimepktotalnumber = 0; }
  301. if ($newalltimenktotalnumber eq "") { $newalltimenktotalnumber = 0; }
  302. if ($newalltimeopenentriesnumber eq "") { $newalltimeopenentriesnumber = 0; }
  303. if ($newalltimeclosedentriesnumber eq "") { $newalltimeclosedentriesnumber = 0; }
  304.  
  305. open (FUNNYFEETAUGH, ">gm-counter.cgi") || &gm_dangermouse("Can't write to the counter file.  Please make sure that gm-counter.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  306. print FUNNYFEETAUGH "$newentrynumber\n";
  307. print FUNNYFEETAUGH "$newarchivenumber\n";
  308. print FUNNYFEETAUGH "$newstayattopnumber\n";
  309. print FUNNYFEETAUGH "$newalltimepktotalnumber\n";
  310. print FUNNYFEETAUGH "$newalltimenktotalnumber\n";
  311. print FUNNYFEETAUGH "$newalltimecommentstotalnumber\n";
  312. print FUNNYFEETAUGH "$newalltimeopenentriesnumber\n";
  313. print FUNNYFEETAUGH "$newalltimeclosedentriesnumber\n";
  314. close (FUNNYFEETAUGH);
  315.  
  316. }
  317.  
  318. # ------------------
  319. # read the templates
  320. # ------------------
  321.  
  322. sub gm_readtemplates {
  323.  
  324. open (FUNNYFEETTAMMY, "gm-templates.cgi") || &gm_dangermouse("Can't read the templates file.  Please make sure that gm-templates.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  325. @gmtemplates = <FUNNYFEETTAMMY>;
  326. close (FUNNYFEETTAMMY);
  327.  
  328. $gmcounter = 0;
  329.  
  330. foreach (@gmtemplates) {
  331.     chomp ($gmtemplates[$gmcounter]);
  332.     $gmtemplates[$gmcounter] =~ s/\|\*\|/\n/g;
  333.     $gmcounter++;
  334. }
  335.  
  336. $gmindextemplate = $gmtemplates[0];
  337. $gmentrypagetemplate = $gmtemplates[1];
  338. $gmarchiveindextemplate = $gmtemplates[2];
  339. $gmarchiveentrypagetemplate = $gmtemplates[3];
  340. $gmentrytemplate = $gmtemplates[4];
  341. $gmarchiveentrytemplate = $gmtemplates[5];
  342. $gmstayattoptemplate = $gmtemplates[6];
  343. $gmdatetemplate = $gmtemplates[7];
  344. $gmcommentstemplate = $gmtemplates[8];
  345. $gmcommentsformtemplate = $gmtemplates[9];
  346. $gmparaseparationtemplate = $gmtemplates[10];
  347. $gmkarmaformtemplate = $gmtemplates[11];
  348. $gmmoreprefacetemplate = $gmtemplates[12];
  349. $gmmorelinktemplate = $gmtemplates[13];
  350. $gmkarmalinktemplate = $gmtemplates[14];
  351. $gmcommentslinktemplate = $gmtemplates[15];
  352. $gmcommentauthoremailtemplate = $gmtemplates[16];
  353. $gmcommentauthorhomepagetemplate = $gmtemplates[17];
  354. $gmcommentdividertemplate = $gmtemplates[18];
  355.  
  356. $gmmoreentrytemplate = $gmtemplates[19];
  357. $gmmoreentrypagetemplate = $gmtemplates[20];
  358. $gmmorearchiveentrypagetemplate = $gmtemplates[21];
  359. $gmpreviouslinktemplate = $gmtemplates[22];
  360. $gmnextlinktemplate = $gmtemplates[23];
  361. $gmpreviousmorelinktemplate = $gmtemplates[24];
  362. $gmnextmorelinktemplate = $gmtemplates[25];
  363. $gmarchivemasterindextemplate = $gmtemplates[26];
  364. $gmlogarchiveslinktemplate = $gmtemplates[27];
  365. $gmentrypagelinktemplate = $gmtemplates[28];
  366. $gmmoreentrypagelinktemplate = $gmtemplates[29];
  367. $gmlogarchiveslinkseparatortemplate = $gmtemplates[30];
  368. $gmentrypagelinkseparatortemplate = $gmtemplates[31];
  369. $gmentrypagelinkmonthseparatortemplate = $gmtemplates[32];
  370. $gmentrypagelinkdayseparatortemplate = $gmtemplates[33];
  371. $gmentrypagelinkyearseparatortemplate = $gmtemplates[34];
  372. $gmheadertemplate = $gmtemplates[35];
  373. $gmfootertemplate = $gmtemplates[36];
  374. $gmsidebartemplate = $gmtemplates[37];
  375. $gmcustomlinktemplate = $gmtemplates[38];
  376. $gmentryseparatortemplate = $gmtemplates[39];
  377. $gmarchiveentryseparatortemplate = $gmtemplates[40];
  378. $gmmorearchiveentrytemplate = $gmtemplates[41];
  379. $gmdatearchivetemplate = $gmtemplates[42];
  380.  
  381. $gmlogarchiveslinkweeklytemplate = $gmtemplates[43];
  382. $gmcustomonetemplate = $gmtemplates[44];
  383. $gmcustomtwotemplate = $gmtemplates[45];
  384. $gmcustomthreetemplate = $gmtemplates[46];
  385. $gmcustomfourtemplate = $gmtemplates[47];
  386. $gmcustomfivetemplate = $gmtemplates[48];
  387. $gmcustomsixtemplate = $gmtemplates[49];
  388. $gmcustomseventemplate = $gmtemplates[50];
  389. $gmcustomeighttemplate = $gmtemplates[51];
  390. $gmcustomninetemplate = $gmtemplates[52];
  391. $gmcustomtentemplate = $gmtemplates[53];
  392. $gmpopuppagetemplate = $gmtemplates[54];
  393. $gmpopupcodetemplate = $gmtemplates[55];
  394. $gmsearchformtemplate = $gmtemplates[56];
  395. $gmsearchresultspagetemplate = $gmtemplates[57];
  396. $gmsearchresultsentrytemplate = $gmtemplates[58];
  397. $gmcalendartablebeginningtemplate = $gmtemplates[59];
  398. $gmcalendartableendingtemplate = $gmtemplates[60];
  399. $gmcalendarblankcelltemplate = $gmtemplates[61];
  400. $gmcalendarfullcelltemplate = $gmtemplates[62];
  401. $gmcalendarfullcelllinktemplate = $gmtemplates[63];
  402. $gmcalendarweekblankdaytemplate = $gmtemplates[64];
  403. $gmcalendarweekfulldaytemplate = $gmtemplates[65];
  404. $gmcalendarweekfulldaylinktemplate = $gmtemplates[66];
  405. $gmcommentpreviewdividertemplate = $gmtemplates[67];
  406. $gmcommentpreviewformtemplate = $gmtemplates[68];
  407. $gmsmartlinknocommentstemplate = $gmtemplates[69];
  408. $gmsmartlinkonecommenttemplate = $gmtemplates[70];
  409. $gmsmartlinkmanycommentstemplate = $gmtemplates[71];
  410. $gmlinebreaktemplate = $gmtemplates[72];
  411.  
  412. }
  413.  
  414. # ---------------------
  415. # delouse all templates
  416. # ---------------------
  417.  
  418. sub gm_delousealltemplates {
  419.  
  420. $gmindextemplate = &delouse($gmindextemplate);
  421. $gmentrypagetemplate = &delouse($gmentrypagetemplate);
  422. $gmarchiveindextemplate = &delouse($gmarchiveindextemplate);
  423. $gmarchiveentrypagetemplate = &delouse($gmarchiveentrypagetemplate);
  424. $gmentrytemplate = &delouse($gmentrytemplate);
  425. $gmarchiveentrytemplate = &delouse($gmarchiveentrytemplate);
  426. $gmstayattoptemplate = &delouse($gmstayattoptemplate);
  427. $gmdatetemplate = &delouse($gmdatetemplate);
  428. $gmcommentstemplate = &delouse($gmcommentstemplate);
  429. $gmcommentsformtemplate = &delouse($gmcommentsformtemplate);
  430. $gmparaseparationtemplate = &delouse($gmparaseparationtemplate);
  431. $gmkarmaformtemplate = &delouse($gmkarmaformtemplate);
  432. $gmmoreprefacetemplate = &delouse($gmmoreprefacetemplate);
  433. $gmmorelinktemplate = &delouse($gmmorelinktemplate);
  434. $gmkarmalinktemplate = &delouse($gmkarmalinktemplate);
  435. $gmcommentslinktemplate = &delouse($gmcommentslinktemplate);
  436. $gmcommentauthoremailtemplate = &delouse($gmcommentauthoremailtemplate);
  437. $gmcommentauthorhomepagetemplate = &delouse($gmcommentauthorhomepagetemplate);
  438. $gmcommentdividertemplate = &delouse($gmcommentdividertemplate);
  439. $gmmoreentrytemplate = &delouse($gmmoreentrytemplate);
  440. $gmmoreentrypagetemplate = &delouse($gmmoreentrypagetemplate);
  441. $gmmorearchiveentrypagetemplate = &delouse($gmmorearchiveentrypagetemplate);
  442. $gmpreviouslinktemplate = &delouse($gmpreviouslinktemplate);
  443. $gmnextlinktemplate = &delouse($gmnextlinktemplate);
  444. $gmpreviousmorelinktemplate = &delouse($gmpreviousmorelinktemplate);
  445. $gmnextmorelinktemplate = &delouse($gmnextmorelinktemplate);
  446. $gmarchivemasterindextemplate = &delouse($gmarchivemasterindextemplate);
  447. $gmlogarchiveslinktemplate = &delouse($gmlogarchiveslinktemplate);
  448. $gmentrypagelinktemplate = &delouse($gmentrypagelinktemplate);
  449. $gmmoreentrypagelinktemplate = &delouse($gmmoreentrypagelinktemplate);
  450. $gmlogarchiveslinkseparatortemplate = &delouse($gmlogarchiveslinkseparatortemplate);
  451. $gmentrypagelinkseparatortemplate = &delouse($gmentrypagelinkseparatortemplate);
  452. $gmentrypagelinkmonthseparatortemplate = &delouse($gmentrypagelinkmonthseparatortemplate);
  453. $gmentrypagelinkdayseparatortemplate = &delouse($gmentrypagelinkdayseparatortemplate);
  454. $gmentrypagelinkyearseparatortemplate = &delouse($gmentrypagelinkyearseparatortemplate);
  455. $gmheadertemplate = &delouse($gmheadertemplate);
  456. $gmfootertemplate = &delouse($gmfootertemplate);
  457. $gmsidebartemplate = &delouse($gmsidebartemplate);
  458. $gmcustomlinktemplate = "";
  459. $gmentryseparatortemplate = &delouse($gmentryseparatortemplate);
  460. $gmarchiveentryseparatortemplate = &delouse($gmarchiveentryseparatortemplate);
  461. $gmmorearchiveentrytemplate = &delouse($gmmorearchiveentrytemplate);
  462. $gmdatearchivetemplate = &delouse($gmdatearchivetemplate);
  463.  
  464. $gmlogarchiveslinkweeklytemplate = &delouse($gmlogarchiveslinkweeklytemplate);
  465. $gmcustomonetemplate = &delouse($gmcustomonetemplate);
  466. $gmcustomtwotemplate = &delouse($gmcustomtwotemplate);
  467. $gmcustomthreetemplate = &delouse($gmcustomthreetemplate);
  468. $gmcustomfourtemplate = &delouse($gmcustomfourtemplate);
  469. $gmcustomfivetemplate = &delouse($gmcustomfivetemplate);
  470. $gmcustomsixtemplate = &delouse($gmcustomsixtemplate);
  471. $gmcustomseventemplate = &delouse($gmcustomseventemplate);
  472. $gmcustomeighttemplate = &delouse($gmcustomeighttemplate);
  473. $gmcustomninetemplate = &delouse($gmcustomninetemplate);
  474. $gmcustomtentemplate = &delouse($gmcustomtentemplate);
  475. $gmpopuppagetemplate = &delouse($gmpopuppagetemplate);
  476. $gmpopupcodetemplate = &delouse($gmpopupcodetemplate);
  477. $gmsearchformtemplate = &delouse($gmsearchformtemplate);
  478. $gmsearchresultspagetemplate = &delouse($gmsearchresultspagetemplate);
  479. $gmsearchresultsentrytemplate = &delouse($gmsearchresultsentrytemplate);
  480. $gmcalendartablebeginningtemplate = &delouse($gmcalendartablebeginningtemplate);
  481. $gmcalendartableendingtemplate = &delouse($gmcalendartableendingtemplate);
  482. $gmcalendarblankcelltemplate = &delouse($gmcalendarblankcelltemplate);
  483. $gmcalendarfullcelltemplate = &delouse($gmcalendarfullcelltemplate);
  484. $gmcalendarfullcelllinktemplate = &delouse($gmcalendarfullcelllinktemplate);
  485. $gmcalendarweekblankdaytemplate = "";
  486. $gmcalendarweekfulldaytemplate = &delouse($gmcalendarweekfulldaytemplate);
  487. $gmcalendarweekfulldaylinktemplate = &delouse($gmcalendarweekfulldaylinktemplate);
  488. $gmcommentpreviewdividertemplate = &delouse($gmcommentpreviewdividertemplate);
  489. $gmcommentpreviewformtemplate = &delouse($gmcommentpreviewformtemplate);
  490. $gmsmartlinknocommentstemplate = &delouse($gmsmartlinknocommentstemplate);
  491. $gmsmartlinkonecommenttemplate = &delouse($gmsmartlinkonecommenttemplate);
  492. $gmsmartlinkmanycommentstemplate = &delouse($gmsmartlinkmanycommentstemplate);
  493. $gmlinebreaktemplate = &delouse($gmlinebreaktemplate);
  494.  
  495. }
  496.  
  497. # --------------------
  498. # read the config file
  499. # --------------------
  500.  
  501. sub gm_readconfig {
  502.  
  503. open (FUNNYFEETCOCO, "gm-config.cgi") || &gm_dangermouse("Can't read the configuration file.  Please make sure that gm-config.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  504. @gmconfig = <FUNNYFEETCOCO>;
  505. close (FUNNYFEETCOCO);
  506.  
  507. $gmcounter = 0;
  508.  
  509. foreach (@gmconfig) {
  510.     chomp ($gmconfig[$gmcounter]);
  511.     $gmcounter++;
  512. }
  513.  
  514. $LogPath = $gmconfig[0];
  515. $EntriesPath = $gmconfig[1];
  516. $LogWebPath = $gmconfig[2];
  517. $EntriesWebPath = $gmconfig[3];
  518. $NotifyEmail = $gmconfig[4];
  519. $indexfilename = $gmconfig[5];
  520. $entrysuffix = $gmconfig[6];
  521. $indexdays = $gmconfig[7];
  522. $serveroffset = $gmconfig[8];
  523. $timezone = $gmconfig[9];
  524. $keeplog = $gmconfig[10];
  525. $posttoarchives = $gmconfig[11];
  526. $allowkarmadefault = $gmconfig[12];
  527. $allowcommentsdefault = $gmconfig[13];
  528. $commentsorder = $gmconfig[14];
  529. $generateentrypages = $gmconfig[15];
  530. $allowhtmlincomments = $gmconfig[16];
  531. $logkarmaandcomments = $gmconfig[17];
  532. $mailprog = $gmconfig[18];
  533. $NotifyForStatus = $gmconfig[19];
  534. $autolinkurls = $gmconfig[20];
  535. $striplinesfromcomments = $gmconfig[21];
  536. $allowmultiplekarmavotes = $gmconfig[22];
  537. $versionsetup = $gmconfig[23];
  538. $cgilocalpath = $gmconfig[24];
  539. $cgiwebpath = $gmconfig[25];
  540. $concurrentmainandarchives = $gmconfig[26];
  541. $keeparchivemasterindex = $gmconfig[27];
  542. $entrylistsortorder = $gmconfig[28];
  543. $allowkarmaorcomments = $gmconfig[29];
  544. $entrylistcountnumber = $gmconfig[30];
  545.  
  546. $cookiesallowed = $gmconfig[31];
  547. $logarchivesuffix = $gmconfig[32];
  548. $censorlist = $gmconfig[33];
  549. $censorenabled = $gmconfig[34];
  550. $keepmonthlyarchives = $gmconfig[35];
  551. $defaultentrylistview = $gmconfig[36];
  552. $linktocalendarentries = $gmconfig[37];
  553. $automaticrebuilddefault = $gmconfig[38];
  554. $commententrylistonlyifokay = $gmconfig[39];
  555. $otherfilelist = $gmconfig[40];
  556. $otherfilelistentryrebuild = $gmconfig[41];
  557. $archiveformat = $gmconfig[42];
  558. $inlineformatting = $gmconfig[43];
  559. $uploadfilesallowed = $gmconfig[44];
  560. $uploadfilesizelimit = $gmconfig[45];
  561.  
  562. }
  563.  
  564. # ---------------------
  565. # write the config file
  566. # ---------------------
  567.  
  568. sub gm_writeconfig {
  569.  
  570. if ($versionsetup eq "") { $versionsetup = $gmversion; }
  571.  
  572. open (FUNNYFEETCONNIE, ">gm-config.cgi") || &gm_dangermouse("Can't write to the configuration file.  Please make sure that gm-config.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  573. print FUNNYFEETCONNIE "$LogPath\n";
  574. print FUNNYFEETCONNIE "$EntriesPath\n";
  575. print FUNNYFEETCONNIE "$LogWebPath\n";
  576. print FUNNYFEETCONNIE "$EntriesWebPath\n";
  577. print FUNNYFEETCONNIE "$NotifyEmail\n";
  578. print FUNNYFEETCONNIE "$indexfilename\n";
  579. print FUNNYFEETCONNIE "$entrysuffix\n";
  580. print FUNNYFEETCONNIE "$indexdays\n";
  581. print FUNNYFEETCONNIE "$serveroffset\n";
  582. print FUNNYFEETCONNIE "$timezone\n";
  583. print FUNNYFEETCONNIE "$keeplog\n";
  584. print FUNNYFEETCONNIE "$posttoarchives\n";
  585. print FUNNYFEETCONNIE "$allowkarmadefault\n";
  586. print FUNNYFEETCONNIE "$allowcommentsdefault\n";
  587. print FUNNYFEETCONNIE "$commentsorder\n";
  588. print FUNNYFEETCONNIE "$generateentrypages\n";
  589. print FUNNYFEETCONNIE "$allowhtmlincomments\n";
  590. print FUNNYFEETCONNIE "$logkarmaandcomments\n";
  591. print FUNNYFEETCONNIE "$mailprog\n";
  592. print FUNNYFEETCONNIE "$NotifyForStatus\n";
  593. print FUNNYFEETCONNIE "$autolinkurls\n";
  594. print FUNNYFEETCONNIE "$striplinesfromcomments\n";
  595. print FUNNYFEETCONNIE "$allowmultiplekarmavotes\n";
  596. print FUNNYFEETCONNIE "$versionsetup\n";
  597. print FUNNYFEETCONNIE "$cgilocalpath\n";
  598. print FUNNYFEETCONNIE "$cgiwebpath\n";
  599. print FUNNYFEETCONNIE "$concurrentmainandarchives\n";
  600. print FUNNYFEETCONNIE "$keeparchivemasterindex\n";
  601. print FUNNYFEETCONNIE "$entrylistsortorder\n";
  602. print FUNNYFEETCONNIE "$allowkarmaorcomments\n";
  603. print FUNNYFEETCONNIE "$entrylistcountnumber\n";
  604. print FUNNYFEETCONNIE "$cookiesallowed\n";
  605. print FUNNYFEETCONNIE "$logarchivesuffix\n";
  606. print FUNNYFEETCONNIE "$censorlist\n";
  607. print FUNNYFEETCONNIE "$censorenabled\n";
  608. print FUNNYFEETCONNIE "$keepmonthlyarchives\n";
  609. print FUNNYFEETCONNIE "$defaultentrylistview\n";
  610. print FUNNYFEETCONNIE "$linktocalendarentries\n";
  611. print FUNNYFEETCONNIE "$automaticrebuilddefault\n";
  612. print FUNNYFEETCONNIE "$commententrylistonlyifokay\n";
  613. print FUNNYFEETCONNIE "$otherfilelist\n";
  614. print FUNNYFEETCONNIE "$otherfilelistentryrebuild\n";
  615. print FUNNYFEETCONNIE "$archiveformat\n";
  616. print FUNNYFEETCONNIE "$inlineformatting\n";
  617. print FUNNYFEETCONNIE "$uploadfilesallowed\n";
  618. print FUNNYFEETCONNIE "$uploadfilesizelimit\n";
  619. close (FUNNYFEETCONNIE);
  620.  
  621. }
  622.  
  623. # ---------------------------------
  624. # gather ye all thy entry variables
  625. # ---------------------------------
  626.  
  627. sub gm_getentryvariables {
  628.  
  629. my $thisentrygetmynumber = shift;
  630.  
  631. &gm_readconfig;
  632. &gm_readtemplates;
  633. &gm_readcounter;
  634.  
  635. $thisentrynumberpadded = sprintf ("%8d", $thisentrygetmynumber);
  636. $thisentrynumberpadded =~ tr/ /0/;
  637.  
  638. open (FUNNYFEETENTRY, "$EntriesPath/$thisentrynumberpadded.cgi") || &gm_dangermouse("Can't read $EntriesPath/$thisentrynumberpadded.cgi.  Please make sure that your entries/archives directory is correctly configured and is CHMODed to 777, or try running Diagnostics & Repair in the Configuration screen.");
  639. @entrylines = <FUNNYFEETENTRY>;
  640. close (FUNNYFEETENTRY);
  641.  
  642. $gmcounter = 0;
  643.  
  644. foreach (@entrylines) {
  645.     chomp ($entrylines[$gmcounter]);
  646.     $entrylines[$gmcounter] =~ s/\|\*\|/\n/g;
  647.     $gmcounter++;
  648. }
  649.  
  650. ($thisentrynumber, $thisentryauthor, $thisentrysubject, $thisentryweekdaynumber, $thisentrymonth, $thisentryday, $thisentryyearyear, $thisentryhour, $thisentryminute, $thisentrysecond, $thisentryampm, $thisentrypositivekarma, $thisentrynegativekarma, $thisentrycommentsnumber, $thisentryallowkarma, $thisentryallowcomments, $thisentryopenstatus) = split (/\|/, $entrylines[0]);
  651.  
  652. chomp ($thisentryopenstatus);
  653.  
  654. $thisentryisanarchive = "no";
  655. if ($thisentrynumber <= $newarchivenumber) { $thisentryisanarchive = "yes"; }
  656.  
  657. if ($generateentrypages eq "no") { $thisentryallowcomments = "no"; }
  658.  
  659. $thisentryyear = substr($thisentryyearyear, -2, 2);
  660.  
  661. @months = ("null", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  662. @weekdays = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
  663.  
  664. $thisentryweekday = $weekdays[$thisentryweekdaynumber];
  665. $thisentrymonthword = $months[$thisentrymonth];
  666. $thisentryweekdayshort = substr($thisentryweekday, 0, 3);
  667. $thisentrymonthwordshort = substr($thisentrymonthword, 0, 3);
  668. $thisentryweekdayupper = uc($thisentryweekday);
  669. $thisentrymonthwordupper = uc($thisentrymonthword);
  670. $thisentryweekdaylower = lc($thisentryweekday);
  671. $thisentrymonthwordlower = lc($thisentrymonthword);
  672. $thisentryweekdayuppershort = uc($thisentryweekdayshort);
  673. $thisentrymonthworduppershort = uc($thisentrymonthwordshort);
  674. $thisentryweekdaylowershort = lc($thisentryweekdayshort);
  675. $thisentrymonthwordlowershort = lc($thisentrymonthwordshort);
  676.  
  677. $thisentrymonthmonth = sprintf ("%2d", $thisentrymonth);
  678. $thisentrydayday = sprintf ("%2d", $thisentryday);
  679. $thisentryhourhour = sprintf ("%2d", $thisentryhour);
  680. $thisentryminuteminute = sprintf ("%2d", $thisentryminute);
  681. $thisentrysecondsecond = sprintf ("%2d", $thisentrysecond);
  682. $thisentrymonthmonth =~ tr/ /0/;
  683. $thisentrydayday =~ tr/ /0/;
  684. $thisentryhourhour =~ tr/ /0/;
  685. $thisentryminuteminute =~ tr/ /0/;
  686. $thisentrysecondsecond =~ tr/ /0/;
  687.  
  688. $thisentryampmdot = "A.M.";
  689. $thisentrymilitaryhour = $thisentryhour;
  690. if ($thisentryampm eq "PM") {
  691.     $thisentryampmdot = "P.M.";
  692.     if ($thisentryhour ne "12") { $thisentrymilitaryhour = $thisentryhour + 12; }
  693. }
  694.  
  695. $thisentrymilitaryhour = sprintf ("%2d", $thisentrymilitaryhour);
  696. $thisentrymilitaryhour =~ tr/ /0/;
  697. $thisentryampmlower = lc($thisentryampm);
  698. $thisentryampmdotlower = lc($thisentryampmdot);
  699.  
  700. if (($thisentryhour eq "12") && ($thisentryampm eq "AM")) {
  701.     $thisentrymilitaryhour = "00";
  702. }
  703.  
  704. $leapyearcheck = $thisentryyearyear % 4;
  705.  
  706. $thisentrymaxdaysinthismonth = 31;
  707. if (($thisentrymonthword eq "September") || ($thisentrymonthword eq "April") || ($thisentrymonthword eq "June") || ($thisentrymonthword eq "November")) { $thisentrymaxdaysinthismonth = 30; }
  708. if ($thisentrymonthword eq "February") {
  709.     $thisentrymaxdaysinthismonth = 28;
  710.     if ($leapyearcheck eq "0") { $thisentrymaxdaysinthismonth = 29; }
  711. }
  712. $thisentrymaxdaysinpreviousmonth = 31;
  713. if (($thisentrymonthword eq "October") || ($thisentrymonthword eq "May") || ($thisentrymonthword eq "July") || ($thisentrymonthword eq "December")) { $thisentrymaxdaysinpreviousmonth = 30; }
  714. if ($thisentrymonthword eq "March") {
  715.     $thisentrymaxdaysinpreviousmonth = 28;
  716.     if ($leapyearcheck eq "0") { $thisentrymaxdaysinpreviousmonth = 29; }
  717. }
  718.  
  719. $thisentryweekbeginningmonth = $thisentrymonth;
  720. $thisentryweekbeginningyearyear = $thisentryyearyear;
  721. $thisentryweekendingmonth = $thisentrymonth;
  722. $thisentryweekendingyearyear = $thisentryyearyear;
  723.  
  724. $thisentryweekbeginningday = $thisentryday - $thisentryweekdaynumber;
  725. $thisentryweekendingday = $thisentryweekbeginningday + 6;
  726.  
  727. if ($thisentryweekbeginningday < 1) {
  728.     $thisentryweekbeginningday = $thisentryweekbeginningday + $thisentrymaxdaysinpreviousmonth;
  729.     if ($thisentryweekbeginningday > $thisentryday) { $thisentryweekbeginningmonth--; }
  730.     if ($thisentryweekbeginningmonth < 1) {
  731.         $thisentryweekbeginningmonth = 12;
  732.         $thisentryweekbeginningyearyear--;
  733.     }
  734. }
  735.  
  736. if ($thisentryweekendingday > $thisentrymaxdaysinthismonth) {
  737.     $thisentryweekendingday = $thisentryweekendingday - $thisentrymaxdaysinthismonth;
  738.     if ($thisentryweekendingday < $thisentryday) { $thisentryweekendingmonth++; }
  739.     if ($thisentryweekendingmonth > 12) {
  740.         $thisentryweekendingmonth = 1;
  741.         $thisentryweekendingyearyear++;
  742.     }
  743. }
  744.  
  745. $thisentryweekbeginningyear = substr($thisentryweekbeginningyearyear, -2, 2);
  746. $thisentryweekendingyear = substr($thisentryweekendingyearyear, -2, 2);
  747.  
  748. $thisentryweekbeginningdayday = sprintf ("%2d", $thisentryweekbeginningday);
  749. $thisentryweekbeginningdayday =~ tr/ /0/;
  750. $thisentryweekendingdayday = sprintf ("%2d", $thisentryweekendingday);
  751. $thisentryweekendingdayday =~ tr/ /0/;
  752. $thisentryweekbeginningmonthmonth = sprintf ("%2d", $thisentryweekbeginningmonth);
  753. $thisentryweekbeginningmonthmonth =~ tr/ /0/;
  754. $thisentryweekendingmonthmonth = sprintf ("%2d", $thisentryweekendingmonth);
  755. $thisentryweekendingmonthmonth =~ tr/ /0/;
  756.  
  757. $thisentryweekbeginningweekday = "Sunday";
  758. $thisentryweekbeginningmonthword = $months[$thisentryweekbeginningmonth];
  759. $thisentryweekbeginningweekdayshort = substr($thisentryweekbeginningweekday, 0, 3);
  760. $thisentryweekbeginningmonthwordshort = substr($thisentryweekbeginningmonthword, 0, 3);
  761. $thisentryweekbeginningweekdayupper = uc($thisentryweekbeginningweekday);
  762. $thisentryweekbeginningmonthwordupper = uc($thisentryweekbeginningmonthword);
  763. $thisentryweekbeginningweekdaylower = lc($thisentryweekbeginningweekday);
  764. $thisentryweekbeginningmonthwordlower = lc($thisentryweekbeginningmonthword);
  765. $thisentryweekbeginningweekdayuppershort = uc($thisentryweekbeginningweekdayshort);
  766. $thisentryweekbeginningmonthworduppershort = uc($thisentryweekbeginningmonthwordshort);
  767. $thisentryweekbeginningweekdaylowershort = lc($thisentryweekbeginningweekdayshort);
  768. $thisentryweekbeginningmonthwordlowershort = lc($thisentryweekbeginningmonthwordshort);
  769.  
  770. $thisentryweekendingweekday = "Saturday";
  771. $thisentryweekendingmonthword = $months[$thisentryweekendingmonth];
  772. $thisentryweekendingweekdayshort = substr($thisentryweekendingweekday, 0, 3);
  773. $thisentryweekendingmonthwordshort = substr($thisentryweekendingmonthword, 0, 3);
  774. $thisentryweekendingweekdayupper = uc($thisentryweekendingweekday);
  775. $thisentryweekendingmonthwordupper = uc($thisentryweekendingmonthword);
  776. $thisentryweekendingweekdaylower = lc($thisentryweekendingweekday);
  777. $thisentryweekendingmonthwordlower = lc($thisentryweekendingmonthword);
  778. $thisentryweekendingweekdayuppershort = uc($thisentryweekendingweekdayshort);
  779. $thisentryweekendingmonthworduppershort = uc($thisentryweekendingmonthwordshort);
  780. $thisentryweekendingweekdaylowershort = lc($thisentryweekendingweekdayshort);
  781. $thisentryweekendingmonthwordlowershort = lc($thisentryweekendingmonthwordshort);
  782.  
  783. open (FUNNYFEETVISHNU, "gm-authors.cgi") || &gm_dangermouse("Can't read the authors file.  Please make sure that gm-authors.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  784. @gettheauthordata = <FUNNYFEETVISHNU>;
  785. close (FUNNYFEETVISHNU);
  786.  
  787. $thisentryauthoremail = "";
  788. $thisentryauthorhomepage = "";
  789. $thisentryauthorentrycount = "";
  790.  
  791. foreach $gettheauthordataline (@gettheauthordata) {
  792.     chomp ($gettheauthordataline);
  793.     @gettheauthorinfo = split (/\|/, $gettheauthordataline);
  794.     if ($gettheauthorinfo[0] eq $thisentryauthor) {
  795.         $thisentryauthoremail = $gettheauthorinfo[2];
  796.         $thisentryauthorhomepage = $gettheauthorinfo[3];
  797.         $thisentryauthorentrycount = $gettheauthorinfo[5];
  798.     }
  799. }
  800.  
  801. $thisentryauthorsmartlink = $thisentryauthor;
  802. if ($thisentryauthoremail ne "") { $thisentryauthorsmartlink = "<a href=\"mailto:$thisentryauthoremail\">$thisentryauthor</a>"; }
  803. if ($thisentryauthorhomepage ne "") { $thisentryauthorsmartlink = "<a href=\"$thisentryauthorhomepage\" target=\"new\">$thisentryauthor</a>"; }
  804.  
  805. $thisentryfilename = "$EntriesWebPath\/$thisentrynumberpadded\.$entrysuffix";
  806.  
  807. $thisentrycommentspostlink = "$thisentryfilename\#comments";
  808.  
  809. $thisentrycommentstatussmart = $gmsmartlinkmanycommentstemplate;
  810.  
  811. if ($thisentrycommentsnumber eq "0") { $thisentrycommentstatussmart = $gmsmartlinknocommentstemplate; }
  812. if ($thisentrycommentsnumber eq "1") { $thisentrycommentstatussmart = $gmsmartlinkonecommenttemplate; }
  813.  
  814. $thisentrycommentstatussmartupper = uc($thisentrycommentstatussmart);
  815. $thisentrycommentstatussmartlower = lc($thisentrycommentstatussmart);
  816.  
  817. $thisentrypagelink = $thisentryfilename;
  818.  
  819. $indexfilenamesmartcheck = "/$indexfilename";
  820. $indexfilenameprefix = substr($indexfilename, 0, 6);
  821.  
  822. if ($indexfilenameprefix eq "index.") { $indexfilenamesmartcheck = "/"; }
  823.  
  824. $thisentrypageindexlink = "$LogWebPath$indexfilenamesmartcheck";
  825. $thisentrypagearchiveindexlink = "$EntriesWebPath$indexfilenamesmartcheck";
  826.  
  827. if ($keepmonthlyarchives eq "no") {
  828.     $thisentrypagearchivelogindexlink = $thisentrypageindexlink;
  829. } else {
  830.     if ($archiveformat eq "week") {
  831.         $thisentrypagearchivelogindexlink = "$EntriesWebPath/archive-$thisentryweekbeginningmonthmonth$thisentryweekbeginningdayday$thisentryweekbeginningyearyear-$thisentryweekendingmonthmonth$thisentryweekendingdayday$thisentryweekendingyearyear\.$logarchivesuffix";
  832.     } else {
  833.         $thisentrypagearchivelogindexlink = "$EntriesWebPath/archive-$thisentrymonthmonth$thisentryyearyear\.$logarchivesuffix";
  834.     }
  835. }
  836.  
  837. $thisentrypagesmartindexlink = $thisentrypageindexlink;
  838.  
  839. if (($thisentrynumber <= $newarchivenumber) && ($keepmonthlyarchives ne "no")) {
  840.     $thisentrypagesmartindexlink = $thisentrypagearchivelogindexlink;
  841. }
  842.  
  843. $thisentrycommentslink = "";
  844. $thisentrycommentsform = "";
  845. if ($thisentryallowcomments eq "yes") {
  846.     if (($allowkarmaorcomments eq "comments") || ($allowkarmaorcomments eq "both")) {
  847.         $thisentrycommentslink = $gmcommentslinktemplate;
  848.         $thisentrycommentsform = $gmcommentsformtemplate;
  849.     }
  850. }
  851.  
  852. $thisentrykarmalink = "";
  853. $thisentrykarmaform = "";
  854. if ($thisentryallowkarma eq "yes") {
  855.     if (($allowkarmaorcomments eq "karma") || ($allowkarmaorcomments eq "both")) {
  856.         $thisentrykarmalink = $gmkarmalinktemplate;
  857.         $thisentrykarmaform = $gmkarmaformtemplate;
  858.     }
  859. }
  860.  
  861. if (($thisentryisanarchive eq "yes") && ($posttoarchives eq "no")) {
  862.     $thisentrykarmalink = "";
  863.     $thisentrykarmaform = "";
  864.     $thisentrycommentslink = "";
  865.     $thisentrycommentsform = "";
  866. }
  867.  
  868. $thisentrysearchform = $gmsearchformtemplate;
  869.  
  870. if ($generateentrypages eq "no") {
  871.     $thisentrycommentslink = "";
  872.     $thisentrycommentsform = "";
  873.     $thisentrysearchform = "";
  874. }
  875.  
  876. $thisentrypositivekarmalink = "$cgiwebpath/gm-karma.cgi?vote=positive&entry=$thisentrynumberpadded";
  877. $thisentrynegativekarmalink = "$cgiwebpath/gm-karma.cgi?vote=negative&entry=$thisentrynumberpadded";
  878.  
  879. $thisentrytotalkarma = $thisentrypositivekarma - $thisentrynegativekarma;
  880.  
  881. @thisentrykarmavoters = split (/\|/, $entrylines[1]);
  882.  
  883. $thisentrymainbody = $entrylines[2];
  884. $thisentrymorebody = $entrylines[3];
  885.  
  886. if (($thisentrymainbody =~ /\|\*\|\|\*\|/) || ($thisentrymorebody =~ /\|\*\|\|\*\|/)) {
  887.     $thisentrymainbody =~ s/\|\*\|\|\*\|/<PARABREAK>/g;
  888.     $thisentrymorebody =~ s/\|\*\|\|\*\|/<PARABREAK>/g;
  889. }
  890. if (($thisentrymainbody =~ /\n\n/) || ($thisentrymorebody =~ /\n\n/)) {
  891.     $thisentrymainbody =~ s/\n\n/<PARABREAK>/g;
  892.     $thisentrymorebody =~ s/\n\n/<PARABREAK>/g;
  893. }
  894. if (($thisentrymainbody =~ /\|\*\|/) || ($thisentrymorebody =~ /\|\*\|/)) {
  895.     $thisentrymainbody =~ s/\|\*\|/$gmlinebreaktemplate/g;
  896.     $thisentrymorebody =~ s/\|\*\|/$gmlinebreaktemplate/g;
  897. }
  898. if (($thisentrymainbody =~ /\n/) || ($thisentrymorebody =~ /\n/)) {
  899.     $thisentrymainbody =~ s/\n/$gmlinebreaktemplate/g;
  900.     $thisentrymorebody =~ s/\n/$gmlinebreaktemplate/g;
  901. }
  902. if (($thisentrymainbody =~ /<PARABREAK>/) || ($thisentrymorebody =~ /<PARABREAK>/)) {
  903.     $thisentrymainbody =~ s/<PARABREAK>/$gmparaseparationtemplate/g;
  904.     $thisentrymorebody =~ s/<PARABREAK>/$gmparaseparationtemplate/g;
  905. }
  906.  
  907. if (($censorenabled eq "both") || ($censorenabled eq "entries")) {
  908.     unless ($censorlist eq "") {
  909.         @censoredterms = split(/\|\*\|/, $censorlist);
  910.         foreach $thisterm (@censoredterms) {
  911.             unless ($thisterm eq "") {
  912.                 if ((substr($thisterm, 0, 1) eq "[") && (substr($thisterm, -1, 1) eq "]")) {
  913.                     $thisrealterm = $thisterm;
  914.                     $thisrealterm =~ s/\[//g;
  915.                     $thisrealterm =~ s/\]//g;
  916.                     $thisrealtermlength = length($thisrealterm);
  917.                     $thisrealtermreplace = "*" x $thisrealtermlength;
  918.                     $thisrealtermreplacedash = "-" x $thisrealtermlength;
  919.                     if ($thisentrysubject =~ m/$thisrealterm/i) {
  920.                         $thisentrysubject =~ s/\b$thisrealterm\b/$thisrealtermreplacedash/isg;
  921.                     }
  922.                     if ($thisentrymainbody =~ m/$thisrealterm/i) {
  923.                         $thisentrymainbody =~ s/\b$thisrealterm\b/$thisrealtermreplace/isg;
  924.                     }
  925.                     if ($thisentrymorebody =~ m/$thisrealterm/i) {
  926.                         $thisentrymorebody =~ s/\b$thisrealterm\b/$thisrealtermreplace/isg;
  927.                     }
  928.                 } else {
  929.                     $thisrealtermlength = length($thisterm);
  930.                     $thisrealtermreplace = "*" x $thisrealtermlength;
  931.                     $thisrealtermreplacedash = "-" x $thisrealtermlength;
  932.                     if ($thisentrysubject =~ m/$thisterm/i) {
  933.                         $thisentrysubject =~ s/\b$thisterm\b/$thisrealtermreplacedash/isg;
  934.                     }
  935.                     if ($thisentrymainbody =~ m/$thisterm/i) {
  936.                         $thisentrymainbody =~ s/\b$thisterm\b/$thisrealtermreplace/isg;
  937.                     }
  938.                     if ($thisentrymorebody =~ m/$thisterm/i) {
  939.                         $thisentrymorebody =~ s/\b$thisterm\b/$thisrealtermreplace/isg;
  940.                     }
  941.                 }
  942.             }
  943.         }
  944.     }
  945. }
  946.  
  947. $thisentrymorepreface = "";
  948. $thisentrymorelink = "";
  949. if (($thisentrymorebody ne "") && ($generateentrypages ne "no")) {
  950.     $thisentrymorepreface = $gmmoreprefacetemplate;
  951.     $thisentrymorelink = $gmmorelinktemplate;
  952. }
  953.  
  954. $thisentrycommentdivider = "";
  955. if ($thisentrycommentsnumber ne "0") { $thisentrycommentdivider = $gmcommentdividertemplate; }
  956.  
  957. $thisentrycomments = "";
  958.  
  959. if (($inlineformatting eq "entries") || ($inlineformatting eq "both")) {
  960.     if (($thisentrysubject =~ /\*\*(.*?)\*\*/) || ($thisentrysubject =~ /\\\\(.*?)\\\\/) || ($thisentrysubject =~ /__(.*?)__/)) {
  961.         $thisentrysubject =~ s/\*\*(.*?)\*\*/<B>$1<\/B>/isg;
  962.         $thisentrysubject =~ s/\\\\(.*?)\\\\/<I>$1<\/I>/isg;
  963.         $thisentrysubject =~ s/__(.*?)__/<U>$1<\/U>/isg;
  964.     }
  965.     if (($thisentrymainbody =~ /\*\*(.*?)\*\*/) || ($thisentrymainbody =~ /\\\\(.*?)\\\\/) || ($thisentrymainbody =~ /__(.*?)__/)) {
  966.         $thisentrymainbody =~ s/\*\*(.*?)\*\*/<B>$1<\/B>/isg;
  967.         $thisentrymainbody =~ s/\\\\(.*?)\\\\/<I>$1<\/I>/isg;
  968.         $thisentrymainbody =~ s/__(.*?)__/<U>$1<\/U>/isg;
  969.     }
  970.     if (($thisentrymorebody =~ /\*\*(.*?)\*\*/) || ($thisentrymorebody =~ /\\\\(.*?)\\\\/) || ($thisentrymorebody =~ /__(.*?)__/)) {
  971.         $thisentrymorebody =~ s/\*\*(.*?)\*\*/<B>$1<\/B>/isg;
  972.         $thisentrymorebody =~ s/\\\\(.*?)\\\\/<I>$1<\/I>/isg;
  973.         $thisentrymorebody =~ s/__(.*?)__/<U>$1<\/U>/isg;
  974.     }
  975. }
  976.  
  977. if (($thisentrycommentsnumber ne "0") && ($generateentrypages ne "no")) {
  978.     $thisisaspellcheck = "no";
  979.     &gm_collatecomments;
  980.     $thisentrycomments =~ s/\"/"/g;
  981. }
  982.  
  983. }
  984.  
  985. # -----------------
  986. # comment collating
  987. # -----------------
  988.  
  989. sub gm_collatecomments {
  990.  
  991. $commentcounter = 4;
  992. if ($commentsorder eq "ascending") { $commentcounter = $thisentrycommentsnumber + 3; }
  993.  
  994. $commentcountermax = $thisentrycommentsnumber + 3;
  995. $commentcountercurrent = $thisentrycommentsnumber;
  996.  
  997. do {
  998.  
  999. $thiscommentordernumber = $commentcounter - 3;
  1000.  
  1001. ($thiscommentauthor, $thiscommentauthorip, $thiscommentauthoremailabsolute, $thiscommentauthorhomepageabsolute, $thiscommentweekdaynumber, $thiscommentmonth, $thiscommentday, $thiscommentyearyear, $thiscommenthour, $thiscommentminute, $thiscommentsecond, $thiscommentampm, $thiscommenttext) = split (/\|/, $entrylines[$commentcounter]);
  1002.  
  1003. $thiscommentyear = substr($thiscommentyearyear, -2, 2);
  1004.  
  1005. @months = ("null", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  1006. @weekdays = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
  1007.  
  1008. $thiscommentweekday = $weekdays[$thiscommentweekdaynumber];
  1009. $thiscommentmonthword = $months[$thiscommentmonth];
  1010. $thiscommentweekdayshort = substr($thiscommentweekday, 0, 3);
  1011. $thiscommentmonthwordshort = substr($thiscommentmonthword, 0, 3);
  1012. $thiscommentweekdayupper = uc($thiscommentweekday);
  1013. $thiscommentmonthwordupper = uc($thiscommentmonthword);
  1014. $thiscommentweekdaylower = lc($thiscommentweekday);
  1015. $thiscommentmonthwordlower = lc($thiscommentmonthword);
  1016. $thiscommentweekdayuppershort = uc($thiscommentweekdayshort);
  1017. $thiscommentmonthworduppershort = uc($thiscommentmonthwordshort);
  1018. $thiscommentweekdaylowershort = lc($thiscommentweekdayshort);
  1019. $thiscommentmonthwordlowershort = lc($thiscommentmonthwordshort);
  1020.  
  1021. $thiscommentmonthmonth = sprintf ("%2d", $thiscommentmonth);
  1022. $thiscommentdayday = sprintf ("%2d", $thiscommentday);
  1023. $thiscommenthourhour = sprintf ("%2d", $thiscommenthour);
  1024. $thiscommentminuteminute = sprintf ("%2d", $thiscommentminute);
  1025. $thiscommentsecondsecond = sprintf ("%2d", $thiscommentsecond);
  1026. $thiscommentmonthmonth =~ tr/ /0/;
  1027. $thiscommentdayday =~ tr/ /0/;
  1028. $thiscommenthourhour =~ tr/ /0/;
  1029. $thiscommentminuteminute =~ tr/ /0/;
  1030. $thiscommentsecondsecond =~ tr/ /0/;
  1031.  
  1032. $thiscommentampmdot = "A.M.";
  1033. $thiscommentmilitaryhour = $thiscommenthour;
  1034. if ($thiscommentampm eq "PM") {
  1035.     $thiscommentampmdot = "P.M.";
  1036.     if ($thiscommenthour ne "12") { $thiscommentmilitaryhour = $thiscommenthour + 12; }
  1037. }
  1038. $thiscommentmilitaryhour = sprintf ("%2d", $thiscommentmilitaryhour);
  1039. $thiscommentmilitaryhour =~ tr/ /0/;
  1040. $thiscommentampmlower = lc($thiscommentampm);
  1041. $thiscommentampmdotlower = lc($thiscommentampmdot);
  1042.  
  1043. $thiscommentauthor =~ s/"/\"/g;
  1044. $thiscommentauthoremailabsolute =~ s/"/\"/g;
  1045. $thiscommentauthorhomepageabsolute =~ s/"/\"/g;
  1046.  
  1047. $thiscommentauthoremail = "";
  1048. $thiscommentauthorhomepage = "";
  1049.  
  1050. $thiscommentauthorsmartlink = $thiscommentauthor;
  1051. if ($thiscommentauthoremailabsolute ne "") {
  1052.     $thiscommentauthoremail = $gmcommentauthoremailtemplate;
  1053.     $thiscommentauthorsmartlink = "<a href=\"mailto:$thiscommentauthoremailabsolute\">$thiscommentauthor</a>";
  1054. }
  1055. if ($thiscommentauthorhomepageabsolute ne "") {
  1056.     $thiscommentauthorhomepage = $gmcommentauthorhomepagetemplate;
  1057.     $thiscommentauthorsmartlink = "<a href=\"$thiscommentauthorhomepageabsolute\" target=\"new\">$thiscommentauthor</a>";
  1058. }
  1059.  
  1060. if (($allowhtmlincomments eq "linkboldital") || ($allowhtmlincomments eq "linkonly")) {
  1061.     if ($thiscommenttext =~ m/\*/i) { $thiscommenttext =~ s/\*/\|AMP\|/g; }
  1062.     if (($thiscommenttext =~ m/<a href/i) && ($thiscommenttext =~ m/<\/a>/i)) {
  1063.         $thiscommenttext =~ s/<a href/\*a href\*/isg;
  1064.         $thiscommenttext =~ s/<\/a>/\*a\*/isg;
  1065.     }
  1066.     if ($allowhtmlincomments eq "linkboldital") {
  1067.         if (($thiscommenttext =~ m/<b>/i) && ($thiscommenttext =~ m/<\/b>/i)) {
  1068.             $thiscommenttext =~ s/<b>/\*b\*/isg;
  1069.             $thiscommenttext =~ s/<\/b>/\*bb\*/isg;
  1070.         }
  1071.         if (($thiscommenttext =~ m/<i>/i) && ($thiscommenttext =~ m/<\/i>/i)) {
  1072.             $thiscommenttext =~ s/<i>/\*i\*/isg;
  1073.             $thiscommenttext =~ s/<\/i>/\*ii\*/isg;
  1074.         }
  1075.     }
  1076. }
  1077.  
  1078. unless ($allowhtmlincomments eq "yes") { $thiscommenttext =~ s/<([^>]|\n)*>//g; }
  1079.  
  1080. if ($autolinkurls eq "yes") {
  1081. # these two lines of code written in part by Neal Coffey (cray@indecisions.org)
  1082.     $thiscommenttext =~ s#(^|\s)(\w+://)([A-Za-z0-9?=_\-/.%+&'~\#@!\^]+)#$1<a href="$2$3">$2$3</a>#isg;
  1083.     $thiscommenttext =~ s#(^|\s)(www.[A-Za-z0-9?=_\-/.%+&'~\#@!\^]+)#$1<a href="http://$2" target="new">$2</a>#isg;
  1084. # thanks, Neal!
  1085.     $thiscommenttext =~ s/(\w+\@\w+\.\w+)/<a href="mailto:$1">$1<\/a>/isg;
  1086. }
  1087.  
  1088. if (($allowhtmlincomments eq "linkboldital") || ($allowhtmlincomments eq "linkonly")) {
  1089.     if (($thiscommenttext =~ m/\*a href\*/i) && ($thiscommenttext =~ m/\*a\*/i)) {
  1090.         $thiscommenttext =~ s/\*a href\*/<a href/isg;
  1091.         $thiscommenttext =~ s/\*a\*/<\/a>/isg;
  1092.     }
  1093.     if ($allowhtmlincomments eq "linkboldital") {
  1094.         if (($thiscommenttext =~ m/\*b\*/i) && ($thiscommenttext =~ m/\*bb\*/i)) {
  1095.             $thiscommenttext =~ s/\*b\*/<b>/isg;
  1096.             $thiscommenttext =~ s/\*bb\*/<\/b>/isg;
  1097.         }
  1098.         if (($thiscommenttext =~ m/\*i\*/i) && ($thiscommenttext =~ m/\*ii\*/i)) {
  1099.             $thiscommenttext =~ s/\*i\*/<i>/isg;
  1100.             $thiscommenttext =~ s/\*ii\*/<\/i>/isg;
  1101.         }
  1102.     }
  1103.     if ($thiscommenttext =~ m/\|AMP\|/i) { $thiscommenttext =~ s/\|AMP\|/\*/g; }
  1104. }
  1105.  
  1106. if (($inlineformatting eq "comments") || ($inlineformatting eq "both")) {
  1107.     if (($thiscommenttext =~ /\*\*(.*?)\*\*/) || ($thiscommenttext =~ /\\\\(.*?)\\\\/) || ($thiscommenttext =~ /__(.*?)__/)) {
  1108.         $thiscommenttext =~ s/\*\*(.*?)\*\*/<b>$1<\/b>/isg;
  1109.         $thiscommenttext =~ s/\\\\(.*?)\\\\/<i>$1<\/i>/isg;
  1110.         $thiscommenttext =~ s/__(.*?)__/<u>$1<\/u>/isg;
  1111.     }
  1112. }
  1113.  
  1114. if ($striplinesfromcomments eq "yes") {
  1115.     if (($thiscommenttext =~ /\|\*\|/) || ($thiscommenttext =~ /\n/)) {
  1116.         $thiscommenttext =~ s/\|\*\|/ /g;
  1117.         $thiscommenttext =~ s/\n/ /g;
  1118.     }
  1119. } else {
  1120.     if (($thiscommenttext =~ /\|\*\|/) || ($thiscommenttext =~ /\n/)) {
  1121.         $thiscommenttext =~ s/\|\*\|\|\*\|/<PARABREAK>/g;
  1122.         $thiscommenttext =~ s/\n\n/<PARABREAK>/g;
  1123.         $thiscommenttext =~ s/\|\*\|/$gmlinebreaktemplate/g;
  1124.         $thiscommenttext =~ s/\n/$gmlinebreaktemplate/g;
  1125.         $thiscommenttext =~ s/<PARABREAK>/$gmparaseparationtemplate/g;
  1126.     }
  1127. }
  1128.  
  1129. if (($censorenabled eq "both") || ($censorenabled eq "comments")) {
  1130.     unless ($censorlist eq "") {
  1131.         @censoredterms = split(/\|\*\|/, $censorlist);
  1132.         foreach $thisterm (@censoredterms) {
  1133.             unless ($thisterm eq "") {
  1134.                 if ((substr($thisterm, 0, 1) eq "[") && (substr($thisterm, -1, 1) eq "]")) {
  1135.                     $thisrealterm = $thisterm;
  1136.                     $thisrealterm =~ s/\[//g;
  1137.                     $thisrealterm =~ s/\]//g;
  1138.                     $thisrealtermlength = length($thisrealterm);
  1139.                     $thisrealtermreplace = "*" x $thisrealtermlength;
  1140.                     $thisrealtermreplacedash = "-" x $thisrealtermlength;
  1141.                     if ($thiscommenttext =~ m/$thisrealterm/i) {
  1142.                         $thiscommenttext =~ s/\b$thisrealterm\b/$thisrealtermreplace/isg;
  1143.                     }
  1144.                     if ($thiscommentauthor =~ m/$thisrealterm/i) {
  1145.                         $thiscommentauthor =~ s/\b$thisrealterm\b/$thisrealtermreplacedash/isg;
  1146.                     }
  1147.                 } else {
  1148.                     $thisrealtermlength = length($thisterm);
  1149.                     $thisrealtermreplace = "*" x $thisrealtermlength;
  1150.                     $thisrealtermreplacedash = "-" x $thisrealtermlength;
  1151.                     if ($thiscommenttext =~ m/$thisterm/i) {
  1152.                         $thiscommenttext =~ s/\b$thisterm\b/$thisrealtermreplace/isg;
  1153.                     }
  1154.                     if ($thiscommentauthor =~ m/$thisterm/i) {
  1155.                         $thiscommentauthor =~ s/\b$thisterm\b/$thisrealtermreplacedash/isg;
  1156.                     }
  1157.                 }
  1158.             }
  1159.         }
  1160.     }
  1161. }
  1162.  
  1163. $thiscommentfullbody = $gmcommentstemplate;
  1164.  
  1165. if ($thiscommentfullbody =~ m/{{comment/i) {
  1166.     $thiscommentfullbody =~ s/{{commentbody}}/$thiscommenttext/gi;
  1167.     $thiscommentfullbody =~ s/{{commentauthoremail}}/$thiscommentauthoremail/gi;
  1168.     $thiscommentfullbody =~ s/{{commentauthorhomepage}}/$thiscommentauthorhomepage/gi;
  1169.     $thiscommentfullbody =~ s/{{commentauthor}}/$thiscommentauthor/gi;
  1170.     $thiscommentfullbody =~ s/{{commentauthoremailabsolute}}/$thiscommentauthoremailabsolute/gi;
  1171.     $thiscommentfullbody =~ s/{{commentauthorhomepageabsolute}}/$thiscommentauthorhomepageabsolute/gi;
  1172.     $thiscommentfullbody =~ s/{{commentauthorsmartlink}}/$thiscommentauthorsmartlink/gi;
  1173.     $thiscommentfullbody =~ s/{{commentauthorip}}/$thiscommentauthorip/gi;
  1174.     $thiscommentfullbody =~ s/{{commentordernumber}}/$thiscommentordernumber/gi;
  1175. }
  1176.  
  1177. $thiscommentfullbody =~ s/{{day}}/$thiscommentday/gi;
  1178. $thiscommentfullbody =~ s/{{month}}/$thiscommentmonth/gi;
  1179. $thiscommentfullbody =~ s/{{year}}/$thiscommentyear/gi;
  1180. $thiscommentfullbody =~ s/{{hour}}/$thiscommenthour/gi;
  1181. $thiscommentfullbody =~ s/{{minute}}/$thiscommentminute/gi;
  1182. $thiscommentfullbody =~ s/{{second}}/$thiscommentsecond/gi;
  1183. $thiscommentfullbody =~ s/{{dayday}}/$thiscommentdayday/gi;
  1184. $thiscommentfullbody =~ s/{{monthmonth}}/$thiscommentmonthmonth/gi;
  1185. $thiscommentfullbody =~ s/{{yearyear}}/$thiscommentyearyear/gi;
  1186. $thiscommentfullbody =~ s/{{hourhour}}/$thiscommenthourhour/gi;
  1187. $thiscommentfullbody =~ s/{{minuteminute}}/$thiscommentminuteminute/gi;
  1188. $thiscommentfullbody =~ s/{{secondsecond}}/$thiscommentsecondsecond/gi;
  1189. $thiscommentfullbody =~ s/{{weekday}}/$thiscommentweekday/gi;
  1190. $thiscommentfullbody =~ s/{{weekdayshort}}/$thiscommentweekdayshort/gi;
  1191. $thiscommentfullbody =~ s/{{monthword}}/$thiscommentmonthword/gi;
  1192. $thiscommentfullbody =~ s/{{monthwordshort}}/$thiscommentmonthwordshort/gi;
  1193. $thiscommentfullbody =~ s/{{weekdayupper}}/$thiscommentweekdayupper/gi;
  1194. $thiscommentfullbody =~ s/{{monthwordupper}}/$thiscommentmonthwordupper/gi;
  1195. $thiscommentfullbody =~ s/{{weekdaylower}}/$thiscommentweekdaylower/gi;
  1196. $thiscommentfullbody =~ s/{{monthwordlower}}/$thiscommentmonthwordlower/gi;
  1197. $thiscommentfullbody =~ s/{{weekdayuppershort}}/$thiscommentweekdayuppershort/gi;
  1198. $thiscommentfullbody =~ s/{{monthworduppershort}}/$thiscommentmonthworduppershort/gi;
  1199. $thiscommentfullbody =~ s/{{weekdaylowershort}}/$thiscommentweekdaylowershort/gi;
  1200. $thiscommentfullbody =~ s/{{monthwordlowershort}}/$thiscommentmonthwordlowershort/gi;
  1201. $thiscommentfullbody =~ s/{{militaryhour}}/$thiscommentmilitaryhour/gi;
  1202. $thiscommentfullbody =~ s/{{ampm}}/$thiscommentampm/gi;
  1203. $thiscommentfullbody =~ s/{{ampmdot}}/$thiscommentampmdot/gi;
  1204. $thiscommentfullbody =~ s/{{ampmlower}}/$thiscommentampmlower/gi;
  1205. $thiscommentfullbody =~ s/{{ampmdotlower}}/$thiscommentampmdotlower/gi;
  1206.  
  1207. $thisentrycomments .= $thiscommentfullbody;
  1208.  
  1209. if ($commentsorder eq "ascending") { $commentcounter--; } else { $commentcounter++; }
  1210.  
  1211. $commentcountercurrent--;
  1212.  
  1213. } until $commentcountercurrent eq "0";
  1214.  
  1215. }
  1216.  
  1217. # ----------------
  1218. # format the entry
  1219. # ----------------
  1220.  
  1221. sub gm_formatentry {
  1222.  
  1223. my $entrygetreturn = shift;
  1224.  
  1225. $entryreturn = $entrygetreturn;
  1226.  
  1227. # $entryreturn =~ s/\|\*\|/\n/g;
  1228.  
  1229. if (($entryreturn =~ m/{{header}}/i) || ($entryreturn =~ m/{{footer}}/i) || ($entryreturn =~ m/{{sidebar}}/i)) {
  1230.     $entryreturn =~ s/{{header}}/$gmheadertemplate/gi;
  1231.     $entryreturn =~ s/{{footer}}/$gmfootertemplate/gi;
  1232.     $entryreturn =~ s/{{sidebar}}/$gmsidebartemplate/gi;
  1233. }
  1234.  
  1235. if ($entryreturn =~ m/{{custom/i) {
  1236.     $entryreturn =~ s/{{customone}}/$gmcustomonetemplate/gi;
  1237.     $entryreturn =~ s/{{customtwo}}/$gmcustomtwotemplate/gi;
  1238.     $entryreturn =~ s/{{customthree}}/$gmcustomthreetemplate/gi;
  1239.     $entryreturn =~ s/{{customfour}}/$gmcustomfourtemplate/gi;
  1240.     $entryreturn =~ s/{{customfive}}/$gmcustomfivetemplate/gi;
  1241.     $entryreturn =~ s/{{customsix}}/$gmcustomsixtemplate/gi;
  1242.     $entryreturn =~ s/{{customseven}}/$gmcustomseventemplate/gi;
  1243.     $entryreturn =~ s/{{customeight}}/$gmcustomeighttemplate/gi;
  1244.     $entryreturn =~ s/{{customnine}}/$gmcustomninetemplate/gi;
  1245.     $entryreturn =~ s/{{customten}}/$gmcustomtentemplate/gi;
  1246. }
  1247.  
  1248. if ($entryreturn =~ m/{{logarchivelist}}/i) {
  1249.     if ($keepmonthlyarchives eq "no") {
  1250.         $entryreturn =~ s/{{logarchivelist}}//gi;
  1251.     } else {
  1252.         &gm_generatearchiveloglist;
  1253.         $entryreturn =~ s/{{logarchivelist}}/$logarchivelistfinal/gi;
  1254.     }
  1255. }
  1256.  
  1257. if ($generateentrypages eq "yes") {
  1258.     if (($entryreturn =~ m/{{logshortentrylist/i) || ($entryreturn =~ m/{{logmoreentrylist/i) || ($entryreturn =~ m/{{logentrylist/i)) {
  1259.         &gm_generateentryloglist;
  1260.         $entryreturn =~ s/{{logshortentrylist}}/$logshortentrylistfinal/gi;
  1261.         $entryreturn =~ s/{{logmoreentrylist}}/$logmoreentrylistfinal/gi;
  1262.         $entryreturn =~ s/{{logentrylist}}/$logentrylistfinal/gi;
  1263.         $entryreturn =~ s/{{logshortentrylist month}}/$logshortentrylistmonthfinal/gi;
  1264.         $entryreturn =~ s/{{logshortentrylist day}}/$logshortentrylistdayfinal/gi;
  1265.         $entryreturn =~ s/{{logshortentrylist year}}/$logshortentrylistyearfinal/gi;
  1266.         $entryreturn =~ s/{{logmoreentrylist month}}/$logmoreentrylistmonthfinal/gi;
  1267.         $entryreturn =~ s/{{logmoreentrylist day}}/$logmoreentrylistdayfinal/gi;
  1268.         $entryreturn =~ s/{{logmoreentrylist year}}/$logmoreentrylistyearfinal/gi;
  1269.         $entryreturn =~ s/{{logentrylist month}}/$logentrylistmonthfinal/gi;
  1270.         $entryreturn =~ s/{{logentrylist day}}/$logentrylistdayfinal/gi;
  1271.         $entryreturn =~ s/{{logentrylist year}}/$logentrylistyearfinal/gi;
  1272.         $entryreturn =~ s/{{logshortentrylist number}}/$logshortentrylistnumberfinal/gi;
  1273.         $entryreturn =~ s/{{logmoreentrylist number}}/$logmoreentrylistnumberfinal/gi;
  1274.         $entryreturn =~ s/{{logentrylist number}}/$logentrylistnumberfinal/gi;
  1275.         $entryreturn =~ s/{{logshortentrylist firsthalf}}/$logshortentrylistfirsthalffinal/gi;
  1276.         $entryreturn =~ s/{{logshortentrylist secondhalf}}/$logshortentrylistsecondhalffinal/gi;
  1277.         $entryreturn =~ s/{{logmoreentrylist firsthalf}}/$logmoreentrylistfirsthalffinal/gi;
  1278.         $entryreturn =~ s/{{logmoreentrylist secondhalf}}/$logmoreentrylistsecondhalffinal/gi;
  1279.         $entryreturn =~ s/{{logentrylist firsthalf}}/$logentrylistfirsthalffinal/gi;
  1280.         $entryreturn =~ s/{{logentrylist secondhalf}}/$logentrylistsecondhalffinal/gi;
  1281.     }
  1282.     if (($entryreturn =~ m/{{logshortentrylist comments/i) || ($entryreturn =~ m/{{logmoreentrylist comments/i) || ($entryreturn =~ m/{{logentrylist comments/i)) {
  1283.         &gm_generateentryloglistcomments;
  1284.         $entryreturn =~ s/{{logshortentrylist comments}}/$logshortentrylistfinal/gi;
  1285.         $entryreturn =~ s/{{logmoreentrylist comments}}/$logmoreentrylistfinal/gi;
  1286.         $entryreturn =~ s/{{logentrylist comments}}/$logentrylistfinal/gi;
  1287.         $entryreturn =~ s/{{logshortentrylist commentsminimum}}/$logshortminimumentrylistfinal/gi;
  1288.         $entryreturn =~ s/{{logmoreentrylist commentsminimum}}/$logmoreminimumentrylistfinal/gi;
  1289.         $entryreturn =~ s/{{logentrylist commentsminimum}}/$logminimumentrylistfinal/gi;
  1290.         $entryreturn =~ s/{{logshortentrylist commentsnumber}}/$logshortnumberentrylistfinal/gi;
  1291.         $entryreturn =~ s/{{logmoreentrylist commentsnumber}}/$logmorenumberentrylistfinal/gi;
  1292.         $entryreturn =~ s/{{logentrylist commentsnumber}}/$lognumberentrylistfinal/gi;
  1293.     }
  1294.     if (($entryreturn =~ m/{{logshortentrylist /i) || ($entryreturn =~ m/{{logmoreentrylist /i) || ($entryreturn =~ m/{{logentrylist /i)) {
  1295.         open (FUNNYFEETBRAHMA, "gm-authors.cgi") || &gm_dangermouse("Can't read the authors file.  Please make sure that gm-authors.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  1296.         @gettheauthordata = <FUNNYFEETBRAHMA>;
  1297.         close (FUNNYFEETBRAHMA);
  1298.         foreach $gettheauthordataline (@gettheauthordata) {
  1299.             chomp ($gettheauthordataline);
  1300.             @gettheauthorinfo = split (/\|/, $gettheauthordataline);
  1301.             $thisentryloglistauthor = $gettheauthorinfo[0];
  1302.             &gm_generateentryloglistauthor;
  1303.             $entryreturn =~ s/{{logshortentrylist $thisentryloglistauthor}}/$logshortentrylistfinal/gi;
  1304.             $entryreturn =~ s/{{logmoreentrylist $thisentryloglistauthor}}/$logmoreentrylistfinal/gi;
  1305.             $entryreturn =~ s/{{logentrylist $thisentryloglistauthor}}/$logentrylistfinal/gi;
  1306.         }
  1307.     }
  1308. }
  1309.  
  1310. if (($entryreturn =~ m/{{calendar}}/i) || ($entryreturn =~ m/{{calendarweek}}/i)) {
  1311.     $usethisentryweekdaynumber = $thisentryweekdaynumber;
  1312.     $usethisentryday = $thisentryday;
  1313.     $usethisentrymonth = $thisentrymonth;
  1314.     $usethisentrymonthmonth = $thisentrymonthmonth;
  1315.     $usethisentrymonthword = $thisentrymonthword;
  1316.     $usethisentryyear = $thisentryyear;
  1317.     $usethisentryyearyear = $thisentryyearyear;
  1318.     &gm_generatecalendar;
  1319.     $entryreturn =~ s/{{calendar}}/$calendarfull/gi;
  1320.     $entryreturn =~ s/{{calendarweek}}/$calendarweekfull/gi;
  1321. }
  1322.  
  1323. if ($entryreturn =~ m/{{calendar (..)\/(..)}}/i) {
  1324.  
  1325.     until ($entryreturn !~ m/{{calendar (..)\/(..)}}/ig) {
  1326.  
  1327.         $usethisentrymonthmonth = $1;
  1328.         $usethisentryyear = $2;
  1329.  
  1330.         open (FUNNYFEETKALI, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  1331.         @loglistloglines = <FUNNYFEETKALI>;
  1332.         close (FUNNYFEETKALI);
  1333.  
  1334.         $gotthecalendarmonth = "no";
  1335.  
  1336.         foreach $thisloglistline (@loglistloglines) {
  1337.             ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  1338.             &gm_getloglistvariables;
  1339.             if (($loglistmonthmonth eq $usethisentrymonthmonth) && ($loglistyear eq $usethisentryyear) && ($gotthecalendarmonth eq "no")) {
  1340.                 $usethisentryweekdaynumber = $loglistentryweekdaynumber;
  1341.                 $usethisentryday = $loglistday;
  1342.                 $usethisentrymonth = $loglistmonth;
  1343.                 $usethisentrymonthword = $loglistmonthword;
  1344.                 $usethisentryyearyear = $loglistyearyear;
  1345.                 &gm_generatecalendar;
  1346.                 $entryreturn =~ s/{{calendar $usethisentrymonthmonth\/$usethisentryyear}}/$calendarfull/gi;
  1347.                 $gotthecalendarmonth = "yes";
  1348.             }
  1349.         }
  1350.  
  1351.         if ($entryreturn =~ m/{{calendar $usethisentrymonthmonth\/$usethisentryyear}}/i) {
  1352.             $entryreturn =~ s/{{calendar $usethisentrymonthmonth\/$usethisentryyear}}//gi;
  1353.         }
  1354.  
  1355.     }
  1356.  
  1357. }
  1358.  
  1359. if (($entryreturn =~ m/{{commentdivider}}/i) || ($entryreturn =~ m/{{entrycommentsform}}/i) || ($entryreturn =~ m/{{entrykarmaform}}/i) || ($entryreturn =~ m/{{searchform}}/i)) {
  1360.     $entryreturn =~ s/{{commentdivider}}/$thisentrycommentdivider/gi;
  1361.     $entryreturn =~ s/{{entrycommentsform}}/$thisentrycommentsform/gi;
  1362.     $entryreturn =~ s/{{entrykarmaform}}/$thisentrykarmaform/gi;
  1363.     $entryreturn =~ s/{{searchform}}/$thisentrysearchform/gi;
  1364. }
  1365.  
  1366. if ($entryreturn =~ m/{{entry/i) {
  1367.     $entryreturn =~ s/{{entrymainbody}}/$thisentrymainbody/gi;
  1368.     $entryreturn =~ s/{{entrymorebody}}/$thisentrymorebody/gi;
  1369.     $entryreturn =~ s/{{entrycomments}}/$thisentrycomments/gi;
  1370.     if ($entryreturn =~ m/{{entrymainbodyfirstwords (\d+)}}/i) {
  1371.         until ($entryreturn !~ m/{{entrymainbodyfirstwords (\d+)}}/isg) {
  1372.             $firstwordscount = $1;
  1373.             $grabmainbodywords = $thisentrymainbody;
  1374.             if ($grabmainbodywords =~ m/{{link/i) {
  1375.                 $grabmainbodywords =~ s/({{linkmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  1376.                 $grabmainbodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  1377.                 $grabmainbodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  1378. ###########################################################
  1379. # 9/2/2001 - CHERYL LAMBERT
  1380. # ADDED {{linkblank}} TEMPLATE VARIABLE SO THAT I CAN USE target="_blank" TO OPEN NEW WINDOWS
  1381.         $grabmainbodywords =~ s/({{linkblankmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  1382.         $grabmainbodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  1383.         $grabmainbodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  1384. ###########################################################                
  1385.             }
  1386.             if ($grabmainbodywords =~ m/{{email/i) {
  1387.                 $grabmainbodywords =~ s/({{emailmo) (\S+\@\S+?) (.+?)(\|)(.+?)(}})/$3/isg;
  1388.                 $grabmainbodywords =~ s/({{email) (\S+\@\S+?)(}})/$2/isg;
  1389.                 $grabmainbodywords =~ s/({{email) (\S+\@\S+?) (.+?)(}})/$3/isg;
  1390.             }
  1391.             $grabmainbodywords =~ s/<([^>]|\n)*>/ /g;
  1392.             $grabmainbodywords =~ s/{{(.*?)}}/ /g;
  1393.             $grabmainbodywords =~ s/\n/ /g;
  1394.             $grabmainbodywords =~ s/\r/ /g;
  1395.             $grabmainbodywords =~ s/\|\*\|/ /g;
  1396.             $grabmainbodywords =~ s/^\s+//;
  1397.             $grabmainbodywords =~ s/\s+$//;
  1398.             $grabmainbodywords =~ s/\s{2,}/ /g;
  1399.             @grabmainbodywordslist = split (/ /, $grabmainbodywords);
  1400.             $countwordsfromhere = 0;
  1401.             (@finalmainbodywordslist, @finalmainbodywordslist = ());
  1402.             if ($firstwordscount < 1) { $firstwordscount = 1; }
  1403.             do {
  1404.                 $finalmainbodywordslist[$countwordsfromhere] = $grabmainbodywordslist[$countwordsfromhere];
  1405.                 $countwordsfromhere++;
  1406.             } until $countwordsfromhere eq $firstwordscount;
  1407.             $finalmainbodyfirstwords = join (" ", @finalmainbodywordslist);
  1408.             $finalmainbodyfirstwords =~ s/^\s+//;
  1409.             $finalmainbodyfirstwords =~ s/\s+$//;
  1410.             $finalmainbodyfirstwords =~ s/\s{2,}//g;
  1411.             if (substr($finalmainbodyfirstwords, -1) =~ /\W/) { chop($finalmainbodyfirstwords); }
  1412.             if (substr($finalmainbodyfirstwords, -1) eq / /) { chop($finalmainbodyfirstwords); }
  1413.             $entryreturn =~ s/{{entrymainbodyfirstwords ($firstwordscount)}}/$finalmainbodyfirstwords/isg;
  1414.         }
  1415.     }
  1416.     if ($entryreturn =~ m/{{entrymorebodyfirstwords (\d+)}}/i) {
  1417.         until ($entryreturn !~ m/{{entrymorebodyfirstwords (\d+)}}/isg) {
  1418.             $firstwordscount = $1;
  1419.             if ($thisentrymorebody eq "") {
  1420.                 $entryreturn =~ s/{{entrymorebodyfirstwords ($firstwordscount)}}//isg;
  1421.             } else {
  1422.                 $grabmorebodywords = $thisentrymorebody;
  1423.                 if ($grabmorebodywords =~ m/{{link/i) {
  1424.                     $grabmorebodywords =~ s/({{linkmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  1425.                     $grabmorebodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  1426.                     $grabmorebodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  1427. ###########################################################
  1428. # 9/2/2001 - CHERYL LAMBERT
  1429. # ADDED {{linkblank}} TEMPLATE VARIABLE SO THAT I CAN USE target="_blank" TO OPEN NEW WINDOWS
  1430.           $grabmorebodywords =~ s/({{linkblankmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  1431.           $grabmorebodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  1432.           $grabmorebodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  1433. ###########################################################                    
  1434.                 }
  1435.                 if ($grabmorebodywords =~ m/{{email/i) {
  1436.                     $grabmorebodywords =~ s/({{emailmo) (\S+\@\S+?) (.+?)(\|)(.+?)(}})/$3/isg;
  1437.                     $grabmorebodywords =~ s/({{email) (\S+\@\S+?)(}})/$2/isg;
  1438.                     $grabmorebodywords =~ s/({{email) (\S+\@\S+?) (.+?)(}})/$3/isg;
  1439.                 }
  1440.                 $grabmorebodywords =~ s/<([^>]|\n)*>/ /g;
  1441.                 $grabmorebodywords =~ s/{{(.*?)}}/ /g;
  1442.                 $grabmorebodywords =~ s/\n/ /g;
  1443.                 $grabmorebodywords =~ s/\r/ /g;
  1444.                 $grabmorebodywords =~ s/\|\*\|/ /g;
  1445.                 $grabmorebodywords =~ s/^\s+//;
  1446.                 $grabmorebodywords =~ s/\s+$//;
  1447.                 $grabmorebodywords =~ s/\s{2,}/ /g;
  1448.                 @grabmorebodywordslist = split (/ /, $grabmorebodywords);
  1449.                 $countwordsfromhere = 0;
  1450.                 (@finalmorebodywordslist, @finalmorebodywordslist = ());
  1451.                 if ($firstwordscount < 1) { $firstwordscount = 1; }
  1452.                 do {
  1453.                     $finalmorebodywordslist[$countwordsfromhere] = $grabmorebodywordslist[$countwordsfromhere];
  1454.                     $countwordsfromhere++;
  1455.                 } until $countwordsfromhere eq $firstwordscount;
  1456.                 $finalmorebodyfirstwords = join (" ", @finalmorebodywordslist);
  1457.                 $finalmorebodyfirstwords =~ s/^\s+//;
  1458.                 $finalmorebodyfirstwords =~ s/\s+$//;
  1459.                 $finalmorebodyfirstwords =~ s/\s{2,}//g;
  1460.                 if (substr($finalmorebodyfirstwords, -1) =~ /\W/) { chop($finalmorebodyfirstwords); }
  1461.                 if (substr($finalmorebodyfirstwords, -1) eq / /) { chop($finalmorebodyfirstwords); }
  1462.                 $entryreturn =~ s/{{entrymorebodyfirstwords ($firstwordscount)}}/$finalmorebodyfirstwords/isg;
  1463.             }
  1464.         }
  1465.     }
  1466. }
  1467.  
  1468. if (($entryreturn =~ m/link}}/i) || ($entryreturn =~ m/{{morepreface}}/i)) {
  1469.     $entryreturn =~ s/{{morepreface}}/$thisentrymorepreface/gi;
  1470.     $entryreturn =~ s/{{morelink}}/$thisentrymorelink/gi;
  1471.     $entryreturn =~ s/{{karmalink}}/$thisentrykarmalink/gi;
  1472.     $entryreturn =~ s/{{commentslink}}/$thisentrycommentslink/gi;
  1473.     $entryreturn =~ s/{{pagelink}}/$thisentrypagelink/gi;
  1474.     $entryreturn =~ s/{{pageindexlink}}/$thisentrypageindexlink/gi;
  1475.     $entryreturn =~ s/{{pagearchiveindexlink}}/$thisentrypagearchiveindexlink/gi;
  1476.     $entryreturn =~ s/{{pagearchivelogindexlink}}/$thisentrypagearchivelogindexlink/gi;
  1477.     $entryreturn =~ s/{{pagesmartindexlink}}/$thisentrypagesmartindexlink/gi;
  1478.     $entryreturn =~ s/{{commentspostlink}}/$thisentrycommentspostlink/gi;
  1479.     $entryreturn =~ s/{{authorsmartlink}}/$thisentryauthorsmartlink/gi;
  1480. }
  1481.  
  1482. if (($entryreturn =~ m/karma}}/i) || ($entryreturn =~ m/karmalink}}/i)) {
  1483.     $entryreturn =~ s/{{positivekarmalink}}/$thisentrypositivekarmalink/gi;
  1484.     $entryreturn =~ s/{{negativekarmalink}}/$thisentrynegativekarmalink/gi;
  1485.     $entryreturn =~ s/{{positivekarma}}/$thisentrypositivekarma/gi;
  1486.     $entryreturn =~ s/{{negativekarma}}/$thisentrynegativekarma/gi;
  1487.     $entryreturn =~ s/{{totalkarma}}/$thisentrytotalkarma/gi;
  1488. }
  1489.  
  1490. if ($entryreturn =~ m/{{entry/i) {
  1491.     $entryreturn =~ s/{{entrysubject}}/$thisentrysubject/gi;
  1492.     ###########################################################
  1493.     # 9/3/2001 - CHERYL LAMBERT
  1494.     # ADDED 1 TEMPLATE VARIABLE SO THAT I CAN STRIP THE HTML CODE FROM THE ENTRYSUBJECT
  1495.     # WHEN IT IS USED IN THE <TITLE> TAG
  1496.         my $thisentrysubjectstripped = $thisentrysubject;
  1497.         $thisentrysubjectstripped =~ s/<.*?>//gi;
  1498.         $thisentrysubjectstripped =~ s/<\/.*?>//gi;
  1499.         $entryreturn =~ s/{{entrysubjectstripped}}/$thisentrysubjectstripped/gi;
  1500.     ###########################################################
  1501.     $entryreturn =~ s/{{entrynumber}}/$thisentrynumber/gi;
  1502.     $entryreturn =~ s/{{entrynumberpadded}}/$thisentrynumberpadded/gi;
  1503. }
  1504.  
  1505. if ($entryreturn =~ m/{{author/i) {
  1506.     $entryreturn =~ s/{{author}}/$thisentryauthor/gi;
  1507.     $entryreturn =~ s/{{authoremail}}/$thisentryauthoremail/gi;
  1508.     $entryreturn =~ s/{{authorhomepage}}/$thisentryauthorhomepage/gi;
  1509.     $entryreturn =~ s/{{authorentrycount}}/$thisentryauthorentrycount/gi;
  1510. }
  1511.  
  1512. if (($entryreturn =~ m/{{authoremail /i) || ($entryreturn =~ m/{{authorhomepage /i) || ($entryreturn =~ m/{{authorentrycount /i) || ($entryreturn =~ m/{{authoremaillink /i) || ($entryreturn =~ m/{{authorhomepagelink /i) || ($entryreturn =~ m/{{authorsmartlink /i)) {
  1513.     &gm_generateexternalauthorvariables;
  1514. }
  1515.  
  1516. if ($entryreturn =~ m/{{comments/i) {
  1517.     $entryreturn =~ s/{{commentstatussmart}}/$thisentrycommentstatussmart/gi;
  1518.     $entryreturn =~ s/{{commentstatussmartupper}}/$thisentrycommentstatussmartupper/gi;
  1519.     $entryreturn =~ s/{{commentstatussmartlower}}/$thisentrycommentstatussmartlower/gi;
  1520.     $entryreturn =~ s/{{commentsnumber}}/$thisentrycommentsnumber/gi;
  1521. }
  1522.  
  1523. if (($entryreturn =~ m/{{day/i) || ($entryreturn =~ m/{{month/i) || ($entryreturn =~ m/{{year/i) || ($entryreturn =~ m/{{hour/i) || ($entryreturn =~ m/{{minute/i) || ($entryreturn =~ m/{{second/i) || ($entryreturn =~ m/{{weekday/i) || ($entryreturn =~ m/{{militaryhour}}/i) || ($entryreturn =~ m/{{ampm/i) || ($entryreturn =~ m/{{timezone}}/i)) {
  1524.     $entryreturn =~ s/{{day}}/$thisentryday/gi;
  1525.     $entryreturn =~ s/{{month}}/$thisentrymonth/gi;
  1526.     $entryreturn =~ s/{{year}}/$thisentryyear/gi;
  1527.     $entryreturn =~ s/{{hour}}/$thisentryhour/gi;
  1528.     $entryreturn =~ s/{{minute}}/$thisentryminute/gi;
  1529.     $entryreturn =~ s/{{second}}/$thisentrysecond/gi;
  1530.     $entryreturn =~ s/{{dayday}}/$thisentrydayday/gi;
  1531.     $entryreturn =~ s/{{monthmonth}}/$thisentrymonthmonth/gi;
  1532.     $entryreturn =~ s/{{yearyear}}/$thisentryyearyear/gi;
  1533.     $entryreturn =~ s/{{hourhour}}/$thisentryhourhour/gi;
  1534.     $entryreturn =~ s/{{minuteminute}}/$thisentryminuteminute/gi;
  1535.     $entryreturn =~ s/{{secondsecond}}/$thisentrysecondsecond/gi;
  1536.     $entryreturn =~ s/{{weekday}}/$thisentryweekday/gi;
  1537.     $entryreturn =~ s/{{weekdayshort}}/$thisentryweekdayshort/gi;    
  1538.     $entryreturn =~ s/{{monthword}}/$thisentrymonthword/gi;
  1539.     $entryreturn =~ s/{{monthwordshort}}/$thisentrymonthwordshort/gi;    
  1540.     $entryreturn =~ s/{{weekdayupper}}/$thisentryweekdayupper/gi;
  1541.     $entryreturn =~ s/{{monthwordupper}}/$thisentrymonthwordupper/gi;
  1542.     $entryreturn =~ s/{{weekdaylower}}/$thisentryweekdaylower/gi;
  1543.     $entryreturn =~ s/{{monthwordlower}}/$thisentrymonthwordlower/gi;
  1544.     $entryreturn =~ s/{{weekdayuppershort}}/$thisentryweekdayuppershort/gi;
  1545.     $entryreturn =~ s/{{monthworduppershort}}/$thisentrymonthworduppershort/gi;
  1546.     $entryreturn =~ s/{{weekdaylowershort}}/$thisentryweekdaylowershort/gi;
  1547.     $entryreturn =~ s/{{monthwordlowershort}}/$thisentrymonthwordlowershort/gi;
  1548.     $entryreturn =~ s/{{militaryhour}}/$thisentrymilitaryhour/gi;
  1549.     $entryreturn =~ s/{{ampm}}/$thisentryampm/gi;
  1550.     $entryreturn =~ s/{{ampmdot}}/$thisentryampmdot/gi;
  1551.     $entryreturn =~ s/{{ampmlower}}/$thisentryampmlower/gi;
  1552.     $entryreturn =~ s/{{ampmdotlower}}/$thisentryampmdotlower/gi;
  1553.     $entryreturn =~ s/{{timezone}}/$timezone/gi;
  1554. }
  1555.  
  1556. if (($entryreturn =~ m/{{weekbeginning/i) || ($entryreturn =~ m/{{weekending/i)) {
  1557.     $entryreturn =~ s/{{weekbeginningday}}/$thisentryweekbeginningday/gi;
  1558.     $entryreturn =~ s/{{weekbeginningdayday}}/$thisentryweekbeginningdayday/gi;
  1559.     $entryreturn =~ s/{{weekbeginningmonth}}/$thisentryweekbeginningmonth/gi;
  1560.     $entryreturn =~ s/{{weekbeginningmonthmonth}}/$thisentryweekbeginningmonthmonth/gi;
  1561.     $entryreturn =~ s/{{weekbeginningyear}}/$thisentryweekbeginningyear/gi;
  1562.     $entryreturn =~ s/{{weekbeginningyearyear}}/$thisentryweekbeginningyearyear/gi;
  1563.     $entryreturn =~ s/{{weekbeginningweekday}}/$thisentryweekbeginningweekday/gi;
  1564.     $entryreturn =~ s/{{weekbeginningweekdayshort}}/$thisentryweekbeginningweekdayshort/gi;
  1565.     $entryreturn =~ s/{{weekbeginningmonthword}}/$thisentryweekbeginningmonthword/gi;
  1566.     $entryreturn =~ s/{{weekbeginningmonthwordshort}}/$thisentryweekbeginningmonthwordshort/gi;
  1567.     $entryreturn =~ s/{{weekbeginningweekdayupper}}/$thisentryweekbeginningweekdayupper/gi;
  1568.     $entryreturn =~ s/{{weekbeginningmonthwordupper}}/$thisentryweekbeginningmonthwordupper/gi;
  1569.     $entryreturn =~ s/{{weekbeginningweekdaylower}}/$thisentryweekbeginningweekdaylower/gi;
  1570.     $entryreturn =~ s/{{weekbeginningmonthwordlower}}/$thisentryweekbeginningmonthwordlower/gi;
  1571.     $entryreturn =~ s/{{weekbeginningweekdayuppershort}}/$thisentryweekbeginningweekdayuppershort/gi;
  1572.     $entryreturn =~ s/{{weekbeginningmonthworduppershort}}/$thisentryweekbeginningmonthworduppershort/gi;
  1573.     $entryreturn =~ s/{{weekbeginningweekdaylowershort}}/$thisentryweekbeginningweekdaylowershort/gi;
  1574.     $entryreturn =~ s/{{weekbeginningmonthwordlowershort}}/$thisentryweekbeginningmonthwordlowershort/gi;
  1575.     $entryreturn =~ s/{{weekendingday}}/$thisentryweekendingday/gi;
  1576.     $entryreturn =~ s/{{weekendingdayday}}/$thisentryweekendingdayday/gi;
  1577.     $entryreturn =~ s/{{weekendingmonth}}/$thisentryweekendingmonth/gi;
  1578.     $entryreturn =~ s/{{weekendingmonthmonth}}/$thisentryweekendingmonthmonth/gi;
  1579.     $entryreturn =~ s/{{weekendingyear}}/$thisentryweekendingyear/gi;
  1580.     $entryreturn =~ s/{{weekendingyearyear}}/$thisentryweekendingyearyear/gi;
  1581.     $entryreturn =~ s/{{weekendingweekday}}/$thisentryweekendingweekday/gi;
  1582.     $entryreturn =~ s/{{weekendingweekdayshort}}/$thisentryweekendingweekdayshort/gi;    
  1583.     $entryreturn =~ s/{{weekendingmonthword}}/$thisentryweekendingmonthword/gi;
  1584.     $entryreturn =~ s/{{weekendingmonthwordshort}}/$thisentryweekendingmonthwordshort/gi;    
  1585.     $entryreturn =~ s/{{weekendingweekdayupper}}/$thisentryweekendingweekdayupper/gi;
  1586.     $entryreturn =~ s/{{weekendingmonthwordupper}}/$thisentryweekendingmonthwordupper/gi;
  1587.     $entryreturn =~ s/{{weekendingweekdaylower}}/$thisentryweekendingweekdaylower/gi;
  1588.     $entryreturn =~ s/{{weekendingmonthwordlower}}/$thisentryweekendingmonthwordlower/gi;
  1589.     $entryreturn =~ s/{{weekendingweekdayuppershort}}/$thisentryweekendingweekdayuppershort/gi;
  1590.     $entryreturn =~ s/{{weekendingmonthworduppershort}}/$thisentryweekendingmonthworduppershort/gi;
  1591.     $entryreturn =~ s/{{weekendingweekdaylowershort}}/$thisentryweekendingweekdaylowershort/gi;
  1592.     $entryreturn =~ s/{{weekendingmonthwordlowershort}}/$thisentryweekendingmonthwordlowershort/gi;
  1593. }
  1594.  
  1595. if ($entryreturn =~ m/{{link/i) {
  1596.     $entryreturn =~ s/({{linkmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/<a href="$2$3" onmouseover="window.status='$6';return true" onmouseout="window.status='';return true">$4<\/a>/isg;
  1597.     $entryreturn =~ s/({{link) (http|https|ftp)(:\/\/\S+?)(}})/<a href="$2$3">$2$3<\/a>/isg;
  1598.     $entryreturn =~ s/({{link) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/<a href="$2$3">$4<\/a>/isg;
  1599.     ###########################################################
  1600.     # 9/2/2001 - CHERYL LAMBERT
  1601.     # ADDED {{linkblank}} TEMPLATE VARIABLE SO THAT I CAN USE target="_blank" TO OPEN NEW WINDOWS
  1602.     $entryreturn =~ s/({{linkblankmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/<A HREF="$2$3" onMouseOver="window.status='$6';return true" onMouseOut="window.status='';return true" target="_blank">$4<\/A>/isg;
  1603.     $entryreturn =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?)(}})/<A HREF="$2$3" target="_blank">$2$3<\/A>/isg;
  1604.     $entryreturn =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/<A HREF="$2$3" target="_blank">$4<\/A>/isg;
  1605.     ###########################################################
  1606. }
  1607.  
  1608. if ($entryreturn =~ m/{{email/i) {
  1609.     $entryreturn =~ s/({{emailmo) (\S+\@\S+?) (.+?)(\|)(.+?)(}})/<a href="mailto:$2" onmouseover="window.status='$5';return true" onmouseout="window.status='';return true">$3<\/>/isg;
  1610.     $entryreturn =~ s/({{email) (\S+\@\S+?)(}})/<a href="mailto:$2">$2<\/a>/isg;
  1611.     $entryreturn =~ s/({{email) (\S+\@\S+?) (.+?)(}})/<a href="mailto:$2">$3<\/a>/isg;
  1612. }
  1613.  
  1614. if ($entryreturn =~ m/{{popup (\S+) (.+?) (\d+)x(\d+)}}/i) {
  1615.     until ($entryreturn !~ m/{{popup (\S+) (.+?) (\d+)x(\d+)}}/isg) {
  1616.  
  1617.         $popupfile = $1;
  1618.         $popuptitle = $2;
  1619.         $popupwidth = $3;
  1620.         $popupheight = $4;
  1621.         $popuphtmlfile = $1;
  1622.         $popuphtmlfile =~ s/\.(\S+)$//;
  1623.         $popuphtmlfile .= ".$entrysuffix";
  1624.         $popuppage = $gmpopuppagetemplate;
  1625.         $popupcode = $gmpopupcodetemplate;
  1626.         $popuppage =~ s/{{popupfile}}/$popupfile/gi;
  1627.         $popuppage =~ s/{{popuphtmlfile}}/$popuphtmlfile/gi;
  1628.         $popuppage =~ s/{{popuptitle}}/$popuptitle/gi;
  1629.         $popuppage =~ s/{{popupwidth}}/$popupwidth/gi;
  1630.         $popuppage =~ s/{{popupheight}}/$popupheight/gi;
  1631.         $popupcode =~ s/{{popupfile}}/$popupfile/gi;
  1632.         $popupcode =~ s/{{popuphtmlfile}}/$popuphtmlfile/gi;
  1633.         $popupcode =~ s/{{popuptitle}}/$popuptitle/gi;
  1634.         $popupcode =~ s/{{popupwidth}}/$popupwidth/gi;
  1635.         $popupcode =~ s/{{popupheight}}/$popupheight/gi;
  1636.         $popuppage =~ s/{{cgiwebpath}}/$cgiwebpath/gi;
  1637.         $popuppage =~ s/{{entrieswebpath}}/$EntriesWebPath/gi;
  1638.         $popuppage =~ s/{{logwebpath}}/$LogWebPath/gi;
  1639.  
  1640.         open (FUNNYFEETWAGS, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  1641.         @loglistloglines = <FUNNYFEETWAGS>;
  1642.         close (FUNNYFEETWAGS);
  1643.  
  1644.         $foundpopupmatch = "no";
  1645.  
  1646.         foreach $thisloglistline (@loglistloglines) {
  1647.             chomp ($thisloglistline);
  1648.             ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  1649.             if (($thisentrynumber eq $loglistnumber) && ($foundpopupmatch eq "no")) {
  1650.                 &gm_getloglistvariables;
  1651.                 $foundpopupmatch = "yes";
  1652.             }
  1653.         }
  1654.  
  1655.         $listsubsub = $popuppage;
  1656.         &entrylistsubsub;
  1657.  
  1658.         open (POPUPVIDEO, ">$EntriesPath/$popuphtmlfile") || &gm_dangermouse("Can't write to $EntriesPath/$popuphtmlfile.  Please make sure your entries/archives directory is correctly set and is CHMODed to 777; also, try running Diagnostics & Repair in the Configuration screen.");
  1659.         print POPUPVIDEO $listsubsub;
  1660.         close (POPUPVIDEO);
  1661.  
  1662.         $listsubsub = $popupcode;
  1663.         &entrylistsubsub;
  1664.  
  1665.         $entryreturn =~ s/{{popup $popupfile $popuptitle ($popupwidth)x($popupheight)}}/$listsubsub/isg;
  1666.  
  1667.     }
  1668. }
  1669.  
  1670. if (($entryreturn =~ m/{{previous/i) || ($entryreturn =~ m/{{next/i)) {
  1671.  
  1672.     open (FUNNYFEETSCRATCH, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  1673.     @checkingloglistloglines = <FUNNYFEETSCRATCH>;
  1674.     close (FUNNYFEETSCRATCH);
  1675.  
  1676.     $entryreturn =~ s/{{previousmore/{{moreprevious/isg;
  1677.     $entryreturn =~ s/{{nextmore/{{morenext/isg;
  1678.  
  1679.     if ($thisentrynumber ne "1") {
  1680.         $thispreviousentrynumber = $thisentrynumber - 1;
  1681.         $foundregular = "no";
  1682.         $foundmore = "no";
  1683.         $foundboth = "no";
  1684.         do {
  1685.  
  1686.             foreach $thisloglistline (@checkingloglistloglines) {
  1687.                 chomp ($thisloglistline);
  1688.                 ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  1689.                 if (($thispreviousentrynumber eq $loglistnumber) && ($loglistnumber < $thisentrynumber) && ($foundregular eq "no") && ($loglistopenstatus ne "C")) {
  1690.                     $entryreturn =~ s/{{previouslink}}/$gmpreviouslinktemplate/isg;
  1691.                     &gm_getloglistvariables;
  1692.                     $listsubsub = $entryreturn;
  1693.                     $listsubsub =~ s/{{previous/{{/isg;
  1694.                     &entrylistsubsub;
  1695.                     $entryreturn = $listsubsub;
  1696.                     $foundregular = "yes";
  1697.                 }
  1698.                 if (($thispreviousentrynumber eq $loglistnumber) && ($loglistmorestatus eq "Y") && ($loglistnumber < $thisentrynumber) && ($foundmore eq "no") && ($loglistopenstatus ne "C")) {
  1699.                     $entryreturn =~ s/{{morepreviouslink}}/$gmpreviousmorelinktemplate/isg;
  1700.                     $entryreturn =~ s/{{previousmore/{{moreprevious/isg;
  1701.                     &gm_getloglistvariables;
  1702.                     $listsubsub = $entryreturn;
  1703.                     $listsubsub =~ s/{{moreprevious/{{/isg;
  1704.                     &entrylistsubsub;
  1705.                     $entryreturn = $listsubsub;
  1706.                     $foundmore = "yes";
  1707.                 }
  1708.             }
  1709.  
  1710.             if (($foundregular eq "yes") && ($foundmore eq "yes")) { $foundboth = "yes"; }
  1711.             if ($thispreviousentrynumber eq "1") { $foundboth = "yes"; }
  1712.             $thispreviousentrynumber--;
  1713.  
  1714.         } until $foundboth eq "yes";
  1715.     }
  1716.  
  1717.     if ($thisentrynumber ne $newentrynumber) {
  1718.         @checkingloglistloglines = reverse @checkingloglistloglines;
  1719.         $thisnextentrynumber = $thisentrynumber + 1;
  1720.         $foundregular = "no";
  1721.         $foundmore = "no";
  1722.         $foundboth = "no";
  1723.         do {
  1724.  
  1725.             foreach $thisloglistline (@checkingloglistloglines) {
  1726.                 chomp ($thisloglistline);
  1727.                 ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  1728.                 if (($thisnextentrynumber eq $loglistnumber) && ($loglistnumber > $thisentrynumber) && ($foundregular eq "no") && ($loglistopenstatus ne "C")) {
  1729.                     $entryreturn =~ s/{{nextlink}}/$gmnextlinktemplate/isg;
  1730.                     &gm_getloglistvariables;
  1731.                     $listsubsub = $entryreturn;
  1732.                     $listsubsub =~ s/{{next/{{/isg;
  1733.                     &entrylistsubsub;
  1734.                     $entryreturn = $listsubsub;
  1735.                     $foundregular = "yes";
  1736.                 }
  1737.                 if (($thisnextentrynumber eq $loglistnumber) && ($loglistmorestatus eq "Y") && ($loglistnumber > $thisentrynumber) && ($foundmore eq "no") && ($loglistopenstatus ne "C")) {
  1738.                     $entryreturn =~ s/{{morenextlink}}/$gmnextmorelinktemplate/isg;
  1739.                     $entryreturn =~ s/{{nextmore/{{morenext/isg;
  1740.                     &gm_getloglistvariables;
  1741.                     $listsubsub = $entryreturn;
  1742.                     $listsubsub =~ s/{{morenext/{{/isg;
  1743.                     &entrylistsubsub;
  1744.                     $entryreturn = $listsubsub;
  1745.                     $foundmore = "yes";
  1746.                 }
  1747.             }
  1748.  
  1749.             if (($foundregular eq "yes") && ($foundmore eq "yes")) { $foundboth = "yes"; }
  1750.             if ($thisnextentrynumber eq $newentrynumber) { $foundboth = "yes"; }
  1751.             $thisnextentrynumber++;
  1752.  
  1753.         } until $foundboth eq "yes";
  1754.     }
  1755.  
  1756.     $entryreturn =~ s/{{previouspagelink}}/$thisentrypagesmartindexlink/isg;
  1757.     $entryreturn =~ s/{{nextpagelink}}/$thisentrypagesmartindexlink/isg;
  1758.     $entryreturn =~ s/{{previousmorepagelink}}/$thisentrypagesmartindexlink/isg;
  1759.     $entryreturn =~ s/{{nextmorepagelink}}/$thisentrypagesmartindexlink/isg;
  1760.     $entryreturn =~ s/{{morepreviouspagelink}}/$thisentrypagesmartindexlink/isg;
  1761.     $entryreturn =~ s/{{morenextpagelink}}/$thisentrypagesmartindexlink/isg;
  1762.     $entryreturn =~ s/{{previouslink}}//isg;
  1763.     $entryreturn =~ s/{{nextlink}}//isg;
  1764.  
  1765.     if (($entryreturn =~ m/{{previous/i) || ($entryreturn =~ m/{{next/i)) {
  1766.         foreach $thisloglistline (@checkingloglistloglines) {
  1767.             chomp ($thisloglistline);
  1768.             ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  1769.             if ($loglistnumber eq $thisentrynumber) {
  1770.                 &gm_getloglistvariables;
  1771.                 $listsubsub = $entryreturn;
  1772.                 $listsubsub =~ s/{{previous/{{/isg;
  1773.                 $listsubsub =~ s/{{next/{{/isg;
  1774.                 &entrylistsubsub;
  1775.                 $entryreturn = $listsubsub;
  1776.             }
  1777.         }
  1778.     }
  1779.  
  1780.     $entryreturn =~ s/{{morepagelink}}/$thisentrypagesmartindexlink/isg;
  1781.  
  1782. }
  1783.  
  1784.  
  1785. if ($entryreturn =~ m/window.status='(.*?)';/i) {
  1786.     $entryreturn =~ s/\(/GMLEFTPARENTHESES/g;
  1787.     $entryreturn =~ s/\)/GMRIGHTPARENTHESES/g;
  1788.     $entryreturn =~ s/\?/GMQUESTIONMARK/g;
  1789.     $entryreturn =~ s/\+/GMPLUS/g;
  1790.     until ($entryreturn !~ m/window.status='(.*?)';/ig) {
  1791.         $windowstatusorigstring = $1;
  1792.         $windowstatusmiddlenew = $1;
  1793.         $windowstatusmiddlenew =~ s#'#\\'#isg;
  1794.         $windowstatusmiddlenew =~ s#"#\\'#isg;
  1795.         $entryreturn =~ s/window.status='$windowstatusorigstring';/WSPLACEHOLDER='$windowstatusmiddlenew';/isg;
  1796.     }
  1797.     $entryreturn =~ s/WSPLACEHOLDER=/window.status=/isg;
  1798.     $entryreturn =~ s/GMLEFTPARENTHESES/\(/g;
  1799.     $entryreturn =~ s/GMRIGHTPARENTHESES/\)/g;
  1800.     $entryreturn =~ s/GMQUESTIONMARK/\?/g;
  1801.     $entryreturn =~ s/GMPLUS/\+/g;
  1802. }
  1803.  
  1804. if ($entryreturn =~ m/{{randomnumber (\d+)-(\d+)}}/i) {
  1805.     until ($entryreturn !~ m/{{randomnumber (\d+)-(\d+)}}/isg) {
  1806.         $minrand = $1;
  1807.         $maxrand = $2;
  1808.         $maxtemprand = $maxrand - $minrand;
  1809.         $maxtemprand++;
  1810.         $randresult = int(rand $maxtemprand) + $minrand;
  1811.         $entryreturn =~ s/{{randomnumber ($minrand)-($maxrand)}}/$randresult/i;
  1812.     }
  1813. }
  1814.  
  1815. if (($entryreturn =~ m/{{cgiwebpath}}/i) || ($entryreturn =~ m/{{entrieswebpath}}/i) || ($entryreturn =~ m/{{logwebpath}}/i)) {
  1816.     $entryreturn =~ s/{{cgiwebpath}}/$cgiwebpath/gi;
  1817.     $entryreturn =~ s/{{entrieswebpath}}/$EntriesWebPath/gi;
  1818.     $entryreturn =~ s/{{logwebpath}}/$LogWebPath/gi;
  1819. }
  1820.  
  1821. if (($entryreturn =~ m/{{gmversion}}/i) || ($entryreturn =~ m/{{gmicon}}/i)) {
  1822.     $entryreturn =~ s/{{gmversion}}/$gmversion/gi;
  1823.     $entryreturn =~ s/{{gmicon}}/<a href="http:\/\/noahgrey.com\/greysoft\/" target="_top"><img border="0" src="$LogWebPath\/gm-icon.gif" alt="Powered By Greymatter" \/><\/a>/gi;
  1824. }
  1825.  
  1826. }
  1827.  
  1828. # ----------------------------
  1829. # generate the main index file
  1830. # ----------------------------
  1831.  
  1832. sub gm_generatemainindex {
  1833.  
  1834. &gm_readconfig;
  1835. &gm_readcounter;
  1836. &gm_readtemplates;
  1837.  
  1838. $indexlogbody = "";
  1839. $indexentrycounter = $newentrynumber;
  1840. $indexcurrentdatemarker = "erewhon";
  1841. $indexcurrentdatescounted = 0;
  1842.  
  1843. if ($newstayattopnumber ne "0") {
  1844.     &gm_getentryvariables($newstayattopnumber);
  1845.     if ($thisentryopenstatus eq "open") {
  1846.         &gm_formatentry($gmstayattoptemplate);
  1847.         $indexlogbody .= $entryreturn;
  1848.     }
  1849. }
  1850.  
  1851. do {
  1852.  
  1853. &gm_getentryvariables($indexentrycounter);
  1854.  
  1855. $datemark = "$thisentrymonth $thisentryday $thisentryyearyear";
  1856.  
  1857. if (($datemark ne $indexcurrentdatemarker) && ($thisentryopenstatus eq "open") && ($indexentrycounter ne $newstayattopnumber)) {
  1858.     $indexcurrentdatescounted++;
  1859.     if ($gmdatetemplate ne "") {
  1860.         $currentdatehead = $gmdatetemplate;
  1861.         $currentdatehead =~ s/{{day}}/$thisentryday/gi;
  1862.         $currentdatehead =~ s/{{dayday}}/$thisentrydayday/gi;
  1863.         $currentdatehead =~ s/{{year}}/$thisentryyear/gi;
  1864.         $currentdatehead =~ s/{{yearyear}}/$thisentryyearyear/gi;
  1865.         $currentdatehead =~ s/{{month}}/$thisentrymonth/gi;
  1866.         $currentdatehead =~ s/{{monthmonth}}/$thisentrymonthmonth/gi;
  1867.         $currentdatehead =~ s/{{weekday}}/$thisentryweekday/gi;
  1868.         $currentdatehead =~ s/{{weekdayshort}}/$thisentryweekdayshort/gi;        
  1869.         $currentdatehead =~ s/{{monthword}}/$thisentrymonthword/gi;
  1870.         $currentdatehead =~ s/{{monthwordshort}}/$thisentrymonthwordshort/gi;        
  1871.         $currentdatehead =~ s/{{weekdayupper}}/$thisentryweekdayupper/gi;
  1872.         $currentdatehead =~ s/{{monthwordupper}}/$thisentrymonthwordupper/gi;
  1873.         $currentdatehead =~ s/{{weekdaylower}}/$thisentryweekdaylower/gi;
  1874.         $currentdatehead =~ s/{{monthwordlower}}/$thisentrymonthwordlower/gi;
  1875.         $currentdatehead =~ s/{{weekdayuppershort}}/$thisentryweekdayuppershort/gi;
  1876.         $currentdatehead =~ s/{{monthworduppershort}}/$thisentrymonthworduppershort/gi;
  1877.         $currentdatehead =~ s/{{weekdaylowershort}}/$thisentryweekdaylowershort/gi;
  1878.         $currentdatehead =~ s/{{monthwordlowershort}}/$thisentrymonthwordlowershort/gi;
  1879.         unless ($indexcurrentdatescounted > $indexdays) { $indexlogbody .= $currentdatehead; }
  1880.     }
  1881.     $indexcurrentdatemarker = "$thisentrymonth $thisentryday $thisentryyearyear";
  1882. } else {
  1883.     if (($indexentrycounter ne $newstayattopnumber) && ($thisentryopenstatus eq "open") && ($indexcurrentdatescounted <= $indexdays) && ($gmentryseparatortemplate ne "")) {
  1884.         $indexlogbody .= $gmentryseparatortemplate;
  1885.     }
  1886. }
  1887.  
  1888. if (($indexentrycounter ne $newstayattopnumber) && ($thisentryopenstatus eq "open") && ($indexcurrentdatescounted <= $indexdays)) {
  1889.     if ($thisentrymorebody ne "") {
  1890.         &gm_formatentry($gmmoreentrytemplate);
  1891.     } else {
  1892.         &gm_formatentry($gmentrytemplate);
  1893.     }
  1894.     $indexlogbody .= $entryreturn;
  1895. }
  1896.  
  1897. $indexentrycounter--;
  1898.  
  1899. if ($indexentrycounter eq "0") {
  1900.     if ($indexcurrentdatescounted > $indexdays) { $indexentrycounter++; }
  1901.     $indexcurrentdatescounted = $indexdays + 1;
  1902. }
  1903.  
  1904. if (($newstayattopnumber eq "1") && ($newentrynumber eq "1")) { $indexcurrentdatescounted = $indexdays + 1; }
  1905.  
  1906. if ($indexcurrentdatescounted > $indexdays) {
  1907.     if ($indexentrycounter < 0) { $indexentrycounter = 0; }
  1908.     unless ($indexentrycounter eq "0") { $indexentrycounter = $thisentrynumber; }
  1909. }
  1910.  
  1911. } until $indexcurrentdatescounted > $indexdays;
  1912.  
  1913. $newindexfile = $gmindextemplate;
  1914. $newindexfile =~ s/{{logbody}}/$indexlogbody/gi;
  1915.  
  1916. &gm_getentryvariables($newentrynumber);
  1917. &gm_formatentry($newindexfile);
  1918.  
  1919. open (THISFILECLAWS, ">$LogPath/$indexfilename") || &gm_dangermouse("Can't write to $LogPath/$indexfilename.  Please make sure your paths are configured correctly and that $indexfilename is CHMODed to 666; also try running Diagnostics & Repair from the Configuration screen.");
  1920. print THISFILECLAWS $entryreturn;
  1921. close (THISFILECLAWS);
  1922.  
  1923. $newarchivenumber = $indexentrycounter;
  1924.  
  1925. &gm_writecounter;
  1926.  
  1927. }
  1928.  
  1929. # ---------------------
  1930. # generate archive file
  1931. # ---------------------
  1932.  
  1933. sub gm_generatearchive {
  1934.  
  1935. my $getstartnumber = shift;
  1936.  
  1937. $startnumber = $getstartnumber;
  1938.  
  1939. &gm_readconfig;
  1940. &gm_readcounter;
  1941. &gm_readtemplates;
  1942.  
  1943. $indexarchivebody = "";
  1944. $indexentrycounter = $startnumber;
  1945. $indexcurrentdatemarker = "erewhon";
  1946. $indexcurrentdatescounted = 0;
  1947. &gm_getentryvariables($startnumber);
  1948. $indexcurrentmonthcounter = $thisentrymonth;
  1949. $indexcurrentweekcounter = "$thisentryweekbeginningdayday$thisentryweekendingdayday";
  1950.  
  1951. do {
  1952.  
  1953. &gm_getentryvariables($indexentrycounter);
  1954.  
  1955. $thisentryweek = "$thisentryweekbeginningdayday$thisentryweekendingdayday";
  1956.  
  1957. if (($generateentrypages eq "yes") && ($indexentrycounter eq $newarchivenumber)) {
  1958.     if ($thisentryopenstatus eq "open") {
  1959.         &gm_formatentry($gmarchiveentrypagetemplate);
  1960.         open (THISFILE, ">$EntriesPath/$thisentrynumberpadded.$entrysuffix") || &gm_dangermouse("Can't write to $EntriesPath/$thisentrynumberpadded.$entrysuffix.  Please make sure that your entries/archives directory is correctly configured and is CHMODed to 777; also try running Diagnostics & Repair from the Configuration screen.");
  1961.         print THISFILE $entryreturn;
  1962.         close (THISFILE);
  1963.     } else {
  1964.         unlink ("$EntriesPath/$thisentrynumberpadded.$entrysuffix");
  1965.     }
  1966. }
  1967.  
  1968. $datemark = "$thisentrymonth $thisentryday $thisentryyearyear";
  1969.  
  1970. if (($datemark ne $indexcurrentdatemarker) && ($thisentryopenstatus eq "open") && ($indexentrycounter ne $newstayattopnumber)) {
  1971.     $indexcurrentdatescounted++;
  1972.     if ($gmdatearchivetemplate ne "") {
  1973.         $currentdatehead = $gmdatearchivetemplate;
  1974.         $currentdatehead =~ s/{{day}}/$thisentryday/gi;
  1975.         $currentdatehead =~ s/{{dayday}}/$thisentrydayday/gi;
  1976.         $currentdatehead =~ s/{{year}}/$thisentryyear/gi;
  1977.         $currentdatehead =~ s/{{yearyear}}/$thisentryyearyear/gi;
  1978.         $currentdatehead =~ s/{{month}}/$thisentrymonth/gi;
  1979.         $currentdatehead =~ s/{{monthmonth}}/$thisentrymonthmonth/gi;
  1980.         $currentdatehead =~ s/{{weekday}}/$thisentryweekday/gi;
  1981.         $currentdatehead =~ s/{{weekdayshort}}/$thisentryweekdayshort/gi;        
  1982.         $currentdatehead =~ s/{{monthword}}/$thisentrymonthword/gi;
  1983.         $currentdatehead =~ s/{{monthwordshort}}/$thisentrymonthwordshort/gi;        
  1984.         $currentdatehead =~ s/{{weekdayupper}}/$thisentryweekdayupper/gi;
  1985.         $currentdatehead =~ s/{{monthwordupper}}/$thisentrymonthwordupper/gi;
  1986.         $currentdatehead =~ s/{{weekdaylower}}/$thisentryweekdaylower/gi;
  1987.         $currentdatehead =~ s/{{monthwordlower}}/$thisentrymonthwordlower/gi;
  1988.         $currentdatehead =~ s/{{weekdayuppershort}}/$thisentryweekdayuppershort/gi;
  1989.         $currentdatehead =~ s/{{monthworduppershort}}/$thisentrymonthworduppershort/gi;
  1990.         $currentdatehead =~ s/{{weekdaylowershort}}/$thisentryweekdaylowershort/gi;
  1991.         $currentdatehead =~ s/{{monthwordlowershort}}/$thisentrymonthwordlowershort/gi;
  1992.         if ($archiveformat eq "week") {
  1993.             unless ($thisentryweek ne $indexcurrentweekcounter) { $indexarchivebody .= $currentdatehead; }
  1994.         } else {
  1995.             unless ($thisentrymonth ne $indexcurrentmonthcounter) { $indexarchivebody .= $currentdatehead; }
  1996.         }
  1997.     }
  1998.     $indexcurrentdatemarker = "$thisentrymonth $thisentryday $thisentryyearyear";
  1999. } else {
  2000.     if ($archiveformat eq "week") {
  2001.         if (($thisentryopenstatus eq "open") && ($thisentryweek eq $indexcurrentweekcounter) && ($gmarchiveentryseparatortemplate ne "")) {
  2002.             $indexarchivebody .= $gmarchiveentryseparatortemplate;
  2003.         }
  2004.     } else {
  2005.         if (($thisentryopenstatus eq "open") && ($thisentrymonth eq $indexcurrentmonthcounter) && ($gmarchiveentryseparatortemplate ne "")) {
  2006.             $indexarchivebody .= $gmarchiveentryseparatortemplate;
  2007.         }
  2008.     }
  2009. }
  2010.  
  2011. if ($archiveformat eq "week") {
  2012.     if (($thisentryopenstatus eq "open") && ($thisentryweek eq $indexcurrentweekcounter)) {
  2013.         if ($thisentrymorebody ne "") {
  2014.             &gm_formatentry($gmmorearchiveentrytemplate);
  2015.         } else {
  2016.             &gm_formatentry($gmarchiveentrytemplate);
  2017.         }
  2018.         $indexarchivebody .= $entryreturn;
  2019.     }
  2020. } else {
  2021.     if (($thisentryopenstatus eq "open") && ($thisentrymonth eq $indexcurrentmonthcounter)) {
  2022.         if ($thisentrymorebody ne "") {
  2023.             &gm_formatentry($gmmorearchiveentrytemplate);
  2024.         } else {
  2025.             &gm_formatentry($gmarchiveentrytemplate);
  2026.         }
  2027.         $indexarchivebody .= $entryreturn;
  2028.     }
  2029. }
  2030.  
  2031. $indexentrycounter--;
  2032.  
  2033. if ($archiveformat eq "week") {
  2034.     if ($thisentryweek ne $indexcurrentweekcounter) {
  2035.         $indexcurrentmonthcounter = "finis";
  2036.     } else {
  2037.         $indexcurrentmonthcounter = $thisentrymonth;
  2038.     }
  2039. }
  2040.  
  2041. if ($indexentrycounter eq "0") { $indexcurrentmonthcounter = "finis"; }
  2042.  
  2043. } until $thisentrymonth ne $indexcurrentmonthcounter;
  2044.  
  2045. $stoppednumber = $thisentrynumber;
  2046.  
  2047. &gm_getentryvariables($startnumber);
  2048.  
  2049. if ($archiveformat eq "week") {
  2050.     $usethisarchivefilename = "$EntriesPath/archive-$thisentryweekbeginningmonthmonth$thisentryweekbeginningdayday$thisentryweekbeginningyearyear-$thisentryweekendingmonthmonth$thisentryweekendingdayday$thisentryweekendingyearyear\.$logarchivesuffix";
  2051. } else {
  2052.     $usethisarchivefilename = "$EntriesPath/archive-$thisentrymonthmonth$thisentryyearyear\.$logarchivesuffix";
  2053. }
  2054.  
  2055. $newarchivefile = $gmarchiveindextemplate;
  2056. $newarchivefile =~ s/{{year}}/$thisentryyear/gi;
  2057. $newarchivefile =~ s/{{yearyear}}/$thisentryyearyear/gi;
  2058. $newarchivefile =~ s/{{month}}/$thisentrymonth/gi;
  2059. $newarchivefile =~ s/{{monthmonth}}/$thisentrymonthmonth/gi;
  2060. $newarchivefile =~ s/{{monthword}}/$thisentrymonthword/gi;
  2061. $newarchivefile =~ s/{{monthwordshort}}/$thisentrymonthwordshort/gi;
  2062. $newarchivefile =~ s/{{monthwordupper}}/$thisentrymonthwordupper/gi;
  2063. $newarchivefile =~ s/{{monthwordlower}}/$thisentrymonthwordlower/gi;
  2064. $newarchivefile =~ s/{{monthworduppershort}}/$thisentrymonthworduppershort/gi;
  2065. $newarchivefile =~ s/{{monthwordlowershort}}/$thisentrymonthwordlowershort/gi;
  2066. $newarchivefile =~ s/{{archivebody}}/$indexarchivebody/gi;
  2067. $newarchivefile =~ s/{{logbody}}/$indexarchivebody/gi;
  2068.  
  2069. &gm_formatentry($newarchivefile);
  2070.  
  2071. ##if ($archiveformat eq "week") {
  2072. ##    $usethisarchivefilename = "$EntriesPath/archive-$thisentryweekbeginningmonthmonth$thisentryweekbeginningdayday$thisentryweekbeginningyearyear-$thisentryweekendingmonthmonth$thisentryweekendingdayday$thisentryweekendingyearyear\.$logarchivesuffix";
  2073. ##} else {
  2074. ##    $usethisarchivefilename = "$EntriesPath/archive-$thisentrymonthmonth$thisentryyearyear\.$logarchivesuffix";
  2075. ##}
  2076.  
  2077. open (THISFILEPAWS, ">$usethisarchivefilename") || &gm_dangermouse("Can't write to $usethisarchivefilename.  Please make sure that your entries/archives directory is correctly configured and is CHMODed to 777; also try running Diagnostics & Repair from the Configuration screen.");
  2078. print THISFILEPAWS $entryreturn;
  2079. close (THISFILEPAWS);
  2080.  
  2081. chmod (0666, "$usethisarchivefilename");
  2082.  
  2083. }
  2084.  
  2085. # -----------------------
  2086. # rebuild connected files
  2087. # -----------------------
  2088.  
  2089. sub gm_rebuildconnectedfiles {
  2090.  
  2091. @connectedfilelist = split (/\|\*\|/, $otherfilelist);
  2092.  
  2093. @variabledatabase = ("{{header}}", "{{footer}}", "{{sidebar}}", "{{log", "{{calendar", "{{comment", "{{entry", "link}}", "karma}}", "{{author", "{{day", "{{month", "{{year", "{{hour", "{{minute", "{{second", "{{weekday", "{{militaryhour}}", "{{ampm", "{{timezone}}", "{{link", "{{email", "{{previous", "{{next", "webpath}}", "{{gm");
  2094.  
  2095. &gm_getentryvariables($newentrynumber);
  2096.  
  2097. $connectedfilesdone = "no";
  2098. $connectstartfromhere = $IN{'connectednumber'};
  2099. if ($connectstartfromhere eq "") { $connectstartfromhere = 0; }
  2100. $connectendhere = $connectstartfromhere + 19;
  2101. if (($connectendhere > $#connectedfilelist) || ($connectendhere eq $#connectedfilelist)) {
  2102.     $connectendhere = $#connectedfilelist;
  2103.     $connectedfilesdone = "yes";
  2104. }
  2105. $IN{'connectednumber'} = $connectendhere + 1;
  2106.  
  2107. $connectcounter = 0;
  2108.  
  2109. foreach $usethisfilename (@connectedfilelist) {
  2110. unless (($connectcounter < $connectstartfromhere) || ($connectcounter > $connectendhere)) {
  2111.  
  2112.     $usethisfilenamestripped = $usethisfilename;
  2113.     $usethisfilenamestripped =~ s/\//BACKSLASH/g;
  2114.     $usethisfilenamestripped =~ s/\W//g;
  2115.     $usethisfilenamestripped =~ s/BACKSLASH/-/g;
  2116.  
  2117.     $thereisapattern = "no";
  2118.  
  2119.     open (OTHERORIGFILE, "$usethisfilename") || &gm_dangermouse("Can't open $usethisfilename.  Please make sure that this file exists and is CHMODed to 666, or else remove it from your list of connected files in configuration.");
  2120.     @otherorigfilelines = <OTHERORIGFILE>;
  2121.     close (OTHERORIGFILE);
  2122.  
  2123.     unless (!(open(CHECKTHISFILE,"$EntriesPath/$usethisfilenamestripped.cgi"))) {
  2124.         open (OTHERPATTERNFILE, "$EntriesPath/$usethisfilenamestripped.cgi") || &gm_dangermouse("Can't open $EntriesPath/$usethisfilenamestripped.cgi.  Please make sure that your entries/archives directory is correctly configured and is CHMODed to 777; also try running Diagnostics & Repair from the Configuration screen.");
  2125.         @otherpatternfilelines = <OTHERPATTERNFILE>;
  2126.         close (OTHERPATTERNFILE);
  2127.         $thereisapattern = "yes";
  2128.     }
  2129.     close(CHECKTHISFILE);
  2130.  
  2131.     $gmcounter = 0;
  2132.  
  2133.     foreach (@otherorigfilelines) {
  2134.         chomp ($otherorigfilelines[$gmcounter]);
  2135.         $gmcounter++;
  2136.     }
  2137.  
  2138.     $otherorigfilebody = join ("|*|", @otherorigfilelines);
  2139.  
  2140.     foreach $thisvariablecheck (@variabledatabase) {
  2141.         if ($otherorigfilebody =~ m/$thisvariablecheck/i) { $thereisapattern = "no"; }
  2142.     }
  2143.  
  2144.     unless ($thereisapattern eq "no") {
  2145.         $gmcounter = 0;
  2146.         foreach (@otherpatternfilelines) {
  2147.             chomp ($otherpatternfilelines[$gmcounter]);
  2148.             $gmcounter++;
  2149.         }
  2150.         $otherpatternfilebody = join ("|*|", @otherpatternfilelines);
  2151.         $otherfilebody = $otherpatternfilebody;
  2152.     } else {
  2153.         $otherfilebody = $otherorigfilebody;
  2154.     }
  2155.  
  2156.     $newfilebodypattern = $otherfilebody;
  2157.  
  2158.     &gm_formatentry($otherfilebody);
  2159.  
  2160.     $entryreturn =~ s/\|\*\|/\n/g;
  2161.     $newfilebodypattern =~ s/\|\*\|/\n/g;
  2162.  
  2163.     chmod (0666, "$usethisfilename");
  2164.  
  2165.     open (OTHERFILEONE, ">$usethisfilename") || &gm_dangermouse("Can't write to $usethisfilename.  Please make sure that this file exists and is CHMODed to 666, or else remove it from your list of connected files in configuration.");
  2166.     print OTHERFILEONE $entryreturn;
  2167.     close (OTHERFILEONE);
  2168.  
  2169.     open (OTHERFILETWO, ">$EntriesPath/$usethisfilenamestripped.cgi") || &gm_dangermouse("Can't write to $EntriesPath/$usethisfilenamestripped.cgi.  Please make sure that your entries/archives directory is correctly configured and is CHMODed to 777; also try running Diagnostics & Repair from the Configuration screen.");
  2170.     print OTHERFILETWO $newfilebodypattern;
  2171.     close (OTHERFILETWO);
  2172.  
  2173.     chmod (0666, "$EntriesPath/$usethisfilenamestripped.cgi");
  2174.  
  2175. }
  2176. $connectcounter++;
  2177. }
  2178.  
  2179. }
  2180.  
  2181. # -------------------------
  2182. # generate log archive list
  2183. # -------------------------
  2184.  
  2185. sub gm_generatearchiveloglist {
  2186.  
  2187. &gm_readcounter;
  2188.  
  2189. ###########################################################
  2190. # 9/3/2001 - CHERYL LAMBERT
  2191. # Problem: If the last archived entry is a different month/year from the current month/year, the
  2192. # {{calendar}} on the Archive Master Index page displays the month/year of the last archived
  2193. # entry instead of the current month/year.  For example, my last archived entry was 8/21/2001
  2194. # but the current date was 9/3/2001 when I discovered this problem.  The {{calendar}} displayed
  2195. # on the Archive Master Index page was for August 2001 not for September 2001.
  2196. # The following section of code corrects this problem by getting the current date and using
  2197. # the current date instead of the last archived date to create the {{calendar}} on the
  2198. # Archive Master Index page.
  2199.     my ($tsec,$tmin,$thour,$tmday,$tmon,$tyear,$twday,$tyday,$tisdst) = localtime(time);
  2200.     $tmon += 1;
  2201.     $tyear += 1900;
  2202.     if (($tmon != $thisentrymonth) || ($tyear != $thisentryyearyear)) {  
  2203.         $thisentrymonth = $tmon;
  2204.         $thisentryday = $tmday;  
  2205.         $thisentryhour = $thour;  
  2206.         $thisentryminute = $tmin;  
  2207.         $thisentrysecond = $tsec;  
  2208.         $thisentryweekdaynumber = $twday;  
  2209.         $thisentryweekday = $weekdays[$twday];  
  2210.         $thisentrymonthword = $months[$thisentrymonth];  
  2211.         $thisentrymonthmonth = sprintf ("%2d", $thisentrymonth);  
  2212.         $thisentrydayday = sprintf ("%2d", $thisentryday);  
  2213.         $thisentryhourhour = sprintf ("%2d", $thisentryhour);  
  2214.         $thisentryminuteminute = sprintf ("%2d", $thisentryminute);  
  2215.         $thisentrysecondsecond = sprintf ("%2d", $thisentrysecond);  
  2216.         $thisentrymonthmonth =~ tr/ /0/;  $thisentrydayday =~ tr/ /0/;  
  2217.         $thisentryhourhour =~ tr/ /0/;  $thisentryminuteminute =~ tr/ /0/;  
  2218.         $thisentrysecondsecond =~ tr/ /0/;
  2219.         }
  2220. ###########################################################
  2221.  
  2222. open (FUNNYFEETMIDNIGHT, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  2223. @loglistloglines = <FUNNYFEETMIDNIGHT>;
  2224. close (FUNNYFEETMIDNIGHT);
  2225.  
  2226. $listcountmonthyear = "begin";
  2227. $listcountweek = "begin";
  2228.  
  2229. $logarchivelistfinal = "";
  2230.  
  2231. foreach $loglistline (@loglistloglines) {
  2232.  
  2233.     chomp ($loglistline);
  2234.     ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $loglistline);
  2235.     &gm_getloglistvariables;
  2236.  
  2237.     unless ($loglistopenstatus eq "C") {
  2238.  
  2239.         $thisloglistmonthyear = "$loglistmonthmonth $loglistyearyear";
  2240.         $thisloglistweek = "$loglistweekbeginningdayday$loglistweekendingdayday";
  2241.  
  2242.         if ($archiveformat eq "week") {
  2243.             if ($thisloglistweek ne $listcountweek) {
  2244.                 $listsubsub = $gmlogarchiveslinkweeklytemplate;
  2245.                 &entrylistsubsub;
  2246.                 $listsubsub .= "|*|";
  2247.                 $logarchivelistfinal .= $listsubsub;
  2248.                 $listcountweek = $thisloglistweek;
  2249.             }
  2250.         } else {
  2251.             if ($thisloglistmonthyear ne $listcountmonthyear) {
  2252.                 $listsubsub = $gmlogarchiveslinktemplate;
  2253.                 &entrylistsubsub;
  2254.                 $listsubsub .= "|*|";
  2255.                 $logarchivelistfinal .= $listsubsub;
  2256.                 $listcountmonthyear = $thisloglistmonthyear;
  2257.             }
  2258.         }
  2259.  
  2260.     }
  2261.  
  2262. }
  2263.  
  2264. @loglistfinalcollection = split (/\|\*\|/, $logarchivelistfinal);
  2265.  
  2266. if ($entrylistsortorder eq "descending") { @loglistfinalcollection = reverse @loglistfinalcollection; }
  2267.  
  2268. $logarchivelistfinal = join ("$gmlogarchiveslinkseparatortemplate", @loglistfinalcollection);
  2269.  
  2270. }
  2271.  
  2272. # -----------------------
  2273. # generate log entry list
  2274. # -----------------------
  2275.  
  2276. sub gm_generateentryloglist {
  2277.  
  2278. $logshortentrylistfinal = "";
  2279. $logmoreentrylistfinal = "";
  2280. $logentrylistfinal = "";
  2281. $logshortentrylistmonthfinal = "";
  2282. $logshortentrylistdayfinal = "";
  2283. $logshortentrylistyearfinal = "";
  2284. $logmoreentrylistmonthfinal = "";
  2285. $logmoreentrylistdayfinal = "";
  2286. $logmoreentrylistyearfinal = "";
  2287. $logentrylistmonthfinal = "";
  2288. $logentrylistdayfinal = "";
  2289. $logentrylistyearfinal = "";
  2290. $logshortentrylistnumberfinal = "";
  2291. $logmoreentrylistnumberfinal = "";
  2292. $logentrylistnumberfinal = "";
  2293. $logshortentrylistfirsthalffinal = "";
  2294. $logshortentrylistsecondhalffinal = "";
  2295. $logmoreentrylistfirsthalffinal = "";
  2296. $logmoreentrylistsecondhalffinal = "";
  2297. $logentrylistfirsthalffinal = "";
  2298. $logentrylistsecondhalffinal = "";
  2299.  
  2300. open (FUNNYFEETSPOT, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  2301. @loglistloglines = <FUNNYFEETSPOT>;
  2302. close (FUNNYFEETSPOT);
  2303.  
  2304. if ($entrylistsortorder eq "descending") { @loglistloglines = reverse @loglistloglines; }
  2305.  
  2306. ($toploglistnumber, $toploglistauthor, $toploglistsubject, $toploglistdate, $toploglisttimeampm, $toploglistopenstatus, $toploglistmorestatus) = split (/\|/, $loglistloglines[0]);
  2307. ($toploglistmonthmonth, $toploglistdayday, $toploglistyear) = split (/\//, $toploglistdate);
  2308.  
  2309. $shortentrycounter = 0;
  2310. $moreentrycounter = 0;
  2311. $allentrycounter = 0;
  2312.  
  2313. $shorttotalentrycounter = 0;
  2314. $moretotalentrycounter = 0;
  2315. $alltotalentrycounter = 0;
  2316.  
  2317. foreach $loglistcounterline (@loglistloglines) {
  2318.     chomp ($loglistcounterline);
  2319.     ($loglistcounternumber, $loglistcounterauthor, $loglistcountersubject, $loglistcounterdate, $loglistcountertimeampm, $loglistcounteropenstatus, $loglistcountermorestatus) = split (/\|/, $loglistcounterline);
  2320.     unless ($loglistcounteropenstatus eq "C") {
  2321.         $alltotalentrycounter++;
  2322.         if ($loglistcountermorestatus eq "Y") { $moretotalentrycounter++; } else { $shorttotalentrycounter++; }
  2323.     }
  2324. }
  2325.  
  2326. $shorttotalentryhalfcounter = sprintf("%.0f", ($shorttotalentrycounter / 2));
  2327. $moretotalentryhalfcounter = sprintf("%.0f", ($moretotalentrycounter / 2));
  2328. $alltotalentryhalfcounter = sprintf("%.0f", ($alltotalentrycounter / 2));
  2329.  
  2330. $listdaymarker = "tommy";
  2331. $listmonthmarker = "tommy";
  2332. $listyearmarker = "tommy";
  2333.  
  2334. foreach $loglistline (@loglistloglines) {
  2335.  
  2336.     chomp ($loglistline);
  2337.     ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $loglistline);
  2338.  
  2339.     unless ($loglistopenstatus eq "C") {
  2340.  
  2341.         &gm_getloglistvariables;
  2342.  
  2343.         $usethismorelinktemplate = $gmmoreentrypagelinktemplate;
  2344.         $usethislinktemplate = $gmentrypagelinktemplate;
  2345.  
  2346.         if (($gmentrypagelinkdayseparatortemplate ne "") && ($listdaymarker ne $loglistday)) {
  2347.             $usethismorelinktemplate = "$gmentrypagelinkdayseparatortemplate|*|$usethismorelinktemplate";
  2348.             $usethislinktemplate = "$gmentrypagelinkdayseparatortemplate|*|$usethislinktemplate";
  2349.         }
  2350.  
  2351.         if (($gmentrypagelinkmonthseparatortemplate ne "") && ($listmonthmarker ne $loglistmonth)) {
  2352.             $usethismorelinktemplate = "$gmentrypagelinkmonthseparatortemplate|*|$usethismorelinktemplate";
  2353.             $usethislinktemplate = "$gmentrypagelinkmonthseparatortemplate|*|$usethislinktemplate";
  2354.         }
  2355.  
  2356.         if (($gmentrypagelinkyearseparatortemplate ne "") && ($listyearmarker ne $loglistyear)) {
  2357.             $usethismorelinktemplate = "$gmentrypagelinkyearseparatortemplate|*|$usethismorelinktemplate";
  2358.             $usethislinktemplate = "$gmentrypagelinkyearseparatortemplate|*|$usethislinktemplate";
  2359.         }
  2360.  
  2361.         if ($loglistmorestatus eq "Y") {
  2362.             $moreentrycounter++;
  2363.             $listsubsub = $usethismorelinktemplate;
  2364.             &entrylistsubsub;
  2365.             $listsubsub .= "|*|";
  2366.             $logmoreentrylistfinal .= $listsubsub;
  2367.             if ($loglistmonthmonth eq $toploglistmonthmonth) { $logmoreentrylistmonthfinal .= $listsubsub; }
  2368.             if ($loglistdayday eq $toploglistdayday) { $logmoreentrylistdayfinal .= $listsubsub; }
  2369.             if ($loglistyear eq $toploglistyear) { $logmoreentrylistyearfinal .= $listsubsub; }
  2370.             unless ($moreentrycounter > $entrylistcountnumber) { $logmoreentrylistnumberfinal .= $listsubsub; }
  2371.             if ($moreentrycounter <= $moretotalentryhalfcounter) {
  2372.                 $logmoreentrylistfirsthalffinal .= $listsubsub;
  2373.             } else {
  2374.                 $logmoreentrylistsecondhalffinal .= $listsubsub;
  2375.             }
  2376.         } else {
  2377.             $shortentrycounter++;
  2378.             $listsubsub = $usethislinktemplate;
  2379.             &entrylistsubsub;
  2380.             $listsubsub .= "|*|";
  2381.             $logshortentrylistfinal .= $listsubsub;
  2382.             if ($loglistmonthmonth eq $toploglistmonthmonth) { $logshortentrylistmonthfinal .= $listsubsub; }
  2383.             if ($loglistdayday eq $toploglistdayday) { $logshortentrylistdayfinal .= $listsubsub; }
  2384.             if ($loglistyear eq $toploglistyear) { $logshortentrylistyearfinal .= $listsubsub; }
  2385.             unless ($shortentrycounter > $entrylistcountnumber) { $logshortentrylistnumberfinal .= $listsubsub; }
  2386.             if ($shortentrycounter <= $shorttotalentryhalfcounter) {
  2387.                 $logshortentrylistfirsthalffinal .= $listsubsub;
  2388.             } else {
  2389.                 $logshortentrylistsecondhalffinal .= $listsubsub;
  2390.             }
  2391.         }
  2392.  
  2393.         $allentrycounter++;
  2394.         $logentrylistfinal .= $listsubsub;
  2395.         if ($loglistmonthmonth eq $toploglistmonthmonth) { $logentrylistmonthfinal .= $listsubsub; }
  2396.         if ($loglistdayday eq $toploglistdayday) { $logentrylistdayfinal .= $listsubsub; }
  2397.         if ($loglistyear eq $toploglistyear) { $logentrylistyearfinal .= $listsubsub; }
  2398.         unless ($allentrycounter > $entrylistcountnumber) { $logentrylistnumberfinal .= $listsubsub; }
  2399.         if ($allentrycounter <= $alltotalentryhalfcounter) {
  2400.             $logentrylistfirsthalffinal .= $listsubsub;
  2401.         } else {
  2402.             $logentrylistsecondhalffinal .= $listsubsub;
  2403.         }
  2404.  
  2405.         $listdaymarker = $loglistday;
  2406.         $listmonthmarker = $loglistmonth;
  2407.         $listyearmarker = $loglistyear;
  2408.  
  2409.     }
  2410.  
  2411. }
  2412.  
  2413. @logshortentrylistfinalcollection = split (/\|\*\|/, $logshortentrylistfinal);
  2414. @logmoreentrylistfinalcollection = split (/\|\*\|/, $logmoreentrylistfinal);
  2415. @logentrylistfinalcollection = split (/\|\*\|/, $logentrylistfinal);
  2416. @logshortentrylistmonthfinalcollection = split (/\|\*\|/, $logshortentrylistmonthfinal);
  2417. @logshortentrylistdayfinalcollection = split (/\|\*\|/, $logshortentrylistdayfinal);
  2418. @logshortentrylistyearfinalcollection = split (/\|\*\|/, $logshortentrylistyearfinal);
  2419. @logmoreentrylistmonthfinalcollection = split (/\|\*\|/, $logmoreentrylistmonthfinal);
  2420. @logmoreentrylistdayfinalcollection = split (/\|\*\|/, $logmoreentrylistdayfinal);
  2421. @logmoreentrylistyearfinalcollection = split (/\|\*\|/, $logmoreentrylistyearfinal);
  2422. @logentrylistmonthfinalcollection = split (/\|\*\|/, $logentrylistmonthfinal);
  2423. @logentrylistdayfinalcollection = split (/\|\*\|/, $logentrylistdayfinal);
  2424. @logentrylistyearfinalcollection = split (/\|\*\|/, $logentrylistyearfinal);
  2425. @logshortentrylistnumberfinalcollection = split (/\|\*\|/, $logshortentrylistnumberfinal);
  2426. @logmoreentrylistnumberfinalcollection = split (/\|\*\|/, $logmoreentrylistnumberfinal);
  2427. @logentrylistnumberfinalcollection = split (/\|\*\|/, $logentrylistnumberfinal);
  2428. @logshortentrylistfirsthalffinalcollection = split (/\|\*\|/, $logshortentrylistfirsthalffinal);
  2429. @logshortentrylistsecondhalffinalcollection = split (/\|\*\|/, $logshortentrylistsecondhalffinal);
  2430. @logmoreentrylistfirsthalffinalcollection = split (/\|\*\|/, $logmoreentrylistfirsthalffinal);
  2431. @logmoreentrylistsecondhalffinalcollection = split (/\|\*\|/, $logmoreentrylistsecondhalffinal);
  2432. @logentrylistfirsthalffinalcollection = split (/\|\*\|/, $logentrylistfirsthalffinal);
  2433. @logentrylistsecondhalffinalcollection = split (/\|\*\|/, $logentrylistsecondhalffinal);
  2434.  
  2435. $logshortentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistfinalcollection);
  2436. $logmoreentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistfinalcollection);
  2437. $logentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistfinalcollection);
  2438. $logshortentrylistmonthfinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistmonthfinalcollection);
  2439. $logshortentrylistdayfinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistdayfinalcollection);
  2440. $logshortentrylistyearfinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistyearfinalcollection);
  2441. $logmoreentrylistmonthfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistmonthfinalcollection);
  2442. $logmoreentrylistdayfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistdayfinalcollection);
  2443. $logmoreentrylistyearfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistyearfinalcollection);
  2444. $logentrylistmonthfinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistmonthfinalcollection);
  2445. $logentrylistdayfinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistdayfinalcollection);
  2446. $logentrylistyearfinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistyearfinalcollection);
  2447. $logshortentrylistnumberfinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistnumberfinalcollection);
  2448. $logmoreentrylistnumberfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistnumberfinalcollection);
  2449. $logentrylistnumberfinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistnumberfinalcollection);
  2450. $logshortentrylistfirsthalffinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistfirsthalffinalcollection);
  2451. $logshortentrylistsecondhalffinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistsecondhalffinalcollection);
  2452. $logmoreentrylistfirsthalffinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistfirsthalffinalcollection);
  2453. $logmoreentrylistsecondhalffinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistsecondhalffinalcollection);
  2454. $logentrylistfirsthalffinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistfirsthalffinalcollection);
  2455. $logentrylistsecondhalffinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistsecondhalffinalcollection);
  2456.  
  2457. }
  2458.  
  2459. # ----------------------------------------------
  2460. # generate log entry list for individual authors
  2461. # ----------------------------------------------
  2462.  
  2463. sub gm_generateentryloglistauthor {
  2464.  
  2465. $logshortentrylistfinal = "";
  2466. $logmoreentrylistfinal = "";
  2467. $logentrylistfinal = "";
  2468.  
  2469. open (FUNNYFEETINDY, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  2470. @loglistloglines = <FUNNYFEETINDY>;
  2471. close (FUNNYFEETINDY);
  2472.  
  2473. if ($entrylistsortorder eq "descending") { @loglistloglines = reverse @loglistloglines; }
  2474.  
  2475. ($toploglistnumber, $toploglistauthor, $toploglistsubject, $toploglistdate, $toploglisttimeampm, $toploglistopenstatus, $toploglistmorestatus) = split (/\|/, $loglistloglines[0]);
  2476. ($toploglistmonthmonth, $toploglistdayday, $toploglistyear) = split (/\//, $toploglistdate);
  2477.  
  2478. $shortentrycounter = 0;
  2479. $moreentrycounter = 0;
  2480. $allentrycounter = 0;
  2481.  
  2482. $listdaymarker = "tommy";
  2483. $listmonthmarker = "tommy";
  2484. $listyearmarker = "tommy";
  2485.  
  2486. foreach $loglistline (@loglistloglines) {
  2487.  
  2488.     chomp ($loglistline);
  2489.     ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $loglistline);
  2490.  
  2491.     unless (($loglistopenstatus eq "C") || ($thisentryloglistauthor ne $loglistauthor)) {
  2492.  
  2493.         &gm_getloglistvariables;
  2494.  
  2495.         $usethismorelinktemplate = $gmmoreentrypagelinktemplate;
  2496.         $usethislinktemplate = $gmentrypagelinktemplate;
  2497.  
  2498.         if (($gmentrypagelinkdayseparatortemplate ne "") && ($listdaymarker ne $loglistday)) {
  2499.             $usethismorelinktemplate = "$gmentrypagelinkdayseparatortemplate|*|$usethismorelinktemplate";
  2500.             $usethislinktemplate = "$gmentrypagelinkdayseparatortemplate|*|$usethislinktemplate";
  2501.         }
  2502.  
  2503.         if (($gmentrypagelinkmonthseparatortemplate ne "") && ($listmonthmarker ne $loglistmonth)) {
  2504.             $usethismorelinktemplate = "$gmentrypagelinkmonthseparatortemplate|*|$usethismorelinktemplate";
  2505.             $usethislinktemplate = "$gmentrypagelinkmonthseparatortemplate|*|$usethislinktemplate";
  2506.         }
  2507.  
  2508.         if (($gmentrypagelinkyearseparatortemplate ne "") && ($listyearmarker ne $loglistyear)) {
  2509.             $usethismorelinktemplate = "$gmentrypagelinkyearseparatortemplate|*|$usethismorelinktemplate";
  2510.             $usethislinktemplate = "$gmentrypagelinkyearseparatortemplate|*|$usethislinktemplate";
  2511.         }
  2512.  
  2513.         if ($loglistmorestatus eq "Y") {
  2514.             $moreentrycounter++;
  2515.             $listsubsub = $usethismorelinktemplate;
  2516.             &entrylistsubsub;
  2517.             $listsubsub .= "|*|";
  2518.             $logmoreentrylistfinal .= $listsubsub;
  2519.         } else {
  2520.             $shortentrycounter++;
  2521.             $listsubsub = $usethislinktemplate;
  2522.             &entrylistsubsub;
  2523.             $listsubsub .= "|*|";
  2524.             $logshortentrylistfinal .= $listsubsub;
  2525.         }
  2526.  
  2527.         $allentrycounter++;
  2528.         $logentrylistfinal .= $listsubsub;
  2529.  
  2530.         $listdaymarker = $loglistday;
  2531.         $listmonthmarker = $loglistmonth;
  2532.         $listyearmarker = $loglistyear;
  2533.  
  2534.     }
  2535.  
  2536. }
  2537.  
  2538. @logshortentrylistfinalcollection = split (/\|\*\|/, $logshortentrylistfinal);
  2539. @logmoreentrylistfinalcollection = split (/\|\*\|/, $logmoreentrylistfinal);
  2540. @logentrylistfinalcollection = split (/\|\*\|/, $logentrylistfinal);
  2541.  
  2542. $logshortentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistfinalcollection);
  2543. $logmoreentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistfinalcollection);
  2544. $logentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistfinalcollection);
  2545.  
  2546. }
  2547.  
  2548. # -------------------------------------------
  2549. # generate log entry list for comment sorting
  2550. # -------------------------------------------
  2551.  
  2552. sub gm_generateentryloglistcomments {
  2553.  
  2554. $logshortentrylistfinal = "";
  2555. $logmoreentrylistfinal = "";
  2556. $logentrylistfinal = "";
  2557. $logshortminimumentrylistfinal = "";
  2558. $logmoreminimumentrylistfinal = "";
  2559. $logminimumentrylistfinal = "";
  2560. $logshortnumberentrylistfinal = "";
  2561. $logmorenumberentrylistfinal = "";
  2562. $lognumberentrylistfinal = "";
  2563.  
  2564. $countfromhere = 1;
  2565.  
  2566. do {
  2567.  
  2568.     $countfromherenumberpadded = sprintf ("%8d", $countfromhere);
  2569.     $countfromherenumberpadded =~ tr/ /0/;
  2570.     open (FUNNYFEETCOMMIE, "$EntriesPath/$countfromherenumberpadded.cgi") || &gm_dangermouse("Can't read $EntriesPath/$countfromherenumberpadded.cgi.  Please make sure that your entries/archives directory is correctly configured and is CHMODed to 777, or try running Diagnostics & Repair in the Configuration screen.");
  2571.     @countfromhereentrylines = <FUNNYFEETCOMMIE>;
  2572.     close (FUNNYFEETCOMMIE);
  2573.  
  2574.     chomp ($countfromhereentrylines[0]);
  2575.  
  2576.     ($countfromhereentrynumber, $countfromhereentryauthor, $countfromhereentrysubject, $countfromhereentryweekdaynumber, $countfromhereentrymonth, $countfromhereentryday, $countfromhereentryyearyear, $countfromhereentryhour, $countfromhereentryminute, $countfromhereentrysecond, $countfromhereentryampm, $countfromhereentrypositivekarma, $countfromhereentrynegativekarma, $countfromhereentrycommentsnumber, $countfromhereentryallowkarma, $countfromhereentryallowcomments, $countfromhereentryopenstatus) = split (/\|/, $countfromhereentrylines[0]);
  2577.  
  2578.     $countfromcanpost = "Y";
  2579.  
  2580.     if ($countfromhereentryallowcomments eq "no") { $countfromcanpost = "N"; }
  2581.     if (($posttoarchives eq "no") && ($countfromhereentrynumber <= $newarchivenumber)) { $countfromcanpost = "N"; }
  2582.  
  2583.     unless ($countfromhereentryopenstatus eq "closed") {
  2584.         $countslot = $countfromhere - 1;
  2585.         $countfromherelist[$countslot] = "$countfromhereentrycommentsnumber|$countfromhereentrynumber|$countfromcanpost";
  2586.     }
  2587.  
  2588.     $countfromhere++;
  2589.  
  2590. } until $countfromhere > $newentrynumber;
  2591.  
  2592. sub numerically { $a <=> $b }
  2593. @countfromherelist = sort numerically @countfromherelist;
  2594.  
  2595. unless ($entrylistsortorder eq "descending") { @countfromherelist = reverse @countfromherelist; }
  2596.  
  2597. open (FUNNYFEETBLECH, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  2598. @loglistloglines = <FUNNYFEETBLECH>;
  2599. close (FUNNYFEETBLECH);
  2600.  
  2601. $shortentrycounter = 0;
  2602. $moreentrycounter = 0;
  2603. $allentrycounter = 0;
  2604.  
  2605. $listdaymarker = "tommy";
  2606. $listmonthmarker = "tommy";
  2607. $listyearmarker = "tommy";
  2608.  
  2609. foreach $countfromhereline (@countfromherelist) {
  2610.  
  2611.     ($countfromherecommentsnumber, $countfromhereentrynumber, $countfromherecanpost) = split (/\|/, $countfromhereline);
  2612.  
  2613.     foreach $loglistline (@loglistloglines) {
  2614.  
  2615.         chomp ($loglistline);
  2616.         ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $loglistline);
  2617.  
  2618.         if ($loglistnumber eq $countfromhereentrynumber) {
  2619.             unless (($countfromherecanpost eq "N") && ($commententrylistonlyifokay eq "yes")) {
  2620.  
  2621.                 &gm_getloglistvariables;
  2622.  
  2623.                 $usethismorelinktemplate = $gmmoreentrypagelinktemplate;
  2624.                 $usethislinktemplate = $gmentrypagelinktemplate;
  2625.  
  2626.                 if (($gmentrypagelinkdayseparatortemplate ne "") && ($listdaymarker ne $loglistday)) {
  2627.                     $usethismorelinktemplate = "$gmentrypagelinkdayseparatortemplate|*|$usethismorelinktemplate";
  2628.                     $usethislinktemplate = "$gmentrypagelinkdayseparatortemplate|*|$usethislinktemplate";
  2629.                 }
  2630.  
  2631.                 if (($gmentrypagelinkmonthseparatortemplate ne "") && ($listmonthmarker ne $loglistmonth)) {
  2632.                     $usethismorelinktemplate = "$gmentrypagelinkmonthseparatortemplate|*|$usethismorelinktemplate";
  2633.                     $usethislinktemplate = "$gmentrypagelinkmonthseparatortemplate|*|$usethislinktemplate";
  2634.                 }
  2635.  
  2636.                 if (($gmentrypagelinkyearseparatortemplate ne "") && ($listyearmarker ne $loglistyear)) {
  2637.                     $usethismorelinktemplate = "$gmentrypagelinkyearseparatortemplate|*|$usethismorelinktemplate";
  2638.                     $usethislinktemplate = "$gmentrypagelinkyearseparatortemplate|*|$usethislinktemplate";
  2639.                 }
  2640.  
  2641.                 if ($loglistmorestatus eq "Y") {
  2642.                     $moreentrycounter++;
  2643.                     $listsubsub = $usethismorelinktemplate;
  2644.                     &entrylistsubsub;
  2645.                     $listsubsub .= "|*|";
  2646.                     $logmoreentrylistfinal .= $listsubsub;
  2647.                     unless ($countfromherecommentsnumber < 1) { $logmoreminimumentrylistfinal .= $listsubsub; }
  2648.                     unless ($moreentrycounter > $entrylistcountnumber) { $logmorenumberentrylistfinal .= $listsubsub; }
  2649.                 } else {
  2650.                     $shortentrycounter++;
  2651.                     $listsubsub = $usethislinktemplate;
  2652.                     &entrylistsubsub;
  2653.                     $listsubsub .= "|*|";
  2654.                     $logshortentrylistfinal .= $listsubsub;
  2655.                     unless ($countfromherecommentsnumber < 1) { $logshortminimumentrylistfinal .= $listsubsub; }
  2656.                     unless ($shortentrycounter > $entrylistcountnumber) { $logshortnumberentrylistfinal .= $listsubsub; }
  2657.                 }
  2658.  
  2659.                 $allentrycounter++;
  2660.                 $logentrylistfinal .= $listsubsub;
  2661.                 unless ($countfromherecommentsnumber < 1) { $logminimumentrylistfinal .= $listsubsub; }
  2662.                 unless ($allentrycounter > $entrylistcountnumber) { $lognumberentrylistfinal .= $listsubsub; }
  2663.  
  2664.                 $listdaymarker = $loglistday;
  2665.                 $listmonthmarker = $loglistmonth;
  2666.                 $listyearmarker = $loglistyear;
  2667.  
  2668.             }
  2669.         }
  2670.  
  2671.     }
  2672.  
  2673. }
  2674.  
  2675. @logshortentrylistfinalcollection = split (/\|\*\|/, $logshortentrylistfinal);
  2676. @logmoreentrylistfinalcollection = split (/\|\*\|/, $logmoreentrylistfinal);
  2677. @logentrylistfinalcollection = split (/\|\*\|/, $logentrylistfinal);
  2678. @logshortminimumentrylistfinalcollection = split (/\|\*\|/, $logshortminimumentrylistfinal);
  2679. @logmoreminimumentrylistfinalcollection = split (/\|\*\|/, $logmoreminimumentrylistfinal);
  2680. @logminimumentrylistfinalcollection = split (/\|\*\|/, $logminimumentrylistfinal);
  2681. @logshortnumberentrylistfinalcollection = split (/\|\*\|/, $logshortnumberentrylistfinal);
  2682. @logmorenumberentrylistfinalcollection = split (/\|\*\|/, $logmorenumberentrylistfinal);
  2683. @lognumberentrylistfinalcollection = split (/\|\*\|/, $lognumberentrylistfinal);
  2684.  
  2685. $logshortentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logshortentrylistfinalcollection);
  2686. $logmoreentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreentrylistfinalcollection);
  2687. $logentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logentrylistfinalcollection);
  2688. $logshortminimumentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logshortminimumentrylistfinalcollection);
  2689. $logmoreminimumentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logmoreminimumentrylistfinalcollection);
  2690. $logminimumentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logminimumentrylistfinalcollection);
  2691. $logshortnumberentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logshortnumberentrylistfinalcollection);
  2692. $logmorenumberentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @logmorenumberentrylistfinalcollection);
  2693. $lognumberentrylistfinal = join ("$gmentrypagelinkseparatortemplate", @lognumberentrylistfinalcollection);
  2694.  
  2695. }
  2696.  
  2697. # ----------------------
  2698. # get log list variables
  2699. # ----------------------
  2700.  
  2701. sub gm_getloglistvariables {
  2702.  
  2703. $loglistnumberpadded = sprintf ("%8d", $loglistnumber);
  2704. $loglistnumberpadded =~ tr/ /0/;
  2705.  
  2706. ($loglistmonthmonth, $loglistdayday, $loglistyear) = split (/\//, $loglistdate);
  2707.  
  2708. if ((substr($loglistmonthmonth, 0, 1)) eq "0") {
  2709.     $loglistmonth = substr($loglistmonthmonth, -1, 1);
  2710. } else {
  2711.     $loglistmonth = $loglistmonthmonth;
  2712. }
  2713.  
  2714. if ((substr($loglistdayday, 0, 1)) eq "0") {
  2715.     $loglistday = substr($loglistdayday, -1, 1);
  2716. } else {
  2717.     $loglistday = $loglistdayday;
  2718. }
  2719.  
  2720. if ($loglistyear > 80) {
  2721.     $loglistyearyear = "19$loglistyear";
  2722. } else {
  2723.     $loglistyearyear = "20$loglistyear";
  2724. }
  2725.  
  2726. ($loglisttime, $loglistampm) = split (/ /, $loglisttimeampm);
  2727. ($loglisthourhour, $loglistminuteminute) = split (/:/, $loglisttime);
  2728.  
  2729. if ((substr($loglisthourhour, 0, 1)) eq "0") {
  2730.     $loglisthour = substr($loglisthourhour, -1, 1);
  2731. } else {
  2732.     $loglisthour = $loglisthourhour;
  2733. }
  2734.  
  2735. if ((substr($loglistminuteminute, 0, 1)) eq "0") {
  2736.     $loglistminute = substr($loglistminuteminute, -1, 1);
  2737. } else {
  2738.     $loglistminute = $loglistminuteminute;
  2739. }
  2740.  
  2741. $loglistmilitaryhour = $loglisthour;
  2742.  
  2743. if ($loglistampm eq "AM") {
  2744.     $loglistampmdot = "A.M.";
  2745.     $loglistampmlower = "am";
  2746.     $loglistampmdotlower = "a.m.";
  2747. } else {
  2748.     $loglistampmdot = "P.M.";
  2749.     $loglistampmlower = "pm";
  2750.     $loglistampmdotlower = "p.m.";
  2751.     $loglistmilitaryhour = $loglistmilitaryhour + 12;
  2752. }
  2753.  
  2754. $loglistmilitaryhour = sprintf ("%2d", $loglistmilitaryhour);
  2755. $loglistmilitaryhour =~ tr/ /0/;
  2756.  
  2757. @months = ("null", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  2758.  
  2759. $loglistmonthword = $months[$loglistmonth];
  2760. $loglistmonthwordshort = substr($loglistmonthword, 0, 3);
  2761. $loglistmonthwordupper = uc($loglistmonthword);
  2762. $loglistmonthwordlower = lc($loglistmonthword);
  2763. $loglistmonthworduppershort = uc($loglistmonthwordshort);
  2764. $loglistmonthwordlowershort = lc($loglistmonthwordshort);
  2765.  
  2766. open (FUNNYFEETLOGME, "$EntriesPath/$loglistnumberpadded.cgi") || &gm_dangermouse("Can't read $EntriesPath/$loglistnumberpadded.cgi.  Please make sure that your entries/archives directory is correctly configured and is CHMODed to 777, or try running Diagnostics & Repair in the Configuration screen.");
  2767. @loglistentrylines = <FUNNYFEETLOGME>;
  2768. close (FUNNYFEETLOGME);
  2769.  
  2770. $gmcounter = 0;
  2771.  
  2772. foreach (@loglistentrylines) {
  2773.     chomp ($loglistentrylines[$gmcounter]);
  2774.     $gmcounter++;
  2775. }
  2776.  
  2777. ($loglistentrynumber, $loglistentryauthor, $loglistentrysubject, $loglistentryweekdaynumber, $loglistentrymonth, $loglistentryday, $loglistentryyearyear, $loglistentryhour, $loglistentryminute, $loglistentrysecond, $loglistentryampm, $loglistentrypositivekarma, $loglistentrynegativekarma, $loglistentrycommentsnumber, $loglistentryallowkarma, $loglistentryallowcomments, $loglistentryopenstatus) = split (/\|/, $loglistentrylines[0]);
  2778.  
  2779. $loglistentrytotalkarma = $loglistentrypositivekarma - $loglistentrynegativekarma;
  2780.  
  2781. $loglistentrypositivekarmalink = "$cgiwebpath/gm-karma.cgi?vote=positive&entry=$loglistnumberpadded";
  2782. $loglistentrynegativekarmalink = "$cgiwebpath/gm-karma.cgi?vote=negative&entry=$loglistnumberpadded";
  2783.  
  2784. open (FUNNYFEETAUTHTWO, "gm-authors.cgi") || &gm_dangermouse("Can't read the authors file.  Please make sure that gm-authors.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  2785. @gettheauthordata = <FUNNYFEETAUTHTWO>;
  2786. close (FUNNYFEETAUTHTWO);
  2787.  
  2788. $loglistentryauthoremail = "";
  2789. $loglistentryauthorhomepage = "";
  2790. $loglistentryauthorentrycount = "";
  2791.  
  2792. foreach $gettheauthordataline (@gettheauthordata) {
  2793.     chomp ($gettheauthordataline);
  2794.     @gettheauthorinfo = split (/\|/, $gettheauthordataline);
  2795.     if ($gettheauthorinfo[0] eq $loglistentryauthor) {
  2796.         $loglistentryauthoremail = $gettheauthorinfo[2];
  2797.         $loglistentryauthorhomepage = $gettheauthorinfo[3];
  2798.         $loglistentryauthorentrycount = $gettheauthorinfo[5];
  2799.     }
  2800. }
  2801.  
  2802. $loglistentryauthorsmartlink = $loglistentryauthor;
  2803. if ($loglistentryauthoremail ne "") { $loglistentryauthorsmartlink = "<A HREF=\"mailto:$loglistentryauthoremail\">$loglistentryauthor</A>"; }
  2804. if ($loglistentryauthorhomepage ne "") { $loglistentryauthorsmartlink = "<A HREF=\"$loglistentryauthorhomepage\">$loglistentryauthor</A>"; }
  2805.  
  2806. $loglistentryfilename = "$EntriesWebPath\/$loglistnumberpadded\.$entrysuffix";
  2807.  
  2808. $loglistentrycommentspostlink = "$loglistentryfilename\#comments";
  2809.  
  2810. $loglistentrycommentstatussmart = $gmsmartlinkmanycommentstemplate;
  2811.  
  2812. if ($loglistentrycommentsnumber eq "0") { $loglistentrycommentstatussmart = $gmsmartlinknocommentstemplate; }
  2813. if ($loglistentrycommentsnumber eq "1") { $loglistentrycommentstatussmart = $gmsmartlinkonecommenttemplate; }
  2814.  
  2815. $loglistentrycommentstatussmartupper = uc($loglistentrycommentstatussmart);
  2816. $loglistentrycommentstatussmartlower = lc($loglistentrycommentstatussmart);
  2817.  
  2818. $leapyearcheck = $loglistyearyear % 4;
  2819.  
  2820. $loglistmaxdaysinthismonth = 31;
  2821. if (($loglistmonthword eq "September") || ($loglistmonthword eq "April") || ($loglistmonthword eq "June") || ($loglistmonthword eq "November")) { $loglistmaxdaysinthismonth = 30; }
  2822. if ($loglistmonthword eq "February") {
  2823.     $loglistmaxdaysinthismonth = 28;
  2824.     if ($leapyearcheck eq "0") { $loglistmaxdaysinthismonth = 29; }
  2825. }
  2826. $loglistmaxdaysinpreviousmonth = 31;
  2827. if (($loglistmonthword eq "October") || ($loglistmonthword eq "May") || ($loglistmonthword eq "July") || ($loglistmonthword eq "December")) { $loglistmaxdaysinpreviousmonth = 30; }
  2828. if ($loglistmonthword eq "March") {
  2829.     $loglistmaxdaysinpreviousmonth = 28;
  2830.     if ($leapyearcheck eq "0") { $loglistmaxdaysinpreviousmonth = 29; }
  2831. }
  2832.  
  2833. $loglistweekbeginningmonth = $loglistmonth;
  2834. $loglistweekbeginningyearyear = $loglistyearyear;
  2835. $loglistweekendingmonth = $loglistmonth;
  2836. $loglistweekendingyearyear = $loglistyearyear;
  2837.  
  2838. $loglistweekbeginningday = $loglistday - $loglistentryweekdaynumber;
  2839. $loglistweekendingday = $loglistweekbeginningday + 6;
  2840.  
  2841. if ($loglistweekbeginningday < 1) {
  2842.     $loglistweekbeginningday = $loglistweekbeginningday + $loglistmaxdaysinpreviousmonth;
  2843.     if ($loglistweekbeginningday > $loglistday) { $loglistweekbeginningmonth--; }
  2844.     if ($loglistweekbeginningmonth < 1) {
  2845.         $loglistweekbeginningmonth = 12;
  2846.         $loglistweekbeginningyearyear--;
  2847.     }
  2848. }
  2849.  
  2850. if ($loglistweekendingday > $loglistmaxdaysinthismonth) {
  2851.     $loglistweekendingday = $loglistweekendingday - $loglistmaxdaysinthismonth;
  2852.     if ($loglistweekendingday < $loglistday) { $loglistweekendingmonth++; }
  2853.     if ($loglistweekendingmonth > 12) {
  2854.         $loglistweekendingmonth = 1;
  2855.         $loglistweekendingyearyear++;
  2856.     }
  2857. }
  2858.  
  2859. $loglistweekbeginningyear = substr($loglistweekbeginningyearyear, -2, 2);
  2860. $loglistweekendingyear = substr($loglistweekendingyearyear, -2, 2);
  2861.  
  2862. $loglistweekbeginningdayday = sprintf ("%2d", $loglistweekbeginningday);
  2863. $loglistweekbeginningdayday =~ tr/ /0/;
  2864. $loglistweekendingdayday = sprintf ("%2d", $loglistweekendingday);
  2865. $loglistweekendingdayday =~ tr/ /0/;
  2866. $loglistweekbeginningmonthmonth = sprintf ("%2d", $loglistweekbeginningmonth);
  2867. $loglistweekbeginningmonthmonth =~ tr/ /0/;
  2868. $loglistweekendingmonthmonth = sprintf ("%2d", $loglistweekendingmonth);
  2869. $loglistweekendingmonthmonth =~ tr/ /0/;
  2870.  
  2871. $loglistweekbeginningweekday = "Sunday";
  2872. $loglistweekbeginningmonthword = $months[$loglistweekbeginningmonth];
  2873. $loglistweekbeginningweekdayshort = substr($loglistweekbeginningweekday, 0, 3);
  2874. $loglistweekbeginningmonthwordshort = substr($loglistweekbeginningmonthword, 0, 3);
  2875. $loglistweekbeginningweekdayupper = uc($loglistweekbeginningweekday);
  2876. $loglistweekbeginningmonthwordupper = uc($loglistweekbeginningmonthword);
  2877. $loglistweekbeginningweekdaylower = lc($loglistweekbeginningweekday);
  2878. $loglistweekbeginningmonthwordlower = lc($loglistweekbeginningmonthword);
  2879. $loglistweekbeginningweekdayuppershort = uc($loglistweekbeginningweekdayshort);
  2880. $loglistweekbeginningmonthworduppershort = uc($loglistweekbeginningmonthwordshort);
  2881. $loglistweekbeginningweekdaylowershort = lc($loglistweekbeginningweekdayshort);
  2882. $loglistweekbeginningmonthwordlowershort = lc($loglistweekbeginningmonthwordshort);
  2883.  
  2884. $loglistweekendingweekday = "Saturday";
  2885. $loglistweekendingmonthword = $months[$loglistweekendingmonth];
  2886. $loglistweekendingweekdayshort = substr($loglistweekendingweekday, 0, 3);
  2887. $loglistweekendingmonthwordshort = substr($loglistweekendingmonthword, 0, 3);
  2888. $loglistweekendingweekdayupper = uc($loglistweekendingweekday);
  2889. $loglistweekendingmonthwordupper = uc($loglistweekendingmonthword);
  2890. $loglistweekendingweekdaylower = lc($loglistweekendingweekday);
  2891. $loglistweekendingmonthwordlower = lc($loglistweekendingmonthword);
  2892. $loglistweekendingweekdayuppershort = uc($loglistweekendingweekdayshort);
  2893. $loglistweekendingmonthworduppershort = uc($loglistweekendingmonthwordshort);
  2894. $loglistweekendingweekdaylowershort = lc($loglistweekendingweekdayshort);
  2895. $loglistweekendingmonthwordlowershort = lc($loglistweekendingmonthwordshort);
  2896.  
  2897. $loglistpagelink = "$EntriesWebPath\/$loglistnumberpadded\.$entrysuffix";
  2898.  
  2899. if ($keepmonthlyarchives eq "no") {
  2900.     $loglistpagearchivelogindexlink = "{{pageindexlink}}";
  2901. } else {
  2902.     if ($archiveformat eq "week") {
  2903.         $loglistpagearchivelogindexlink = "$EntriesWebPath/archive-$loglistweekbeginningmonthmonth$loglistweekbeginningdayday$loglistweekbeginningyearyear-$loglistweekendingmonthmonth$loglistweekendingdayday$loglistweekendingyearyear\.$logarchivesuffix";
  2904.     } else {
  2905.         $loglistpagearchivelogindexlink = "$EntriesWebPath/archive-$loglistmonthmonth$loglistyearyear\.$logarchivesuffix";
  2906.     }
  2907. }
  2908.  
  2909. $loglistmainbody = $loglistentrylines[2];
  2910. $loglistmorebody = $loglistentrylines[3];
  2911.  
  2912. if (($loglistmainbody =~ /\|\*\|/) || ($loglistmorebody =~ /\|\*\|/)) {
  2913.     $loglistmainbody =~ s/\|\*\|/<BR>/g;
  2914.     $loglistmorebody =~ s/\|\*\|/<BR>/g;
  2915. }
  2916. if (($loglistmainbody =~ /\n/) || ($loglistmorebody =~ /\n/)) {
  2917.     $loglistmainbody =~ s/\n/<BR>/g;
  2918.     $loglistmorebody =~ s/\n/<BR>/g;
  2919. }
  2920. if (($loglistmainbody =~ /<BR><BR>/) || ($loglistmorebody =~ /<BR><BR>/)) {
  2921.     $loglistmainbody =~ s/<BR><BR>/$gmparaseparationtemplate/g;
  2922.     $loglistmorebody =~ s/<BR><BR>/$gmparaseparationtemplate/g;
  2923. }
  2924.  
  2925. if (($censorenabled eq "both") || ($censorenabled eq "entries")) {
  2926.     unless ($censorlist eq "") {
  2927.         @censoredterms = split(/\|\*\|/, $censorlist);
  2928.         foreach $thisterm (@censoredterms) {
  2929.             unless ($thisterm eq "") {
  2930.                 if ((substr($thisterm, 0, 1) eq "[") && (substr($thisterm, -1, 1) eq "]")) {
  2931.                     $thisrealterm = $thisterm;
  2932.                     $thisrealterm =~ s/\[//g;
  2933.                     $thisrealterm =~ s/\]//g;
  2934.                     $thisrealtermlength = length($thisrealterm);
  2935.                     $thisrealtermreplace = "*" x $thisrealtermlength;
  2936.                     $thisrealtermreplacedash = "-" x $thisrealtermlength;
  2937.                     if ($loglistsubject =~ m/$thisrealterm/i) {
  2938.                         $loglistsubject =~ s/\b$thisrealterm\b/$thisrealtermreplacedash/isg;
  2939.                     }
  2940.                     if ($loglistmainbody =~ m/$thisrealterm/i) {
  2941.                         $loglistmainbody =~ s/\b$thisrealterm\b/$thisrealtermreplace/isg;
  2942.                     }
  2943.                     if ($loglistmorebody =~ m/$thisrealterm/i) {
  2944.                         $loglistmorebody =~ s/\b$thisrealterm\b/$thisrealtermreplace/isg;
  2945.                     }
  2946.                 } else {
  2947.                     $thisrealtermlength = length($thisterm);
  2948.                     $thisrealtermreplace = "*" x $thisrealtermlength;
  2949.                     $thisrealtermreplacedash = "-" x $thisrealtermlength;
  2950.                     if ($loglistsubject =~ m/$thisterm/i) {
  2951.                         $loglistsubject =~ s/\b$thisterm\b/$thisrealtermreplacedash/isg;
  2952.                     }
  2953.                     if ($loglistmainbody =~ m/$thisterm/i) {
  2954.                         $loglistmainbody =~ s/\b$thisterm\b/$thisrealtermreplace/isg;
  2955.                     }
  2956.                     if ($loglistmorebody =~ m/$thisterm/i) {
  2957.                         $loglistmorebody =~ s/\b$thisterm\b/$thisrealtermreplace/isg;
  2958.                     }
  2959.                 }
  2960.             }
  2961.         }
  2962.     }
  2963. }
  2964.  
  2965. if (($inlineformatting eq "entries") || ($inlineformatting eq "both")) {
  2966.     if (($loglistsubject =~ /\*\*(.*?)\*\*/) || ($loglistsubject =~ /\\\\(.*?)\\\\/) || ($loglistsubject =~ /__(.*?)__/)) {
  2967.         $loglistsubject =~ s/\*\*(.*?)\*\*/<B>$1<\/B>/isg;
  2968.         $loglistsubject =~ s/\\\\(.*?)\\\\/<I>$1<\/I>/isg;
  2969.         $loglistsubject =~ s/__(.*?)__/<U>$1<\/U>/isg;
  2970.     }
  2971.     if (($loglistmainbody =~ /\*\*(.*?)\*\*/) || ($loglistmainbody =~ /\\\\(.*?)\\\\/) || ($loglistmainbody =~ /__(.*?)__/)) {
  2972.         $loglistmainbody =~ s/\*\*(.*?)\*\*/<B>$1<\/B>/isg;
  2973.         $loglistmainbody =~ s/\\\\(.*?)\\\\/<I>$1<\/I>/isg;
  2974.         $loglistmainbody =~ s/__(.*?)__/<U>$1<\/U>/isg;
  2975.     }
  2976.     if (($loglistmorebody =~ /\*\*(.*?)\*\*/) || ($loglistmorebody =~ /\\\\(.*?)\\\\/) || ($loglistmorebody =~ /__(.*?)__/)) {
  2977.         $loglistmorebody =~ s/\*\*(.*?)\*\*/<B>$1<\/B>/isg;
  2978.         $loglistmorebody =~ s/\\\\(.*?)\\\\/<I>$1<\/I>/isg;
  2979.         $loglistmorebody =~ s/__(.*?)__/<U>$1<\/U>/isg;
  2980.     }
  2981. }
  2982.  
  2983. }
  2984.  
  2985. # --------------------------
  2986. # entry list sub-sub routine
  2987. # --------------------------
  2988.  
  2989. sub entrylistsubsub {
  2990.  
  2991. $listsubsub =~ s/{{year}}/$loglistyear/gi;
  2992. $listsubsub =~ s/{{yearyear}}/$loglistyearyear/gi;
  2993. $listsubsub =~ s/{{month}}/$loglistmonth/gi;
  2994. $listsubsub =~ s/{{monthmonth}}/$loglistmonthmonth/gi;
  2995. $listsubsub =~ s/{{monthword}}/$loglistmonthword/gi;
  2996. $listsubsub =~ s/{{monthwordshort}}/$loglistmonthword/gi;
  2997. $listsubsub =~ s/{{monthwordupper}}/$loglistmonthwordupper/gi;
  2998. $listsubsub =~ s/{{monthwordlower}}/$loglistmonthwordlower/gi;
  2999. $listsubsub =~ s/{{monthworduppershort}}/$loglistmonthworduppershort/gi;
  3000. $listsubsub =~ s/{{monthwordlowershort}}/$loglistmonthwordlowershort/gi;
  3001. $listsubsub =~ s/{{day}}/$loglistday/gi;
  3002. $listsubsub =~ s/{{dayday}}/$loglistdayday/gi;
  3003. $listsubsub =~ s/{{hour}}/$loglisthour/gi;
  3004. $listsubsub =~ s/{{hourhour}}/$loglisthourhour/gi;
  3005. $listsubsub =~ s/{{militaryhour}}/$loglistmilitaryhour/gi;
  3006. $listsubsub =~ s/{{minute}}/$loglistminute/gi;
  3007. $listsubsub =~ s/{{minuteminute}}/$loglistminuteminute/gi;
  3008. $listsubsub =~ s/{{ampm}}/$loglistampm/gi;
  3009. $listsubsub =~ s/{{ampmlower}}/$loglistampm/gi;
  3010. $listsubsub =~ s/{{ampmdot}}/$loglistampmdot/gi;
  3011. $listsubsub =~ s/{{ampmdotlower}}/$loglistampmdotlower/gi;
  3012. $listsubsub =~ s/{{author}}/$loglistauthor/gi;
  3013. $listsubsub =~ s/{{entrysubject}}/$loglistsubject/gi;
  3014. $listsubsub =~ s/{{entrynumber}}/$loglistnumber/gi;
  3015. $listsubsub =~ s/{{entrynumberpadded}}/$loglistnumberpadded/gi;
  3016. $listsubsub =~ s/{{pagelink}}/$loglistpagelink/gi;
  3017. $listsubsub =~ s/{{pagearchivelogindexlink}}/$loglistpagearchivelogindexlink/gi;
  3018.  
  3019. if ($listsubsub =~ m/{{author/i) {
  3020.     $listsubsub =~ s/{{author}}/$loglistentryauthor/gi;
  3021.     $listsubsub =~ s/{{authoremail}}/$loglistentryauthoremail/gi;
  3022.     $listsubsub =~ s/{{authorhomepage}}/$loglistentryauthorhomepage/gi;
  3023.     $listsubsub =~ s/{{authorentrycount}}/$loglistentryauthorentrycount/gi;
  3024. }
  3025.  
  3026. if (($listsubsub =~ m/{{weekbeginning/i) || ($listsubsub =~ m/{{weekending/i)) {
  3027.     $listsubsub =~ s/{{weekbeginningday}}/$loglistweekbeginningday/gi;
  3028.     $listsubsub =~ s/{{weekbeginningdayday}}/$loglistweekbeginningdayday/gi;
  3029.     $listsubsub =~ s/{{weekbeginningmonth}}/$loglistweekbeginningmonth/gi;
  3030.     $listsubsub =~ s/{{weekbeginningmonthmonth}}/$loglistweekbeginningmonthmonth/gi;
  3031.     $listsubsub =~ s/{{weekbeginningyear}}/$loglistweekbeginningyear/gi;
  3032.     $listsubsub =~ s/{{weekbeginningyearyear}}/$loglistweekbeginningyearyear/gi;
  3033.     $listsubsub =~ s/{{weekbeginningweekday}}/$loglistweekbeginningweekday/gi;
  3034.     $listsubsub =~ s/{{weekbeginningweekdayshort}}/$loglistweekbeginningweekdayshort/gi;    
  3035.     $listsubsub =~ s/{{weekbeginningmonthword}}/$loglistweekbeginningmonthword/gi;
  3036.     $listsubsub =~ s/{{weekbeginningmonthwordshort}}/$loglistweekbeginningmonthwordshort/gi;
  3037.     $listsubsub =~ s/{{weekbeginningweekdayupper}}/$loglistweekbeginningweekdayupper/gi;
  3038.     $listsubsub =~ s/{{weekbeginningmonthwordupper}}/$loglistweekbeginningmonthwordupper/gi;
  3039.     $listsubsub =~ s/{{weekbeginningweekdaylower}}/$loglistweekbeginningweekdaylower/gi;
  3040.     $listsubsub =~ s/{{weekbeginningmonthwordlower}}/$loglistweekbeginningmonthwordlower/gi;
  3041.     $listsubsub =~ s/{{weekbeginningweekdayuppershort}}/$loglistweekbeginningweekdayuppershort/gi;
  3042.     $listsubsub =~ s/{{weekbeginningmonthworduppershort}}/$loglistweekbeginningmonthworduppershort/gi;
  3043.     $listsubsub =~ s/{{weekbeginningweekdaylowershort}}/$loglistweekbeginningweekdaylowershort/gi;
  3044.     $listsubsub =~ s/{{weekbeginningmonthwordlowershort}}/$loglistweekbeginningmonthwordlowershort/gi;
  3045.     $listsubsub =~ s/{{weekendingday}}/$loglistweekendingday/gi;
  3046.     $listsubsub =~ s/{{weekendingdayday}}/$loglistweekendingdayday/gi;
  3047.     $listsubsub =~ s/{{weekendingmonth}}/$loglistweekendingmonth/gi;
  3048.     $listsubsub =~ s/{{weekendingmonthmonth}}/$loglistweekendingmonthmonth/gi;
  3049.     $listsubsub =~ s/{{weekendingyear}}/$loglistweekendingyear/gi;
  3050.     $listsubsub =~ s/{{weekendingyearyear}}/$loglistweekendingyearyear/gi;
  3051.     $listsubsub =~ s/{{weekendingweekday}}/$loglistweekendingweekday/gi;
  3052.     $listsubsub =~ s/{{weekendingweekdayshort}}/$loglistweekendingweekdayshort/gi;
  3053.     $listsubsub =~ s/{{weekendingmonthword}}/$loglistweekendingmonthword/gi;
  3054.     $listsubsub =~ s/{{weekendingmonthwordshort}}/$loglistweekendingmonthwordshort/gi;
  3055.     $listsubsub =~ s/{{weekendingweekdayupper}}/$loglistweekendingweekdayupper/gi;
  3056.     $listsubsub =~ s/{{weekendingmonthwordupper}}/$loglistweekendingmonthwordupper/gi;
  3057.     $listsubsub =~ s/{{weekendingweekdaylower}}/$loglistweekendingweekdaylower/gi;
  3058.     $listsubsub =~ s/{{weekendingmonthwordlower}}/$loglistweekendingmonthwordlower/gi;
  3059.     $listsubsub =~ s/{{weekendingweekdayuppershort}}/$loglistweekendingweekdayuppershort/gi;
  3060.     $listsubsub =~ s/{{weekendingmonthworduppershort}}/$loglistweekendingmonthworduppershort/gi;
  3061.     $listsubsub =~ s/{{weekendingweekdaylowershort}}/$loglistweekendingweekdaylowershort/gi;
  3062.     $listsubsub =~ s/{{weekendingmonthwordlowershort}}/$loglistweekendingmonthwordlowershort/gi;
  3063. }
  3064.  
  3065. if (($listsubsub =~ m/karma}}/i) || ($listsubsub =~ m/karmalink}}/i)) {
  3066.     $listsubsub =~ s/{{positivekarmalink}}/$loglistentrypositivekarmalink/gi;
  3067.     $listsubsub =~ s/{{negativekarmalink}}/$loglistentrynegativekarmalink/gi;
  3068.     $listsubsub =~ s/{{positivekarma}}/$loglistentrypositivekarma/gi;
  3069.     $listsubsub =~ s/{{negativekarma}}/$loglistentrynegativekarma/gi;
  3070.     $listsubsub =~ s/{{totalkarma}}/$loglistentrytotalkarma/gi;
  3071. }
  3072.  
  3073. if ($listsubsub =~ m/{{comments/i) {
  3074.     $listsubsub =~ s/{{commentsnumber}}/$loglistentrycommentsnumber/gi;
  3075.     $listsubsub =~ s/{{commentstatussmart}}/$loglistentrycommentstatussmart/gi;
  3076.     $listsubsub =~ s/{{commentstatussmartupper}}/$loglistentrycommentstatussmartupper/gi;
  3077.     $listsubsub =~ s/{{commentstatussmartlower}}/$loglistentrycommentstatussmartlower/gi;
  3078. }
  3079.  
  3080. if ($listsubsub =~ m/{{entry/i) {
  3081.     $listsubsub =~ s/{{entrymainbody}}/$loglistmainbody/gi;
  3082.     $listsubsub =~ s/{{entrymorebody}}/$loglistmorebody/gi;
  3083.     $listsubsub =~ s/{{entrycomments}}/$loglistcomments/gi;
  3084.     if ($listsubsub =~ m/{{entrymainbodyfirstwords (\d+)}}/i) {
  3085.         until ($listsubsub !~ m/{{entrymainbodyfirstwords (\d+)}}/isg) {
  3086.             $firstwordscount = $1;
  3087.             $grabmainbodywords = $loglistmainbody;
  3088.             if ($grabmainbodywords =~ m/{{link/i) {
  3089.                 $grabmainbodywords =~ s/({{linkmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  3090.                 $grabmainbodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  3091.                 $grabmainbodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  3092. ###########################################################
  3093. # 9/2/2001 - CHERYL LAMBERT
  3094. # ADDED {{linkblank}} TEMPLATE VARIABLE SO THAT I CAN USE target="_blank" TO OPEN NEW WINDOWS
  3095.         $grabmainbodywords =~ s/({{linkblankmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  3096.         $grabmainbodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  3097.         $grabmainbodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  3098. ###########################################################
  3099.             }
  3100.             if ($grabmainbodywords =~ m/{{email/i) {
  3101.                 $grabmainbodywords =~ s/({{emailmo) (\S+\@\S+?) (.+?)(\|)(.+?)(}})/$3/isg;
  3102.                 $grabmainbodywords =~ s/({{email) (\S+\@\S+?)(}})/$2/isg;
  3103.                 $grabmainbodywords =~ s/({{email) (\S+\@\S+?) (.+?)(}})/$3/isg;
  3104.             }
  3105.             $grabmainbodywords =~ s/<([^>]|\n)*>/ /g;
  3106.             $grabmainbodywords =~ s/{{(.*?)}}/ /g;
  3107.             $grabmainbodywords =~ s/\n/ /g;
  3108.             $grabmainbodywords =~ s/\r/ /g;
  3109.             $grabmainbodywords =~ s/\|\*\|/ /g;
  3110.             $grabmainbodywords =~ s/^\s+//;
  3111.             $grabmainbodywords =~ s/\s+$//;
  3112.             $grabmainbodywords =~ s/\s{2,}/ /g;
  3113.             @grabmainbodywordslist = split (/ /, $grabmainbodywords);
  3114.             $countwordsfromhere = 0;
  3115.             (@finalmainbodywordslist, @finalmainbodywordslist = ());
  3116.             if ($firstwordscount < 1) { $firstwordscount = 1; }
  3117.             do {
  3118.                 $finalmainbodywordslist[$countwordsfromhere] = $grabmainbodywordslist[$countwordsfromhere];
  3119.                 $countwordsfromhere++;
  3120.             } until $countwordsfromhere eq $firstwordscount;
  3121.             $finalmainbodyfirstwords = join (" ", @finalmainbodywordslist);
  3122.             $finalmainbodyfirstwords =~ s/^\s+//;
  3123.             $finalmainbodyfirstwords =~ s/\s+$//;
  3124.             $finalmainbodyfirstwords =~ s/\s{2,}//g;
  3125.             if (substr($finalmainbodyfirstwords, -1) =~ /\W/) { chop($finalmainbodyfirstwords); }
  3126.             if (substr($finalmainbodyfirstwords, -1) eq / /) { chop($finalmainbodyfirstwords); }
  3127.             $listsubsub =~ s/{{entrymainbodyfirstwords ($firstwordscount)}}/$finalmainbodyfirstwords/isg;
  3128.         }
  3129.     }
  3130.     if ($listsubsub =~ m/{{entrymorebodyfirstwords (\d+)}}/i) {
  3131.         until ($listsubsub !~ m/{{entrymorebodyfirstwords (\d+)}}/isg) {
  3132.             $firstwordscount = $1;
  3133.             if ($loglistmorebody eq "") {
  3134.                 $listsubsub =~ s/{{entrymorebodyfirstwords ($firstwordscount)}}//isg;
  3135.             } else {
  3136.                 $grabmorebodywords = $loglistmorebody;
  3137.                 if ($grabmorebodywords =~ m/{{link/i) {
  3138.                     $grabmorebodywords =~ s/({{linkmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  3139.                     $grabmorebodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  3140.                     $grabmorebodywords =~ s/({{link) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  3141. ###########################################################
  3142. # 9/2/2001 - CHERYL LAMBERT
  3143. # ADDED {{linkblank}} TEMPLATE VARIABLE SO THAT I CAN USE target="_blank" TO OPEN NEW WINDOWS
  3144.           $grabmorebodywords =~ s/({{linkblankmo) (http|https|ftp)(:\/\/\S+?) (.+?)(\|)(.+?)(}})/$4/isg;
  3145.           $grabmorebodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?)(}})/$2$3/isg;
  3146.           $grabmorebodywords =~ s/({{linkblank) (http|https|ftp)(:\/\/\S+?) (.+?)(}})/$4/isg;
  3147. ###########################################################
  3148.                 }
  3149.                 if ($grabmorebodywords =~ m/{{email/i) {
  3150.                     $grabmorebodywords =~ s/({{emailmo) (\S+\@\S+?) (.+?)(\|)(.+?)(}})/$3/isg;
  3151.                     $grabmorebodywords =~ s/({{email) (\S+\@\S+?)(}})/$2/isg;
  3152.                     $grabmorebodywords =~ s/({{email) (\S+\@\S+?) (.+?)(}})/$3/isg;
  3153.                 }
  3154.                 $grabmorebodywords =~ s/<([^>]|\n)*>/ /g;
  3155.                 $grabmorebodywords =~ s/{{(.*?)}}/ /g;
  3156.                 $grabmorebodywords =~ s/\n/ /g;
  3157.                 $grabmorebodywords =~ s/\r/ /g;
  3158.                 $grabmorebodywords =~ s/\|\*\|/ /g;
  3159.                 $grabmorebodywords =~ s/^\s+//;
  3160.                 $grabmorebodywords =~ s/\s+$//;
  3161.                 $grabmorebodywords =~ s/\s{2,}/ /g;
  3162.                 @grabmorebodywordslist = split (/ /, $grabmorebodywords);
  3163.                 $countwordsfromhere = 0;
  3164.                 (@finalmorebodywordslist, @finalmorebodywordslist = ());
  3165.                 if ($firstwordscount < 1) { $firstwordscount = 1; }
  3166.                 do {
  3167.                     $finalmorebodywordslist[$countwordsfromhere] = $grabmorebodywordslist[$countwordsfromhere];
  3168.                     $countwordsfromhere++;
  3169.                 } until $countwordsfromhere eq $firstwordscount;
  3170.                 $finalmorebodyfirstwords = join (" ", @finalmorebodywordslist);
  3171.                 $finalmorebodyfirstwords =~ s/^\s+//;
  3172.                 $finalmorebodyfirstwords =~ s/\s+$//;
  3173.                 $finalmorebodyfirstwords =~ s/\s{2,}//g;
  3174.                 if (substr($finalmorebodyfirstwords, -1) =~ /\W/) { chop($finalmorebodyfirstwords); }
  3175.                 if (substr($finalmorebodyfirstwords, -1) eq / /) { chop($finalmorebodyfirstwords); }
  3176.                 $listsubsub =~ s/{{entrymorebodyfirstwords ($firstwordscount)}}/$finalmorebodyfirstwords/isg;
  3177.             }
  3178.         }
  3179.     }
  3180. }
  3181.  
  3182. }
  3183.  
  3184. # ----------------------------------
  3185. # generate external author variables
  3186. # ----------------------------------
  3187.  
  3188. sub gm_generateexternalauthorvariables {
  3189.  
  3190. open (FUNNYFEETAUTHORS, "gm-authors.cgi") || &gm_dangermouse("Can't read the authors file.  Please make sure that gm-authors.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files; also try running Diagnostics & Repair from the Configuration screen.");
  3191. @gettheexternalauthordata = <FUNNYFEETAUTHORS>;
  3192. close (FUNNYFEETAUTHORS);
  3193.  
  3194. foreach $gettheexternalauthordataline (@gettheexternalauthordata) {
  3195.     chomp ($gettheexternalauthordataline);
  3196.     @gettheexternalauthorinfo = split (/\|/, $gettheexternalauthordataline);
  3197.     $thisexternalauthor = $gettheexternalauthorinfo[0];
  3198.     $thisexternalauthoremail = $gettheexternalauthorinfo[2];
  3199.     $thisexternalauthorhomepage = $gettheexternalauthorinfo[3];
  3200.     $thisexternalauthorentrycount = $gettheexternalauthorinfo[5];
  3201.  
  3202.     $thisexternalauthorsmartlink = $thisexternalauthor;
  3203.     if ($thisexternalauthoremail ne "") { $thisexternalauthorsmartlink = "<A HREF=\"mailto:$thisentryauthoremail\">$thisentryauthor</A>"; }
  3204.     if ($thisexternalauthorhomepage ne "") { $thisexternalauthorsmartlink = "<A HREF=\"$thisentryauthorhomepage\">$thisentryauthor</A>"; }
  3205.  
  3206.     $entryreturn =~ s/{{authoremail $thisexternalauthor}}/$thisexternalauthoremail/isg;
  3207.     $entryreturn =~ s/{{authorhomepage $thisexternalauthor}}/$thisexternalauthorhomepage/isg;
  3208.     $entryreturn =~ s/{{authorsmartlink $thisexternalauthor}}/$thisexternalauthorsmartlink/isg;
  3209.     $entryreturn =~ s/{{authorentrycount $thisexternalauthor}}/$thisexternalauthorentrycount/isg;
  3210. }
  3211.  
  3212. }
  3213.  
  3214. # -----------------
  3215. # generate calendar
  3216. # -----------------
  3217.  
  3218. sub gm_generatecalendar {
  3219.  
  3220. $usethisentrydayday = sprintf ("%2d", $usethisentryday);
  3221. $usethisentrydayday =~ tr/ /0/;
  3222. $usethisentrymonthmonth = sprintf ("%2d", $usethisentrymonth);
  3223. $usethisentrymonthmonth =~ tr/ /0/;
  3224. $usethisentryyear = substr($usethisentryyearyear, -2, 2);
  3225. $usethisentrymonthwordupper = uc($usethisentrymonthword);
  3226. $usethisentrymonthwordlower = lc($usethisentrymonthword);
  3227. $usethisentrymonthwordshort = substr($usethisentrymonthword, 0, 3);
  3228. $usethisentrymonthworduppershort = uc($usethisentrymonthwordshort);
  3229. $usethisentrymonthwordlowershort = lc($usethisentrymonthwordshort);
  3230.  
  3231. $leapyearcheck = $usethisentryyearyear % 4;
  3232.  
  3233. $maxdaysinthismonth = 31;
  3234. if (($usethisentrymonthword eq "September") || ($usethisentrymonthword eq "April") || ($usethisentrymonthword eq "June") || ($usethisentrymonthword eq "November")) { $maxdaysinthismonth = 30; }
  3235. if ($usethisentrymonthword eq "February") {
  3236.     $maxdaysinthismonth = 28;
  3237.     if ($leapyearcheck eq "0") { $maxdaysinthismonth = 29; }
  3238. }
  3239.  
  3240. $maxdaysinpreviousmonth = 31;
  3241. if (($usethisentrymonthword eq "October") || ($usethisentrymonthword eq "May") || ($usethisentrymonthword eq "July") || ($usethisentrymonthword eq "December")) { $maxdaysinpreviousmonth = 30; }
  3242. if ($usethisentrymonthword eq "March") {
  3243.     $maxdaysinpreviousmonth = 28;
  3244.     if ($leapyearcheck eq "0") { $maxdaysinpreviousmonth = 29; }
  3245. }
  3246.  
  3247. $calendarweekday[$usethisentryweekdaynumber] = $usethisentryday;
  3248. $weekcountfrom = $usethisentryweekdaynumber;
  3249. $weekcountfromday = $usethisentryday;
  3250. $weekcountspecial = "none";
  3251.  
  3252. unless ($weekcountfrom eq "0") {
  3253.     do {
  3254.         $weekcountfrom--;
  3255.         $weekcountfromday--;
  3256.         if ($weekcountfromday eq 0) {
  3257.             $weekcountfromday = $maxdaysinpreviousmonth;
  3258.             $weekcountspecial = "gotolastmonth";
  3259.         }
  3260.         unless ($weekcountfrom < 0) { $calendarweekday[$weekcountfrom] = $weekcountfromday; }
  3261.     } until $weekcountfrom eq "0";
  3262. }
  3263.  
  3264. $weekcountfrom = $usethisentryweekdaynumber;
  3265. $weekcountfromday = $usethisentryday;
  3266.  
  3267. unless ($weekcountfrom eq "6") {
  3268.     do {
  3269.         $weekcountfrom++;
  3270.         $weekcountfromday++;
  3271.         if ($weekcountfromday > $maxdaysinthismonth) {
  3272.             $weekcountfromday = 1;
  3273.             $weekcountspecial = "gotonextmonth";
  3274.         }
  3275.         unless ($weekcountfrom > 6) { $calendarweekday[$weekcountfrom] = $weekcountfromday; }
  3276.     } until $weekcountfrom eq "6";
  3277. }
  3278.  
  3279. $countfromhere = $usethisentryday;
  3280. $calendardataday[$usethisentryday] = $usethisentryweekdaynumber;
  3281.  
  3282. unless ($countfromhere eq "1") {
  3283.     do {
  3284.         $thistempday = $calendardataday[$countfromhere];
  3285.         $thistempday--;
  3286.         $countfromhere--;
  3287.         if ($thistempday < 0) { $thistempday = 6; }
  3288.         $calendardataday[$countfromhere] = $thistempday;
  3289.     } until $countfromhere eq "1";
  3290. }
  3291.  
  3292. $weekcountfromday = $usethisentryday;
  3293. $countfromhere = $usethisentryday;
  3294.  
  3295. unless ($countfromhere eq $maxdaysinthismonth) {
  3296.     do {
  3297.         $thistempday = $calendardataday[$countfromhere];
  3298.         $thistempday++;
  3299.         $countfromhere++;
  3300.         if ($thistempday > 6) { $thistempday = 0; }
  3301.         $calendardataday[$countfromhere] = $thistempday;
  3302.     } until $countfromhere eq $maxdaysinthismonth;
  3303. }
  3304.  
  3305. $calendarfull = $gmcalendartablebeginningtemplate;
  3306.  
  3307. $calendarfull .= "$gmcalendarblankcelltemplate" x $calendardataday[1];
  3308.  
  3309. open (FUNNYFEETLIST, "gm-entrylist.cgi") || &gm_dangermouse("Can't read the entry list file.  Please make sure that gm-entrylist.cgi is in the same directory as all your other Greymatter files and is CHMODed to 666; also, try running Diagnostics & Repair in the Configuration screen.");
  3310. @loglistloglines = <FUNNYFEETLIST>;
  3311. close (FUNNYFEETLIST);
  3312.  
  3313. $loglistdates = "";
  3314.  
  3315. foreach $thisloglistline (@loglistloglines) {
  3316.     ($thisloglistnumber, $thisloglistauthor, $thisloglistsubject, $thisloglistdate, $thisloglisttimeampm, $thisloglistopenstatus, $thisloglistmorestatus) = split (/\|/, $thisloglistline);
  3317.     unless ($thisloglistopenstatus eq "C") { $loglistdates .= "$thisloglistdate "; }
  3318. }
  3319.  
  3320. $weekcountfrom = 0;
  3321. $calendarweekfull = "";
  3322.  
  3323. do {
  3324.     $currentcountday = $calendarweekday[$weekcountfrom];
  3325.     $currentcountmonth = $usethisentrymonth;
  3326.     $currentcountyearyear = $usethisentryyearyear;
  3327.     if (($currentcountday > 20) && ($weekcountspecial eq "gotolastmonth")) {
  3328.         $currentcountmonth--;
  3329.         if ($currentcountmonth < 1) {
  3330.             $currentcountmonth = 12;
  3331.             $currentcountyearyear--;
  3332.         }
  3333.     }
  3334.     if (($currentcountday < 10) && ($weekcountspecial eq "gotonextmonth")) {
  3335.         $currentcountmonth++;
  3336.         if ($currentcountmonth > 12) {
  3337.             $currentcountmonth = 1;
  3338.             $currentcountyearyear++;
  3339.         }
  3340.     }
  3341.     $currentcountdayday = sprintf ("%2d", $currentcountday);
  3342.     $currentcountdayday =~ tr/ /0/;
  3343.     $currentcountmonthmonth = sprintf ("%2d", $currentcountmonth);
  3344.     $currentcountmonthmonth =~ tr/ /0/;
  3345.     $currentcountyear = substr($currentcountyearyear, -2, 2);
  3346.     $thisweeklistdate = "$currentcountmonthmonth\/$currentcountdayday\/$currentcountyear";
  3347.     if ($loglistdates =~ /$thisweeklistdate/) {
  3348.         if ($generateentrypages eq "no") {
  3349.             foreach $thisloglistline (@loglistloglines) {
  3350.                 chomp ($thisloglistline);
  3351.                 ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  3352.                 if ($loglistdate eq $thisweeklistdate) {
  3353.                     &gm_getloglistvariables;
  3354.                     $listsubsub = $gmcalendarweekfulldaytemplate;
  3355.                     &entrylistsubsub;
  3356.                     $calendarweekfull .= $listsubsub;
  3357.                 }
  3358.             }
  3359.         } else {
  3360.             $thiscalendarweeklink = "";
  3361.             foreach $thisloglistline (@loglistloglines) {
  3362.                 chomp ($thisloglistline);
  3363.                 ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  3364.                 if (($loglistdate eq $thisweeklistdate) && ($thiscalendarweeklink eq "")) {
  3365.                     unless (($thisloglistmorestatus eq "N") && ($linktocalendarentries eq "more")) {
  3366.                         $thiscalendarweeklink = "yes";
  3367.                     }
  3368.                 }
  3369.             }
  3370.             if ($thiscalendarweeklink eq "") {
  3371.                 $listsubsub = $gmcalendarweekfulldaytemplate;
  3372.                 $listsubsub =~ s/{{day}}/$currentcountday/g;
  3373.                 $listsubsub =~ s/{{day}}/$currentcountday/g;
  3374.                 $listsubsub =~ s/{{month}}/$currentcountmonth/g;
  3375.                 $listsubsub =~ s/{{monthmonth}}/$currentcountmonthmonth/g;
  3376.                 $listsubsub =~ s/{{year}}/$currentcountyear/g;
  3377.                 $listsubsub =~ s/{{yearyear}}/$currentcountyearyear/g;
  3378.                 $calendarweekfull .= $listsubsub;
  3379.             } else {
  3380.                 foreach $thisloglistline (@loglistloglines) {
  3381.                     chomp ($thisloglistline);
  3382.                     ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  3383.                     if (($loglistdate eq $thisweeklistdate) && ($thiscalendarweeklink eq "yes") && ($loglistopenstatus ne "C")) {
  3384.                         &gm_getloglistvariables;
  3385.                         $listsubsub = $gmcalendarweekfulldaylinktemplate;
  3386.                         &entrylistsubsub;
  3387.                         $calendarweekfull .= $listsubsub;
  3388.                         $thiscalendarweeklink = "";
  3389.                     }
  3390.                 }
  3391.             }
  3392.         }
  3393.     } else {
  3394.         $listsubsub = $gmcalendarweekfulldaytemplate;
  3395.         $listsubsub =~ s/{{day}}/$currentcountday/g;
  3396.         $listsubsub =~ s/{{day}}/$currentcountday/g;
  3397.         $listsubsub =~ s/{{month}}/$currentcountmonth/g;
  3398.         $listsubsub =~ s/{{monthmonth}}/$currentcountmonthmonth/g;
  3399.         $listsubsub =~ s/{{year}}/$currentcountyear/g;
  3400.         $listsubsub =~ s/{{yearyear}}/$currentcountyearyear/g;
  3401.         $calendarweekfull .= $listsubsub;
  3402.     }
  3403.     $weekcountfrom++;
  3404. } until $weekcountfrom eq "7";
  3405.  
  3406. $countfromhere = 1;
  3407.  
  3408. do {
  3409.     $countfromherepadded = sprintf ("%2d", $countfromhere);
  3410.     $countfromherepadded =~ tr/ /0/;
  3411.     $thislistdate = "$usethisentrymonthmonth\/$countfromherepadded\/$usethisentryyear";
  3412.     if ($loglistdates =~ /$thislistdate/) {
  3413.         if ($generateentrypages eq "no") {
  3414.             foreach $thisloglistline (@loglistloglines) {
  3415.                 chomp ($thisloglistline);
  3416.                 ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  3417.                 if ($loglistdate eq $thislistdate) {
  3418.                     &gm_getloglistvariables;
  3419.                     $listsubsub = $gmcalendarfullcelltemplate;
  3420.                     &entrylistsubsub;
  3421.                     $calendarfull .= $listsubsub;
  3422.                 }
  3423.             }
  3424.         } else {
  3425.             $thiscalendarlink = "";
  3426.             foreach $thisloglistline (@loglistloglines) {
  3427.                 chomp ($thisloglistline);
  3428.                 ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  3429.                 if (($loglistdate eq $thislistdate) && ($thiscalendarlink eq "")) {
  3430.                     unless (($loglistmorestatus eq "N") && ($linktocalendarentries eq "more")) {
  3431.                         $thiscalendarlink = "yes";
  3432.                     }
  3433.                 }
  3434.             }
  3435.             if ($thiscalendarlink eq "") {
  3436.                 $listsubsub = $gmcalendarfullcelltemplate;
  3437.                 $listsubsub =~ s/{{day}}/$countfromhere/g;
  3438.                 $listsubsub =~ s/{{day}}/$countfromherepadded/g;
  3439.                 $calendarfull .= $listsubsub;
  3440.             } else {
  3441.                 foreach $thisloglistline (@loglistloglines) {
  3442.                     chomp ($thisloglistline);
  3443.                     ($loglistnumber, $loglistauthor, $loglistsubject, $loglistdate, $loglisttimeampm, $loglistopenstatus, $loglistmorestatus) = split (/\|/, $thisloglistline);
  3444.                     if (($loglistdate eq $thislistdate) && ($thiscalendarlink eq "yes") && ($loglistopenstatus ne "C")) {
  3445.                         &gm_getloglistvariables;
  3446.                         $listsubsub = $gmcalendarfullcelllinktemplate;
  3447.                         &entrylistsubsub;
  3448.                         $calendarfull .= $listsubsub;
  3449.                         $thiscalendarlink = "";
  3450.                     }
  3451.                 }
  3452.             }
  3453.         }
  3454.     } else {
  3455.         $listsubsub = $gmcalendarfullcelltemplate;
  3456.         $listsubsub =~ s/{{day}}/$countfromhere/g;
  3457.         $listsubsub =~ s/{{day}}/$countfromherepadded/g;
  3458.         $calendarfull .= $listsubsub;
  3459.     }
  3460.     if ($calendardataday[$countfromhere] eq "6") { $calendarfull .= "</TR>\n<TR>"; }
  3461.     $countfromhere++;
  3462. } until $countfromhere > $maxdaysinthismonth;
  3463.  
  3464. $endofcaldisplay = 6 - $calendardataday[$maxdaysinthismonth];
  3465. $calendarfull .= "$gmcalendarblankcelltemplate" x $endofcaldisplay;
  3466. $calendarfull .= $gmcalendartableendingtemplate;
  3467.  
  3468. $calendarfull =~ s/{{month}}/$usethisentrymonth/g;
  3469. $calendarfull =~ s/{{monthmonth}}/$usethisentrymonthmonth/g;
  3470. $calendarfull =~ s/{{year}}/$usethisentryyear/g;
  3471. $calendarfull =~ s/{{yearyear}}/$usethisentryyearyear/g;
  3472. $calendarfull =~ s/{{monthword}}/$usethisentrymonthword/g;
  3473. $calendarfull =~ s/{{monthwordupper}}/$usethisentrymonthwordupper/g;
  3474. $calendarfull =~ s/{{monthwordlower}}/$usethisentrymonthwordlower/g;
  3475. $calendarfull =~ s/{{monthwordshort}}/$usethisentrymonthwordshort/g;
  3476. $calendarfull =~ s/{{monthworduppershort}}/$usethisentrymonthworduppershort/g;
  3477. $calendarfull =~ s/{{monthwordlowershort}}/$usethisentrymonthwordlowershort/g;
  3478.  
  3479. }
  3480.  
  3481. # -----------------
  3482. # log the author in
  3483. # -----------------
  3484.  
  3485. sub gm_login {
  3486.  
  3487. if (!(open(CHECKMATE,"gm-counter.cgi"))) {
  3488.     &gm_dangermouse("gm-counter.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 666.");
  3489. }
  3490. close(CHECKMATE);
  3491.  
  3492. if (!(open(CHECKMATE,"gm-karma.cgi"))) {
  3493.     &gm_dangermouse("gm-karma.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 755.");
  3494. }
  3495. close(CHECKMATE);
  3496.  
  3497. if (!(open(CHECKMATE,"gm-comments.cgi"))) {
  3498.     &gm_dangermouse("gm-comments.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 755.");
  3499. }
  3500. close(CHECKMATE);
  3501.  
  3502. if (!(open(CHECKMATE,"gm-upload.cgi"))) {
  3503.     &gm_dangermouse("gm-upload.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 755.");
  3504. }
  3505. close(CHECKMATE);
  3506.  
  3507. if (!(open(CHECKMATE,"gm-entrylist.cgi"))) {
  3508.     &gm_dangermouse("gm-entrylist.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 666.");
  3509. }
  3510. close(CHECKMATE);
  3511.  
  3512. if (!(open(CHECKMATE,"gm-cplog.cgi"))) {
  3513.     &gm_dangermouse("gm-cplog.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 666.");
  3514. }
  3515. close(CHECKMATE);
  3516.  
  3517. if (!(open(CHECKMATE,"gm-authors.cgi"))) {
  3518.     &gm_dangermouse("gm-authors.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 666.");
  3519. }
  3520. close(CHECKMATE);
  3521.  
  3522. if (!(open(CHECKMATE,"gm-templates.cgi"))) {
  3523.     &gm_dangermouse("gm-templates.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 666.");
  3524. }
  3525. close(CHECKMATE);
  3526.  
  3527. if (!(open(CHECKMATE,"gm-banlist.cgi"))) {
  3528.     &gm_dangermouse("gm-banlist.cgi is missing.  Please upload this file to the same directory as all the other Greymatter cgi files, and make sure you CHMOD it to 666.");
  3529. }
  3530. close(CHECKMATE);
  3531.  
  3532. if ($loginnotice eq "") { $loginnotice = qq(<B><FONT COLOR="#000000">Login Prompt</font></B><P>); }
  3533.  
  3534. &gm_readconfig;
  3535.  
  3536. if ($cookiesallowed eq "no") {
  3537.     $getnameandpwcookie = "";
  3538. } else {
  3539.     $getnameandpwcookie = "<SCRIPT TYPE=\"text/javascript\" LANGUAGE=\"JavaScript\">\n<!--//\ndocument.gmloginform.authorname.value = getCookie(\"gmcookiename\");\ndocument.gmloginform.authorpassword.value = getCookie(\"gmcookiepw\");\ndocument.gmloginform.authorname.focus();\n//-->\n</SCRIPT>";
  3540. }
  3541.  
  3542. print<<GMLOGIN;
  3543.  
  3544. $gmheadtag
  3545.  
  3546. $gmframetop
  3547. $loginnotice
  3548.  
  3549. <FORM ACTION="gm.cgi" METHOD=POST NAME="gmloginform"><TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0><TR><TD ALIGN=RIGHT>$gmfonttag Author:</font></TD><TD ALIGN=LEFT></font><INPUT TYPE=TEXT CLASS="textinput" SIZE=20 NAME="authorname" STYLE="width: 200">$gmfonttag</TD></TR><TR><TD ALIGN=RIGHT>$gmfonttag Password:</font></TD><TD ALIGN=LEFT></font><INPUT TYPE=PASSWORD CLASS="textinput" SIZE=20 NAME="authorpassword" STYLE="width: 200">$gmfonttag</TD></TR></TABLE><P><INPUT TYPE=SUBMIT CLASS="button" VALUE="Enter" STYLE="background: #D0FFD0; width: 75"><INPUT TYPE=HIDDEN NAME="thomas" VALUE="login"></FORM><P><font size=\"1\">"Not knowing when the dawn will come, I open every door."—Emily Dickinson</font>
  3550. $getnameandpwcookie
  3551. $gmframebottom
  3552.  
  3553. </BODY>
  3554. </HTML>
  3555.  
  3556. GMLOGIN
  3557.  
  3558. exit;
  3559.  
  3560. }
  3561.  
  3562. # ------------------
  3563. # validate the login
  3564. # ------------------
  3565.  
  3566. sub gm_validate {
  3567.  
  3568. &gm_bancheck;
  3569. &gm_readconfig;
  3570.  
  3571. $gmvalidated = "no";
  3572. $gmentryaccess = "no";
  3573. $gmentryeditaccess = "no";
  3574. $gmconfigurationaccess = "no";
  3575. $gmtemplateaccess = "no";
  3576. $gmauthoraccess = "no";
  3577. $gmcplogaccess = "no";
  3578. $gmrebuildaccess = "no";
  3579. $gmbookmarkletaccess = "no";
  3580. $gmuploadaccess = "no";
  3581. $gmloginaccess = "no";
  3582.  
  3583. $IN{'authorname'} =~ s/\|//g;
  3584. $IN{'authorpassword'} =~ s/\|//g;
  3585. $IN{'authorname'} =~ s/^\s+//;
  3586. $IN{'authorname'} =~ s/\s+$//;
  3587. $IN{'authorpassword'} =~ s/^\s+//;
  3588. $IN{'authorpassword'} =~ s/\s+$//;
  3589.  
  3590. if (($IN{'authorname'} eq "") || ($IN{'authorpassword'} eq "")) {
  3591.     $loginnotice = qq(<B><FONT COLOR="#0000FF">You left one or more of the fields blank.  Please try again.</font></B><P>);
  3592.     &gm_writetocplog("<B><FONT COLOR=\"#FF0000\">Invalid login attempt:</font></B> One or more fields left blank ($IN{'authorname'} $IN{'authorpassword'})");
  3593.     &gm_login;
  3594. }
  3595.  
  3596. open (FUNNYFEETVALLERY, "gm-authors.cgi") || &gm_dangermouse("Can't read the authors file.  Please make sure that gm-authors.cgi is CHMODed to 666 and is in the same place as all your other Greymatter CGI files.");
  3597. @gmauthordata = <FUNNYFEETVALLERY>;
  3598. close (FUNNYFEETVALLERY);
  3599.  
  3600. foreach $gmauthordataline (@gmauthordata) {
  3601.     chomp ($gmauthordataline);
  3602.     @gmauthorinfo = split (/\|/, $gmauthordataline);
  3603.     if ($gmauthorinfo[0] eq $IN{'authorname'}) {
  3604.         $gmvalidated = "foundname";
  3605.         if ($gmauthorinfo[1] eq $IN{'authorpassword'}) {
  3606.             $gmvalidated = "yes";
  3607.             if ($gmauthorinfo[6] eq "Y") { $gmentryaccess = "yes"; }
  3608.             if ($gmauthorinfo[7] eq "Y") { $gmentryeditaccess = "yes"; }
  3609.             if ($gmauthorinfo[7] eq "O") { $gmentryeditaccess = "mineonly"; }
  3610.             if ($gmauthorinfo[8] eq "Y") { $gmconfigurationaccess = "yes"; }
  3611.             if ($gmauthorinfo[9] eq "Y") { $gmtemplateaccess = "yes"; }
  3612.             if ($gmauthorinfo[9] eq "O") { $gmtemplateaccess = "hfsonly"; }
  3613.             if ($gmauthorinfo[10] eq "Y") { $gmauthoraccess = "yes"; }
  3614.             if ($gmauthorinfo[11] eq "Y") { $gmrebuildaccess = "yes"; }
  3615.             if ($gmauthorinfo[12] eq "Y") { $gmcplogaccess = "yes"; }
  3616.             if ($gmauthorinfo[13] eq "Y") { $gmbookmarkletaccess = "yes"; }
  3617.             if ($gmauthorinfo[14] eq "Y") { $gmuploadaccess = "yes"; }
  3618.             if ($gmauthorinfo[15] eq "Y") { $gmloginaccess = "yes"; }
  3619.         }
  3620.     }
  3621. }
  3622.  
  3623. if ($gmvalidated eq "foundname") {
  3624.     $loginnotice = qq(<B><FONT COLOR="#0000FF">The password you entered for that author is incorrect.  Please try again.</font></B><P>);
  3625.     &gm_writetocplog("<B><FONT COLOR=\"#FF0000\">Invalid login attempt:</font></B> Incorrect password ($IN{'authorpassword'}) for $IN{'authorname'}");
  3626.     &gm_login;
  3627. }
  3628.  
  3629. if ($gmvalidated ne "yes") {
  3630.     $loginnotice = qq(<B><FONT COLOR="#0000FF">No such author is registered.  Please try again.</font></B><P>);
  3631.     &gm_writetocplog("<B><FONT COLOR=\"#FF0000\">Invalid login attempt:</font></B> No such author as $IN{'authorname'} ($IN{'authorpassword'}) registered");
  3632.     &gm_login;
  3633. }
  3634.  
  3635. }
  3636.  
  3637. # --------------------------
  3638. # check if this IP is banned
  3639. # --------------------------
  3640.  
  3641. sub gm_bancheck {
  3642.  
  3643. open (FUNNYFEETBABY, "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; also try running Diagnostics & Repair from the Configuration screen.");
  3644. @gmbanlist = <FUNNYFEETBABY>;
  3645. close (FUNNYFEETBABY);
  3646.  
  3647. $currentip = $ENV{'REMOTE_ADDR'};
  3648.  
  3649. if ($gmbanlist[0] ne "") {
  3650.     foreach $gmbanlistline (@gmbanlist) {
  3651.         chomp ($gmbanlistline);
  3652.         ($checkthisip, $checkthisiphost, $checkthisperson) = split (/\|/, $gmbanlistline);
  3653.         if (($currentip =~ /$checkthisip/) && ($checkthisip ne "")) {
  3654.  
  3655.             if ($keeplog eq "yes") {
  3656.                 &date;
  3657.                 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; also try running Diagnostics & Repair from the Configuration screen.");
  3658.                 print FUNNYFEET "<font size=\"1\">[$basedate] [$currentip]</font> <font color=\"#FF0000\"><b>A banned IP ($checkthisip";
  3659.                 if ($checkthisperson ne "") { print FUNNYFEET ", \"$checkthisperson\""; }
  3660.                 print FUNNYFEET ") attempted to access this program</b></font>\n";
  3661.                 close (FUNNYFEET);
  3662.             }
  3663.  
  3664. print<<GMBANNEDNOTICE;
  3665.  
  3666. $gmheadtag
  3667.  
  3668. $gmframetop
  3669. You have been banned from accessing this program.<br />(IP: $currentip)
  3670. $gmframebottom
  3671.  
  3672. </body>
  3673. </html>
  3674.  
  3675. GMBANNEDNOTICE
  3676.  
  3677. exit;
  3678.  
  3679.         }
  3680.     }
  3681. }
  3682.  
  3683. }
  3684.  
  3685. # ---------------
  3686. # write to cp log
  3687. # ---------------
  3688.  
  3689. sub gm_writetocplog {
  3690.  
  3691. my $writetologtext = shift;
  3692.  
  3693. if ($keeplog eq "yes") {
  3694.     &date;
  3695.     open (ITSLOGITSLOG, ">>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.");
  3696.     print ITSLOGITSLOG "<font size=\"1\">[$basedate] [$authorIP]</font> $writetologtext\n";
  3697.     close (ITSLOGITSLOG);
  3698. }
  3699.  
  3700. }
  3701.  
  3702. # -----------------------------
  3703. # danger will robinson, danger!
  3704. # -----------------------------
  3705.  
  3706. sub gm_dangermouse {
  3707.  
  3708. my $dangerwarning = shift;
  3709.  
  3710. print<<GMDANGER;
  3711.  
  3712. $gmheadtag
  3713.  
  3714. $gmframetop<b><font color=\"#FF0000\">Error Notice</font></b><p>$dangerwarning$gmframebottom</p>
  3715.  
  3716. </body>
  3717. </body>
  3718.  
  3719. GMDANGER
  3720.  
  3721. exit;
  3722.  
  3723. }
  3724.  
  3725. 1;
  3726.  
  3727.  
  3728.