📄 ch18.htm
字号:
if ( $author
eq $entry ) {<BR>
system("rm
$post.post");<BR>
next
POSTINGS;<BR>
}<BR>
}<BR>
}<BR>
&report_removal;<BR>
}<BR>
<BR>
#<BR>
# generate the form which the user fills in to decide which dates
are<BR>
# supposed to be removed from the body of discussion forum postings
<BR>
#<BR>
sub query_date_remove {<BR>
<BR>
&get_posts;<BR>
<BR>
foreach $post ( @posts ) {<BR>
open(POST,"$post.post");
<BR>
&read_header;<BR>
@tfields = split(/[\s]+/,$time);
<BR>
$timetemp = join(' ',@tfields[0..2],$tfields[4]);
<BR>
$dates{$timetemp} .= "<LI><A
HREF=$forum_url?$post>$subject</A> ";<BR>
$dates{$timetemp} .= "$author
";<BR>
if ( defined($to) ) { $dates{$timetemp}
.= "<B><I>To:</I></B> $to ";
}<BR>
$dates{$timetemp} .= "<I><B>On:</B>
$time</I>\n";<BR>
close(POST);<BR>
}<BR>
foreach $key ( keys(%dates)) {<BR>
substr($dates{$key},$[,0)
= "<UL>\n";<BR>
substr($dates{$key},-1,0)
= "\n</UL>\n";<BR>
}<BR>
<BR>
print "Content-type: text/html\n\n";
<BR>
print <<END;<BR>
<HTML><HEAD><TITLE>Discussion Forum Administration</TITLE></HEAD>
<BR>
<BODY><BR>
<H3>Discussion Forum Administration : Remove Postings by
Date</H3><BR>
<FORM ACTION=$prog_url METHOD=POST><BR>
<INPUT TYPE=HIDDEN NAME=method VALUE="date"><BR>
<TABLE BORDER CELLPADDING=8><BR>
<TR><TH VALIGN=TOP ALIGN=CENTER>Date</TH><BR>
<TH VALIGN=TOP ALIGN=CENTER>Check to Remove</TH><BR>
<TH VALIGN=TOP ALIGN=CENTER>Postings on this Date</TH></TR>
<BR>
END<BR>
foreach $date (sort by_date (keys(%dates)) )
{<BR>
print "<TR><TD
VALIGN=TOP ALIGN=LEFT>$date</TD>\n";<BR>
print "<TD VALIGN=TOP
ALIGN=CENTER><INPUT TYPE=chECKBOX NAME=\"DATE"
.<BR>
&hex_encode($date) . "\"></TD>\n";
<BR>
print "<TD VALIGN=TOP
ALIGN=LEFT>$dates{$date}</TD></TR>\n";<BR>
}<BR>
<BR>
print <<END;<BR>
</TABLE><BR>
<P><INPUT TYPE=SUBMIT NAME=submit VALUE="Submit
this form"><BR>
<INPUT TYPE=reset NAME=reset VALUE="Reset this form"></FORM>
<BR>
</BODY></HTML><BR>
END<BR>
exit 0;<BR>
}<BR>
<BR>
#<BR>
# actually does the grunt-work of removing the <BR>
# previously-selected "bad dates"<BR>
#<BR>
sub date_remove {<BR>
<BR>
local($i,$mark);<BR>
<BR>
foreach $date ( keys(%input) ) {<BR>
next if !($date =~ /^DATE/);
<BR>
substr($date,$[,length('DATE'))
= '';<BR>
$bad_dates[$i++] = &hex_decode($date);
<BR>
}<BR>
<BR>
&get_posts;<BR>
<BR>
POSTINGS: foreach $post ( @posts ) {<BR>
open(POST,"$post.post");
<BR>
&read_header;<BR>
close(POST);<BR>
@tfields = split(/[\s]+/,$time);
<BR>
$time = join(' ',@tfields[0..2],$tfields[4]);
<BR>
foreach $date ( @bad_dates
) {<BR>
if ( $time
eq $date ) {<BR>
system("rm
$post.post");<BR>
next
POSTINGS;<BR>
}<BR>
}<BR>
}<BR>
&report_removal;<BR>
}<BR>
<BR>
sub report_removal {<BR>
<BR>
print "Content-type: text/html\n\n";
<BR>
print <<END;<BR>
<HTML><HEAD><TITLE>Discussion Forum Administration</TITLE></HEAD>
<BR>
<BODY><BR>
<H3>Postings Successfully Removed</H3><BR>
<P><BR>
<A HREF=$prog_url>Return to the Discussion Forum Administration
Page</A><BR>
</BODY></HTML><BR>
END<BR>
<BR>
exit 0;<BR>
}<BR>
<BR>
sub get_posts {<BR>
<BR>
@posts = 'ls -r1 *.post';<BR>
$post_len = length(".post\n");<BR>
foreach $post ( @posts ) {<BR>
substr($post,-$post_len) =
''; # remove unwanted tailing characters<BR>
}<BR>
}<BR>
<BR>
sub read_article {<BR>
<BR>
local ($post_id);<BR>
<BR>
($post_id) = @_;<BR>
<BR>
open(POST,"$post_id.post");<BR>
&read_header;<BR>
@body = <POST>;<BR>
close(POST);<BR>
}<BR>
<BR>
sub read_header {<BR>
<BR>
chop($author = <POST>);<BR>
($discard,$author) = split(/\t/,$author);<BR>
chop($email = <POST>);<BR>
($discard,$email) = split(/\t/,$email);<BR>
chop($subject = <POST>);<BR>
($discard,$subject) = split(/\t/,$subject);
<BR>
chop($to = <POST>);<BR>
($discard,$to) = split(/\t/,$to);<BR>
chop($time = <POST>);<BR>
($discard,$time) = split(/\t/,$time);<BR>
}<BR>
<BR>
sub intro_page {<BR>
<BR>
print "Content-type: text/html\n\n";
<BR>
print <<END;<BR>
<HTML><HEAD><TITLE>Discussion Forum Administration</TITLE></HEAD>
<BR>
<BODY><BR>
<H3>Discussion Forum Administration</H3><BR>
<P><BR>
Please choose one of the following methods for removing postings
from the<BR>
discussion forum:<BR>
<UL><BR>
<LI><A HREF=$prog_url?posts>Remove Individual Postings</A>
<BR>
<LI><A HREF=$prog_url?date>Remove Postings by Date</A>
<BR>
<LI><A HREF=$prog_url?thread>Remove Postings by Thread</A>
<BR>
<LI><A HREF=$prog_url?author>Remove Postings by Author</A>
<BR>
</UL><BR>
</BODY></HTML><BR>
END<BR>
<BR>
}<BR>
<BR>
#<BR>
# this function is used by the sort command when a case-insensitive
string<BR>
# comparison is performed... for instance, in a situation where
I want 'a'<BR>
# to come before 'Z' rather than after, as would usually be the
case <BR>
# given that Z comes before a in the ASCII sequence<BR>
#<BR>
sub case_insensitive {<BR>
<BR>
local($atemp,$btemp);<BR>
$atemp = $a; $btemp = $b;<BR>
<BR>
$atemp =~ tr/A-Z/a-z/;<BR>
$btemp =~ tr/A-Z/a-z/;<BR>
<BR>
$atemp cmp $btemp;<BR>
}<BR>
<BR>
#<BR>
# this function is used by the sort command when trying to compare
the<BR>
# dates of two postings<BR>
#<BR>
sub by_date {<BR>
<BR>
local($akey,$bkey);<BR>
<BR>
$akey = $a; <BR>
$bkey = $b;<BR>
<BR>
@afields = split(/[\s]+/,$akey);<BR>
@bfields = split(/[\s]+/,$bkey);<BR>
<BR>
substr($afields[3],$[,2) = '';<BR>
substr($bfields[3],$[,2) = '';<BR>
<BR>
$months{'Jan'} = 0;<BR>
$months{'Feb'} = 1;<BR>
$months{'Mar'} = 2;<BR>
$months{'Apr'} = 3;<BR>
$months{'May'} = 4;<BR>
$months{'Jun'} = 5;<BR>
$months{'Jul'} = 6;<BR>
$months{'Aug'} = 7;<BR>
$months{'Sep'} = 8;<BR>
$months{'Oct'} = 9;<BR>
$months{'Nov'} = 10;<BR>
$months{'Dec'} = 11;<BR>
$weekday{'Sun'} = 0;<BR>
$weekday{'Mon'} = 1;<BR>
$weekday{'Tue'} = 2;<BR>
$weekday{'Wed'} = 3;<BR>
$weekday{'Thu'} = 4;<BR>
$weekday{'Fri'} = 5;<BR>
$weekday{'Sat'} = 6;<BR>
<BR>
&timegm('0','0','0',$afields[2],$months{$afields[1]},$afields[3],
<BR>
$weekday{$afields[0]},'','') <=> <BR>
&timegm('0','0','0',$bfields[2],$months{$bfields[1]},$bfields[3],
<BR>
$weekday{$bfields[0]},'','');<BR>
<BR>
}<BR>
<BR>
#<BR>
# I hex-encode certain fields to avoid the possibility that info
within<BR>
# the fields will botch up certain HTML situations.<BR>
#<BR>
sub hex_encode {<BR>
<BR>
local($an,$temp);<BR>
($an) = @_;<BR>
<BR>
undef($temp);<BR>
for $i ( 0 .. (length($an)-1) ) {<BR>
$temp .= sprintf("%lx",ord(substr($an,$[+$i,1)));
<BR>
}<BR>
$temp;<BR>
}<BR>
<BR>
#<BR>
# hex-decoding is necessary to retrieve info that was hex-encoded
before<BR>
#<BR>
sub hex_decode {<BR>
<BR>
local($acode,$temp,$t);<BR>
($acode) = @_;<BR>
<BR>
undef($temp);<BR>
while ( $acode ) {<BR>
$t = substr($acode,$[,2);
<BR>
substr($acode,$[,2) = '';
<BR>
$temp .= pack("c",hex($t));
<BR>
}<BR>
$temp;<BR>
}</FONT></TT>
</BLOCKQUOTE>
<HR>
<H2><A NAME="DiscussionForumAdditions"><FONT SIZE=5 COLOR=#FF0000>Discussion
Forum Additions</FONT></A></H2>
<P>
Now that the basic concept of a discussion forum and its administration
has been established, let's consider what sorts of useful "bells
and whistles" can be brought to the field.
<H3><A NAME="SelectiveSortingCriteria">Selective Sorting Criteria</A>
</H3>
<P>
Much as articles could be deleted according to author or subject
in addition to date, coding in an option so that
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -