Mercurial > hg > lukkari
changeset 39:78d0c1cd7282
Add support for upcoming period data.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 08 Mar 2012 07:31:33 +0200 |
parents | 2195ede068c8 |
children | 808cf4c768c4 |
files | index.php |
diffstat | 1 files changed, 43 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- 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 <b>".$luokkaDefault."</b>."); - $luokka = $luokkaDefault; -} - - -if (isset($_GET["tila"])) { - $tila = $_GET["tila"]; - echo "Luokkatilan näyttömoodi ei vielä tuettu.<br />\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 <b>".$luokkaDefault."</b>."); + $luokka = $luokkaDefault; +} + + +if (isset($_GET["tila"])) { + $tila = $_GET["tila"]; + echo "Luokkatilan näyttömoodi ei vielä tuettu.<br />\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 "</a>]</td> - <td>[<a href=\"http://www.oamk.fi/tyojarjestykset/otek/luokat/OR_".$luokka.".htm\">Alkuperäinen</a>]</td> - <td>[<a href=\"".$baseURI."?next\">Seuraava periodi</a>]</td> + <td>[<a href=\"http://www.oamk.fi/tyojarjestykset/otek/luokat/OR_".$luokka.".htm\">Alkuperäinen</a>]</td> + + <td>[<a href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">".($nextPeriod ? "Nykyinen" : "Seuraava")." periodi</a>]</td> </tr> </table> </form>