--- capa/capa51/Discuss/Ver1.3/Attic/capadiscuss 1999/10/13 18:45:28 1.2 +++ capa/capa51/Discuss/Ver1.3/Attic/capadiscuss 2000/01/05 21:11:15 1.6 @@ -1,13 +1,15 @@ #!/usr/ucb/perl # # CAPA Discussion Forum -# version 1.3 +# version 1.3.0 # # Michigan State University # Department of Physics and Astronomy # # Ryan J. Shaltry # tech4@msue.msu.edu +# Guy Albertelli +# albertel@msu.edu print "Content-type: text/html\n\n"; @@ -102,8 +104,9 @@ exit; ####################### sub GetSetList { opendir(DDIR,"$capadir/$class/discussion"); - @sets = grep(/[0-9]/,sort(readdir(DDIR))); + @sets = grep(/^[0-9]+$/,sort(readdir(DDIR))); closedir(DDIR); + if ($debug) {print "
Sets:". @sets ."
\n";} } sub SetListHeader { @@ -116,11 +119,40 @@ sub SetListHeader { $pdset .= "\n"; } +sub GetInfoList { + local(@temp,@alldir,@setdir); +# if ($debug) {print "
GetInfoList
";} + opendir(DDIR,"$capadir/$class/discussion"); + @alldir = sort(grep(/.info$/,readdir(DDIR))); + closedir(DDIR); + + opendir(FORUM,"$capadir/$class/discussion/$setid"); + @setdir = sort(grep(/.info$/,readdir(FORUM))); + closedir(FORUM); + + foreach $file(@setdir) { @setdir2 = (@setdir2,"$setid/$file"); } + @infofiles = (@alldir,@setdir2); + $infostring = ""; +# if ($debug) {print "
GetInfoList" . @infofiles."
";} + foreach $infofile(@infofiles) { +# if ($debug) {print "
GetInfoList" . $infofile."
";} + @temp = reverse split /\//, $infofile; + $infodesc = $temp[0]; + $infodesc =~ s/.info//g; + $infodesc =~ s/_/ /g; + $infostring .= &InfoButtonHTML; + } + if ($infostring ne "") { + # $infostring = "" . $infostring; + } +# if ($debug) {print "
GetInfoList" . $infostring."
";} +} + sub NewSet { &Log("NewSet"); if($setid <= $psetid) { #grab capaid - if ($debug) {print "ViewSet
";$BenchmarkTa = new Benchmark;} + if ($debug) {print "NewSet
";$BenchmarkTa = new Benchmark;} @allcapaid = `allcapaid -s $setid -e $setid -stu $snum -c $capadir/$class -i`; $capaid = $allcapaid[2]; @@ -131,7 +163,9 @@ if($debug) {$BenchmarkTb = new Benchmark return; } + if ($debug) { print "
GetSetList\n"; } &GetSetList; + if ($debug) { print "
EndGetSetList\n"; } &SetListHeader; &NewSetHTML; #exit; @@ -148,20 +182,13 @@ sub ViewSet { $capasbin = "$capasbin/$teachdir/capasbin"; &SetJumpBox; + $backfunction="viewset"; + &GetInfoList; + opendir(FORUM,"$capadir/$class/discussion/$setid"); @dir = sort(readdir(FORUM)); closedir(FORUM); - @infofiles = grep(/.info/,@dir); - $infostring = ""; - $backfunction = "viewset"; - foreach $infofile(@infofiles) { - $infodesc = $infofile; - $infodesc =~ s/.info//g; - $infodesc =~ s/_/ /g; - $infostring .= &InfoButtonHTML; - } - foreach $i(@dir) { $probnum = &RemZero(substr($i,0,6)); $found[$probnum]++; @@ -268,6 +295,7 @@ sub ViewProblem { } if($msgcount eq "1") { + &GetInfoList; $postbutton = &ReplyButtonHTML; &ProblemJumpBox; &ViewProblemTopHTML; @@ -301,14 +329,15 @@ sub ViewProblem { $hidebutton = &UnHideButtonHTML; $messagenote = "Hidden by $hiddenuser on $hiddendate at $hiddentime from $hiddenaddr"; } - $message =~ s//>/g; +# $message =~ s//>/g; &ViewProblemGutsHTML; } } } if($msgfind eq "no") { + &GetInfoList; $postbutton = &PostNewButtonHTML; &ProblemJumpBox; &ViewProblemTopHTML; @@ -322,7 +351,8 @@ sub ViewProblem { } sub ViewInfoFile { - open(INFOFILE,"$capadir/$class/discussion/$setid/$file"); + &Log("InfoFile"); + open(INFOFILE,"$capadir/$class/discussion/$file"); @file = ; closedir(INFOFILE); @@ -554,10 +584,24 @@ sub WriteMsg { $filename = shift(@_); # add sr to grab e-mail address of user + + #


      • 1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1, BR=>1, TT=>1, STRONG=>1, + BLOCKQUOTE=>1, DIV=>1, IMG=>1); + $message = $form{'message'}; - $message =~ s/\n\r\n/

        /g; + + $message =~ s/((\n\r)|(\n))\n/

        /g; $message =~ s/\n/
        /g; + $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ + {($html{uc($2)}&(length($1)<1000))?"\<$1":"\<$1"}/ge; + $message =~ s/(\]*)\>/ + {($html{uc($2)}&(length($1)<1000))?"$1\>":"$1\>"}/ge; + +# $message =~ s//>/g; + # check if posted anonymously if($form{'ANONYMOUS'} eq "yes") { $username = "Anonymous|$username"; @@ -658,7 +702,7 @@ sub ValidateUser { if($valid eq "no") { &InvalidVarsHTML; } # check w/ allcapaid program - @allcapaid = `allcapaid51 -s $setid -e $setid -stu $snum -c $capadir/$class -i -checkopen`; + @allcapaid = `allcapaid -s $setid -e $setid -stu $snum -c $capadir/$class -i -checkopen`; chop $allcapaid[2]; chop $allcapaid[2]; @@ -721,17 +765,8 @@ sub ProblemJumpBox { } sub SetJumpBox { - opendir(DDIR,"$capadir/$class/discussion"); - @sets = grep(/[0-9]/,sort(readdir(DDIR))); - closedir(DDIR); - - $pdset = ""; + &GetSetList; + &SetListHeader; } sub AddZero { @@ -772,7 +807,7 @@ sub form_info { foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); - + if ($name eq "message") {$allow_html=1;} else {$allow_html=0;} # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; @@ -829,7 +864,7 @@ sub Log { &Lock("lock.file"); open(LOG,">>$capadir/$class/discussion/logs/access.log"); - print LOG "$snum|$capaid|$username|$email|$logmsg|$setid|$probnum|$HyphenDate|$Time\n"; + print LOG "$snum|$capaid|$username|$email|$logmsg|$setid|$probnum|$HyphenDate|$Time|$file\n"; close(LOG); &Unlock("lock.file"); }