chiark / gitweb /
e99c8d1d109dd1ecc4b060d18831036f115de81c
[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/blacklist", "" );
375   &append_to_file( "$dir/address.txt", "$address\n" );
376   &append_to_file( "$dir/moderators", "ADMIN \U$password\n" );
377   &append_to_file( "$dir/rejection-reasons",
378 "offtopic::a blatantly offtopic article, spam
379 harassing::message of harassing content
380 charter::message poorly formatted
381 " );
382   &append_to_file( "$dir/whitelist", "" );
383   print " done.\n";
384
385
386   print "</PRE>\n";
387
388   &end_html;
389 }
390
391 #
392 #
393 sub print_images {
394   $web_subdir = pop( @_ );
395   $subdir = pop( @_ );
396   $newsgroup = pop( @_ );
397
398   opendir( SUBDIR, $subdir );
399
400   my $count = 0;
401
402   while( $_ = readdir( SUBDIR ) ) {
403     my $file = "$subdir/$_";
404     next if( ! -f $file || ! -r $file );
405     my $extension = $file;
406     $extension =~ s/^.*\.//;
407     $extension = "\L$extension";
408     
409     if( $extension eq "gif" || $extension eq "jpg" || $extension eq "jpeg" ) {
410       print "<CENTER> <IMG SRC=$base_address_for_files/queues/$newsgroup/$web_subdir/$_></CENTER><HR>\n";
411       $count++;
412     } else {
413       my $filename = $_;
414       $filename =~ s/^.*\///;
415       next if $filename eq "skeleton.skeleton" 
416               || $filename eq "headers.txt"
417               || $filename eq "full_message.txt"
418               || $filename eq "text.files.lst"
419               || $filename eq "stump-prolog.txt"
420               || $filename eq "stump-warning.txt"
421               || $filename =~ /msg-.*\.doc/;
422       
423       &print_image( "no_image.gif", "security warning" );
424       print "<B>Non-image attachment:</B><CODE>$filename</CODE> NOT SHOWN for security reasons.<BR>\n";
425     }
426   }
427   return $count;
428 }
429
430 # prints warning if there is warning stored about the article
431 sub print_article_warning { # short-subdir
432   my $file = pop( @_ );
433
434   my $warning_file = &article_file_name( $file ) . "/stump-warning.txt";
435
436   if( -r $warning_file ) {
437     open( WARNING, $warning_file );
438     while ($warning = <WARNING>) {
439         next unless $warning =~ m/\S/;
440         $warning =~ s/\&/&amp;/g;
441         $warning =~ s/</&lt;/g;
442         $warning =~ s/>/&gt;/g;
443         &print_image( "star.gif", "warning" );
444         print "<FONT COLOR=red>$warning</FONT><br>\n";
445     }
446     close( WARNING );
447     return 1;
448   }
449
450   return 0;
451 }
452
453 sub get_queue_list ($) {
454     my ($newsgroup) = @_;
455     my $dir = "$queues_dir/$newsgroup";
456     my %sortkeys;
457
458     opendir(QUEUED, $dir) or &error("could not open directory $dir");
459
460     for (;;) {
461         $!=0;
462         my $subdir= scalar readdir(QUEUED);
463         last unless defined $subdir;
464
465         my $subpath= "$dir/$subdir";
466         next if $subdir =~ /^\.+/;
467         next unless -d $subpath;
468         my $sortkey;
469         if (!stat "$subpath/stump-warning.txt") {
470             $!==&ENOENT or die "$subpath $!";
471             $sortkey= 0;
472         } else {
473             $sortkey= (stat _)[9];
474         }
475         $sortkeys{$subdir}= $sortkey;
476     }
477     closedir( QUEUED );
478     my @articles= sort { $sortkeys{$a} <=> $sortkeys{$b} } keys %sortkeys;
479     return ($dir, @articles);
480 }
481
482 # main moderation page
483 sub html_moderation_screen {
484   my $newsgroup = &required_parameter( 'newsgroup' );
485   my $moderator = $request{'moderator'};
486   my $password = $request{'password'};
487
488
489   if( $request{'next_screen'} eq 'single' ) {
490     # we show a single article if the user so requested.
491     # just get the first article from the queue if any, otherwise show 
492     # an empty main screen.
493    
494     my ($dir, @articles)= get_queue_list($newsgroup);
495
496     my $i;
497     for ($i=0; $i<@articles; $i++) {
498         my $subdir= shift @articles;
499         push @articles, $subdir;
500         last if $request{"decision_$subdir"};
501     }
502
503     while( $subdir = shift @articles ) {
504       if( -d "$dir/$subdir" && !($subdir =~ /^\.+/) 
505           && open( PROLOG, "$dir/$subdir/stump-prolog.txt" ) ) {
506               &html_moderate_article( $subdir );
507               return;
508       }
509     }
510   } else {
511         # otherwise just show the moderator an empty main screen.
512   }
513     
514   &begin_html( "Main Moderation Screen: $newsgroup" );
515   print "Welcome to the main moderation screen. Its main purpose is to 
516 help you process most messages extremely quickly. For every message, it 
517 presents you who sent it, as well as the first three non-blank lines.
518 For those messages where the decision is obvious, simply select your
519 decision (approve/reject etc) and click submit. For those messages which
520 you would like to review in more details, do not select anything and
521 use Review/Comment function from this screen or from a subsequent screen.
522 Remember that if you do not make any decision, the article would stay in the
523 queue.\n";
524
525   &read_rejection_reasons;
526
527   my ($dir, @articles)= get_queue_list($newsgroup);
528
529   print "
530   <FORM METHOD=$request_method action=$base_address>
531   <INPUT NAME=action VALUE=approval_decision TYPE=hidden>";
532     &html_print_credentials;
533   
534   my $file, $subject = "No Subject", $from = "From nobody";
535   my $form_not_empty = "";
536   my $article_count = 0;
537   my $warning = "";
538   while( ($subdir = shift @articles) && $article_count++ < 40 ) {
539     $file=$subdir;
540     if( -d "$dir/$subdir" && !($subdir =~ /^\.+/) 
541         && open( PROLOG, "$dir/$subdir/stump-prolog.txt" ) ) {
542         while( <PROLOG> ) {
543           chop;
544           if( /^Real-Subject: /i ) {
545             s/\&/&amp;/g;
546             s/</&lt;/g;
547             s/>/&gt;/g;
548             s/^Real-Subject: //g;
549             $subject = substr( $_, 0, 50 );
550           } elsif( /^From: /i ){
551             s/\&/&amp;/g;
552             s/</&lt;/g;
553             s/>/&gt;/g;
554             $from = substr( $_, 0, 50 );
555           } elsif( /^$/ ) {
556             last;
557           }
558         }
559
560         print "<HR><B>$from: $subject</B>(";
561         print "<A HREF=$base_address?action=moderate_article&newsgroup=$newsgroup&" .
562               "moderator=$moderator&password=$password&file=$subdir>Review/Comment/Preapprove</A>)<BR>\n";
563         print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=approve>Approve\n";
564         print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=skip>Leave\n";
565         print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=leave>Back of queue\n";
566         foreach (@short_rejection_reasons) {
567           print "<INPUT TYPE=radio NAME=\"decision_$file\" VALUE=\"reject $_\">Reject \u$_\n";
568         }
569
570         print "<BR>\n";
571
572         &print_article_warning( $file );
573
574         print "<PRE>\n";
575
576         my $i = 0;
577
578         while( ($_ = <PROLOG>) && $i < 5 ) {
579             chop;
580             next if m/^\>/;
581             s/\&/&amp;/g;
582             s/</&lt;/g;
583             s/>/&gt;/g;
584             if( $_ ne "" ) {
585               print "]  " . substr( $_, 0, 75 ) . "\n";
586               $i++;
587             }
588         }
589
590         print "</PRE>";
591         $form_not_empty = "yes";
592         close( PROLOG );
593         $article_count += &print_images( $newsgroup, "$dir/$subdir", $subdir );
594     }
595   }
596
597   if( $form_not_empty ) {
598     print "<HR> <INPUT TYPE=submit VALUE=Submit>
599 <INPUT TYPE=reset VALUE=Reset>
600 ";
601   } else {
602     print "
603 <HR>
604 No articles present in the queue
605 <INPUT TYPE=submit VALUE=Refresh>
606 <HR>\n";
607   }
608
609   print "<A HREF=$base_address?action=change_password&newsgroup=$newsgroup&" .
610         "moderator=$moderator&password=$password>Change Password</A>";
611
612   print "</FORM>\n\n";
613
614   print "<FORM METHOD=$request_method action=$base_address>";
615   &html_print_credentials;
616   print "<INPUT NAME=action VALUE=moderator_admin TYPE=hidden>
617          <INPUT TYPE=submit VALUE=\"Manage pass/grey/block-lists\">
618          </FORM>";
619
620   &end_html;
621 }
622
623 # prints hidden fields -- credentials
624 sub html_print_credentials {
625   my $newsgroup = $request{'newsgroup'};
626   my $moderator = $request{'moderator'};
627   my $password = $request{'password'};
628
629   print "
630  <INPUT NAME=newsgroup VALUE=\"$newsgroup\" TYPE=hidden>
631  <INPUT NAME=moderator VALUE=\"$moderator\" TYPE=hidden>
632  <INPUT NAME=password VALUE=\"$password\" TYPE=hidden>\n";
633 }
634
635 # newsgroup admin page
636 sub html_newsgroup_management {
637   &begin_html( "Administer $request{'newsgroup'}" );
638
639   print "All usernames and passwords are not case sensitive.\n";
640   print "<HR>Use this form to add new moderators or change passwords:<BR>
641  <FORM METHOD=$request_method action=$base_address>
642  <INPUT NAME=action VALUE=add_user TYPE=hidden>";
643   &html_print_credentials;
644   print "
645  Username: <INPUT NAME=user VALUE=\"\" SIZE=20>
646  <BR>
647  Password: <INPUT NAME=new_password VALUE=\"\" SIZE=20>
648  <BR>
649  <INPUT TYPE=submit VALUE=\"Add/Change\">
650  <INPUT TYPE=reset VALUE=Reset>
651  </FORM>
652 ";
653
654   print "<HR>Use this form to delete moderators:<BR>
655  <FORM METHOD=$request_method action=$base_address>
656  <INPUT NAME=action VALUE=delete_user TYPE=hidden>";
657   &html_print_credentials;
658   print "
659  Username: <INPUT NAME=user VALUE=\"\" SIZE=20>
660  <BR>
661  <INPUT TYPE=submit VALUE=\"Delete Moderator\">
662  <INPUT TYPE=reset VALUE=Reset>
663  </FORM><HR>
664
665  <FORM METHOD=$request_method action=$base_address>
666  <INPUT NAME=action VALUE=edit_list TYPE=hidden>";
667   &html_print_credentials;
668   print "
669   Configuration List: <SELECT NAME=list_to_edit>
670
671     <OPTION VALUE=good.posters.list>Good Posters List
672     <OPTION VALUE=watch.posters.list>Suspicious Posters List
673     <OPTION VALUE=bad.posters.list>Banned Posters List
674     <OPTION VALUE=good.subjects.list>Good Subjects List
675     <OPTION VALUE=watch.subjects.list>Suspicious Subjects List
676     <OPTION VALUE=bad.subjects.list>Banned Subjects List
677     <OPTION VALUE=watch.words.list>Suspicious Words List
678     <OPTION VALUE=bad.words.list>Banned Words List
679
680   </SELECT>
681   <INPUT TYPE=submit VALUE=\"Edit\">
682   <INPUT TYPE=reset VALUE=Reset>";
683
684   &link_to_help( "filter-lists", "filtering lists" );
685
686   print "
687   </FORM><HR>
688
689   List of current moderators:<P>
690
691   <UL>\n";
692
693   foreach (keys %moderators) {
694       print "<LI> $_\n";
695   }
696
697   print "</UL>\n";
698
699   &end_html;
700 }
701
702
703 # edit config list
704 sub edit_configuration_list {
705
706   my $list_to_edit = &required_parameter( 'list_to_edit' );
707
708   $list_to_edit = &check_config_list( $list_to_edit );
709
710   my $list_file = &full_config_file_name( $list_to_edit );
711
712   my $list_content = "";
713
714   if( open( LIST, $list_file ) ) {
715     $list_content .= $_ while( <LIST> );
716     close( LIST );
717   }
718
719   $list_content =~ s/\&/&amp;/g;
720   $list_content =~ s/</&lt;/g;
721   $list_content =~ s/>/&gt/g;
722
723   &begin_html( "Edit $list_to_edit" );
724
725   print
726 " <FORM METHOD=$request_method action=$base_address>
727  <INPUT NAME=action VALUE=set_config_list TYPE=hidden>
728  <INPUT NAME=list_to_edit VALUE=$list_to_edit TYPE=hidden>";
729   &html_print_credentials;
730   &link_to_help( $list_to_edit, "$list_to_edit" );
731   print "
732  Edit this list: <HR>
733 <TEXTAREA NAME=list rows=20 COLS=50>
734 $list_content</TEXTAREA>
735
736  <BR>
737  <INPUT TYPE=submit VALUE=\"Set\">
738  </FORM>
739 ";
740
741   &end_html;
742 }
743
744 # password change page
745 sub html_change_password{
746   &begin_html( "Change Password" );
747
748   print "All usernames and passwords are not case sensitive.\n";
749   print "<HR>Use this form to change your password:<BR>
750  <FORM METHOD=$request_method action=$base_address>
751  <INPUT NAME=action VALUE=validate_change_password TYPE=hidden>";
752   &html_print_credentials;
753   print "
754  <BR>
755  New Password: <INPUT NAME=new_password VALUE=\"\" SIZE=20>
756  <BR>
757  <INPUT TYPE=submit VALUE=Submit>
758  <INPUT TYPE=reset VALUE=Reset>
759  </FORM>
760 ";
761
762   &end_html;
763 }
764
765
766 # newsgroup creation form
767 sub init_request_newsgroup_creation{
768   my $newsgroup = &required_parameter( 'newsgroup' );
769
770   &begin_html( "Request Creation of $newsgroup" );
771
772   print "This page helps you ask the system administrator of your domain
773 to create <B>$newsgroup</B> on your server. Type in your domain name and
774 click SUBMIT. An email will be sent to news\@domain and usenet\@domain
775 and postmaster\@domain
776 asking them to create your newsgroup. Please do NOT abuse this system.
777 NOTE: You can give the URL of this page to your group readers so that 
778 they could request creation of their newsgroups by themselves.\n";
779
780   print "<HR>
781  <FORM METHOD=$request_method action=$base_address>
782  <INPUT NAME=action VALUE=complete_newsgroup_creation_request TYPE=hidden>\n";
783   &html_print_credentials;
784   print "
785  <BR>
786  Domain Name ONLY: <INPUT NAME=domain_name VALUE=\"\" SIZE=40>
787  <BR>
788  <INPUT TYPE=submit VALUE=Submit>
789  <INPUT TYPE=reset VALUE=Reset>
790  </FORM>
791 ";
792
793   &end_html;
794 }
795
796
797 # newsgroup creation completion
798 sub complete_newsgroup_creation_request{
799   my $newsgroup = &required_parameter( 'newsgroup' );
800   my $domain_name = &required_parameter( 'domain_name' );
801
802   if( !($domain_name =~ /(^[a-zA-Z0-9\.-_]+$)/) ) {
803     &user_error( "invalid domain name" );
804   }
805
806   $domain_name = $1;
807
808
809   my $request = "To: news\@$domain_name, usenet\@$domain_name, postmaster\@$domain_name
810 Subject: Please create $newsgroup (Moderated)
811 From: devnull\@algebra.com ($newsgroup Moderator)
812 Organization: stump.algebra.com
813
814 Dear News Administrator:
815
816 A user of $domain_name has requested that you create a newsgroup
817
818         $newsgroup (Moderated) 
819
820 on your server. $newsgroup
821 is a legitimately created moderated newsgroup that is available worldwide.
822
823 Thank you very much for your help and cooperation.
824
825 Sincerely,
826
827         - Moderator of $newsgroup.
828
829 ";
830
831   &email_message( $request, "news\@$domain_name" );
832   &email_message( $request, "usenet\@$domain_name" );
833   &email_message( $request, "postmaster\@$domain_name" );
834
835   &begin_html( "Request to create $newsgroup sent" );
836
837   print "The following request has been sent:<HR><PRE>\n";
838
839   print "$request</PRE>\n";
840
841   &end_html;
842 }
843
844 # displays help
845 sub display_help {
846   my $topic_name = &required_parameter( "topic" );
847
848   $topic_name =~ s/\///g;
849   $topic_name =~ s/\.\.//g;
850   $topic_name = &untaint( $topic_name );
851
852   my $file = "$webstump_home/doc/help/$topic_name.html";
853
854   &error( "Topic $topic_name not found in $file." ) 
855         if ! -r $file;
856
857   open( FILE, "$file" );
858   my $help = "";
859   $help .= $_ while( <FILE> );
860   close( FILE );
861
862   $help =~ s/##/$base_address?action=help&topic=/g;
863
864   &begin_html( "$topic_name" );
865
866   print $help;
867
868   print "<HR>";
869 }
870
871
872
873
874
875
876
877 1;