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-profile.cgi < prev    next >
Text File  |  1999-02-12  |  12KB  |  315 lines

  1. #!/usr/bin/perl
  2. $discus_conf = '/usr/local/www/www.hirez.org/discus_admin_149349189/discus.conf';
  3. #Discus user profile editor script (board-profile.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. &parse_form;
  37. &read_cookie;
  38. #-------------------------------------------------------------------------------
  39. $FORM{'username'} =~ tr/A-Z/a-z/;
  40. $FORM{'password'} =~ tr/A-Z/a-z/;
  41. if ($FORM{'action'} eq "clear_cookie") {
  42.     print "Set-Cookie: user$COOKIE_ID=nobody; expires=Sunday, 06-Sep-1998 00:00:00 GMT; path=/\n";
  43.     print "Set-Cookie: cpwd$COOKIE_ID=nobody; expires=Sunday, 06-Sep-1998 00:00:00 GMT; path=/\n";
  44.     print "Set-Cookie: rpwd$COOKIE_ID=nobody; expires=Sunday, 06-Sep-1998 00:00:00 GMT; path=/\n";
  45.     print "Set-Cookie: pass$COOKIE_ID=nobody; expires=Sunday, 06-Sep-1998 00:00:00 GMT; path=/\n";
  46.     $COOKIE{'user' . $COOKIE_ID} = "";
  47.     $COOKIE{'cpwd' . $COOKIE_ID} = "";
  48.     $COOKIE{'rpwd' . $COOKIE_ID} = "";
  49.     $FORM{'action'} = "";
  50.     $script_url =~ m|^http://([^/]+)|; $aft = $';
  51.     foreach $key (keys(%COOKIE)) {
  52.         if ($key =~ m|^auth(\d+)|) {
  53.             print "Set-Cookie: $key=none; expires=Sunday, 06-Sep-1998 00:00:00 GMT; path=$aft\n";
  54.             $COOKIE{$key} = "";
  55.         }
  56.     }
  57. }
  58. if ($FORM{'action'} eq "") {
  59.     &header;
  60.     ($bg, $tx, $li, $vl, $al, $face, $size, $image) = &ex('extract_colorsonly', 1);
  61.     &ex('printuntil', 1, 1, 0, $L{PROFEDIT_TITLE});
  62.     print "<CENTER><FONT SIZE=+1><B>$L{PROFEDIT_TITLE}</B></FONT></CENTER><HR>\n";
  63.     print $L{PROFILE_LOGIN};
  64.     $ucid = "user$COOKIE_ID";
  65.     print "<FORM ACTION=\"$script_url/board-profile.$cgi_extension\" METHOD=POST>\n";
  66.     print "<TABLE><TR><TD><FONT FACE=\"$face\" SIZE=$size><B>$L{PROFILE_USERNAME}</B></FONT></TD>\n";
  67.     print "<TD><INPUT TYPE=TEXT NAME=username VALUE=\"";
  68.     print $COOKIE{$ucid} if $COOKIE{$ucid} ne "";
  69.     print "\" SIZE=15></TD></TR>\n";
  70.     print "<TR><TD><FONT FACE=\"$face\" SIZE=$size><B>$L{PROFILE_PASSWORD}</B></FONT></TD>\n";
  71.     print "<TD><INPUT TYPE=PASSWORD NAME=password VALUE=\"\" SIZE=15></TD></TR>\n";
  72.     print "</TABLE><P><INPUT TYPE=SUBMIT VALUE=\"$L{PROFILE_LOGIN_BUTTON}\">\n";
  73.     print "<INPUT TYPE=HIDDEN NAME=action VALUE=profile_editor_screen>\n";
  74.     print "</FORM>\n";
  75.     if ($COOKIE{$ucid} ne "") {
  76.         $ts = $L{LOGIN_YOUARELOGGEDIN};
  77.         $cu = $COOKIE{$ucid};
  78.         $ts =~ s/\%user/$cu/g;
  79.         print "<FORM ACTION=\"$script_url/board-profile.$cgi_extension\" METHOD=POST>\n";
  80.         print "<HR><INPUT TYPE=HIDDEN NAME=action VALUE=clear_cookie>\n";
  81.         print $ts;
  82.         print "<P>\n";
  83.         print "<INPUT TYPE=SUBMIT VALUE=\"$L{LOGIN_CLEARBUTTON}\">\n";
  84.         print "</FORM>\n";
  85.     }
  86.     if ($GLOBAL_OPTIONS{'allow_selfreg'}) {
  87.         print "<FORM ACTION=\"$script_url/board-profile.$cgi_extension\" METHOD=POST>\n";
  88.         print "<HR>$L{REG_FRONTSCREEN}<P>\n";
  89.         print "<INPUT TYPE=SUBMIT VALUE=\"$L{REG_FRONTSCREEN_BUTTON}\">\n";
  90.         print "<INPUT TYPE=HIDDEN NAME=action VALUE=register>\n";
  91.         print "</FORM>\n";        
  92.     }
  93.     &ex('printuntil', 3, 17, 0, "", 0, 1);
  94.     exit(0);
  95. }
  96. if ($FORM{'action'} eq "display_profile") {
  97.     $profile = $FORM{'profile'};
  98.     if ($pro) {
  99.         &ex('display_profile', $profile);
  100.     } else {
  101.         &error_message("$L{FEATURE_NOT_SUPPORTED}", "$L{FEATURE_NOT_SUPPORTED_DESCR}");
  102.     }
  103.     exit(0);
  104. }
  105. if ($FORM{'action'} eq "register") {
  106.     &ex('register_1', 1);
  107. }
  108. if ($FORM{'action'} eq "register_2") {
  109.     &ex('register_2', 1);
  110. }
  111. if ($FORM{'action'} eq "display_picture") {
  112.     $profile = $FORM{'picture'};
  113.     &ex('display_picture', $profile);
  114.     exit(0);
  115. }
  116. if ($FORM{'action'} eq "sync") {
  117.     ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'}, 1);
  118.     @result = split(/\n/, $result);
  119.     @result_save = @result;
  120.     foreach $line (@result) {
  121.         $line =~ s/\s+$//;
  122.         ($file, $user, $pass, $email, $full, $edit) = split(/:/, $line);
  123.         $line = "" if $edit == 0;
  124.     }
  125.     @result = grep(/\S/, @result);
  126.     $s = join("\n", @result);
  127.     foreach $line (@result) {
  128.         ($file, $user, $pass, $email, $full, $edit, $notify, $last, $group) = split(/:/, $line);
  129.         if ($edit == 2 || $edit == 4) {
  130.             $EMAIL_FORCE = $email;
  131.         }
  132.     }
  133.     foreach $line (@result) {
  134.         ($file, $user, $pass, $email, $full, $edit, $notify, $last, $group) = split(/:/, $line);
  135.         if ($file eq $FORM{'file'}) {
  136.             if ($group eq $FORM{'group'}) {
  137.                 $email = $EMAIL_FORCE if $EMAIL_FORCE;
  138.                 $notify = "*" if $notify eq "";
  139.                 &ex('save_profile_information', $pass, $email, $full, "", $notify, $last, "", @result_save);
  140.                 &ex('synchronize_PRO', $file, $user, $s) if $pro;
  141.                 last;
  142.             }            
  143.         }
  144.     }
  145.     $FORM{'action'} = "profile_editor_screen";
  146. }
  147. if ($FORM{'action'} eq "profile_editor_screen") {
  148.     ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'}, 1);
  149.     @result = split(/\n/, $result);
  150.     foreach $line (@result) {
  151.         ($file, $user, $pass, $email, $full, $edit) = split(/:/, $line);
  152.         $line = "" if $edit == 0;
  153.         $LINE_FORCE = $line if ($edit == 2 || $edit == 4);
  154.     }
  155.     @result = grep(/\S/, @result);
  156.     if (scalar(@result) == 0) {
  157.         &error_message($L{PROFILE_AUTHERROR}, $L{PROFILE_AUTHERROR_DESCR}, 0, 1);
  158.     }
  159.     $r = $result[0];
  160.     $r = $LINE_FORCE if $LINE_FORCE;
  161.     $r =~ s/\n$//;
  162.     $s = join("\n", @result);
  163.     @result_save = @result;
  164.     ($differences) = &ex('compare_profiles', $s) if !$pro;
  165.     ($differences) = &ex('compare_profiles_PRO', $s) if $pro;
  166.     &ex('display_profile_differences', $FORM{'username'}, $FORM{'password'}, $s) if ($differences && !$pro);
  167.     &ex('display_profile_differences_PRO', $FORM{'username'}, $FORM{'password'}, $s) if ($differences && $pro);
  168.     ($file, $user, $pass, $email, $full, $edit, $notify, $last, $group) = split(/:/, $r);
  169.     $file =~ tr/A-Z/a-z/;
  170.     &ex("profile_editor_screen", $file, $FORM{"username"}, $group, $FORM{"username"}, "$script_url/board-profile.$cgi_extension", "profile_editor") if !$pro;
  171.     &ex("profile_editor_screen_PRO", $file, $FORM{"username"}, $group, $FORM{"username"}, "$script_url/board-profile.$cgi_extension", "profile_editor") if $pro;
  172.     exit(0);
  173. }
  174. if ($FORM{'action'} eq "register_info") {
  175.     $user = $FORM{'username'}; $user =~ s/://g;
  176.     @group = split(/,/, $FORM{'group'});
  177.     undef @result;
  178.     open (USERS, "$admin_dir/users.txt");
  179.     @users = <USERS>;
  180.     close (USERS);
  181.     @u = grep(/^$user:/, @users);
  182.     foreach $line (@u) {
  183.         chop $line if $line =~ m|\n|;
  184.         ($u, $p, $e, $f, $d, $n, $l, $g) = split(/:/, $line);
  185.         if (grep(/^$g$/, @group) || $p eq "*Q*") {
  186.             push (@result, "USERS:$line\n");
  187.         }
  188.     }
  189.     @result_save = @result;
  190.     &ex('info_save_pro', 1);
  191.     &ex('register_thanks', 1);
  192. }
  193. if ($FORM{'action'} eq "profile_editor") {
  194.     ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'}, 1);
  195.     @result = split(/\n/, $result);
  196.     foreach $line (@result) {
  197.         ($file, $user, $pass, $email, $full, $edit) = split(/:/, $line);
  198.         $EMAIL_FORCE = $email if ($edit == 2 || $edit == 4);
  199.         $line = "" if $edit == 0;
  200.     }
  201.     @result = grep(/\S/, @result);
  202.     @result_save = @result;
  203.     if (scalar(@result) == 0) {
  204.         &error_message($L{PROFILE_AUTHERROR}, $L{PROFILE_AUTHERROR_DESCR}, 0, 1);
  205.     }
  206.     if ($FORM{'action2'} eq "infosave") {
  207.         $email = $FORM{'profile_email'}; $email = substr($email, 0, 40) if length($email) > 40;
  208.         $full = $FORM{'profile_fullname'}; $full = substr($full, 0, 40) if length($full) > 40;
  209.         if ($email =~ m|^([\w\-\+\.]+)\@([\w\-\+\.]+)$|) {
  210.             $email_new = $email;
  211.         } else {
  212.             $email_new = "email";
  213.         }
  214.         if ($full eq "") {
  215.             $full = "fullname";
  216.         } else {
  217.             $full =~ s/\n//g;
  218.             $full =~ s/[:<>]//g;    
  219.         }
  220.         $email_new = $EMAIL_FORCE if $EMAIL_FORCE;
  221.         &ex('save_profile_information', "", $email_new, $full, "", "", "", "", @result);
  222.     }
  223.     if ($FORM{'action2'} eq "notifysave") {
  224.         if (!$pro) {
  225.             undef @em;
  226.             foreach $key (keys(%FORM)) {
  227.                 if ($key =~ m|^notify_(\d+)|) {
  228.                     push (@em, $1);
  229.                 }
  230.             }
  231.             $emr = join(",", @em); $emr = "*" if $emr eq "";
  232.             &ex('save_profile_information', "", "", "", "", $emr, "", "", @result);
  233.         } else {
  234.             &ex('notify_save_pro', 1) if $FORM{'submit'} ne $L{PRED_FIRSTLEVEL};
  235.             &ex('select_by_subtopics', $file, $FORM{"username"}, $group, $FORM{"username"}, "$script_url/board-profile.$cgi_extension", "profile_editor") if $FORM{'submit'} eq $L{PRED_FIRSTLEVEL};
  236.         }
  237.     }
  238.     if ($FORM{'action2'} eq "preferences") {
  239.         &ex('prefs_save_pro', 1);
  240.     }    
  241.     if ($FORM{'action2'} eq "infosection") {
  242.         &ex('info_save_pro', 1);
  243.     }
  244.     if ($FORM{'action2'} eq "changepass") {
  245.         $p1 = $FORM{'pass_1'}; $p2 = $FORM{'pass_2'};
  246.         $p1 =~ tr/A-Z/a-z/; $p2 =~ tr/A-Z/a-z/;
  247.         while ($p1 =~ m|(\W)|g) {
  248.             $o = ord($1); $m = $1;    
  249.             &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_ALPHA}) if $o < 126;
  250.         }
  251.         &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_MATCH}) if $p1 ne $p2;
  252.         &error_message($L{PROFILE_CHPASS_ERROR}, $L{PROFILE_CHPASS_ERROR_LENGTH}) if (length($p1) < 1 || length($p2) > 20);
  253.         srand(time);
  254.         undef (@salt);
  255.         for ($i=1; $i<=4; $i++) {
  256.             push (@salt, int(rand(26))+65);
  257.         }
  258.         $salt = pack('c4', @salt);
  259.         $new_password = crypt($p1, $salt);
  260.         &ex('save_profile_information', $new_password, "", "", "", "", "", "", @result);
  261.         if ($FORM{'password'} eq "adminlogin" && $COOKIE{'pass' . $COOKIE_ID} ne "") {
  262.             print "Set-Cookie: pass", $COOKIE_ID, "=", crypt($new_password, "cookie"), "; path=/\n"; 
  263.             &seturl("$script_url/board-profile.$cgi_extension?action=profile_editor_screen&password=adminlogin&username=$FORM{'username'}");
  264.             exit(0);
  265.         }
  266.         &header;
  267.         &ex('printuntil', 1, 1, 0, $L{PROFILE_CHANGEDPASSWORD});
  268.         print "<CENTER><FONT SIZE=4><B>$L{PROFILE_CHANGEDPASSWORD}</B></FONT></CENTER><HR>\n";
  269.         $l = $L{PROFILE_CHANGEDPASSWORD_DESCR};
  270.         print $l if $FORM{'password'} ne "adminlogin";
  271.         $l = $L{BPCLICKCONTINUE};
  272.         print "<P><CENTER><A HREF=\"$script_url/board-profile.$cgi_extension\">$l</A></CENTER>\n";
  273.         &ex('printuntil', 3, 17, 0, "", 0, 1);
  274.         exit(0);
  275.     }
  276.     if ($FORM{'action2'} eq "editpost") {
  277.         ($key) = grep(/^(\d+)$/, keys(%FORM));
  278.         &ex('edit_post_form', 0, 0, $key, "", "", $FORM{'username'});
  279.         exit(0);
  280.     }    
  281.     ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'}, 1);
  282.     @result = split(/\n/, $result);
  283.     foreach $line (@result) {
  284.         ($file, $user, $pass, $email, $full, $edit, $email, $time, $group) = split(/:/, $line);
  285.         $line = "" if $edit == 0;
  286.     }
  287.     foreach $line (@result) {
  288.         ($file, $user, $pass, $email, $full, $edit, $email, $time, $group) = split(/:/, $line);
  289.         if ($edit == 2) {
  290.             last;
  291.         }
  292.     }
  293.     @result = grep(/\S/, @result);
  294.     @result_save = @result;
  295.     &ex("profile_editor_screen", $file, $FORM{"username"}, $group, $FORM{"username"}, "$script_url/board-profile.$cgi_extension", "profile_editor") if !$pro;
  296.     &ex("profile_editor_screen_PRO", $file, $FORM{"username"}, $group, $FORM{"username"}, "$script_url/board-profile.$cgi_extension", "profile_editor") if $pro;
  297. }
  298. if ($FORM{'action'} eq "edit_message") {
  299.     ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'}, 1);
  300.     @result = split(/\n/, $result);
  301.     foreach $line (@result) {
  302.         ($file, $user, $pass, $email, $full, $edit) = split(/:/, $line);
  303.         $line = "" if $edit == 0;
  304.     }
  305.     @result = grep(/\S/, @result);
  306.     @result_save = @result;
  307.     if (scalar(@result) == 0) {
  308.         &error_message($L{PROFILE_AUTHERROR}, $L{PROFILE_AUTHERROR_DESCR}, 0, 1);
  309.     }
  310.     &ex('edit_message_action', 1);
  311.     $file =~ tr/A-Z/a-z/;
  312.     &ex("profile_editor_screen_PRO", $file, $FORM{"username"}, $group, $FORM{"username"}, "$script_url/board-profile.$cgi_extension", "profile_editor");
  313. }
  314. &error_message("Unrecognized action");
  315.