#!perl
use strict;
use lib "C:/apache/htdocs/pm";
use my_board;
my( $msg_id, $sth, $count, $msg, $resp );
if ( $CG->param( 'msg' ) =~ /^(\d+)$/ ) {
$msg_id = $1;
} else {
dienice( $CG->param( 'msg' ) ."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();
$sth->execute( $msg_id, $msg_id);
if ( $sth < 1 ) {
dienice( "Message $msg_id does not exist" );
}
$msg = $sth->fetchrow_hashref;
# Create the header
create_header("Message #$msg_id: $msg->{subject}");
print $CG->a({-href=>'forums.cgi?forum=' . $msg->{forum}}, 'Topic: ' . $msg->{subject}) . "\n" . $CG->br() . "\n";
showpst( $msg );
print $CG->hr() . "\n";
print $CG->a( {-href=>'reply.cgi?forum=' . $msg->{forum} . '&msg=' . $msg->{id}}, 'Reply to this post') . "\n" . $CG->br() . "\n";
print $CG->p('Replies: ') . "\n" . $CG->br() . "\n";
showrep( $msg );
sub showpst {
my ($hd);
my ($msg1) = shift;
# Change carriage returns to
's
$msg->{message} = s/\n/
/;
print qq{};
print $CG->hr() . "\n";
print $CG->p('Message #: ' . $msg->{id}) . "\n" . $CG->br() . "\n";
print $CG->p('Subject: ' . $msg->{subject}) . "\n" . $CG->br() . "\n";
print $CG->p('Author: ' . $msg->{author}) . "\n" . $CG->br() . "\n";
print $CG->p('Posted on: ' . $msg->{nicedate}) . "\n" . $CG->br() . "\n";
print $CG->p($msg->{author} . "'s message:") . "\n" . $CG->br() . "\n";
print $CG->p($msg->{message}) . "\n" . $CG->br() . "\n";
print qq{} . "\n";
print qq{} . "\n";
}
sub showrep {
$sth = $dbh->prepare( "SELECT replies.*, date_format(date, '%c/%e/%Y/%r') AS nicedate, forums.name FROM messages, forums WHERE replies.forum = forums.id and (replies.id=? OR thread_id=?) ORDER BY thread_id, date" ) or dbdie();
$sth->execute( $msg_id, $msg_id);
}