# HG changeset patch # User Matti Hamalainen # Date 1331184693 -7200 # Node ID 78d0c1cd728212d906a2823967f3d8549c712c86 # Parent 2195ede068c88f360f7af6f61761a7622e868ecd Add support for upcoming period data. diff -r 2195ede068c8 -r 78d0c1cd7282 index.php --- a/index.php Thu Mar 08 07:30:59 2012 +0200 +++ b/index.php Thu Mar 08 07:31:33 2012 +0200 @@ -3,7 +3,6 @@ $pageCharset = "utf-8"; $internalCharset = "utf-8"; $luokkaDefault = "TTE9SNO"; -$dataDir = "cache/"; $classFile = "luokat.txt"; $mapFile = "kartta.png"; $roomFile = "luokkatilat.txt"; @@ -55,37 +54,6 @@ } } -// Check for mini-info mode -$miniMode = isset($_GET["nyt"]); - -// Check given parameters -if (isset($_GET["luokka"])) { - $luokka = $_GET["luokka"]; - if (checkClassID($luokka) && !$miniMode) { - setcookie("lukluokka", $luokka, time() + 365*24*60*60); // expire in a year - } -} else -if (isset($_COOKIE["lukluokka"])) { - $luokka = $_COOKIE["lukluokka"]; - checkClassID($luokka); -} else { - errorMsg("Luokkaa ei asetettu, käytetään vakioarvoa ".$luokkaDefault."."); - $luokka = $luokkaDefault; -} - - -if (isset($_GET["tila"])) { - $tila = $_GET["tila"]; - echo "Luokkatilan näyttömoodi ei vielä tuettu.
\n"; - exit; - - $fp = @fopen($roomFile, "rb"); - if ($fp) { - fclose($fp); - } -} - - function getHourStamp($hour, $sec = 0, $mon = 0, $day = 0, $year = 0) { global $hourStamps; @@ -136,6 +104,46 @@ } +// Check for mini-info mode +$miniMode = isset($_GET["nyt"]); + +// Check given parameters +if (isset($_GET["luokka"])) { + $luokka = $_GET["luokka"]; + if (checkClassID($luokka) && !$miniMode) { + setcookie("lukluokka", $luokka, time() + 365*24*60*60); // expire in a year + } +} else +if (isset($_COOKIE["lukluokka"])) { + $luokka = $_COOKIE["lukluokka"]; + checkClassID($luokka); +} else { + errorMsg("Luokkaa ei asetettu, käytetään vakioarvoa ".$luokkaDefault."."); + $luokka = $luokkaDefault; +} + + +if (isset($_GET["tila"])) { + $tila = $_GET["tila"]; + echo "Luokkatilan näyttömoodi ei vielä tuettu.
\n"; + exit; + + $fp = @fopen($roomFile, "rb"); + if ($fp) { + fclose($fp); + } +} + + +if (isset($_GET["next"])) { + $nextPeriod = TRUE; + $dataFile = "cache-next/".$luokka.".data"; +} else { + $nextPeriod = FALSE; + $dataFile = "cache/".$luokka.".data"; +} + + // Global cache for course data $cache = array(); $cacheDirty = FALSE; @@ -168,10 +176,6 @@ errorMsg("Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua."); } -if (isset($_GET["next"])) - $dataFile = "cache-next/".$luokka.".data"; -else - $dataFile = "cache/".$luokka.".data"; if (!file_exists($dataFile)) { errorMsg("Luokan ".chentities($luokka)." tietoja ei löytynyt! Jos luokkakoodi on uusi, ilmestyy se järjestelmään seuraavan päivityksen aikana. Luokkatiedot päivitetään 2 kertaa vuorokaudessa."); @@ -424,8 +428,9 @@ echo "&nyt\">Mini-info"; echo "] - [Alkuperäinen] - [Seuraava periodi] + [Alkuperäinen] + + [".($nextPeriod ? "Nykyinen" : "Seuraava")." periodi]