Mercurial > hg > lukkari
annotate index.php @ 60:cdc04572800c
Add back the indicator box for number of hours for the class.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Oct 2012 01:39:38 +0300 |
parents | aa201ddd33dd |
children | 6635246b70d9 |
rev | line source |
---|---|
59 | 1 <?php |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
2 // |
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
3 // Yes, this is horrible. :| |
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
4 // |
38
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
5 $pageCharset = "utf-8"; |
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
6 $internalCharset = "utf-8"; |
1 | 7 $luokkaDefault = "TTE9SNO"; |
5 | 8 $classFile = "luokat.txt"; |
1 | 9 $cacheFile = "coursecache.txt"; |
59 | 10 $baseURI = "http://tnsp.org/luk2/"; |
30 | 11 //$infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&opas=2010-2011&vuosi=10S11K&koodi1="; |
12 $infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&koodi1="; | |
1 | 13 $dayNames = array("Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai", "Sunnuntai"); |
14 | |
48
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
15 $pageCSSData = array("cookie" => "lukcss", "prefix" => $baseURI."luk"); |
49
16aea8e5cb71
Improved CSS, added a third stylesheet option.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
16 $pageCSSAlts = array("blue" => "1", "old" => "2", "purple" => "3"); |
48
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
17 |
5 | 18 // Include framework |
1 | 19 require "mcommon.inc.php"; |
20 require "merrors.inc.php"; | |
21 | |
2 | 22 |
5 | 23 // Helper functions |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
24 function lukChEntities($str) |
38
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
25 { |
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
26 global $internalCharset; |
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
27 // return $str; |
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
28 return htmlentities($str, ENT_NOQUOTES, $internalCharset); |
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
29 } |
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
30 |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
31 function lukCheckClassID(&$id) |
1 | 32 { |
33 global $luokkaDefault; | |
23
b4b86915ae2c
Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
34 if (preg_match("#^([A-Z]{3}\d[A-Za-z0-9_]{1,6}|ccr|Ryh_[A-Z]{3}\d[A-Za-z0-9_]{1,6})$#", $id, $m)) { |
b4b86915ae2c
Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
35 $id = $m[1]; |
b4b86915ae2c
Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
36 return TRUE; |
b4b86915ae2c
Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
37 } else { |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
38 errorMsg("Virhe! Luokan täytyy olla muotoa <b>XXXnXXX</b>, käytetään vakioarvoa <b>".$luokkaDefault."</b>."); |
1 | 39 $id = $luokkaDefault; |
40 return FALSE; | |
23
b4b86915ae2c
Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
41 } |
1 | 42 } |
43 | |
59 | 44 |
45 function lukGetDayFromTimestamp($stamp) | |
46 { | |
47 $info = getdate($stamp); | |
48 $day = $info["wday"]; | |
49 return ($day > 0) ? $day - 1 : $day + 6; | |
50 } | |
51 | |
52 | |
53 function lukGetHourStamp($stamp) | |
5 | 54 { |
59 | 55 return date("H:i", mktime(0, 0, $stamp, 0, 0, 0)); |
56 } | |
57 | |
58 | |
59 function lukGetHourStr($hour) | |
60 { | |
61 global $classHourTimes; | |
62 if (isset($classHourTimes[$hour])) | |
63 { | |
64 return | |
65 "<br />". | |
66 lukGetHourStamp($classHourTimes[$hour]["start"]). | |
67 " - ". | |
68 lukGetHourStamp($classHourTimes[$hour]["end"]). | |
69 "<br /><br />"; | |
70 } | |
17 | 71 else |
59 | 72 return "ERROR"; |
5 | 73 } |
74 | |
75 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
76 function lukMatchCourse($id) |
1 | 77 { |
38
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
78 global $cache, $infoURI, $cacheDirty, $internalCharset; |
1 | 79 |
80 // Check if course exists in cache | |
59 | 81 if (!isset($cache[$id])) |
82 { | |
83 // Not cached, try to fetch data | |
1 | 84 $cacheDirty = TRUE; |
85 $data = @file_get_contents($infoURI.$id); | |
59 | 86 if ($data !== FALSE) |
87 { | |
38
2195ede068c8
Add chentities() helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
88 $data = iconv("iso-8859-1", $internalCharset, $data); |
59 | 89 if (preg_match("#<td class=\"smallheadercell\"><strong>(.+?)\s+(\d+)\s*op\s*</strong></td>#", $data, $m)) |
90 { | |
1 | 91 // Add data to cache |
92 $cache[$id] = array("desc" => $m[1], "op" => intval($m[2])); | |
93 } | |
94 } | |
95 } | |
96 | |
97 if (isset($cache[$id])) | |
59 | 98 { |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
99 return "<a target=\"_blank\" title=\"".lukChEntities($id." - ".$cache[$id]["op"]." op"). |
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
100 "\" href=\"".lukChEntities($infoURI.$id)."\">".lukChEntities($cache[$id]["desc"])."</a>"; |
59 | 101 } |
1 | 102 else |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
103 return lukChEntities($id); |
1 | 104 } |
105 | |
106 | |
59 | 107 function lukGetClassInfo($isSplit, $data) |
108 { | |
109 if ($isSplit) | |
110 { | |
111 $out = "<table>". | |
112 "<tr><td>".lukMatchCourse($data[0])."</td><td>".lukMatchCourse($data[1])."</td></tr>"; | |
113 | |
114 for ($i = 2; $i < count($data); $i += 2) | |
115 { | |
116 $out .= "<tr><td>".lukChEntities($data[$i])."</td><td>". | |
117 (isset($data[$i+1]) ? lukChEntities($data[$i+1]) : "")."</td></tr>"; | |
118 } | |
119 | |
120 return $out."</table>"; | |
121 } | |
122 else | |
123 { | |
124 $out = lukMatchCourse($data[0])."<br />"; | |
125 | |
126 for ($i = 1; $i < count($data); $i++) | |
127 { | |
128 $out .= lukChEntities($data[$i])."<br />"; | |
129 } | |
130 | |
131 return $out; | |
132 } | |
133 } | |
134 | |
135 | |
136 function lukGetClassInfoData($id) | |
137 { | |
138 global $classInfo; | |
139 | |
140 if (isset($id)) | |
141 { | |
142 if ($id >= 0 && isset($classInfo[$id])) | |
143 { | |
144 $i = $classInfo[$id]; | |
145 $isSplit = preg_match("/^[A-Z]\d{6}$/", $i["data"][1]); | |
146 return lukGetClassInfo($isSplit, $i["data"]); | |
147 } | |
148 else | |
149 return "<p>Ei tunteja.</p>"; | |
150 } | |
151 else | |
152 return "<p>Ei mitään.</p>"; | |
153 } | |
154 | |
155 | |
156 function lukFindClass($day, $hour) | |
157 { | |
158 global $classHourDefs, $classDayTable; | |
159 if (isset($classDayTable[$day])) | |
160 { | |
161 foreach ($classDayTable[$day] as $id) | |
162 { | |
163 if ($hour >= $classHourDefs[$id]["start"] && | |
164 $hour < $classHourDefs[$id]["start"] + $classHourDefs[$id]["hours"]) | |
165 return $id; | |
166 } | |
167 } | |
168 return 0; | |
169 } | |
170 | |
171 | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
172 // Check for mini-info mode |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
173 $miniMode = isset($_GET["nyt"]); |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
174 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
175 // Check given parameters |
59 | 176 if (isset($_GET["luokka"])) |
177 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
178 $luokka = $_GET["luokka"]; |
59 | 179 if (lukCheckClassID($luokka) && !$miniMode) |
180 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
181 setcookie("lukluokka", $luokka, time() + 365*24*60*60); // expire in a year |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
182 } |
59 | 183 } |
184 else | |
185 if (isset($_COOKIE["lukluokka"])) | |
186 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
187 $luokka = $_COOKIE["lukluokka"]; |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
188 lukCheckClassID($luokka); |
59 | 189 } |
190 else | |
191 { | |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
192 errorMsg("Luokkaa ei asetettu, käytetään vakioarvoa <b>".$luokkaDefault."</b>."); |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
193 $luokka = $luokkaDefault; |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
194 } |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
195 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
196 |
59 | 197 if (isset($_GET["next"])) |
198 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
199 $nextPeriod = TRUE; |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
200 $dataFile = "cache-next/".$luokka.".data"; |
59 | 201 } |
202 else | |
203 { | |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
204 $nextPeriod = FALSE; |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
205 $dataFile = "cache/".$luokka.".data"; |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
206 } |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
207 |
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
208 |
1 | 209 // Global cache for course data |
210 $cache = array(); | |
211 $cacheDirty = FALSE; | |
212 | |
213 // Try to read cachefile, if we can get file lock on it | |
214 $fp = @fopen($cacheFile, "rb"); | |
59 | 215 if ($fp) |
216 { | |
217 if (flock($fp, LOCK_SH)) | |
218 { | |
1 | 219 require($cacheFile); |
220 flock($fp, LOCK_UN); | |
221 } | |
222 fclose($fp); | |
223 } | |
224 | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
225 |
28 | 226 // Read classfile |
59 | 227 $classes = array(); |
5 | 228 $fp = @fopen($classFile, "rb"); |
59 | 229 if ($fp) |
230 { | |
231 if (flock($fp, LOCK_SH)) | |
232 { | |
233 while (!feof($fp)) | |
234 { | |
5 | 235 $str = trim(fgets($fp, 128)); |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
236 if (strlen($str) > 2 && $str[0] != "#") |
5 | 237 $classes[] = $str; |
238 } | |
239 flock($fp, LOCK_UN); | |
240 } | |
241 fclose($fp); | |
59 | 242 } |
243 else | |
244 { | |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
245 errorMsg("Luokkien listaa ei löytynyt. Kokeile ladata sivu uudelleen hetken kuluttua."); |
1 | 246 } |
247 | |
248 | |
59 | 249 if (!file_exists($dataFile)) |
250 { | |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
251 errorMsg("Luokan ".lukChEntities($luokka)." tietoja ei löytynyt! ". |
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
252 "Jos luokkakoodi on uusi, ilmestyy se järjestelmään seuraavan ". |
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
253 "päivityksen aikana. Luokkatiedot päivitetään kerran viikossa."); |
5 | 254 $haveData = FALSE; |
1 | 255 } |
59 | 256 else |
13
57dd1db922c2
Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
257 { |
59 | 258 require($dataFile); |
259 $haveData = isset($classInfo); | |
13
57dd1db922c2
Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
260 } |
57dd1db922c2
Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
261 |
57dd1db922c2
Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
262 |
59 | 263 function lukNormalTimeTable() |
264 { | |
265 global $classInfo, $classHourDefs, $dayNames, $classHourTimes; | |
20 | 266 |
59 | 267 // $currStamp = time() + 9 * 60 * 60 + 18 * 60; |
268 $currStamp = time(); | |
269 $currTime = $currStamp - mktime(0, 0, 0); | |
270 $currDay = lukGetDayFromTimestamp($currStamp); | |
271 | |
5 | 272 // Create the timetable table |
273 $out = | |
274 "<p>".join("; ", $classInfo["general"])."</p>\n". | |
59 | 275 "<div>Viikossa yhteensä <b>".$classInfo["totalHours"]."</b> tuntia.</div>\n". |
5 | 276 "<table class=\"timetable\">". |
277 " <tr>\n <th></th>\n"; | |
59 | 278 $cellWidth = 100 / $classInfo["maxDays"]; |
279 if ($cellWidth > 25) $cellWidth = 25; | |
280 for ($day = 0; $day < $classInfo["maxDays"]; $day++) | |
281 { | |
282 $out .= " <th style=\"width: ".$cellWidth."%;\" class=\"days\">".$dayNames[$day]."</th>\n"; | |
5 | 283 } |
284 $out .= " </tr>\n"; | |
1 | 285 |
59 | 286 for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) |
287 { | |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
288 $out .= " <tr>\n". |
59 | 289 " <th class=\"hours\">".lukGetHourStr($hour)."</th>\n"; |
290 for ($day = 0; $day < $classInfo["maxDays"]; $day++) | |
291 { | |
292 $id = lukFindClass($day, $hour); | |
293 if ($id > 0) | |
294 { | |
295 $class = &$classHourDefs[$id]; | |
296 if (!isset($class["set"])) | |
297 { | |
298 $class["set"] = TRUE; | |
299 | |
300 $isSplit = preg_match("/^[A-Z]\d{6}$/", $class["data"][1]); | |
301 | |
302 $isActive = $day == $currDay && | |
303 $currTime >= $classHourTimes[$class["start"]]["start"] && | |
304 $currTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; | |
305 | |
306 $out .= " <td rowspan=\"".$class["hours"]. | |
307 "\" class=\"".($class["grouped"] ? "clgrouped" : ($isActive ? "clactive" : "clnormal"))."\">"; | |
308 | |
309 // if ($isActive) | |
310 // $out .= sprintf("%d : %d <> %d, %d -- ", $day, $currTime, $classHourTimes[$class["start"]]["start"], $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]); | |
1 | 311 |
59 | 312 $out .= |
313 lukGetClassInfo($isSplit, $class["data"]). | |
60
cdc04572800c
Add back the indicator box for number of hours for the class.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
314 "<div class=\"nhours\"><span>".$class["hours"]."h</span></div></td>\n"; |
59 | 315 } |
316 } | |
317 else | |
318 { | |
319 $out .= " <td class=\"clnothing\"></td>\n"; | |
320 } | |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
321 } |
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
322 $out .= " </tr>\n"; |
1 | 323 } |
324 | |
59 | 325 return $out."</table>\n"; |
326 } | |
5 | 327 |
328 | |
59 | 329 // |
330 // | |
331 // | |
5 | 332 $pageTitle = $haveData ? $luokka." / ".join("; ", $classInfo["info"]) : $luokka; |
333 printPageHeader($pageTitle); | |
18 | 334 |
59 | 335 echo "<form id=\"controls\" action=\"".$baseURI."\" method=\"get\"> |
30 | 336 <table> |
337 <tr> | |
45
d8a1e85b8dda
Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
338 <th> |
30 | 339 <select name=\"luokka\"> |
340 "; | |
5 | 341 |
342 foreach ($classes as $class) { | |
43
7621bfc47491
Various bits and pieces -- a commit that defies logic. Oh well.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
343 echo " <option ".($luokka == $class ? "selected=\"selected\" " : "")."value=\"".$class."\">".lukChEntities($class)."</option>\n"; |
1 | 344 } |
30 | 345 echo |
346 " </select> | |
45
d8a1e85b8dda
Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
347 </th> |
d8a1e85b8dda
Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
348 <th><input class=\"submit\" type=\"submit\" value=\" Vaihda \" /></th> |
d8a1e85b8dda
Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
349 <th><a href=\"".$baseURI."?luokka=".$luokka; |
17 | 350 |
351 if ($miniMode) | |
352 echo "\">Normaali"; | |
353 else | |
354 echo "&nyt\">Mini-info"; | |
355 | |
45
d8a1e85b8dda
Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
356 echo "</a></th> |
d8a1e85b8dda
Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
357 <th><a href=\"http://www.oamk.fi/tyojarjestykset/otek/luokat/OR_".$luokka.".htm\">Alkuperäinen</a></th> |
39
78d0c1cd7282
Add support for upcoming period data.
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
358 |
45
d8a1e85b8dda
Change the visual style a tiny bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
359 <th><a href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">".($nextPeriod ? "Nykyinen" : "Seuraava")." periodi</a></th> |
30 | 360 </tr> |
361 </table> | |
362 </form> | |
363 "; | |
13
57dd1db922c2
Fix hours, add mini-info mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
364 |
18 | 365 echo "<h1>".$pageTitle."</h1>\n"; |
1 | 366 |
367 // Show error messages | |
59 | 368 if ($errorSet) |
369 { | |
1 | 370 echo "<ul>\n"; |
44
57af36f0864e
Rename some functions + reindentation cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
371 foreach ($errorMsgs as $msg) |
1 | 372 echo "<li>$msg</li>\n"; |
373 echo "</ul>\n"; | |
374 } | |
375 | |
59 | 376 if ($haveData) |
377 { | |
378 echo lukNormalTimeTable(); | |
379 } | |
5 | 380 |
48
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
381 echo "<div id=\"footer\"> |
37 | 382 Yhteydenotot <b>ccr @ IRCNet</b> tai <b>ccr at tnsp dot org</b>. En vastaa mahdollisista virheistä tiedoissa! |
30 | 383 </div> |
48
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
384 <div id=\"csssel\"> |
59 | 385 <div id=\"ctitle\">Lukkari v2.0 beta</div> |
48
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
386 Style: "; |
49
16aea8e5cb71
Improved CSS, added a third stylesheet option.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
387 foreach ($pageCSSAlts as $name => $id) |
48
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
388 echo "<a href=\"?css=".$id."\">".$name."</a>"; |
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
389 echo " |
d41b51cd4ae5
Implement switchable CSS support and a new default style + very minor code
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
390 </div> |
30 | 391 "; |
1 | 392 printPageFooter(); |
393 | |
394 | |
395 // Dump the course data cache, but only if it has changed | |
396 if ($cacheDirty) { | |
27
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
397 // Create string containing the data |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
398 $str = "<?\n\$cache = array(\n"; |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
399 foreach ($cache as $id => $data) { |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
400 $str .= " \"".addslashes($id)."\" => array(\"desc\" => \"". |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
401 addslashes($data["desc"])."\", \"op\" => ".$data["op"]."),\n"; |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
402 } |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
403 $str .= ");\n?>"; |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
404 |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
405 // Use locking to prevent concurrent access and dump data |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
406 if (file_put_contents($cacheFile, $str, LOCK_EX) === FALSE) { |
7655db03ea60
Use different strategy of saving course cache, by using file_put_contents() with locking instead of using separate writes.
Matti Hamalainen <ccr@tnsp.org>
parents:
23
diff
changeset
|
407 // Can't do much anything here .. |
1 | 408 } |
409 } | |
410 | |
411 ?> |