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 / acheron / cgi-bin / discus / board-admin-3.cgi < prev    next >
Text File  |  1999-01-26  |  8KB  |  198 lines

  1. #!/usr/bin/perl
  2. $discus_conf = '/usr/local/www/www.acheron.org/discus_admin_245059122/discus.conf';
  3. #Discus board administration script (board-admin-3.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. #-------------------------------------------------------------------------------
  40. # USER MANAGER ACTIONS AND OTHER RELATED FUNCTIONS
  41. #-------------------------------------------------------------------------------
  42. if ($FORM{'action'} eq "add_user") {
  43.     &check_passwd;
  44.     &verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to add users to this group!");
  45.     &ex('add_user', $FORM{"username"}, $FORM{"newuser"}, $FORM{"pass_1"}, $FORM{"pass_2"}, $FORM{"group"}, $FORM{'email'}, $FORM{'fullname'});
  46.     &ex('user_mgr_2', $FORM{"username"}, $FORM{"group"}); exit(0);
  47. }
  48. if ($FORM{'action'} eq 'preview_list') {
  49.     &check_passwd;
  50.     &verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to add users to this group!");
  51.     &ex("preview_user_list", $FORM{"username"}, $FORM{"group"}, $FORM{"list"});
  52.     exit(0);
  53. }
  54. if ($FORM{'action'} eq 'submit_list') {
  55.     &check_passwd;
  56.     &verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to add users to this group!");
  57.     if ($FORM{'modify'} == 1) {
  58.         ($modified_list) = &ex("modify_list", 1);
  59.         &ex("preview_user_list", $FORM{"username"}, $FORM{"group"}, $modified_list, $FORM{"delimiter"});
  60.     } else {
  61.         &ex("add_user_list", $FORM{"username"}, $FORM{"group"});
  62.         &ex('user_mgr_2', $FORM{"username"}, $FORM{"group"}); exit(0);
  63.     }
  64. }
  65. if ($FORM{'action'} eq "user_form") {
  66.     &check_passwd;
  67.     &verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to remove or edit users in this group!");
  68.     if ($FORM{'SELECTION'} =~ /^delete(.+)/) {
  69.         $remove = $1;
  70.         if ($remove ne "ALL") {
  71.             &ex("delete_user", $remove, $FORM{"group"});
  72.         } else {
  73.             &ex("delete_user", $FORM{"MARK"}, $FORM{"group"});
  74.         }
  75.         &ex('user_mgr_2', $FORM{"username"}, $FORM{"group"}); exit(0);
  76.     } elsif ($FORM{'SELECTION'} =~ /^edit(.+)/) {
  77.         $edit = $1;
  78.         &ex("profile_editor_screen", "users", $edit, $FORM{'group'}, $FORM{"username"}, "$cgiurl3", "profile_user", 1) if !$pro;
  79.         &ex("profile_editor_screen_PRO", "users", $edit, $FORM{'group'}, $FORM{"username"}, "$cgiurl3", "profile_user", 1) if $pro;
  80.         exit(0);
  81.     }
  82. }
  83. if ($FORM{'action'} eq "profile_user") {
  84.     &check_passwd;
  85.     &verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to remove or edit users in this group!");
  86.     $act2 = $FORM{'action2'};
  87.     $group = $FORM{'group'};
  88.     $username = $FORM{'username_edit'};
  89.     open (USERS, "$admin_dir/users.txt"); @users = <USERS>; close (USERS);
  90.     @users = grep(/:$group\s*$/, @users);
  91.     ($result) = grep(/^$username:/, @users);
  92.     $result = "USERS:$result";
  93.     @result = ($result);
  94.     if ($act2 eq "infosave") {
  95.         $email = $FORM{'profile_email'};
  96.         $full = $FORM{'profile_fullname'};
  97.         if ($email =~ m|^([\w\-\+\.]+)\@([\w\-\+\.]+)$|) {
  98.             $email_new = $email;
  99.         } else {
  100.             $email_new = "email";
  101.         }
  102.         if ($full eq "") {
  103.             $full = "fullname";
  104.         } else {
  105.             $full =~ s/\n//g;
  106.             $full =~ s/[:<>]//g;    
  107.         }
  108.         &ex('save_profile_information', "", $email_new, $full, "", "", "", "", @result);
  109.     } elsif ($act2 eq "notifysave") {
  110.         if (!$pro) {
  111.             undef @em;
  112.             foreach $key (keys(%FORM)) {
  113.                 if ($key =~ m|^notify_(\d+)|) {
  114.                     push (@em, $1);
  115.                 }
  116.             }
  117.             $emr = join(",", @em); $emr = "*" if $emr eq "";
  118.             &ex('save_profile_information', "", "", "", "", $emr, "", "", @result);
  119.         } else {
  120.             &ex('select_by_subtopics', "users", $FORM{"username_edit"}, $FORM{'group'}, $FORM{"username"}, "$cgiurl3", "profile_user", 1) if $FORM{'submit'} eq $L{PRED_FIRSTLEVEL};
  121.             &ex('notify_save_pro', $FORM{'username_edit'}, $FORM{'username'});
  122.         }
  123.     } elsif ($act2 eq "changepass") {
  124.         $p1 = $FORM{'pass_1'}; $p2 = $FORM{'pass_2'};
  125.         $p1 =~ tr/A-Z/a-z/; $p2 =~ tr/A-Z/a-z/;
  126.         while ($p1 =~ m|(\W)|g) {
  127.             $o = ord($1); $m = $1;    
  128.             &error_message("Change Password Error", "Password is invalid (password may not contain the character <B>$m</B>).") if $o < 126;
  129.         }
  130.         &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_MATCH}) if $p1 ne $p2;
  131.         &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_LENGTH}) if (length($p1) < 1 || length($p1) > 20);
  132.         srand(time);
  133.         undef (@salt);
  134.         for ($i=1; $i<=4; $i++) {
  135.             push (@salt, int(rand(26))+65);
  136.         }
  137.         $salt = pack('c4', @salt);
  138.         $new_password = crypt($p1, $salt);
  139.         &ex('save_profile_information', $new_password, "", "", "", "", "", "", @result);
  140.     } elsif ($FORM{'action2'} eq "preferences") {
  141.         @result_save = @result;
  142.         &ex('prefs_save_pro', 1);
  143.     } elsif ($FORM{'action2'} eq "infosection") {
  144.         @result_save = @result;
  145.         &ex('info_save_pro', 1);
  146.     } elsif ($act2 eq "editpriv") {
  147.         $FORM{'editing'} =~ s/\D//g;
  148.         &ex('save_profile_information', "", "", "", $FORM{'editing'}, "", "", "", @result);
  149.     } elsif ($act2 eq "picture") {
  150.         &ex('clear_picture', @result);
  151.     }
  152.     &ex("profile_editor_screen", "users", $username, $FORM{'group'}, $FORM{"username"}, "$cgiurl3", "profile_user", 1) if !$pro;
  153.     &ex("profile_editor_screen_PRO", "users", $username, $FORM{'group'}, $FORM{"username"}, "$cgiurl3", "profile_user", 1) if $pro;
  154. }
  155. if ($FORM{'action'} eq "selfreg") {
  156.     &check_passwd;
  157.     &verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to configure this group!");
  158.     &ex('user_selfreg_config_save', $FORM{'group'}, $FORM{'selfreg'});
  159.     &ex('user_mgr_2', $FORM{"username"}, $FORM{"group"}); exit(0);
  160. }
  161. if ($FORM{'action'} eq "userqueue") {
  162.     &check_passwd;
  163.     &ex('userapp_framesetter', $FORM{'username'}, 1) if $FORM{'blank'} == 0;
  164.     &ex('userapp_framesetter', $FORM{'username'}, 2) if $FORM{'blank'} == 1;
  165. }
  166. if ($FORM{'action'} eq "userapp_2") {
  167.     &check_passwd;
  168.     &ex('userapp_2', $FORM{'username'});
  169. }
  170. if ($FORM{'action'} eq "userapp_disp") {
  171.     &check_passwd;
  172.     &verify_owner($FORM{'group'},$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to configure this group!");
  173.     &ex('userapp_disp', $FORM{'username'}, $FORM{'user'}, $FORM{'group'});
  174.     exit(0);
  175. }
  176. if ($FORM{'action'} eq "userapp_action") {
  177.     &check_passwd;
  178.     srand(time);
  179.     if ($FORM{'SELECTION'} =~ /((approve)|(refuse))(.*)/) {
  180.         $todo = $4; $action = $1;
  181.         if ($todo ne "all") {
  182.             if ($todo ne "") {
  183.                 &ex('userapp_action', $FORM{'username'}, $todo, $action);
  184.             }
  185.         } else {
  186.             @mark = split(/,/, $FORM{'MARK'});
  187.             foreach $num (@mark) {
  188.                 &ex('userapp_action', $FORM{'username'}, $num, $action);
  189.             }
  190.         }
  191.     }
  192.     &ex('userapp_framesetter', $FORM{'username'}, 2, 1) if !$FORM{'form'};
  193.     &ex('userapp_result', 1) if scalar(@MESSAGE_OUT);
  194.     &ex('userapp_2', $FORM{'username'}, 1);
  195.     exit(0);
  196. }
  197. &error_message("Invalid Query", "The form action -$FORM{'action'}- is not valid for this script", 0, 1);
  198.