viewmonth.pl

#!/usr/local/bin/perl5
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                                                               #
# viewmonth.pl                                                  #
#                                                               #
# Accepts a year number and a month number, with January as 1.  #
#                                                               #
# Display the news entries for that month.                      #
#                                                               #
# (c) 2000, Benjamin Schak                                      #
# Feel free to use in any way, as long as you keep this notice. #
#                                                               #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

use CGI_UltraLite;
use SCHAK;
use DBI;

package main;

print "Content-type: text/html; charset=utf-8\n\n";

CGI_UltraLite::getparse();
($sec, $min, $hour, $mday, $month, $year, $wday, $ydat, $isdst) = localtime();
$month++;
$year += 1900;
if (defined ($CGI_UltraLite::value[1]) && 0 < $CGI_UltraLite::value[1] &&
$CGI_UltraLite::value[1] < 13) {
	$month = $CGI_UltraLite::value[1];
	$year  = $CGI_UltraLite::value[0];
}

SCHAK::connect;

#SCHAK::doselect("SELECT STAMP, TITLE, BODY FROM ENTRIES
#WHERE MONTH(STAMP)=$month AND YEAR(STAMP)=$year AND PERMISSION=\"PUBLIC\"
#ORDER BY STAMP DESC, ID DESC\;");
SCHAK::doselect("SELECT STAMP, TITLE, BODY, PERMISSION FROM ENTRIES
WHERE MONTH(STAMP)=$month AND YEAR(STAMP)=$year
ORDER BY STAMP DESC, ID DESC\;");

print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
\"http://www.w3.org/TR/html4/strict.dtd\">
<html lang=\"en-us\">
<head>
 <title>$month/$year News</title>
 <meta http-equiv=\"PICS-Label\" content='(PICS-1.1
\"http://www.classify.org/safesurf/\" l gen true for
\"http://www.schak.com/\" r (SS~~000 4 SS~~001 6 SS~~008 2))'>
 <meta http-equiv=\"PICS-Label\" content='(PICS-1.1
\"http://www.rsac.org/ratingsv01.html\" l gen true comment \"RSACi North
America Server\" for \"http://www.schak.com/\" on
\"1999.06.30T18:38-0800\" r (n 0 s 0 v 0 l 3))'>
 <link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\">
</head>
<body>
 <h1>
  $month/$year News
 </h1>
 <div id=\"body\">
";

while (($stamp, $title, $body, $perm) = SCHAK::fetchrow_array()) {
	my $date = substr($stamp, 8, 2);
	if ($perm eq "PUBLIC") {
		print "  <h4>
   $date";
		if ($title) {
			print " ($title)";
		}
		print "
  </h4><div class=\"entry\">$body</div>
";
	}
	else {
		print "  <h4>
   $date";
		print "
  </h4><div class=\"entry\">[Private entry; access denied.]</div>
";
	}
}

print " </div>
 <div id=\"nav\">
  <ul>
   <li><a href=\"/news\">News</a>
    <ul>
     <li><a href=\"/\">Current Month</a></li>
    </ul>
   </li>
   <li><a href=\"/links\">Links</a></li>
   <li><a href=\"/other\">Other</a></li>
   <li><a href=\"/scripts\">Scripts</a></li>
  </ul>
 </div>
</body>
</html>";

SCHAK::disconnect;