@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | |
50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
51 | 52 | |
52 | - if (pg_affected_rows($result) === 0) |
|
53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
53 | + if (pg_affected_rows($result) === 0) { |
|
54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | |
56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
60 | 62 | { |
61 | 63 | global $smcFunc, $db_connection; |
62 | 64 | |
63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
64 | - return false; |
|
65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
66 | + return false; |
|
67 | + } |
|
65 | 68 | |
66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
67 | 70 | $res = pg_fetch_assoc($result); |
68 | 71 | |
69 | - if ($res['server_version_num'] < 90500) |
|
70 | - return false; |
|
72 | + if ($res['server_version_num'] < 90500) { |
|
73 | + return false; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | return $test ? true : parent::isSupported(); |
73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
81 | 85 | |
82 | 86 | $ttl = time() - $ttl; |
83 | 87 | |
84 | - if (empty($this->pg_get_data_prep)) |
|
85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
88 | + if (empty($this->pg_get_data_prep)) { |
|
89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
88 | 93 | |
89 | - if (pg_affected_rows($result) === 0) |
|
90 | - return null; |
|
94 | + if (pg_affected_rows($result) === 0) { |
|
95 | + return null; |
|
96 | + } |
|
91 | 97 | |
92 | 98 | $res = pg_fetch_assoc($result); |
93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
101 | 107 | { |
102 | 108 | global $db_prefix, $db_connection; |
103 | 109 | |
104 | - if (!isset($value)) |
|
105 | - $value = ''; |
|
110 | + if (!isset($value)) { |
|
111 | + $value = ''; |
|
112 | + } |
|
106 | 113 | |
107 | 114 | $ttl = time() + $ttl; |
108 | 115 | |
109 | - if (empty($this->pg_put_data_prep)) |
|
110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
116 | + if (empty($this->pg_put_data_prep)) { |
|
117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
113 | 120 | ); |
121 | + } |
|
114 | 122 | |
115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
116 | 124 | |
117 | - if (pg_affected_rows($result) > 0) |
|
118 | - return true; |
|
119 | - else |
|
120 | - return false; |
|
125 | + if (pg_affected_rows($result) > 0) { |
|
126 | + return true; |
|
127 | + } else { |
|
128 | + return false; |
|
129 | + } |
|
121 | 130 | } |
122 | 131 | |
123 | 132 | /** |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | case 'datetime': |
256 | 256 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
257 | - return 'str_to_date('. |
|
258 | - sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
257 | + return 'str_to_date(' . |
|
258 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
259 | 259 | ',\'%Y-%m-%d %h:%i:%s\')'; |
260 | 260 | else |
261 | 261 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | { |
840 | 840 | $count = count($insertRows); |
841 | 841 | $ai = 0; |
842 | - for($i = 0; $i < $count; $i++) |
|
842 | + for ($i = 0; $i < $count; $i++) |
|
843 | 843 | { |
844 | 844 | $old_id = $smcFunc['db_insert_id'](); |
845 | 845 | |
@@ -865,13 +865,13 @@ discard block |
||
865 | 865 | $count2 = count($indexed_columns); |
866 | 866 | for ($x = 0; $x < $count2; $x++) |
867 | 867 | { |
868 | - $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
|
868 | + $where_string += key($indexed_columns[$x]) . ' = ' . $insertRows[$i][$x]; |
|
869 | 869 | if (($x + 1) < $count2) |
870 | 870 | $where_string += ' AND '; |
871 | 871 | } |
872 | 872 | |
873 | - $request = $smcFunc['db_query']('',' |
|
874 | - SELECT `'. $keys[0] . '` FROM ' . $table .' |
|
873 | + $request = $smcFunc['db_query']('', ' |
|
874 | + SELECT `'. $keys[0] . '` FROM ' . $table . ' |
|
875 | 875 | WHERE ' . $where_string . ' LIMIT 1', |
876 | 876 | array() |
877 | 877 | ); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | $return_var = array(); |
901 | 901 | $count = count($insertRows); |
902 | 902 | $start = smf_db_insert_id($table, $keys[0]); |
903 | - for ($i = 0; $i < $count; $i++ ) |
|
903 | + for ($i = 0; $i < $count; $i++) |
|
904 | 904 | $return_var[] = $start + $i; |
905 | 905 | } |
906 | 906 | return $return_var; |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
1034 | 1034 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
1035 | 1035 | $error_array[7], $error_array[8]); |
1036 | - mysqli_stmt_execute ($mysql_error_data_prep); |
|
1036 | + mysqli_stmt_execute($mysql_error_data_prep); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | ?> |
1040 | 1040 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
33 | 34 | global $smcFunc; |
34 | 35 | |
35 | 36 | // Map some database specific functions, only do this once. |
36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
37 | - $smcFunc += array( |
|
37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
38 | + $smcFunc += array( |
|
38 | 39 | 'db_query' => 'smf_db_query', |
39 | 40 | 'db_quote' => 'smf_db_quote', |
40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -62,9 +63,11 @@ discard block |
||
62 | 63 | 'db_fetch_all' => 'smf_db_fetch_all', |
63 | 64 | 'db_error_insert' => 'smf_db_error_insert', |
64 | 65 | ); |
66 | + } |
|
65 | 67 | |
66 | - if (!empty($db_options['persist'])) |
|
67 | - $db_server = 'p:' . $db_server; |
|
68 | + if (!empty($db_options['persist'])) { |
|
69 | + $db_server = 'p:' . $db_server; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | $connection = mysqli_init(); |
70 | 73 | |
@@ -73,24 +76,27 @@ discard block |
||
73 | 76 | $success = false; |
74 | 77 | |
75 | 78 | if ($connection) { |
76 | - if (!empty($db_options['port'])) |
|
77 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
78 | - else |
|
79 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
79 | + if (!empty($db_options['port'])) { |
|
80 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
81 | + } else { |
|
82 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
83 | + } |
|
80 | 84 | } |
81 | 85 | |
82 | 86 | // Something's wrong, show an error if its fatal (which we assume it is) |
83 | 87 | if ($success === false) |
84 | 88 | { |
85 | - if (!empty($db_options['non_fatal'])) |
|
86 | - return null; |
|
87 | - else |
|
88 | - display_db_error(); |
|
89 | + if (!empty($db_options['non_fatal'])) { |
|
90 | + return null; |
|
91 | + } else { |
|
92 | + display_db_error(); |
|
93 | + } |
|
89 | 94 | } |
90 | 95 | |
91 | 96 | // Select the database, unless told not to |
92 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
93 | - display_db_error(); |
|
97 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
98 | + display_db_error(); |
|
99 | + } |
|
94 | 100 | |
95 | 101 | $smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'', |
96 | 102 | array(), |
@@ -166,34 +172,42 @@ discard block |
||
166 | 172 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
167 | 173 | |
168 | 174 | list ($values, $connection) = $db_callback; |
169 | - if (!is_object($connection)) |
|
170 | - display_db_error(); |
|
175 | + if (!is_object($connection)) { |
|
176 | + display_db_error(); |
|
177 | + } |
|
171 | 178 | |
172 | - if ($matches[1] === 'db_prefix') |
|
173 | - return $db_prefix; |
|
179 | + if ($matches[1] === 'db_prefix') { |
|
180 | + return $db_prefix; |
|
181 | + } |
|
174 | 182 | |
175 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
176 | - return $user_info[$matches[1]]; |
|
183 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
184 | + return $user_info[$matches[1]]; |
|
185 | + } |
|
177 | 186 | |
178 | - if ($matches[1] === 'empty') |
|
179 | - return '\'\''; |
|
187 | + if ($matches[1] === 'empty') { |
|
188 | + return '\'\''; |
|
189 | + } |
|
180 | 190 | |
181 | - if (!isset($matches[2])) |
|
182 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
191 | + if (!isset($matches[2])) { |
|
192 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
193 | + } |
|
183 | 194 | |
184 | - if ($matches[1] === 'literal') |
|
185 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
195 | + if ($matches[1] === 'literal') { |
|
196 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
197 | + } |
|
186 | 198 | |
187 | - if (!isset($values[$matches[2]])) |
|
188 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
199 | + if (!isset($values[$matches[2]])) { |
|
200 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
201 | + } |
|
189 | 202 | |
190 | 203 | $replacement = $values[$matches[2]]; |
191 | 204 | |
192 | 205 | switch ($matches[1]) |
193 | 206 | { |
194 | 207 | case 'int': |
195 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
196 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
208 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
209 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
210 | + } |
|
197 | 211 | return (string) (int) $replacement; |
198 | 212 | break; |
199 | 213 | |
@@ -205,65 +219,73 @@ discard block |
||
205 | 219 | case 'array_int': |
206 | 220 | if (is_array($replacement)) |
207 | 221 | { |
208 | - if (empty($replacement)) |
|
209 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
222 | + if (empty($replacement)) { |
|
223 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
224 | + } |
|
210 | 225 | |
211 | 226 | foreach ($replacement as $key => $value) |
212 | 227 | { |
213 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
214 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
228 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
229 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
230 | + } |
|
215 | 231 | |
216 | 232 | $replacement[$key] = (string) (int) $value; |
217 | 233 | } |
218 | 234 | |
219 | 235 | return implode(', ', $replacement); |
236 | + } else { |
|
237 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
220 | 238 | } |
221 | - else |
|
222 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
223 | 239 | |
224 | 240 | break; |
225 | 241 | |
226 | 242 | case 'array_string': |
227 | 243 | if (is_array($replacement)) |
228 | 244 | { |
229 | - if (empty($replacement)) |
|
230 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
245 | + if (empty($replacement)) { |
|
246 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
247 | + } |
|
231 | 248 | |
232 | - foreach ($replacement as $key => $value) |
|
233 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
249 | + foreach ($replacement as $key => $value) { |
|
250 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
251 | + } |
|
234 | 252 | |
235 | 253 | return implode(', ', $replacement); |
254 | + } else { |
|
255 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
236 | 256 | } |
237 | - else |
|
238 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
239 | 257 | break; |
240 | 258 | |
241 | 259 | case 'date': |
242 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
243 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
244 | - else |
|
245 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
260 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
261 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
262 | + } else { |
|
263 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
264 | + } |
|
246 | 265 | break; |
247 | 266 | |
248 | 267 | case 'time': |
249 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
250 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
251 | - else |
|
252 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
268 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
269 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
270 | + } else { |
|
271 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
272 | + } |
|
253 | 273 | break; |
254 | 274 | |
255 | 275 | case 'datetime': |
256 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
257 | - return 'str_to_date('. |
|
276 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
277 | + return 'str_to_date('. |
|
258 | 278 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
259 | 279 | ',\'%Y-%m-%d %h:%i:%s\')'; |
260 | - else |
|
261 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
280 | + } else { |
|
281 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
282 | + } |
|
262 | 283 | break; |
263 | 284 | |
264 | 285 | case 'float': |
265 | - if (!is_numeric($replacement)) |
|
266 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
286 | + if (!is_numeric($replacement)) { |
|
287 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
288 | + } |
|
267 | 289 | return (string) (float) $replacement; |
268 | 290 | break; |
269 | 291 | |
@@ -277,32 +299,37 @@ discard block |
||
277 | 299 | break; |
278 | 300 | |
279 | 301 | case 'inet': |
280 | - if ($replacement == 'null' || $replacement == '') |
|
281 | - return 'null'; |
|
282 | - if (!isValidIP($replacement)) |
|
283 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
302 | + if ($replacement == 'null' || $replacement == '') { |
|
303 | + return 'null'; |
|
304 | + } |
|
305 | + if (!isValidIP($replacement)) { |
|
306 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
307 | + } |
|
284 | 308 | //we don't use the native support of mysql > 5.6.2 |
285 | 309 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
286 | 310 | |
287 | 311 | case 'array_inet': |
288 | 312 | if (is_array($replacement)) |
289 | 313 | { |
290 | - if (empty($replacement)) |
|
291 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
314 | + if (empty($replacement)) { |
|
315 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
316 | + } |
|
292 | 317 | |
293 | 318 | foreach ($replacement as $key => $value) |
294 | 319 | { |
295 | - if ($replacement == 'null' || $replacement == '') |
|
296 | - $replacement[$key] = 'null'; |
|
297 | - if (!isValidIP($value)) |
|
298 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
320 | + if ($replacement == 'null' || $replacement == '') { |
|
321 | + $replacement[$key] = 'null'; |
|
322 | + } |
|
323 | + if (!isValidIP($value)) { |
|
324 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
325 | + } |
|
299 | 326 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
300 | 327 | } |
301 | 328 | |
302 | 329 | return implode(', ', $replacement); |
330 | + } else { |
|
331 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
303 | 332 | } |
304 | - else |
|
305 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
306 | 333 | break; |
307 | 334 | |
308 | 335 | default: |
@@ -378,22 +405,25 @@ discard block |
||
378 | 405 | // Are we in SSI mode? If so try that username and password first |
379 | 406 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
380 | 407 | { |
381 | - if (empty($db_persist)) |
|
382 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
383 | - else |
|
384 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
408 | + if (empty($db_persist)) { |
|
409 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
410 | + } else { |
|
411 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
412 | + } |
|
385 | 413 | } |
386 | 414 | // Fall back to the regular username and password if need be |
387 | 415 | if (!$db_connection) |
388 | 416 | { |
389 | - if (empty($db_persist)) |
|
390 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
391 | - else |
|
392 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
417 | + if (empty($db_persist)) { |
|
418 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
419 | + } else { |
|
420 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
421 | + } |
|
393 | 422 | } |
394 | 423 | |
395 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
396 | - $db_connection = false; |
|
424 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
425 | + $db_connection = false; |
|
426 | + } |
|
397 | 427 | |
398 | 428 | $connection = $db_connection; |
399 | 429 | } |
@@ -401,18 +431,20 @@ discard block |
||
401 | 431 | // One more query.... |
402 | 432 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
403 | 433 | |
404 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
405 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
434 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
435 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
436 | + } |
|
406 | 437 | |
407 | 438 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
408 | 439 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
409 | 440 | { |
410 | 441 | // Add before LIMIT |
411 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
412 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
413 | - else |
|
414 | - // Append it. |
|
442 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
443 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
444 | + } else { |
|
445 | + // Append it. |
|
415 | 446 | $db_string .= "\n\t\t\tORDER BY null"; |
447 | + } |
|
416 | 448 | } |
417 | 449 | |
418 | 450 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -434,8 +466,9 @@ discard block |
||
434 | 466 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
435 | 467 | |
436 | 468 | // Initialize $db_cache if not already initialized. |
437 | - if (!isset($db_cache)) |
|
438 | - $db_cache = array(); |
|
469 | + if (!isset($db_cache)) { |
|
470 | + $db_cache = array(); |
|
471 | + } |
|
439 | 472 | |
440 | 473 | if (!empty($_SESSION['debug_redirect'])) |
441 | 474 | { |
@@ -461,17 +494,18 @@ discard block |
||
461 | 494 | while (true) |
462 | 495 | { |
463 | 496 | $pos = strpos($db_string, '\'', $pos + 1); |
464 | - if ($pos === false) |
|
465 | - break; |
|
497 | + if ($pos === false) { |
|
498 | + break; |
|
499 | + } |
|
466 | 500 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
467 | 501 | |
468 | 502 | while (true) |
469 | 503 | { |
470 | 504 | $pos1 = strpos($db_string, '\'', $pos + 1); |
471 | 505 | $pos2 = strpos($db_string, '\\', $pos + 1); |
472 | - if ($pos1 === false) |
|
473 | - break; |
|
474 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
506 | + if ($pos1 === false) { |
|
507 | + break; |
|
508 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
475 | 509 | { |
476 | 510 | $pos = $pos1; |
477 | 511 | break; |
@@ -487,29 +521,35 @@ discard block |
||
487 | 521 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
488 | 522 | |
489 | 523 | // Comments? We don't use comments in our queries, we leave 'em outside! |
490 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
491 | - $fail = true; |
|
524 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
525 | + $fail = true; |
|
526 | + } |
|
492 | 527 | // Trying to change passwords, slow us down, or something? |
493 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
494 | - $fail = true; |
|
495 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
496 | - $fail = true; |
|
528 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
529 | + $fail = true; |
|
530 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
531 | + $fail = true; |
|
532 | + } |
|
497 | 533 | |
498 | - if (!empty($fail) && function_exists('log_error')) |
|
499 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
534 | + if (!empty($fail) && function_exists('log_error')) { |
|
535 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
536 | + } |
|
500 | 537 | } |
501 | 538 | |
502 | - if (empty($db_unbuffered)) |
|
503 | - $ret = @mysqli_query($connection, $db_string); |
|
504 | - else |
|
505 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
539 | + if (empty($db_unbuffered)) { |
|
540 | + $ret = @mysqli_query($connection, $db_string); |
|
541 | + } else { |
|
542 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
543 | + } |
|
506 | 544 | |
507 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
508 | - $ret = smf_db_error($db_string, $connection); |
|
545 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
546 | + $ret = smf_db_error($db_string, $connection); |
|
547 | + } |
|
509 | 548 | |
510 | 549 | // Debugging. |
511 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
512 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
550 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
551 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
552 | + } |
|
513 | 553 | |
514 | 554 | return $ret; |
515 | 555 | } |
@@ -556,12 +596,13 @@ discard block |
||
556 | 596 | // Decide which connection to use |
557 | 597 | $connection = $connection === null ? $db_connection : $connection; |
558 | 598 | |
559 | - if ($type == 'begin') |
|
560 | - return @mysqli_query($connection, 'BEGIN'); |
|
561 | - elseif ($type == 'rollback') |
|
562 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
563 | - elseif ($type == 'commit') |
|
564 | - return @mysqli_query($connection, 'COMMIT'); |
|
599 | + if ($type == 'begin') { |
|
600 | + return @mysqli_query($connection, 'BEGIN'); |
|
601 | + } elseif ($type == 'rollback') { |
|
602 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
603 | + } elseif ($type == 'commit') { |
|
604 | + return @mysqli_query($connection, 'COMMIT'); |
|
605 | + } |
|
565 | 606 | |
566 | 607 | return false; |
567 | 608 | } |
@@ -601,8 +642,9 @@ discard block |
||
601 | 642 | // 2013: Lost connection to server during query. |
602 | 643 | |
603 | 644 | // Log the error. |
604 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
605 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
645 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
646 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
647 | + } |
|
606 | 648 | |
607 | 649 | // Database error auto fixing ;). |
608 | 650 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -611,8 +653,9 @@ discard block |
||
611 | 653 | $old_cache = @$modSettings['cache_enable']; |
612 | 654 | $modSettings['cache_enable'] = '1'; |
613 | 655 | |
614 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
615 | - $db_last_error = max(@$db_last_error, $temp); |
|
656 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
657 | + $db_last_error = max(@$db_last_error, $temp); |
|
658 | + } |
|
616 | 659 | |
617 | 660 | if (@$db_last_error < time() - 3600 * 24 * 3) |
618 | 661 | { |
@@ -628,8 +671,9 @@ discard block |
||
628 | 671 | foreach ($tables as $table) |
629 | 672 | { |
630 | 673 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
631 | - if (trim($table) != '') |
|
632 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
674 | + if (trim($table) != '') { |
|
675 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
676 | + } |
|
633 | 677 | } |
634 | 678 | } |
635 | 679 | |
@@ -638,8 +682,9 @@ discard block |
||
638 | 682 | // Table crashed. Let's try to fix it. |
639 | 683 | elseif ($query_errno == 1016) |
640 | 684 | { |
641 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
642 | - $fix_tables = array('`' . $match[1] . '`'); |
|
685 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
686 | + $fix_tables = array('`' . $match[1] . '`'); |
|
687 | + } |
|
643 | 688 | } |
644 | 689 | // Indexes crashed. Should be easy to fix! |
645 | 690 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -658,13 +703,15 @@ discard block |
||
658 | 703 | |
659 | 704 | // Make a note of the REPAIR... |
660 | 705 | cache_put_data('db_last_error', time(), 600); |
661 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
662 | - updateSettingsFile(array('db_last_error' => time())); |
|
706 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
707 | + updateSettingsFile(array('db_last_error' => time())); |
|
708 | + } |
|
663 | 709 | |
664 | 710 | // Attempt to find and repair the broken table. |
665 | - foreach ($fix_tables as $table) |
|
666 | - $smcFunc['db_query']('', " |
|
711 | + foreach ($fix_tables as $table) { |
|
712 | + $smcFunc['db_query']('', " |
|
667 | 713 | REPAIR TABLE $table", false, false); |
714 | + } |
|
668 | 715 | |
669 | 716 | // And send off an email! |
670 | 717 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -673,11 +720,12 @@ discard block |
||
673 | 720 | |
674 | 721 | // Try the query again...? |
675 | 722 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
676 | - if ($ret !== false) |
|
677 | - return $ret; |
|
723 | + if ($ret !== false) { |
|
724 | + return $ret; |
|
725 | + } |
|
726 | + } else { |
|
727 | + $modSettings['cache_enable'] = $old_cache; |
|
678 | 728 | } |
679 | - else |
|
680 | - $modSettings['cache_enable'] = $old_cache; |
|
681 | 729 | |
682 | 730 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
683 | 731 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -687,22 +735,25 @@ discard block |
||
687 | 735 | // Are we in SSI mode? If so try that username and password first |
688 | 736 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
689 | 737 | { |
690 | - if (empty($db_persist)) |
|
691 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
692 | - else |
|
693 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
738 | + if (empty($db_persist)) { |
|
739 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
740 | + } else { |
|
741 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
742 | + } |
|
694 | 743 | } |
695 | 744 | // Fall back to the regular username and password if need be |
696 | 745 | if (!$db_connection) |
697 | 746 | { |
698 | - if (empty($db_persist)) |
|
699 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
700 | - else |
|
701 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
747 | + if (empty($db_persist)) { |
|
748 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
749 | + } else { |
|
750 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
751 | + } |
|
702 | 752 | } |
703 | 753 | |
704 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
705 | - $db_connection = false; |
|
754 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
755 | + $db_connection = false; |
|
756 | + } |
|
706 | 757 | } |
707 | 758 | |
708 | 759 | if ($db_connection) |
@@ -713,24 +764,27 @@ discard block |
||
713 | 764 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
714 | 765 | |
715 | 766 | $new_errno = mysqli_errno($db_connection); |
716 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
717 | - break; |
|
767 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
768 | + break; |
|
769 | + } |
|
718 | 770 | } |
719 | 771 | |
720 | 772 | // If it failed again, shucks to be you... we're not trying it over and over. |
721 | - if ($ret !== false) |
|
722 | - return $ret; |
|
773 | + if ($ret !== false) { |
|
774 | + return $ret; |
|
775 | + } |
|
723 | 776 | } |
724 | 777 | } |
725 | 778 | // Are they out of space, perhaps? |
726 | 779 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
727 | 780 | { |
728 | - if (!isset($txt)) |
|
729 | - $query_error .= ' - check database storage space.'; |
|
730 | - else |
|
781 | + if (!isset($txt)) { |
|
782 | + $query_error .= ' - check database storage space.'; |
|
783 | + } else |
|
731 | 784 | { |
732 | - if (!isset($txt['mysql_error_space'])) |
|
733 | - loadLanguage('Errors'); |
|
785 | + if (!isset($txt['mysql_error_space'])) { |
|
786 | + loadLanguage('Errors'); |
|
787 | + } |
|
734 | 788 | |
735 | 789 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
736 | 790 | } |
@@ -738,15 +792,17 @@ discard block |
||
738 | 792 | } |
739 | 793 | |
740 | 794 | // Nothing's defined yet... just die with it. |
741 | - if (empty($context) || empty($txt)) |
|
742 | - die($query_error); |
|
795 | + if (empty($context) || empty($txt)) { |
|
796 | + die($query_error); |
|
797 | + } |
|
743 | 798 | |
744 | 799 | // Show an error message, if possible. |
745 | 800 | $context['error_title'] = $txt['database_error']; |
746 | - if (allowedTo('admin_forum')) |
|
747 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
748 | - else |
|
749 | - $context['error_message'] = $txt['try_again']; |
|
801 | + if (allowedTo('admin_forum')) { |
|
802 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
803 | + } else { |
|
804 | + $context['error_message'] = $txt['try_again']; |
|
805 | + } |
|
750 | 806 | |
751 | 807 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
752 | 808 | { |
@@ -778,8 +834,9 @@ discard block |
||
778 | 834 | $return_var = null; |
779 | 835 | |
780 | 836 | // With nothing to insert, simply return. |
781 | - if (empty($data)) |
|
782 | - return; |
|
837 | + if (empty($data)) { |
|
838 | + return; |
|
839 | + } |
|
783 | 840 | |
784 | 841 | // Replace the prefix holder with the actual prefix. |
785 | 842 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -789,23 +846,26 @@ discard block |
||
789 | 846 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
790 | 847 | { |
791 | 848 | $with_returning = true; |
792 | - if ($returnmode == 2) |
|
793 | - $return_var = array(); |
|
849 | + if ($returnmode == 2) { |
|
850 | + $return_var = array(); |
|
851 | + } |
|
794 | 852 | } |
795 | 853 | |
796 | 854 | // Inserting data as a single row can be done as a single array. |
797 | - if (!is_array($data[array_rand($data)])) |
|
798 | - $data = array($data); |
|
855 | + if (!is_array($data[array_rand($data)])) { |
|
856 | + $data = array($data); |
|
857 | + } |
|
799 | 858 | |
800 | 859 | // Create the mold for a single row insert. |
801 | 860 | $insertData = '('; |
802 | 861 | foreach ($columns as $columnName => $type) |
803 | 862 | { |
804 | 863 | // Are we restricting the length? |
805 | - if (strpos($type, 'string-') !== false) |
|
806 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
807 | - else |
|
808 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
864 | + if (strpos($type, 'string-') !== false) { |
|
865 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
866 | + } else { |
|
867 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
868 | + } |
|
809 | 869 | } |
810 | 870 | $insertData = substr($insertData, 0, -2) . ')'; |
811 | 871 | |
@@ -814,8 +874,9 @@ discard block |
||
814 | 874 | |
815 | 875 | // Here's where the variables are injected to the query. |
816 | 876 | $insertRows = array(); |
817 | - foreach ($data as $dataRow) |
|
818 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
877 | + foreach ($data as $dataRow) { |
|
878 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
879 | + } |
|
819 | 880 | |
820 | 881 | // Determine the method of insertion. |
821 | 882 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -834,8 +895,7 @@ discard block |
||
834 | 895 | ), |
835 | 896 | $connection |
836 | 897 | ); |
837 | - } |
|
838 | - else //special way for ignore method with returning |
|
898 | + } else //special way for ignore method with returning |
|
839 | 899 | { |
840 | 900 | $count = count($insertRows); |
841 | 901 | $ai = 0; |
@@ -855,19 +915,21 @@ discard block |
||
855 | 915 | ); |
856 | 916 | $new_id = $smcFunc['db_insert_id'](); |
857 | 917 | |
858 | - if ($last_id != $new_id) //the inserted value was new |
|
918 | + if ($last_id != $new_id) { |
|
919 | + //the inserted value was new |
|
859 | 920 | { |
860 | 921 | $ai = $new_id; |
861 | 922 | } |
862 | - else // the inserted value already exists we need to find the pk |
|
923 | + } else // the inserted value already exists we need to find the pk |
|
863 | 924 | { |
864 | 925 | $where_string = ''; |
865 | 926 | $count2 = count($indexed_columns); |
866 | 927 | for ($x = 0; $x < $count2; $x++) |
867 | 928 | { |
868 | 929 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
869 | - if (($x + 1) < $count2) |
|
870 | - $where_string += ' AND '; |
|
930 | + if (($x + 1) < $count2) { |
|
931 | + $where_string += ' AND '; |
|
932 | + } |
|
871 | 933 | } |
872 | 934 | |
873 | 935 | $request = $smcFunc['db_query']('',' |
@@ -883,25 +945,27 @@ discard block |
||
883 | 945 | } |
884 | 946 | } |
885 | 947 | |
886 | - if ($returnmode == 1) |
|
887 | - $return_var = $ai; |
|
888 | - else if ($returnmode == 2) |
|
889 | - $return_var[] = $ai; |
|
948 | + if ($returnmode == 1) { |
|
949 | + $return_var = $ai; |
|
950 | + } else if ($returnmode == 2) { |
|
951 | + $return_var[] = $ai; |
|
952 | + } |
|
890 | 953 | } |
891 | 954 | } |
892 | 955 | |
893 | 956 | |
894 | 957 | if ($with_returning) |
895 | 958 | { |
896 | - if ($returnmode == 1 && empty($return_var)) |
|
897 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
898 | - else if ($returnmode == 2 && empty($return_var)) |
|
959 | + if ($returnmode == 1 && empty($return_var)) { |
|
960 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
961 | + } else if ($returnmode == 2 && empty($return_var)) |
|
899 | 962 | { |
900 | 963 | $return_var = array(); |
901 | 964 | $count = count($insertRows); |
902 | 965 | $start = smf_db_insert_id($table, $keys[0]); |
903 | - for ($i = 0; $i < $count; $i++ ) |
|
904 | - $return_var[] = $start + $i; |
|
966 | + for ($i = 0; $i < $count; $i++ ) { |
|
967 | + $return_var[] = $start + $i; |
|
968 | + } |
|
905 | 969 | } |
906 | 970 | return $return_var; |
907 | 971 | } |
@@ -919,8 +983,9 @@ discard block |
||
919 | 983 | */ |
920 | 984 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
921 | 985 | { |
922 | - if (empty($log_message)) |
|
923 | - $log_message = $error_message; |
|
986 | + if (empty($log_message)) { |
|
987 | + $log_message = $error_message; |
|
988 | + } |
|
924 | 989 | |
925 | 990 | foreach (debug_backtrace() as $step) |
926 | 991 | { |
@@ -939,12 +1004,14 @@ discard block |
||
939 | 1004 | } |
940 | 1005 | |
941 | 1006 | // A special case - we want the file and line numbers for debugging. |
942 | - if ($error_type == 'return') |
|
943 | - return array($file, $line); |
|
1007 | + if ($error_type == 'return') { |
|
1008 | + return array($file, $line); |
|
1009 | + } |
|
944 | 1010 | |
945 | 1011 | // Is always a critical error. |
946 | - if (function_exists('log_error')) |
|
947 | - log_error($log_message, 'critical', $file, $line); |
|
1012 | + if (function_exists('log_error')) { |
|
1013 | + log_error($log_message, 'critical', $file, $line); |
|
1014 | + } |
|
948 | 1015 | |
949 | 1016 | if (function_exists('fatal_error')) |
950 | 1017 | { |
@@ -952,12 +1019,12 @@ discard block |
||
952 | 1019 | |
953 | 1020 | // Cannot continue... |
954 | 1021 | exit; |
1022 | + } elseif ($error_type) { |
|
1023 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
1024 | + } else { |
|
1025 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
1026 | + } |
|
955 | 1027 | } |
956 | - elseif ($error_type) |
|
957 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
958 | - else |
|
959 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
960 | -} |
|
961 | 1028 | |
962 | 1029 | /** |
963 | 1030 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -974,10 +1041,11 @@ discard block |
||
974 | 1041 | '\\' => '\\\\', |
975 | 1042 | ); |
976 | 1043 | |
977 | - if ($translate_human_wildcards) |
|
978 | - $replacements += array( |
|
1044 | + if ($translate_human_wildcards) { |
|
1045 | + $replacements += array( |
|
979 | 1046 | '*' => '%', |
980 | 1047 | ); |
1048 | + } |
|
981 | 1049 | |
982 | 1050 | return strtr($string, $replacements); |
983 | 1051 | } |
@@ -991,8 +1059,9 @@ discard block |
||
991 | 1059 | */ |
992 | 1060 | function smf_is_resource($result) |
993 | 1061 | { |
994 | - if ($result instanceof mysqli_result) |
|
995 | - return true; |
|
1062 | + if ($result instanceof mysqli_result) { |
|
1063 | + return true; |
|
1064 | + } |
|
996 | 1065 | |
997 | 1066 | return false; |
998 | 1067 | } |
@@ -1020,16 +1089,18 @@ discard block |
||
1020 | 1089 | global $db_prefix, $db_connection; |
1021 | 1090 | static $mysql_error_data_prep; |
1022 | 1091 | |
1023 | - if (empty($mysql_error_data_prep)) |
|
1024 | - $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
1092 | + if (empty($mysql_error_data_prep)) { |
|
1093 | + $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
1025 | 1094 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
1026 | 1095 | VALUES( ?, ?, unhex(?), ?, ?, ?, ?, ?, ?)' |
1027 | 1096 | ); |
1097 | + } |
|
1028 | 1098 | |
1029 | - if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) |
|
1030 | - $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
1031 | - else |
|
1032 | - $error_array[2] = null; |
|
1099 | + if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) { |
|
1100 | + $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
1101 | + } else { |
|
1102 | + $error_array[2] = null; |
|
1103 | + } |
|
1033 | 1104 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
1034 | 1105 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
1035 | 1106 | $error_array[7], $error_array[8]); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) |
233 | 233 | WHERE t.id_topic IS NULL |
234 | 234 | GROUP BY m.id_topic, m.id_board', |
235 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
235 | + 'fix_processing' => function($row) use ($smcFunc) |
|
236 | 236 | { |
237 | 237 | global $salvageBoardID; |
238 | 238 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // Remove all topics that have zero messages in the messages table. |
319 | 319 | 'fix_collect' => array( |
320 | 320 | 'index' => 'id_topic', |
321 | - 'process' => function ($topics) use ($smcFunc) |
|
321 | + 'process' => function($topics) use ($smcFunc) |
|
322 | 322 | { |
323 | 323 | $smcFunc['db_query']('', ' |
324 | 324 | DELETE FROM {db_prefix}topics |
@@ -356,21 +356,21 @@ discard block |
||
356 | 356 | AND p.id_poll IS NULL |
357 | 357 | GROUP BY o.id_poll, t.id_topic, t.id_board, t.id_member_started, m.member_name |
358 | 358 | ', |
359 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
359 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
360 | 360 | { |
361 | 361 | global $salvageBoardID; |
362 | 362 | |
363 | 363 | $row['poster_name'] = !empty($row['poster_name']) ? $row['poster_name'] : $txt['guest']; |
364 | 364 | $row['id_poster'] = !empty($row['id_poster']) ? $row['id_poster'] : 0; |
365 | 365 | |
366 | - if(empty($row['id_board'])) |
|
366 | + if (empty($row['id_board'])) |
|
367 | 367 | { |
368 | 368 | // Only if we don't have a reasonable idea of where to put it. |
369 | 369 | createSalvageArea(); |
370 | - $row['id_board'] = (int)$salvageBoardID; |
|
370 | + $row['id_board'] = (int) $salvageBoardID; |
|
371 | 371 | } |
372 | 372 | |
373 | - if(empty($row['id_topic'])) { |
|
373 | + if (empty($row['id_topic'])) { |
|
374 | 374 | $newMessageID = $smcFunc['db_insert']('', |
375 | 375 | '{db_prefix}messages', |
376 | 376 | array( |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll) |
493 | 493 | WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH} |
494 | 494 | AND t.id_poll IS NULL', |
495 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
495 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
496 | 496 | { |
497 | 497 | global $salvageBoardID; |
498 | 498 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
606 | 606 | GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved |
607 | 607 | ORDER BY t.id_topic', |
608 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
608 | + 'fix_processing' => function($row) use ($smcFunc) |
|
609 | 609 | { |
610 | 610 | $row['firstmsg_approved'] = (int) $row['firstmsg_approved']; |
611 | 611 | $row['myid_first_msg'] = (int) $row['myid_first_msg']; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | ) |
635 | 635 | ); |
636 | 636 | }, |
637 | - 'message_function' => function ($row) use ($txt, &$context) |
|
637 | + 'message_function' => function($row) use ($txt, &$context) |
|
638 | 638 | { |
639 | 639 | // A pretend error? |
640 | 640 | if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
669 | 669 | GROUP BY t.id_topic, t.num_replies, mf.approved |
670 | 670 | ORDER BY t.id_topic', |
671 | - 'fix_processing' => function ($row) |
|
671 | + 'fix_processing' => function($row) |
|
672 | 672 | { |
673 | 673 | |
674 | 674 | global $smcFunc; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | ); |
690 | 690 | |
691 | 691 | }, |
692 | - 'message_function' => function ($row) |
|
692 | + 'message_function' => function($row) |
|
693 | 693 | { |
694 | 694 | |
695 | 695 | global $txt, $context; |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | GROUP BY t.id_topic, t.unapproved_posts |
723 | 723 | HAVING unapproved_posts != COUNT(mu.id_msg) |
724 | 724 | ORDER BY t.id_topic', |
725 | - 'fix_processing' => function ($row) |
|
725 | + 'fix_processing' => function($row) |
|
726 | 726 | { |
727 | 727 | |
728 | 728 | global $smcFunc; |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | WHERE b.id_board IS NULL |
765 | 765 | AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
766 | 766 | GROUP BY t.id_board', |
767 | - 'fix_processing' => function ($row) |
|
767 | + 'fix_processing' => function($row) |
|
768 | 768 | { |
769 | 769 | |
770 | 770 | global $smcFunc, $salvageCatID, $txt; |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | ORDER BY b.id_cat, b.id_board', |
814 | 814 | 'fix_collect' => array( |
815 | 815 | 'index' => 'id_cat', |
816 | - 'process' => function ($cats) |
|
816 | + 'process' => function($cats) |
|
817 | 817 | { |
818 | 818 | global $smcFunc, $salvageCatID; |
819 | 819 | createSalvageArea(); |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | // Last step-make sure all non-guest posters still exist. |
850 | 850 | 'fix_collect' => array( |
851 | 851 | 'index' => 'id_msg', |
852 | - 'process' => function ($msgs) |
|
852 | + 'process' => function($msgs) |
|
853 | 853 | { |
854 | 854 | |
855 | 855 | global $smcFunc; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | ORDER BY b.id_parent, b.id_board', |
879 | 879 | 'fix_collect' => array( |
880 | 880 | 'index' => 'id_parent', |
881 | - 'process' => function ($parents) |
|
881 | + 'process' => function($parents) |
|
882 | 882 | { |
883 | 883 | global $smcFunc, $salvageBoardID, $salvageCatID; |
884 | 884 | createSalvageArea(); |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | AND p.id_poll IS NULL', |
913 | 913 | 'fix_collect' => array( |
914 | 914 | 'index' => 'id_poll', |
915 | - 'process' => function ($polls) |
|
915 | + 'process' => function($polls) |
|
916 | 916 | { |
917 | 917 | |
918 | 918 | global $smcFunc; |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | ORDER BY cal.id_topic', |
947 | 947 | 'fix_collect' => array( |
948 | 948 | 'index' => 'id_topic', |
949 | - 'process' => function ($events) |
|
949 | + 'process' => function($events) |
|
950 | 950 | { |
951 | 951 | |
952 | 952 | global $smcFunc; |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
979 | 979 | 'fix_collect' => array( |
980 | 980 | 'index' => 'id_topic', |
981 | - 'process' => function ($topics) |
|
981 | + 'process' => function($topics) |
|
982 | 982 | { |
983 | 983 | |
984 | 984 | global $smcFunc; |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | GROUP BY lt.id_member', |
1011 | 1011 | 'fix_collect' => array( |
1012 | 1012 | 'index' => 'id_member', |
1013 | - 'process' => function ($members) |
|
1013 | + 'process' => function($members) |
|
1014 | 1014 | { |
1015 | 1015 | |
1016 | 1016 | global $smcFunc; |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | GROUP BY lb.id_board', |
1043 | 1043 | 'fix_collect' => array( |
1044 | 1044 | 'index' => 'id_board', |
1045 | - 'process' => function ($boards) |
|
1045 | + 'process' => function($boards) |
|
1046 | 1046 | { |
1047 | 1047 | |
1048 | 1048 | global $smcFunc; |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | GROUP BY lb.id_member', |
1075 | 1075 | 'fix_collect' => array( |
1076 | 1076 | 'index' => 'id_member', |
1077 | - 'process' => function ($members) use ($smcFunc) |
|
1077 | + 'process' => function($members) use ($smcFunc) |
|
1078 | 1078 | { |
1079 | 1079 | $smcFunc['db_query']('', ' |
1080 | 1080 | DELETE FROM {db_prefix}log_boards |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | GROUP BY lmr.id_board', |
1104 | 1104 | 'fix_collect' => array( |
1105 | 1105 | 'index' => 'id_board', |
1106 | - 'process' => function ($boards) use ($smcFunc) |
|
1106 | + 'process' => function($boards) use ($smcFunc) |
|
1107 | 1107 | { |
1108 | 1108 | $smcFunc['db_query']('', ' |
1109 | 1109 | DELETE FROM {db_prefix}log_mark_read |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | GROUP BY lmr.id_member', |
1133 | 1133 | 'fix_collect' => array( |
1134 | 1134 | 'index' => 'id_member', |
1135 | - 'process' => function ($members) use ($smcFunc) |
|
1135 | + 'process' => function($members) use ($smcFunc) |
|
1136 | 1136 | { |
1137 | 1137 | $smcFunc['db_query']('', ' |
1138 | 1138 | DELETE FROM {db_prefix}log_mark_read |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | GROUP BY pmr.id_pm', |
1162 | 1162 | 'fix_collect' => array( |
1163 | 1163 | 'index' => 'id_pm', |
1164 | - 'process' => function ($pms) use ($smcFunc) |
|
1164 | + 'process' => function($pms) use ($smcFunc) |
|
1165 | 1165 | { |
1166 | 1166 | $smcFunc['db_query']('', ' |
1167 | 1167 | DELETE FROM {db_prefix}pm_recipients |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | GROUP BY pmr.id_member', |
1192 | 1192 | 'fix_collect' => array( |
1193 | 1193 | 'index' => 'id_member', |
1194 | - 'process' => function ($members) |
|
1194 | + 'process' => function($members) |
|
1195 | 1195 | { |
1196 | 1196 | |
1197 | 1197 | global $smcFunc; |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | AND mem.id_member IS NULL', |
1224 | 1224 | 'fix_collect' => array( |
1225 | 1225 | 'index' => 'id_pm', |
1226 | - 'process' => function ($guestMessages) |
|
1226 | + 'process' => function($guestMessages) |
|
1227 | 1227 | { |
1228 | 1228 | |
1229 | 1229 | global $smcFunc; |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | GROUP BY ln.id_member', |
1256 | 1256 | 'fix_collect' => array( |
1257 | 1257 | 'index' => 'id_member', |
1258 | - 'process' => function ($members) use ($smcFunc) |
|
1258 | + 'process' => function($members) use ($smcFunc) |
|
1259 | 1259 | { |
1260 | 1260 | $smcFunc['db_query']('', ' |
1261 | 1261 | DELETE FROM {db_prefix}log_notify |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic) |
1283 | 1283 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
1284 | 1284 | AND lss.id_topic IS NULL', |
1285 | - 'fix_full_processing' => function ($result) |
|
1285 | + 'fix_full_processing' => function($result) |
|
1286 | 1286 | { |
1287 | 1287 | |
1288 | 1288 | global $smcFunc; |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | ); |
1315 | 1315 | |
1316 | 1316 | }, |
1317 | - 'message_function' => function ($row) |
|
1317 | + 'message_function' => function($row) |
|
1318 | 1318 | { |
1319 | 1319 | |
1320 | 1320 | global $txt, $context; |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | AND t.id_topic IS NULL', |
1345 | 1345 | 'fix_collect' => array( |
1346 | 1346 | 'index' => 'id_topic', |
1347 | - 'process' => function ($deleteTopics) |
|
1347 | + 'process' => function($deleteTopics) |
|
1348 | 1348 | { |
1349 | 1349 | |
1350 | 1350 | global $smcFunc; |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | AND mem.id_member IS NULL', |
1377 | 1377 | 'fix_collect' => array( |
1378 | 1378 | 'index' => 'id_member', |
1379 | - 'process' => function ($members) |
|
1379 | + 'process' => function($members) |
|
1380 | 1380 | { |
1381 | 1381 | |
1382 | 1382 | global $smcFunc; |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | AND p.id_poll IS NULL', |
1408 | 1408 | 'fix_collect' => array( |
1409 | 1409 | 'index' => 'id_poll', |
1410 | - 'process' => function ($polls) |
|
1410 | + 'process' => function($polls) |
|
1411 | 1411 | { |
1412 | 1412 | |
1413 | 1413 | global $smcFunc; |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | AND lrc.id_report IS NULL', |
1439 | 1439 | 'fix_collect' => array( |
1440 | 1440 | 'index' => 'id_report', |
1441 | - 'process' => function ($reports) |
|
1441 | + 'process' => function($reports) |
|
1442 | 1442 | { |
1443 | 1443 | |
1444 | 1444 | global $smcFunc; |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | AND lr.id_report IS NULL', |
1470 | 1470 | 'fix_collect' => array( |
1471 | 1471 | 'index' => 'id_report', |
1472 | - 'process' => function ($reports) |
|
1472 | + 'process' => function($reports) |
|
1473 | 1473 | { |
1474 | 1474 | global $smcFunc; |
1475 | 1475 | $smcFunc['db_query']('', ' |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | GROUP BY lgr.id_member', |
1500 | 1500 | 'fix_collect' => array( |
1501 | 1501 | 'index' => 'id_member', |
1502 | - 'process' => function ($members) |
|
1502 | + 'process' => function($members) |
|
1503 | 1503 | { |
1504 | 1504 | global $smcFunc; |
1505 | 1505 | $smcFunc['db_query']('', ' |
@@ -1529,7 +1529,7 @@ discard block |
||
1529 | 1529 | GROUP BY lgr.id_group', |
1530 | 1530 | 'fix_collect' => array( |
1531 | 1531 | 'index' => 'id_group', |
1532 | - 'process' => function ($groups) |
|
1532 | + 'process' => function($groups) |
|
1533 | 1533 | { |
1534 | 1534 | global $smcFunc; |
1535 | 1535 | $smcFunc['db_query']('', ' |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | ); |
51 | 52 | |
52 | 53 | // Start displaying errors without fixing them. |
53 | - if (isset($_GET['fixErrors'])) |
|
54 | - checkSession('get'); |
|
54 | + if (isset($_GET['fixErrors'])) { |
|
55 | + checkSession('get'); |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // Will want this. |
57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
71 | 73 | |
72 | - if (empty($context['repair_errors'])) |
|
73 | - $context['repair_errors'][] = '???'; |
|
74 | + if (empty($context['repair_errors'])) { |
|
75 | + $context['repair_errors'][] = '???'; |
|
76 | + } |
|
74 | 77 | } |
75 | - } |
|
76 | - else |
|
78 | + } else |
|
77 | 79 | { |
78 | 80 | $context['error_search'] = false; |
79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
120 | 122 | |
121 | 123 | // More time, I need more time! |
122 | 124 | @set_time_limit(600); |
123 | - if (function_exists('apache_reset_timeout')) |
|
124 | - @apache_reset_timeout(); |
|
125 | + if (function_exists('apache_reset_timeout')) { |
|
126 | + @apache_reset_timeout(); |
|
127 | + } |
|
125 | 128 | |
126 | 129 | // Errr, wait. How much time has this taken already? |
127 | - if (!$force && (time() - $time_start) < 3) |
|
128 | - return; |
|
130 | + if (!$force && (time() - $time_start) < 3) { |
|
131 | + return; |
|
132 | + } |
|
129 | 133 | |
130 | 134 | // Restore the query cache if interested. |
131 | - if (!empty($db_temp_cache)) |
|
132 | - $db_cache = $db_temp_cache; |
|
135 | + if (!empty($db_temp_cache)) { |
|
136 | + $db_cache = $db_temp_cache; |
|
137 | + } |
|
133 | 138 | |
134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
138 | 143 | $context['sub_template'] = 'not_done'; |
139 | 144 | |
140 | 145 | // Change these two if more steps are added! |
141 | - if (empty($max_substep)) |
|
142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
143 | - else |
|
144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
146 | + if (empty($max_substep)) { |
|
147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
148 | + } else { |
|
149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
150 | + } |
|
145 | 151 | |
146 | 152 | // Never more than 100%! |
147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
613 | 619 | |
614 | 620 | // Not really a problem? |
615 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
616 | - return false; |
|
621 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
622 | + return false; |
|
623 | + } |
|
617 | 624 | |
618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
638 | 645 | { |
639 | 646 | // A pretend error? |
640 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
641 | - return false; |
|
647 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
648 | + return false; |
|
649 | + } |
|
642 | 650 | |
643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
653 | + } |
|
654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
656 | + } |
|
657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
659 | + } |
|
649 | 660 | |
650 | 661 | return true; |
651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
676 | 687 | |
677 | 688 | // Not really a problem? |
678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
679 | - return false; |
|
689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
690 | + return false; |
|
691 | + } |
|
680 | 692 | |
681 | 693 | $smcFunc['db_query']('', ' |
682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
695 | 707 | global $txt, $context; |
696 | 708 | |
697 | 709 | // Just joking? |
698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
699 | - return false; |
|
710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
711 | + return false; |
|
712 | + } |
|
700 | 713 | |
701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
716 | + } |
|
703 | 717 | |
704 | 718 | return true; |
705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
1290 | 1304 | $inserts = array(); |
1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1292 | 1306 | { |
1293 | - foreach (text2words($row['subject']) as $word) |
|
1294 | - $inserts[] = array($word, $row['id_topic']); |
|
1307 | + foreach (text2words($row['subject']) as $word) { |
|
1308 | + $inserts[] = array($word, $row['id_topic']); |
|
1309 | + } |
|
1295 | 1310 | if (count($inserts) > 500) |
1296 | 1311 | { |
1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
1305 | 1320 | |
1306 | 1321 | } |
1307 | 1322 | |
1308 | - if (!empty($inserts)) |
|
1309 | - $smcFunc['db_insert']('ignore', |
|
1323 | + if (!empty($inserts)) { |
|
1324 | + $smcFunc['db_insert']('ignore', |
|
1310 | 1325 | '{db_prefix}log_search_subjects', |
1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
1312 | 1327 | $inserts, |
1313 | 1328 | array('word', 'id_topic') |
1314 | 1329 | ); |
1330 | + } |
|
1315 | 1331 | |
1316 | 1332 | }, |
1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
1581 | 1597 | $current_step++; |
1582 | 1598 | |
1583 | 1599 | // Already done this? |
1584 | - if ($_GET['step'] > $current_step) |
|
1585 | - continue; |
|
1600 | + if ($_GET['step'] > $current_step) { |
|
1601 | + continue; |
|
1602 | + } |
|
1586 | 1603 | |
1587 | 1604 | // If we're fixing it but it ain't broke why try? |
1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
1611 | 1628 | while (!$done) |
1612 | 1629 | { |
1613 | 1630 | // Make sure there's at least one ID to test. |
1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
1615 | - break; |
|
1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
1632 | + break; |
|
1633 | + } |
|
1616 | 1634 | |
1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
1618 | - if (!$do_fix) |
|
1619 | - $test_query = 'check_query'; |
|
1620 | - else |
|
1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1636 | + if (!$do_fix) { |
|
1637 | + $test_query = 'check_query'; |
|
1638 | + } else { |
|
1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1640 | + } |
|
1622 | 1641 | |
1623 | 1642 | // Do the test... |
1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
1628 | 1647 | ); |
1629 | 1648 | |
1630 | 1649 | // Does it need a fix? |
1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1633 | - else |
|
1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1652 | + } else { |
|
1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
1654 | + } |
|
1635 | 1655 | |
1636 | 1656 | $total_queries++; |
1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
1643 | 1663 | // Assume need to fix. |
1644 | 1664 | $found_errors = true; |
1645 | 1665 | |
1646 | - if (isset($test['message'])) |
|
1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
1666 | + if (isset($test['message'])) { |
|
1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
1668 | + } |
|
1648 | 1669 | |
1649 | 1670 | // One per row! |
1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
1654 | 1675 | $variables = $test['messages']; |
1655 | 1676 | foreach ($variables as $k => $v) |
1656 | 1677 | { |
1657 | - if ($k == 0 && isset($txt[$v])) |
|
1658 | - $variables[$k] = $txt[$v]; |
|
1659 | - elseif ($k > 0 && isset($row[$v])) |
|
1660 | - $variables[$k] = $row[$v]; |
|
1678 | + if ($k == 0 && isset($txt[$v])) { |
|
1679 | + $variables[$k] = $txt[$v]; |
|
1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
1681 | + $variables[$k] = $row[$v]; |
|
1682 | + } |
|
1661 | 1683 | } |
1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
1668 | 1690 | { |
1669 | 1691 | // Find out if there are actually errors. |
1670 | 1692 | $found_errors = false; |
1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1672 | - $found_errors |= $test['message_function']($row); |
|
1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1694 | + $found_errors |= $test['message_function']($row); |
|
1695 | + } |
|
1673 | 1696 | } |
1674 | 1697 | |
1675 | 1698 | // Actually have something to fix? |
1676 | - if ($found_errors) |
|
1677 | - $to_fix[] = $error_type; |
|
1699 | + if ($found_errors) { |
|
1700 | + $to_fix[] = $error_type; |
|
1701 | + } |
|
1678 | 1702 | } |
1679 | 1703 | |
1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
1684 | 1708 | if (isset($test['fix_collect'])) |
1685 | 1709 | { |
1686 | 1710 | $ids = array(); |
1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
1713 | + } |
|
1689 | 1714 | if (!empty($ids)) |
1690 | 1715 | { |
1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
1694 | 1719 | } |
1695 | 1720 | |
1696 | 1721 | // Simply executing a fix it query? |
1697 | - elseif (isset($test['fix_it_query'])) |
|
1698 | - $smcFunc['db_query']('', |
|
1722 | + elseif (isset($test['fix_it_query'])) { |
|
1723 | + $smcFunc['db_query']('', |
|
1699 | 1724 | $test['fix_it_query'], |
1700 | 1725 | array( |
1701 | 1726 | ) |
1702 | 1727 | ); |
1728 | + } |
|
1703 | 1729 | |
1704 | 1730 | // Do we have some processing to do? |
1705 | 1731 | elseif (isset($test['fix_processing'])) |
1706 | 1732 | { |
1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1708 | - $test['fix_processing']($row); |
|
1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1734 | + $test['fix_processing']($row); |
|
1735 | + } |
|
1709 | 1736 | } |
1710 | 1737 | |
1711 | 1738 | // What about the full set of processing? |
1712 | - elseif (isset($test['fix_full_processing'])) |
|
1713 | - $test['fix_full_processing']($request); |
|
1739 | + elseif (isset($test['fix_full_processing'])) { |
|
1740 | + $test['fix_full_processing']($request); |
|
1741 | + } |
|
1714 | 1742 | |
1715 | 1743 | // Do we have other things we need to fix as a result? |
1716 | 1744 | if (!empty($test['force_fix'])) |
1717 | 1745 | { |
1718 | - foreach ($test['force_fix'] as $item) |
|
1719 | - if (!in_array($item, $to_fix)) |
|
1746 | + foreach ($test['force_fix'] as $item) { |
|
1747 | + if (!in_array($item, $to_fix)) |
|
1720 | 1748 | $to_fix[] = $item; |
1749 | + } |
|
1721 | 1750 | } |
1722 | 1751 | } |
1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
1735 | 1764 | if ($_GET['substep'] <= $step_max) |
1736 | 1765 | { |
1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
1767 | + } else { |
|
1768 | + $done = true; |
|
1738 | 1769 | } |
1739 | - else |
|
1740 | - $done = true; |
|
1770 | + } else { |
|
1771 | + $done = true; |
|
1741 | 1772 | } |
1742 | - else |
|
1743 | - $done = true; |
|
1744 | 1773 | |
1745 | 1774 | // Don't allow more than 1000 queries at a time. |
1746 | - if ($total_queries >= 1000) |
|
1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1775 | + if ($total_queries >= 1000) { |
|
1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1777 | + } |
|
1748 | 1778 | } |
1749 | 1779 | |
1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
1757 | 1787 | if ($do_fix) |
1758 | 1788 | { |
1759 | 1789 | $key = array_search($error_type, $to_fix); |
1760 | - if ($key !== false && isset($to_fix[$key])) |
|
1761 | - unset($to_fix[$key]); |
|
1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
1791 | + unset($to_fix[$key]); |
|
1792 | + } |
|
1762 | 1793 | } |
1763 | 1794 | |
1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
1781 | 1812 | static $createOnce = false; |
1782 | 1813 | |
1783 | 1814 | // Have we already created it? |
1784 | - if ($createOnce) |
|
1785 | - return; |
|
1786 | - else |
|
1787 | - $createOnce = true; |
|
1815 | + if ($createOnce) { |
|
1816 | + return; |
|
1817 | + } else { |
|
1818 | + $createOnce = true; |
|
1819 | + } |
|
1788 | 1820 | |
1789 | 1821 | // Back to the forum's default language. |
1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
1800 | 1832 | ) |
1801 | 1833 | ); |
1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1836 | + } |
|
1804 | 1837 | $smcFunc['db_free_result']($result); |
1805 | 1838 | |
1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
1833 | 1866 | ) |
1834 | 1867 | ); |
1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1870 | + } |
|
1837 | 1871 | $smcFunc['db_free_result']($result); |
1838 | 1872 | |
1839 | 1873 | if (empty($salvageBoardID)) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main admin handling function.<br> |
@@ -444,8 +445,9 @@ discard block |
||
444 | 445 | foreach ($admin_includes as $include) |
445 | 446 | { |
446 | 447 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
447 | - if (file_exists($include)) |
|
448 | - require_once($include); |
|
448 | + if (file_exists($include)) { |
|
449 | + require_once($include); |
|
450 | + } |
|
449 | 451 | } |
450 | 452 | } |
451 | 453 | |
@@ -457,24 +459,27 @@ discard block |
||
457 | 459 | unset($admin_areas); |
458 | 460 | |
459 | 461 | // Nothing valid? |
460 | - if ($admin_include_data == false) |
|
461 | - fatal_lang_error('no_access', false); |
|
462 | + if ($admin_include_data == false) { |
|
463 | + fatal_lang_error('no_access', false); |
|
464 | + } |
|
462 | 465 | |
463 | 466 | // Build the link tree. |
464 | 467 | $context['linktree'][] = array( |
465 | 468 | 'url' => $scripturl . '?action=admin', |
466 | 469 | 'name' => $txt['admin_center'], |
467 | 470 | ); |
468 | - if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
|
469 | - $context['linktree'][] = array( |
|
471 | + if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') { |
|
472 | + $context['linktree'][] = array( |
|
470 | 473 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
471 | 474 | 'name' => $admin_include_data['label'], |
472 | 475 | ); |
473 | - if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
|
474 | - $context['linktree'][] = array( |
|
476 | + } |
|
477 | + if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) { |
|
478 | + $context['linktree'][] = array( |
|
475 | 479 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
476 | 480 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
477 | 481 | ); |
482 | + } |
|
478 | 483 | |
479 | 484 | // Make a note of the Unique ID for this menu. |
480 | 485 | $context['admin_menu_id'] = $context['max_menu_id']; |
@@ -484,16 +489,18 @@ discard block |
||
484 | 489 | $context['admin_area'] = $admin_include_data['current_area']; |
485 | 490 | |
486 | 491 | // Now - finally - call the right place! |
487 | - if (isset($admin_include_data['file'])) |
|
488 | - require_once($sourcedir . '/' . $admin_include_data['file']); |
|
492 | + if (isset($admin_include_data['file'])) { |
|
493 | + require_once($sourcedir . '/' . $admin_include_data['file']); |
|
494 | + } |
|
489 | 495 | |
490 | 496 | // Get the right callable. |
491 | 497 | $call = call_helper($admin_include_data['function'], true); |
492 | 498 | |
493 | 499 | // Is it valid? |
494 | - if (!empty($call)) |
|
495 | - call_user_func($call); |
|
496 | -} |
|
500 | + if (!empty($call)) { |
|
501 | + call_user_func($call); |
|
502 | + } |
|
503 | + } |
|
497 | 504 | |
498 | 505 | /** |
499 | 506 | * The main administration section. |
@@ -547,13 +554,14 @@ discard block |
||
547 | 554 | |
548 | 555 | $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; |
549 | 556 | $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; |
550 | - if ($context['admin_area'] != 'credits') |
|
551 | - $context[$context['admin_menu_name']]['tab_data'] = array( |
|
557 | + if ($context['admin_area'] != 'credits') { |
|
558 | + $context[$context['admin_menu_name']]['tab_data'] = array( |
|
552 | 559 | 'title' => $txt['admin_center'], |
553 | 560 | 'help' => '', |
554 | 561 | 'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
555 | 562 | ' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']), |
556 | 563 | ); |
564 | + } |
|
557 | 565 | |
558 | 566 | // Lastly, fill in the blanks in the support resources paragraphs. |
559 | 567 | $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], |
@@ -571,9 +579,10 @@ discard block |
||
571 | 579 | 'https://www.simplemachines.org/redirect/customize_support' |
572 | 580 | ); |
573 | 581 | |
574 | - if ($context['admin_area'] == 'admin') |
|
575 | - loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
576 | -} |
|
582 | + if ($context['admin_area'] == 'admin') { |
|
583 | + loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
584 | + } |
|
585 | + } |
|
577 | 586 | |
578 | 587 | /** |
579 | 588 | * Get one of the admin information files from Simple Machines. |
@@ -584,8 +593,9 @@ discard block |
||
584 | 593 | |
585 | 594 | setMemoryLimit('32M'); |
586 | 595 | |
587 | - if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) |
|
588 | - fatal_lang_error('no_access', false); |
|
596 | + if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) { |
|
597 | + fatal_lang_error('no_access', false); |
|
598 | + } |
|
589 | 599 | |
590 | 600 | // Strip off the forum cache part or we won't find it... |
591 | 601 | $_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']); |
@@ -600,27 +610,30 @@ discard block |
||
600 | 610 | ) |
601 | 611 | ); |
602 | 612 | |
603 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
604 | - fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
613 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
614 | + fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
615 | + } |
|
605 | 616 | |
606 | 617 | list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request); |
607 | 618 | $smcFunc['db_free_result']($request); |
608 | 619 | |
609 | 620 | // @todo Temp |
610 | 621 | // Figure out if sesc is still being used. |
611 | - if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') |
|
612 | - $file_data = ' |
|
622 | + if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') { |
|
623 | + $file_data = ' |
|
613 | 624 | if (!(\'smfForum_sessionvar\' in window)) |
614 | 625 | window.smfForum_sessionvar = \'sesc\'; |
615 | 626 | ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'=')); |
627 | + } |
|
616 | 628 | |
617 | 629 | $context['template_layers'] = array(); |
618 | 630 | // Lets make sure we aren't going to output anything nasty. |
619 | 631 | @ob_end_clean(); |
620 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
621 | - @ob_start('ob_gzhandler'); |
|
622 | - else |
|
623 | - @ob_start(); |
|
632 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
633 | + @ob_start('ob_gzhandler'); |
|
634 | + } else { |
|
635 | + @ob_start(); |
|
636 | + } |
|
624 | 637 | |
625 | 638 | // Make sure they know what type of file we are. |
626 | 639 | header('Content-Type: ' . $filetype); |
@@ -660,11 +673,12 @@ discard block |
||
660 | 673 | updateAdminPreferences(); |
661 | 674 | } |
662 | 675 | |
663 | - if (trim($context['search_term']) == '') |
|
664 | - $context['search_results'] = array(); |
|
665 | - else |
|
666 | - call_helper($subActions[$context['search_type']]); |
|
667 | -} |
|
676 | + if (trim($context['search_term']) == '') { |
|
677 | + $context['search_results'] = array(); |
|
678 | + } else { |
|
679 | + call_helper($subActions[$context['search_type']]); |
|
680 | + } |
|
681 | + } |
|
668 | 682 | |
669 | 683 | /** |
670 | 684 | * A complicated but relatively quick internal search. |
@@ -728,8 +742,9 @@ discard block |
||
728 | 742 | |
729 | 743 | loadLanguage(implode('+', $language_files)); |
730 | 744 | |
731 | - foreach ($include_files as $file) |
|
732 | - require_once($sourcedir . '/' . $file . '.php'); |
|
745 | + foreach ($include_files as $file) { |
|
746 | + require_once($sourcedir . '/' . $file . '.php'); |
|
747 | + } |
|
733 | 748 | |
734 | 749 | /* This is the huge array that defines everything... it's a huge array of items formatted as follows: |
735 | 750 | 0 = Language index (Can be array of indexes) to search through for this setting. |
@@ -753,11 +768,12 @@ discard block |
||
753 | 768 | foreach ($section['areas'] as $menu_key => $menu_item) |
754 | 769 | { |
755 | 770 | $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); |
756 | - if (!empty($menu_item['subsections'])) |
|
757 | - foreach ($menu_item['subsections'] as $key => $sublabel) |
|
771 | + if (!empty($menu_item['subsections'])) { |
|
772 | + foreach ($menu_item['subsections'] as $key => $sublabel) |
|
758 | 773 | { |
759 | 774 | if (isset($sublabel['label'])) |
760 | 775 | $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); |
776 | + } |
|
761 | 777 | } |
762 | 778 | } |
763 | 779 | } |
@@ -767,9 +783,10 @@ discard block |
||
767 | 783 | // Get a list of their variables. |
768 | 784 | $config_vars = $setting_area[0](true); |
769 | 785 | |
770 | - foreach ($config_vars as $var) |
|
771 | - if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
786 | + foreach ($config_vars as $var) { |
|
787 | + if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
772 | 788 | $search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], array('file', 'db'))) || isset($var[3]) ? (in_array($var[2], array('file', 'db')) ? $var[1] : $var[3]) : ''); |
789 | + } |
|
773 | 790 | } |
774 | 791 | |
775 | 792 | $context['page_title'] = $txt['admin_search_results']; |
@@ -782,8 +799,9 @@ discard block |
||
782 | 799 | foreach ($data as $item) |
783 | 800 | { |
784 | 801 | $found = false; |
785 | - if (!is_array($item[0])) |
|
786 | - $item[0] = array($item[0]); |
|
802 | + if (!is_array($item[0])) { |
|
803 | + $item[0] = array($item[0]); |
|
804 | + } |
|
787 | 805 | foreach ($item[0] as $term) |
788 | 806 | { |
789 | 807 | if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false)) |
@@ -841,8 +859,9 @@ discard block |
||
841 | 859 | $postVars = explode(' ', $context['search_term']); |
842 | 860 | |
843 | 861 | // Encode the search data. |
844 | - foreach ($postVars as $k => $v) |
|
845 | - $postVars[$k] = urlencode($v); |
|
862 | + foreach ($postVars as $k => $v) { |
|
863 | + $postVars[$k] = urlencode($v); |
|
864 | + } |
|
846 | 865 | |
847 | 866 | // This is what we will send. |
848 | 867 | $postVars = implode('+', $postVars); |
@@ -854,8 +873,9 @@ discard block |
||
854 | 873 | $search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
855 | 874 | |
856 | 875 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
857 | - if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) |
|
858 | - fatal_lang_error('cannot_connect_doc_site'); |
|
876 | + if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) { |
|
877 | + fatal_lang_error('cannot_connect_doc_site'); |
|
878 | + } |
|
859 | 879 | |
860 | 880 | $search_results = $matches[1]; |
861 | 881 | |
@@ -867,8 +887,9 @@ discard block |
||
867 | 887 | $results = new xmlArray($search_results, false); |
868 | 888 | |
869 | 889 | // Move through the api layer. |
870 | - if (!$results->exists('api')) |
|
871 | - fatal_lang_error('cannot_connect_doc_site'); |
|
890 | + if (!$results->exists('api')) { |
|
891 | + fatal_lang_error('cannot_connect_doc_site'); |
|
892 | + } |
|
872 | 893 | |
873 | 894 | // Are there actually some results? |
874 | 895 | if ($results->exists('api/query/search/p')) |
@@ -904,8 +925,9 @@ discard block |
||
904 | 925 | ); |
905 | 926 | |
906 | 927 | // If it's not got a sa set it must have come here for first time, pretend error log should be reversed. |
907 | - if (!isset($_REQUEST['sa'])) |
|
908 | - $_REQUEST['desc'] = true; |
|
928 | + if (!isset($_REQUEST['sa'])) { |
|
929 | + $_REQUEST['desc'] = true; |
|
930 | + } |
|
909 | 931 | |
910 | 932 | // Setup some tab stuff. |
911 | 933 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -955,9 +977,10 @@ discard block |
||
955 | 977 | unset($_SESSION['admin_time']); |
956 | 978 | |
957 | 979 | // Clean any admin tokens as well. |
958 | - foreach ($_SESSION['token'] as $key => $token) |
|
959 | - if (strpos($key, '-admin') !== false) |
|
980 | + foreach ($_SESSION['token'] as $key => $token) { |
|
981 | + if (strpos($key, '-admin') !== false) |
|
960 | 982 | unset($_SESSION['token'][$key]); |
983 | + } |
|
961 | 984 | |
962 | 985 | redirectexit(); |
963 | 986 | } |
@@ -144,11 +144,12 @@ discard block |
||
144 | 144 | <div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>'; |
145 | 145 | |
146 | 146 | $options = 1; |
147 | - foreach ($context['poll']['options'] as $option) |
|
148 | - echo ' |
|
147 | + foreach ($context['poll']['options'] as $option) { |
|
148 | + echo ' |
|
149 | 149 | <div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong> |
150 | 150 | ', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', ' |
151 | 151 | </div>'; |
152 | + } |
|
152 | 153 | |
153 | 154 | echo ' |
154 | 155 | </div>'; |
@@ -170,9 +171,10 @@ discard block |
||
170 | 171 | echo ' |
171 | 172 | <hr>'; |
172 | 173 | |
173 | - foreach ($context['printattach'][$post['id_msg']] as $attach) |
|
174 | - echo ' |
|
174 | + foreach ($context['printattach'][$post['id_msg']] as $attach) { |
|
175 | + echo ' |
|
175 | 176 | <img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">'; |
177 | + } |
|
176 | 178 | } |
177 | 179 | |
178 | 180 | echo ' |
@@ -207,12 +209,13 @@ discard block |
||
207 | 209 | <div class="print_options">'; |
208 | 210 | |
209 | 211 | // Which option is set, text or text&images |
210 | - if (isset($_REQUEST['images'])) |
|
211 | - echo ' |
|
212 | + if (isset($_REQUEST['images'])) { |
|
213 | + echo ' |
|
212 | 214 | <a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>'; |
213 | - else |
|
214 | - echo ' |
|
215 | + } else { |
|
216 | + echo ' |
|
215 | 217 | <strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>'; |
218 | + } |
|
216 | 219 | |
217 | 220 | echo ' |
218 | 221 | </div><!-- .print_options -->'; |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | <h3 class="catbg">', $context['page_title'], '</h3> |
47 | 47 | </div>'; |
48 | 48 | |
49 | - if (!empty($context['poll_error']['messages'])) |
|
50 | - echo ' |
|
49 | + if (!empty($context['poll_error']['messages'])) { |
|
50 | + echo ' |
|
51 | 51 | <div class="errorbox"> |
52 | 52 | <dl class="poll_error"> |
53 | 53 | <dt> |
@@ -58,6 +58,7 @@ discard block |
||
58 | 58 | </dt> |
59 | 59 | </dl> |
60 | 60 | </div>'; |
61 | + } |
|
61 | 62 | |
62 | 63 | echo ' |
63 | 64 | <div> |
@@ -79,8 +80,9 @@ discard block |
||
79 | 80 | <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" size="80" maxlength="255">'; |
80 | 81 | |
81 | 82 | // Does this option have a vote count yet, or is it new? |
82 | - if ($choice['votes'] != -1) |
|
83 | - echo ' (', $choice['votes'], ' ', $txt['votes'], ')'; |
|
83 | + if ($choice['votes'] != -1) { |
|
84 | + echo ' (', $choice['votes'], ' ', $txt['votes'], ')'; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </dd>'; |
@@ -118,14 +120,15 @@ discard block |
||
118 | 120 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
119 | 121 | </dd>'; |
120 | 122 | |
121 | - if ($context['poll']['guest_vote_allowed']) |
|
122 | - echo ' |
|
123 | + if ($context['poll']['guest_vote_allowed']) { |
|
124 | + echo ' |
|
123 | 125 | <dt> |
124 | 126 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
125 | 127 | </dt> |
126 | 128 | <dd> |
127 | 129 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll']['guest_vote']) ? ' checked' : '', '> |
128 | 130 | </dd>'; |
131 | + } |
|
129 | 132 | } |
130 | 133 | |
131 | 134 | echo ' |
@@ -141,12 +144,13 @@ discard block |
||
141 | 144 | </fieldset>'; |
142 | 145 | |
143 | 146 | // If this is an edit, we can allow them to reset the vote counts. |
144 | - if ($context['is_edit']) |
|
145 | - echo ' |
|
147 | + if ($context['is_edit']) { |
|
148 | + echo ' |
|
146 | 149 | <fieldset id="poll_reset"> |
147 | 150 | <legend>', $txt['reset_votes'], '</legend> |
148 | 151 | <input type="checkbox" name="resetVoteCount" value="on"> ' . $txt['reset_votes_check'] . ' |
149 | 152 | </fieldset>'; |
153 | + } |
|
150 | 154 | echo ' |
151 | 155 | <input type="submit" name="post" value="', $txt['save'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button"> |
152 | 156 | </div><!-- .roundframe --> |
@@ -44,10 +44,11 @@ discard block |
||
44 | 44 | <dt>', $txt['users_online_today'], ':</dt> |
45 | 45 | <dd>', $context['online_today'], '</dd>'; |
46 | 46 | |
47 | - if (!empty($modSettings['hitStats'])) |
|
48 | - echo ' |
|
47 | + if (!empty($modSettings['hitStats'])) { |
|
48 | + echo ' |
|
49 | 49 | <dt>', $txt['num_hits'], ':</dt> |
50 | 50 | <dd>', $context['num_hits'], '</dd>'; |
51 | + } |
|
51 | 52 | |
52 | 53 | echo ' |
53 | 54 | </dl> |
@@ -71,17 +72,19 @@ discard block |
||
71 | 72 | <dt>', $txt['gender_stats'], ':</dt> |
72 | 73 | <dd>'; |
73 | 74 | |
74 | - foreach ($context['gender'] as $g => $n) |
|
75 | - echo $g, ': ', $n, '<br>'; |
|
75 | + foreach ($context['gender'] as $g => $n) { |
|
76 | + echo $g, ': ', $n, '<br>'; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | echo ' |
78 | 80 | </dd>'; |
79 | 81 | } |
80 | 82 | |
81 | - if (!empty($modSettings['hitStats'])) |
|
82 | - echo ' |
|
83 | + if (!empty($modSettings['hitStats'])) { |
|
84 | + echo ' |
|
83 | 85 | <dt>', $txt['average_hits'], ':</dt> |
84 | 86 | <dd>', $context['average_hits'], '</dd>'; |
87 | + } |
|
85 | 88 | |
86 | 89 | echo ' |
87 | 90 | </dl>'; |
@@ -105,14 +108,15 @@ discard block |
||
105 | 108 | </dt> |
106 | 109 | <dd class="statsbar">'; |
107 | 110 | |
108 | - if (!empty($item['percent'])) |
|
109 | - echo ' |
|
111 | + if (!empty($item['percent'])) { |
|
112 | + echo ' |
|
110 | 113 | <div class="bar" style="width: ', $item['percent'], '%;"> |
111 | 114 | <span class="righttext">', $item['num'], '</span> |
112 | 115 | </div>'; |
113 | - else |
|
114 | - echo ' |
|
116 | + } else { |
|
117 | + echo ' |
|
115 | 118 | <div class="bar empty"><span class="righttext">', $item['num'], '</span></div>'; |
119 | + } |
|
116 | 120 | |
117 | 121 | echo ' |
118 | 122 | </dd>'; |
@@ -144,9 +148,10 @@ discard block |
||
144 | 148 | <th>', $txt['stats_new_members'], '</th> |
145 | 149 | <th>', $txt['most_online'], '</th>'; |
146 | 150 | |
147 | - if (!empty($modSettings['hitStats'])) |
|
148 | - echo ' |
|
151 | + if (!empty($modSettings['hitStats'])) { |
|
152 | + echo ' |
|
149 | 153 | <th>', $txt['page_views'], '</th>'; |
154 | + } |
|
150 | 155 | |
151 | 156 | echo ' |
152 | 157 | </tr> |
@@ -165,9 +170,10 @@ discard block |
||
165 | 170 | <th>', $year['new_members'], '</th> |
166 | 171 | <th>', $year['most_members_online'], '</th>'; |
167 | 172 | |
168 | - if (!empty($modSettings['hitStats'])) |
|
169 | - echo ' |
|
173 | + if (!empty($modSettings['hitStats'])) { |
|
174 | + echo ' |
|
170 | 175 | <th>', $year['hits'], '</th>'; |
176 | + } |
|
171 | 177 | |
172 | 178 | echo ' |
173 | 179 | </tr>'; |
@@ -184,9 +190,10 @@ discard block |
||
184 | 190 | <th>', $month['new_members'], '</th> |
185 | 191 | <th>', $month['most_members_online'], '</th>'; |
186 | 192 | |
187 | - if (!empty($modSettings['hitStats'])) |
|
188 | - echo ' |
|
193 | + if (!empty($modSettings['hitStats'])) { |
|
194 | + echo ' |
|
189 | 195 | <th>', $month['hits'], '</th>'; |
196 | + } |
|
190 | 197 | |
191 | 198 | echo ' |
192 | 199 | </tr>'; |
@@ -203,9 +210,10 @@ discard block |
||
203 | 210 | <td>', $day['new_members'], '</td> |
204 | 211 | <td>', $day['most_members_online'], '</td>'; |
205 | 212 | |
206 | - if (!empty($modSettings['hitStats'])) |
|
207 | - echo ' |
|
213 | + if (!empty($modSettings['hitStats'])) { |
|
214 | + echo ' |
|
208 | 215 | <td>', $day['hits'], '</td>'; |
216 | + } |
|
209 | 217 | |
210 | 218 | echo ' |
211 | 219 | </tr>'; |
@@ -945,7 +945,7 @@ |
||
945 | 945 | } |
946 | 946 | |
947 | 947 | echo isset($config_var['postinput']) ? ' |
948 | - ' . $config_var['postinput'] : '',' |
|
948 | + ' . $config_var['postinput'] : '', ' |
|
949 | 949 | </dd>'; |
950 | 950 | } |
951 | 951 | } |
@@ -65,9 +65,10 @@ discard block |
||
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | |
67 | 67 | // If we have lots of admins... don't show them all. |
68 | - if (!empty($context['more_admins_link'])) |
|
69 | - echo ' |
|
68 | + if (!empty($context['more_admins_link'])) { |
|
69 | + echo ' |
|
70 | 70 | (', $context['more_admins_link'], ')'; |
71 | + } |
|
71 | 72 | |
72 | 73 | echo ' |
73 | 74 | </div><!-- #version_details --> |
@@ -84,17 +85,19 @@ discard block |
||
84 | 85 | foreach ($area['areas'] as $item_id => $item) |
85 | 86 | { |
86 | 87 | // No point showing the 'home' page here, we're already on it! |
87 | - if ($area_id == 'forum' && $item_id == 'index') |
|
88 | - continue; |
|
88 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
89 | + continue; |
|
90 | + } |
|
89 | 91 | |
90 | 92 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
91 | 93 | |
92 | - if (!empty($item['icon_file'])) |
|
93 | - echo ' |
|
94 | + if (!empty($item['icon_file'])) { |
|
95 | + echo ' |
|
94 | 96 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
95 | - else |
|
96 | - echo ' |
|
97 | + } else { |
|
98 | + echo ' |
|
97 | 99 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
100 | + } |
|
98 | 101 | } |
99 | 102 | |
100 | 103 | echo ' |
@@ -105,10 +108,11 @@ discard block |
||
105 | 108 | </div><!-- #admincenter -->'; |
106 | 109 | |
107 | 110 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
108 | - if (empty($modSettings['disable_smf_js'])) |
|
109 | - echo ' |
|
111 | + if (empty($modSettings['disable_smf_js'])) { |
|
112 | + echo ' |
|
110 | 113 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
111 | 114 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
115 | + } |
|
112 | 116 | |
113 | 117 | // This sets the announcements and current versions themselves ;). |
114 | 118 | echo ' |
@@ -187,9 +191,10 @@ discard block |
||
187 | 191 | <em>', $version['version'], '</em>'; |
188 | 192 | |
189 | 193 | // more details for this item, show them a link |
190 | - if ($context['can_admin'] && isset($version['more'])) |
|
191 | - echo |
|
194 | + if ($context['can_admin'] && isset($version['more'])) { |
|
195 | + echo |
|
192 | 196 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
197 | + } |
|
193 | 198 | echo ' |
194 | 199 | <br>'; |
195 | 200 | } |
@@ -220,21 +225,23 @@ discard block |
||
220 | 225 | |
221 | 226 | foreach ($context['credits'] as $section) |
222 | 227 | { |
223 | - if (isset($section['pretext'])) |
|
224 | - echo ' |
|
228 | + if (isset($section['pretext'])) { |
|
229 | + echo ' |
|
225 | 230 | <p>', $section['pretext'], '</p> |
226 | 231 | <hr>'; |
232 | + } |
|
227 | 233 | |
228 | 234 | echo ' |
229 | 235 | <dl>'; |
230 | 236 | |
231 | 237 | foreach ($section['groups'] as $group) |
232 | 238 | { |
233 | - if (isset($group['title'])) |
|
234 | - echo ' |
|
239 | + if (isset($group['title'])) { |
|
240 | + echo ' |
|
235 | 241 | <dt> |
236 | 242 | <strong>', $group['title'], ':</strong> |
237 | 243 | </dt>'; |
244 | + } |
|
238 | 245 | |
239 | 246 | echo ' |
240 | 247 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -243,10 +250,11 @@ discard block |
||
243 | 250 | echo ' |
244 | 251 | </dl>'; |
245 | 252 | |
246 | - if (isset($section['posttext'])) |
|
247 | - echo ' |
|
253 | + if (isset($section['posttext'])) { |
|
254 | + echo ' |
|
248 | 255 | <hr> |
249 | 256 | <p>', $section['posttext'], '</p>'; |
257 | + } |
|
250 | 258 | } |
251 | 259 | |
252 | 260 | echo ' |
@@ -262,9 +270,10 @@ discard block |
||
262 | 270 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
263 | 271 | |
264 | 272 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
265 | - foreach ($context['current_versions'] as $variable => $version) |
|
266 | - echo ' |
|
273 | + foreach ($context['current_versions'] as $variable => $version) { |
|
274 | + echo ' |
|
267 | 275 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
276 | + } |
|
268 | 277 | |
269 | 278 | // Now we just have to include the script and wait ;). |
270 | 279 | echo ' |
@@ -361,8 +370,8 @@ discard block |
||
361 | 370 | <tbody>'; |
362 | 371 | |
363 | 372 | // Loop through every source file displaying its version - using javascript. |
364 | - foreach ($context['file_versions'] as $filename => $version) |
|
365 | - echo ' |
|
373 | + foreach ($context['file_versions'] as $filename => $version) { |
|
374 | + echo ' |
|
366 | 375 | <tr class="windowbg"> |
367 | 376 | <td class="half_table"> |
368 | 377 | ', $filename, ' |
@@ -374,6 +383,7 @@ discard block |
||
374 | 383 | <em id="currentSources', $filename, '">??</em> |
375 | 384 | </td> |
376 | 385 | </tr>'; |
386 | + } |
|
377 | 387 | |
378 | 388 | // Default template files. |
379 | 389 | echo ' |
@@ -399,8 +409,8 @@ discard block |
||
399 | 409 | <table id="Default" class="table_grid"> |
400 | 410 | <tbody>'; |
401 | 411 | |
402 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
403 | - echo ' |
|
412 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
413 | + echo ' |
|
404 | 414 | <tr class="windowbg"> |
405 | 415 | <td class="half_table"> |
406 | 416 | ', $filename, ' |
@@ -412,6 +422,7 @@ discard block |
||
412 | 422 | <em id="currentDefault', $filename, '">??</em> |
413 | 423 | </td> |
414 | 424 | </tr>'; |
425 | + } |
|
415 | 426 | |
416 | 427 | // Now the language files... |
417 | 428 | echo ' |
@@ -439,8 +450,8 @@ discard block |
||
439 | 450 | |
440 | 451 | foreach ($context['default_language_versions'] as $language => $files) |
441 | 452 | { |
442 | - foreach ($files as $filename => $version) |
|
443 | - echo ' |
|
453 | + foreach ($files as $filename => $version) { |
|
454 | + echo ' |
|
444 | 455 | <tr class="windowbg"> |
445 | 456 | <td class="half_table"> |
446 | 457 | ', $filename, '.<em>', $language, '</em>.php |
@@ -452,6 +463,7 @@ discard block |
||
452 | 463 | <em id="current', $filename, '.', $language, '">??</em> |
453 | 464 | </td> |
454 | 465 | </tr>'; |
466 | + } |
|
455 | 467 | } |
456 | 468 | |
457 | 469 | echo ' |
@@ -481,8 +493,8 @@ discard block |
||
481 | 493 | <table id="Templates" class="table_grid"> |
482 | 494 | <tbody>'; |
483 | 495 | |
484 | - foreach ($context['template_versions'] as $filename => $version) |
|
485 | - echo ' |
|
496 | + foreach ($context['template_versions'] as $filename => $version) { |
|
497 | + echo ' |
|
486 | 498 | <tr class="windowbg"> |
487 | 499 | <td class="half_table"> |
488 | 500 | ', $filename, ' |
@@ -494,6 +506,7 @@ discard block |
||
494 | 506 | <em id="currentTemplates', $filename, '">??</em> |
495 | 507 | </td> |
496 | 508 | </tr>'; |
509 | + } |
|
497 | 510 | |
498 | 511 | echo ' |
499 | 512 | </tbody> |
@@ -523,8 +536,8 @@ discard block |
||
523 | 536 | <table id="Tasks" class="table_grid"> |
524 | 537 | <tbody>'; |
525 | 538 | |
526 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
527 | - echo ' |
|
539 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
540 | + echo ' |
|
528 | 541 | <tr class="windowbg"> |
529 | 542 | <td class="half_table"> |
530 | 543 | ', $filename, ' |
@@ -536,6 +549,7 @@ discard block |
||
536 | 549 | <em id="currentTasks', $filename, '">??</em> |
537 | 550 | </td> |
538 | 551 | </tr>'; |
552 | + } |
|
539 | 553 | |
540 | 554 | echo ' |
541 | 555 | </tbody> |
@@ -577,9 +591,10 @@ discard block |
||
577 | 591 | { |
578 | 592 | global $context, $scripturl, $txt, $modSettings; |
579 | 593 | |
580 | - if (!empty($context['saved_successful'])) |
|
581 | - echo ' |
|
594 | + if (!empty($context['saved_successful'])) { |
|
595 | + echo ' |
|
582 | 596 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
597 | + } |
|
583 | 598 | |
584 | 599 | // First section is for adding/removing words from the censored list. |
585 | 600 | echo ' |
@@ -594,11 +609,12 @@ discard block |
||
594 | 609 | <p>', $txt['admin_censored_where'], '</p>'; |
595 | 610 | |
596 | 611 | // Show text boxes for censoring [bad ] => [good ]. |
597 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
598 | - echo ' |
|
612 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
613 | + echo ' |
|
599 | 614 | <div class="block"> |
600 | 615 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
601 | 616 | </div>'; |
617 | + } |
|
602 | 618 | |
603 | 619 | // Now provide a way to censor more words. |
604 | 620 | echo ' |
@@ -673,19 +689,21 @@ discard block |
||
673 | 689 | <div class="windowbg2 noup"> |
674 | 690 | ', $txt['not_done_reason']; |
675 | 691 | |
676 | - if (!empty($context['continue_percent'])) |
|
677 | - echo ' |
|
692 | + if (!empty($context['continue_percent'])) { |
|
693 | + echo ' |
|
678 | 694 | <div class="progress_bar"> |
679 | 695 | <div class="full_bar">', $context['continue_percent'], '%</div> |
680 | 696 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"></div> |
681 | 697 | </div>'; |
698 | + } |
|
682 | 699 | |
683 | - if (!empty($context['substep_enabled'])) |
|
684 | - echo ' |
|
700 | + if (!empty($context['substep_enabled'])) { |
|
701 | + echo ' |
|
685 | 702 | <div class="progress_bar"> |
686 | 703 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
687 | 704 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"></div> |
688 | 705 | </div>'; |
706 | + } |
|
689 | 707 | |
690 | 708 | echo ' |
691 | 709 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -720,35 +738,40 @@ discard block |
||
720 | 738 | { |
721 | 739 | global $context, $txt, $scripturl; |
722 | 740 | |
723 | - if (!empty($context['saved_successful'])) |
|
724 | - echo ' |
|
741 | + if (!empty($context['saved_successful'])) { |
|
742 | + echo ' |
|
725 | 743 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
726 | - elseif (!empty($context['saved_failed'])) |
|
727 | - echo ' |
|
744 | + } elseif (!empty($context['saved_failed'])) { |
|
745 | + echo ' |
|
728 | 746 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
747 | + } |
|
729 | 748 | |
730 | - if (!empty($context['settings_pre_javascript'])) |
|
731 | - echo ' |
|
749 | + if (!empty($context['settings_pre_javascript'])) { |
|
750 | + echo ' |
|
732 | 751 | <script>', $context['settings_pre_javascript'], '</script>'; |
752 | + } |
|
733 | 753 | |
734 | - if (!empty($context['settings_insert_above'])) |
|
735 | - echo $context['settings_insert_above']; |
|
754 | + if (!empty($context['settings_insert_above'])) { |
|
755 | + echo $context['settings_insert_above']; |
|
756 | + } |
|
736 | 757 | |
737 | 758 | echo ' |
738 | 759 | <div id="admincenter"> |
739 | 760 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
740 | 761 | |
741 | 762 | // Is there a custom title? |
742 | - if (isset($context['settings_title'])) |
|
743 | - echo ' |
|
763 | + if (isset($context['settings_title'])) { |
|
764 | + echo ' |
|
744 | 765 | <div class="cat_bar"> |
745 | 766 | <h3 class="catbg">', $context['settings_title'], '</h3> |
746 | 767 | </div>'; |
768 | + } |
|
747 | 769 | |
748 | 770 | // Have we got a message to display? |
749 | - if (!empty($context['settings_message'])) |
|
750 | - echo ' |
|
771 | + if (!empty($context['settings_message'])) { |
|
772 | + echo ' |
|
751 | 773 | <div class="information">', $context['settings_message'], '</div>'; |
774 | + } |
|
752 | 775 | |
753 | 776 | // Now actually loop through all the variables. |
754 | 777 | $is_open = false; |
@@ -801,8 +824,9 @@ discard block |
||
801 | 824 | // Hang about? Are you pulling my leg - a callback?! |
802 | 825 | if (is_array($config_var) && $config_var['type'] == 'callback') |
803 | 826 | { |
804 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
805 | - call_user_func('template_callback_' . $config_var['name']); |
|
827 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
828 | + call_user_func('template_callback_' . $config_var['name']); |
|
829 | + } |
|
806 | 830 | |
807 | 831 | continue; |
808 | 832 | } |
@@ -832,9 +856,10 @@ discard block |
||
832 | 856 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
833 | 857 | |
834 | 858 | // Show the [?] button. |
835 | - if ($config_var['help']) |
|
836 | - echo ' |
|
859 | + if ($config_var['help']) { |
|
860 | + echo ' |
|
837 | 861 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
862 | + } |
|
838 | 863 | |
839 | 864 | echo ' |
840 | 865 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -843,23 +868,26 @@ discard block |
||
843 | 868 | $config_var['preinput']; |
844 | 869 | |
845 | 870 | // Show a check box. |
846 | - if ($config_var['type'] == 'check') |
|
847 | - echo ' |
|
871 | + if ($config_var['type'] == 'check') { |
|
872 | + echo ' |
|
848 | 873 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
874 | + } |
|
849 | 875 | // Escape (via htmlspecialchars.) the text box. |
850 | - elseif ($config_var['type'] == 'password') |
|
851 | - echo ' |
|
876 | + elseif ($config_var['type'] == 'password') { |
|
877 | + echo ' |
|
852 | 878 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
853 | 879 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
880 | + } |
|
854 | 881 | // Show a selection box. |
855 | 882 | elseif ($config_var['type'] == 'select') |
856 | 883 | { |
857 | 884 | echo ' |
858 | 885 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
859 | 886 | |
860 | - foreach ($config_var['data'] as $option) |
|
861 | - echo ' |
|
887 | + foreach ($config_var['data'] as $option) { |
|
888 | + echo ' |
|
862 | 889 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
890 | + } |
|
863 | 891 | echo ' |
864 | 892 | </select>'; |
865 | 893 | } |
@@ -876,16 +904,18 @@ discard block |
||
876 | 904 | |
877 | 905 | foreach ($context['board_list'] as $id_cat => $cat) |
878 | 906 | { |
879 | - if (!$first) |
|
880 | - echo ' |
|
907 | + if (!$first) { |
|
908 | + echo ' |
|
881 | 909 | <hr>'; |
910 | + } |
|
882 | 911 | echo ' |
883 | 912 | <strong>', $cat['name'], '</strong> |
884 | 913 | <ul>'; |
885 | 914 | |
886 | - foreach ($cat['boards'] as $id_board => $brd) |
|
887 | - echo ' |
|
915 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
916 | + echo ' |
|
888 | 917 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
918 | + } |
|
889 | 919 | |
890 | 920 | echo ' |
891 | 921 | </ul>'; |
@@ -895,12 +925,14 @@ discard block |
||
895 | 925 | </fieldset>'; |
896 | 926 | } |
897 | 927 | // Text area? |
898 | - elseif ($config_var['type'] == 'large_text') |
|
899 | - echo ' |
|
928 | + elseif ($config_var['type'] == 'large_text') { |
|
929 | + echo ' |
|
900 | 930 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
931 | + } |
|
901 | 932 | // Permission group? |
902 | - elseif ($config_var['type'] == 'permissions') |
|
903 | - theme_inline_permissions($config_var['name']); |
|
933 | + elseif ($config_var['type'] == 'permissions') { |
|
934 | + theme_inline_permissions($config_var['name']); |
|
935 | + } |
|
904 | 936 | |
905 | 937 | // BBC selection? |
906 | 938 | elseif ($config_var['type'] == 'bbc') |
@@ -912,22 +944,24 @@ discard block |
||
912 | 944 | |
913 | 945 | foreach ($context['bbc_columns'] as $bbcColumn) |
914 | 946 | { |
915 | - foreach ($bbcColumn as $bbcTag) |
|
916 | - echo ' |
|
947 | + foreach ($bbcColumn as $bbcTag) { |
|
948 | + echo ' |
|
917 | 949 | <li class="list_bbc floatleft"> |
918 | 950 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
919 | 951 | </li>'; |
952 | + } |
|
920 | 953 | } |
921 | 954 | echo ' </ul> |
922 | 955 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
923 | 956 | </fieldset>'; |
924 | 957 | } |
925 | 958 | // A simple message? |
926 | - elseif ($config_var['type'] == 'var_message') |
|
927 | - echo ' |
|
959 | + elseif ($config_var['type'] == 'var_message') { |
|
960 | + echo ' |
|
928 | 961 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '> |
929 | 962 | ', $config_var['var_message'], ' |
930 | 963 | </div>'; |
964 | + } |
|
931 | 965 | // Assume it must be a text box |
932 | 966 | else |
933 | 967 | { |
@@ -952,62 +986,70 @@ discard block |
||
952 | 986 | ' . $config_var['postinput'] : '',' |
953 | 987 | </dd>'; |
954 | 988 | } |
955 | - } |
|
956 | - else |
|
989 | + } else |
|
957 | 990 | { |
958 | 991 | // Just show a separator. |
959 | - if ($config_var == '') |
|
960 | - echo ' |
|
992 | + if ($config_var == '') { |
|
993 | + echo ' |
|
961 | 994 | </dl> |
962 | 995 | <hr> |
963 | 996 | <dl class="settings">'; |
964 | - else |
|
965 | - echo ' |
|
997 | + } else { |
|
998 | + echo ' |
|
966 | 999 | <dd> |
967 | 1000 | <strong>' . $config_var . '</strong> |
968 | 1001 | </dd>'; |
1002 | + } |
|
969 | 1003 | } |
970 | 1004 | } |
971 | 1005 | |
972 | - if ($is_open) |
|
973 | - echo ' |
|
1006 | + if ($is_open) { |
|
1007 | + echo ' |
|
974 | 1008 | </dl>'; |
1009 | + } |
|
975 | 1010 | |
976 | - if (empty($context['settings_save_dont_show'])) |
|
977 | - echo ' |
|
1011 | + if (empty($context['settings_save_dont_show'])) { |
|
1012 | + echo ' |
|
978 | 1013 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
1014 | + } |
|
979 | 1015 | |
980 | - if ($is_open) |
|
981 | - echo ' |
|
1016 | + if ($is_open) { |
|
1017 | + echo ' |
|
982 | 1018 | </div><!-- .windowbg2 -->'; |
1019 | + } |
|
983 | 1020 | |
984 | 1021 | |
985 | 1022 | // At least one token has to be used! |
986 | - if (isset($context['admin-ssc_token'])) |
|
987 | - echo ' |
|
1023 | + if (isset($context['admin-ssc_token'])) { |
|
1024 | + echo ' |
|
988 | 1025 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1026 | + } |
|
989 | 1027 | |
990 | - if (isset($context['admin-dbsc_token'])) |
|
991 | - echo ' |
|
1028 | + if (isset($context['admin-dbsc_token'])) { |
|
1029 | + echo ' |
|
992 | 1030 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1031 | + } |
|
993 | 1032 | |
994 | - if (isset($context['admin-mp_token'])) |
|
995 | - echo ' |
|
1033 | + if (isset($context['admin-mp_token'])) { |
|
1034 | + echo ' |
|
996 | 1035 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1036 | + } |
|
997 | 1037 | |
998 | 1038 | echo ' |
999 | 1039 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1000 | 1040 | </form> |
1001 | 1041 | </div><!-- #admincenter -->'; |
1002 | 1042 | |
1003 | - if (!empty($context['settings_post_javascript'])) |
|
1004 | - echo ' |
|
1043 | + if (!empty($context['settings_post_javascript'])) { |
|
1044 | + echo ' |
|
1005 | 1045 | <script> |
1006 | 1046 | ', $context['settings_post_javascript'], ' |
1007 | 1047 | </script>'; |
1048 | + } |
|
1008 | 1049 | |
1009 | - if (!empty($context['settings_insert_below'])) |
|
1010 | - echo $context['settings_insert_below']; |
|
1050 | + if (!empty($context['settings_insert_below'])) { |
|
1051 | + echo $context['settings_insert_below']; |
|
1052 | + } |
|
1011 | 1053 | |
1012 | 1054 | // We may have added a board listing. If we did, we need to make it work. |
1013 | 1055 | addInlineJavascript(' |
@@ -1030,9 +1072,10 @@ discard block |
||
1030 | 1072 | { |
1031 | 1073 | global $context, $txt; |
1032 | 1074 | |
1033 | - if (!empty($context['saved_successful'])) |
|
1034 | - echo ' |
|
1075 | + if (!empty($context['saved_successful'])) { |
|
1076 | + echo ' |
|
1035 | 1077 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1078 | + } |
|
1036 | 1079 | |
1037 | 1080 | // Standard fields. |
1038 | 1081 | template_show_list('standard_profile_fields'); |
@@ -1066,11 +1109,12 @@ discard block |
||
1066 | 1109 | { |
1067 | 1110 | loadLanguage('Errors'); |
1068 | 1111 | |
1069 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1070 | - echo ' |
|
1112 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1113 | + echo ' |
|
1071 | 1114 | <div class="errorbox">', |
1072 | 1115 | $txt['custom_option_' . $_GET['msg']], ' |
1073 | 1116 | </div>'; |
1117 | + } |
|
1074 | 1118 | } |
1075 | 1119 | |
1076 | 1120 | echo ' |
@@ -1137,9 +1181,10 @@ discard block |
||
1137 | 1181 | <dd> |
1138 | 1182 | <select name="placement" id="placement">'; |
1139 | 1183 | |
1140 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1141 | - echo ' |
|
1184 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1185 | + echo ' |
|
1142 | 1186 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1187 | + } |
|
1143 | 1188 | |
1144 | 1189 | echo ' |
1145 | 1190 | </select> |
@@ -1163,9 +1208,10 @@ discard block |
||
1163 | 1208 | <dd> |
1164 | 1209 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1165 | 1210 | |
1166 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1167 | - echo ' |
|
1211 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1212 | + echo ' |
|
1168 | 1213 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1214 | + } |
|
1169 | 1215 | |
1170 | 1216 | echo ' |
1171 | 1217 | </select> |
@@ -1197,9 +1243,10 @@ discard block |
||
1197 | 1243 | </dt> |
1198 | 1244 | <dd id="options_dd">'; |
1199 | 1245 | |
1200 | - foreach ($context['field']['options'] as $k => $option) |
|
1201 | - echo ' |
|
1246 | + foreach ($context['field']['options'] as $k => $option) { |
|
1247 | + echo ' |
|
1202 | 1248 | ', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">'; |
1249 | + } |
|
1203 | 1250 | |
1204 | 1251 | echo ' |
1205 | 1252 | <span id="addopt"></span> |
@@ -1263,9 +1310,10 @@ discard block |
||
1263 | 1310 | </fieldset> |
1264 | 1311 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
1265 | 1312 | |
1266 | - if ($context['fid']) |
|
1267 | - echo ' |
|
1313 | + if ($context['fid']) { |
|
1314 | + echo ' |
|
1268 | 1315 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
1316 | + } |
|
1269 | 1317 | |
1270 | 1318 | echo ' |
1271 | 1319 | </div><!-- .windowbg2 --> |
@@ -1312,8 +1360,7 @@ discard block |
||
1312 | 1360 | <p class="centertext"> |
1313 | 1361 | <strong>', $txt['admin_search_results_none'], '</strong> |
1314 | 1362 | </p>'; |
1315 | - } |
|
1316 | - else |
|
1363 | + } else |
|
1317 | 1364 | { |
1318 | 1365 | echo ' |
1319 | 1366 | <ol class="search_results">'; |
@@ -1340,9 +1387,10 @@ discard block |
||
1340 | 1387 | <li> |
1341 | 1388 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1342 | 1389 | |
1343 | - if ($result['help']) |
|
1344 | - echo ' |
|
1390 | + if ($result['help']) { |
|
1391 | + echo ' |
|
1345 | 1392 | <p class="double_height">', $result['help'], '</p>'; |
1393 | + } |
|
1346 | 1394 | |
1347 | 1395 | echo ' |
1348 | 1396 | </li>'; |
@@ -1382,10 +1430,11 @@ discard block |
||
1382 | 1430 | <strong>', $txt['setup_verification_answer'], '</strong> |
1383 | 1431 | </dd>'; |
1384 | 1432 | |
1385 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1386 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1433 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1434 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1387 | 1435 | { |
1388 | 1436 | $question = $context['question_answers'][$q_id]; |
1437 | + } |
|
1389 | 1438 | |
1390 | 1439 | echo ' |
1391 | 1440 | <dt> |
@@ -1393,9 +1442,10 @@ discard block |
||
1393 | 1442 | </dt> |
1394 | 1443 | <dd>'; |
1395 | 1444 | |
1396 | - foreach ($question['answers'] as $answer) |
|
1397 | - echo ' |
|
1445 | + foreach ($question['answers'] as $answer) { |
|
1446 | + echo ' |
|
1398 | 1447 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
1448 | + } |
|
1399 | 1449 | |
1400 | 1450 | echo ' |
1401 | 1451 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1434,11 +1484,12 @@ discard block |
||
1434 | 1484 | ', $txt['errors_found'], ': |
1435 | 1485 | <ul>'; |
1436 | 1486 | |
1437 | - foreach ($context['repair_errors'] as $error) |
|
1438 | - echo ' |
|
1487 | + foreach ($context['repair_errors'] as $error) { |
|
1488 | + echo ' |
|
1439 | 1489 | <li> |
1440 | 1490 | ', $error, ' |
1441 | 1491 | </li>'; |
1492 | + } |
|
1442 | 1493 | |
1443 | 1494 | echo ' |
1444 | 1495 | </ul> |
@@ -1448,16 +1499,15 @@ discard block |
||
1448 | 1499 | <p class="padding"> |
1449 | 1500 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1450 | 1501 | </p>'; |
1451 | - } |
|
1452 | - else |
|
1453 | - echo ' |
|
1502 | + } else { |
|
1503 | + echo ' |
|
1454 | 1504 | <p>', $txt['maintain_no_errors'], '</p> |
1455 | 1505 | <p class="padding"> |
1456 | 1506 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1457 | 1507 | </p>'; |
1508 | + } |
|
1458 | 1509 | |
1459 | - } |
|
1460 | - else |
|
1510 | + } else |
|
1461 | 1511 | { |
1462 | 1512 | if (!empty($context['redirect_to_recount'])) |
1463 | 1513 | { |
@@ -1469,8 +1519,7 @@ discard block |
||
1469 | 1519 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1470 | 1520 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1471 | 1521 | </form>'; |
1472 | - } |
|
1473 | - else |
|
1522 | + } else |
|
1474 | 1523 | { |
1475 | 1524 | echo ' |
1476 | 1525 | <p>', $txt['errors_fixed'], '</p> |
@@ -1561,9 +1610,10 @@ discard block |
||
1561 | 1610 | <tr class="windowbg"> |
1562 | 1611 | <td class="equal_table">', $key, '</td>'; |
1563 | 1612 | |
1564 | - foreach ($setting as $key_lm => $value) |
|
1565 | - echo ' |
|
1613 | + foreach ($setting as $key_lm => $value) { |
|
1614 | + echo ' |
|
1566 | 1615 | <td class="equal_table">', $value, '</td>'; |
1616 | + } |
|
1567 | 1617 | |
1568 | 1618 | echo ' |
1569 | 1619 | </tr>'; |
@@ -1623,8 +1673,8 @@ discard block |
||
1623 | 1673 | { |
1624 | 1674 | global $context, $txt; |
1625 | 1675 | |
1626 | - if ($context['user']['is_admin']) |
|
1627 | - echo ' |
|
1676 | + if ($context['user']['is_admin']) { |
|
1677 | + echo ' |
|
1628 | 1678 | <span class="floatright admin_search"> |
1629 | 1679 | <span class="generic_icons filter centericon"></span> |
1630 | 1680 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';"> |
@@ -1635,6 +1685,7 @@ discard block |
||
1635 | 1685 | </select> |
1636 | 1686 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
1637 | 1687 | </span>'; |
1638 | -} |
|
1688 | + } |
|
1689 | + } |
|
1639 | 1690 | |
1640 | 1691 | ?> |
1641 | 1692 | \ No newline at end of file |
@@ -18,9 +18,10 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl; |
19 | 19 | |
20 | 20 | // Are we done sending the newsletter? |
21 | - if (!empty($context['newsletter_sent'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['newsletter_sent'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox">', $txt['admin_news_newsletter_' . $context['newsletter_sent']], '</div>'; |
24 | + } |
|
24 | 25 | |
25 | 26 | echo ' |
26 | 27 | <div id="admincenter"> |
@@ -39,9 +40,10 @@ discard block |
||
39 | 40 | </dt> |
40 | 41 | <dd>'; |
41 | 42 | |
42 | - foreach ($context['groups'] as $group) |
|
43 | - echo ' |
|
43 | + foreach ($context['groups'] as $group) { |
|
44 | + echo ' |
|
44 | 45 | <label for="groups_', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
46 | + } |
|
45 | 47 | |
46 | 48 | echo ' |
47 | 49 | <br> |
@@ -82,9 +84,10 @@ discard block |
||
82 | 84 | </dt> |
83 | 85 | <dd>'; |
84 | 86 | |
85 | - foreach ($context['groups'] as $group) |
|
86 | - echo ' |
|
87 | + foreach ($context['groups'] as $group) { |
|
88 | + echo ' |
|
87 | 89 | <label for="exclude_groups_', $group['id'], '"><input type="checkbox" name="exclude_groups[', $group['id'], ']" id="exclude_groups_', $group['id'], '" value="', $group['id'], '"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
90 | + } |
|
88 | 91 | |
89 | 92 | echo ' |
90 | 93 | <br> |
@@ -230,9 +233,10 @@ discard block |
||
230 | 233 | <div id="bbcBox_message"></div>'; |
231 | 234 | |
232 | 235 | // What about smileys? |
233 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
234 | - echo ' |
|
236 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
237 | + echo ' |
|
235 | 238 | <div id="smileyBox_message"></div>'; |
239 | + } |
|
236 | 240 | |
237 | 241 | // Show BBC buttons, smileys and textbox. |
238 | 242 | echo ' |
@@ -253,9 +257,10 @@ discard block |
||
253 | 257 | <input type="hidden" name="email_force" value="', $context['email_force'], '"> |
254 | 258 | <input type="hidden" name="total_emails" value="', $context['total_emails'], '">'; |
255 | 259 | |
256 | - foreach ($context['recipients'] as $key => $values) |
|
257 | - echo ' |
|
260 | + foreach ($context['recipients'] as $key => $values) { |
|
261 | + echo ' |
|
258 | 262 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
263 | + } |
|
259 | 264 | |
260 | 265 | echo ' |
261 | 266 | <script>'; |
@@ -413,9 +418,10 @@ discard block |
||
413 | 418 | <input type="hidden" name="parse_html" value="', $context['parse_html'], '">'; |
414 | 419 | |
415 | 420 | // All the things we must remember! |
416 | - foreach ($context['recipients'] as $key => $values) |
|
417 | - echo ' |
|
421 | + foreach ($context['recipients'] as $key => $values) { |
|
422 | + echo ' |
|
418 | 423 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
424 | + } |
|
419 | 425 | |
420 | 426 | echo ' |
421 | 427 | </div><!-- .windowbg --> |
@@ -448,9 +454,10 @@ discard block |
||
448 | 454 | { |
449 | 455 | global $context, $txt; |
450 | 456 | |
451 | - if (!empty($context['saved_successful'])) |
|
452 | - echo ' |
|
457 | + if (!empty($context['saved_successful'])) { |
|
458 | + echo ' |
|
453 | 459 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
460 | + } |
|
454 | 461 | |
455 | 462 | template_show_list('news_lists'); |
456 | 463 | } |