#!/usr/bin/perl
use strict;
#use lib 'C:\Inetpub\wwwroot\Sites\asp\echoingw\members\login.';
use lib '.';
use MyBoard;
# declare variables
my($sth, $rv, $f, $count);
my($limit);
# untaint the limit count
if ($cgi->param('start') =~ /^(\d+)$/) {
$limit = $1;
} else {
$limit = 0;
}
my $count = 0;
# how many msgs to display per page
my($maxcount) = 500;
&do_header($maintitle);
## BEGIN HEADER PAGE CONTENT ##
print qq(
|
Archives: Welcome to the archives! Archived messages are listed below by title, date, time posted, and the number of comments.
To view a message, simply click on the title and that message, (including comments), will be opened in a new window.
|
);
my($today) = "";
# delete the forum_id stuff in the query,
# alter the date format to read "Thursday, May 8, 2002"
# and format the time into "12:30 PM"
#
$sth = $dbh->prepare("select *,date_format(date, '%W, %M %e, %Y') as nicedate, date_format(date, '%l:%i %p') as nicetime from messages where thread_id=0 order by id desc limit $limit, $maxcount") or &dbdie;
$rv = $sth->execute;
while ($f = $sth->fetchrow_hashref) {
my($asth) = $dbh->prepare("select count(*) from messages where thread_id=$f->{id}");
$rv = $asth->execute;
my($r) = $asth->fetchrow_array;
my($responses);
if ($r == 1) {
$responses = "1 comment";
} elsif ($r > 1) {
$responses = "$r comments";
} else {
$responses = "0 comments";
}
# if ($f->{nicedate} ne $today) {
# if ($today ne "") {
# print qq(
\n);
# }
# print qq(Dateline: $f->{nicedate}
\n);
# $today = $f->{nicedate};
# }
# Convert hard returns to line returns in post.
$f->{message} =~ s/\r/
/g;
# Stip all HTML Tags and convert to &alt characters.
$f->{message} =~ s/</g;
$f->{message} =~ s/>/g;
# Convert
tag back to HTML.
$f->{message} =~ s/<br/
{message} =~ s/>br/
{message} =~ s/\[i\]/\/g;
$f->{message} =~ s/\[\/i\]/\<\/i>/g;
# Bold
$f->{message} =~ s/\[b\]/\/g;
$f->{message} =~ s/\[\/b\]/\<\/b>/g;
# Underline
$f->{message}=~ s/\[u\]/\/g;
$f->{message} =~ s/\[\/u\]/\<\/u>/g;
# Lists
$f->{message}=~ s/\[ul\]/\\n);
#$count = $count + 1;
## COUNTS ##
$count++;
# print the previous and next links
#if ($count == 0) {
# print qq(No messages.
\n);
#} else {
# my($prev);
# if ($limit > 0) {
# $prev = $limit - $maxcount;
# if ($prev < 0) {
# $prev = 0;
# }
# print qq(
previous $maxcount | \n);
# }
# if ($count == $maxcount) {
# my($next);
# $next = $limit + $maxcount;
# print qq(next $maxcount\n);
# }
#}
## COUNTS ##
}
&do_footer;