annotate msite.inc.php @ 32:36392d1d6b5f

Moar work.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 10 Dec 2012 11:14:05 +0200
parents 7be3f8cf1f7a
children 5bf22431176c
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 //
9
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
3 // FAPWEB - Demo Party Website System System
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
4 // (C) Copyright 2012 Matti 'ccr' Hamalainen <ccr@tnsp.org>
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 //
9
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
6
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
7 // Globals and definitions
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 $errorSet = FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 $errorMsg = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
11 define("VT_STR", 1);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
12 define("VT_INT", 2);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
13 define("VT_BOOL", 3);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
14 define("VT_TEXT", 4);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
15
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
16
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
17 if (function_exists("ini_set"))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
18 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
19 // Use cookies to store the session ID on the client side
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
20 @ini_set("session.use_only_cookies", 1);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
21
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
22 // Disable transparent Session ID support
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
23 @ini_set("session.use_trans_sid", 0);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
24 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
25
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
26
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 function stError($msg)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 global $errorSet, $errorMsg;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 $errorSet = TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 $errorMsg .= "<li>".$msg."</li>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 function stCheckHTTPS()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 return isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != "" && $_SERVER["HTTPS"] != "off");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
41 function stSetupCacheControl()
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
42 {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
43 header("Cache-Control: must-revalidate, no-store, private");
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
44 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
46
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
47
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
48 function stSessionExpire()
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
50 global $sessionType;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
51
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
52 // Check for session expiration
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
53 if (!isset($_SESSION[$sessionType]) || !isset($_SESSION[$sessionType]["expires"]))
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
54 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
55 if (stGetSetting("debug")) error_log("Session ".$sessionType." expires due to expire time not set.");
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
56 stSessionEnd();
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
57 return FALSE;
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
58 }
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
59
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
60 if ($_SESSION[$sessionType]["expires"] < time())
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
61 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
62 if (stGetSetting("debug")) error_log("Session ".$sessionType." / ".session_id()." expires due to timeout ".$_SESSION[$sessionType]["expires"]." < ".time());
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
63 stSessionEnd();
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
64 return FALSE;
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
65 }
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
66
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
67 // Add more time to expiration
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
68 $timeout = stGetSetting($_SESSION[$sessionType]["timeout"], 0);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
69 if (stGetSetting("debug")) error_log("Adding more time to ".$sessionType." session ".session_id()." :: ".$timeout);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
70 $_SESSION[$sessionType]["expires"] = time() + $timeout * 60;
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
71 return TRUE;
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
72 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
73
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
74
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
75 function stSessionEnd()
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
76 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
77 global $sessionType;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
78 $result = FALSE;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
79
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
80 if (stGetSetting("debug")) error_log("Request END session ".$sessionType);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
81
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
82 if (@session_start() === TRUE && isset($_SESSION))
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
83 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
84 // End current session type
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
85 if (isset($_SESSION[$sessionType]))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
86 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
87 if (stGetSetting("debug")) error_log("END session ".$sessionType." / ".$_SESSION[$sessionType]["expires"]);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
88 $_SESSION[$sessionType] = array();
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
89 unset($_SESSION[$sessionType]);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
90 $result = TRUE;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
91 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
92
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
93 // If all session types are ended, clear the cookies etc
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
94 if (!isset($_SESSION["user"]) && !isset($_SESSION["admin"]))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
95 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
96 if (stGetSetting("debug")) error_log("Clearing all session data.");
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
97 $_SESSION = array();
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
98
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
99 if (ini_get("session.use_cookies"))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
100 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
101 $params = session_get_cookie_params();
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
102 setcookie(session_name(), "", time() - 242000,
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
103 $params["path"], $params["domain"],
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
104 $params["secure"], $params["httponly"]
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
105 );
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
106 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
107
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
108 @session_destroy();
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
109 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
110 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
111
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
112 return $result;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
113 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
114
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
115
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
116 function stSessionStart($key, $timeout)
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
117 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
118 global $sessionType;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
119
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
120 if (@session_start() === TRUE)
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
121 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
122 if (stGetSetting("debug")) error_log("START ".$sessionType." session OK.");
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
123 $_SESSION[$sessionType] = array(
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
124 "key" => $key,
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
125 "timeout" => $timeout,
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
126 "expires" => time() + stGetSetting($timeout) * 60,
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
127 "message" => "",
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
128 "status" => 0,
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
129 );
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
130 return TRUE;
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
131 }
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
132 else
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
133 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
134 if (stGetSetting("debug")) error_log("START ".$sessionType." session --FAILED--");
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
135 return FALSE;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
136 }
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
137 }
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
138
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
139
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
140 function stAdmSessionAuth()
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
141 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
142 if (@session_start() === TRUE &&
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
143 stGetSessionItem("key", FALSE) == stGetSetting("admPassword"))
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
144 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
145 if (stGetSetting("debug")) error_log("AUTH admin session OK.");
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
146 return stSessionExpire();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 else
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
149 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
150 if (stGetSetting("debug")) error_log("AUTH admin session FAIL.");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 return FALSE;
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
152 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
156 function stUserSessionAuth()
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
157 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
158 global $sessionType;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
159
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
160 if (@session_start() === TRUE &&
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
161 isset($_SESSION[$sessionType]) &&
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
162 isset($_SESSION[$sessionType]["key"]))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
163 return stSessionExpire();
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
164 else
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
165 return FALSE;
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
166 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
167
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
168
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
169 function stSetSessionStatus($status)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
171 global $sessionType;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
172 if (isset($_SESSION[$sessionType]) || session_start() === TRUE)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
174 if ($status >= 0)
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
175 stSetSessionItem("prevstatus", stGetSessionItem("status", FALSE));
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
176
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
177 stSetSessionItem("status", $status);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 }
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
179 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
180
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
181
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
182 function stReloadSettings()
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
183 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
184 global $siteSettings;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
185 $res = stExecSQL("SELECT * FROM settings");
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
186 if ($res !== FALSE)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
187 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
188 foreach ($res as $row)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
189 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
190 switch ($row["vtype"])
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
191 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
192 case VT_INT: $val = intval($row["vint"]); break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
193 case VT_BOOL: $val = intval($row["vint"]) ? true : false; break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
194 case VT_STR: $val = $row["vstr"]; break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
195 case VT_TEXT: $val = $row["vtext"]; break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
196 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
197 $siteSettings[$row["key"]] = $val;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
198 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
199 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
200 else
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
201 die("Error fetching site settings.");
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
202 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
203
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
204
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
205 function stGetSetting($name)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
207 global $siteSettings;
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 if (isset($siteSettings[$name]))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 return $siteSettings[$name];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 else
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
211 die("No config value for '".$name."'.\n");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 function stChkSetting($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 global $siteSettings;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 return isset($siteSettings[$name]) && $siteSettings[$name];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 function stSpecURL($id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 global $specURLs;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 if (isset($specURLs[$id]))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 return "<a href=\"".$specURLs[$id][0]."\">".$specURLs[$id][1]."</a>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 return "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 function stPrintSpecURL($id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 echo stSpecURL($id);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 function dhentities($str)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 return str_replace(array("&lt;","&gt;"), array("<", ">"), htmlentities($str, ENT_NOQUOTES, "UTF-8"));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 function chentities($str)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 return htmlentities($str, ENT_NOQUOTES, "UTF-8");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
250 function stGetIDName($name, $id, $prefix = "")
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
251 {
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
252 return
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
253 ($id != "" ? "id=\"".$prefix.$name.$id."\" " : "").
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
254 ($name != "" ? "name=\"".$prefix.$name.$id."\" " : "");
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
255 }
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
256
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
257
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 function stGetFormCheckBoxInput($name, $id, $prefix, $checked, $label, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
261 "<input ".$extra." type=\"checkbox\" ".stGetIDName($name, $id, $prefix).
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
262 ($checked ? "checked=\"checked\" " : "")." />".
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
263 ($label != "" ? "<label for=\"".$name."\">".$label."</label>" : "");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
267 function stGetFormRadioButtonInput($name, $id, $prefix, $value, $checked, $label, $extra = "")
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
268 {
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
269 return
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
270 "<input ".$extra." type=\"radio\" ".stGetIDName($name, $id, $prefix).
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
271 ($checked ? "checked=\"checked\" " : "")." value=\"".$value."\" />".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
272 ($label != "" ? "<label for=\"".$name."\">".$label."</label>" : "");
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
273 }
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
274
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
275
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 function stGetFormButtonInput($name, $id, $prefix, $label, $onclick = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
279 "<input type=\"button\" ".stGetIDName($name, $id, $prefix).
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
280 "value=\" ".chentities($label)." \" ".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 ($onclick != "" ? "onClick=\"".$onclick."\"" : "")." />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 function stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
288 "<textarea ".$extra." ".stGetIDName($name, $id, $prefix).
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
289 "rows=\"".$rows."\" cols=\"".$cols."\">".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 (isset($value) ? chentities($value) : "").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 "</textarea>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 function stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
298 "<input ".$extra." type=\"text\" ".stGetIDName($name, $id, $prefix).
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
299 "size=\"".$size."\" maxlength=\"".$len."\"".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 (isset($value) ? " value=\"".chentities($value)."\"" : "").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 " />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 function stGetFormPasswordInput($name, $id, $prefix)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 return
13
cb4af708e295 Simplify.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
308 "<input type=\"password\" ".stGetIDName($name, $id, $prefix)." />";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
312 function stGetFormSubmitInput($name, $label, $onclick = "")
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
313 {
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
314 return
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
315 "<input type=\"submit\" name=\"".$name.
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
316 "\" value=\" ".chentities($label)." \" ".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
317 ($onclick != "" ? "onClick=\"".$onclick."\"" : "")." />";
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
318 }
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
319
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
320
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 function stGetFormHiddenInput($name, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 {
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
323 return
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
324 "<input type=\"hidden\" name=\"".$name.
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
325 "\" value=\"".chentities($value)."\" />";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
329 function stGetFormStart($name, $action = "", $method = "post")
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
330 {
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
331 return
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
332 "<form name=\"".$name."\" action=\"".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
333 ($action != "" ? $action : $name).
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
334 "\" method=\"".$method."\">\n";
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
335 }
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
336
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
337
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 function stGetTDEditTextItem($edit, $size, $len, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 "<td class=\"".$name."\">".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 "</td>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 function stPrintFormTextInput($text1, $text2, $size, $len, $name, $extra="")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 echo " <tr><th>".chentities($text1)."</th><td>".
15
ea0f98a0bed8 Fix some issues and bugs caused by recent changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 13
diff changeset
350 stGetFormTextInput($size, $len, $name, "", "", stGetRequestItem($name), $extra).
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 "</td><td>".chentities($text2)."</td></tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 function stPrintFormHiddenInput($name, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 echo " ".stGetFormHiddenInput($name, $value)."\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 function stPrintAttendee($item, $row, $edit, $eclass = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 $id = $item["id"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 $prefix = "at";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 echo " ".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 "<tr class=\"".($row % 2 == 1 ? "rodd" : "reven").$eclass."\" id=\"attendee".$id."\">".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 stGetTDEditTextItem(FALSE, 20, 40, "name", $id, $prefix, $item["name"]).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 stGetTDEditTextItem(FALSE, 20, 40, "groups", $id, $prefix, $item["groups"]).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 "<td class=\"regtime\">".date("d M Y / H:i", $item["regtime"])."</td>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 stGetTDEditTextItem($edit, 30, 64, "oneliner", $id, $prefix, $item["oneliner"], "autocomplete=\"off\"");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 if ($edit)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 echo
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 stGetTDEditTextItem($edit, 20, 40, "email", $id, $prefix, $item["email"], "autocomplete=\"off\"").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 "<td>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 "<button class=\"button\" id=\"atupd".$id."\" type=\"button\" onclick=\"updateAttendee(".$id.")\">Update</button>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 "<button class=\"button\" id=\"atdel".$id."\" type=\"button\" onclick=\"deleteAttendee(".$id.")\">Delete</button>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 "</td>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 echo "</tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 function stPrintNewsItem($item, $edit = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 echo
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 "<div class=\"newsitem\" id=\"news".$item["id"]."\">\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 " <h2>".chentities($item["title"])."</h2>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 " <div class=\"text\">".dhentities($item["text"])."</div>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 " <div class=\"sig\">-- ".chentities($item["author"])."<br />".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 date("d M Y / H:i", $item["utime"]).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 $edit."</div>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 "</div>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 function stChkDataItem($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 return !isset($_REQUEST[$name]) || strlen(trim($_REQUEST[$name])) < 1;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 function stChkRequestItem($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 return isset($_REQUEST[$name]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 function stGetRequestItem($name, $default = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 return isset($_REQUEST[$name]) ? trim($_REQUEST[$name]) : $default;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 function stGetDRequestItem($name, $default = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 return trim(urldecode(stGetRequestItem($name, $default)));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
423 function stGetSessionItem($name, $default = "")
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
424 {
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
425 global $sessionType;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
426 if (isset($sessionType))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
427 return (isset($_SESSION[$sessionType]) && isset($_SESSION[$sessionType][$name])) ? trim($_SESSION[$sessionType][$name]) : $default;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
428 else
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
429 return isset($_SESSION[$name]) ? trim($_SESSION[$name]) : $default;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
430 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
431
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
432
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
433 function stSetSessionItem($name, $value)
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
434 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
435 global $sessionType;
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
436 if (!isset($sessionType))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
437 die("Session type not set.");
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
438
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
439 $_SESSION[$sessionType][$name] = $value;
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
440 }
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
441
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
442
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 function stLogSQLError($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446 error_log("SQL error ".implode("; ", $db->errorInfo())." in statement \"".$sql."\"");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
449
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
450 function stConnectSQLDB()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 try {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
454 $db = new PDO(stGetSetting("sqlDB"));
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
456 catch (PDOException $e) {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457 error_log("Could not connect to SQL database: ".$e->getMessage().".");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460 return TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
461 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 function stGetSQLParam($type, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
466 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 switch ($type)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469 case "d":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470 return intval($value);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472 case "s":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473 return $db->quote($value);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
474
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
475 case "D":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
476 return intval(stGetRequestItem($value));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478 case "S":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
479 return $db->quote(stGetDRequestItem($value));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
480
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 case "Q":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 return $db->quote(stripslashes(stGetDRequestItem($value)));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 case "B":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 return intval(stGetRequestItem($value)) ? 1 : 0;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
489
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
490 function stPrepareSQL()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
491 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 $argc = func_num_args();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493 $argv = func_get_args();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494 if ($argc < 1)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
495 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496 error_log("Invalid stPrepareSQL() call, no arguments!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
500 $fmt = $argv[0];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 $len = strlen($fmt);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
502 $sql = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 $argn = 1;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504 $pos = 0;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 while ($pos < $len)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 if ($fmt[$pos] == "%")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509 if ($argn < $argc)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 $sql .= stGetSQLParam($fmt[++$pos], $argv[$argn++]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 error_log("Invalid SQL statement format string '".$fmt.
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514 "', not enough parameters specified (".$argn." of ".$argc.")");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
519 $sql .= $fmt[$pos];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
520 $pos++;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 return $sql;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527 function stPrepareSQLUpdate($table, $cond, $pairs)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529 $sql = array();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530 foreach ($pairs as $name => $attr)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
531 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532 $sql[] = $name."=".stGetSQLParam($attr, $name);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
533 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
534 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
535 "UPDATE ".$table." SET ".implode(",", $sql).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
536 ($cond != "" ? " ".$cond : "");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
538
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
540 function stExecSQL($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
542 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
543 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544 return $res;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
546 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
547 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
548 stError("Oh noes! SQL error #23!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
551 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
553
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
554 function stFetchSQL($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
555 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
556 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
557 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
558 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
559 return $res->fetch();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
560 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
561 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
562 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
563 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
564 stError("Oh noes! SQL error #31!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
565 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
570 function stFetchSQLColumn($sql, $column = 0)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
571 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
572 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
573 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
575 return $res->fetchColumn($column);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
576 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
577 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
578 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
579 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580 stError("Oh noes! SQL error #81!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
581 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
582 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
583 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
584
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
585
24
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
586 function stGetCompoList($fvisible, $fvoting = FALSE)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
587 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
588 global $compos;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
589
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
590 // Get entries and competitions into an array structure
24
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
591 $sql = "SELECT * FROM compos";
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
592 if ($fvisible || $fvoting)
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
593 {
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
594 $sql .= " WHERE ".implode(" AND ", array($fvisible ? "visible<>0" : "", $fvoting ? "voting<>0" : ""));
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
595 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
596 foreach (stExecSQL($sql) as $compo)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
597 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
598 $id = $compo["id"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
599
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
600 $compos[$compo["id"]] = array(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
601 "name" => $compo["name"],
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
602 "entries" => array()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
603 );
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
604
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
605 $sql = stPrepareSQL("SELECT * FROM entries WHERE compo_id=%d", $id);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606 foreach (stExecSQL($sql) as $entry)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
607 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608 $compos[$id]["entries"][$entry["id"]] = $entry;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
609 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
610 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
611 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
612
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
613
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
614 //
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
615 // CLI utility helper functions
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
616 //
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
617 function stCArg($index)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
618 {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
619 global $argc, $argv;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
620 if ($index < $argc)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
621 return $argv[$index];
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
622 else
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
623 return FALSE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
624 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
625
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
626 function stCArgLC($index)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
627 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
628 global $argc, $argv;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
629 if ($index < $argc)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
630 return strtolower($argv[$index]);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
631 else
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
632 return FALSE;
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
635
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
636 function stCSQLError($sql)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
637 {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
638 global $db;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
639 die("Error executing SQL query: ".implode("; ", $db->errorInfo())." in statement \"".$sql."\"\n");
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
640 exit;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
641 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
642
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
643
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
644 function stCheckCLIOrDie()
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
645 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
646 if (php_sapi_name() != "cli" || !empty($_SERVER["REMOTE_ADDR"]))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
647 {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
648 header("Status: 404 Not Found");
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
649 die();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
651 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
652
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
653
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
654 ?>