# HG changeset patch # User Matti Hamalainen # Date 1440404392 -10800 # Node ID 66c871dacbc24e8293870bb9b9bb52fde58ed094 # Parent 34ce8339b95658627fb707b7cdbf93427bef6e2c Improve course ID handling. diff -r 34ce8339b956 -r 66c871dacbc2 index.php --- a/index.php Mon Aug 24 11:00:13 2015 +0300 +++ b/index.php Mon Aug 24 11:19:52 2015 +0300 @@ -188,13 +188,14 @@ } -function lukFetchCourseData($uri, &$cache) +function lukFetchCourseData($id, $uri, &$cache) { global $pageCharset; if (($data = @file_get_contents($uri)) !== FALSE) { $data = @iconv("iso8859-15", $pageCharset, $data); + // Korjausrakentamisen rakennussuunnittelu 3 op if (preg_match("#(.+?)\s+(\d+)\s*(op|ECTS\s+cr)\s*#", $data, $m)) { @@ -203,7 +204,7 @@ } else // ... (N op) - if (preg_match("#(.+?)\s+\((\d+)\s*(op|ECTS\s+cr)\)\s*#", $data, $m)) + if (preg_match("#(.+?)\s+\((\d+)\s*(op|ECTS\s+cr|cr)\)\s*#i", $data, $m)) { $cache = array("desc" => $m[1], "op" => intval($m[2]), "uri" => $uri); return TRUE; @@ -226,8 +227,10 @@ { // Not cached, try to fetch data $uri = "http://www.oamk.fi/opinto-opas/opintojaksohaku/?sivu=oj_kuvaus&koodi1=".$id."&kieli=".strtoupper($pageLang); - if (lukFetchCourseData($uri."&opas=2015-2016", $cache[$id][$pageLang]) || - lukFetchCourseData($uri."&opas=2014-2015", $cache[$id][$pageLang])) + if ( + lukFetchCourseData($id, $uri."&opas=2014-2015", $cache[$id][$pageLang]) || + lukFetchCourseData($id, $uri."&opas=2015-2016", $cache[$id][$pageLang]) + ) $cacheDirty = TRUE; }