#!/usr/bin/perl -Tw
############################################################
## Written and copyright 2002 by
## Jacqueline D. Hamilton (kira@cgi101.com)
##
## This code is excerpted from "CGI Programming 201"
## (http://www.cgi101.com/advanced)
##
## You may use this code on your own website, however
## you may not publish or sell any copy or derivative work
## without permission of the author.
#############################################################
use strict;
use lib '.';
use MyBoard;
my ($msgid, $sth, $rv, $count, $msg, $resp);
# untaint the query string
if ($ENV{QUERY_STRING} =~ /^(\d+)$/) {
$msgid = $1;
} else {
&dienice("$ENV{QUERY_STRING} isn't a valid message number.");
}
$sth = $dbh->prepare("select messages.*, date_format(date,'%c/%e/%Y %r') as
nicedate, forums.name from messages, forums where messages.forum = forums.id and (messages.id=? or thread_id=?) order by thread_id, date") or &dbdie;
$rv = $sth->execute($msgid, $msgid);
if ($rv < 1) {
&dienice("Message $msgid does not exist.");
}
$msg = $sth->fetchrow_hashref;
&do_header("Message #$msgid: $msg->{subject}");
print qq($msg->{name} Topic:
$msg->{subject}
\n);
&showpost($msg);
print qq(
Article #$msg->{id}Reply to this post
Subject: $msg->{subject}
Author: $msg->{author}
Posted: $msg->{nicedate}
$msg->{message}
EndHTML }