📄 ch18.htm
字号:
END<BR>
<BR>
}<BR>
<BR>
#<BR>
# the following subroutine presents a threaded list of postings
which<BR>
# may be removed by either thread or individual posting, depending
on<BR>
# the value of the $mode variable<BR>
#<BR>
sub query_remove {<BR>
<BR>
print "Content-type: text/html\n\n";
<BR>
print <<END;<BR>
<HTML><HEAD><TITLE>Discussion Forum Administration</TITLE></HEAD>
<BR>
<BODY><BR>
END<BR>
&get_posts;<BR>
<BR>
if ( $#posts == -1 ) {<BR>
print "<H4>No postings
found</H4>\n</BODY></HTML>";<BR>
return 0;<BR>
} elsif ( $mode eq 'posts' ) {<BR>
print "<H3>Discussion
Forum Administration : Remove Individual",<BR>
" Postings</H3>\n";
<BR>
print "<FORM METHOD=POST
ACTION=$prog_url>\n";<BR>
print "<INPUT TYPE=HIDDEN
NAME=method VALUE=\"posts\">\n";<BR>
<BR>
$code = 'POST';<BR>
} elsif ( $mode eq 'thread' ) {<BR>
print "<H3>Discussion
Forum Administration : Remove Threads</H3>\n";<BR>
print "<P>Clicking
in a checkbox will remove that posting and all",<BR>
"its children upon form
submission.</P>\n";<BR>
print "<FORM METHOD=POST
ACTION=$prog_url>\n";<BR>
print "<INPUT TYPE=HIDDEN
NAME=method VALUE=\"thread\">\n";<BR>
<BR>
$code = 'THREAD';<BR>
}<BR>
<BR>
#<BR>
# reconstructs header fields from posting and place into the list
<BR>
#<BR>
$ul_count = 0;<BR>
foreach $i ( 0 .. $#posts ) {<BR>
<BR>
#<BR>
# this if structure implements my "typographical trick"
which threads<BR>
# postings based solely on their file names. "bits"
of posting names,<BR>
# separated by '_', are compared, first to see how many left-most
bits<BR>
# the current posting has in common with its immediate predecessor,
<BR>
# and then the signed inequality of right-most not-in-common bits
is<BR>
# used to determine the extent of <UL> pushing/popping needed
to thread<BR>
#<BR>
if ( $i != 0 ) {<BR>
<BR>
$this =
$posts[$i];<BR>
$previous
= $posts[$i-1];<BR>
<BR>
@this_bits
= split(/-/,$this);<BR>
@previous_bits
= split(/-/,$previous);<BR>
<BR>
if ( $#this_bits
> $#previous_bits ) {<BR>
$lesser_bits
= $#previous_bits;<BR>
} else {
<BR>
$lesser_bits
= $#this_bits;<BR>
}<BR>
<BR>
$common
= 0;<BR>
for $j (
0 .. $lesser_bits ) {<BR>
last
if $this_bits[$j] ne $previous_bits[$j];<BR>
$common++;
<BR>
}<BR>
<BR>
splice(@this_bits,$[,$common);
<BR>
splice(@previous_bits,$[,$common);
<BR>
<BR>
if ( $common
== 0 ) {<BR>
while
( $ul_count ) {<BR>
print
"</UL>";<BR>
$ul_count--;
<BR>
}
<BR>
} else {
<BR>
if
( $#this_bits > $#previous_bits ) {<BR>
for
$k ( 1 .. ($#this_bits - $#previous_bits) ) {<BR>
print
"<UL>\n";<BR>
$ul_count++;
<BR>
}
<BR>
}
elsif ( $#this_bits < $#previous_bits ) {<BR>
for
$k ( 1 .. ($#previous_bits - $#this_bits) ) {<BR>
print
"</UL>\n";<BR>
$ul_count--;
<BR>
}
<BR>
}
<BR>
}<BR>
} else {<BR>
$this =
$posts[0];<BR>
print "<UL>\n";
<BR>
}<BR>
<BR>
open(POST,"$this.post");
<BR>
&read_header;<BR>
close(POST);<BR>
<BR>
print "<LI><I>remove</I>
<INPUT TYPE=checkbox NAME=\"$code$this\"> ";
<BR>
print "<FONT SIZE=-1><A
HREF=$forum_url?$this>$subject</A> ";<BR>
print "$author ";
<BR>
if ( defined($to) ) { print
"<B><I>To:</I></B> $to "; }
<BR>
print "<I><B>On:</B>
$time</I></FONT>\n";<BR>
}<BR>
<BR>
while ( $ul_count ) {<BR>
print "</UL>";
<BR>
$ul_count--;<BR>
}<BR>
print "</UL>\n<HR>\n";
<BR>
<BR>
print "<P><INPUT TYPE=SUBMIT NAME=submit
VALUE=\"Submit this form\">\n";<BR>
print "<INPUT TYPE=reset NAME=reset
VALUE=\"Reset this form\">\n";<BR>
print "\n</FORM>\n";<BR>
<BR>
print "</BODY></HTML>\n";
<BR>
exit 0;<BR>
}<BR>
<BR>
#<BR>
# - it's easy to remove posts -- just delete the corresponding
.post file<BR>
# - proper threading is maintained by the spiffy "typographic
data structure"<BR>
#<BR>
sub remove_posts {<BR>
<BR>
foreach $key ( keys %input ) {<BR>
if ( $key =~ /POST/ ) {<BR>
substr($key,$[,4)
= '';<BR>
system("rm
$key.post");<BR>
}<BR>
}<BR>
&report_removal;<BR>
}<BR>
<BR>
#<BR>
# - it's easy to remove threads -- just delete the corresponding
.post file<BR>
# - proper threading is maintained by the spiffy "typographic
data structure"<BR>
#<BR>
sub thread_remove {<BR>
<BR>
foreach $key ( keys %input ) {<BR>
if ( $key =~ /THREAD/ ) {
<BR>
substr($key,$[,6) = '';<BR>
system("rm $key*.post");
<BR>
}<BR>
}<BR>
&report_removal;<BR>
}<BR>
<BR>
#<BR>
# generate the form which asks for names of to-be-removed authors
<BR>
#<BR>
sub query_author_remove {<BR>
<BR>
&get_posts;<BR>
<BR>
#<BR>
# build list of author names and their corresponding postings
by<BR>
# parsing the entire collection of postings<BR>
#<BR>
foreach $post ( @posts ) {<BR>
open(POST,"$post.post");
<BR>
&read_header;<BR>
$allauthors{$author} .= "<LI><A
HREF=$forum_url?$post>$subject</A> ";<BR>
$allauthors{$author} .= "$author
";<BR>
if ( defined($to) ) { $allauthors{$author}
.= "<B><I>To:</I></B> $to ";
}<BR>
$allauthors{$author} .= "<I><B>On:</B>
$time</I>\n";<BR>
close(POST);<BR>
}<BR>
foreach $key ( keys(%allauthors)) {<BR>
substr($allauthors{$key},$[,0)
= "<UL>\n";<BR>
substr($allauthors{$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
Author</H3><BR>
<FORM ACTION=$prog_url METHOD=POST><BR>
<INPUT TYPE=HIDDEN NAME=method VALUE="author">
<BR>
<TABLE BORDER CELLPADDING=8><BR>
<TR><TH VALIGN=TOP ALIGN=CENTER>Author Name</TH>
<BR>
<TH VALIGN=TOP ALIGN=CENTER>Check to Remove</TH><BR>
<TH VALIGN=TOP ALIGN=CENTER>This Author's Postings</TH></TR>
<BR>
END<BR>
foreach $authname (sort case_insensitive (keys(%allauthors)))
{<BR>
print "<TR><TD
VALIGN=TOP ALIGN=LEFT>$authname</TD>\n";<BR>
print "<TD VALIGN=TOP
ALIGN=CENTER><INPUT TYPE=chECKBOX NAME=\"AUTHOR"
.<BR>
&hex_encode($authname)
. "\"></TD>\n";<BR>
print "<TD VALIGN=TOP
ALIGN=LEFT>$allauthors{$authname}</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>
# it's easy to remove postings by authors -- once you have the
author's<BR>
# name, just scan through all header fields and check to see if
the name<BR>
# in the header field matches the name to be deleted<BR>
#<BR>
sub author_remove {<BR>
<BR>
local($i,$mark);<BR>
<BR>
foreach $auth ( keys(%input) ) {<BR>
next if !($auth =~ /^AUTHOR/);
<BR>
substr($auth,$[,length('AUTHOR'))
= '';<BR>
$ex_authors[$i++] = &hex_decode($auth);
<BR>
}<BR>
<BR>
&get_posts;<BR>
<BR>
POSTINGS: foreach $post ( @posts ) {<BR>
open(POST,"$post.post");
<BR>
&read_header;<BR>
close(POST);<BR>
foreach $entry ( @ex_authors
) {<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -