chiark / gitweb /
59a6423de6674f7aca397a73b28a386225296980
[modbot-mtm.git] / webstump / scripts / html_output.pl
1 #
2 # This is a module with functions for HTML output.
3 #
4 # I separate it from the main STUMP stuff because these functions are
5 # bulky and not very interesting.
6 #
7 #
8
9 use POSIX;
10
11 sub begin_html {
12   my $title = pop( @_ );
13   print 
14 "Content-Type: text/html\n\n
15 <TITLE>$title</TITLE>
16 <BODY>
17 <H1>$title</H1>\n\n";
18
19   if( &is_demo_mode ) {
20     print "<B> You are operating in demonstration mode. User actions will have no effect.</B><HR>\n";
21   }
22   
23 }
24
25 sub end_html {
26   print "\n<HR>Thank you for using <A HREF=$STUMP_URL>STUMP Robomoderator</A>.
27 <!-- <BR>
28 Click <A HREF=$base_address>here</A> to return to WebSTUMP. -->
29 ";
30 }
31
32 # prints a link to help
33 # accepts topic id and topic name.
34 #
35 sub link_to_help {
36   my $topic_name = pop( @_ );
37   my $topic = pop( @_ );
38
39   #&print_image( "help.gif", "" );
40
41   print "<A HREF=$base_address?action=help&topic=$topic TARGET=new>Click here for help on $topic_name</A>\n";
42 }
43
44 #
45 # prints image and an alt text
46 #
47 sub print_image { # image_file, alt_text
48   my $alt = pop( @_ );
49   my $file = pop( @_ );
50
51   print "<IMG SRC=$base_address_for_files/images/$file ALT=\"$alt\" ALIGN=BOTTOMP>\n";
52 }
53
54 # prints the welcome page and login screen.
55 sub html_welcome_page {
56   &begin_html( "Welcome to WebSTUMP" );
57
58   print 
59
60 "Welcome to WebSTUMP, the moderators' front end for <A
61 HREF=http://www.algebra.com/~ichudov/stump>STUMP</A> users -- USENET newsgroup
62 moderators. Only authorized users are allowed to log into this
63 program.
64
65 <HR>";
66
67   my $motd_file = "$webstump_home/config/motd";
68
69   if( -f $motd_file && -r $motd_file ){
70     open( MOTD, $motd_file );
71     print "<B>Message of the Day:</B><BR><PRE>\n";
72     print while( <MOTD> );
73     close( MOTD );
74     print "</PRE><HR>\n";
75   }
76
77   print "
78 Newsgroups Status:<BR>
79 <TABLE BORDER=3>\n";
80
81   for( sort @newsgroups_array ) {
82     print "<TR><TD>";
83     
84     my $count = &get_article_count( $_ );
85
86     print " <A HREF=$base_address?action=login_screen\&newsgroup=$_>$_</A>";
87     &print_image( "smiley.gif", "" ) if $count;
88     print "</TD>";
89
90
91     print "<TD>$count messages in queue<BR></TD>";
92 #    print "<TD><A HREF=$base_address?action=init_request_newsgroup_creation\&newsgroup=$_>Request creation</A></TD>\n";
93   }
94
95   print "</TABLE>\n";
96   print "<HR>Note: click on the newsgroup to login in as moderator. 
97 <!-- Click on 'Request Creation' to ask a sysadmin at a specific domain
98 to carry your newsgroup. -->\n<HR>
99 <A HREF=$base_address?action=admin_login>Click here to administer this WebSTUMP installation</A>
100 ";
101   &end_html;
102 }
103
104 # prints the login screen for newsgroup.
105 sub html_login_screen {
106   my $newsgroup = $request{'newsgroup'} || &error( "newsgroup not defined" );
107
108   my $count = &get_article_count( $newsgroup );
109
110
111   if( $count ) {
112     &begin_html( "$count articles in queue for $newsgroup" );
113   } else {
114     &begin_html( "Empty Queue for $newsgroup" );
115   }
116
117   print
118 " Welcome to the Moderation  Center for  $newsgroup. Please bookmark
119 this page. <HR>";
120
121
122   my $color = "", $end_color = "";
123
124   if( $count ) {
125     $color = "<font color=red>";
126     $end_color = "<font color=black>";
127   }
128
129   print 
130 "<FORM METHOD=$request_method action=$base_address>
131  <INPUT NAME=action VALUE=moderation_screen TYPE=hidden>
132   $color ($count ";
133   
134   &print_image( "new_tiny2.gif", "new" ) if $count;
135
136   print " articles available)<BR> $end_color
137  Login: <INPUT NAME=moderator VALUE=\"\" SIZE=20>
138  <BR>
139  Password: <INPUT NAME=password TYPE=password VALUE=\"\" SIZE=20>
140  <BR>
141  <INPUT TYPE=submit VALUE=\"Proceed with Login\">
142  <INPUT TYPE=reset VALUE=\"Reset\">
143  <INPUT NAME=newsgroup VALUE=\"$newsgroup\" TYPE=hidden>
144  </FORM><HR>
145   Please log into $newsgroup. You can only log in if you know your login id
146   and know the secret password. You should not give your password to any
147   unauthorized user. Your login id and password are NOT case sentitive, 
148   which means that,
149   for example, \"xyzzy\" and \"XyZZY\" are equally valid.<P>
150 ";
151
152 #  print "
153 # Log in as \"admin\" if you want to 
154 #<UL>
155 #  <LI> edit filtering lists.";
156 #
157 #  &link_to_help( "filter-lists", "Filter Lists" );
158 #
159 #  print "
160 #  <LI> add/delete users or change their passwords.
161 #  <LI> First Time Users: You have to log in as admin and add a moderator user
162 #  who will be able to moderate the newsgroup. Then log in again as that
163 #  user. If you are a new user, you have to have your admin password assigned to
164 #  you by the administrator.
165 #</UL>
166 #
167 #";
168   &end_html;
169 }
170
171 # prints the login screen for newsgroup.
172 sub admin_login_screen {
173   &begin_html( "Administrative login" );
174
175   print
176 "
177 Attention: this page is only for the maintainer of the whole WebSTUMP
178 installation. Please return to the main page if you are not the maintainer
179 of this installation. <HR>
180 ";
181
182   print 
183 "<FORM METHOD=$request_method action=$base_address>
184  <INPUT NAME=action VALUE=webstump_admin_screen TYPE=hidden>
185  Password: <INPUT NAME=password TYPE=password VALUE=\"\" SIZE=20>
186  <BR>
187  <INPUT TYPE=submit VALUE=\"Proceed with Login\">
188  <INPUT TYPE=reset VALUE=\"Reset\">
189  </FORM>
190 ";
191
192   &end_html;
193 }
194
195 # main moderation page -- old version
196 sub html_moderate_article {
197   my $newsgroup = &required_parameter( 'newsgroup' );
198   my $moderator = $request{'moderator'};
199   my $password = $request{'password'};
200   my $file = shift @_ || &required_parameter('file');
201
202   &begin_html( "Main Moderation Screen: $newsgroup" );
203   print "<HR>\n";
204
205   &read_rejection_reasons;
206
207   my $dir = "$queues_dir/$newsgroup";
208
209   if( -d "$dir/$file" && open( TEXT_FILES, "$dir/$file/text.files.lst" ) ) {
210
211       print "<HR>\n" if &print_article_warning( $file );
212
213       print "<PRE>\n";
214       my $filename;
215       my $inhead= 1;
216       while( $filename = <TEXT_FILES> ) {
217         open( ARTICLE, "$dir/$file/$filename" );
218         while( <ARTICLE> ) {
219           $embolden= m/^(?:from|subject)\s*\:/i;
220           s/\&/&amp;/g;
221           s/</&lt;/g;
222           s/>/&gt;/g;
223           $_= "<strong>$_</strong>" if $embolden;
224           print;
225           $inhead= 0 unless m/\S/;
226         }
227         close( ARTICLE );
228         $inhead= 0;
229       }
230
231       print "\n</PRE>\n\n";
232
233       &print_images( $newsgroup, "$dir/$file", $file);
234
235   } else {
236     print "This message ($dir/$file) no longer exists -- maybe it was " .
237           "approved or rejected by another moderator.";
238   }
239
240       print "<HR>
241 <FORM NAME=decision METHOD=$request_method action=$base_address>
242 ";
243
244   print "
245 <INPUT NAME=action VALUE=approval_decision TYPE=hidden>";
246   &html_print_credentials;
247   print "<SELECT NAME=\"decision_$file\">
248 <OPTION VALUE=\"approve\">Approve</OPTION>
249 <OPTION VALUE=\"leave\">Put to back of queue</OPTION>
250 <OPTION VALUE=\"consider\">Back of queue, adding mark requesting further consideration</OPTION>
251 ";
252
253       foreach (sort(keys %rejection_reasons)) {
254         print "<OPTION VALUE=\"reject $_\">Reject -- $rejection_reasons{$_}</OPTION>\n";
255       }
256
257       print "<BR>";
258
259       print "</SELECT><BR> Comment: <INPUT NAME=comment VALUE=\"\" SIZE=80><BR>";
260
261   print "<BR>
262 <INPUT TYPE=radio NAME=poster_decision VALUE=nothing CHECKED>Don't change poster's status</INPUT>
263 <INPUT TYPE=radio NAME=poster_decision VALUE=preapprove 
264 >Preapprove poster</INPUT>
265 <INPUT TYPE=radio NAME=poster_decision VALUE=ban 
266   ONCLICK=\"alert( 'Banning a poster is a controversial practice'); \"
267 > Ban All Posts by this Person (Careful!)</INPUT>
268 <BR><BR>
269 <INPUT TYPE=radio NAME=thread_decision VALUE=nothing CHECKED>Don't change thread's status</INPUT>
270 <!-- <INPUT TYPE=radio NAME=thread_decision VALUE=preapprove>Preapprove thread, by Subject:</INPUT> -->
271 <BR>
272
273 <INPUT TYPE=radio NAME=thread_decision VALUE=ban
274   ONCLICK=\"alert( 'Banning a thread is a controversial practice'); \"
275 >Ban Entire Thread By Subject (Careful!)</INPUT>
276 <INPUT TYPE=radio NAME=thread_decision VALUE=watch>Put Entire thread on a Watch, by Subject:</INPUT>
277
278 <BR><BR>
279 <I>
280 NOTE: Decisions to ban and preapprove posters and threads can be reversed by 
281 logging in as \"admin\" and editing respective lists of preapproved
282 and banned threads  and posters.
283 ";
284
285   &link_to_help( "filter-lists", "automatic filtering and filter lists, blacklisting and preapproved threads." );
286
287   print "Be really careful about blacklisting of everyone except spammers.</I><BR><BR>
288
289 <INPUT TYPE=radio NAME=next_screen VALUE=single CHECKED> 
290         Review ONE article in next screen
291 <INPUT TYPE=radio NAME=next_screen VALUE=multiple> 
292         Review multiple articles in next screen
293 <HR>
294
295 <INPUT TYPE=submit VALUE=\"Submit\">
296 <INPUT TYPE=submit NAME=skip_submit VALUE=\"Skip\">
297 <INPUT TYPE=reset VALUE=\"Reset\">
298 ";
299
300       print "</FORM>\n\n";
301   print "<BR><A HREF=$base_address?action=change_password&newsgroup=$newsgroup&" .
302         "moderator=$moderator&password=$password>Change Password</A>";
303
304   closedir( QUEUE );
305   &end_html;
306 }
307
308 # WebSTUMP administrative screen
309 sub webstump_admin_screen {
310
311   &verify_admin_password;
312
313   my $password = $request{'password'};
314
315   &begin_html( "WebSTUMP Administration" );
316   print "
317 <FORM METHOD=$request_method action=$base_address>
318 <INPUT NAME=action VALUE=admin_add_newsgroup TYPE=hidden>
319 <INPUT NAME=password VALUE=\"$password\" TYPE=hidden>\n";
320
321
322   print "
323 <HR>
324 Create a new newsgroup on the server:<BR>
325
326 Newsgroup:<BR> <INPUT NAME=newsgroup_name VALUE=\"\" SIZE=50><BR>
327 Address to send approved/rejected messages <BR>
328         <INPUT NAME=newsgroup_approved_address VALUE=\"\" SIZE=30><BR>
329 Admin Password For this group:<BR> <INPUT NAME=newsgroup_password VALUE=\"\" SIZE=10><BR>
330 <INPUT TYPE=submit VALUE=\"Submit\">
331 <INPUT TYPE=reset VALUE=\"Reset\"><HR>
332 ";
333
334       print "</FORM>\n\n<PRE>\n";
335
336   &end_html;
337 }
338
339 # WebSTUMP "add newsgroup" function
340 sub admin_add_newsgroup {
341
342   &verify_admin_password;
343
344   my $newsgroup = &required_parameter( 'newsgroup_name' );
345
346   $newsgroup =~ s/\///g;
347   $newsgroup = &untaint( $newsgroup );
348
349   my $address = &required_parameter( 'newsgroup_approved_address' );
350   my $password = &required_parameter( 'newsgroup_password' );
351
352   &user_error( "Newsgroup $newsgroup already exists" )
353     if defined $newsgroups_index{$newsgroup};
354
355   &user_error( "Password may only contain letters and digits" )
356     if( ! ($password =~ /^[a-zA-Z0-9]+$/ ) );
357
358   &begin_html( "WebSTUMP Administration: Newsgroup created" );
359
360   print "<PRE>\n\n";
361
362   print "Adding $newsgroup to $webstump_home/config/newsgroups.lst...";
363   mkdir "$webstump_home/queues/$newsgroup", 0755;
364   print " done.\n";
365   
366   $dir = "$webstump_home/config/newsgroups/$newsgroup";
367   
368   print "Creating $dir...";
369   mkdir $dir, 0755;
370   print " done.\n";
371   
372   print "Creating files in $dir...";
373   
374   &append_to_file( "$dir/address.txt", "$address\n" );
375   &append_to_file( "$dir/moderators", "ADMIN \U$password\n" );
376   &append_to_file( "$dir/rejection-reasons",
377 "offtopic::a blatantly offtopic article, spam
378 harassing::message of harassing content
379 charter::message poorly formatted
380 " );
381   print " done.\n";
382
383
384   print "</PRE>\n";
385
386   &end_html;
387 }
388
389 #
390 #
391 sub print_images {
392   $web_subdir = pop( @_ );
393   $subdir = pop( @_ );
394   $newsgroup = pop( @_ );
395
396   opendir( SUBDIR, $subdir );
397
398   my $count = 0;
399
400   while( $_ = readdir( SUBDIR ) ) {
401     my $file = "$subdir/$_";
402     next if( ! -f $file || ! -r $file );
403     my $extension = $file;
404     $extension =~ s/^.*\.//;
405     $extension = "\L$extension";
406     
407     if( $extension eq "gif" || $extension eq "jpg" || $extension eq "jpeg" ) {
408       print "<CENTER> <IMG SRC=$base_address_for_files/queues/$newsgroup/$web_subdir/$_></CENTER><HR>\n";
409       $count++;
410     } else {
411       my $filename = $_;
412       $filename =~ s/^.*\///;
413       next if $filename eq "skeleton.skeleton" 
414               || $filename eq "headers.txt"
415               || $filename eq "full_message.txt"
416               || $filename eq "text.files.lst"
417               || $filename eq "stump-prolog.txt"
418               || $filename eq "stump-warning.txt"
419               || $filename =~ /msg-.*\.doc/;
420       
421       &print_image( "no_image.gif", "security warning" );
422       print "<B>Non-image attachment:</B><CODE>$filename</CODE> NOT SHOWN for security reasons.<BR>\n";
423     }
424   }
425   return $count;
426 }
427
428 # prints warning if there is warning stored about the article
429 sub print_article_warning { # short-subdir
430   my $file = pop( @_ );
431
432   my $warning_file = &article_file_name( $file ) . "/stump-warning.txt";
433
434   if( -r $warning_file ) {
435     open( WARNING, $warning_file );
436     while ($warning = <WARNING>) {
437         next unless $warning =~ m/\S/;
438         $warning =~ s/\&/&amp;/g;
439         $warning =~ s/</&lt;/g;
440         $warning =~ s/>/&gt;/g;
441         &print_image( "star.gif", "warning" );
442         print "<FONT COLOR=red>$warning</FONT><br>\n";
443     }
444     close( WARNING );
445     return 1;
446   }
447
448   return 0;
449 }
450
451 sub get_queue_list ($) {
452     my ($newsgroup) = @_;
453     my $dir = "$queues_dir/$newsgroup";
454     my %sortkeys;
455
456     opendir(QUEUED, $dir) or &error("could not open directory $dir");
457
458     for (;;) {
459         $!=0;
460         my $subdir= scalar readdir(QUEUED);
461         last unless defined $subdir;
462
463         my $subpath= "$dir/$subdir";
464         next if $subdir =~ /^\.+/;
465         next unless -d $subpath;
466         my $sortkey;
467         if (!stat "$subpath/stump-warning.txt") {
468             $!==&ENOENT or die "$subpath $!";
469             $sortkey= 0;
470         } else {
471             $sortkey= (stat _)[9];
472         }
473         $sortkeys{$subdir}= $sortkey;
474     }
475     closedir( QUEUED );
476     my @articles= sort { $sortkeys{$a} <=> $sortkeys{$b} } keys %sortkeys;
477     return ($dir, @articles);
478 }
479
480 # main moderation page
481 sub html_moderation_screen {
482   my $newsgroup = &required_parameter( 'newsgroup' );
483   my $moderator = $request{'moderator'};
484   my $password = $request{'password'};
485
486
487   if( $request{'next_screen'} eq 'single' ) {
488     # we show a single article if the user so requested.
489     # just get the first article from the queue if any, otherwise show 
490     # an empty main screen.
491    
492     my ($dir, @articles)= get_queue_list($newsgroup);
493
494     my $i;
495     for ($i=0; $i<@articles; $i++) {
496         my $subdir= shift @articles;
497         push @articles, $subdir;
498         last if $request{"decision_$subdir"};
499     }
500
501     while( $subdir = shift @articles ) {
502       if( -d "$dir/$subdir" && !($subdir =~ /^\.+/) 
503           && open( PROLOG, "$dir/$subdir/stump-prolog.txt" ) ) {
504               &html_moderate_article( $subdir );
505               return;
506       }
507     }
508   } else {
509         # otherwise just show the moderator an empty main screen.
510   }
511     
512   &begin_html( "Main Moderation Screen: $newsgroup" );
513   print "Welcome to the main moderation screen. Its main purpose is to 
514 help you process most messages extremely quickly. For every message, it 
515 presents you who sent it, as well as the first three non-blank lines.
516 For those messages where the decision is obvious, simply select your
517 decision (approve/reject etc) and click submit. For those messages which
518 you would like to review in more details, do not select anything and
519 use Review/Comment function from this screen or from a subsequent screen.
520 Remember that if you do not make any decision, the article would stay in the
521 queue.\n";
522
523   &read_rejection_reasons;
524
525   my ($dir, @articles)= get_queue_list($newsgroup);
526
527   print "
528   <FORM METHOD=$request_method action=$base_address>
529   <INPUT NAME=action VALUE=approval_decision TYPE=hidden>";
530     &html_print_credentials;
531   
532   my $file, $subject = "No Subject", $from = "From nobody";
533   my $form_not_empty = "";
534   my $article_count = 0;
535   my $warning = "";
536   while( ($subdir = shift @articles) && $article_count++ < 40 ) {
537     $file=$subdir;
538     if( -d "$dir/$subdir" && !($subdir =~ /^\.+/) 
539         && open( PROLOG, "$dir/$subdir/stump-prolog.txt" ) ) {
540         while( <PROLOG> ) {
541           chop;
542           if( /^Real-Subject: /i ) {
543             s/\&/&amp;/g;
544             s/</&lt;/g;
545             s/>/&gt;/g;
546             s/^Real-Subject: //g;
547             $subject = substr( $_, 0, 50 );
548           } elsif( /^From: /i ){
549             s/\&/&amp;/g;
550             s/</&lt;/g;
551             s/>/&gt;/g;
552             $from = substr( $_, 0, 50 );
553           } elsif( /^$/ ) {
554             last;
555           }
556         }
557
558         print "<HR><B>$from: $subject</B>(";
559         print "<A HREF=$base_address?action=moderate_article&newsgroup=$newsgroup&" .
560               "moderator=$moderator&password=$password&file=$subdir>Review/Comment/Preapprove</A>)<BR>\n";
561         print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=approve>Approve\n";
562         print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=skip>Leave\n";
563         print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=leave>Back of queue\n";
564         foreach (@short_rejection_reasons) {
565           print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=\"reject $_\">Reject \u$_\n";
566         }
567
568         print "<BR>\n";
569
570         &print_article_warning( $file );
571
572         print "<PRE>\n";
573
574         my $i = 0;
575
576         while( ($_ = <PROLOG>) && $i < 5 ) {
577             chop;
578             next if m/^\>/;
579             s/\&/&amp;/g;
580             s/</&lt;/g;
581             s/>/&gt;/g;
582             if( $_ ne "" ) {
583               print "]  " . substr( $_, 0, 75 ) . "\n";
584               $i++;
585             }
586         }
587
588         print "</PRE>";
589         $form_not_empty = "yes";
590         close( PROLOG );
591         $article_count += &print_images( $newsgroup, "$dir/$subdir", $subdir );
592     }
593   }
594
595   if( $form_not_empty ) {
596     print "<HR> <INPUT TYPE=submit VALUE=Submit>
597 <INPUT TYPE=reset VALUE=Reset>
598 ";
599   } else {
600     print "
601 <HR>
602 No articles present in the queue
603 <INPUT TYPE=submit VALUE=Refresh>
604 <HR>\n";
605   }
606
607   print "<A HREF=$base_address?action=change_password&newsgroup=$newsgroup&" .
608         "moderator=$moderator&password=$password>Change Password</A>";
609
610   print "</FORM>\n\n";
611
612   print "<FORM METHOD=$request_method action=$base_address>";
613   &html_print_credentials;
614   print "<INPUT NAME=action VALUE=moderator_admin TYPE=hidden>
615          <INPUT TYPE=submit VALUE=\"Manage pass/grey/block-lists\">
616          </FORM>";
617
618   &end_html;
619 }
620
621 # prints hidden fields -- credentials
622 sub html_print_credentials {
623   my $newsgroup = $request{'newsgroup'};
624   my $moderator = $request{'moderator'};
625   my $password = $request{'password'};
626
627   print "
628  <INPUT NAME=newsgroup VALUE=\"$newsgroup\" TYPE=hidden>
629  <INPUT NAME=moderator VALUE=\"$moderator\" TYPE=hidden>
630  <INPUT NAME=password VALUE=\"$password\" TYPE=hidden>\n";
631 }
632
633 # newsgroup admin page
634 sub html_newsgroup_management {
635   &begin_html( "Administer $request{'newsgroup'}" );
636
637   print "All usernames and passwords are not case sensitive.\n";
638   print "<HR>Use this form to add new moderators or change passwords:<BR>
639  <FORM METHOD=$request_method action=$base_address>
640  <INPUT NAME=action VALUE=add_user TYPE=hidden>";
641   &html_print_credentials;
642   print "
643  Username: <INPUT NAME=user VALUE=\"\" SIZE=20>
644  <BR>
645  Password: <INPUT NAME=new_password VALUE=\"\" SIZE=20>
646  <BR>
647  <INPUT TYPE=submit VALUE=\"Add/Change\">
648  <INPUT TYPE=reset VALUE=Reset>
649  </FORM>
650 ";
651
652   print "<HR>Use this form to delete moderators:<BR>
653  <FORM METHOD=$request_method action=$base_address>
654  <INPUT NAME=action VALUE=delete_user TYPE=hidden>";
655   &html_print_credentials;
656   print "
657  Username: <INPUT NAME=user VALUE=\"\" SIZE=20>
658  <BR>
659  <INPUT TYPE=submit VALUE=\"Delete Moderator\">
660  <INPUT TYPE=reset VALUE=Reset>
661  </FORM><HR>
662
663  <FORM METHOD=$request_method action=$base_address>
664  <INPUT NAME=action VALUE=edit_list TYPE=hidden>";
665   &html_print_credentials;
666   print "
667   Configuration List: <SELECT NAME=list_to_edit>
668
669     <OPTION VALUE=good.posters.list>Good Posters List
670     <OPTION VALUE=watch.posters.list>Suspicious Posters List
671     <OPTION VALUE=bad.posters.list>Banned Posters List
672     <OPTION VALUE=good.subjects.list>Good Subjects List
673     <OPTION VALUE=watch.subjects.list>Suspicious Subjects List
674     <OPTION VALUE=bad.subjects.list>Banned Subjects List
675     <OPTION VALUE=watch.words.list>Suspicious Words List
676     <OPTION VALUE=bad.words.list>Banned Words List
677
678   </SELECT>
679   <INPUT TYPE=submit VALUE=\"Edit\">
680   <INPUT TYPE=reset VALUE=Reset>";
681
682   &link_to_help( "filter-lists", "filtering lists" );
683
684   print "
685   </FORM><HR>
686
687   List of current moderators:<P>
688
689   <UL>\n";
690
691   foreach (keys %moderators) {
692       print "<LI> $_\n";
693   }
694
695   print "</UL>\n";
696
697   &end_html;
698 }
699
700
701 # edit config list
702 sub edit_configuration_list {
703
704   my $list_to_edit = &required_parameter( 'list_to_edit' );
705
706   $list_to_edit = &check_config_list( $list_to_edit );
707
708   my $list_file = &full_config_file_name( $list_to_edit );
709
710   my $list_content = "";
711
712   if( open( LIST, $list_file ) ) {
713     $list_content .= $_ while( <LIST> );
714     close( LIST );
715   }
716
717   $list_content =~ s/\&/&amp;/g;
718   $list_content =~ s/</&lt;/g;
719   $list_content =~ s/>/&gt/g;
720
721   &begin_html( "Edit $list_to_edit" );
722
723   print
724 " <FORM METHOD=$request_method action=$base_address>
725  <INPUT NAME=action VALUE=set_config_list TYPE=hidden>
726  <INPUT NAME=list_to_edit VALUE=$list_to_edit TYPE=hidden>";
727   &html_print_credentials;
728   &link_to_help( $list_to_edit, "$list_to_edit" );
729   print "
730  Edit this list: <HR>
731 <TEXTAREA NAME=list rows=20 COLS=50>
732 $list_content</TEXTAREA>
733
734  <BR>
735  <INPUT TYPE=submit VALUE=\"Set\">
736  </FORM>
737 ";
738
739   &end_html;
740 }
741
742 # password change page
743 sub html_change_password{
744   &begin_html( "Change Password" );
745
746   print "All usernames and passwords are not case sensitive.\n";
747   print "<HR>Use this form to change your password:<BR>
748  <FORM METHOD=$request_method action=$base_address>
749  <INPUT NAME=action VALUE=validate_change_password TYPE=hidden>";
750   &html_print_credentials;
751   print "
752  <BR>
753  New Password: <INPUT NAME=new_password VALUE=\"\" SIZE=20>
754  <BR>
755  <INPUT TYPE=submit VALUE=Submit>
756  <INPUT TYPE=reset VALUE=Reset>
757  </FORM>
758 ";
759
760   &end_html;
761 }
762
763
764 # newsgroup creation form
765 sub init_request_newsgroup_creation{
766   my $newsgroup = &required_parameter( 'newsgroup' );
767
768   &begin_html( "Request Creation of $newsgroup" );
769
770   print "This page helps you ask the system administrator of your domain
771 to create <B>$newsgroup</B> on your server. Type in your domain name and
772 click SUBMIT. An email will be sent to news\@domain and usenet\@domain
773 and postmaster\@domain
774 asking them to create your newsgroup. Please do NOT abuse this system.
775 NOTE: You can give the URL of this page to your group readers so that 
776 they could request creation of their newsgroups by themselves.\n";
777
778   print "<HR>
779  <FORM METHOD=$request_method action=$base_address>
780  <INPUT NAME=action VALUE=complete_newsgroup_creation_request TYPE=hidden>\n";
781   &html_print_credentials;
782   print "
783  <BR>
784  Domain Name ONLY: <INPUT NAME=domain_name VALUE=\"\" SIZE=40>
785  <BR>
786  <INPUT TYPE=submit VALUE=Submit>
787  <INPUT TYPE=reset VALUE=Reset>
788  </FORM>
789 ";
790
791   &end_html;
792 }
793
794
795 # newsgroup creation completion
796 sub complete_newsgroup_creation_request{
797   my $newsgroup = &required_parameter( 'newsgroup' );
798   my $domain_name = &required_parameter( 'domain_name' );
799
800   if( !($domain_name =~ /(^[a-zA-Z0-9\.-_]+$)/) ) {
801     &user_error( "invalid domain name" );
802   }
803
804   $domain_name = $1;
805
806
807   my $request = "To: news\@$domain_name, usenet\@$domain_name, postmaster\@$domain_name
808 Subject: Please create $newsgroup (Moderated)
809 From: devnull\@algebra.com ($newsgroup Moderator)
810 Organization: stump.algebra.com
811
812 Dear News Administrator:
813
814 A user of $domain_name has requested that you create a newsgroup
815
816         $newsgroup (Moderated) 
817
818 on your server. $newsgroup
819 is a legitimately created moderated newsgroup that is available worldwide.
820
821 Thank you very much for your help and cooperation.
822
823 Sincerely,
824
825         - Moderator of $newsgroup.
826
827 ";
828
829   &email_message( $request, "news\@$domain_name" );
830   &email_message( $request, "usenet\@$domain_name" );
831   &email_message( $request, "postmaster\@$domain_name" );
832
833   &begin_html( "Request to create $newsgroup sent" );
834
835   print "The following request has been sent:<HR><PRE>\n";
836
837   print "$request</PRE>\n";
838
839   &end_html;
840 }
841
842 # displays help
843 sub display_help {
844   my $topic_name = &required_parameter( "topic" );
845
846   $topic_name =~ s/\///g;
847   $topic_name =~ s/\.\.//g;
848   $topic_name = &untaint( $topic_name );
849
850   my $file = "$webstump_home/doc/help/$topic_name.html";
851
852   &error( "Topic $topic_name not found in $file." ) 
853         if ! -r $file;
854
855   open( FILE, "$file" );
856   my $help = "";
857   $help .= $_ while( <FILE> );
858   close( FILE );
859
860   $help =~ s/##/$base_address?action=help&topic=/g;
861
862   &begin_html( "$topic_name" );
863
864   print $help;
865
866   print "<HR>";
867 }
868
869
870
871
872
873
874
875 1;