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 : C:/nginx/html/Admin/Class/ |
Upload File : |
<? // Admin/Class/ClassAddFormParse.phpinc debugTrackBegin(); #d_On(); $error = false; $f_error = ''; $f_classId = formValue('classId'); $f_courseId = formValue('courseId'); $f_parseDataArray = explode("\n",formValue('parseData')); $dataLineCount = 0; // Valid Bldgs $Bldgs = array("Main", "A", "B", "C", "D", "F", "H", "L", "On", "Off", "S"); if (d_O()) { /* */ #d_Var("$_POST",$_POST); d_Var('$f_classId',$f_classId); d_Var('$f_courseId',$f_courseId); d_Var('$f_parseDataArray',$f_parseDataArray); /* */ } $classDataArray = array(); $classIndex = -1; $previousIndex = 0; setState('Begin'); for ($index=1; $index<=count($f_parseDataArray); $index++) { $parseLine = trim($f_parseDataArray[$index-1]); if (d_O()) d_Var('$parseLine',$parseLine,'d'); if ( $parseLine != '' ) { // Parse this line. $parseLineNoSpaces = str_replace(" ","",$parseLine); $tokens = explode(" ",str_replace("\t"," ",$parseLine)); // Trim the tokens. for ($tokensIndex=0; $tokensIndex<count($tokens); $tokensIndex++) { $tokens[$tokensIndex] = trim($tokens[$tokensIndex]); } foreach ( $tokens as $tokenIndex => $token ) { if ( $token == '' ) unset($tokens[$tokenIndex]); } $tokens = array_values($tokens); if (d_O()) d_Line("parseLine=$parseLine",'h'); if (d_O()) d_Var('tokens',$tokens,'l'); #if (d_O()) d_Var('tokens',$tokens); $tokenCount = count($tokens); for ($tokensIndex=0; $tokensIndex<$tokenCount; $tokensIndex++) { $token = $tokens[$tokensIndex]; if (d_O()) d_Line("State <span class=\"bold\">[$state]</span> line#$index token#$tokensIndex [".$token."]",'h'); switch ($state) { case 'Begin': // Look for RCclassId. if ( $token == '' ) { // Skip blank token } else { // Parse RCclassId $is_RCclassId = preg_match("/[0-9]{6}/",$token); d_Var('is_RCclassId',$is_RCclassId,'aA'); if ($is_RCclassId) { // RCclassId found. $classIndex++; if (d_O()) d_Line("Class begin [$classIndex]",'/oi'); $classDataArray[$classIndex]['RCclassId'] = $token; setState('CourseNumber'); d_Var('RCclassId found',$classDataArray[$classIndex]['RCclassId'],'a'); $classDataArray[$classIndex]['classDays'] = array(); $f_classDays = ''; $classDataArray[$classIndex]['classDateStart'] = array(); $classDataArray[$classIndex]['classDateStop'] = array(); $classDataArray[$classIndex]['OffCampus'] = false; $classDataArray[$classIndex]['Online'] = false; $classDataArray[$classIndex]['classTimeStart'] = array(); $classDataArray[$classIndex]['classTimeStop'] = array(); $classDataArray[$classIndex]['classRoomBldg'] = array(); $classDataArray[$classIndex]['classRoomNumber'] = array(); $classDataArray[$classIndex]['classInstructor'] = array(); } else { // Check for additional class dates, days, etc... if ( preg_match("$[0-9]{2}/[0-9]{2}/[0-9]{2}$",$token) ) { // Date found. // Move to DateBegin with same token. d_Line('Move to DateBegin with same token','w'); $tokensIndex--; $dataLineFinishCount = 0; setState('DateBegin'); } else { $error = true; $f_error .= "Line $index ".'RCclassId not found ('.$token.').<br>'; #d_Line($f_error); setState('Error'); } } } break; case 'CourseNumber': // Look for CourseNumber if ( $token != '' ) { // Parse for CourseNumber $is_CourseNumber = preg_match("/[A-Za-z]{3,4}[0-9]{2,4}/",$token); if (d_O()) d_Var('is_CourseNumber',$is_CourseNumber,'aA'); if ( $is_CourseNumber ) { // CourseNumber found. $classDataArray[$classIndex]['courseNumber'] = $token; d_Var('CourseNumber found',$classDataArray[$classIndex]['courseNumber'],'a'); setState('SectionNumber'); } else { $error = true; if ( preg_match("/[A-Za-z]{3,4}/",$token) ) { // Course department part found. $tokensIndexNext = $tokensIndex + 1; if ( preg_match("/[0-9]{2,4}/",$tokens[$tokensIndexNext]) ) { // Course number part found. $classDataArray[$classIndex]['courseNumber'] = $token.$tokens[$tokensIndexNext]; d_Var('courseNumber found',$classDataArray[$classIndex]['courseNumber'],'a'); $tokensIndex = $tokensIndexNext; $error = false; setState('SectionNumber'); } } if ( $error ) { $f_error .= "Line $index ".'CourseNumber not found ('.$token.').<br>'; setState('Error'); } } } else { // Skip this token. } break; case 'SectionNumber': // Look for SectionNumber if ( $token != '' ) { // Parse for SectionNumber $is_SectionNumber = preg_match("/[0-9]{1,3}/",$token); if (d_O()) d_Var('is_SectionNumber',$is_SectionNumber,'aA'); #if (d_O()) d_Var('preg_match("/[0-9]{1,3}/",'.$token.')',preg_match("/[0-9]{1,3}/",$token)); if ( $is_SectionNumber ) { // SectionNumber found. $classDataArray[$classIndex]['classSection'] = $token; d_Var('SectionNumber found',$classDataArray[$classIndex]['classSection'],'a'); // Move to DateBegin. $dataLineFinishCount = 0; setState('DateBegin'); #$classDataArray[$classIndex]['classDateStart'] = array(); #$classDataArray[$classIndex]['classDateStop'] = array(); // Skip to end of parseLine. //$tokensIndex = $tokenCount+1; // Skip to end of line. } else { $error = true; $f_error .= "Line $index ".'SectionNumber not found ('.$token.').<br>'; setState('Error'); } } else { // Skip this token. } break; case 'DateBegin': // Look for date lines. #d_Var('$tokensIndex',$tokensIndex); #d_Var('strstr('.$token.",'-')",strstr($token,'-')); if ( $token != '' ) { // Parse DateBegin. $is_DateBegin = preg_match("$[0-9]{2}/[0-9]{2}/[0-9]{2}$",$token); if (d_O()) d_Var('is_DateBegin',$is_DateBegin,'aA'); if ( $is_DateBegin ) { // DateBegin found. $startDate = $token; list($startMonth,$startDay,$year) = explode('/',$startDate); $year = date('Y'); $classDateStart = valid_date($year.'-'.$startMonth.'-'.$startDay); $classDataArray[$classIndex]['classDateStart'][] = $classDateStart; d_Var('DateBegin found',$classDataArray[$classIndex]['classDateStart'],'a+'); setState('DateEnd'); } else { // Skip this token. } } else { // Skip this token. } break; case 'DateEnd': // Look for date lines. #d_Var('$tokensIndex',$tokensIndex); #d_Var('strstr('.$token.",'-')",strstr($token,'-')); if ( $token != '' ) { // Parse DateEnd. $is_DateEnd = preg_match("$[0-9]{2}/[0-9]{2}/[0-9]{2}$",$token); if (d_O()) d_Var('is_DateEnd',$is_DateEnd,'aA'); if ( $is_DateEnd ) { // DateBegin found. $stopDate = $token; list($stoptMonth,$stopDay,$year) = explode('/',$stopDate); $year = date('Y'); $classDateStop = valid_date($year.'-'.$stoptMonth.'-'.$stopDay); $classDataArray[$classIndex]['classDateStop'][] = $classDateStop; d_Var('DateEnd found',$classDataArray[$classIndex]['classDateStop'],'a+'); setState('Days'); //$classDataArray[$classIndex]['classDays'] = array(); } else { // Skip this token. } } else { // Skip this token. } break; case 'Days': // Days may be more than one token. // Look for Days. // If token == '-' there is no days or time and these can be skipped. if ( $token == '-') { // There are no days or times. if (d_O()) d_Line("There are no days or times.",'A'); $classDataArray[$classIndex]['classDays'][] = ''; $classDataArray[$classIndex]['classTimeStart'][] = ''; $classDataArray[$classIndex]['classTimeStop'][] = ''; #d_Line('Move to Bldgs','i'); // Move to Bldgs $dataLineCount = 0; setState('Bldgs'); } else { // See if we are done with Days. if ( !in_array(substr($token,0,1),array('0','1','2','3','4','5','6','7','8','9')) ) { // Is this a day? // Yes, it is a day $f_classDays = $f_classDays.$token; if (d_O()) d_Var('$f_classDays',$f_classDays); $thisDayError = ''; if ( preg_match_all("/[Uu]/",$f_classDays,$matches) > 1 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has more than one Sunday (U).<br>'; } if ( preg_match_all("/[Mm]/",$f_classDays,$matches) > 1 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has more than one Monday (M).<br>'; } if ( preg_match_all("/[Tt]/",$f_classDays,$matches) > 1 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has more than one Tuesday (T).<br>'; } if ( preg_match_all("/[Ww]/",$f_classDays,$matches) > 1 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has more than one Wednesday (W).<br>'; } if ( preg_match_all("/[Hh]/",$f_classDays,$matches) > 1 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has more than one Thursday (H).<br>'; } if ( preg_match_all("/[Ff]/",$f_classDays,$matches) > 1 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has more than one Friday (F).<br>'; } if ( preg_match_all("/[Ss]/",$f_classDays,$matches) > 1 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has more than one Saturday (S).<br>'; } if ( preg_match_all("/[^UuMmTtWwHhFfSs]/",$f_classDays,$matches) > 0 ) { $thisDayError .= 'Line '.$index.' Days ('.$f_classDays.') has non-day characters (UMTWHFS).<br>'; } } else { // Is this a day? // No, it must be a time. if ( $thisDayError == '' ) { // Save days. $classDataArray[$classIndex]['classDays'][] = $f_classDays; if (d_O()) d_Var("Days found",$classDataArray[$classIndex]['classDays'],'a+'); $dataLineCount += 1; } $f_classDays = ''; // Move to Times with same token. d_Line('Move to Times with same token','w'); $tokensIndex--; $dataLineFinishCount = 0; setState('Times'); } // Is this a day? } break; case 'Times': // Look for Times. if ( $token == '-' || $token == 'Arranged' ) { // The time is - or Arranged. if ( $token == '-' ) $token = ''; $classDataArray[$classIndex]['classTimeStart'][] = $token; $classDataArray[$classIndex]['classTimeStop'][] = ''; if (d_O()) d_Var("classTimeStart",$token); if (d_O()) d_Var("classTimeStop",''); $dataLineCount += 1; } else { // Time found. $time1 = trim($token); $tokensIndex++; $token = $tokens[$tokensIndex]; $time1 .= trim($token); d_Var('$time1',$time1,''); if ( valid_time($time1) ) { // Save start time. $classDataArray[$classIndex]['classTimeStart'][] = valid_time($time1); if (d_O()) d_Var("Times Start",$classDataArray[$classIndex]['classTimeStart'],'a+'); $tokensIndex++; $tokensIndex++; $token = $tokens[$tokensIndex]; $time2 = trim($token); $tokensIndex++; $token = $tokens[$tokensIndex]; $time2 .= trim($token); d_Var('$time2',$time2,''); if ( valid_time($time2) ) { if ( strtotime(valid_time($time1)) < strtotime($time2) ) { // Save stop time $classDataArray[$classIndex]['classTimeStop'][] = valid_time($time2); if (d_O()) d_Var("Times Stop",$classDataArray[$classIndex]['classTimeStop'],'a+'); $dataLineCount += 1; // Move to Bldgs $dataLineCount = 0; setState('Bldgs'); } else { // Start after stop. setState('Error:'.__LINE__); $error = true; $f_error .= 'Line '.$index.' Start time ('.$times[0].') is not before Stop time ('.$time2.').<br>'; } // if ( strtotime($f_classTimeStartArray[$index-1]) < strtotime($f_classTimeStop) ) } else { // This is not a valid TimeStop. $error = true; $f_error .= 'Line '.$index.' Stop time ('.$time2.') is not a valid time.<br>'; setState('Error'); } } else { // This is not a valid TimeStart. $error = true; $f_error .= 'Line '.$index.' Start time ('.$time1.') is not a valid time.<br>'; setState('Error'); } } break; case 'Bldgs': // Look for Bldgs. if ( $token == 'ON' ) { // Is the Bldg ON? // Move to next token. $tokensIndex++; $token2 = $tokens[$tokensIndex]; if ( $token2 == 'Online' ) { $classDataArray[$classIndex]['Online'] = true; $classDataArray[$classIndex]['classRoomBldg'][] = ''; // Move to Instructors $dataLineCount = 0; setState('Instructors'); } else { // This is not a valid Bldgs. $error = true; $f_error .= 'Line '.$index.' Bldgs ('.$token.' '.$token2.') is not a valid Bldgs.<br>'; setState('Error'); } } elseif ( $token == 'OFF' ) { // Is the Bldg OFF? // Move to next token. $tokensIndex++; $token2 = $tokens[$tokensIndex]; if ( $token2 == 'CAMPUS' ) { $classDataArray[$classIndex]['OffCampus'] = true; $classDataArray[$classIndex]['classRoomBldg'][] = ''; // Move to Instructors $dataLineCount = 0; setState('Instructors'); } else { // This is not a valid Bldgs. $error = true; $f_error .= 'Line '.$index.' Bldgs ('.$token.' '.$token2.') is not a valid Bldgs.<br>'; setState('Error'); } } else { // Is the Bldg ON or OFF? // No, set Bldg. $classDataArray[$classIndex]['classRoomBldg'][] = $token; if (d_O()) d_Var("Bldgs found",$classDataArray[$classIndex]['classRoomBldg'],'a+'); // Move to Rooms $dataLineCount = 0; setState('Rooms'); } break; case 'Rooms': // Look for Rooms. $classDataArray[$classIndex]['classRoomNumber'][] = $token; if (d_O()) d_Var("classRoomNumber",$classDataArray[$classIndex]['classRoomNumber'],'a+'); // Move to Instructors $dataLineCount = 0; setState('Instructors'); #$classDataArray[$classIndex]['classInstructor'] = array(); break; case 'Instructors': // Look for Instructors. $f_Instructor = $token; if ( $f_Instructor !== 'Staff') { if ( stripos($f_Instructor,',') !== false ) { $tokensIndex++; $token2 = $tokens[$tokensIndex]; $f_Instructor = $token.$token2; } $classDataArray[$classIndex]['classInstructor'][] = $f_Instructor; if (d_O()) d_Var("Instructors found",$classDataArray[$classIndex]['classInstructor'],'a+'); $tokensIndex++; } else { } // Begin again if (d_O()) d_Var('End class parse at ',$index-1); setState('Begin'); break; case 'Error': // Found an error. $errorToken = $tokensIndex; $errorLine = $index; // Skip to end of parseLine. $tokensIndex = $tokenCount+1; // Skip to end of parseData. $index = count($f_parseDataArray)+1; break; default: if (d_O()) d_Var('$classDataArray',$classDataArray); $f_error = 'The state ('.$state.') is not programmed for parseLine('.$index.')='.$token.' <span class="pv_fl"> '.basename(__FILE__).':'.__LINE__.'</span><br>'.$parseLine; include('common/displayErrorsAndMessages.phpinc'); include('common/pageFooter.phpinc'); break; } // switch ($state) } // for ($tokensIndex=0; $tokensIndex<$tokenCount $tokensIndex++) } else { d_line("Blank line#$index skipped."); } $previousIndex = $index; } // for ($index=0; $index<count($f_parseDataArray); $index++) if (d_O()) echo "<br>\n"; if (d_O()) d_Var('$classDataArray',$classDataArray); d_Var('$error',$error); function setState($value) { $GLOBALS['state'] = $value; d_Line('$state set to '.$value,'i'); } // RCclassId // classSection // classDays // classTimeStart // classTimeStop // classRoomBldg // classRoomNumber // classInstructor debugTrackEnd(); ?>