annotate msite.inc.php @ 87:3da47d3e6a3c

Remove a function, etc.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 18 Oct 2013 09:47:15 +0300
parents 63a6caf59e5c
children 6edd7d623eab
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
33
5bf22431176c Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
4 // Generic and miscellaneous site support code
9
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
5 // (C) Copyright 2012 Matti 'ccr' Hamalainen <ccr@tnsp.org>
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 //
9
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
7
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
8 // Globals and definitions
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 $errorSet = FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 $errorMsg = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
12 define("VT_STR", 1);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
13 define("VT_INT", 2);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
14 define("VT_BOOL", 3);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
15 define("VT_TEXT", 4);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
16
51
7bdf89601ba0 Work on session stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
17 define("SESS_USER", "user");
7bdf89601ba0 Work on session stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
18 define("SESS_ADMIN", "admin");
7bdf89601ba0 Work on session stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
19
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
20
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
21 if (function_exists("ini_set"))
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
22 {
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
23 // Use cookies to store the session ID on the client side
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
24 @ini_set("session.use_only_cookies", 1);
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 // Disable transparent Session ID support
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
27 @ini_set("session.use_trans_sid", 0);
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
28 }
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
29
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
30
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 function stError($msg)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 global $errorSet, $errorMsg;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 $errorSet = TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 $errorMsg .= "<li>".$msg."</li>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 function stCheckHTTPS()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 return isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != "" && $_SERVER["HTTPS"] != "off");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 function stSetupCacheControl()
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
46 {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
47 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
48 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
49 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
50
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
51
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
52 function stReloadSettings()
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
53 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
54 global $siteSettings;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
55 $res = stExecSQL("SELECT * FROM settings");
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
56 if ($res !== FALSE)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
57 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
58 foreach ($res as $row)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
59 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
60 switch ($row["vtype"])
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
61 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
62 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
63 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
64 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
65 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
66 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
67 $siteSettings[$row["key"]] = $val;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
68 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
69 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
70 else
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
71 die("Error fetching site settings.");
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
72 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
73
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
74
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
75 function stGetSetting($name)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
77 global $siteSettings;
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 if (isset($siteSettings[$name]))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 return $siteSettings[$name];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 else
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
81 die("No config value for '".$name."'.\n");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 function stChkSetting($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 global $siteSettings;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 return isset($siteSettings[$name]) && $siteSettings[$name];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 function dhentities($str)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 return str_replace(array("&lt;","&gt;"), array("<", ">"), htmlentities($str, ENT_NOQUOTES, "UTF-8"));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 function chentities($str)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 return htmlentities($str, ENT_NOQUOTES, "UTF-8");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
104 function stGetIDName($name, $id, $prefix = "")
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
105 {
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
106 return
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
107 ($id != "" ? "id=\"".$prefix.$name.$id."\" " : "").
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
108 ($name != "" ? "name=\"".$prefix.$name.$id."\" " : "");
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
109 }
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
110
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
111
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 function stGetFormCheckBoxInput($name, $id, $prefix, $checked, $label, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
115 "<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
116 ($checked ? "checked=\"checked\" " : "")." />".
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
117 ($label != "" ? "<label for=\"".$name."\">".$label."</label>" : "");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
121 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
122 {
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
123 return
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
124 "<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
125 ($checked ? "checked=\"checked\" " : "")." value=\"".$value."\" />".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
126 ($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
127 }
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
128
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
129
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 function stGetFormButtonInput($name, $id, $prefix, $label, $onclick = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
133 "<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
134 "value=\" ".chentities($label)." \" ".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 ($onclick != "" ? "onClick=\"".$onclick."\"" : "")." />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 function stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
142 "<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
143 "rows=\"".$rows."\" cols=\"".$cols."\">".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 (isset($value) ? chentities($value) : "").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 "</textarea>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 function stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 return
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
152 "<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
153 "size=\"".$size."\" maxlength=\"".$len."\"".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 (isset($value) ? " value=\"".chentities($value)."\"" : "").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 " />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 function stGetFormPasswordInput($name, $id, $prefix)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 return
13
cb4af708e295 Simplify.
Matti Hamalainen <ccr@tnsp.org>
parents: 12
diff changeset
162 "<input type=\"password\" ".stGetIDName($name, $id, $prefix)." />";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
166 function stGetFormSubmitInput($name, $label, $onclick = "")
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
167 {
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
168 return
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
169 "<input type=\"submit\" name=\"".$name.
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
170 "\" value=\" ".chentities($label)." \" ".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
171 ($onclick != "" ? "onClick=\"".$onclick."\"" : "")." />";
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
172 }
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
173
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
174
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 function stGetFormHiddenInput($name, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 {
12
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
177 return
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
178 "<input type=\"hidden\" name=\"".$name.
358534308c61 Clean up some of the html item generation code.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
179 "\" value=\"".chentities($value)."\" />";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
183 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
184 {
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
185 return
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
186 "<form name=\"".$name."\" action=\"".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
187 ($action != "" ? $action : $name).
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
188 "\" method=\"".$method."\">\n";
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
189 }
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
190
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
191
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 function stGetTDEditTextItem($edit, $size, $len, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 "<td class=\"".$name."\">".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 "</td>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 function stPrintFormTextInput($text1, $text2, $size, $len, $name, $extra="")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 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
204 stGetFormTextInput($size, $len, $name, "", "", stGetRequestItem($name), $extra).
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 "</td><td>".chentities($text2)."</td></tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 function stPrintFormHiddenInput($name, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 echo " ".stGetFormHiddenInput($name, $value)."\n";
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 stChkDataItem($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 return !isset($_REQUEST[$name]) || strlen(trim($_REQUEST[$name])) < 1;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 }
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 function stChkRequestItem($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 return isset($_REQUEST[$name]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 function stGetRequestItem($name, $default = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 return isset($_REQUEST[$name]) ? trim($_REQUEST[$name]) : $default;
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 function stGetDRequestItem($name, $default = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 return trim(urldecode(stGetRequestItem($name, $default)));
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 function stLogSQLError($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 error_log("SQL error ".implode("; ", $db->errorInfo())." in statement \"".$sql."\"");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 function stConnectSQLDB()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 try {
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
250 $db = new PDO(stGetSetting("sqlDB"));
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 catch (PDOException $e) {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 error_log("Could not connect to SQL database: ".$e->getMessage().".");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 return TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 function stGetSQLParam($type, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 switch ($type)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 case "d":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 return intval($value);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 case "s":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 return $db->quote($value);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270
72
63a6caf59e5c Fix creation of boolean settings, and add '%b' formatter into stPrepareSQL().
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
271 case "b":
63a6caf59e5c Fix creation of boolean settings, and add '%b' formatter into stPrepareSQL().
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
272 return intval($value) ? 1 : 0;
63a6caf59e5c Fix creation of boolean settings, and add '%b' formatter into stPrepareSQL().
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
273
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 case "D":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 return intval(stGetRequestItem($value));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 case "S":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 return $db->quote(stGetDRequestItem($value));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 case "Q":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 return $db->quote(stripslashes(stGetDRequestItem($value)));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 case "B":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 return intval(stGetRequestItem($value)) ? 1 : 0;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 function stPrepareSQL()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 $argc = func_num_args();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 $argv = func_get_args();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 if ($argc < 1)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 error_log("Invalid stPrepareSQL() call, no arguments!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 }
87
3da47d3e6a3c Remove a function, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
298
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 $fmt = $argv[0];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 $len = strlen($fmt);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 $sql = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 $argn = 1;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 $pos = 0;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 while ($pos < $len)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 if ($fmt[$pos] == "%")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 if ($argn < $argc)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 $sql .= stGetSQLParam($fmt[++$pos], $argv[$argn++]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 error_log("Invalid SQL statement format string '".$fmt.
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 "', not enough parameters specified (".$argn." of ".$argc.")");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 $sql .= $fmt[$pos];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 $pos++;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 return $sql;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 function stPrepareSQLUpdate($table, $cond, $pairs)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 $sql = array();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 foreach ($pairs as $name => $attr)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 $sql[] = $name."=".stGetSQLParam($attr, $name);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 "UPDATE ".$table." SET ".implode(",", $sql).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 ($cond != "" ? " ".$cond : "");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 function stExecSQL($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 return $res;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 stError("Oh noes! SQL error #23!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 function stFetchSQL($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 return $res->fetch();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 stError("Oh noes! SQL error #31!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 function stFetchSQLColumn($sql, $column = 0)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 return $res->fetchColumn($column);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 stError("Oh noes! SQL error #81!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
385 //
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
386 // Site-specific common functions .. these should be elsewhere
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
387 //
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
388 function stPrintAttendee($item, $row, $edit, $eclass = "")
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
389 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
390 $id = $item["id"];
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
391 $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
392 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
393
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
394 echo
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
395 stGetTDEditTextItem(FALSE, 20, 40, "name", $id, $prefix, $item["name"]).
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
396 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
397 "<td class=\"regtime\">".date("d.m. H:i", $item["regtime"])."</td>".
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
398 stGetTDEditTextItem($edit, 30, 64, "oneliner", $id, $prefix, $item["oneliner"], "autocomplete=\"off\"");
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
399
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
400 if ($edit)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
401 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
402 echo
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
403 stGetTDEditTextItem($edit, 20, 40, "email", $id, $prefix, $item["email"], "autocomplete=\"off\"").
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
404 "<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
405 "<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
406 "<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
407 "</td>";
37
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
408 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
409
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
410 echo "</tr>\n";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
411 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
412
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
413
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
414 function stPrintNewsItem($item, $edit = "")
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
415 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
416 echo
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
417 "<div class=\"newsitem\" id=\"news".$item["id"]."\">\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
418 " <h2>".chentities($item["title"])."</h2>\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
419 " <div class=\"text\">".dhentities($item["text"])."</div>\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
420 " <div class=\"sig\">-- ".chentities($item["author"])."<br />".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
421 date("d M Y / H:i", $item["utime"]).
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
422 $edit."</div>\n".
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
423 "</div>\n";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
424 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
425
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
426
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
427 function stGetCompoList($fvisible, $fvoting = FALSE)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
428 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
429 global $compos;
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
430
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
431 // Get entries and competitions into an array structure
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
432 $sql = "SELECT * FROM compos";
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
433 if ($fvisible || $fvoting)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
434 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
435 $sql .= " WHERE ".implode(" AND ", array($fvisible ? "visible<>0" : "", $fvoting ? "voting<>0" : ""));
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
436 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
437 foreach (stExecSQL($sql) as $compo)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
438 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
439 $id = $compo["id"];
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
440
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
441 $compos[$compo["id"]] = array(
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
442 "name" => $compo["name"],
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
443 "entries" => array()
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
444 );
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
445
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
446 $sql = stPrepareSQL("SELECT * FROM entries WHERE compo_id=%d", $id);
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
447 foreach (stExecSQL($sql) as $entry)
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
448 {
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
449 $compos[$id]["entries"][$entry["id"]] = $entry;
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
450 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
451 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
452 }
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
453
238c73840b61 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
454
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
455 function stGenerateUserKey()
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
456 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
457 global $db;
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
458 $keyChars = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
459
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
460 while (TRUE)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
461 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
462 // Generate one randomized keycode
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
463 $key = "";
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
464 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
465 $key .= $keyChars[rand() % strlen($keyChars)];
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
466
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
467 // 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
468 // 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
469 // 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
470 $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
471 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
472 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
473 // Did we get results?
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
474 if ($res->fetchColumn() === FALSE)
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
475 {
69
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
476 // Nope, return key
30a4420e85ab stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
477 return $key;
65
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
478 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
479 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
480 else
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
481 {
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
482 stLogSQLError($sql);
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
483 return FALSE;
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
484 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
485 }
72b22729ae7e Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
486 }
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
487
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
488
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
489 function stSetStatus($val, $msg)
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
490 {
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
491 global $statusSet;
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
492 if (!$statusSet)
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
493 {
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
494 header("Status: ".$val." ".$msg);
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
495 }
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
496 $statusSet = TRUE;
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
497 }
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
498
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
499
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
500 function stExecSQLCond($sql, $okmsg)
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
501 {
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
502 if (($res = stExecSQL($sql)) !== FALSE)
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
503 {
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
504 if ($okmsg != "")
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
505 stSetStatus(200, $okmsg);
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
506 return $res;
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
507 }
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
508 else
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
509 {
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
510 stSetStatus(900, "Error in SQL execution.");
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
511 return FALSE;
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
512 }
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
513 }
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
514
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
515
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516 ?>