#!/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, $msg, $resp); # untaint the message number # this is different from message.cgi in that it's a posted value # rather than the query string. if ($cgi->param('msgid') =~ /^(\d+)$/) { $msgid = $1; } else { &dienice($cgi->param('msgid') . " isn't a valid message number."); } $sth = $dbh->prepare("select messages.*, date_format(date,'%c/%e/%Y %r') as nicedate from messages where (messages.id=? or thread_id=?) order by thread_id, date") or &dbdie; $rv = $sth->execute($msgid, $msgid); if ($rv < 1) { &dienice("Message ID $msgid doesn't exist."); } $msg = $sth->fetchrow_hashref; &do_header("Delete Message #$msgid: $msg->{subject}"); print qq(

Delete Message

\n); &showpost($msg); # add article-only cancel button # the hidden field "action" tells cancel2.cgi to just cancel the one # message. print qq(
); print qq(
\n); if ($msg->{thread_id} == 0) { $resp = 0; while ($msg = $sth->fetchrow_hashref) { if ($resp == 0) { print "Responses:
\n"; $resp = 1; } # don't show the full text of followups - just the subject line, # author, and date posted. print qq(#$msg->{id}: $msg->{subject} - posted by $msg->{author} on $msg->{nicedate}
\n); } # if there aren't any responses, say so: if ($resp == 0) { print qq(

No responses to this article.

\n); } else { # print the cancel-thread button print qq(
); } } &do_footer; sub showpost { my($hdr); my($msg) = @_; # change all carriage returns to the HTML-ized "break" tag $msg->{message} =~ s/\n/
\n/g; # modify the post to display the author's e-mail and IP addresses # as well as the forum name print <
Forum: $msg->{name}
Article #$msg->{id}
Subject: $msg->{subject}
Author: $msg->{author} ($msg->{email}) ($msg->{ip})
Posted: $msg->{nicedate}

$msg->{message}

EndHTML }