#!/usr/bin/perl &parse_form; my($facts, $line, $count); my(@file); use CGI; use CGI::Carp qw(fatalsToBrowser); $query= new CGI; my($group, $level, $section,$level1, $section1,, $section2,$i, $j); my($head, $footer); ## Get cookies first $group = $query->cookie('group'); $level = $query->cookie('level'); $section = $query->cookie('section'); $level1=$level; $section1=$section; if ($section==5.5){ $section1=1; $level1++; $cookie1 = $query->cookie(-name=>'section', -value=>"$section1"); $cookie2 = $query->cookie(-name=>'level', -value=>"$level1"); print $query->header(-cookie=>[$cookie1,$cookie2]); }else{ print "Content-type:text/html\n\n"; } my($error); $error= <

Sherlock Error

Sorry.

There appears to be an error in your login id or password. Please check them and try again. If you are still unsuccessful, please contact the SiteMage.

EOT if($group eq ""){ print "$error"; exit; } ($second, $minute, $hour, $dayofmonth, $month, $year, $weekday, $dayofyear, $isdst)=localtime(time); $realmonth=$month+1; $year=2000; $facts="$FORM{'self'}"; if ($section>5.5){ $section=6; print ""; print ""; print "
"; open(g, "$group.txt"); flock(g,2); @file=; flock(g,8); close(g); $line=""; until($line eq "$level$section"){ $line=shift(@file); chomp($line); } $line=shift(@file); chomp($line); until($line eq "EOF"){ print "$line
"; $line=shift(@file); chomp($line); } print "
"; exit; } if($section==5.5){ $section=5; open(F, ">>$group.txt")||print "Could not open '$group.txt' for writing"; flock(F, 2); print F "$level$section\n"; print F "Level $level Self-Directed Learning\n"; print F "$facts\n"; print F "Posted at $hour:$minute $realmonth/$dayofmonth/$year\n"; print F " \n"; print F "
\n"; print F "EOF\n"; flock(F,8); close(F); $section2=5; open(G, ">>$level$section2.txt")||print "Could not open '$level$section.txt' for writing"; flock(G,2); @file=; print G "$group Self-Directed Learning\n"; print G "$facts\n"; print G "Posted at $hour:$minute $realmonth/$dayofmonth/$year\n"; print G " \n"; print G "
\n"; print G "EOF\n"; flock(G,8); close(G); ##increment section to current! $section=6; open(H, "log.txt"); flock(H,2); @file=; flock(H,8); close(H); open(I, ">log.txt"); flock(I, 2); foreach $line (@file){ chomp($line); ($groupname, $grouppass, $grouplevel, $groupsection)= split(/ /, $line); if ($groupname eq "$group"){ $groupsection=1; $grouplevel=$level1; print I "$groupname $grouppass $grouplevel $groupsection\n"; }else{ print I "$groupname $grouppass $grouplevel $groupsection\n"; } } flock(I,8); close(I); } $head= < Virtual Sherlock: PBL Board

EOT print "$head"; if ($section==6){ if ($level1!=4){ print ""; print "

Congratulations, You have just passed a level!

"; print ""; print "

You are now granted new casebook access! Good job Gumshoe.

"; }else{ print ""; print ""; print "

Congratulations, You have finished all of the casebooks. Log back on to see the solution!

"; print "

You are now granted complete casebook access! Great job Detective!

"; } } print "

You have the option of seeing either all of your old posts, or the posts of other groups of levels passed. The more you have posted, the more you can see. Simply check all the boxes of posts you want to see.

"; ##The Interactive Html## print "
"; print "

See postings by Casebook and Step


"; if ($level1==1){ print "

You must be on at least level two to view other group postings.

"; } if ($level1>=2){ print "

Complete Casebook 1 Entries

"; print "Casebook 1 Facts Casebook 1 Ideas/Hyotheses

Casebook 1 Learning Issues Casebook 1 Action Plans

Casebook 1 Self-Directed Learning

All Casebook 1 Group Postings
"; } if ($level1>=3){ print "

Complete Casebook 2 Entries

"; print "Casebook 2 Facts Casebook 2 Ideas/Hyotheses

Casebook 2 Learning Issues Casebook 2 Action Plans

Casebook 2 Self-Directed Learning

All Casebook 2 Group Postings
"; } if ($level1>=4){ print "

Complete Casebook 3 Entries

"; print "Casebook 3 Facts Casebook 3 Ideas/Hyotheses

Casebook 3 Learning Issues Casebook 3 Action Plans

Casebook 3 Self-Directed Learning

All Casebook 3 Group Postings
"; } print "

See all of your own postings.


"; print "All $group postings to date

"; print "

Logout of Sherlock Here

"; print ""; ####################### # Parse Form Subroutine sub parse_form { local($name,$value); # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # Remove any NULL characters, Server Side Includes $value =~ s/\0//g; $value =~ s///g; if ($allow_html != 1) { $value =~ s/<([^>]|\n)*>//g; } else { unless ($name eq 'body') { $value =~ s/<([^>]|\n)*>//g; } } $FORM{$name} = $value; } # Make sure that message fields do not exceed allowed value if ($enforce_max_len) { foreach $name (keys %max_len) { if (length($FORM{$name}) > $max_len{$name}) { if ($enforce_max_len == 2) { &error('field_size'); } else { $FORM{$name} = sprintf("%.$max_len{$name}s",$FORM{$name}); } } } } } exit;