--- capa/capa51/Discuss/Ver1.3/Attic/capadiscuss 1999/12/16 22:08:57 1.5 +++ capa/capa51/Discuss/Ver1.3/Attic/capadiscuss 2000/01/31 18:34:12 1.7 @@ -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"; @@ -170,6 +172,7 @@ if($debug) {$BenchmarkTb = new Benchmark } sub ViewSet { + local($hidden); if ($debug) {print "InsideViewSet
";$BenchmarkTa = new Benchmark;} &Log("ViewSet"); &CheckAdmin; @@ -213,6 +216,7 @@ if($debug) {$BenchmarkTb = new Benchmark $col = 1; for($probnum=1; $probnum<=$maxprobs; $probnum++) { + $hidden=0; if($col eq "1" && $probnum > $col1size && $bigtable eq "yes") { $col = 2; &ViewSetEndColHTML; @@ -224,13 +228,19 @@ if($debug) {$BenchmarkTb = new Benchmark closedir(MSG); foreach $msg(@msgs) { if(&RemZero(substr($msg,0,6)) eq $probnum) { - push(@good,$msg); + &OpenMsg("$capadir/$class/discussion/$setid/$msg"); + if(!($status eq "hidden" && $validadmin ne "yes")) { + push(@good,$msg); + } else { $hidden++; } } } - - &OpenMsg("$capadir/$class/discussion/$setid/$good[$#good]"); - $lastpost = "$date at $time"; - $posts = $found[$probnum]; + $posts = $found[$probnum]-$hidden; + if ($posts >0) { + &OpenMsg("$capadir/$class/discussion/$setid/$good[$#good]"); + $lastpost = "$date at $time"; + } else { + $lastpost = "--"; + } } else { $lastpost = "--"; @@ -582,12 +592,24 @@ sub WriteMsg { $filename = shift(@_); # add sr to grab e-mail address of user + + #


      • + %html=(B=>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//>/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"; @@ -646,6 +668,7 @@ sub CheckAdmin { last; } } + if ($debug) { print "Admin Sections: ".$adminsection;} @adminsections = split(/\,/,$adminsection); for ($asection=0; $asection <= $#adminsections; $asection++) { $adminsections[$asection]=&RemZero($adminsections[$asection]) @@ -657,10 +680,12 @@ sub CheckAdmin { $snum =~ tr/a-z/A-Z/; LINE: foreach $line(@classl) { - ($course,$coursenum,$section,$stunum,$a) = split(/\ +/,$line); + $section= substr $line, 10, 3; + $stunum= substr $line, 14, 9; $stunum =~ tr/a-z/A-Z/; if ( $stunum ne $snum ) { next LINE;} $section = &RemZero($section); + if ($debug) {print "
        ".$stunum."Is in section:".$section."
        ";} foreach $asection(@adminsections) { if($section eq $asection ) { $validadmin = "yes"; @@ -688,7 +713,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]; @@ -793,7 +818,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; @@ -813,6 +838,8 @@ sub GetDateTime { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time); $mon++; + $year=$year+1900; + if ($hour < 12) { $AMPM = "AM"; }