annotate msite.inc.php @ 641:1a123c6c2241

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 03 Nov 2014 01:58:41 +0200
parents c78e11aa3162
children 2eeca16e9c96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 //
571
ce11ea112a65 Change the header blurb a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 570
diff changeset
3 // FAPWeb - Simple Web-based Demoparty Management System
33
5bf22431176c Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
4 // Generic and miscellaneous site support code
565
ed2247111fdd Bump copyright years.
Matti Hamalainen <ccr@tnsp.org>
parents: 558
diff changeset
5 // (C) Copyright 2012-2014 Tecnic Software productions (TNSP)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 //
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
7 require_once "msitegen.inc.php";
51
7bdf89601ba0 Work on session stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
8
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
9 // Define modes of party information display system
410
298822ed0420 Change display mode constant values.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
10 define("SMODE_DISABLED", 0);
298822ed0420 Change display mode constant values.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
11 define("SMODE_ROTATE", 1);
298822ed0420 Change display mode constant values.
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
12 define("SMODE_COMPO", 2);
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
13
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
14
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
15 // Define sizes of database fields, see createdb.php
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
16 // and also the places where input is validated.
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
17 define("SET_LEN_USERNAME", 32);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
18 define("SET_LEN_GROUPS", 64);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
19 define("SET_LEN_ONELINER", 64);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
20 define("SET_LEN_EMAIL", 80);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
21
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
22 define("SET_LEN_NEWS_TITLE", 128);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
23 define("SET_LEN_NEWS_TEXT", 4096);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
24 define("SET_LEN_NEWS_AUTHOR", 64);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
25
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
26 define("SET_LEN_COMPO_NAME", 128);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
27 define("SET_LEN_COMPO_DESC", 4096);
533
f872843ae396 Add file path to compo data.
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
28 define("SET_LEN_COMPO_PATH", 128);
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
29
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
30 define("SET_LEN_ENTRY_NAME", 64);
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
31 define("SET_LEN_ENTRY_AUTHOR", 64);
526
e074775d853e Make filename field shorter.
Matti Hamalainen <ccr@tnsp.org>
parents: 512
diff changeset
32 define("SET_LEN_ENTRY_FILENAME", 128);
506
d29166d97b46 Change some database field sizes.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
33 define("SET_LEN_ENTRY_INFO", 1024);
527
d6726a4883a6 Add "notes" field for entries, to contain notes private to organizers.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
34 define("SET_LEN_ENTRY_NOTES", 1024);
528
dd5c5577c495 Add preview file and file type fields for entry, for screenshots etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
35 define("SET_LEN_ENTRY_PREVIEW_FILE", 128);
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
36
506
d29166d97b46 Change some database field sizes.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
37 define("SET_LEN_DISP_SLIDE_TITLE", 64);
420
e9f6e242c4b9 Define some more SQL field lengths.
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
38 define("SET_LEN_DISP_SLIDE_TEXT", 4096);
e9f6e242c4b9 Define some more SQL field lengths.
Matti Hamalainen <ccr@tnsp.org>
parents: 410
diff changeset
39 define("SET_LEN_ROT_LIST_NAME", 128);
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
40
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 491
diff changeset
41 define("SET_LEN_VOTEKEY", 64);
508
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
42
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
43
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
44 //
528
dd5c5577c495 Add preview file and file type fields for entry, for screenshots etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
45 // Entry preview type (value) and flags (bitfield)
508
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
46 //
528
dd5c5577c495 Add preview file and file type fields for entry, for screenshots etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
47 define("EPREV_IMAGE", 1); // Preview is image (PNG, JPEG)
dd5c5577c495 Add preview file and file type fields for entry, for screenshots etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
48 define("EPREV_AUDIO", 2); // Preview is audio (MP3)
dd5c5577c495 Add preview file and file type fields for entry, for screenshots etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
49
508
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
50 define("EFLAG_DISQUALIFIED", 1); // Entry is disqualified
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
51 define("EFLAG_PROBLEMS", 2); // Has some problems
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
52
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
53
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
54 //
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
55 // Competition types
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
56 //
606
3d2b70fbeb78 Slight cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
57 define("COMPO_NORMAL", 0); // Normal voting compo, points determine placement
3d2b70fbeb78 Slight cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
58 define("COMPO_POINTS", 1); // Assigned points, points determines placement (no voting)
508
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
59 define("COMPO_ASSIGN", 2); // Assigned places (no voting)
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
60
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
61
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
62 $compoModeData = array(
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
63 COMPO_NORMAL => array("Normal",
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
64 "Normal voting compo.",
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
65 ),
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
66 COMPO_POINTS => array("Points",
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
67 "Assigned points (no voting).",
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
68 ),
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
69 COMPO_ASSIGN => array("Assigned",
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
70 "Assigned places (no points, no voting).",
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
71 ),
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
72 );
b6fe46c86ff3 Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
73
641
1a123c6c2241 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 640
diff changeset
74
94
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
75 //
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
76 // Different voting modes
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
77 //
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
78 define("VOTE_FREELY", 0);
274
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
79 define("VOTE_ACTIVATE", 1);
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
80 define("VOTE_ASSIGN", 2);
94
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
81
274
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
82 $voteModeData = array(
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
83 VOTE_FREELY => array("Freeform voting",
282
50e52dc43916 Add missing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
84 "Vote keys are not tied to attendees, and do not need to be activated. ".
274
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
85 "Take one printed key slip, give it to attendee."
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
86 ),
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
87 VOTE_ACTIVATE => array("Key activation",
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
88 "Vote keys are not tied to attendees, but require manual activation. ".
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
89 "Take one printed key slip, find it by the index number in the list below, set to activated. ".
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
90 "Give key slip to attendee."
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
91 ),
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
92 VOTE_ASSIGN => array("Assigned keys",
307
c0d573a5de5b Add procedure description to assigned keys mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 282
diff changeset
93 "Votekeys are tied to attendees, activated by assigning the key to attendee. ".
c0d573a5de5b Add procedure description to assigned keys mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 282
diff changeset
94 "Take one printed key slip, find attendee in the list below, enter key ID number, assign, check. ".
c0d573a5de5b Add procedure description to assigned keys mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 282
diff changeset
95 "Give key slip to attendee."
274
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
96 ),
81507072f25d Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents: 261
diff changeset
97 );
94
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
98
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
99
535
88c048f3b9e1 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
100 //
88c048f3b9e1 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
101 // Party infromation system data/variables handling
88c048f3b9e1 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
102 //
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
103 function stReloadDisplayVars()
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
104 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
105 global $displayVars, $displayVarsChanged;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
106
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
107 $displayVars = array();
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
108 $displayVarsChanged = array();
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
109
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 535
diff changeset
110 if (($res = stExecSQL("SELECT * FROM display_vars")) !== FALSE)
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
111 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
112 foreach ($res as $row)
354
1dd598221874 Simplify code by reusing functions from site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
113 $displayVars[$row["key"]] = stGetSQLSettingData($row);
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
114 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
115 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
116
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
117
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
118 function stSaveDisplayVars()
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
119 {
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
120 global $db, $displayVars, $displayVarsChanged;
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
121
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 535
diff changeset
122 foreach (stExecSQL("SELECT * FROM display_vars") as $item)
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
123 if (isset($displayVarsChanged[$item["key"]]))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
124 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
125 $val = $displayVars[$item["key"]];
354
1dd598221874 Simplify code by reusing functions from site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
126 stExecSQL(
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 535
diff changeset
127 "UPDATE display_vars SET ".stGetSettingSQL($item, $val).
354
1dd598221874 Simplify code by reusing functions from site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
128 " WHERE key=".$db->quote($item["key"]));
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
129 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
130 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
131
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
132
407
eaea1ae2bc3d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
133 function stDisplayUpdated()
eaea1ae2bc3d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
134 {
eaea1ae2bc3d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
135 stSetDisplayVar("lastUpdate", time());
eaea1ae2bc3d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
136 }
eaea1ae2bc3d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
137
eaea1ae2bc3d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
138
454
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
139 function stSetDisplayVarUpd($name, $value)
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
140 {
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
141 if (stGetDisplayVar($name) != $value)
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
142 {
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
143 stSetDisplayVar($name, $value);
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
144 stDisplayUpdated();
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
145 return TRUE;
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
146 }
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
147 else
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
148 return FALSE;
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
149 }
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
150
ea7fc4e9f602 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 447
diff changeset
151
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
152 function stGetDisplayVar($name)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
153 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
154 global $displayVars;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
155 if (isset($displayVars[$name]))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
156 return $displayVars[$name];
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
157 else
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
158 die("No display var for '".$name."'.\n");
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
159 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
160
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
161
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
162 function stSetDisplayVar($name, $value)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
163 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
164 global $displayVars, $displayVarsChanged;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
165 if (isset($displayVars[$name]))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
166 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
167 $displayVars[$name] = $value;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
168 $displayVarsChanged[$name] = true;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
169 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
170 else
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
171 die("No display var for '".$name."'.\n");
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
172 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
173
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
174
535
88c048f3b9e1 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
175 //
88c048f3b9e1 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
176 // SQL database handling / helpoer functions
88c048f3b9e1 Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
177 //
484
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
178 function stExecSQLCond($sql, $msg = FALSE)
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
179 {
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
180 global $db;
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
181 if (($res = stDBExecSQL($db, $sql)) !== FALSE)
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
182 {
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
183 if ($msg !== FALSE)
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
184 stSetStatus(200, $msg);
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
185 return $res;
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
186 }
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
187 else
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
188 {
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
189 stSetStatus(902, "Error in SQL execution.");
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
190 return FALSE;
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
191 }
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
192 }
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
193
c8591a8fadbc Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 459
diff changeset
194
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
195 function stPrintAttendee($item, $row, $tr, $full, $edit, $eclass = "")
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
196 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
197 $id = $item["id"];
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
198 $prefix = "at";
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
199
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
200 if ($tr)
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
201 {
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
202 echo
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
203 " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven").$eclass.
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
204 "\" id=\"attendee".$id."\" ".($full ? "onClick=\"activateAttendee(".$id.")\"" : "").">";
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
205 }
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
206
71
d74fb8cf0062 Adjust attendee output again, we're separating vote keys from there once more. Durr.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
207 echo
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
208 stGetTDEditTextItem($edit, 20, SET_LEN_USERNAME, "name", $id, $prefix, $item["name"]).
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
209 stGetTDEditTextItem($edit, 20, SET_LEN_GROUPS, "groups", $id, $prefix, $item["groups"]).
71
d74fb8cf0062 Adjust attendee output again, we're separating vote keys from there once more. Durr.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
210 "<td class=\"regtime\">".date("d.m. H:i", $item["regtime"])."</td>".
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
211 stGetTDEditTextItem($edit, 30, SET_LEN_ONELINER, "oneliner", $id, $prefix, $item["oneliner"], "autocomplete=\"off\"");
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
212
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
213 if ($full)
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
214 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
215 echo
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
216 stGetTDEditTextItem($edit, 20, SET_LEN_EMAIL, "email", $id, $prefix, $item["email"], "autocomplete=\"off\"");
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
217
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
218 if ($edit)
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
219 {
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
220 echo
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
221 "<td>".
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
222 "<button class=\"button\" id=\"atupd".$id."\" type=\"button\" onclick=\"updateAttendee(".$id.")\"> Upd </button>".
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
223 "<button class=\"button\" id=\"atdel".$id."\" type=\"button\" onclick=\"deleteAttendee(".$id.")\"> Del </button>".
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
224 "</td>";
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
225 }
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
226 else
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
227 echo "<td></td>";
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
228 }
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
229
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
230 if ($tr)
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
231 echo "</tr>\n";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
232 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
233
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
234
222
b236b4d8d7a9 Remove useless code.
Matti Hamalainen <ccr@tnsp.org>
parents: 207
diff changeset
235 function stPrintNewsItem($item)
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
236 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
237 echo
592
642df17214f6 Improve news item DOM IDs.
Matti Hamalainen <ccr@tnsp.org>
parents: 585
diff changeset
238 "<div class=\"newsItem\" id=\"news".$item["id"]."\">\n".
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
239 " <h2>".chentities($item["title"])."</h2>\n".
592
642df17214f6 Improve news item DOM IDs.
Matti Hamalainen <ccr@tnsp.org>
parents: 585
diff changeset
240 " <div class=\"newsText\">".dhentities($item["text"])."</div>\n".
593
3cceb9f13762 And some more tweaking.
Matti Hamalainen <ccr@tnsp.org>
parents: 592
diff changeset
241 " <div class=\"newsAuthor\"><span class=\"newsSig\">-- ".chentities($item["author"])."</span>".
3cceb9f13762 And some more tweaking.
Matti Hamalainen <ccr@tnsp.org>
parents: 592
diff changeset
242 "<span class=\"newsDate\">".date("d M Y / H:i", $item["utime"])."</span></div>\n".
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
243 "</div>\n";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
244 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
245
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
246
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
247 function stGenerateUserKey()
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
248 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
249 global $db;
99
2169c3177f47 Limit the vote key character space even more.
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
250 $keyChars = "abdefghjkmnpqrstwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
251
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
252 while (TRUE)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
253 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
254 // Generate one randomized keycode
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
255 $key = "";
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
256 for ($n = 0; $n < stGetSetting("userKeyLength"); $n++)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
257 $key .= $keyChars[rand() % strlen($keyChars)];
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
258
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
259 // Check if it already exists, to avoid duplicates
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
260 // We need custom query code here, because stFetchSQLColumn()
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
261 // won't work due to it returning FALSE in error cases.
87
3da47d3e6a3c Remove a function, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
262 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE key=%s", $key);
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
263 if (($res = @$db->query($sql)) !== FALSE)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
264 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
265 // Did we get results?
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
266 if ($res->fetchColumn() === FALSE)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
267 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
268 // Nope, return key
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
269 return $key;
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
270 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
271 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
272 else
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
273 {
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
274 stLogSQLError($sql);
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
275 return FALSE;
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
276 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
277 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
278 }
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
279
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
280
103
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
281 function stCheckRegistrationAvailable()
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
282 {
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
283 global $maxAttendeesHard, $maxAttendeesSoft, $numAttendees;
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
284
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
285 $maxAttendeesHard = stGetSetting("maxAttendeesHard");
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
286 $maxAttendeesSoft = stGetSetting("maxAttendeesSoft");
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
287 if (($numAttendees = stFetchSQLColumn("SELECT COUNT(*) FROM attendees")) === FALSE)
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
288 $numAttendees = 0;
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
289
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
290 return stChkSetting("allowRegister") && ($maxAttendeesHard <= 0 || $numAttendees < $maxAttendeesHard);
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
291 }
135
eecac02579c4 Move stChop() to site module and rename it to stStrChop().
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
292
eecac02579c4 Move stChop() to site module and rename it to stStrChop().
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
293
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 222
diff changeset
294 function stValidateRequestUserData($admin)
207
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
295 {
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
296 if (!stChkRequestItem("name", $fake,
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
297 array(CHK_ISGT, VT_STR, 0, "Handle / name not given."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 243
diff changeset
298 array(CHK_LTEQ, VT_STR, SET_LEN_USERNAME, "Handle / name is too long, should be less than ".SET_LEN_USERNAME." characters.")
207
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
299 )) return FALSE;
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
300
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
301 if (!stChkRequestItem("groups", $fake,
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 243
diff changeset
302 array(CHK_LTEQ, VT_STR, SET_LEN_GROUPS, "Groups are too long, should be less than ".SET_LEN_GROUPS." characters.")
207
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
303 )) return FALSE;
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
304
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
305 if (!stChkRequestItem("oneliner", $fake,
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 243
diff changeset
306 array(CHK_LTEQ, VT_STR, SET_LEN_ONELINER, "Oneliner is too long, should be less than ".SET_LEN_ONELINER." characters.")
207
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
307 )) return FALSE;
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
308
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
309 $email = stGetRequestItem("email");
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
310 if (!$admin && stGetSetting("requireEMail") && strlen($email) < 4)
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
311 {
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
312 stError("E-mail address not given, or it is too short.");
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
313 return FALSE;
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
314 }
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
315
605
f928b0a6e1af Better validation for e-mail addresses.
Matti Hamalainen <ccr@tnsp.org>
parents: 598
diff changeset
316 if (strlen($email) > 0 && preg_match("/^[a-z0-9][a-z0-9\+\-\.\%_]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", $email) != 1)
207
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
317 {
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
318 stError("E-mail address not in proper format.");
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
319 return FALSE;
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
320 }
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
321
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
322 if (strlen($email) > SET_LEN_EMAIL)
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
323 {
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
324 stError("E-mail address too long, max ".SET_LEN_EMAIL." characters.");
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
325 return FALSE;
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
326 }
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
327
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
328 return TRUE;
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
329 }
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
330
e31c42a9b574 Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
331
637
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
332 function stGetTDEditTextItem($edit, $size, $len, $name, $id, $prefix, $value, $extra = "")
437
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
333 {
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
334 return
637
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
335 "<td class=\"".$name."\">".
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
336 ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)).
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
337 "</td>";
437
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
338 }
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
339
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
340
637
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
341 function stPrintFormTextInput($text1, $text2, $size, $len, $name, $extra="")
437
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
342 {
637
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
343 echo " <tr><th>".chentities($text1)."</th><td>".
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
344 stGetFormTextInput($size, $len, $name, "", "", stGetRequestItem($name), $extra).
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
345 "</td><td>".chentities($text2)."</td></tr>\n";
437
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
346 }
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
347
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
348
637
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
349 function stPrintFormHiddenInput($name, $value)
437
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
350 {
637
a376521c7bd1 Move some code around, for more appropriate placement in the modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 623
diff changeset
351 echo " ".stGetFormHiddenInput($name, $value)."\n";
437
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
352 }
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
353
cefa64c8be63 Move some functions to msite.
Matti Hamalainen <ccr@tnsp.org>
parents: 420
diff changeset
354
488
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
355 function stConvSwitchMode(&$str, &$mode, $newMode)
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
356 {
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
357 if ($newMode != $mode)
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
358 {
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
359 if ($mode != "")
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
360 $str .= "\n</".$mode.">\n";
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
361
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
362 $mode = $newMode;
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
363
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
364 if ($mode != "")
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
365 $str .= "<".$mode.">\n";
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
366 }
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
367 }
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
368
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
369
491
c360fb50221c Add entity handling to stConvertCommonDesc().
Matti Hamalainen <ccr@tnsp.org>
parents: 488
diff changeset
370 function stConvertCommonDesc($desc, $chent)
488
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
371 {
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
372 $str = "";
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
373 $mode = "";
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
374
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
375 foreach (explode("\n", $desc) as $line)
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
376 {
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
377 if (preg_match("/^\s*\s*\*(.+)$/", $line, $m))
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
378 {
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
379 stConvSwitchMode($str, $mode, "ol");
491
c360fb50221c Add entity handling to stConvertCommonDesc().
Matti Hamalainen <ccr@tnsp.org>
parents: 488
diff changeset
380 $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n";
488
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
381 }
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
382 else
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
383 if (preg_match("/^\s*-\s*(.+)$/", $line, $m))
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
384 {
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
385 stConvSwitchMode($str, $mode, "ul");
491
c360fb50221c Add entity handling to stConvertCommonDesc().
Matti Hamalainen <ccr@tnsp.org>
parents: 488
diff changeset
386 $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n";
488
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
387 }
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
388 else
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
389 {
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
390 stConvSwitchMode($str, $mode, "p");
491
c360fb50221c Add entity handling to stConvertCommonDesc().
Matti Hamalainen <ccr@tnsp.org>
parents: 488
diff changeset
391 $str .= ($chent ? chentities($line) : $line);
488
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
392 }
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
393 }
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
394
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
395 stConvSwitchMode($str, $mode, "");
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
396
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
397 return $str;
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
398 }
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
399
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
400
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
401 function stGetNumberSuffix($val)
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
402 {
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
403 switch ($val)
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
404 {
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
405 case 1: return "st";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
406 case 2: return "nd";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
407 case 3: return "rd";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
408 case 4: case 5: case 6:
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
409 case 7: case 8: case 9: return "th";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
410 default: return "th";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
411 }
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
412 }
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
413
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
414
606
3d2b70fbeb78 Slight cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
415 function stGetCompoResultsSQL($mode, $compo)
531
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
416 {
623
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
417 //
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
418 // Act based on competition type
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
419 //
640
c78e11aa3162 Rename a database field, so that it does not conflict with AJAX request item
Matti Hamalainen <ccr@tnsp.org>
parents: 637
diff changeset
420 switch ($compo["ctype"])
531
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
421 {
623
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
422 case COMPO_NORMAL:
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
423 //
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
424 // "Normal" competition, where results are somehow
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
425 // based on points / voting.
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
426 //
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
427 switch ($mode)
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
428 {
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
429 case VOTE_FREELY:
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
430 $sql =
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
431 "SELECT entries.*,SUM(votes.value) AS votesum ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
432 "FROM entries ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
433 "LEFT JOIN votes ON votes.entry_id=entries.id";
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
434 break;
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
435
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
436 case VOTE_ACTIVATE:
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
437 $sql =
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
438 "SELECT entries.*, ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
439 "(SELECT SUM(votes.value) FROM votes ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
440 "LEFT JOIN votekeys ON votes.key_id=votekeys.id ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
441 "WHERE votes.entry_id=entries.id AND votekeys.active<>0) ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
442 "AS votesum ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
443 "FROM entries";
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
444 break;
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
445
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
446 case VOTE_ASSIGN:
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
447 $sql =
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
448 "SELECT entries.*, ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
449 "(SELECT SUM(votes.value) FROM votes ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
450 "LEFT JOIN votekeys ON votes.key_id=votekeys.id ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
451 "LEFT JOIN attendees ON votekeys.id=attendees.key_id ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
452 "WHERE votes.entry_id=entries.id AND attendees.key_id<>0) ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
453 "AS votesum ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
454 "FROM entries";
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
455 break;
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
456 }
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
457
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
458 $extra =
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
459 "GROUP BY entries.id ".
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
460 "ORDER BY votesum DESC";
531
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
461 break;
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
462
623
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
463 case COMPO_POINTS:
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
464 case COMPO_ASSIGN:
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
465 //
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
466 // These essentially do the same ...
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
467 //
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
468 $sql = "SELECT entries.* FROM entries";
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
469 $extra = "ORDER BY entries.evalue DESC";
531
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
470 break;
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
471 }
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
472
623
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
473 return $sql." ".
606
3d2b70fbeb78 Slight cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
474 "WHERE entries.compo_id=".$compo["id"]." ".
570
27c64c5ad1a8 Remove the now useless stStrKludge() function and its use.
Matti Hamalainen <ccr@tnsp.org>
parents: 568
diff changeset
475 "AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0 ".
623
8e6331d7870d Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 606
diff changeset
476 $extra;
531
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
477 }
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
478
ec30ad303bd1 Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
479
512
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
480 function stGetCompoResultsASCIIStr($showAuthors, $html)
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
481 {
606
3d2b70fbeb78 Slight cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
482 $sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC";
3d2b70fbeb78 Slight cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
483 if (($res = stExecSQL($sql)) === false)
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
484 return "";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
485
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
486 $voteKeyMode = stGetSetting("voteKeyMode");
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
487 $out = "";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
488
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
489 // For each compo that has been set visible
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
490 foreach ($res as $compo)
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
491 {
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
492 // Check if there are any entries for it
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
493 $sql =
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
494 "SELECT COUNT(*) FROM entries ".
598
ba84d8e35d6b Do not count entries that have been flagged as disqualified.
Matti Hamalainen <ccr@tnsp.org>
parents: 593
diff changeset
495 "WHERE compo_id=".$compo["id"]." ".
ba84d8e35d6b Do not count entries that have been flagged as disqualified.
Matti Hamalainen <ccr@tnsp.org>
parents: 593
diff changeset
496 "AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0";
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
497
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
498 if (($nentries = stFetchSQLColumn($sql)) !== FALSE && $nentries > 0)
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
499 {
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
500 // Get voting results by mode
606
3d2b70fbeb78 Slight cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
501 $sql = stGetCompoResultsSQL($voteKeyMode, $compo);
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
502
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
503 // List results
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
504 $prev = FALSE;
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
505 $index = 0;
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
506
512
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
507 if ($html)
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
508 {
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
509 $out .=
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
510 "<pre>\n".
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
511 "<b> ".chentities($compo["name"])." </b>\n".
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
512 str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n";
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
513 }
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
514 else
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
515 {
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
516 $out .=
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
517 " ".$compo["name"]."\n".
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
518 str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n";
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
519 }
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
520
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
521 foreach (stExecSQL($sql) as $entry)
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
522 {
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
523 if ($entry["votesum"] !== $prev)
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
524 {
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
525 $index++;
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
526 $out .= sprintf("%3d%s.", $index, stGetNumberSuffix($index));
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
527 }
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
528 else
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
529 $out .= " -''-";
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
530
570
27c64c5ad1a8 Remove the now useless stStrKludge() function and its use.
Matti Hamalainen <ccr@tnsp.org>
parents: 568
diff changeset
531 $name = stStrChopPad($entry["name"], 30);
27c64c5ad1a8 Remove the now useless stStrKludge() function and its use.
Matti Hamalainen <ccr@tnsp.org>
parents: 568
diff changeset
532 $author = stStrChopPad($showAuthors ? $entry["author"] : "-", 30);
512
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
533
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
534 $out .= sprintf(" %s by %s (%d pts)\n",
512
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
535 $html ? chentities($name) : $name,
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
536 $html ? chentities($author) : $author,
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
537 $entry["votesum"]);
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
538
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
539 $prev = $entry["votesum"];
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
540 }
512
998a09b332f1 Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
541 $out .= "\n\n".($html ? "</pre>\n" : "");
511
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
542 }
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
543 }
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
544
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
545 return $out;
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
546 }
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
547
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
548
6fe66ea0e954 Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents: 508
diff changeset
549
459
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
550 function stNormalizeListSlideOrder($list_id)
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
551 {
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
552 }
Matti Hamalainen <ccr@tnsp.org>
parents: 454
diff changeset
553
488
532cebd9c9f2 Move some functions to site module.
Matti Hamalainen <ccr@tnsp.org>
parents: 484
diff changeset
554
585
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
555 // Get link helper function
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
556 function stGetMainPageLink($id, $name, $show = TRUE)
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
557 {
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
558 global $currPagename;
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
559 if ($show)
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
560 return " <a class=\"".($id == $currPagename ? "active" : "inactive")."\" href=\"".$id."\">".$name."</a>\n";
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
561 else
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
562 return "";
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
563 }
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
564
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
565 ?>