# FILE: src-board-subs-6 # 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 group_mgr { local ($username) = @_; open (GROUP, "$admin_dir/groups.txt") || &error_message("File Error", "Cannot open group file (group.txt)! (Code 060101)"); @group = ; close (GROUP); $count = @group; &header; print "Group Manager\n"; print "\n"; print "\n\n"; print "
$fs\n"; print "
Group Manager
\n
\n"; print "

Groups

\n"; print "\n"; $bgcolor = "ffffcc"; $c = 0; $ct = scalar(@group); print "\n"; foreach $line (sort(@group)) { ($group, $users) = split(/:/, $line); @users = split(/,/, $users); $uct = scalar(@users); print ""; if ($bgcolor eq "ffffcc") { $bgcolor = "ffffff"; } else { $bgcolor = "ffffcc"; } $num = $group; foreach $numb (sort(@group)) { if ($numb eq $num) { $fl = 1; } elsif ($fl == 0) { $topstr .= "document.sf.MARK$numb.checked = c;"; } elsif ($fl == 1) { $botstr .= "document.sf.MARK$numb.checked = c;"; } } print ""; print ""; print "\n"; print ""; print "\n"; print ""; print "\n"; } if ($ct > 0) { print ""; print "\n"; print ""; print ""; print "\n"; print ""; print "\n"; print ""; print "\n"; print "\n"; } print "
 MarkDel Edit Group 
 "; print " "; print " "; $c++; print "    \n"; $uct = 0 if $uct eq ""; print "\u$group ($uct moderator"; print "s" if $uct != 1; print ") 
 (Marked)     
 
\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "

Add a Group

\n"; print "
"; print "
$fs", "Group Name:"; print ""; print "
\n"; print "\n"; print "\n"; print "

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

\n"; print "
\n"; exit(0); } #---SEPARATOR---# sub add_group { local ($username, $newgroup) = @_; local (@groupline, $usercount, $line); &error_message("Add Group Error", "Group name is invalid -- it may contain only alphanumeric characters and the underscore character ("_").") if $newgroup =~ /\W/; $usercount = length($newgroup); $newgroup =~ tr/A-Z/a-z/; &error_message("Add Group Error", "The group name is invalid (name must be between 2 and 20 characters).") if ($usercount < 2 || $usercount > 20); &lock("$admin_dir/groups.txt"); open(GROUP,"$admin_dir/groups.txt") || &error_message("Add Group Error", "Cannot read group file (groups.txt)! (Code 060201)"); @groupline = ; close(GROUP); foreach $line (@groupline) { ($user, $therest) = split(/:/, $line); &error_message("Add Group Error", "The selected group ($newgroup) already exists!") if $user eq $newgroup; } open(GROUP,">>$admin_dir/groups.txt") || &error_message("Add Group Error", "Cannot append group file (groups.txt)! (Code 060302)"); print GROUP "$newgroup:$superuser\n"; close(GROUP); &unlock("$admin_dir/groups.txt"); } #---SEPARATOR---# sub delete_group { local ($toremove) = @_; local (@group, $line, $user, $therest); &lock("$admin_dir/groups.txt"); open (GROUP, "$admin_dir/groups.txt") || &error_message("File Error", "Cannot open group file (groups.txt) for reading! (Code 060301)"); @group = ; close (GROUP); open (GROUP, ">$admin_dir/groups.txt") || &error_message("File Error", "Cannot open group file (groups.txt) for writing! (Code 060302)"); foreach $line (@group) { ($user) = split(/:/, $line); print GROUP $line if $toremove ne $user; } close (GROUP); &unlock("$admin_dir/groups.txt"); &lock("$admin_dir/users.txt"); open (USERS, "$admin_dir/users.txt"); @users = ; close (USERS); foreach $line (@users) { $line = "" if $line =~ m|:$toremove\s*$|; } @users = grep(/\S/, @users); open (USERS, ">$admin_dir/users.txt"); print USERS @users; close (USERS); &unlock("$admin_dir/users.txt"); } #---SEPARATOR---# sub edit_group { local ($username, $group) = @_; open (GROUP, "$admin_dir/groups.txt") || &error_message("File Error", "Cannot open group file (groups.txt) for reading! (Code 060401)"); @group = ; close (GROUP); &error_message("Invalid Group Selection", "The specified group does not exist! (Code 060402)") if !grep(/^$group:/, @group); &error_message("Invalid Group Selection", "The specified group does not exist! (Code 060403)") if $group eq ""; ($line) = grep(/^$group:/, @group); ($group, $usersingroup) = split(/:/, $line, 2); chop ($usersingroup) if $usersingroup =~ /\n$/; @users = split(/,/, $usersingroup); $count = @users; &header; print "Edit Group\n"; print "\n"; print "\n"; print "\n"; print "$fs
Group Editor: \u$group
\n"; print "
\n"; print "Group Manager: Edit \u$group\n
\n"; print "

Moderators In Group

\n"; print "
\n"; print "\n"; $bgcolor = "ffffcc"; $c = 0; $ct = scalar(@users); open (PASSWD, "$admin_dir/passwd.txt"); @passwd = ; close (PASSWD); foreach $line (@passwd) { ($un, $pw, $em, $fnm) = split(/:/, $line); $fn{$un} = $fnm; } print "\n"; foreach $line (sort(@users)) { $fullname = $fn{$line}; $num = $line; print ""; if ($bgcolor eq "ffffcc") { $bgcolor = "ffffff"; } else { $bgcolor = "ffffcc"; } $num = $line; print ""; print ""; print "\n"; print ""; print "\n"; } if ($ct > 0) { print ""; print "\n"; print ""; print ""; print "\n"; print ""; print "\n"; print "\n"; } print "
 MarkRem Moderator 
 "; print " "; print " "; $c++; print "   \u$num "; if ($fullname ne "" && $fullname ne "none" && $fullname ne "fullname") { print "($fullname)"; } print " 
 (Marked)   
 
\n"; print "\n"; print "

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

\n"; @users_pr = @users; undef @users; foreach $line (@passwd) { ($user, $pw, $em, $fn) = split(/:/, $line); if (!grep(/^$user$/, @users_pr)) { push (@users, $user); } } if (scalar(@users) > 0) { print "

Add Moderators to Group

\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $bgcolor = "ffffcc"; $c = 0; $ct = scalar(@users); print "\n"; foreach $line (sort(@users)) { $fullname = $fn{$line}; $num = $line; print ""; if ($bgcolor eq "ffffcc") { $bgcolor = "ffffff"; } else { $bgcolor = "ffffcc"; } $num = $line; print ""; print ""; print "\n"; print ""; print "\n"; } if ($ct > 0) { print ""; print "\n"; print ""; print ""; print "\n"; print ""; print "\n"; print "\n"; } print "
 MarkAdd Moderator 
 "; print " "; print " "; $c++; print "   \u$num "; if ($fullname ne "" && $fullname ne "none" && $fullname ne "fullname") { print "($fullname)"; } print " 
 (Marked)   
 
\n"; print "\n"; print "

\n"; } print "\n"; } #---SEPARATOR---# sub delete_moderator_from_group { local ($moderator, $group) = @_; &lock("$admin_dir/groups.txt"); open (GROUP, "$admin_dir/groups.txt") || &error_message("Delete Moderator From Group Error", "Could not open groups file (groups.txt)! (Code 060501)"); @group = ; close (GROUP); foreach $line (@group) { next if $line !~ /^$group:/; chop $line if $line =~ /\n$/; ($group, $users) = split(/:/, $line, 2); @users = split(/,/, $users); @newusers = sort(grep(!/^$moderator$/, @users)); $newuserstring = join(",", @newusers); $newuserstring .= "\n"; $line = "$group:$newuserstring"; } open (GROUP, ">$admin_dir/groups.txt") || &error_message("Delete Moderator From Group Error", "Could not write to groups file (groups.txt)! (Code 060502)"); print GROUP @group; close (GROUP); &unlock("$admin_dir/groups.txt"); } #---SEPARATOR---# sub add_to_group { local ($group, $moderator) = @_; &lock("$admin_dir/passwd.txt"); open (PASSWD, "$admin_dir/passwd.txt") || &error_message("Add Moderator To Group Error", "Cannot open password file (passwd.txt)! (Code 060601)"); @passwd = ; close (PASSWD); &unlock("$admin_dir/passwd.txt"); &error_message("Add Moderator To Group Error", "Specified moderator does not exist in password file! (Code 060602)") if (!grep(/^$moderator:/, @passwd)); &lock("$admin_dir/groups.txt"); open (GROUP, "$admin_dir/groups.txt") || &error_message("Add Moderator To Group Error", "Cannot open group file (groups.txt)! (Code 060603)"); @group = ; close (GROUP); &error_message("Add Moderator To Group Error", "Specified group does not exist in group file! (Code 060604)") if (!grep(/^$group:/, @group)); foreach $line (@group) { next if $line !~ /^$group:/; ($group, $users) = split(/:/, $line, 2); chop ($users) if $users =~ /\n$/; @users = split(/,/, $users); if (grep(/^$moderator$/, @users)) { &unlock("$admin_dir/groups.txt"); &error_message("Add Moderator To Group Error", "Specified moderator is already a member of the specified group! (Code 060605)") ; } push (@users, $moderator); $line = "$group:"; $line .= join(",", @users); $line .= "\n"; } open (GROUP, ">$admin_dir/groups.txt") || &error_message("Delete Moderator From Group Error", "Could not write to groups file (groups.txt)! (Code 060606)"); print GROUP @group; close (GROUP); &unlock("$admin_dir/groups.txt"); } #---SEPARATOR---# #REQ:build_graphical_tree #REQ:page_manager_navbar sub move_message_form { local ($topic_number, $field, $form_move, $form_mark, $referer, $username) = @_; if ($field =~ /^(\d+)$/) { $tomove = $1; $plural = ""; } else { $tomove = $form_mark; $plural = "s"; } &header; print "Move Message$plural\n"; print "\n"; print "$fs
Move Message$plural
\n"; &page_manager_navbar($topic_number, $me_number, "Move Message$plural"); print "Select a destination for the message$plural you wish to move by clicking on\n"; print "the folder icon ()\n"; print "next to the destination. You may also move messages into a new subtopic.\n"; print "

Existing Subtopics

\n"; open (TOPFILE, "$message_dir/board-topics.html"); @topfile = ; close (TOPFILE); $topic_numbers = ""; $me_number_hold = $me_number; $topic_number_hold = $topic_number; foreach $line (@topfile) { if ($line =~ //) { $num = $1; &extract("//$num/$num.$ext"); if (&verify_owner($owner,$username)) { $topic_numbers .= "$num,"; } } } &build_graphical_tree($username, $topic_numbers, "$topic_number_hold/$me_number_hold", ""; print "
\n"; print "

Move Into New Subtopic

\n"; print "New Subtopic Name: \n"; print "
$fs Include "Add a Message" box\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } #---SEPARATOR---# #REQ:webtags #REQ:get_number #REQ:get_date_time #REQ:new_file #REQ:change_layout sub move_message { local ($old_topic, $old_page, $postindex, $new_topic, $new_page, $parmin) = @_; local ($num, $dt, $url, @file, $line, $str, $strg, $ts, @pi, $ind); if ($old_topic == $new_topic && $old_page == $new_page) { return ($new_page, $new_topic); } &extract("//$old_topic/$old_page.$ext"); if ($new_topic eq "Create") { if ($param !~ /Sublist/) { &change_layout($old_topic, $old_page, $param . "Sublist"); } $newsubject = &webtags($new_page,3); &error_message("Create New Subtopic Error", "You must type a subject for the new subtopic!") if $newsubject eq ""; &error_message("Create New Subtopic Error", "The following formatting error was returned: $newsubject") if $newsubject =~ /

FORMATTING/i; $num = &get_number; if ($parmin == 1) { $parm2 = "MessagesAdd"; } else { $parm2 = "Messages"; } &new_file($old_topic, $num, $old_page, $owner, $newsubject, $parm2); $new_topic = $old_topic; $new_page = $num; $url = "$html_url/messages/$old_topic/$new_page.$ext"; $newpage = $newsubject; $dt = &get_date_time ('long'); $dt =~ s/\W//g; $url .= "?$dt" if !$noqm; &lock("$message_dir/$old_topic/$old_page.$ext"); open (FILE, "$message_dir/$old_topic/$old_page.$ext"); @file = ; close (FILE); open (FILE, ">$message_dir/$old_topic/$old_page.$ext"); foreach $line (@file) { if ($line =~ //) { $str = &JavaScript_prepare($newpage); $strg = "onMouseOver=\"return setStatus('$str')\""; $ts = &get_date_time('short'); print FILE "
  • $newsubject $ts
  • \n"; print FILE "\n"; } else { print FILE $line; } } close (FILE); &unlock("$message_dir/$old_topic/$old_page.$ext"); } &lock("$message_dir/$new_topic/$new_page.$ext"); &lock("$message_dir/$old_topic/$old_page.$ext"); local ($head1, $color1, $lm1, $sublist1, $about1, $about_src1, $message1, $message_src1) = &get_page($old_topic, $old_page); local ($head2, $color2, $lm2, $sublist2, $about2, $about_src2, $message2, $message_src2) = &get_page($new_topic, $new_page); @pi = split(/,/, $postindex); local ($flag, $temp, @message1, @pushed); $flag = 0; @message1 = split(/\n/, $message1); foreach $ind (@message1) { if ($ind =~ m||) { $temp = $1; if (grep(/^$temp$/, @pi)) { $message2 .= "$ind\n"; $flag = 1; $ind = ""; } } elsif ($ind =~ m||) { $temp = $1; if (grep(/^$temp$/, @pi)) { $message_src2 .= "$ind\n"; $flag = 1; $ind = ""; } } elsif ($ind =~ m|$html_dir/messages/$new_topic/$numb.$exten"); eval 'binmode(FILE_D);'; while () { print FILE_D; } close (FILE_D); close (FILE_S); unlink ("$html_dir/messages/$old_topic/$numb.$exten"); $message2 =~ s|; close (LOG); local ($indx, $who, $when, $where, $rest); foreach $line (@LOG) { ($indx, $who, $when, $where, $rest) = split(/;/, $line, 5); if (grep(/^$indx$/, @pi)) { $line = join(";", $indx, $who, $when, "$new_topic/$new_page", $rest); } } open (LOG, ">$admin_dir/log.txt"); print LOG @LOG; close (LOG); &unlock("$admin_dir/log.txt"); return ($new_page, $new_topic); } #---SEPARATOR---# #REQ:extract_colorsonly #REQ:page_manager_navbar sub edit_message_form { local ($topic_number, $page_number, $post_index, $source, $formatted, $username) = @_; if ($formatted eq "") { open (FILE, "$message_dir/$topic_number/$page_number.$ext"); @file = ; close (FILE); $message = ""; $flag = 0; foreach $line (@file) { if ($line =~ //; $formatted = $'; } &header; ($bgcolor, $text, $link, $vlink, $alink, $face, $size, $img) = &extract_colorsonly; print "Preview of Edited Message\n"; print ""; print "$fs\n"; print "

    Preview of Edited Message
    \n"; &page_manager_navbar($topic_number, $me_number, "Edit Message"); if ($formatted !~ /

    FORMATTING/i) { print "A preview of your message appears below. If you used any formatting tags in your "; print "message, please check to see that your formatting is displayed correctly in "; print "the preview.

    \n"; print "\n"; } print "
    " if $formatted !~ /

    FORMATTING/i; print $formatted; print "

    \n" if $formatted !~ /

    FORMATTING/i; print "
    \n"; $source =~ s/\s+$//; $source = &unescape($source) if ($source !~ /\s/ && $FORM{'editing_flag'} == 0); if ($flag_edited == 1 || $FORM{'editing_flag'}) { $source =~ s/&/&/g; $source =~ s//>/g; $source =~ s/"/"/g; } print "
    "; print "
    "; print "

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n" if $formatted !~ /

    FORMATTING/i; print "\n"; print "\n"; print "

    \n"; print "\n"; } #---SEPARATOR---# sub save_edited_message { local ($topic_number, $page_number, $post_index, $source, $formatted, $username) = @_; &lock("$message_dir/$topic_number/$page_number.$ext"); local ($head, $color, $lm, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic_number, $page_number); local (@message, $line, $flag); @message = split(/\n/, $message); $flag = 0; foreach $line (@message) { if ($line =~ m||) { $flag = 1; } elsif ($line =~ m|^
    \s*$|) { $byflag = 1; next; } elsif ($byflag == 1) { $byflag = 0; } elsif ($line =~ m||) { $flag = 0; $line = join("\n", "", $formatted, $line); } elsif ($flag == 1) { $line = ""; } } $message = join("\n", grep(/\S/, @message)); @message = split(/\n/, $message_src); $flag = 0; foreach $line (@message) { if ($line =~ m||) { $flag = 1; } elsif ($line =~ m||) { $flag = 0; $line = join("\n", $source, $line); } elsif ($flag == 1) { $line = ""; } } $message_src = join("\n", grep(/\S/, @message)); &set_page($topic_number, $page_number, $head, $color, $lm, $sublist, $about, $about_src, $message, $message_src); &unlock("$message_dir/$topic_number/$page_number.$ext"); $src = &unescape($source); $src .= " "; $src =~ m|^(.{0,40})|; $prev = $1; &lock("$admin_dir/log.txt"); open (LOG, "$admin_dir/log.txt"); @log = ; close (LOG); foreach $line (@log) { if ($line =~ m|^$post_index;|) { @spl = split(/;/, $line, 8); $line = join(";", $spl[0], $spl[1], $spl[2], $spl[3], $spl[4], $spl[5], &escape($prev), $spl[7]); } } open (LOG, ">$admin_dir/log.txt"); print LOG @log; close (LOG); &unlock("$admin_dir/log.txt"); } #---SEPARATOR---# sub reorder_messages { local ($referer, $arraystr) = @_; local (@array, %message, $file, @file, $line, $flag, $message, %printed); &extract($referer); $file = "$message_dir/$topic_number/$me_number.$ext"; &lock($file); open (FILE_R, $file); @file = ; close (FILE_R); foreach $line (@file) { if ($line =~ //) { $flag = $1; $message{$flag} .= $line; $printed{$flag} = 0; } elsif ($line =~ //) { $message{$flag} .= $line; $flag = 0; } elsif ($flag > 0) { $message{$flag} .= $line; } } $flag = 0; @array = split(/:/, $arraystr); open (FILE_R, ">$file"); foreach $line (@file) { if ($line =~ //) { print FILE_R $line; $flag = 0; } elsif ($flag == 0) { print FILE_R $line; } } close (FILE_R); &unlock($file); }