# FILE: src-board-subs-8 # 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 change_layout { local ($topic_number,$page_number, $param) = @_; &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 (@head, $line); @head = split(/\n/, $head); foreach $line (@head) { if ($line =~ m|"; } } $head = join("\n", grep(/\S/, @head)); &set_page($topic_number, $page_number, $head, $color, $lm, $sublist, $about, $about_src, $message, $message_src); &unlock("$message_dir/$topic_number/$page_number.$ext"); } #---SEPARATOR---# sub write_source { local ($file, $index, $source) = @_; local ($src,@file,$line); $src = $source; $src =~ s//>/g; &lock($file); open (SRCFILE, $file); @file = ; close (SRCFILE); open (SRCFILE, ">$file"); foreach $line (@file) { if ($line =~ /|) { $type = $1; $numb = $4; $text = $5; $javastr = &JavaScript_prepare ($text); if ($type eq "Topic") { $topic_number = $numb; $navstr .= ""; $navstr .= "$text"; $navstr .= ": "; $lastone = $text; } elsif ($type eq "Level") { $navstr .= ""; $navstr .= "$text"; $navstr .= ": "; $lastone = $text; } } } chop ($navstr); chop ($navstr); while ($navstr !~ / $maxtest; } @splits = split(/,/, $v6, $maxtest); if ($maxtest != 1) { for ($i = 0; $i < ($maxtest - 1); $i++) { if (&remove_html($splits[$i]) ne $splits[$i]) { $nonest = $L{NONESTHTML}; $nonest =~ s/\%code/$v2/g; return ("!Error", "$nonest"); } } } $sc = scalar(@splits); while ($temp =~ m%\|(\d+)\|%) { $temp = join("", $`, $splits[($1)-1], $'); } if ($sc < $maxtest) { $wnarg = $L{WRONGNUMBEROFARGUMENTS}; $wnarg =~ s/\%code/$v2/g; $wnarg =~ s/\%required/$maxtest/g; $wnarg =~ s/\%your/$sc/g; return ("!Error", "$wnarg"); } if ($v2 eq "table" || $v2 eq "tablenb" || $v2 eq $L{TABLE_TAG} || $v2 eq $L{TABLE_NB_TAG}) { if ($temp =~ m|\t|) { $temp =~ s%\t%%g; } else { $temp =~ s%,%%g; } $temp =~ s%
%%g; } elsif ($v2 eq "list" || $v2 eq $L{LIST_TAG}) { $temp =~ s%
%
  • %g; } $text_in = join("", $v1, $temp, $v7); } else { $sc = $L{CODEDOESNOTEXIST}; $sc =~ s/\%code/$v2/g; return ("!Error", "$sc"); } } return ($messages, $text_in); } sub escape_input { local ($stringin) = @_; $_ = $stringin; s/&/&/g; s//\>/g; s/"/"/g; s/\\\\/\/g; s/\\\{/{/g; s/\\\}/}/g; s/\\,/,/g; s/\(/(/g; s/\)/)/g; s/\[/[/g; s/\]/]/g; s/\*/*/g; s/\+/+/g; s/\|/|/g; s/'/'/g; s/\r\n/\n/g; s/\r/\n/g; s/\n/
    /g; return $_; } sub read_tags { local ($cont_code) = @_; undef %char; undef %tags; undef $str; open (WTCONF, "<$webtags_conf_file"); while () { next if /^#/; s/^\s*//; s/\s*$//; if ($str) { if (m|\\$|) { $str .= $`; } else { if ($cont =~ m|^[cC]|) { $char{$code} = join("", $str, $_); } elsif ($cont >= $cont_code) { $tags{$code} = join("", $str, $_); $str_ = $tags{$code}; while ($str_ =~ m|!VAR\((\w+)\)!|) { $before = $`; $after = $'; $f = $1; $f = "\$" . $f; $f =~ s/"/\\"/g; $result = eval qq/"$f"/; $str_ = $before . $result . $after; } $tags{$code} = $str_; } $str = ""; next; } } if (($cont, $code, $act) = m|^([cC0-9])\s*(\S+)\s*(.*)|) { if ($act =~ m|\\$|) { $str = $`; next; } $code = &escape_input($code); if ($cont =~ m|^[cC]|) { $char{$code} = $act; } elsif ($cont >= $cont_code) { $tags{$code} = $act; $str_ = $tags{$code}; while ($str_ =~ m|!VAR\((\w+)\)!|) { $before = $`; $after = $'; $f = $1; $f = "\$" . $f; $f =~ s/"/\\"/g; $result = eval qq/"$f"/; $str_ = $before . $result . $after; } $tags{$code} = $str_; } } } close (WTCONF); } #---SEPARATOR---# sub change_private_and_public { local ($topic_number, $me_number, $text) = @_; local ($line, @file, @other, $other, $flag); &lock("$message_dir/$topic_number/$me_number.$ext"); open (FILE_PP, "$message_dir/$topic_number/$me_number.$ext"); @file = ; close (FILE_PP); @other = grep(//; &change_private_and_public ($topic_number, $1, $text); } $flag = 0; open (FILE_PP, ">$message_dir/$topic_number/$me_number.$ext"); foreach $line (@file) { if ($line =~ //) { print FILE_PP $line; print FILE_PP $text; $flag = 1; } elsif ($line =~ //) { print FILE_PP $line; $flag = 0; } elsif ($flag == 0) { print FILE_PP $line; } } close (FILE_PP); &unlock("$message_dir/$topic_number/$me_number.$ext"); } #---SEPARATOR---# sub page_manager_navbar { local ($topic_number, $page_number, $closing_text) = @_; local ($head) = &get_page($topic_number, $page_number); local ($number, $name, @array, %level, $str, @head, $topic_name, $line); print "
    \nPage Manager:\n"; @head = split(/\n/, $head); foreach $line (@head) { if ($line =~ m||) { $level{$1} = "$2:$3"; } elsif ($line =~ m||) { @array = ("$1:$2"); } } foreach $key (sort by_number keys(%level)) { push (@array, $level{$key}); } foreach $line (@array) { ($number,$name) = split(/:/, $line, 2); print ""; print "$name:\n"; } print "$closing_text\n
    \n\n"; } #---SEPARATOR---# #REQ:page_manager_navbar #REQ:build_graphical_tree sub graphic_browser_select { local ($topic_number, $page_number, $username) = @_; &header; $topic_number_hold = $topic_number; $page_number_hold = $me_number; print "Show All Subtopics\n"; print "$fs\n"; print "
    Show All Subtopics
    \n"; &page_manager_navbar($topic_number, $page_number, "Show All Subtopics"); print "Select a page to edit:

    \n"; open (TOPFILE, "$message_dir/board-topics.html"); @topfile = ; close (TOPFILE); $topic_numbers = ""; 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/$page_number_hold", "", "\n"; } #---SEPARATOR---# #REQ:build_graphical_tree #REQ:page_manager_navbar sub move_subtopic_form { local ($topic_number_hold, $me_number_hold, $username, $plural, $singular, $ref) = @_; &header; print "Move Subtopic$plural\n"; print "\n"; print "$fs

    Move Subtopic$plural
    \n"; &page_manager_navbar($topic_number_hold, $me_number_hold, "Move Subtopic$plural"); print "

    Select a destination for the subtopics$plural you wish to move by clicking on\n"; print "the folder icon ()\n"; print "next to the destination.

    \n"; open (TOPFILE, "$message_dir/board-topics.html"); @topfile = ; close (TOPFILE); $topic_numbers = ""; 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", "

    \n"; } #---SEPARATOR---# #REQ:prepare_navbar #REQ:moved_message_update_log #REQ:remove_message_from_log sub recurse { local ($topic_number,$page_number,$action,$parameter) = @_; local (@fileinput, $line, $filespec,$file); $file = "$message_dir/$topic_number/$page_number.$ext"; $file = "$message_dir/board-topics.html" if $topic_number == "top"; &lock("$file"); open (RFILE, $file); @fileinput = ; close (RFILE); foreach $line (@fileinput) { if ($line =~ //) { $topic_number = $1 if $file eq "$message_dir/board-topics.html"; &recurse ($topic_number, $1, $action, $parameter); } while ($line =~ m|; close (FILE_RECURSING); $/ = "\n"; $filespec =~ m|(\d+/\d+).$ext|; local ($new_where) = $1; local ($evalstr) = ""; while ($line =~ //g) { $evalstr .= "&moved_message_update_log ($1, '$new_where');"; } &unlock("$filespec"); eval $evalstr; } if ($recurse_action eq "delete") { local ($evalstr) = ""; local ($line, @filespecD); &lock($filespec); open (FILE2, $filespec); @filespecD = ; close (FILE2); $line = join("\n", @filespecD); while ($line =~ //g) { $evalstr .= "&remove_message_from_log ($1);"; } while ($line =~ m|; close (CHGRPFILE); open (CHGRPFILE, ">" . "$filespec"); foreach $chgrpline (@chgrpfile) { if ($chgrpline =~ //) { $chgrpline =~ s/$1/$parameter/g; print CHGRPFILE $chgrpline; } else { print CHGRPFILE $chgrpline; } } close (CHGRPFILE); &unlock($filespec); } elsif ($recurse_action =~ /rename:(.*)/) { local ($type) = $1; local (@renamefile, $renameline, $numren, $me_num, $java, $navflag); &lock($filespec); open (RENAMEFILE, "$filespec"); @renamefile = ; close (RENAMEFILE); local ($meflag) = 0; foreach $renameline (@renamefile) { if ($renameline =~ /\n"; } elsif ($renameline =~ /\n"; $meflag = 1; } elsif ($renameline =~ /
    / && $meflag == 1) { $renameline = "
    $newname

    \n"; } } $navbar = &prepare_navbar (@renamefile); $java = &JavaScript_prepare ($navbar); open (RENAMEFILE, ">$filespec"); foreach $renameline (@renamefile) { if ($renameline =~ //) { print RENAMEFILE "\n"; print RENAMEFILE "\n"; print RENAMEFILE "$navbar\n"; print RENAMEFILE "\n"; print RENAMEFILE "\n"; $navflag = 1; } elsif ($renameline =~ /window.defaultStatus = "(.*)"/) { print RENAMEFILE "\t\twindow.defaultStatus = \"$java\"\n"; } elsif ($renameline =~ //) { $navflag = 0; } elsif ($navflag == 0) { print RENAMEFILE $renameline; } } close (RENAMEFILE); &unlock($filespec); } } #---SEPARATOR---# #REQ:extract_colorsonly #REQ:get_date_time sub new_file { local ($topic_number, $page_number, $parent, $group, $pagetitle, $param) = @_; local ($head, $color, $lm, $sublist, $about, $about_src, $message, $message_src); local (@head, $line, $maxkey); $param = "Sublist" if $param eq ""; if ($parent == 0) { local ($bg, $tx, $li, $vl, $al, $fa, $si, $im) = &extract_colorsonly; $color = join("\t", $bg, $tx, $li, $vl, $al, $im, $si, $fa); $head = "\n"; $head .= "\n"; $head .= "\n"; } else { &lock("$message_dir/$topic_number/$parent.$ext"); ($head, $color, $lm, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic_number, $parent); @head = split(/\n/, $head); foreach $line (@head) { if ($line =~ m|\n"; $head .= "\n"; $head .= "\n"; $head .= "\n"; } $head .= "\n"; local ($timestr) = &get_date_time('long'); $timestr =~ s/\W//g; &set_page($topic_number, $page_number, $head, $color, $timestr, "", "", "", "", ""); }