home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / www / mirrors / hirez / cgi-bin / discus / board-admin.cgi < prev    next >
Text File  |  1999-02-12  |  12KB  |  279 lines

  1. #!/usr/bin/perl
  2. $discus_conf = '/usr/local/www/www.hirez.org/discus_admin_149349189/discus.conf';
  3. #Discus board administration script (board-admin.cgi)
  4. #-------------------------------------------------------------------------------
  5. # This script is copyright (c) 1998 by DiscusWare, LLC, all rights reserved.
  6. # Its use is subject to the license agreement that can be found at the following
  7. # URL:  http://www.chem.hope.edu/discus/license
  8. #-------------------------------------------------------------------------------
  9. if (open (FILE, "$discus_conf")) {
  10.     @file = <FILE>;
  11.     close (FILE);
  12.     $evals = "";
  13.     foreach $line (@file) {
  14.         if ($line =~ /^(\w+)=(.*)/) {
  15.             $varname = $1;
  16.             $value = $2;
  17.             $value =~ s/'/\\'/g; $value =~ s/\r//g;
  18.             $evals .= "\$$varname='$value'; ";
  19.         }
  20.     }
  21.     eval($evals);
  22.     require "$admin_dir/source/src-board-subs-common";
  23. } else {
  24.     print "Content-type: text/html\n\n";
  25.     print "<HTML><HEAD><TITLE>Script Execution Error</TITLE></HEAD>\n";
  26.     print "<BODY BGCOLOR=#ffffff TEXT=#000000>\n";
  27.     print "<H1>Script Execution Error</H1>\n";
  28.     print "Discus scripts could not execute because the discus.conf file\n";
  29.     print "could not be opened.";
  30.     print "<P>Reason: <FONT COLOR=#ff0000><B>$!</B></FONT>" if $!;
  31.     print "<P>This generally indicates a setup error of some kind.\n";
  32.     print "Consult the <A HREF=\"http://www.chem.hope.edu/discus/rc\">Discus ";
  33.     print "Resource Center</A> for troubleshooting information.</BODY></HTML>\n";
  34.     exit(0);
  35. }
  36. require "$admin_dir/source/src-board-subs-admin";
  37. &parse_form;
  38. &read_cookie;
  39. if ($FORM{'action'} eq "profile_editor") {
  40.     &check_passwd;
  41.     &ex("profile_editor_screen", "passwd", $FORM{"username"}, "", $FORM{"username"}, "$script_url/board-profile.$cgi_extension", "profile_editor");
  42. }
  43. if ($FORM{'action'} eq "manual_restore") {
  44.     &check_passwd;
  45.     &error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
  46.     &ex('manual_restore', $FORM{'file'}, $FORM{'perform'}, $FORM{'selection'});
  47.     exit(0);
  48. }
  49. if ($FORM{'action'} eq "auto_restore") {
  50.     &check_passwd;
  51.     &error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
  52.     &ex('manual_restore', $FORM{'file'}, "rest2", "*");
  53.     exit(0);
  54. }
  55. if ($FORM{'action'} eq "analyze_log") {
  56.     &check_passwd;
  57.     &ex('log_analysis_access', $FORM{'username'}, $FORM{'analyze'}) if $FORM{'perform'} == 1;
  58.     &ex('log_analysis_by_user', $FORM{'username'}, $FORM{'analyze'}) if $FORM{'perform'} == 2;
  59.     exit(0);
  60. }
  61. if ($FORM{'action'} eq "create_backup") {
  62.     &check_passwd;
  63.     &error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
  64.     &ex('create_backup', $FORM{'filename'}, $FORM{'element1'}, $FORM{'element2'}, $FORM{'element3'}, $FORM{'element4'}, $FORM{'element5'});
  65.     &ex('backup_mgr', 1);
  66.     exit(0);
  67. }
  68. if ($FORM{'action'} eq "bumgr") {
  69.     &check_passwd;
  70.     &error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
  71.     &ex('bumgr', 1);
  72.     &ex('backup_mgr', 1);
  73.     exit(0);
  74. }    
  75. if ($FORM{'action'} eq "profile_fields") {
  76.     &check_passwd;
  77.     &error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
  78.     &ex('profile_fields_save', 1) if $FORM{'save'};
  79.     &ex('profile_fields', 1);
  80.     exit(0);
  81. }
  82. if ($FORM{'action'} eq "email_list") {
  83.     &check_passwd;
  84.     &error_message("Permissions Error", "Only the superuser may access this!") if $FORM{'username'} ne $superuser;
  85.     &ex('email_list', $FORM{'prm'});
  86.     exit(0);
  87. }
  88. if ($FORM{'action'} eq "data_recovery") {
  89.     &check_passwd;
  90.     &error_message("Permissions Error", "Only the superuser may access the data recovery utility") if $FORM{'username'} ne $superuser;
  91.     &ex("data_recovery_action", $FORM{'topic'}, $FORM{'fixem'});
  92.     exit(0);
  93. }
  94. if ($FORM{'action'} eq "data_recovery_top") {
  95.     &check_passwd;
  96.     &error_message("Permissions Error", "Only the superuser may access the data recovery utility") if $FORM{'username'} ne $superuser;
  97.     &ex("data_recovery_top", $FORM{'rectype'});
  98.     exit(0);
  99. }
  100. if ($FORM{'action'} eq "archive_options") {
  101.     &check_passwd;
  102.     &error_message("Permissions Error", "Only the superuser may save options that affect archiving") if $FORM{'username'} ne $superuser;
  103.     &ex('save_archive_options', 1);
  104.     &ex('archive_mgr', 1);
  105. }
  106. if ($FORM{'action'} eq "options_save") {
  107.     &check_passwd;
  108.     &error_message("Permissions Error", "Only the superuser may save options that affect the entire board") if $FORM{'username'} ne $superuser;
  109.     &ex('options_save', 1);
  110.     &ex('options_mgr', 1);
  111. } else {
  112.     if ($GLOBAL_OPTIONS{'admin'} == 0 && $GLOBAL_OPTIONS{'options_used'} == 1) {
  113.         &error_message("Administration Disabled", "Administration has been disabled on this board for all moderators except the superuser.") if $FORM{'username'} ne $superuser;
  114.     }
  115. }
  116. if ($FORM{'action'} eq "email_save") {
  117.     &check_passwd;
  118.     &error_message("Permissions Error", "Only the superuser may save options that affect the entire board", 0, 1) if $FORM{'username'} ne $superuser;
  119.     &error_message("Permissions Error", "The e-mail notification settings are <U>read-only</U>.  To remove this restriction, move the <U>email.txt</U> file from the <U>$admin_dir/source</U> directory into your <U>$admin_dir</U> directory.", 0, 1) if -e "$admin_dir/source/email.txt";
  120.     &ex('email_configuration', 1);
  121.     &ex('email_configurator', 1);
  122. }
  123. if ($FORM{'action'} eq "prune_board") {
  124.     &check_passwd;
  125.     &error_message("Permissions Error", "Only the superuser may access this option") if $FORM{'username'} ne $superuser;
  126.     $FORM{'prune_days'} =~ s/\D//g;
  127.     &error_message("Archive/Prune Error", "The number of days you specified is invalid") if $FORM{'prune_days'} <= 0;
  128.     foreach $key (keys(%FORM)) {
  129.         if ($key =~ m|prune_(\d+)|) {
  130.             $topic = $1;
  131.             &ex('prune_messages', $topic, $FORM{'prune_days'}, $FORM{'dowhat'});
  132.         }
  133.     }
  134.     &ex('archive_mgr', 1);
  135. }
  136. if ($FORM{'action'} eq "cuss_save") {
  137.     &check_passwd;
  138.     &error_message("Permissions Error", "Only the superuser may save options that affect the entire board") if $FORM{'username'} ne $superuser;
  139.     &ex('cuss_save', $FORM{'cusswords'});
  140.     &ex('profanity_editor', 1);
  141. }
  142. if ($FORM{'action'} eq "queue_edit") {
  143.     &check_passwd;
  144.     @q = &ex('check_queue', $FORM{'username'});
  145.     $FORM{'number'} =~ s/\D//g;
  146.     foreach $line (@q) {
  147.         $line =~ m|^(\d+)/(\d+)|;
  148.         if ($1 == $FORM{'number'}) {
  149.             &ex('queue_edit', $FORM{'username'}, $FORM{'number'}, $FORM{'submit'}, $FORM{'subject'}, $FORM{'message'}, $2);
  150.         }
  151.     }
  152.     &error_message("Queue Error", "The message you attempted to edit is no longer in the queue.");
  153. }
  154. if ($FORM{'action'} eq "queue_action") {
  155.     &check_passwd;
  156.     @q = &ex('check_queue', $FORM{'username'});
  157.     if ($FORM{'SELECTION'} =~ /((approve)|(refuse))(\w+)/) {
  158.         $todo = $4; $action = $1;
  159.         if ($todo ne "all") {
  160.             $todo =~ s/\D//g;
  161.             if ($todo != 0) {
  162.                 &ex('queue_action', $FORM{'username'}, $todo, $action, $FORM{'form'});
  163.             }
  164.         } else {
  165.             @mark = split(/,/, $FORM{'MARK'});
  166.             foreach $num (@mark) {
  167.                 $num =~ s/\D//g;
  168.                 &ex('queue_action', $FORM{'username'}, $num, $action, $FORM{'form'}, 1);
  169.             }
  170.         }
  171.     }
  172.     &ex('queue_mgr_1', $FORM{'username'}, 1);
  173.     exit(0);
  174. }
  175. if ($FORM{'action'} eq 'show_secure_graphic') {
  176.     &check_passwd;
  177.     &extract ($FORM{'HTTP_REFERER'});
  178.     &verify_owner($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit this page!");
  179.     &ex('show_secure_image', $FORM{'file'}, $FORM{'type'});
  180.     exit(0);
  181. }
  182. if ($FORM{'action'} eq "access_edit_simple") {
  183.     &check_passwd;
  184.     &extract("/$FORM{'topic'}/$FORM{'topic'}.$ext");
  185.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit access in this topic!");
  186.     &ex('posting_options', $FORM{'topic'}, $FORM{'anondisable'}, $FORM{'stampdisable'}, $FORM{'emaildisable'});
  187.     &ex('access_edit_simple', $FORM{'topic'}, "posting", $FORM{'publicbox'}, $FORM{'modgroup'}, $FORM{'usergroup'}, $FORM{'modall'}, $FORM{'userall'}, $owner, $FORM{'kill'});
  188.     &ex('access_mgr_2', $FORM{'topic'}, $FORM{'username'});
  189.     exit(0);
  190. }
  191. if ($FORM{'action'} eq "access_pro") {
  192.     &check_passwd;
  193.     &extract("/$FORM{'topic'}/$FORM{'topic'}.$ext");
  194.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit access in this topic!");
  195.     &ex('access_edit_configure', $FORM{'word'}, $FORM{'do'});
  196.     exit(0);
  197. }
  198. if ($FORM{'action'} eq "access_edit_pro") {
  199.     &check_passwd;
  200.     &extract("/$FORM{'topic'}/$FORM{'topic'}.$ext");
  201.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit access in this topic!");
  202.     $file = "";
  203.     $file = "security" if $FORM{'privs'} eq "reading";
  204.     $file = "posting" if $file eq "";
  205.     &ex('aedit_pro', $topic_number, $file);
  206.     &ex('access_mgr_2_pro', $FORM{'topic'}, $FORM{'username'});
  207.     exit(0);
  208. }
  209. if ($FORM{'action'} eq "access_edit_advanced") {
  210.     &check_passwd;
  211.     &extract("/$FORM{'topic'}/$FORM{'topic'}.$ext");
  212.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit access in this topic!");
  213.     $file = "";
  214.     $file = "security" if $FORM{'privtype'} eq "reading";
  215.     $file = "posting" if $file eq "";
  216.     &ex('advanced_access_editor', $file, $FORM{'do'}, $topic_number);
  217.     &ex('access_mgr_2_pro', $FORM{'topic'}, $FORM{'username'});
  218.     exit(0);
  219. }
  220. if ($FORM{'action'} =~ m|^reg_config_save|) {
  221.     &check_passwd;
  222.     &error_message("Permissions Error", "You must be the superuser to access this function!") if $FORM{'username'} ne $superuser;
  223.     &ex('save_selfreg_config', $FORM{'banned'}) if $FORM{'action'} eq "reg_config_save";
  224.     &ex('save_selfreg_config_rs', 1) if $FORM{'action'} eq "reg_config_save_rs";
  225.     if ($FORM{'action'} eq "reg_config_save_welcome") {
  226.         $FORM{'message'} =~ s/^\s+//; $FORM{'message'} =~ s/\s+$//;
  227.         ($lint_subj, $new_message) = &ex('webtags', $FORM{'message'}, 1, 1);
  228.         $FORM{'submit'} = "Preview" if $lint_subj eq "!Error";
  229.         if ($FORM{'submit'} =~ /Preview/) {
  230.             $FORM{'message'} =~ s/&/&/g;
  231.             $FORM{'message'} =~ s/</</g;
  232.             $FORM{'message'} =~ s/>/>/g;
  233.             $FORM{'message'} =~ s/"/"/g;
  234.             &ex('preview_admin_message', $FORM{"message"}, $new_message, $FORM{"username"}, "", "reg_config_save_welcome", "Welcome Message");
  235.             exit(0);
  236.         } else {
  237.             &ex('save_selfreg_config_welcome', $FORM{'message'}, $new_message);
  238.         }
  239.     }
  240.     &ex('reg_configurator', 1);
  241.     exit(0);
  242. }
  243. ##########################################################################
  244. # SET INITIAL PASSWORD FOR THE SUPERUSER
  245. ##########################################################################
  246. if ($FORM{'action'} eq "password") {
  247.     &check_passwd(0,1);
  248.     &error_message("Permissions Error", "You must be the superuser to access this function!") if $FORM{'username'} ne $superuser;
  249.     &lock("$admin_dir/passwd.txt");
  250.     open (PASS, "$admin_dir/passwd.txt") || &error_message("File Read Error", "Cannot read your <B>passwd.txt</B> file.");
  251.     @pass = <PASS>; close (PASS);
  252.     open (PASS, ">$admin_dir/passwd.txt") || &error_message("File Write Error", "Cannot write to your <B>passwd.txt</B> file.  Check that you have set permissions properly on that file.");
  253.     print PASS @pass;
  254.     close (PASS);
  255.     &unlock("$admin_dir/passwd.txt");
  256.     ($result) = grep(/^$superuser:/, @pass);
  257.     $result = "PASSWD:$result";
  258.     @result = ($result);
  259.     $p1 = $FORM{'pass1'}; $p2 = $FORM{'pass2'};
  260.     $p1 =~ tr/A-Z/a-z/; $p2 =~ tr/A-Z/a-z/;
  261.     &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_ALPHA}) if $p1 =~ /\W/;
  262.     &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_MATCH}) if $p1 ne $p2;
  263.     &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_LENGTH}) if length($p1) < 2;
  264.     srand(time);
  265.     undef (@salt);
  266.     for ($i=1; $i<=4; $i++) {
  267.         push (@salt, int(rand(26))+65);
  268.     }
  269.     $salt = pack('c4', @salt);
  270.     $new_password = crypt($p1, $salt);
  271.     &ex('save_profile_information', $new_password, "", "", "", "", "", "", @result);
  272.     &ex('register_discus', 1);
  273.     exit(0);
  274. }
  275. ##########################################################################
  276. # GENERAL FUNCTIONS
  277. ##########################################################################
  278. &error_message("Unexplained Error", "The script form values passed to the board administration program produced an unexplained error.");
  279.