# FILE: src-board-subs-2
# 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---#
#REQ:new_file
#REQ:get_date_time
#REQ:get_number
sub add_page {
local ($newpage, $type, $url, $target, $tn, $mn, $grp, $datetime_in) = @_;
local ($num, $dt, @sublist, $line, $str, $strg, $ts);
$owner = $grp if $grp ne "";
$num = &get_number;
if ($tn != 0) {
$topic_number = $tn; $me_number = $mn;
}
$url = "$message_url/$topic_number/$num.$ext" if $type ne "LINK";
$dt = &get_date_time('long');
$dt =~ s/\W//g;
$newpage = &remove_links($newpage);
$url .= "?$dt" if ($type ne "LINK" && !$noqm);
&lock("$message_dir/$topic_number/$me_number.$ext");
local ($head, $color, $lm, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic_number,$me_number);
$str = &JavaScript_prepare($newpage);
$strg = "onMouseOver=\"return setStatus('$str')\"";
$ts = &get_date_time('short');
$ts = $datetime_in if $datetime_in ne "";
$sublist .= "
$newpage $ts\n" if $type ne "LINK";
$sublist .= "
$newpage\n" if $type eq "LINK";
&set_page($topic_number, $me_number, $head, $color, $lm, $sublist, $about, $about_src, $message, $message_src);
&unlock("$message_dir/$topic_number/$me_number.$ext");
&new_file ($topic_number, $num, $me_number, $owner, $newpage, $type) if $type ne "LINK";
return $num;
}
#---SEPARATOR---#
sub rename_topic_form {
local ($oldname, $topic_number, $username) = @_;
&header;
print "
Topic Properties\n";
print "$fs\n";
print "Topic Properties\n";
print "
\n";
print "Board Manager: Topic Properties
\n";
print "\n";
exit(0);
}
#---SEPARATOR---#
sub change_topic_group_form {
local ($topics, $username) = @_;
@topics = split(/,/, $topics);
&header;
print "Change Topic Group\n";
print "\n";
print "$fsChange Topic Group\n";
print "
\n";
print "Board Manager: Change Topic Group
\n";
print "\n";
exit(0);
}
#---SEPARATOR---#
sub add_moderator {
local ($username, $newuser, $pass1, $pass2) = @_;
$newuser =~ tr/A-Z/a-z/; $pass1 =~ tr/A-Z/a-z/; $pass2 =~ tr/A-Z/a-z/;
&error_message("Add Moderator Error", "Username is invalid (username may contain only alphanumeric characters).") if $newuser =~ /\W/;
&error_message("Add Moderator Error", "The entered passwords do not match!") if $pass1 ne $pass2;
$usercount = length($newuser);
&error_message("Add Moderator Error", "The username is invalid (username must be between 3 and 15 characters).") if ($usercount < 3 || $usercount > 15);
&error_message("Add Moderator Error", "The entered passwords are invalid (password may contain only alphanumeric characters.") if $pass1 =~ /\W/;
$passcount = length($pass1);
&error_message("Add Moderator Error", "The entered passwords are invalid (password must be between 3 and 15 alphanumeric characters).") if ($passcount < 3 || $passcount > 15);
open(PASSWD,"$admin_dir/passwd.txt") || &error_message("Add Moderator Error", "Cannot read password file (passwd.txt)! (Code 020401)");
@passwdline = ;
close(PASSWD);
foreach $line (@passwdline) {
($user, $encpass, $therest) = split(/:/, $line);
&error_message("Add Moderator Error", "The selected username already exists as a moderator!") if $user eq $newuser;
}
srand(time);
undef (@salt);
for ($i=1; $i<=4; $i++) {
push (@salt, int(rand(26))+65);
}
$salt = pack('c4', @salt);
&lock("$admin_dir/passwd.txt");
open(PASSWD,">>$admin_dir/passwd.txt") || &error_message("Add Moderator Error", "Cannot append password file (passwd.txt)! (Code 020202)");
$new_password = crypt($pass1, $salt);
print PASSWD "$newuser:$new_password:email:fullname:1:0:0\n";
close(PASSWD);
&unlock("$admin_dir/passwd.txt");
}
#---SEPARATOR---#
sub delete_moderator {
local ($toremove) = @_;
local (@passwd, $line, $user, $therest);
&lock("$admin_dir/passwd.txt");
open (PASSWD, "$admin_dir/passwd.txt") || &error_message("File Error", "Cannot open password file (passwd.txt) for reading! (Code 020501)");
@passwd = ;
close (PASSWD);
open (PASSWD, ">$admin_dir/passwd.txt") || &error_message("File Error", "Cannot open password file (passwd.txt) for writing! (Code 020502)");
foreach $line (@passwd) {
($user) = split(/:/, $line);
print PASSWD $line if $toremove ne $user;
}
close (PASSWD);
&unlock("$admin_dir/passwd.txt");
&lock("$admin_dir/groups.txt");
open (GRP, "$admin_dir/groups.txt"); @grp = ; close (GRP);
foreach $line (@grp) {
chop $line if $line =~ /\n/;
($group, $users) = split(/:/, $line);
@users = split(/,/, $users);
@users = grep(!/^$toremove$/, @users);
$users = join(",", @users);
$users .= "\n";
$line = join(":", $group, $users);
}
open (GRP, ">$admin_dir/groups.txt");
print GRP @grp;
close (GRP);
&unlock("$admin_dir/groups.txt");
}
#---SEPARATOR---#
sub edit_moderator {
local ($username, $moderator) = @_;
open (PASSWD, "$admin_dir/passwd.txt") || &error_message("File Error", "Cannot open password file (passwd.txt) for reading! (Code 020601)");
@passwd = ;
close (PASSWD);
&error_message("Invalid Moderator Selection", "The specified moderator does not exist! (Code 020602)") if !grep(/^$moderator:/, @passwd);
&error_message("Invalid Moderator Selection", "The specified moderator does not exist! (Code 020603)") if $moderator eq "";
($line) = grep(/^$moderator:/, @passwd);
($user, $encrpass, $email, $fullname, $profile, $notify, $lastcheck) = split(/:/, $line);
&header;
print "Edit Moderator\n";
print "\n";
print "Moderator Editor: \u$moderator\n";
print "
\n";
print "Moderator Manager: Edit \u$moderator\n
\n";
print "\n";
print "\n" if $moderator eq $superuser;
return if $moderator eq $superuser;
print "
Change Moderator Password
\n";
print "\n";
print "