# FILE: src-board-subs-7 # Copyright (c) 1998, Kevin W. Paulisse and William F. Polik, all rights reserved # Licensed under the Discus license agreement # http://www.chem.hope.edu/discus #---SEPARATOR---# sub profile_editor { local ($username, $passwdfile, $formurl, $editoption, $action1, $action2, $username2, $group, $pgtitle, $navbar) = @_; open (PASSWD, "$admin_dir/$passwdfile") || &error_message ("$pgtitle Error", "Could not open password file ($passwdfile) for reading! (Code 070101)"); @passwd = ; close (PASSWD); $username_disp = $username; $username_disp = $username2 if $username2; @passwd = grep(/:$group\s*$/, @passwd) if $group; if ($username2 ne "") { ($line) = grep(/^$username2:/, @passwd); } else { ($line) = grep(/^$username:/, @passwd); } chop ($line) if $line =~ /\n$/; ($user, $pass, $email, $fullname, $profile, $wantemail, $lastcheck) = split(/:/, $line); &error_message("$pgtitle Error", "You do not have permission to edit your profile! (Code 070102)") if ($profile == 0 && $username ne $superuser && $editoption != 1); &header; print "$pgtitle\n"; print "$fs\n"; print "
$pgtitle
\n"; print "
\n"; if ($navbar == 1) { print "User Manager: Edit \u$group: Edit \u$username_disp\n" if $passwdfile eq "users.txt"; print "
\n"; } elsif ($navbar == 2) { print "Moderator Manager: Edit \u$username_disp\n"; print "
\n"; } print "

Profile Editor

\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($editoption == 1) { print "\n"; } print "
$fs", "Username:$fs\u$username_disp
$fs", "E-mail Address:
$fs", "Full Name:
$fs", "E-mail Notification:$fsMy own posts
\n"; print "Others' posts within my groups
$fs", "Can edit profile:$fsNo "; print "Yes
\n"; print "
\n"; print "\n"; print "
\n"; print "\n"; print "\n" if $username2; print "\n" if $group; print "\n"; print "
\n"; if ($navbar != 2 || $username_disp ne $superuser) { print "

Change Password

\n"; print "
\n"; print "
"; print "\n"; print "
$fs", "Enter New Password:
$fs", "Retype New Password:
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n" if $username2; print "\n" if $group; print "
\n"; } print "\n"; } #---SEPARATOR---# sub user_mgr_1 { local ($username) = @_; local ($append,$owntopic); &header; print "User Manager\n"; print "\n"; print "\n"; print "\n"; print "$fs
User Manager
\n"; $append = "?username=$username"; print "
\n"; print "Select one of the following groups of users to edit:\n"; print "

\n"; local (%seen); open (GROUP, "$admin_dir/groups.txt"); local (@group) = ; close (GROUP); open (USER, "$admin_dir/users.txt"); local (@user) = ; close (USER); local ($line, $foo, @moderator, $moderators, $group_name, @groups); foreach $line (@group) { chop ($line) if $line =~ /\n/; ($group_name, $moderators) = split(/:/, $line); @moderator=split(/,/, $moderators); push (@groups, $group_name) if grep(/^$username$/, @moderator); } local (@key) = sort(@groups); print "\n"; $bgcolor = "ffffcc"; if (@key) { foreach $line (@key) { @validuser = grep(/:$line\n?$/, @user); $user_count = scalar(@validuser); $user_count -= scalar(grep(/^[A-Z]/, @validuser)); $user_count = "0" if $user_count == 0; print "\n"; $pp = "Private"; $pp = "Public" if grep(/^PUBLIC:\*:/, @validuser); print "\n"; if ($bgcolor eq "ffffff") { $bgcolor = "ffffcc"; } else { $bgcolor = "ffffff"; } } print "\n"; } else { print "
 GroupUsers  Posting 
 $fs"; print "\u$line$fs$user_count  $fs$pp 
 
 You are not authorized to edit any groups! 
\n"; } print "\n"; } #---SEPARATOR---# sub user_mgr_2 { local ($username, $group) = @_; open (PASSWD, "$admin_dir/users.txt") || &error_message("File Error", "Cannot open user password file (users.txt)! (Code 070201)"); @passwd = ; close (PASSWD); &header; print "User Manager: \u$group\n"; print "\n"; print "\n"; print "\n"; print "$fs

\u$group
\n"; print "
\n"; print "User Manager: Edit \u$group\n"; print "
\n"; print "

Users

\n"; print "
\n"; undef @valid_user_list; foreach $line (sort(@passwd)) { ($user, $encpass, $email, $fullname, $profile, $email, $check, $group_test) = split(/:/, $line); chop ($group_test) if $group_test =~ /\n$/; push (@valid_user_list, $line) if $group_test eq $group && $user =~ /[^A-Z]/; } $count = @valid_user_list; if ($count > 25) { print "

\n"; $st = $FORM{'start'}; if ($st ne "showall") { if (($st + 25) >= $count) { @valid_user_list = splice(@valid_user_list, $st); } else { @valid_user_list = splice(@valid_user_list, $st, 25); } } } print "\n"; $bgcolor = "ffffcc"; $c = 0; $count = scalar(@valid_user_list); print "\n"; foreach $line (@valid_user_list) { ($user, $encpass, $email, $fullname, $profile, $email, $check, $group_test) = split(/:/, $line); print ""; if ($bgcolor eq "ffffcc") { $bgcolor = "ffffff"; } else { $bgcolor = "ffffcc"; } $num = $user; print ""; print ""; print "\n"; print ""; print "\n"; print ""; print "\n"; print "\n"; } if ($count > 0) { print ""; print "\n"; print ""; print ""; print "\n"; print ""; print "\n"; print ""; print "\n"; print "\n"; } if ($count == 0) { print "\n"; } else { print "\n"; } print "
 MarkDel Edit User 
 "; $ct = $count; $ct = 25 if $count > 25; $ct = $count if $FORM{'start'} eq "showall"; print " "; print " "; $c++; print "    $fs\u$user "; if ($fullname ne "" && $fullname ne "none" && $fullname ne "fullname") { print "($fullname)"; } print " 
 (Marked)     
 There are no users in this group!
 
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "


\n"; print "

Special Permissions

\n"; print "
\n"; print "
$fs"; print "\n"; print "\n"; print "\n"; open (PASSWD, "$admin_dir/users.txt") || &error_message("File Error", "Cannot open user password file (users.txt)! (Code 070202)"); @passwd = ; close (PASSWD); @users = grep(/:$group\n?$/, @passwd); print " Disabled: Posting disabled (only moderators in this group may post)
\n"; print " Moderators (other groups): Any valid moderator regardless of group
\n"; print " Public: Any username/password at all
\n"; print " Users (other groups): Any valid user regardless of group
\n"; print "

\n"; print "\n"; print "


\n"; print "
\n"; print "

Profile Permissions

\n"; print "
\n"; print "
$fs"; print "\n"; print "\n"; print "\n"; open (PASSWD, "$admin_dir/users.txt") || &error_message("File Error", "Cannot open user password file (users.txt)! (Code 070203)"); @passwd = ; close (PASSWD); @users = grep(/:$group\n?$/, @passwd); print " Anonymous: Users may post as "Anonymous"
\n"; print " E-mail Notification: Honor users' e-mail notification requests
\n"; print " Full Name & E-mail: Display full name and e-mail on posts
\n"; print "

\n"; print "\n"; print "


\n"; print "

Add a User

\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
"; print "
$fs", "Username:"; print ""; print "
$fs", "Password:"; print ""; print "
$fs", "Verify Password:"; print ""; print "
 
\n"; print ""; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "

Add a User List

\n"; print "
\n"; print "
"; print "
$fs"; print "You can paste a delimited user list into this column. The program will\n"; print "parse the incoming list to create user accounts automatically.

\n"; print "\n"; print "\n"; print "\n"; print "

\n"; print "\n"; print "

\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; } #---SEPARATOR---# sub add_user { local ($username, $newuser, $pass1, $pass2, $group) = @_; $newuser =~ tr/A-Z/a-z/; $pass1 =~ tr/A-Z/a-z/; $pass2 =~ tr/A-Z/a-z/; &error_message("Add User Error", "Username is invalid (username may contain only alphanumeric characters).") if $newuser =~ /\W/; &error_message("Add User Error", "The entered passwords do not match!") if $pass1 ne $pass2; $usercount = length($newuser); &error_message("Add User Error", "The username is invalid (username must be between 3 and 15 characters).") if ($usercount < 3 || $usercount > 15); &error_message("Add User Error", "The entered passwords are invalid (password may contain only alphanumeric characters.") if $pass1 =~ /\W/; $passcount = length($pass1); &error_message("Add User Error", "The entered passwords are invalid (password must be between 3 and 15 alphanumeric characters).") if ($passcount < 3 || $passcount > 15); &lock("$admin_dir/users.txt"); open(PASSWD,"$admin_dir/users.txt") || &error_message("Add User Error", "Cannot read password file (users.txt)! (Code 070401)"); @passwdline = ; close(PASSWD); foreach $line (@passwdline) { chop ($line) if $line =~ /\n$/; ($user, $encpass, $foo, $foo, $foo, $foo, $foo,$group_test) = split(/:/, $line); &error_message("Add User Error", "The selected username already exists as a user in this group!") if $user eq $newuser && $group_test eq $group; } srand(time); undef (@salt); for ($i=1; $i<=4; $i++) { push (@salt, int(rand(26))+65); } $salt = pack('c4', @salt); open(PASSWD,">>$admin_dir/users.txt") || &error_message("Add User Error", "Cannot append password file (users.txt)! (Code 070402)"); $new_password = crypt($pass1, $salt); print PASSWD "$newuser:$new_password:email:fullname:1:0:0:$group\n"; close(PASSWD); &unlock("$admin_dir/users.txt"); } #---SEPARATOR---# sub version_manager { &header; print "Version Manager\n"; print "\n"; print "$fs
Version Manager

\n"; print "

Information

\n"; open (LOG, "$admin_dir/log.txt"); if (eval 'flock (LOG, 2);') { $implemented_flock = 1; } else { $implemented_flock = 0; } @log = ; eval 'flock (LOG, 8);'; close (LOG); print "
$fs\n"; print ""$title" is running Discus $version_number.
\n"; print "There are currently ", scalar(@log), " messages on your board.

\n"; print "The current version of Discus is: \n"; print "

\n"; print "


\n"; print "

Download the Latest Version

\n"; print "
$fs\n"; print "Click here to download the source distribution (for unix telnet or Windows console installation).

\n"; print "

\n"; open (A, "$script_dir/board-admin.$cgi_extension"); @a = ; close (A); $p = $a[0]; $p =~ s/^#!//; $p =~ s/\s+$//; print "\n"; print "; close (D); $d = join("", @d); print &escape($d); print "\">\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Click here to prepare a Discus distribution to install by FTP.

\n"; print "

\n"; print "


\n"; print "

Discus Mailing List

\n"; print "
$fs\n"; print "To keep up to date with Discus releases, join the Discus mailing list! You will receive announcements of major upgrades\n"; print "to Discus only (about 1 message every 3 months). Your e-mail address will not be distributed or sold.\n"; print "
\n"; print "(.*)|) { print "$1"; } print "\">\n"; print "\n"; print "\n"; print "\n"; print "

\n"; print "

\n"; print "\n"; } #---SEPARATOR---# sub preview_user_list { local ($username, $group, $listin, $delim, $errflag) = @_; &header; print "Preview User List\n"; print ""; print "$fs
Preview User List
\n"; print "
\n"; print "
User Manager: Edit \u$group: Preview User List\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($errflag ne "") { print "
$fs"; print "

Error

The following error(s) occurred when adding users: "; print "

    $errflag

The users still displayed on the preview have not "; print "yet been added. Please correct the indicated problems and resubmit the form.\n"; print "

\n"; } else { print "

Creation Preview

\n"; } print "
"; $delim = "\t" if $delim eq "tab"; $delim = "," if $delim eq "comma"; $delim = ";" if $delim eq "semi"; @users = split(/\n/, $listin); if ($delim eq "") { $d1 = scalar(grep(/\t/, @users)); $d2 = scalar(grep(/,/, @users)); $d3 = scalar(grep(/;/, @users)); if ($d1 >= $d2 && $d1 >= $d3) { $delim = "\t"; } elsif ($d2 >= $d1 && $d2 >= $d3) { $delim = ","; } elsif ($d3 >= $d1 && $d3 >= $d2) { $delim = ";"; } else { $delim = "\t"; } } $delim2 = "tab" if $delim eq "\t"; $delim2 = "comma" if $delim eq ","; $delim2 = "semi" if $delim eq ";"; print "\n"; undef %emv; undef %fnv; undef %unv; undef %pwv; $mf = 0; foreach $user (@users) { $c = 0; @u = split(/$delim/, $user); $f = 0; $thisone = ""; for ($i = 1; $i <= 2; $i++) { foreach $u (@u) { $u =~ s/^\s+//; $u =~ s/\s+$//; $c += 1; $fv = $c - $f; $key = "COL" . $fv; if ($u eq "*FULLNAME*" || $FORM{$key} eq "FULLNAME") { $fnv{($c-$f)} += 10000; $user = "" if $u =~ /^\*/; } elsif ($u eq "*EMAIL*" || $FORM{$key} eq "EMAIL") { $emv{($c-$f)} += 10000; $user = "" if $u =~ /^\*/; } elsif ($u eq "*USERNAME*" || $FORM{$key} eq "USERNAME") { $unv{($c-$f)} += 10000; $user = "" if $u =~ /^\*/; } elsif ($u eq "*PASSWORD*" || $FORM{$key} eq "PASSWORD") { $pwv{($c-$f)} += 10000; $user = "" if $u =~ /^\*/; } elsif ($FORM{$key} eq "SKIP") { } elsif ($u =~ m|^([\w\s\.\-\+]+)\@([\w\s\.\-\+]+)$|) { $emv{($c-$f)} += 1; } elsif ($u =~ m/\s/) { $fnv{($c-$f)} += 1; $thisone = $u; } elsif ($thisone =~ m|$u|i) { $unv{($c-$f)} += 1; } elsif ($u =~ m|^(\w+)$|) { $pwv{($c-$f)} += 1; } } $f = $c; } $user = join("$delim", @u) if $user ne ""; $c = $c / 2; $mf = $c if $c > $mf; } @users = grep(/\S/, @users); $mx = 0; $id = 0; foreach $key (keys(%emv)) { if ($emv{$key} > $mx) { $id = $key; $mx = $emv{$key}; } } $emv = $id; $mx = 0; $id = 0; foreach $key (keys(%fnv)) { if ($fnv{$key} > $mx) { $id = $key; $mx = $fnv{$key}; } } $fnv = $id; $mx = 0; $id = 0; foreach $key (keys(%unv)) { if ($unv{$key} > $mx) { $id = $key; $mx = $unv{$key}; } } $unv = $id; $mx = 0; $id = 0; foreach $key (keys(%pwv)) { if ($pwv{$key} > $mx) { $id = $key; $mx = $fnv{$key}; } } $pwv = $id; print "$fs"; print "The following user accounts will be generated if you choose to accept this list:

\n"; print "

\n"; print "\n"; for ($i = 1; $i <= $mf; $i++) { print "\n"; } print "\n"; $ctr1 = 0; $ctr2 = 0; foreach $user (@users) { print ""; $ctr1 += 1; $ctr2 = 0; @u = split(/$delim/, $user); foreach $u (@u) { $ctr2 += 1; print ""; } print "\n"; } print "\n"; print "
\n"; print "

\n"; print "\n"; print "

\n"; print "


Advanced Options

\n"; print "
$fs"; print "The following advanced options allow you to manipulate the list above and then refresh the preview.

\n"; print " Generate Usernames:

    "; print " From full names
    \n"; print " From e-mail addresses

\n"; print " Generate Passwords:

    "; print " Equal to last name
    \n"; print " Equal to username
    \n"; print " Give everyone the same password: $fs

\n"; print " Manipulate E-mail Addresses:

    "; print "Append this text to each e-mail address: $fs

\n"; print "

\n"; print "

\n"; print "\n

\n"; exit(0); } #---SEPARATOR---# sub modify_list { $listin = &unescape($FORM{"listin"}); undef @sk; $delim = "\t" if $FORM{"delimiter"} eq "tab"; $delim = "," if $FORM{"delimiter"} eq "comma"; $delim = ";" if $FORM{"delimiter"} eq "semi"; if ($listin eq "") { $ctr1 = 0; $ctr2 = 0; $flag1 = 0; $flag2 = 0; while ($flag1 == 0) { $ctr1 += 1; $ctr2 = 0; $flag2 = 0; while ($flag2 == 0) { $ctr2 += 1; $pos = "x$ctr1" . "y$ctr2"; if ($FORM{$pos} ne "") { $listin .= $FORM{$pos} . $delim; } else { $flag2 = 1; } } $pos = "x" . ($ctr1+1) . "y1"; if ($FORM{$pos} eq "\\") { $flag1 = 1; } else { chop ($listin); $listin .= "\n"; } } } @users = split(/\n/, $listin); $ctr = 0; $fields = 0; foreach $user (@users) { $c = 0; $ctr += 1; @u = split(/$delim/, $user); foreach $p (@u) { $c += 1; $key = "COL$c"; $p =~ s/^\s+//; $p =~ s/\s$//; $username[$ctr] = $p if $FORM{$key} eq "USERNAME"; $password[$ctr] = $p if $FORM{$key} eq "PASSWORD"; $email[$ctr] = $p if $FORM{$key} eq "EMAIL"; $fullname[$ctr] = $p if $FORM{$key} eq "FULLNAME"; } $user = join("$delim", @u); $fields = $c if $c > $fields; } for ($i = 1; $i <= $fields; $i++) { $key = "COL$i"; $sk[$i] = 1 if $FORM{$key} eq "SKIP"; } if ($FORM{"genuser"}) { if ($FORM{"genuname"} eq "email") { &error_message("Modify Listing", "Unable to generate usernames from e-mail addresses -- you do not have an e-mail address column!") if $email[1] eq ""; &error_message("Modify Listing", "Unable to generate usernames from e-mail addresses -- you already have a username column!") if $username[1] ne ""; for ($i = 1; $i <= $ctr; $i++) { $em = $email[$i]; $em =~ m|^([\w\+\-\.]+)\@?|; $o = $1; $o =~ s/\W//g; $users[$i-1] .= "$delim$o"; $username[$i] = $o; } $fields += 1; $FORM{"COL$fields"} = "USERNAME"; } elsif ($FORM{"genuname"} eq "fullname") { &error_message("Modify Listing", "Unable to generate usernames from full names -- you do not have a full name address column!") if $fullname[1] eq ""; &error_message("Modify Listing", "Unable to generate usernames from full names -- you already have a username column!") if $username[1] ne ""; for ($i = 1; $i <= $ctr; $i++) { $o = &extract_lastname($fullname[$i]); $o =~ tr/A-Z/a-z/; $users[$i-1] .= "$delim$o"; $username[$i] = $o; } $fields += 1; $FORM{"COL$fields"} = "USERNAME"; } else { &error_message("Modify Listing", "Unable to generate usernames -- you did not select an option under that heading!"); } } if ($FORM{"genpass"}) { if ($FORM{"genpasswd"} eq "ln") { &error_message("Modify Listing", "Unable to generate passwords from last names -- you do not have a full name column!") if $fullname[1] eq ""; &error_message("Modify Listing", "Unable to generate passwords from last names -- you already have a password column!") if $password[1] ne ""; for ($i = 1; $i <= $ctr; $i++) { $o = &extract_lastname($fullname[$i]); $o =~ tr/A-Z/a-z/; $users[$i-1] .= "$delim$o"; $password[$i] = $o; } $fields += 1; $FORM{"COL$fields"} = "PASSWORD"; } elsif ($FORM{"genpasswd"} eq "user") { &error_message("Modify Listing", "Unable to generate passwords from usernames -- you do not have a username column!") if $fullname[1] eq ""; &error_message("Modify Listing", "Unable to generate passwords from usernames -- you already have a password column!") if $password[1] ne ""; for ($i = 1; $i <= $ctr; $i++) { $users[$i-1] .= "$delim$username[$i]"; $password[$i] = $username[$i]; } $fields += 1; $FORM{"COL$fields"} = "PASSWORD"; } elsif ($FORM{"genpasswd"} eq "same") { &error_message("Modify Listing", "Unable to generate passwords -- you already have a password column!") if $password[1] ne ""; for ($i = 1; $i <= $ctr; $i++) { $users[$i-1] .= "$delim$FORM{'samepasswd'}"; $password[$i] = $FORM{'samepasswd'} } $fields += 1; $FORM{"COL$fields"} = "PASSWORD"; } else { &error_message("Modify Listing", "Unable to generate passwords -- you did not select an option under that heading!"); } } if ($FORM{'manipemail'}) { &error_message("Modify Listing", "Unable to manipulate e-mail addresses -- you do not have an e-mail address column!") if $email[1] eq ""; foreach $user (@users) { $c = 0; $ctr += 1; @u = split(/$delim/, $user); foreach $p (@u) { $c += 1; $key = "COL$c"; $p .= $FORM{'emailadd'} if $FORM{$key} eq "EMAIL"; } $user = join("$delim", @u); } } $listin = join("\n", @users); return $listin; } sub extract_lastname { local ($name) = @_; local ($lastname); $name =~ s/^[\w\s\.\,]//g; if ($name =~ /^(\w+)\s+(\w+)$/) { $lastname = $2; } elsif ($name =~ /^(\w+),\s*(\w+)/) { $lastname = $1; } elsif ($name =~ /^(\w+)\s+(\w+)\s+(\w+)$/) { $lastname = $3; } elsif ($name =~ /^(\w+)\s+(\w+)\s*,\s*(\w+)/) { $lastname = $2; } elsif ($name =~ /^(\w+)\s+(\w+)\.?\s+(\w+)$/) { $lastname = $3; } elsif ($name =~ /^(\w+)\s+(\w+)\.?\s+(\w+)\s*,/) { $lastname = $3; } elsif ($name =~ /^(\w+)\.\s+(\w+)\s+(\w+)\s*,?/) { $lastname = $3; } else { $lastname = $name; } return $lastname; } #---SEPARATOR---# sub add_user_list { local ($username, $group) = @_; $delim = "\t" if $FORM{"delimiter"} eq "tab"; $delim = "," if $FORM{"delimiter"} eq "comma"; $delim = ";" if $FORM{"delimiter"} eq "semi"; $ctr1 = 0; $ctr2 = 0; $flag1 = 0; $flag2 = 0; while ($flag1 == 0) { $ctr1 += 1; $ctr2 = 0; $flag2 = 0; while ($flag2 == 0) { $ctr2 += 1; $pos = "x$ctr1" . "y$ctr2"; if ($FORM{$pos} ne "") { $listin .= $FORM{$pos} . $delim; } else { $flag2 = 1; } } $pos = "x" . ($ctr1+1) . "y1"; chop ($listin); if ($FORM{$pos} eq "\\") { $flag1 = 1; } else { $listin .= "\n"; } } open (PASS, "$admin_dir/users.txt"); @pass = ; close (PASS); @pass_grp = grep(/:$group\s*$/, @pass); undef @username_f; foreach $line (@pass_grp) { push (@username_f, (split(/:/, $line))[0]); } @users = split(/\n/, $listin); $ctr = 0; $fields = 0; foreach $user (@users) { @u = split(/$delim/, $user); foreach $p (@u) { $p =~ s/^\s+//; $p =~ s/\s$//; } $user = join("$delim", @u); } for ($ix = 0; $ix < scalar(@users); $ix++) { $c = 0; $user = $users[$ix]; @u = split(/$delim/, $user); foreach $p (@u) { $c += 1; $key = "COL$c"; $username[$ix] = $p if $FORM{$key} eq "USERNAME"; $password[$ix] = $p if $FORM{$key} eq "PASSWORD"; $email[$ix] = $p if $FORM{$key} eq "EMAIL"; $fullname[$ix] = $p if $FORM{$key} eq "FULLNAME"; } $fields = $c if $c > $fields; } &ex("preview_user_list", $FORM{"username"}, $FORM{"group"}, $listin, $FORM{"delimiter"}, "You did not define a username column") if $username[0] eq ""; &ex("preview_user_list", $FORM{"username"}, $FORM{"group"}, $listin, $FORM{"delimiter"}, "You did not define a password column") if $password[0] eq ""; $errflag = ""; undef @erfl; for ($i = 0; $i < scalar(@users); $i++) { $pw = $password[$i]; $un = $username[$i]; $un =~ tr/A-Z/a-z/; if ($un ne "\\") { $un =~ s/\W//g; } $pw =~ tr/A-Z/a-z/; $pw =~ s/\W//g; if ($un eq "\\") { } elsif (length($un) < 3 || length($un) > 15) { $errflag .= "

  • Username "$un" is not between 3 and 15 characters.\n"; push (@erfl, $i); } elsif (grep(/^$un$/, @username_f)) { $errflag .= "
  • Username "$un" is already taken.\n"; push (@erfl, $i); } elsif (length($password[$i]) < 3 || length($password[$i]) > 15) { $errflag .= "
  • Username "$un" has a password "$pw" that is not between 3 and 15 characters.\n"; push (@erfl, $i); } else { $fn = $fullname[$i];$fn =~ s/[:<>;]//g; $em = $email[$i]; $em =~ s/[:<>;]//g; srand(time); undef (@salt); for ($j=1; $j<=4; $j++) { push (@salt, int(rand(26))+65); } $salt = pack('c4', @salt); $pass = crypt($pw, $salt); push (@pass2, "$un:$pass:$em:$fn:1:0:0:$group\n"); push (@username_f, $un); } } &lock("$admin_dir/users.txt"); open (PASS, "$admin_dir/users.txt"); @pass = ; close (PASS); open (USERS, ">$admin_dir/users.txt"); print USERS @pass; print USERS @pass2; close (USERS); &unlock("$admin_dir/users.txt"); if ($errflag ne "") { undef @users2; for ($i = 0; $i < scalar(@users); $i++) { if (grep(/^$i$/, @erfl)) { push (@users2, $users[$i]); } } $listin = join("\n", @users2); &ex("preview_user_list", $FORM{"username"}, $FORM{"group"}, $listin, $FORM{"delimiter"}, $errflag); } } #---SEPARATOR---# sub delete_user { local ($toremove, $group) = @_; local (@passwd, @nogroup, @thegroup, @toremove, $line, $user); @toremove = split(/,/, $toremove); &lock("$admin_dir/users.txt"); open (PASSWD, "$admin_dir/users.txt") || &error_message("File Error", "Cannot open password file (users.txt) for reading! (Code 070901)"); @passwd = ; close (PASSWD); @nogroup = grep(!/:$group\s*$/, @passwd); @thegroup = grep(/:$group\s*$/, @passwd); foreach $line (@thegroup) { $user = (split(/:/, $line))[0]; $line = "" if grep(/^$user$/, @toremove); } @passwd = @nogroup; push (@passwd, grep(/\S/, @thegroup)); open (PASSWD, ">$admin_dir/users.txt") || &error_message("File Error", "Cannot open password file (passwd.txt) for writing! (Code 070902)"); print PASSWD @passwd; close (PASSWD); &unlock("$admin_dir/users.txt"); } #---SEPARATOR---# sub edit_user { local ($username, $user, $group) = @_; open (PASSWD, "$admin_dir/users.txt") || &error_message("File Error", "Cannot open password file (passwd.txt) for reading! (Code 071001)"); @passwd = ; close (PASSWD); &error_message("Invalid User Selection", "The specified user does not exist! (Code 071002)") if !grep(/^$user:/, @passwd); &error_message("Invalid User Selection", "The specified user does not exist! (Code 071003)") if $user eq ""; @lines = grep(/^$user:/, @passwd); ($line) = grep(/:$group\n?$/, @lines); ($user, $encrpass, $email, $fullname, $profile, $notify, $lastcheck, $group_test) = split(/:/, $line); &header; print "Edit User\n"; print "\n"; print "
    User Editor: \u$user
    \n"; print "
    \n"; print "User Manager: Edit \u$group: Edit \u$user\n"; print "
    \n"; print "
    \n"; print "

    Profile Settings

    \n"; print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    SettingSet New Value
    Username\u$user
    E-mail Address
    Full Name
    Can edit profile\n"; print "No "; print "Yes
    E-mail Notification"; print "Own Posts
    "; print "= 2; print ">Within Moderated Groups
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "
    \n"; print "

    Change User Password

    \n"; print "
    \n"; print ""; print "\n"; print "\n"; print "
    New Password
    Verify

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    \n"; print "\n"; } #---SEPARATOR---# #REQ:change_addmessage sub special_user { local ($group, $special, $onoff) = @_; &lock("$admin_dir/users.txt"); open (USER, "$admin_dir/users.txt"); @users = ; close (USER); @valid = grep(/:$group\n?$/, @users); if (grep(/^$special:/, @valid) && $onoff eq "on") { &unlock("$admin_dir/users.txt"); return 0; } if ($onoff ne "on") { &unlock("$admin_dir/users.txt") if !grep(/^$special:/, @valid); return if !grep(/^$special:/, @valid); ($lineremove) = grep(/^$special:/, @valid); chop ($lineremove) if $lineremove =~ /\n$/; undef (@usersnew); foreach $line (@users) { push (@usersnew, $line) if $line !~ /^$special:/ || $line !~ /:$group\n?/; } } else { @usersnew = @users; push (@usersnew, "$special:*::SPECIAL USER - DO NOT EDIT:0:0:0:$group\n"); } open (USER, ">$admin_dir/users.txt"); print USER @usersnew; close (USERS); &unlock("$admin_dir/users.txt"); undef @todo; if ($special eq "PUBLIC") { open (TOPIC, "$message_dir/board-topics.html"); @topic = ; close (TOPIC); foreach $line (@topic) { if ($line =~ //) { &extract("//$1/$1.$ext"); push (@todo, $1) if $owner eq $group; } } foreach $todo (@todo) { &change_addmessage($todo,$todo,"public") if $onoff eq "on"; &change_addmessage($todo,$todo,"private") if $onoff ne "on"; } } } #---SEPARATOR---# sub change_addmessage { local ($topic_number, $starting_page, $template) = @_; local (@file, $line, $flag, @input); &lock("$message_dir/$topic_number/$starting_page"); local ($head, $color, $lm, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic_number, $starting_page); foreach $line (split(/\n/, $sublist)) { if ($line =~ //) { &change_addmessage($topic_number, $1, $template); } } &set_page($topic_number, $starting_page, $head, $color, $lm, $sublist, $about, $about_src, $message, $message_src); &unlock("$message_dir/$topic_number/$starting_page"); }