# FILE: src-board-subs-4 # 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:extract_colorsonly sub board_manager { local ($username) = @_; $append = "?username=$username&action=menu"; open (FILE, "$message_dir/board-topics.html") || &error_message("File Error", "Could not open top file (board-topics.html)."); @lines = ; close(FILE); undef @topic_number; undef @topic_name; undef @group; $count = 0; $topics = ""; foreach $line (@lines) { $_ = $line; if (//) { $count = $count + 1; $filename = "$message_dir/$1/$1.$ext"; $num = $1; push (@topic_number, $1); &extract ($filename); push (@topics, "$num:$topic_name (\u$owner)"); push (@group, $owner); } } &header; print "Board Manager\n"; print "\n"; print '$fs\n"; print "
Board Manager
\n"; print "
\n"; print "

Topics

\n"; print "
\n"; print "\n"; print "\n"; $c = "ffffcc"; print "\n"; $counter = 0; $ctr = 0; $ct = scalar(@topics); foreach $thing (@topics) { if ($thing =~ /^(\d+):(.*)/) { $num = $1; $descr = $2; print ""; $counter += 1; if ($c eq "ffffcc") { $c = "ffffff"; } else { $c = "ffffcc"; } print ""; print "\n"; print ""; $name2 = &JavaScript_prepare($descr); print ""; print ""; print "\n"; print ""; print "\n"; print ""; print "\n"; } } if ($counter > 0) { print ""; print "\n"; print ""; print "\n"; print ""; print ""; print ""; print "\n"; print ""; print "\n"; print ""; print "\n"; print "\n"; } print "
 Order MarkDelGrp Prop Topic (group) 
  "; print " "; print " "; $ctr += 1; print "    \n"; print "$descr"; print " 
  (Marked)     
 
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "

Add a Topic

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

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

\n"; print "

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

Main Message

\n"; print "
\n"; print "\n"; print "\n"; print "
"; print "$fs", "Enter the text for your "Main Message" in the area below.

\n"; print "

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

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

Board Appearance

\n"; print "
\n"; ($bgcolor,$text,$link,$vlink,$alink,$face,$size, $image) = &extract_colorsonly; print "
"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$fs", "Background:
\n"; print "
THIS IS A SAMPLE OF YOUR COLORS

\n"; print "Text Color
\n"; print "Unvisited Link
\n"; print "Visited Link
\n"; print "Active Link
\n"; print "Smaller Text

$fs", "Text:
$fs", "Link:
$fs", "Visited Link:
$fs", "Active Link:
$fs", "Font Face:
$fs", "Font Size:
$fs", "Background Image:
\n"; print "

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

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

Top Page Options

\n"; print "
$fs"; if (open (FILE, "$admin_dir/frontpage_conf.txt")) { @file = ; close (FILE); foreach $line (@file) { $line =~ m|^(\w+)=(.*)|; $FPCONFIG{$1} = $2; } } else { $FPCONFIG{"Bold"} = "1"; $FPCONFIG{"Group"} = "0"; $FPCONFIG{"Date"} = "1"; print "Error reading $admin_dir/frontpage_conf.txt. Make "; print "sure file exists and is readable/writable!

\n"; } print " Topic names in Bold
\n"; print " Display group name in (parentheses)
\n"; print " Display last modified date

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

\n"; print "\n"; print "\n"; print "
\n"; print "\n"; exit(0); } #---SEPARATOR---# sub build_graphical_tree { local ($username, $topics, $present, $iconlink, $textlink, $stopflag, $stop_present, $skipformstuff, $nsbug) = @_; undef @aarr; undef @barr; undef @carr; undef @darr; @topics = split(/,/, $topics) if $topics ne "*"; open (TOP_FILE, "$message_dir/board-topics.html"); @top = ; close (TOP_FILE); foreach $line (@top) { if ($line =~ //) { $o = $1; $lastnum = $o if (grep(/^$o$/, @topics) || $topics eq "*"); push (@topics, $o) if $topics eq "*"; } } $LAST_TOPIC = $lastnum; $present =~ m|(\d+)/(\d+)|; $topic_number = $1; $me_number = $2; $expl = $topic_number; print "$title
\n"; print "\n"; if (!$nsbug) { print "\n"; } else { for ($i = 0; $i < scalar(@aarr); $i++) { if (length($aarr[$i]) == 0) { if ($barr[$i] == $LAST_TOPIC) { print ""; } else { print ""; } } else { while ($aarr[$i] =~ m|(\w)|g) { print ""; } } print ""; print "$textlink$carr[$i]\">$darr[$i]

\n"; } } } sub descend_tree { local ($topic_number,$page_number,$level,$show,$stopflag,$iconlink,$textlink,$present) = @_; local (@file,$line,$number,$filename,$lastnum,$page,$name,$stopflag1,$iconlink1,$cutnow); local (@present) = split(/,/, $present); $filename = "$message_dir/$topic_number/$page_number.$ext"; open (FILE, $filename); @file = ; close (FILE); foreach $line (@file) { $lastnum = $1 if $line =~ //; } foreach $line (@file) { if ($line =~ /
  • ]*>(.*)<\/A>/) { $page = $1; $name = $2; substr($show, $level, 1) = "1" if $page != $lastnum; substr($show, $level, 1) = "0" if $page == $lastnum; if (grep(/^$page$/, @present) && $stopflag) { $global_cutoff = 1; $cutnow = 1; } $iconlink1 = $iconlink; $iconlink1 = "" if $global_cutoff != 0; $textlink1 = $textlink; $textlink1 =~ s//$topic_number\/$page/g; &drawicon($level, $show, $iconlink1, $page, $stopflag, $topic_number, $name, $textlink1); &descend_tree($topic_number, $page, $level+1, $show, $stopflag, $iconlink, $textlink, $present); $global_cutoff = 0 if $cutnow == 1; $cutnow = 0 if $cutnow == 1; $iconlink = $iconlink1; } } } sub drawicon { local ($level, $show, $iconlink, $page, $stopflag, $topic_number, $name, $textlink) = @_; local ($astr, $bstr); $name = &JavaScript_prepare($name); $name =~ s/\'//g; $astr = "i" if $topic_number != $LAST_TOPIC; $astr = "j" if $topic_number == $LAST_TOPIC; for ($i = 0; $i < $level; $i++) { $img = "j" if substr($show, $i, 1) == 0; $img = "i" if substr($show, $i, 1) == 1; $astr .= $img; } $astr .= "e" if substr($show, $level, 1) == 1; $astr .= "f" if substr($show, $level, 1) == 0; push (@aarr, $astr); push (@barr, $page); push (@carr, "$topic_number/$page.$ext") if $global_cutoff == 0; push (@carr, "") if $global_cutoff == 1; push (@darr, $name); } #---SEPARATOR---# #REQ:get_date_time sub admin_main_menu { local ($user, $crypted_pass_1, $flag) = @_; $ts = &get_date_time("short"); $host = $ENV{'REMOTE_HOST'}; $addr = $ENV{'REMOTE_ADDR'}; $crypted_pass_2 = crypt($crypted_pass_1, "cookie"); open (LOG, ">>$admin_dir/admin.log"); print LOG "$user\"$host\"$addr\"$ts\"ok\n"; close (LOG); print "Set-Cookie: pass=$crypted_pass_2; path=/\n"; &header; print "$titlej Administration\n"; print "\n"; print "\n"; print "\n"; print "You must specify a password!

    \n"; print "You must set your password before continuing.

    \n"; print "

  • Set your password\n"; print "
  • Cancel\n"; print "\n"; exit(0); } print "onLoad=\"menuload()\">\n"; print "
    \n"; print "$fs\n"; print "\n"; if (-e "$html_dir/index.html") { print "Go to Board

    \n"; print " Moderator Functions
    \n"; print " "; print "Page Manager
    \n"; print " "; print "User Manager
    \n"; print " "; print "Profile Manager
    \n"; print " "; print "Log In Again
    \n"; print "
    \n"; print " Instructions
    \n"; print " "; print "Administration
    \n"; print " "; print "Formatting
    \n"; print " "; print "Troubleshooting
    \n"; if ($FORM{'username'} ne $superuser) { print "\n"; exit(0); } print "
    \n"; print " Superuser Functions
    \n"; print " "; print "Board Manager
    \n"; print " "; print "Moderator Manager
    \n"; print " "; print "Group Manager
    \n"; print " "; print "Version Manager
    \n"; print "\n"; exit(0); } #---SEPARATOR---# sub front_page { &header; print "$title Administration\n"; print "\n"; print "$fs

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

    $fs\n"; print "\n"; print "

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

    \n"; print "\n"; print "The administration program will store internal information\n"; print "in a COOKIE. For this to work, you must have cookies\n"; print "enabled on your browser! Also, be sure to exit the browser\n"; print "when you are done so that the information in the cookie will\n"; print "be reset.\n"; print "\n"; exit(0); } #---SEPARATOR---# #REQ:page_manager_navbar sub viewmessage { local ($topic_number, $me_number, $index) = @_; local (@file, $line, $flag, $post, $postby, $postbyflag); local ($head, $color, $lm, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic_number, $me_number); @file = split(/\n/, $message); foreach $line (@file) { last if $line =~ //; if ($line =~ //) { $flag = 1; } elsif ($flag == 1) { if ($postbyflag == 0 && $line =~ /\n$//g; $post =~ s/^
    //; &header; print "Message Viewer\n"; print "\n"; print "\n"; print "\n"; print "$fs\n"; print "
    View Message
    \n"; &page_manager_navbar($topic_number, $me_number, "View Message"); ($bgcolor, $text, $link, $vlink, $alink, $img, $size, $face) = split(/\t/, $color); print "\n"; print "
    "; print "$postby\n$post
    \n"; print "
    \n"; exit(0); } #---SEPARATOR---# sub moderator_mgr { open (PASSWD, "$admin_dir/passwd.txt") || &error_message("File Error", "Cannot open moderator password file (passwd.txt)! (Code 040601)"); @passwd = ; close (PASSWD); $count = scalar(@passwd); &header; print "Moderator Manager\n"; print "\n"; print "\n\n"; print "$fs\n"; print "
    Moderator Manager
    \n
    \n"; print "

    Moderators

    \n"; print "\n"; $bgcolor = "ffffcc"; $c = 0; $ct = scalar(@passwd); print "\n"; undef @mod; foreach $line (sort(@passwd)) { ($user, $encpass, $email, $fullname, $profile, $email, $last) = split(/:/, $line); print ""; if ($bgcolor eq "ffffcc") { $bgcolor = "ffffff"; } else { $bgcolor = "ffffcc"; } $num = $user; print ""; print "" if $user ne $superuser; print "" if $user eq $superuser; 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 Moderator 
     "; print " "; print " "; $c++; print "  N/A  $fs\u$user "; 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 "

    Add a Moderator

    \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 "\n"; print "
    \n"; exit(0); } #---SEPARATOR---# sub remove_message_from_log { local ($postindex) = @_; local (@file, @newfile); &lock("$admin_dir/log.txt"); open (LOG, "$admin_dir/log.txt"); @file = ; close (LOG); if ($postindex =~ /,/) { @pi = split(/,/, $postindex); foreach $q (@pi) { next if $q eq ""; @newfile = grep(!/^$q;/, @file); } } else { @newfile = grep(!/^$postindex;/, @file); } open (LOG, ">$admin_dir/log.txt"); print LOG @newfile; close (LOG); &unlock("$admin_dir/log.txt"); } #---SEPARATOR---# sub moved_message_update_log { local ($postindex, $new_where) = @_; local (@file, $newline, $line); local (@newlines); &lock("$admin_dir/log.txt"); open (LOG, "$admin_dir/log.txt"); @file = ; close (LOG); ($newline) = grep(/^$postindex;/, @file); @newlines = split(/;/, $newline); $newline = join(";", $newlines[0], $newlines[1], $newlines[2], $new_where, $newlines[4]); foreach $line (@file) { $line = $newline if $line =~ /^$postindex;/; } open (LOG, ">$admin_dir/log.txt"); print LOG @file; close (LOG); &unlock("$admin_dir/log.txt"); } #---SEPARATOR---# sub remove_message { local ($referer, $message_number) = @_; local (@mn, $num, @msg, $flag, @removed, @imgtakeout); if ($referer =~ m|/(\d+)/(\d+)\.$ext|) { local ($topic, $page) = ($1, $2); &lock("$message_dir/$topic/$page.$ext"); local ($head1, $color1, $lm1, $sublist1, $about1, $about_src1, $message1, $message_src1) = &get_page($topic, $page); @mn = split(/,/, $message_number); @msg = split(/\n/, $message1); $flag = 0; foreach $line (@msg) { if ($line =~ m||) { $num = $1; if (grep(/^$num$/, @mn)) { $flag = $num; $line = ""; push (@removed, $num); } } elsif ($line =~ m||) { $line = ""; $flag = 0; } elsif ($flag > 0) { $line = ""; } } $message1 = join("\n", grep(/\S/, @msg)); @msg = split(/\n/, $message_src1); $flag = 0; foreach $line (@msg) { if ($line =~ m||) { $num = $1; if (grep(/^$num$/, @mn)) { $flag = $num; $line = ""; } } elsif ($line =~ m||) { $line = ""; $flag = 0; } elsif ($flag > 0) { $l2 = &unescape($line); while ($l2 =~ m|\\image_alreadyuploaded\{\s*(\d+)|g) { push (@imgremove, "$1.gif"); } while ($l2 =~ m|\\jpeg_alreadyuploaded\{\s*(\d+)|g) { push (@imgremove, "$1.jpg"); } $line = ""; } } $message_src1 = join("\n", grep(/\S/, @msg)); &set_page($topic, $page, $head1, $color1, $lm1, $sublist1, $about1, $about_src1, $message1, $message_src1); &unlock("$message_dir/$topic/$page.$ext"); foreach $img (@imgremove) { unlink ("$message_dir/$topic/$img"); } local (@LOG); &lock("$admin_dir/log.txt"); open (LOG, "$admin_dir/log.txt"); @LOG = ; close (LOG); local ($indx, $who, $when, $where, $rest); foreach $line (@LOG) { ($indx, $who, $when, $where, $rest) = split(/;/, $line, 5); if (grep(/^$indx$/, @mn)) { $line = ""; } } @LOG = grep(/\S/, @LOG); open (LOG, ">$admin_dir/log.txt"); print LOG @LOG; close (LOG); &unlock("$admin_dir/log.txt"); } else { &error_message("Extract Error: Could not extract file for message removal"); } } #---SEPARATOR---# sub first_pass { local ($username) = @_; &header; print "Set password\n"; print "$fs\n"; print "
    Set password
    \n
    \n"; print "Welcome to your new Discus board! You need to set the superuser's password using this form.
    \n"; print "
    \n"; print "
    \n"; print "\n"; print "\n"; print "
    $fs", "New Password:
    $fs", "Verify New Password:
    \n\n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    \n"; print "
    \n"; print "\n"; }