annotate msite.inc.php @ 175:8df523e6326a

User require_once instead of require.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 06 Nov 2013 10:27:57 +0200
parents 2359744b4087
children 8f0d81f9c648
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 //
160
0980e705dea0 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
3 // FAPWeb Simple Demoparty System
33
5bf22431176c Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
4 // Generic and miscellaneous site support code
160
0980e705dea0 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 //
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
8
51
7bdf89601ba0 Work on session stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
9 define("SESS_USER", "user");
7bdf89601ba0 Work on session stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
10 define("SESS_ADMIN", "admin");
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
11 require_once "msitegen.inc.php";
51
7bdf89601ba0 Work on session stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
12
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
13 define("SMODE_ROTATE", 1);
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
14 define("SMODE_COMPO", 2);
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
15
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
16
94
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
17 //
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
18 // Different voting modes
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
19 //
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
20 // VOTE_FREELY - Vote keys are not tied to attendees, and do not need to be activated
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
21 define("VOTE_FREELY", 0);
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
22
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
23 // VOTE_ACTIVATE - Vote keys are not tied to attendees, but require manual activation.
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
24 define("VOTE_ACTIVATE", 1);
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
25
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
26 // VOTE_ASSIGN - Keys are tied to attendees, activated by assigning the key to attendee.
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
27 define("VOTE_ASSIGN", 2);
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
28
6edd7d623eab Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
29
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
30 function stReloadDisplayVars()
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
31 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
32 global $displayVars, $displayVarsChanged;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
33
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
34 $displayVars = array();
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
35 $displayVarsChanged = array();
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
36
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
37 if (($res = stExecSQL("SELECT * FROM displayVars")) !== FALSE)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
38 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
39 foreach ($res as $row)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
40 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
41 switch ($row["vtype"])
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
42 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
43 case VT_INT: $val = intval($row["vint"]); break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
44 case VT_BOOL: $val = intval($row["vint"]) ? true : false; break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
45 case VT_STR: $val = $row["vstr"]; break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
46 case VT_TEXT: $val = $row["vtext"]; break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
47 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
48 $displayVars[$row["key"]] = $val;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
49 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
50 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
51 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
52
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
53
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
54 function stSaveDisplayVars()
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
55 {
144
c030c3cf0d80 More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
56 global $db, $displayVars, $displayVarsChanged;
143
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
57
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
58 foreach (stExecSQL("SELECT * FROM displayVars") as $item)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
59 if (isset($displayVarsChanged[$item["key"]]))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
60 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
61 $val = $displayVars[$item["key"]];
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
62 switch ($item["vtype"])
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
63 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
64 case VT_INT: $vsql = stPrepareSQL("vint=%d", $val); break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
65 case VT_BOOL: $vsql = stPrepareSQL("vint=%d", $val ? 1 : 0); break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
66 case VT_STR: $vsql = stPrepareSQL("vstr=%s", $val); break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
67 case VT_TEXT: $vsql = stPrepareSQL("vtext=%s", $val); break;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
68 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
69
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
70 $sql = "UPDATE displayVars SET ".$vsql." WHERE key=".$db->quote($item["key"]);
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
71 stExecSQL($sql);
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
72 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
73 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
74
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
75
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
76 function stGetDisplayVar($name)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
77 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
78 global $displayVars;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
79 if (isset($displayVars[$name]))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
80 return $displayVars[$name];
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
81 else
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
82 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
83 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
84
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
85
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
86 function stSetDisplayVar($name, $value)
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
87 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
88 global $displayVars, $displayVarsChanged;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
89 if (isset($displayVars[$name]))
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
90 {
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
91 $displayVars[$name] = $value;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
92 $displayVarsChanged[$name] = true;
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
93 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
94 else
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
95 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
96 }
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
97
20893a5442b7 Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
98
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
99 function stPrintAttendee($item, $row, $edit, $eclass = "")
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
100 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
101 $id = $item["id"];
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
102 $prefix = "at";
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
103 echo " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\" id=\"attendee".$id."\">";
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
104
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
105 echo
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
106 stGetTDEditTextItem(FALSE, 20, 40, "name", $id, $prefix, $item["name"]).
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
107 stGetTDEditTextItem(FALSE, 20, 40, "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
108 "<td class=\"regtime\">".date("d.m. H:i", $item["regtime"])."</td>".
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
109 stGetTDEditTextItem($edit, 30, 64, "oneliner", $id, $prefix, $item["oneliner"], "autocomplete=\"off\"");
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
110
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
111 if ($edit)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
112 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
113 echo
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
114 stGetTDEditTextItem($edit, 20, 40, "email", $id, $prefix, $item["email"], "autocomplete=\"off\"").
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
115 "<td>".
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
116 "<button class=\"button\" id=\"atupd".$id."\" type=\"button\" onclick=\"updateAttendee(".$id.")\"> Upd </button>".
d74fb8cf0062 Adjust attendee output again, we're separating vote keys from there once more. Durr.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
117 "<button class=\"button\" id=\"atdel".$id."\" type=\"button\" onclick=\"deleteAttendee(".$id.")\"> Del </button>".
d74fb8cf0062 Adjust attendee output again, we're separating vote keys from there once more. Durr.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
118 "</td>";
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
119 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
120
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
121 echo "</tr>\n";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
122 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
123
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
124
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
125 function stPrintNewsItem($item, $edit = "")
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
126 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
127 echo
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
128 "<div class=\"newsitem\" id=\"news".$item["id"]."\">\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
129 " <h2>".chentities($item["title"])."</h2>\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
130 " <div class=\"text\">".dhentities($item["text"])."</div>\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
131 " <div class=\"sig\">-- ".chentities($item["author"])."<br />".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
132 date("d M Y / H:i", $item["utime"]).
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
133 $edit."</div>\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
134 "</div>\n";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
135 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
136
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
137
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
138 function stGetCompoList($fvisible, $fvoting = FALSE)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
139 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
140 global $compos;
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
141
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
142 // Get entries and competitions into an array structure
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
143 $sql = "SELECT * FROM compos";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
144 if ($fvisible || $fvoting)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
145 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
146 $sql .= " WHERE ".implode(" AND ", array($fvisible ? "visible<>0" : "", $fvoting ? "voting<>0" : ""));
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
147 }
121
73608dc4123f Add a tiny weeny comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
148
73608dc4123f Add a tiny weeny comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
149 // Get the data
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
150 foreach (stExecSQL($sql) as $compo)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
151 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
152 $id = $compo["id"];
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
153
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
154 $compos[$compo["id"]] = array(
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
155 "name" => $compo["name"],
109
9a3f0ba4d72b Add showAuthors to collected compo data set by stGetCompoList().
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
156 "showAuthors" => $compo["showAuthors"],
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
157 "entries" => array()
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
158 );
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
159
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
160 $sql = stPrepareSQL("SELECT * FROM entries WHERE compo_id=%d", $id);
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
161 foreach (stExecSQL($sql) as $entry)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
162 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
163 $compos[$id]["entries"][$entry["id"]] = $entry;
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
164 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
165 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
166 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
167
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
168
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
169 function stGenerateUserKey()
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
170 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
171 global $db;
99
2169c3177f47 Limit the vote key character space even more.
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
172 $keyChars = "abdefghjkmnpqrstwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
173
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
174 while (TRUE)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
175 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
176 // Generate one randomized keycode
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
177 $key = "";
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
178 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
179 $key .= $keyChars[rand() % strlen($keyChars)];
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
180
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
181 // 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
182 // 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
183 // 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
184 $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
185 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
186 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
187 // Did we get results?
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
188 if ($res->fetchColumn() === FALSE)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
189 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
190 // Nope, return key
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
191 return $key;
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
192 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
193 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
194 else
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
195 {
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
196 stLogSQLError($sql);
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
197 return FALSE;
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
198 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
199 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
200 }
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
201
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
202
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
203 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
204 {
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
205 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
206
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
207 $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
208 $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
209 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
210 $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
211
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
212 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
213 }
135
eecac02579c4 Move stChop() to site module and rename it to stStrChop().
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
214
eecac02579c4 Move stChop() to site module and rename it to stStrChop().
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
215
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 ?>