# FILE: src-board-subs-1 # 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:get_number #REQ:new_file #REQ:get_date_time sub add_topic { local ($new_topic, $new_topic_group) = @_; local ($topic_number,$topic_name,$me_name,$num,$dt,$lm,@main,$group); local ($main_line,$str,$time,$posted); $num_local = &get_number; $group = $new_topic_group; mkdir ("$message_dir/$num_local",0777) || &error_message("Directory Creation Error", "Could not create new directory for this topic! (System returned the error: '$!'.) If you are running unix, check that permissions on the 'messages' subdirectory are 0777 (rwxrwxrwx)."); chmod (0777, "$message_dir/$num_local"); $topic_number = $num_local; $topic_name = $new_topic; $me_name = $new_topic; $dt = &get_date_time('long'); $dt =~ s/\W//g; &new_file($num_local,$num_local,0,$new_topic_group,$new_topic,"Sublist"); eval 'symlink ("$message_dir/$num_local/$num_local.$ext", "$message_dir/$num_local/index.html");'; &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)."); @main = ; close(MAIN_1); $posted = 0; open(MAIN_1, ">" . "$message_dir/board-topics.html") || &error_message("File Error", "Could not write main topics file (board-topics.html)."); foreach $main_line (@main) { if ($main_line =~ // && $posted == 0) { if (open (FILE_c, "$admin_dir/frontpage_conf.txt")) { @file_c = ; close (FILE_c); foreach $line_c (@file_c) { if ($line_c =~ m|^(\w+)=(.*)|) { $FPCONFIG{$1} = $2; } } } else { $FPCONFIG{"Bold"} = "1"; $FPCONFIG{"Group"} = "0"; $FPCONFIG{"Date"} = "1"; } $new_topic = &remove_links($new_topic); $str = &JavaScript_prepare($new_topic); print MAIN_1 "
  • "; print MAIN_1 "" if $FPCONFIG{"Bold"} == 1; print MAIN_1 "$new_topic"; print MAIN_1 "" if $FPCONFIG{"Bold"} == 1; print MAIN_1 " "; print MAIN_1 "(\u$new_topic_group)" if $FPCONFIG{"Group"} == 1; print MAIN_1 " "; $time = &get_date_time('short'); print MAIN_1 "$time" if $FPCONFIG{"Date"} == 1; print MAIN_1 "

    \n"; $posted = 1; print MAIN_1 "\n"; } elsif ($main_line =~ //) { } else { print MAIN_1 $main_line; } } close(MAIN_1); &unlock("$message_dir/board-topics.html"); return $num_local; } #---SEPARATOR---# #REQ:recurse sub remove_topic { local ($remove_number) = @_; local (@lines,$line,$filenumber,$topic_number); &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)."); foreach $line (@lines) { if ($line =~ //) { if ($1 == $remove_number) { &recurse ($remove_number,$remove_number,"delete"); unlink ("$message_dir/$remove_number/index.html"); rmdir ("$message_dir/$remove_number"); } else { print MAIN_1 $line; } } else { print MAIN_1 $line; } } close (MAIN_1); &unlock("$message_dir/board-topics.html"); } #---SEPARATOR---# #REQ:recurse #REQ:extract_lastmodified #REQ:get_date_time sub rename_topic { local ($topic_number_in, $newname) = @_; local ($line_top,$url,$lm,$str,@lines_top); &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_top = ; close(MAIN_1); foreach $line_top (@lines_top) { if ($line_top =~ /^/) { $lm = &extract_lastmodified ("$topic_number_in:$topic_number_in"); &extract("//$topic_number_in/$topic_number_in.$ext"); $url = "$message_url/$topic_number_in/$topic_number_in.$ext"; $url .= "?$lm" if !$noqm; if (open (FILE_c, "$admin_dir/frontpage_conf.txt")) { @file_c = ; close (FILE_c); foreach $line_c (@file_c) { if ($line_c =~ m|^(\w+)=(.*)|) { $FPCONFIG{$1} = $2; } } } else { $FPCONFIG{"Bold"} = "1"; $FPCONFIG{"Group"} = "0"; $FPCONFIG{"Date"} = "1"; } $lmtime = 0; if ($line_top =~ m|.*(.*)|) { $datetime = $1; } else { $lmtime = (stat "$html_dir/messages/$topic_number_in/$topic_number_in.$ext")[9]; } $line_top = "

  • "; $line_top .= "" if $FPCONFIG{'Bold'} == 1; $line_top .= "$newname"; $line_top .= "" if $FPCONFIG{'Bold'} == 1; $line_top .= " (\u$owner)" if $FPCONFIG{'Group'} == 1; if ($FPCONFIG{'Date'} == 1 && $lmtime != 0) { $line_top .= " " . &get_date_time('short', $lmtime) . ""; } elsif ($FPCONFIG{'Date'} == 1) { $line_top .= " $datetime"; } $line_top .= "

    \n"; } } open(MAIN_1, ">$message_dir/board-topics.html") || &error_message("File Error", "Could not write main topics file (board-topics.html)."); print MAIN_1 @lines_top; close (MAIN_1); &unlock("$message_dir/board-topics.html"); &recurse ("$topic_number_in", "$topic_number_in", "rename:Topic", $newname); } #---SEPARATOR---# sub reorder_topics { local ($array) = @_; local ($topic_number,@ascending,$line,@lines,%newarray,$flag,$key, %printed); @ascending = split(/:/, $array); &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); undef %printed; foreach $line (@lines) { if ($line =~ //) { $newarray{$1} = $line; $printed{$1} = 0; } } open(MAIN_1, ">" . "$message_dir/board-topics.html") || &error_message("File Error", "Could not write main topics file (board-topics.html)."); $flag = 0; foreach $line (@lines) { if ($line =~ // && $flag == 0) { $flag = 1; foreach $key (@ascending) { print MAIN_1 $newarray{$key}; $printed{$key} = 1; } foreach $key (keys(%printed)) { print MAIN_1 $newarray{$key} if $printed{$key} == 0; } } elsif ($line =~ //) { $flag = 0; print MAIN_1 $line; } elsif ($flag == 0) { print MAIN_1 $line; } } close (MAIN_1); &unlock("$message_dir/board-topics.html"); } #---SEPARATOR---# sub change_main_message { local ($newmessage, $source) = @_; local ($line, @lines,$messageflag); &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 =~ /$/) { $messageflag = 1; print MAIN_1 $line; } elsif ($line =~ //) { $messageflag = 0; print MAIN_1 $newmessage . "\n"; print MAIN_1 $line; } elsif ($messageflag == 0) { print MAIN_1 $line; } } close (MAIN_1); &unlock("$message_dir/board-topics.html"); } #---SEPARATOR---# sub register_discus { &header; print 'Password Changed'; print "\n"; print "$fs

    Password Set
    "; print "\n
    \nCongratulations, your superuser password was successfully set.

    \n"; print "At this time, you need to "Register" the Discus\n"; print "program by clicking on "Register Now!" below.

    \n"; print "

    \n"; print "
    \n"; $contact =~ m|(.*)|; $email = $1; $name = $2; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    $fs", "URL:
    $fs", "Title:
    $fs", "Your Name:
    $fs", "Your E-mail:
    $fs Yes! Inform me when new upgrades are available.
    \n

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

    \n\n"; exit(0); } #---SEPARATOR---# #REQ:recurse sub change_topic_group { local ($topic_number, $new_group) = @_; local ($line, @lines,$old_group); if (open (FILE_c, "$admin_dir/frontpage_conf.txt")) { @file_c = ; close (FILE_c); foreach $line_c (@file_c) { if ($line_c =~ m|^(\w+)=(.*)|) { $FPCONFIG{$1} = $2; } } } else { $FPCONFIG{"Bold"} = "1"; $FPCONFIG{"Group"} = "0"; $FPCONFIG{"Date"} = "1"; } 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); if ($FPCONFIG{"Group"} == 1) { &lock("$message_dir/board-topics.html"); open(MAIN_1, ">" . "$message_dir/board-topics.html") || &error_message("File Error", "Could not write main topics file (board-topics.html)."); foreach $line (@lines) { if ($line =~ //) { if ($1 == $topic_number) { if ($line =~ m| \(\w+\)|i) { $line = join("", $`, " (\u$new_group)", $'); } print MAIN_1 $line; } else { print MAIN_1 $line; } } else { print MAIN_1 $line; } } close (MAIN_1); &unlock("$message_dir/board-topics.html"); } &recurse ($topic_number,$topic_number,"chgrp",$new_group); } #---SEPARATOR---# #REQ:printuntil sub preview_board_colors { ($bgcolor,$text,$link,$vlink,$alink,$face,$size,$username,$image) = @_; &header; &printuntil(1, 1, 0, "Preview Appearance", 1); print "
    Preview Appearance
    \n"; for ($i = 3; $i <= 7; $i += 2) { &printuntil($i, $i, 0, "Preview Appearance", 1); } print "
    \n"; print "Board Manager: Preview Appearance
    \n"; print "

    This is the color of normal text.

    \n"; print "This is the color of an unvisited link.

    \n"; print "This is the color of a visited link.

    \n"; print "This is the color of an active link.

    \n"; print "(Note that the background of this page is the background color you have selected. The horizontal rules on this page are identical to those that will be displayed on pages.)

    Also note that some text on the board is displayed as size -1 (one size smaller than the specified base font size). This is a preview of that kind of text.
    \n"; print "


    \n"; print "
    \n"; print "\n"; print "\n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    $fsBackground:
    $fsText:
    $fsLink:
    $fsVisited Link:
    $fsActive Link:
    $fsFont Face:
    $fsFont Size:
    $fsBackground Image:
    \n

    \n"; for ($i = 9; $i <= 13; $i += 2) { &printuntil($i, $i, 0, "Board Appearance Preview", 1); } print "\n"; print "\n"; print "

    \n"; print "\n"; print "\n"; print "
    \n"; for ($i = 15; $i <= 17; $i += 2) { &printuntil($i, $i, 0, "Board Appearance Preview", 1); } } #---SEPARATOR---# #REQ:prepare_navbar #REQ:extract_lastmodified #REQ:change_layout sub change_board_colors { local ($bgcolor,$text,$link,$vlink,$alink,$face,$size,$background) = @_; &lock("*"); $image = $background; local ($addfile, $template, @topics, @mainmessage); $colorstr = join("\t", $bgcolor, $text, $link, $vlink, $alink, $background, $size, $face); local (@topic, @group_list, $line); open (TOPFILE, "$html_dir/messages/board-topics.html"); @topfile = ; close (TOPFILE); $flag = 0; undef (@topics); undef (@mainmessage); foreach $line (@topfile) { if ($line =~ m||) { $flag = 1; push (@mainmessage, $line); } elsif ($line =~ m||) { $flag = 0; push (@mainmessage, $line); } elsif ($flag == 1) { push (@mainmessage, $line); } } open (FILExx, "$admin_dir/newpage.txt"); @file = ; close (FILExx); @mainfile = @file; if (!(grep(//, @file))) { &error_message("Page Regeneration Error", "Template file (newpage.txt) has been corrupted; regeneration stopped for safety reasons."); } $str = "$titlej Topics"; $timestr = ""; open (TOPFILE, ">$html_dir/messages/board-topics.html"); $flag = 0; $flag2 = 0; foreach $line (@file) { if ($line =~ //) { $flag = 1; } elsif ($flag == 1) { while ($line =~ /\$(\w+)/) { $this = eval "\$$1"; $line = $` . $this . $'; } if ($line =~ //) { print TOPFILE "
    \n"; print TOPFILE "\n"; print TOPFILE "
    \n"; $flag2 = 1; } elsif ($flag2 == 1 && $line =~ m||) { $flag2 = 0; } elsif ($line =~ m||) { $flag2 = 1; } elsif ($line =~ m||) { $flag2 = 0; } elsif ($line =~ m||) { $flag2 = 1; print TOPFILE "
    \n"; $tstr = join("", @topics); print TOPFILE $tstr; print TOPFILE "\n"; } elsif ($line =~ m||) { $flag2 = 0; } elsif ($line =~ m||) { $flag2 = 1; } elsif ($line =~ m||) { $flag2 = 0; } elsif ($line =~ m||) { $flag2 = 1; print TOPFILE "
    \n"; $tstr2 = join("", @mainmessage); print TOPFILE $tstr2; } elsif ($line =~ m||) { $flag2 = 0; } elsif ($line =~ m||) { $flag2 = 1; } elsif ($line =~ m||) { $flag2 = 0; } elsif ($line =~ m||) { $flag2 = 1; } elsif ($line =~ m||) { $flag2 = 0; } elsif ($line =~ m|| && $flag2 == 2) { $flag2 = 0; } elsif ($flag2 == 0) { print TOPFILE $line; } } } close (TOPFILE); foreach $linettt (@topics) { if ($linettt =~ m|; close (FILEx); } else { @newpgfile = @mainfile; } $privpub = "private"; open (USER, "$admin_dir/users.txt"); @users = ; close (USER); @valid = grep(/:$owner\n?$/, @users); $privpub = "public" if grep(/^PUBLIC:/, @valid); open (FILExx, "$admin_dir/addmessage-$privpub.txt"); @addfile = ; close (FILExx); foreach $line_2 (@addfile) { $line_2 =~ s///g; $line_2 =~ s//$script_url\/board-post.$cgi_extension/g; } $addfile = join("\n", @addfile); $addfile .= "\n"; $template = join("\n", @newpgfile); $template .= "\n"; ®enerate_page($1, $1, $1, $template, $addfile); } } &unlock("*"); } sub regenerate_page { local ($topic, $page, $my_parent, $template, $addfile) = @_; local (@head, @sublist, $line); local ($head1, $color1, $lm1, $sublist1, $about1, $about_src1, $message1, $message_src1) = &get_page($topic, $page); @head = split(/\n/, $head1); @sublist = split(/\n/, $sublist1); if (!grep(/\n"; } foreach $line (@sublist) { if ($line =~ m||) { ®enerate_page($topic, $1, $page, $template, $addfile); } if ($line =~ m|$html_url/messages/(\d+)/(\d+).$ext#(\w+)|) { $line = join("", $`, "$html_url/messages/$1/$2.$ext?$3", $'); } } $sublist1 = join("\n", @sublist); &set_page($topic, $page, $head1, $colorstr, $lm1, $sublist1, $about1, $about_src1, $message1, $message_src1, $template, $addfile); } #---SEPARATOR---# #REQ:get_date_time sub change_board_toppage { local ($boldon, $groupon, $dateon) = @_; &lock("$admin_dir/frontpage_conf.txt"); open (FILE_c, ">$admin_dir/frontpage_conf.txt"); print FILE_c "Bold=$boldon\n"; print FILE_c "Group=$groupon\n"; print FILE_c "Date=$dateon\n"; close (FILE_c); &unlock("$admin_dir/frontpage_conf.txt"); &lock("$html_dir/messages/board-topics.html"); open (TOPFILE, "$html_dir/messages/board-topics.html"); @topfile = ; close (TOPFILE); foreach $line_top (@topfile) { if ($line_top =~ m||) { $num = $1; $lt = $line_top; $file = "$html_dir/messages/$num/$num.$ext"; $lmtime = (stat $file)[9]; if ($lt =~ m|.*(.*)|) { $dt = $1; } else { $dt = ""; } &extract($file); $lm = (&get_page($num, $num))[2]; $line_top = "
  • "; $line_top .= "" if $boldon; $line_top .= "$topic_name"; $line_top .= "" if $boldon; $line_top .= " (\u$owner)" if $groupon; if ($dateon && $lmtime != 0 && $dt eq "") { $line_top .= " " . &get_date_time('short', $lmtime) . ""; } elsif ($dateon) { $line_top .= " $dt"; } $line_top .= "

    \n"; } } open (TOPFILE, ">$html_dir/messages/board-topics.html"); print TOPFILE @topfile; close (TOPFILE); &unlock("$html_dir/messages/board-topics.html"); }