if (!$success) { $infoToSet[$itemColumn] = mb_convert_encoding($item, 'UTF-8', 'Windows-1252'); $table->setInfoArray($infoToSet); $success = $table->commit(); } if (!$success) { return false; } } return true; } $log = new Log('FetchClasses.txt', LOG_PATH); if (!is_dir(TEMP_PATH . '/FetchClasses')) { mkdir(TEMP_PATH . '/FetchClasses', 0755, true); } $curl = new YaleCurl(); $curl->setCookieFile(TEMP_PATH . '/FetchClasses/cookies.txt'); $curl->setAutoLoginParameters(CAS_USERNAME, CAS_PASSWORD); $mysqli = ProjectFunctions::createMysqli(); MysqliUtil::prepareMysqli($mysqli); foreach ($c['SUBJECT_CODES'] as $courseSubject) { if ($courseSubject === $startSubject) { $skipSubject = false; } if ($skipSubject) { continue; } $searchPost['ProgramSubject'] = urlencode($courseSubject); $log->write("Doing {$courseSubject}"); flush(); $page = $curl->fetchPageAndLogin(OCI_SERVER . '/oci/resultWindow.jsp', $searchPost, false, true);
$success = $table->commit(); if (!$success) { $infoToSet[$itemColumn] = mb_convert_encoding($item, 'UTF-8', 'Windows-1252'); $table->setInfoArray($infoToSet); $success = $table->commit(); } if (!$success) { return false; } } return true; } // Log $log = new Log('FetchRatings.txt', LOG_PATH); // YaleCurl $curl = new YaleCurl(); $cookieFileName = 'cookies'; if (!empty($startSubject)) { $cookieFileName = $startSubject; } if (!is_dir(TEMP_PATH . '/FetchRatings')) { mkdir(TEMP_PATH . '/FetchRatings', 0755, true); } $curl->setCookieFile(TEMP_PATH . "/FetchRatings/{$cookieFileName}.txt"); $curl->setAutoLoginParameters(CAS_USERNAME, CAS_PASSWORD); $mysqli = ProjectFunctions::createMysqli(); MysqliUtil::prepareMysqli($mysqli); $pid = getmypid(); foreach ($c['SUBJECT_CODES'] as $courseSubject) { if ($courseSubject === $startSubject) { $skipSubject = false;