# FILE: src-board-subs-7 #------------------------------------------------------------------------------- # This script is copyright (c) 1998 by DiscusWare, LLC, all rights reserved. # Its use is subject to the license agreement that can be found at the following # URL: http://www.chem.hope.edu/discus/license #------------------------------------------------------------------------------- #---SEPARATOR---# #REQ:send_email_message sub email_notification { local ($topic, $page, $postby, $message_in, $username, $groupname) = @_; undef @addresses; undef %addresses; open (PASSWD, "$admin_dir/passwd.txt"); @passwd = ; close (PASSWD); open (USERS, "$admin_dir/users.txt"); @users = ; close (USERS); foreach $line (@passwd) { $line =~ s/\s*$//; push (@users, "$line:MODERATOR\n"); } @user = grep(/^$username:/, @users); ($uline) = grep(/:$groupname\s*$/, @user); if ($uline) { $line = $uline; $line =~ s/\s*$//; ($user, $pass, $email, $full, $edit, $notify, $last, $group) = split(/:/, $line); $mod = 0; $mod = 1 if $group eq "MODERATOR"; $addresses{$email} = 1; if ($email =~ m|^([\w\-\.\+]+)\@([\w\-\.\+]+)$|) { @emt = split(/,/, $notify); if (grep(/^0$/, @emt)) { push (@addresses, "$email||$user||$pass||$mod"); $addresses{$email} = 1; } } } foreach $line (@users) { $line =~ s/\s*$//; ($user, $pass, $email, $full, $edit, $notify, $last, $group) = split(/:/, $line); next if $addresses{$email}; next if $email !~ m|^([\w\-\.\+]+)\@([\w\-\.\+]+)$|; @emt = split(/,/, $notify); foreach $l (@emt) { if ($l =~ m|^(\d+)/|) { $l = $1; } } $mod = 0; $mod = 1 if $group eq "MODERATOR"; if (grep(/^$topic_number$/, @emt)) { push (@addresses, "$email||$user||$pass||$mod"); $addresses{$email} = 1; } } if (scalar(@addresses)) { $addresses = join(",", @addresses); open (CFG, "$admin_dir/email.txt"); @cfg = ; close (CFG); foreach $line (@cfg) { if ($line =~ m|^(\w+)=(.*)|) { $o = $1; $t = $2; $t = &unescape($t) if $t !~ /\s/; $email{$o} = $t; } } &extract("//$topic/$page.$ext"); $titlestr = "$title: $topic_name"; $emts = $topic_name; foreach $key (sort {$a <=> $b} keys(%level_number)) { $titlestr .= ": $level_name{$key}"; $emts .= ": $level_name{$key}"; } $emts = $me_name if $email{'subjectline'} == 2; $emts_result = &prepare_variable($emts); $titlestr_result = &prepare_variable($titlestr); if ($email{'subjectline'} != 1) { $subject_result = &prepare_variable($emts_result, 1) if $email{'subjectaddress'} != 0; $subject_result = &prepare_variable($emts_result) if $email{'subjectaddress'} == 0; } elsif ($email{'subjectline'} == 1) { $subject_result = &prepare_variable($email{'static'}, 1) if $email{'subjectaddress'} != 0; $subject_result = &prepare_variable($email{'static'}) if $email{'subjectaddress'} == 0; } $postby_result = &prepare_variable($postby); $message_result = $message_in; if ($email{'sendtext'} == 0) { $message_result = $L{EMAIL_NOTIFY_NOTEXT}; } $pb = $L{POSTBY}; ($datetime) = &ex('get_date_time', "long"); $pb =~ s/\%name/$postby_result/g; $pb =~ s/\%date/$datetime/g; $pb = &prepare_variable($pb); ($text_out) = &ex('notification_message', $titlestr_result, $pb, $message_result, 0, $topic_number, $me_number, "", ""); &send_email_message($addresses, $subject_result, $text_out, "", $topic_number, $me_number); } } sub prepare_variable { local ($msg, $remove_metachar) = @_; $msg =~ s/
/\n/g; $msg =~ s/([^/$1/g; $msg =~ s/
  • /\n\* /g; $msg =~ s/<\/UL>/\n\n/g; $msg =~ s/<[^>]*>//g; $msg =~ s/&#(\d+);/pack("c", $1)/ge; $msg =~ s/>/>/g; $msg =~ s/</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"; print "\n"; if ($bgcolor eq "ffffff") { $bgcolor = "ffffcc"; } else { $bgcolor = "ffffff"; } } print "\n"; } else { print "
     GroupUsers   
     $fs"; print "\u$line$fs$user_count   
     
     You are not authorized to edit any groups!
    \n"; } print "\n"; if ($pro) { $groups = join(",", @groups); &ex('userapp_1', $username, $groups, 1); } 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

    User Manager: \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"; $starflag = 0; foreach $line (@valid_user_list) { ($user, $encpass, $email, $fullname, $profile, $email2, $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)" if ($email eq "" || $email eq "email"); print "($fullname)" if ($email ne "" && $email ne "email"); } if ($profile > 2) { print " *"; $starflag = 1; } print " 
     (Marked)     
     There are no users in this group!
     
    \n"; print "
    \n"; if ($starflag) { print "* indicates that a user has never accessed his/her account

    \n"; } print "\n"; print "\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 "
    $fs", "E-mail (optional):"; print ""; print "
    $fs", "Full name (optional):"; 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"; if ($pro) { &ex('user_selfreg_config', $username, $group); } print "
    \n"; print "\n"; } #---SEPARATOR---# sub add_user { local ($username, $newuser, $pass1, $pass2, $group, $email, $full) = @_; $newuser =~ tr/A-Z/a-z/; $pass1 =~ tr/A-Z/a-z/; $pass2 =~ tr/A-Z/a-z/; while ($newuser =~ m|(\W)|g) { $o = ord($1); $m = $1; &error_message("Add User Error", "Username is invalid (username may not contain the character $m).") if $o < 126; } while ($pass1 =~ m|(\W)|g) { $o = ord($1); $m = $1; &error_message("Add User Error", "Password is invalid (password may not contain the character $m).") if $o < 126; } &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 1 and 15 characters).") if ($usercount < 1 || $usercount > 15); $passcount = length($pass1); &error_message("Add User Error", "The entered passwords are invalid (password must be between 1 and 15 alphanumeric characters).") if ($passcount < 1 || $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); if ($email =~ m|^([\w\-\+\.]+)\@([\w\-\+\.]+)$|) { $email_new = $email; } else { $email_new = "email"; } if ($full eq "") { $full = "fullname"; } else { $full =~ s/\n//g; $full =~ s/[:<>]//g; } if ($pro) { $line_new = "$newuser:$new_password:$email_new:$full:3::0:$group\n"; } else { $line_new = "$newuser:$new_password:$email_new:$full:1::0:$group\n"; } print PASSWD $line_new; close(PASSWD); &unlock("$admin_dir/users.txt"); return $line_new; } #---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"); @log = ; close (LOG); print "
    $fs\n"; print ""$title" is running Discus "; print $release_version; print "."; $revision_number = $free_revision if !$pro; $revision_number = $pro_revision if $pro; print $revision_number; print " PRO" if $pro; print ".
    \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 "" if !$pro; print "" if $pro; 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 "\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"; if (!$pro) { print "


    Buy Discus Pro

    \n"; print "
    $fs\n"; print "Discus Pro is a set of add-on features with such functionality as:

      \n"; print "
    • Read-restricted topics\n"; print "
    • User self-registration\n"; print "
    • Automatic archiving and pruning of the board\n"; print "
    • Enhanced user profiles & e-mail notification\n"; print "
    • Message queue (moderators approve posts)\n"; print "
    • Backup and restore board files\n"; print "
    • Attachment uploading (any file types)\n"; print "
    • IP screening (banning or automatic privileges)\n"; print "
    • Log analysis tools\n"; print "
    • and many more...\n
    \n"; print "Discus Pro is available for only \$99.00.\n"; print "You will get to keep all messages, users, moderators, and settings\n"; print "when you upgrade. For more information, please browse to:

    \n"; print "

    \n"; print "The above statements are true as of the release date\n"; print "of this version of Discus. Features, availability, and price are\n"; print "subject to change. For more information, follow the above link.\n"; print "\n"; print "

    \n"; } print "\n"; exit(0); } #---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; $mdv = 0; foreach $user (@users) { $c = 0; @u = split(/$delim/, $user); $mdv = scalar(@u) if scalar(@u) > $mdv; $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 ""; } while ($ctr2 < $mdv) { $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 "") { $maxx = 0; $maxy = 0; $ctr1 = 0; $ctr2 = 0; $flag1 = 0; $flag2 = 0; foreach $key (keys(%FORM)) { if ($key =~ m|x(\d+)y(\d+)|) { $maxx = $1 if $1 > $maxx; $maxy = $2 if $2 > $maxy; } } for ($ctr1 = 1; $ctr1 <= $maxx; $ctr1 += 1) { for ($ctr2 = 1; $ctr2 <= $maxy; $ctr2 += 1) { $pos = "x$ctr1" . "y$ctr2"; $listin .= $FORM{$pos} . $delim; } $pos = "x" . ($ctr1+1) . "y1"; if ($FORM{$pos} eq "\\") { last; } 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 = scalar(@u) if scalar(@u) > $fields; } foreach $user (@users) { @u = split(/$delim/, $user); if (scalar(@u) < $fields) { $user .= $delim x ($fields - scalar(@u)); } } 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"; $maxx = 0; $maxy = 0; $ctr1 = 0; $ctr2 = 0; foreach $key (keys(%FORM)) { if ($key =~ m|x(\d+)y(\d+)|) { $maxx = $1 if $1 > $maxx; $maxy = $2 if $2 > $maxy; } } for ($ctr1 = 1; $ctr1 <= $maxx; $ctr1 += 1) { for ($ctr2 = 1; $ctr2 <= $maxy; $ctr2 += 1) { $pos = "x$ctr1" . "y$ctr2"; $listin .= $FORM{$pos} . $delim; } $pos = "x" . ($ctr1+1) . "y1"; chop ($listin); if ($FORM{$pos} eq "\\") { last; } 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]; $pw =~ tr/A-Z/a-z/; $un = $username[$i]; $un =~ tr/A-Z/a-z/; if ($un ne "\\") { $unflag = 0; $pwflag = 0; while ($un =~ m|(\W)|g) { $o = ord($1); $m = $1; $unflag = 1 if $o < 126; } while ($pw =~ m|(\W)|g) { $o = ord($1); $m = $1; $pwflag = 1 if $o < 126; } } if ($un eq "\\") { } elsif ($unflag == 1) { $errflag .= "

  • Username "$un" is not a valid username.\n"; push (@erfl, $i); } elsif ($pwflag == 1) { $errflag .= "
  • Username "$un" has an invalid password.\n"; push (@erfl, $i); } elsif (length($un) < 1 || length($un) > 15) { $errflag .= "
  • Username "$un" is not between 1 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]) < 1 || length($password[$i]) > 15) { $errflag .= "
  • Username "$un" has a password "$pw" that is not between 1 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:$group\n") if !$pro; push (@pass2, "$un:$pass:$em:$fn:3::0:$group\n") if $pro; 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"); if ($pro) { foreach $line (@toremove) { $profile_fn = &getfn("$line-$group.txt"); if (-e "$admin_dir/profiles/$profile_fn") { $PICT{'picture'} = ""; &ex('read_profile', "$profile_fn"); if ($PICT{'picture'} ne "") { unlink("$admin_dir/profiles/$PICT{'picture'}"); } unlink("$admin_dir/profiles/$profile_fn"); } } } } #---SEPARATOR---# sub posting_options { local ($topic, $anon, $stamp, $email) = @_; $anon += 0; $stamp += 0; &lock("$admin_dir/postoptions.txt"); open (FILE, "$admin_dir/postoptions.txt"); @file = ; close (FILE); ($line) = grep(/^$topic:/, @file); ($t, $opt) = split(/:/, $line); $was_anon = $opt; @file = grep(!/^$topic:/, @file); push (@file, "$topic:$anon:$stamp:$email\n"); open (FILE, ">$admin_dir/postoptions.txt"); print FILE @file; close (FILE); &unlock("$admin_dir/postoptions.txt"); if ($anon != $was_anon) { $MUST_REGENERATE_PAGES = 1 if $anon == 1; $MUST_REGENERATE_PAGES = 2 if $anon == 0; } } #---SEPARATOR---# sub change_title_message { local ($newmessage, $source) = @_; local ($line, @lines,$messageflag, $flag); &lock("$message_dir/board-topics.html"); open(MAIN_1, "$message_dir/board-topics.html") || &error_message("File Error", "Could not open main topics file (board-topics.html)."); @lines = ; close(MAIN_1); open(MAIN_1, ">" . "$message_dir/board-topics.html") || &error_message("File Error", "Could not write main topics file (board-topics.html)."); $messageflag = 0; foreach $line (@lines) { if ($line =~ m||) { $flag = 1; print MAIN_1 $line; print MAIN_1 $newmessage . "\n"; } elsif ($line =~ m||) { print MAIN_1 $line; $flag = 0; } elsif ($flag == 1) { if ($line =~ /\n"; } } else { print MAIN_1 $line; } } close (MAIN_1); &unlock("$message_dir/board-topics.html"); } #---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, $ann, $ann_src, $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, $ann, $ann_src, $sublist, $about, $about_src, $message, $message_src); &unlock("$message_dir/$topic_number/$starting_page"); }