Mercurial > hg > fapweb
annotate showajax.php @ 802:e5bbb01f2dd4
Improve error handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 22 Nov 2014 23:29:23 +0200 |
parents | f97498ef28f4 |
children | 36741dbb4528 |
rev | line source |
---|---|
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 <? |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 // |
571
ce11ea112a65
Change the header blurb a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
565
diff
changeset
|
3 // FAPWeb - Simple Web-based Demoparty Management System |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
4 // Party information display system AJAX backend module |
565 | 5 // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 // |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
7 require_once "mconfig.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
8 require_once "msite.inc.php"; |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
10 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
11 function stPrintCompoEntry($entry, $class, $compo, $title = false) |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
12 { |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
13 echo |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
14 " <div class=\"".$class."\">\n"; |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
15 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
16 if ($title !== false) |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
17 echo |
387 | 18 " <div class=\"entryTitle\">".$title."</div>\n"; |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
19 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
20 echo |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
21 " <div class=\"entryIndex\">#".$entry["show_id"]."</div>\n". |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
22 " <div class=\"entryName\">".chentities($entry["name"])."</div>\n"; |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
23 |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
498
diff
changeset
|
24 if ($compo["show_authors"]) |
387 | 25 { |
26 if ($title === false) | |
27 echo " <div class=\"entryBy\">by</div>\n"; | |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
28 echo " <div class=\"entryAuthor\">".chentities($entry["author"])."</div>\n"; |
387 | 29 } |
30 | |
31 if ($title === false) | |
498
e7566fafe9b1
Use common formatting conversion for entry info texts.
Matti Hamalainen <ccr@tnsp.org>
parents:
497
diff
changeset
|
32 echo " <div class=\"entryInfo\">".stConvertCommonDesc($entry["info"], TRUE)."</div>\n"; |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
33 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
34 echo |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
35 " </div>\n"; |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
36 } |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
37 |
163 | 38 |
140
20ca8edfb01a
Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
39 function stPrintCompoSlide($compo, $entry, $prev) |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
40 { |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
41 echo |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
42 " <div class=\"compoHeader\">\n". |
736
e1d5c3e19930
Work a bit on the party info display code.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
43 " <div class=\"compoHeaderDiv\"></div>\n". |
e1d5c3e19930
Work a bit on the party info display code.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
44 " <div class=\"compoTitle\">".chentities($compo["name"])." competition</div>\n". |
e1d5c3e19930
Work a bit on the party info display code.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
45 " </div>\n"; |
e1d5c3e19930
Work a bit on the party info display code.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
46 |
496
924eb55a98b6
Show "competition is starting" type text if no entries are set currently.
Matti Hamalainen <ccr@tnsp.org>
parents:
495
diff
changeset
|
47 if ($entry === false && $prev === false) |
736
e1d5c3e19930
Work a bit on the party info display code.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
48 echo "<div class=\"compoStarting\">... Is about to start ...</div>"; |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
49 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
50 if ($entry !== false) |
386 | 51 stPrintCompoEntry($entry, "compoNext", $compo, false); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
52 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
53 if ($prev !== false) |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
54 stPrintCompoEntry($prev, "compoPrev", $compo, "Previous entry"); |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
55 } |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
56 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
57 |
140
20ca8edfb01a
Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
58 function stPrintRotationSlide($slide) |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
59 { |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
60 echo |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
61 " <div class=\"showHeader\">\n". |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
62 " </div>\n". |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
63 " <div class=\"showText\">\n". |
140
20ca8edfb01a
Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
64 $slide["text"]. |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
65 " </div>\n"; |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
66 } |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
67 |
163 | 68 |
391 | 69 function stGuruMeditation() |
70 { | |
71 echo | |
72 "<div class=\"guru\">". | |
73 "Software Failure. Press left mouse button to continue.<br />". | |
74 "Guru Meditation #00000004.0000AAC0". | |
75 "</div>\n"; | |
76 } | |
77 | |
78 | |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
79 // |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
80 // Initialize |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
81 // |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 stSetupCacheControl(); |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 if (!stConnectSQLDB()) |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 die("Could not connect to SQL database."); |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
87 stReloadDisplayVars(); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
88 |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
89 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
90 // |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
91 // Check if the slide needs updating? |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
92 // |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
93 $updated = FALSE; |
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
94 |
152 | 95 // Temporary slides are handled globally |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
96 if (stGetDisplayVar("tempDuration") > 0 && |
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
97 stGetDisplayVar("tempSlide") > 0 && |
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
98 stGetDisplayVar("tempSlideSet")) |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
99 { |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
498
diff
changeset
|
100 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
101 stGetDisplayVar("tempSlide")); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
102 |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
103 if (($res = stFetchSQL($sql)) !== false) |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
104 { |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
105 stSetDisplayVar("tempSlideSet", FALSE); |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
106 stSetDisplayVar("activeSlideMode", SMODE_ROTATE); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
107 stSetDisplayVar("activeSlide", stGetDisplayVar("tempSlide")); |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
429
diff
changeset
|
108 stSetDisplayVar("activeSlideExpire", time() + (stGetDisplayVar("tempDuration") * 60)); |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
109 $updated = TRUE; |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
110 } |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
111 } |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
112 else |
152 | 113 // Otherwise we act according to global show mode |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
114 switch (stGetDisplayVar("showMode")) |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
115 { |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
116 case SMODE_ROTATE: |
152 | 117 // |
118 // Rotation / normal slide show mode | |
119 // | |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
120 stSetDisplayVar("activeSlideMode", SMODE_ROTATE); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
121 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
122 if (stGetDisplayVar("rotateList") == 0) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
123 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
124 stSetDisplayVar("rotateList", 1); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
125 stSetDisplayVar("activeSlideExpire", 0); |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
126 $updated = TRUE; |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
127 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
128 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
129 if (time() >= stGetDisplayVar("activeSlideExpire") && |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
130 stGetDisplayVar("rotateList") > 0) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
131 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
132 // Get list of slides from active rotation list |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
133 $list = stGetDisplayVar("rotateList"); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
134 $sql = stPrepareSQL( |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
498
diff
changeset
|
135 "SELECT * FROM rot_list_slides WHERE list_id=%d ORDER BY order_num,id", |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
136 $list); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
137 |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
138 if (($slideList = stExecSQL($sql)) !== false) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
139 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
140 // Get slide at current index |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
141 $slides = array(); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
142 foreach ($slideList as $slide) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
143 $slides[] = $slide; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
144 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
145 $index = stGetDisplayVar("rotateListIndex"); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
146 if (count($slides) > $index) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
147 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
148 $slide_id = $slides[$index]["slide_id"]; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
149 if ($slide_id != stGetDisplayVar("activeSlide")) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
150 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
151 stSetDisplayVar("activeSlide", $slide_id); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
152 stSetDisplayVar("activeSlideExpire", time() + stGetDisplayVar("rotateDuration")); |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
153 $updated = TRUE; |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
154 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
155 } |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
156 |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
157 // Rotate to next slide |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
158 if (++$index >= count($slides)) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
159 $index = 0; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
160 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
161 stSetDisplayVar("rotateListIndex", $index); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
162 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
163 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
164 break; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
165 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
166 case SMODE_COMPO: |
152 | 167 // |
168 // Competition mode, is controlled from admin UI, so we donẗ | |
169 // actually do anything here. | |
170 // | |
387 | 171 if (time() >= stGetDisplayVar("activeSlideExpire")) |
497
570120074b3c
Set updated flag in case the mode has changed and slide expires.
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
172 { |
387 | 173 stSetDisplayVar("activeSlideMode", SMODE_COMPO); |
497
570120074b3c
Set updated flag in case the mode has changed and slide expires.
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
174 $updated = TRUE; |
570120074b3c
Set updated flag in case the mode has changed and slide expires.
Matti Hamalainen <ccr@tnsp.org>
parents:
496
diff
changeset
|
175 } |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
176 break; |
737
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
177 |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
178 case SMODE_DISABLED: |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
179 if (stGetDisplayVar("activeSlideMode") != SMODE_DISABLED) |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
180 { |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
181 stSetDisplayVar("activeSlideMode", SMODE_DISABLED); |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
182 $updated = TRUE; |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
183 } |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
184 break; |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
185 } |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 |
152 | 187 // Check if we need to update the "last updated" timestamp |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
188 if ($updated) |
407 | 189 stDisplayUpdated(); |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
190 |
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
191 |
152 | 192 // |
193 // Serve the request | |
194 // | |
144
c030c3cf0d80
More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
195 $type = stGetRequestItem("type"); |
c030c3cf0d80
More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
196 switch (stGetRequestItem("action")) |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
197 { |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
198 case "check": |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
199 // Check if there has been any change |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
200 $changed = stGetRequestItem("lastUpdate") != stGetDisplayVar("lastUpdate"); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
201 echo $changed ? "changed" : "nochange"; |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
202 break; |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
203 |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
204 case "get": |
144
c030c3cf0d80
More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
205 switch ($type) |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
206 { |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
207 case "update": |
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
208 echo stGetDisplayVar("lastUpdate"); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
209 break; |
144
c030c3cf0d80
More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
210 |
c030c3cf0d80
More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
211 case "slide": |
737
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
212 // Based on the currently active mode ... |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
213 switch (stGetDisplayVar("activeSlideMode")) |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
214 { |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
215 case SMODE_ROTATE: |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
216 // Slide rotation mode, display currently active slide |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
217 if (stGetDisplayVar("activeSlide") > 0) |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
218 { |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
219 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
220 stGetDisplayVar("activeSlide")); |
409 | 221 |
737
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
222 if (($slide = stFetchSQL($sql)) !== false) |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
223 stPrintRotationSlide($slide); |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
224 } |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
225 else |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
226 stGuruMeditation(); |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
227 break; |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
228 |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
229 case SMODE_COMPO: |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
230 // Competition mode, show entry data |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
231 $compo_id = stGetDisplayVar("compoID"); |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
232 $compo = stFetchSQL(stPrepareSQL( |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
233 "SELECT * FROM compos WHERE id=%d", |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
234 $compo_id)); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
235 |
802 | 236 if ($compo !== false) |
237 { | |
238 $prev = stFetchSQL(stPrepareSQL( | |
239 "SELECT * FROM entries WHERE compo_id=%d AND show_id=%d AND show_id<>0", | |
240 $compo_id, stGetDisplayVar("compoPrevEntry"))); | |
737
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
241 |
802 | 242 $entry = stFetchSQL(stPrepareSQL( |
243 "SELECT * FROM entries WHERE compo_id=%d AND show_id=%d AND show_id<>0", | |
244 $compo_id, stGetDisplayVar("compoCurrEntry"))); | |
737
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
245 |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
246 stPrintCompoSlide($compo, $entry, $prev); |
802 | 247 } |
737
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
248 break; |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
249 |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
250 default: |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
251 echo |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
252 " <div class=\"showHeader\">\n". |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
253 " </div>\n". |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
254 " <div class=\"showText\">\n"; |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
255 |
391 | 256 stGuruMeditation(); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
257 |
737
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
258 echo |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
259 " </div>\n"; |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
260 break; |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
261 } |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
262 break; |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
263 |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
264 default: |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
265 stGuruMeditation(); |
f97498ef28f4
Various minor fixes to the slide handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
736
diff
changeset
|
266 break; |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
267 } |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
268 break; |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
269 |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
270 default: |
391 | 271 stGuruMeditation(); |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
272 break; |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
273 } |
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
274 |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
275 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
276 // Save changed variables |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
277 stSaveDisplayVars(); |
211
5bae42020034
Factorize some code into msitegen.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
278 |
417 | 279 //stDumpAJAXStatusErrors(); |
126
71c35d5302c2
More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
280 ?> |