#!/usr/bin/perl -w
# ********************************************** blog.cgi ***********************************************
# *** TEMPLATE REQUIREMENTS ***
# The template file should have the following, each on a line by itself at the start of the line:
# BODY - The actual body of the site
#
# **************************************** Configuration Section ****************************************
my $template = 'template.html'; # HTML filename in current directory to
# use as template for results
# ************************************** End Configuration Section **************************************
# script proper begins...
use CGI qw(:standard);
use strict;
use DBI;
my $navhtml; # The HTML for the navigation section
my $bodyhtml; # The HTML for the body of the site
my $database = "cactus_main";
my $hostname = "localhost";
my $username = "cactus_bblog";
my $password = "bblog";
my $prevCatName = "";
my $numEntriesPerPage = 5;
my $firstEntryNum = 0;
foreach my $entrystart (@ARGV)
{
$firstEntryNum = $entrystart;
}
my ($querystring, $db, $query);
######## Generate the Body HTML ########
$querystring = "SELECT title, body, FROM_UNIXTIME(posttime, '%M %d, %Y'), modifier, sections " .
"FROM bB_posts " .
"WHERE status = 'live' " .
"ORDER BY posttime DESC " .
"LIMIT $firstEntryNum, $numEntriesPerPage";
# Connect To Database
$db = DBI->connect("DBI:mysql:$database:$hostname", $username, $password);
# Execute a Query
$query = $db->prepare($querystring);
$query->execute;
my $count = 0;
$bodyhtml .="
";
# Cleaning Up
$query->finish;
$db->disconnect;
$bodyhtml .= "";
$bodyhtml .= "| ";
if ($firstEntryNum > ($numEntriesPerPage - 1))
{
my $navnum = $firstEntryNum - $numEntriesPerPage;
$bodyhtml .= '<-- Newer Entries';
}
$bodyhtml .= " | ";
$bodyhtml .= "";
if ($count == $numEntriesPerPage)
{
my $navnum = $firstEntryNum + $numEntriesPerPage;
$bodyhtml .= 'Older Entries -->';
}
$bodyhtml .= " | ";
$bodyhtml .= "
";
######## End of generating the Body HTML ########
# Output the actual HTML
print header;
open IN, $template or die "Can't open html for reading: $!\n";
while (my $line = )
{
$line =~ s/NEWSHERE/$bodyhtml/;
print $line;
}
close IN;