$printLB = 123; $marker = 0; $instr = trim($instr); $ins_dir = "$INS_PATH/$instr/"; $placeHolder= 0; $found = "no"; $file = "$ins_dir$crsid"; $header1 = ''; $header2 = ''; if(file_exists("$INC_PATH/l.php")) include "$INC_PATH/l.php"; else error("ldap"); $searchFilter = '&(uid='. $instr . ')(objectclass=nmu)'; $resultEntry = searchLDAP($searchFilter); if($resultEntry){ $SSN = $resultEntry[0] ['ssn'] [0]; } else { die("error looking up SSN"); } if (!($fp = fopen($file, "r"))) die("Unable to open the input file."); while (!feof($fp)) { $buffer = fgets($fp, 30000); $csn = substr($crsid,0,4); $line = trim(substr($buffer,16,27)); $soc = trim(substr($buffer,30,13)); $search = trim("COURSE SEQUENCE $csn"); $firstBlock = "AVERAGE NUMBER RIGHT"; $lastBlock = "POINTS IN TEST"; $searchLB = trim(substr($buffer,35,31)); if ($placeHolder == 4){ studentFound($instr,$header1,$header2,$firstLB,$name,$theRest,$lastLB,$printLB); die(); } elseif(strcmp($soc,$SSN) == 0) { $name = trim(substr($buffer,10,15)); $theRest = substr($buffer,43,49); $placeHolder = 2; $found = "yes"; }elseif($placeHolder == 2){ if(strcmp($searchLB,$firstBlock) == 0){ $firstLB = trim(substr($buffer,35,36)); $marker = 3; } elseif(strcmp($searchLB,$lastBlock) == 0 ){ $lastLB = trim(substr($buffer,35,36)); $placeHolder = 4; } elseif($marker == 3){ if ($printLB == 123){ $printLB = trim(substr($buffer,35,36)); } else { $tempLB = trim(substr($buffer,35,36)); $printLB = $printLB . "\n" . $tempLB; } } }elseif(strcmp($line,$search) == 0){ $placeHolder = 1; $header1 = substr($buffer,1,82); } elseif($placeHolder == 1) { $placeHolder= 0; $header2 = substr($buffer,1,82); } } if ($found == "no"){ studentNotFound($instr,$header1,$header2); } function studentFound($instr,$header1,$header2,$firstLB,$name,$theRest,$lastLB,$printLB){ echo "\n"; echo "
"; echo ""; echo $header1 . ""; } function studentNotFound($instr,$header1,$header2) { echo "\n"; echo "
"; echo $header2 . "\n"; echo " NUMBER NUMBER NUMBER PERCENT\n"; echo " STUDENT NAME RIGHT WRONG OMITTED SCORE\n\n"; echo "$name $theRest \n
\n"; echo "" . $firstLB. "\n"; echo $printLB . "\n"; echo $lastLB. "\n"; echo "
"; echo ""; echo $header1 . "\n
"; echo $header2 . "\n"; echo "