# FILE: src-board-subs-1 #------------------------------------------------------------------------------- # 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:get_number #REQ:new_file #REQ:get_date_time sub add_topic { local ($new_topic, $new_topic_group, $privs, $templ, $topic_unformatted) = @_; local ($topic_number,$topic_name,$me_name,$num,$dt,$lm,@main,$group); local ($main_line,$str,$time,$posted, $num_local); $num_local = &get_number; &lock("$admin_dir/posting.txt"); open (FILE, ">>$admin_dir/posting.txt"); print FILE "$num_local:", ":$new_topic_group:$new_topic_group:\n" if $privs ne "public"; print FILE "$num_local:~:$new_topic_group:$new_topic_group:\n" if $privs eq "public"; close (FILE); &unlock("$admin_dir/posting.txt"); &lock("$admin_dir/security.txt"); open (FILE, ">>$admin_dir/security.txt"); print FILE "$num_local:~:::\n"; close (FILE); &unlock("$admin_dir/security.txt"); $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,"SublistCreateAbout") if $templ eq "yes"; &new_file($num_local,$num_local,0,$new_topic_group,$new_topic,"Sublist") if $templ ne "yes"; if ($templ) { $message_hold = $L{WELCOME_TO_TOPIC}; $message_hold =~ s/\%topicname/$topic_unformatted/g; ($message) = &ex('webtags', $message_hold); &ex('change_about_message', "$message_dir/$num_local/$num_local.$ext", $message_hold, $message); } open (BLANKINDEX, ">$message_dir/$num_local/index.html"); close (BLANKINDEX); chmod (0666, "$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


    \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 =~ //) { print MAIN_1 $line if ($1 != $remove_number); } elsif ($line =~ //) { print MAIN_1 $line if ($1 != $remove_number); } elsif ($line =~ //) { print MAIN_1 $line if ($1 != $remove_number); } else { print MAIN_1 $line; } } close (MAIN_1); &unlock("$message_dir/board-topics.html"); if (-e "$message_dir/$remove_number") { $dir = "$message_dir/$remove_number"; } else { $dir = "$secdir/$remove_number"; } opendir(DIR, $dir); while ($f = readdir(DIR)) { unlink ("$dir/$f"); } closedir(DIR); rmdir("$dir/$f"); &lock("$admin_dir/log.txt"); open (LOG, "$admin_dir/log.txt"); @LOG = ; close (LOG); foreach $line (@LOG) { ($what, $who, $when, $where) = split(/;/, $line); ($topic, $page) = split(/\//, $where); if ($topic == $remove_number) { $line = ""; } } @LOG = grep(/\S/, @LOG); open (LOG, ">$admin_dir/log.txt"); print LOG @LOG; close (LOG); &unlock("$admin_dir/log.txt"); &lock("$admin_dir/posting.txt"); open (POSTING, "$admin_dir/posting.txt"); @posting = ; close (POSTING); @posting = grep(!/^$remove_number:/, @posting); open (POSTING, ">$admin_dir/posting.txt"); print POSTING @posting; close (POSTING); &unlock("$admin_dir/posting.txt"); &lock("$admin_dir/postoptions.txt"); open (POSTING, "$admin_dir/postoptions.txt"); @posting = ; close (POSTING); @posting = grep(!/^$remove_number:/, @posting); open (POSTING, ">$admin_dir/postoptions.txt"); print POSTING @posting; close (POSTING); &unlock("$admin_dir/postoptions.txt"); &lock("$admin_dir/security.txt"); open (READING, "$admin_dir/security.txt"); @reading = ; close (READING); @reading = grep(!/^$remove_number:/, @reading); open (READING, ">$admin_dir/security.txt"); print READING @reading; close (READING); &unlock("$admin_dir/security.txt"); } #---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] if -e "$html_dir/messages/$topic_number_in/$topic_number_in.$ext"; $lmtime = (stat ("$secdir/$topic_number_in/$topic_number_in.$ext"))[9] if !-e "$html_dir/messages/$topic_number_in/$topic_number_in.$ext"; } $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; } elsif ($line =~ m||) { $descrarray{$1} = $line; } } 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}; print MAIN_1 $descrarray{$key}; $printed{$key} = 1; } foreach $key (keys(%printed)) { print MAIN_1 $newarray{$key} if $printed{$key} == 0; print MAIN_1 $descrarray{$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, $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 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" if $pro; print "\n" if $pro_license; 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, $smart) = @_; 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)