changeset 17:611452d30bd4

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 12 Jan 2011 01:32:13 +0200
parents ea9558465ad6
children e0f1a5861f28
files index.php
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Wed Jan 12 01:09:41 2011 +0200
+++ b/index.php	Wed Jan 12 01:32:13 2011 +0200
@@ -44,11 +44,13 @@
     return TRUE;
 }
 
+// Check for mini-info mode
+$miniMode = isset($_GET["nyt"]);
 
 // Check given parameters
 if (isset($_GET["luokka"])) {
   $luokka = $_GET["luokka"];
-  if (checkClassID($luokka) && !isset($_["nyt"])) {
+  if (checkClassID($luokka) && !$miniMode) {
     setcookie("lukluokka", $luokka, time() + 365*24*60*60); // expire in a year
   }
 } else
@@ -76,7 +78,11 @@
 function getHour($hour)
 {
   global $hourStamps;
-  $stamp = mktime($hourStamps[$hour][0], $hourStamps[$hour][1], 0);
+  if (isset($hourStamps[$hour]))
+    $stamp = mktime($hourStamps[$hour][0], $hourStamps[$hour][1], 0);
+  else
+    $stamp = mktime($hour + 8, 0, 0);
+
   return "<br />".date("H:i", $stamp)." - ".date("H:i", $stamp + 45 * 60)."<br /><br />";
 }
 
@@ -140,11 +146,13 @@
     flock($fp, LOCK_UN);
   }
   fclose($fp);
+} else {
+  errorMsg("Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua.");
 }
 
 
 if (!file_exists($dataDir.$luokka.".data")) {
-  errorMsg("Luokan ".htmlentities($luokka)." datatiedostoa ei löytynyt!");
+  errorMsg("Luokan ".htmlentities($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.");
   $haveData = FALSE;
 } else {
   require($dataDir.$luokka.".data");
@@ -223,7 +231,7 @@
 }
 
 
-if (isset($_GET["nyt"])) {
+if ($miniMode) {
   $aika = getdate();
   $hour = $aika["hours"] - 8;
   $day = $aika["wday"] - 1;
@@ -372,7 +380,14 @@
 "    </select>\n".
 "   </td>\n".
 "   <td><input type=\"submit\" value=\" Vaihda \" /></td>\n".
-"   <td>[<a href=\"".$baseURI."?luokka=".$luokka."&amp;nyt\">Mini-info moodi</a>]</td>\n".
+"   <td>[<a href=\"".$baseURI."?luokka=".$luokka;
+
+if ($miniMode)
+  echo "\">Normaali";
+else
+  echo "&amp;nyt\">Mini-info";
+
+echo "</a>]</td>\n".
 "   <td>[<a href=\"http://www.oamk.fi/tyojarjestykset/otek/luokat/OR_".$luokka.".htm\">Alkuperäinen</a>]</td>\n".
 "  </tr>\n".
 " </table>\n".
@@ -389,6 +404,7 @@
 
 echo $out;
 
+echo "<div style=\"position: relative; top: 5em; font-size: 5pt;\"><hr />Yhteydenotot <b>ccr @ IRCNet</b> tai <b>ccr at tnsp.org</b>, en vastaa mahdollisista virheistä tiedoissa.</div>\n";
 printPageFooter();