@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | /** |
501 | 501 | * Returns the amount of affected rows for a query. |
502 | 502 | * |
503 | - * @param mixed $result |
|
503 | + * @param resource|null $result |
|
504 | 504 | * |
505 | 505 | * @return int |
506 | 506 | * |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @param string $db_name The database name |
871 | 871 | * @param resource $db_connection The database connection |
872 | - * @return true Always returns true |
|
872 | + * @return boolean Always returns true |
|
873 | 873 | */ |
874 | 874 | function smf_db_select_db($db_name, $db_connection) |
875 | 875 | { |
@@ -198,22 +198,22 @@ discard block |
||
198 | 198 | |
199 | 199 | case 'date': |
200 | 200 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
201 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
201 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]) . '::date'; |
|
202 | 202 | else |
203 | 203 | smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
204 | 204 | break; |
205 | 205 | |
206 | 206 | case 'time': |
207 | 207 | if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
208 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
208 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]) . '::time'; |
|
209 | 209 | else |
210 | 210 | smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
211 | 211 | break; |
212 | 212 | |
213 | 213 | case 'datetime': |
214 | 214 | 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) |
215 | - return 'to_timestamp('. |
|
216 | - 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]). |
|
215 | + return 'to_timestamp(' . |
|
216 | + 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]) . |
|
217 | 217 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
218 | 218 | else |
219 | 219 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $old_pos = 0; |
424 | 424 | $pos = -1; |
425 | 425 | // Remove the string escape for better runtime |
426 | - $db_string_1 = str_replace('\'\'','',$db_string); |
|
426 | + $db_string_1 = str_replace('\'\'', '', $db_string); |
|
427 | 427 | while (true) |
428 | 428 | { |
429 | 429 | $pos = strpos($db_string_1, '\'', $pos + 1); |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
802 | 802 | { |
803 | 803 | // we only take the first key |
804 | - $returning = ' RETURNING '.$keys[0]; |
|
804 | + $returning = ' RETURNING ' . $keys[0]; |
|
805 | 805 | $with_returning = true; |
806 | 806 | } |
807 | 807 | |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | INSERT INTO ' . $table . '("' . implode('", "', $indexed_columns) . '") |
833 | 833 | VALUES |
834 | 834 | ' . implode(', |
835 | - ', $insertRows).$replace.$returning, |
|
835 | + ', $insertRows) . $replace . $returning, |
|
836 | 836 | array( |
837 | 837 | 'security_override' => true, |
838 | 838 | 'db_error_skip' => $method == 'ignore' || $table === $db_prefix . 'log_errors', |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | if ($returnmode === 2) |
846 | 846 | $return_var = array(); |
847 | 847 | |
848 | - while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
848 | + while (($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
849 | 849 | { |
850 | 850 | if (is_numeric($row[0])) // try to emulate mysql limitation |
851 | 851 | { |
@@ -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) |
@@ -34,8 +35,8 @@ discard block |
||
34 | 35 | global $smcFunc; |
35 | 36 | |
36 | 37 | // Map some database specific functions, only do this once. |
37 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
38 | - $smcFunc += array( |
|
38 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
39 | + $smcFunc += array( |
|
39 | 40 | 'db_query' => 'smf_db_query', |
40 | 41 | 'db_quote' => 'smf_db_quote', |
41 | 42 | 'db_insert' => 'smf_db_insert', |
@@ -63,11 +64,13 @@ discard block |
||
63 | 64 | 'db_fetch_all' => 'smf_db_fetch_all', |
64 | 65 | 'db_error_insert' => 'smf_db_error_insert', |
65 | 66 | ); |
67 | + } |
|
66 | 68 | |
67 | - if (!empty($db_options['persist'])) |
|
68 | - $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
69 | - else |
|
70 | - $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
69 | + if (!empty($db_options['persist'])) { |
|
70 | + $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
71 | + } else { |
|
72 | + $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
73 | + } |
|
71 | 74 | |
72 | 75 | // Something's wrong, show an error if its fatal (which we assume it is) |
73 | 76 | if (!$connection) |
@@ -75,8 +78,7 @@ discard block |
||
75 | 78 | if (!empty($db_options['non_fatal'])) |
76 | 79 | { |
77 | 80 | return null; |
78 | - } |
|
79 | - else |
|
81 | + } else |
|
80 | 82 | { |
81 | 83 | display_db_error(); |
82 | 84 | } |
@@ -127,31 +129,38 @@ discard block |
||
127 | 129 | |
128 | 130 | list ($values, $connection) = $db_callback; |
129 | 131 | |
130 | - if ($matches[1] === 'db_prefix') |
|
131 | - return $db_prefix; |
|
132 | + if ($matches[1] === 'db_prefix') { |
|
133 | + return $db_prefix; |
|
134 | + } |
|
132 | 135 | |
133 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
134 | - return $user_info[$matches[1]]; |
|
136 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
137 | + return $user_info[$matches[1]]; |
|
138 | + } |
|
135 | 139 | |
136 | - if ($matches[1] === 'empty') |
|
137 | - return '\'\''; |
|
140 | + if ($matches[1] === 'empty') { |
|
141 | + return '\'\''; |
|
142 | + } |
|
138 | 143 | |
139 | - if (!isset($matches[2])) |
|
140 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
144 | + if (!isset($matches[2])) { |
|
145 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
146 | + } |
|
141 | 147 | |
142 | - if ($matches[1] === 'literal') |
|
143 | - return '\'' . pg_escape_string($matches[2]) . '\''; |
|
148 | + if ($matches[1] === 'literal') { |
|
149 | + return '\'' . pg_escape_string($matches[2]) . '\''; |
|
150 | + } |
|
144 | 151 | |
145 | - if (!isset($values[$matches[2]])) |
|
146 | - 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__); |
|
152 | + if (!isset($values[$matches[2]])) { |
|
153 | + 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__); |
|
154 | + } |
|
147 | 155 | |
148 | 156 | $replacement = $values[$matches[2]]; |
149 | 157 | |
150 | 158 | switch ($matches[1]) |
151 | 159 | { |
152 | 160 | case 'int': |
153 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
154 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
161 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
162 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
163 | + } |
|
155 | 164 | return (string) (int) $replacement; |
156 | 165 | break; |
157 | 166 | |
@@ -163,65 +172,73 @@ discard block |
||
163 | 172 | case 'array_int': |
164 | 173 | if (is_array($replacement)) |
165 | 174 | { |
166 | - if (empty($replacement)) |
|
167 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
175 | + if (empty($replacement)) { |
|
176 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
177 | + } |
|
168 | 178 | |
169 | 179 | foreach ($replacement as $key => $value) |
170 | 180 | { |
171 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
172 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
181 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
182 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | $replacement[$key] = (string) (int) $value; |
175 | 186 | } |
176 | 187 | |
177 | 188 | return implode(', ', $replacement); |
189 | + } else { |
|
190 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
178 | 191 | } |
179 | - else |
|
180 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
181 | 192 | |
182 | 193 | break; |
183 | 194 | |
184 | 195 | case 'array_string': |
185 | 196 | if (is_array($replacement)) |
186 | 197 | { |
187 | - if (empty($replacement)) |
|
188 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
198 | + if (empty($replacement)) { |
|
199 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
200 | + } |
|
189 | 201 | |
190 | - foreach ($replacement as $key => $value) |
|
191 | - $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
202 | + foreach ($replacement as $key => $value) { |
|
203 | + $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
204 | + } |
|
192 | 205 | |
193 | 206 | return implode(', ', $replacement); |
207 | + } else { |
|
208 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
194 | 209 | } |
195 | - else |
|
196 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
197 | 210 | break; |
198 | 211 | |
199 | 212 | case 'date': |
200 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
201 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
202 | - else |
|
203 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
213 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
214 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
215 | + } else { |
|
216 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
217 | + } |
|
204 | 218 | break; |
205 | 219 | |
206 | 220 | case 'time': |
207 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
208 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
209 | - else |
|
210 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
221 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
222 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
223 | + } else { |
|
224 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
225 | + } |
|
211 | 226 | break; |
212 | 227 | |
213 | 228 | case 'datetime': |
214 | - 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) |
|
215 | - return 'to_timestamp('. |
|
229 | + 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) { |
|
230 | + return 'to_timestamp('. |
|
216 | 231 | 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]). |
217 | 232 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
218 | - else |
|
219 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
233 | + } else { |
|
234 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
235 | + } |
|
220 | 236 | break; |
221 | 237 | |
222 | 238 | case 'float': |
223 | - if (!is_numeric($replacement)) |
|
224 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
239 | + if (!is_numeric($replacement)) { |
|
240 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
241 | + } |
|
225 | 242 | return (string) (float) $replacement; |
226 | 243 | break; |
227 | 244 | |
@@ -234,31 +251,36 @@ discard block |
||
234 | 251 | break; |
235 | 252 | |
236 | 253 | case 'inet': |
237 | - if ($replacement == 'null' || $replacement == '') |
|
238 | - return 'null'; |
|
239 | - if (inet_pton($replacement) === false) |
|
240 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
254 | + if ($replacement == 'null' || $replacement == '') { |
|
255 | + return 'null'; |
|
256 | + } |
|
257 | + if (inet_pton($replacement) === false) { |
|
258 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
259 | + } |
|
241 | 260 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
242 | 261 | |
243 | 262 | case 'array_inet': |
244 | 263 | if (is_array($replacement)) |
245 | 264 | { |
246 | - if (empty($replacement)) |
|
247 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
265 | + if (empty($replacement)) { |
|
266 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
267 | + } |
|
248 | 268 | |
249 | 269 | foreach ($replacement as $key => $value) |
250 | 270 | { |
251 | - if ($replacement == 'null' || $replacement == '') |
|
252 | - $replacement[$key] = 'null'; |
|
253 | - if (!isValidIP($value)) |
|
254 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
271 | + if ($replacement == 'null' || $replacement == '') { |
|
272 | + $replacement[$key] = 'null'; |
|
273 | + } |
|
274 | + if (!isValidIP($value)) { |
|
275 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
276 | + } |
|
255 | 277 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
256 | 278 | } |
257 | 279 | |
258 | 280 | return implode(', ', $replacement); |
281 | + } else { |
|
282 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
259 | 283 | } |
260 | - else |
|
261 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
262 | 284 | break; |
263 | 285 | |
264 | 286 | default: |
@@ -349,14 +371,16 @@ discard block |
||
349 | 371 | ), |
350 | 372 | ); |
351 | 373 | |
352 | - if (isset($replacements[$identifier])) |
|
353 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
374 | + if (isset($replacements[$identifier])) { |
|
375 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
376 | + } |
|
354 | 377 | |
355 | 378 | // Limits need to be a little different. |
356 | 379 | $db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string); |
357 | 380 | |
358 | - if (trim($db_string) == '') |
|
359 | - return false; |
|
381 | + if (trim($db_string) == '') { |
|
382 | + return false; |
|
383 | + } |
|
360 | 384 | |
361 | 385 | // Comments that are allowed in a query are preg_removed. |
362 | 386 | static $allowed_comments_from = array( |
@@ -376,8 +400,9 @@ discard block |
||
376 | 400 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
377 | 401 | $db_replace_result = 0; |
378 | 402 | |
379 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
380 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
403 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
404 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
405 | + } |
|
381 | 406 | |
382 | 407 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
383 | 408 | { |
@@ -398,8 +423,9 @@ discard block |
||
398 | 423 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
399 | 424 | |
400 | 425 | // Initialize $db_cache if not already initialized. |
401 | - if (!isset($db_cache)) |
|
402 | - $db_cache = array(); |
|
426 | + if (!isset($db_cache)) { |
|
427 | + $db_cache = array(); |
|
428 | + } |
|
403 | 429 | |
404 | 430 | if (!empty($_SESSION['debug_redirect'])) |
405 | 431 | { |
@@ -427,17 +453,18 @@ discard block |
||
427 | 453 | while (true) |
428 | 454 | { |
429 | 455 | $pos = strpos($db_string_1, '\'', $pos + 1); |
430 | - if ($pos === false) |
|
431 | - break; |
|
456 | + if ($pos === false) { |
|
457 | + break; |
|
458 | + } |
|
432 | 459 | $clean .= substr($db_string_1, $old_pos, $pos - $old_pos); |
433 | 460 | |
434 | 461 | while (true) |
435 | 462 | { |
436 | 463 | $pos1 = strpos($db_string_1, '\'', $pos + 1); |
437 | 464 | $pos2 = strpos($db_string_1, '\\', $pos + 1); |
438 | - if ($pos1 === false) |
|
439 | - break; |
|
440 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
465 | + if ($pos1 === false) { |
|
466 | + break; |
|
467 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
441 | 468 | { |
442 | 469 | $pos = $pos1; |
443 | 470 | break; |
@@ -453,16 +480,19 @@ discard block |
||
453 | 480 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
454 | 481 | |
455 | 482 | // Comments? We don't use comments in our queries, we leave 'em outside! |
456 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
457 | - $fail = true; |
|
483 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
484 | + $fail = true; |
|
485 | + } |
|
458 | 486 | // Trying to change passwords, slow us down, or something? |
459 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
460 | - $fail = true; |
|
461 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
462 | - $fail = true; |
|
487 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
488 | + $fail = true; |
|
489 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
490 | + $fail = true; |
|
491 | + } |
|
463 | 492 | |
464 | - if (!empty($fail) && function_exists('log_error')) |
|
465 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
493 | + if (!empty($fail) && function_exists('log_error')) { |
|
494 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
495 | + } |
|
466 | 496 | } |
467 | 497 | |
468 | 498 | // Set optimize stuff |
@@ -481,18 +511,21 @@ discard block |
||
481 | 511 | |
482 | 512 | $db_string = $query_hints_set . $db_string; |
483 | 513 | |
484 | - if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...') |
|
485 | - $db_cache[$db_count]['q'] = "\t\t" . $db_string; |
|
514 | + if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...') { |
|
515 | + $db_cache[$db_count]['q'] = "\t\t" . $db_string; |
|
516 | + } |
|
486 | 517 | } |
487 | 518 | |
488 | 519 | $db_last_result = @pg_query($connection, $db_string); |
489 | 520 | |
490 | - if ($db_last_result === false && empty($db_values['db_error_skip'])) |
|
491 | - $db_last_result = smf_db_error($db_string, $connection); |
|
521 | + if ($db_last_result === false && empty($db_values['db_error_skip'])) { |
|
522 | + $db_last_result = smf_db_error($db_string, $connection); |
|
523 | + } |
|
492 | 524 | |
493 | 525 | // Debugging. |
494 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
495 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
526 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
527 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
528 | + } |
|
496 | 529 | |
497 | 530 | return $db_last_result; |
498 | 531 | } |
@@ -509,10 +542,11 @@ discard block |
||
509 | 542 | { |
510 | 543 | global $db_last_result, $db_replace_result; |
511 | 544 | |
512 | - if ($db_replace_result) |
|
513 | - return $db_replace_result; |
|
514 | - elseif ($result === null && !$db_last_result) |
|
515 | - return 0; |
|
545 | + if ($db_replace_result) { |
|
546 | + return $db_replace_result; |
|
547 | + } elseif ($result === null && !$db_last_result) { |
|
548 | + return 0; |
|
549 | + } |
|
516 | 550 | |
517 | 551 | return pg_affected_rows($result === null ? $db_last_result : $result); |
518 | 552 | } |
@@ -536,8 +570,9 @@ discard block |
||
536 | 570 | array( |
537 | 571 | ) |
538 | 572 | ); |
539 | - if (!$request) |
|
540 | - return false; |
|
573 | + if (!$request) { |
|
574 | + return false; |
|
575 | + } |
|
541 | 576 | list ($lastID) = $smcFunc['db_fetch_row']($request); |
542 | 577 | $smcFunc['db_free_result']($request); |
543 | 578 | |
@@ -558,12 +593,13 @@ discard block |
||
558 | 593 | // Decide which connection to use |
559 | 594 | $connection = $connection === null ? $db_connection : $connection; |
560 | 595 | |
561 | - if ($type == 'begin') |
|
562 | - return @pg_query($connection, 'BEGIN'); |
|
563 | - elseif ($type == 'rollback') |
|
564 | - return @pg_query($connection, 'ROLLBACK'); |
|
565 | - elseif ($type == 'commit') |
|
566 | - return @pg_query($connection, 'COMMIT'); |
|
596 | + if ($type == 'begin') { |
|
597 | + return @pg_query($connection, 'BEGIN'); |
|
598 | + } elseif ($type == 'rollback') { |
|
599 | + return @pg_query($connection, 'ROLLBACK'); |
|
600 | + } elseif ($type == 'commit') { |
|
601 | + return @pg_query($connection, 'COMMIT'); |
|
602 | + } |
|
567 | 603 | |
568 | 604 | return false; |
569 | 605 | } |
@@ -591,19 +627,22 @@ discard block |
||
591 | 627 | $query_error = @pg_last_error($connection); |
592 | 628 | |
593 | 629 | // Log the error. |
594 | - if (function_exists('log_error')) |
|
595 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
630 | + if (function_exists('log_error')) { |
|
631 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
632 | + } |
|
596 | 633 | |
597 | 634 | // Nothing's defined yet... just die with it. |
598 | - if (empty($context) || empty($txt)) |
|
599 | - die($query_error); |
|
635 | + if (empty($context) || empty($txt)) { |
|
636 | + die($query_error); |
|
637 | + } |
|
600 | 638 | |
601 | 639 | // Show an error message, if possible. |
602 | 640 | $context['error_title'] = $txt['database_error']; |
603 | - if (allowedTo('admin_forum')) |
|
604 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
605 | - else |
|
606 | - $context['error_message'] = $txt['try_again']; |
|
641 | + if (allowedTo('admin_forum')) { |
|
642 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
643 | + } else { |
|
644 | + $context['error_message'] = $txt['try_again']; |
|
645 | + } |
|
607 | 646 | |
608 | 647 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
609 | 648 | { |
@@ -625,12 +664,14 @@ discard block |
||
625 | 664 | { |
626 | 665 | global $db_row_count; |
627 | 666 | |
628 | - if ($counter !== false) |
|
629 | - return pg_fetch_row($request, $counter); |
|
667 | + if ($counter !== false) { |
|
668 | + return pg_fetch_row($request, $counter); |
|
669 | + } |
|
630 | 670 | |
631 | 671 | // Reset the row counter... |
632 | - if (!isset($db_row_count[(int) $request])) |
|
633 | - $db_row_count[(int) $request] = 0; |
|
672 | + if (!isset($db_row_count[(int) $request])) { |
|
673 | + $db_row_count[(int) $request] = 0; |
|
674 | + } |
|
634 | 675 | |
635 | 676 | // Return the right row. |
636 | 677 | return @pg_fetch_row($request, $db_row_count[(int) $request]++); |
@@ -647,12 +688,14 @@ discard block |
||
647 | 688 | { |
648 | 689 | global $db_row_count; |
649 | 690 | |
650 | - if ($counter !== false) |
|
651 | - return pg_fetch_assoc($request, $counter); |
|
691 | + if ($counter !== false) { |
|
692 | + return pg_fetch_assoc($request, $counter); |
|
693 | + } |
|
652 | 694 | |
653 | 695 | // Reset the row counter... |
654 | - if (!isset($db_row_count[(int) $request])) |
|
655 | - $db_row_count[(int) $request] = 0; |
|
696 | + if (!isset($db_row_count[(int) $request])) { |
|
697 | + $db_row_count[(int) $request] = 0; |
|
698 | + } |
|
656 | 699 | |
657 | 700 | // Return the right row. |
658 | 701 | return @pg_fetch_assoc($request, $db_row_count[(int) $request]++); |
@@ -705,11 +748,13 @@ discard block |
||
705 | 748 | |
706 | 749 | $replace = ''; |
707 | 750 | |
708 | - if (empty($data)) |
|
709 | - return; |
|
751 | + if (empty($data)) { |
|
752 | + return; |
|
753 | + } |
|
710 | 754 | |
711 | - if (!is_array($data[array_rand($data)])) |
|
712 | - $data = array($data); |
|
755 | + if (!is_array($data[array_rand($data)])) { |
|
756 | + $data = array($data); |
|
757 | + } |
|
713 | 758 | |
714 | 759 | // Replace the prefix holder with the actual prefix. |
715 | 760 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -728,11 +773,13 @@ discard block |
||
728 | 773 | //pg 9.5 got replace support |
729 | 774 | $pg_version = $smcFunc['db_get_version'](); |
730 | 775 | // if we got a Beta Version |
731 | - if (stripos($pg_version, 'beta') !== false) |
|
732 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
776 | + if (stripos($pg_version, 'beta') !== false) { |
|
777 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
778 | + } |
|
733 | 779 | // or RC |
734 | - if (stripos($pg_version, 'rc') !== false) |
|
735 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
780 | + if (stripos($pg_version, 'rc') !== false) { |
|
781 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
782 | + } |
|
736 | 783 | |
737 | 784 | $replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false); |
738 | 785 | } |
@@ -751,32 +798,35 @@ discard block |
||
751 | 798 | $key_str .= ($count_pk > 0 ? ',' : ''); |
752 | 799 | $key_str .= $columnName; |
753 | 800 | $count_pk++; |
754 | - } |
|
755 | - else if ($method == 'replace') //normal field |
|
801 | + } else if ($method == 'replace') { |
|
802 | + //normal field |
|
756 | 803 | { |
757 | 804 | $col_str .= ($count > 0 ? ',' : ''); |
805 | + } |
|
758 | 806 | $col_str .= $columnName . ' = EXCLUDED.' . $columnName; |
759 | 807 | $count++; |
760 | 808 | } |
761 | 809 | } |
762 | - if ($method == 'replace') |
|
763 | - $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
764 | - else |
|
765 | - $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
766 | - } |
|
767 | - else if ($method == 'replace') |
|
810 | + if ($method == 'replace') { |
|
811 | + $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
812 | + } else { |
|
813 | + $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
814 | + } |
|
815 | + } else if ($method == 'replace') |
|
768 | 816 | { |
769 | 817 | foreach ($columns as $columnName => $type) |
770 | 818 | { |
771 | 819 | // Are we restricting the length? |
772 | - if (strpos($type, 'string-') !== false) |
|
773 | - $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
774 | - else |
|
775 | - $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
820 | + if (strpos($type, 'string-') !== false) { |
|
821 | + $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
822 | + } else { |
|
823 | + $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
824 | + } |
|
776 | 825 | |
777 | 826 | // A key? That's what we were looking for. |
778 | - if (in_array($columnName, $keys)) |
|
779 | - $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
827 | + if (in_array($columnName, $keys)) { |
|
828 | + $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
829 | + } |
|
780 | 830 | $count++; |
781 | 831 | } |
782 | 832 | |
@@ -812,10 +862,11 @@ discard block |
||
812 | 862 | foreach ($columns as $columnName => $type) |
813 | 863 | { |
814 | 864 | // Are we restricting the length? |
815 | - if (strpos($type, 'string-') !== false) |
|
816 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
817 | - else |
|
818 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
865 | + if (strpos($type, 'string-') !== false) { |
|
866 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
867 | + } else { |
|
868 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
869 | + } |
|
819 | 870 | } |
820 | 871 | $insertData = substr($insertData, 0, -2) . ')'; |
821 | 872 | |
@@ -824,8 +875,9 @@ discard block |
||
824 | 875 | |
825 | 876 | // Here's where the variables are injected to the query. |
826 | 877 | $insertRows = array(); |
827 | - foreach ($data as $dataRow) |
|
828 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
878 | + foreach ($data as $dataRow) { |
|
879 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
880 | + } |
|
829 | 881 | |
830 | 882 | // Do the insert. |
831 | 883 | $request = $smcFunc['db_query']('', ' |
@@ -842,19 +894,21 @@ discard block |
||
842 | 894 | |
843 | 895 | if ($with_returning && $request !== false) |
844 | 896 | { |
845 | - if ($returnmode === 2) |
|
846 | - $return_var = array(); |
|
897 | + if ($returnmode === 2) { |
|
898 | + $return_var = array(); |
|
899 | + } |
|
847 | 900 | |
848 | 901 | while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
849 | 902 | { |
850 | - if (is_numeric($row[0])) // try to emulate mysql limitation |
|
903 | + if (is_numeric($row[0])) { |
|
904 | + // try to emulate mysql limitation |
|
851 | 905 | { |
852 | 906 | if ($returnmode === 1) |
853 | 907 | $return_var = $row[0]; |
854 | - elseif ($returnmode === 2) |
|
855 | - $return_var[] = $row[0]; |
|
856 | - } |
|
857 | - else |
|
908 | + } elseif ($returnmode === 2) { |
|
909 | + $return_var[] = $row[0]; |
|
910 | + } |
|
911 | + } else |
|
858 | 912 | { |
859 | 913 | $with_returning = false; |
860 | 914 | trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR); |
@@ -863,9 +917,10 @@ discard block |
||
863 | 917 | } |
864 | 918 | } |
865 | 919 | |
866 | - if ($with_returning && !empty($return_var)) |
|
867 | - return $return_var; |
|
868 | -} |
|
920 | + if ($with_returning && !empty($return_var)) { |
|
921 | + return $return_var; |
|
922 | + } |
|
923 | + } |
|
869 | 924 | |
870 | 925 | /** |
871 | 926 | * Dummy function really. Doesn't do anything on PostgreSQL. |
@@ -902,8 +957,9 @@ discard block |
||
902 | 957 | */ |
903 | 958 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
904 | 959 | { |
905 | - if (empty($log_message)) |
|
906 | - $log_message = $error_message; |
|
960 | + if (empty($log_message)) { |
|
961 | + $log_message = $error_message; |
|
962 | + } |
|
907 | 963 | |
908 | 964 | foreach (debug_backtrace() as $step) |
909 | 965 | { |
@@ -922,12 +978,14 @@ discard block |
||
922 | 978 | } |
923 | 979 | |
924 | 980 | // A special case - we want the file and line numbers for debugging. |
925 | - if ($error_type == 'return') |
|
926 | - return array($file, $line); |
|
981 | + if ($error_type == 'return') { |
|
982 | + return array($file, $line); |
|
983 | + } |
|
927 | 984 | |
928 | 985 | // Is always a critical error. |
929 | - if (function_exists('log_error')) |
|
930 | - log_error($log_message, 'critical', $file, $line); |
|
986 | + if (function_exists('log_error')) { |
|
987 | + log_error($log_message, 'critical', $file, $line); |
|
988 | + } |
|
931 | 989 | |
932 | 990 | if (function_exists('fatal_error')) |
933 | 991 | { |
@@ -935,12 +993,12 @@ discard block |
||
935 | 993 | |
936 | 994 | // Cannot continue... |
937 | 995 | exit; |
996 | + } elseif ($error_type) { |
|
997 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
998 | + } else { |
|
999 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
1000 | + } |
|
938 | 1001 | } |
939 | - elseif ($error_type) |
|
940 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
941 | - else |
|
942 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
943 | -} |
|
944 | 1002 | |
945 | 1003 | /** |
946 | 1004 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -957,10 +1015,11 @@ discard block |
||
957 | 1015 | '\\' => '\\\\', |
958 | 1016 | ); |
959 | 1017 | |
960 | - if ($translate_human_wildcards) |
|
961 | - $replacements += array( |
|
1018 | + if ($translate_human_wildcards) { |
|
1019 | + $replacements += array( |
|
962 | 1020 | '*' => '%', |
963 | 1021 | ); |
1022 | + } |
|
964 | 1023 | |
965 | 1024 | return strtr($string, $replacements); |
966 | 1025 | } |
@@ -988,11 +1047,12 @@ discard block |
||
988 | 1047 | global $db_prefix, $db_connection; |
989 | 1048 | static $pg_error_data_prep; |
990 | 1049 | |
991 | - if (empty($pg_error_data_prep)) |
|
992 | - $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
1050 | + if (empty($pg_error_data_prep)) { |
|
1051 | + $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
993 | 1052 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
994 | 1053 | VALUES( $1, $2, $3, $4, $5, $6, $7, $8, $9)' |
995 | 1054 | ); |
1055 | + } |
|
996 | 1056 | |
997 | 1057 | pg_execute($db_connection, 'smf_log_errors', $error_array); |
998 | 1058 | } |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | 'class' => 'centercol', |
1335 | 1335 | ), |
1336 | 1336 | 'data' => array( |
1337 | - 'function' => function ($rowData) |
|
1337 | + 'function' => function($rowData) |
|
1338 | 1338 | { |
1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | 'class' => 'centercol', |
1351 | 1351 | ), |
1352 | 1352 | 'data' => array( |
1353 | - 'function' => function ($rowData) |
|
1353 | + 'function' => function($rowData) |
|
1354 | 1354 | { |
1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
1398 | 1398 | ), |
1399 | 1399 | 'data' => array( |
1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1401 | 1401 | { |
1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
1403 | 1403 | |
1404 | 1404 | if ($rowData['field_order'] > 1) |
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1406 | 1406 | |
1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1409 | 1409 | |
1410 | 1410 | $return .= '</p>'; |
1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
1424 | 1424 | ), |
1425 | 1425 | 'data' => array( |
1426 | - 'function' => function ($rowData) use ($scripturl) |
|
1426 | + 'function' => function($rowData) use ($scripturl) |
|
1427 | 1427 | { |
1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
1440 | 1440 | ), |
1441 | 1441 | 'data' => array( |
1442 | - 'function' => function ($rowData) use ($txt) |
|
1442 | + 'function' => function($rowData) use ($txt) |
|
1443 | 1443 | { |
1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | 'value' => $txt['custom_profile_active'], |
1458 | 1458 | ), |
1459 | 1459 | 'data' => array( |
1460 | - 'function' => function ($rowData) use ($txt) |
|
1460 | + 'function' => function($rowData) use ($txt) |
|
1461 | 1461 | { |
1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
1475 | 1475 | ), |
1476 | 1476 | 'data' => array( |
1477 | - 'function' => function ($rowData) |
|
1477 | + 'function' => function($rowData) |
|
1478 | 1478 | { |
1479 | 1479 | global $txt, $context; |
1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1710 | 1710 | |
1711 | 1711 | // All good, proceed. |
1712 | - $smcFunc['db_query']('',' |
|
1712 | + $smcFunc['db_query']('', ' |
|
1713 | 1713 | UPDATE {db_prefix}custom_fields |
1714 | 1714 | SET field_order = {int:old_order} |
1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | 'old_order' => $context['field']['order'], |
1719 | 1719 | ) |
1720 | 1720 | ); |
1721 | - $smcFunc['db_query']('',' |
|
1721 | + $smcFunc['db_query']('', ' |
|
1722 | 1722 | UPDATE {db_prefix}custom_fields |
1723 | 1723 | SET field_order = {int:new_order} |
1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | $smcFunc['db_free_result']($request); |
1821 | 1821 | |
1822 | 1822 | $unique = false; |
1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1824 | 1824 | { |
1825 | 1825 | if (!in_array($col_name, $current_fields)) |
1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | ); |
1994 | 1994 | |
1995 | 1995 | // Re-arrange the order. |
1996 | - $smcFunc['db_query']('',' |
|
1996 | + $smcFunc['db_query']('', ' |
|
1997 | 1997 | UPDATE {db_prefix}custom_fields |
1998 | 1998 | SET field_order = field_order - 1 |
1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
2257 | 2257 | $context['token_check'] = 'noti-admin'; |
2258 | 2258 | |
2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2261 | 2261 | |
2262 | 2262 | loadTemplate('Profile'); |
2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
269 | 273 | |
270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
271 | 275 | |
272 | - if ($return_config) |
|
273 | - return $config_vars; |
|
276 | + if ($return_config) { |
|
277 | + return $config_vars; |
|
278 | + } |
|
274 | 279 | |
275 | 280 | // Setup the template. |
276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
287 | 292 | |
288 | 293 | // Clean up the tags. |
289 | 294 | $bbcTags = array(); |
290 | - foreach (parse_bbc(false) as $tag) |
|
291 | - $bbcTags[] = $tag['tag']; |
|
295 | + foreach (parse_bbc(false) as $tag) { |
|
296 | + $bbcTags[] = $tag['tag']; |
|
297 | + } |
|
292 | 298 | |
293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
303 | + } |
|
297 | 304 | // Work out what is actually disabled! |
298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
337 | 344 | |
338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
339 | 346 | |
340 | - if ($return_config) |
|
341 | - return $config_vars; |
|
347 | + if ($return_config) { |
|
348 | + return $config_vars; |
|
349 | + } |
|
342 | 350 | |
343 | 351 | // Saving? |
344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
379 | 387 | |
380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
381 | 389 | |
382 | - if ($return_config) |
|
383 | - return $config_vars; |
|
390 | + if ($return_config) { |
|
391 | + return $config_vars; |
|
392 | + } |
|
384 | 393 | |
385 | 394 | // Saving? |
386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
418 | 427 | |
419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
420 | 429 | |
421 | - if ($return_config) |
|
422 | - return $config_vars; |
|
430 | + if ($return_config) { |
|
431 | + return $config_vars; |
|
432 | + } |
|
423 | 433 | |
424 | 434 | // Saving? |
425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
463 | 473 | 'enable' => array('check', 'warning_enable'), |
464 | 474 | ); |
465 | 475 | |
466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
467 | - $config_vars += array( |
|
476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
477 | + $config_vars += array( |
|
468 | 478 | '', |
469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
474 | 484 | array('permissions', 'view_warning'), |
475 | 485 | ); |
486 | + } |
|
476 | 487 | |
477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
478 | 489 | |
479 | - if ($return_config) |
|
480 | - return $config_vars; |
|
490 | + if ($return_config) { |
|
491 | + return $config_vars; |
|
492 | + } |
|
481 | 493 | |
482 | 494 | // Cannot use moderation if post moderation is not enabled. |
483 | - if (!$modSettings['postmod_active']) |
|
484 | - unset($config_vars['moderate']); |
|
495 | + if (!$modSettings['postmod_active']) { |
|
496 | + unset($config_vars['moderate']); |
|
497 | + } |
|
485 | 498 | |
486 | 499 | // Will need the utility functions from here. |
487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
506 | 519 | 'warning_watch' => 10, |
507 | 520 | 'warning_mute' => 60, |
508 | 521 | ); |
509 | - if ($modSettings['postmod_active']) |
|
510 | - $vars['warning_moderate'] = 35; |
|
522 | + if ($modSettings['postmod_active']) { |
|
523 | + $vars['warning_moderate'] = 35; |
|
524 | + } |
|
511 | 525 | |
512 | 526 | foreach ($vars as $var => $value) |
513 | 527 | { |
514 | 528 | $config_vars[] = array('int', $var); |
515 | 529 | $_POST[$var] = $value; |
516 | 530 | } |
517 | - } |
|
518 | - else |
|
531 | + } else |
|
519 | 532 | { |
520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
603 | 616 | |
604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
605 | 618 | |
606 | - if ($return_config) |
|
607 | - return $config_vars; |
|
619 | + if ($return_config) { |
|
620 | + return $config_vars; |
|
621 | + } |
|
608 | 622 | |
609 | 623 | // You need to be an admin to edit settings! |
610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
638 | 652 | |
639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
640 | 654 | { |
641 | - if (empty($context['settings_insert_above'])) |
|
642 | - $context['settings_insert_above'] = ''; |
|
655 | + if (empty($context['settings_insert_above'])) { |
|
656 | + $context['settings_insert_above'] = ''; |
|
657 | + } |
|
643 | 658 | |
644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
683 | 698 | |
684 | 699 | // Hack in guest requiring verification! |
685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
686 | - $_POST['posts_require_captcha'] = -1; |
|
700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
701 | + $_POST['posts_require_captcha'] = -1; |
|
702 | + } |
|
687 | 703 | |
688 | 704 | $save_vars = $config_vars; |
689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
701 | 717 | { |
702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
721 | + } |
|
705 | 722 | |
706 | 723 | // Now step through and see if any existing questions no longer exist. |
707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
710 | 727 | $changes['delete'][] = $q_id; |
728 | + } |
|
711 | 729 | |
712 | 730 | // Now let's see if there are new questions or ones that need updating. |
713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
716 | 734 | { |
717 | 735 | // Ignore junky ids. |
718 | 736 | $q_id = (int) $q_id; |
719 | - if ($q_id <= 0) |
|
720 | - continue; |
|
737 | + if ($q_id <= 0) { |
|
738 | + continue; |
|
739 | + } |
|
721 | 740 | |
722 | 741 | // Check the question isn't empty (because they want to delete it?) |
723 | 742 | if (empty($question) || trim($question) == '') |
724 | 743 | { |
725 | - if (isset($context['question_answers'][$q_id])) |
|
726 | - $changes['delete'][] = $q_id; |
|
744 | + if (isset($context['question_answers'][$q_id])) { |
|
745 | + $changes['delete'][] = $q_id; |
|
746 | + } |
|
727 | 747 | continue; |
728 | 748 | } |
729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
731 | 751 | // Get the answers. Firstly check there actually might be some. |
732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
733 | 753 | { |
734 | - if (isset($context['question_answers'][$q_id])) |
|
735 | - $changes['delete'][] = $q_id; |
|
754 | + if (isset($context['question_answers'][$q_id])) { |
|
755 | + $changes['delete'][] = $q_id; |
|
756 | + } |
|
736 | 757 | continue; |
737 | 758 | } |
738 | 759 | // Now get them and check that they might be viable. |
739 | 760 | $answers = array(); |
740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
741 | - if (!empty($answer) && trim($answer) !== '') |
|
761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
762 | + if (!empty($answer) && trim($answer) !== '') |
|
742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
764 | + } |
|
743 | 765 | if (empty($answers)) |
744 | 766 | { |
745 | - if (isset($context['question_answers'][$q_id])) |
|
746 | - $changes['delete'][] = $q_id; |
|
767 | + if (isset($context['question_answers'][$q_id])) { |
|
768 | + $changes['delete'][] = $q_id; |
|
769 | + } |
|
747 | 770 | continue; |
748 | 771 | } |
749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
753 | 776 | { |
754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
756 | - } |
|
757 | - else |
|
779 | + } else |
|
758 | 780 | { |
759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
784 | + } |
|
762 | 785 | } |
763 | 786 | |
764 | - if (!isset($qs_per_lang[$lang_id])) |
|
765 | - $qs_per_lang[$lang_id] = 0; |
|
787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
788 | + $qs_per_lang[$lang_id] = 0; |
|
789 | + } |
|
766 | 790 | $qs_per_lang[$lang_id]++; |
767 | 791 | } |
768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
812 | 836 | |
813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
816 | - $_POST['qa_verification_number'] = $count_questions; |
|
839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
840 | + $_POST['qa_verification_number'] = $count_questions; |
|
841 | + } |
|
817 | 842 | |
818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
828 | 853 | |
829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
830 | 855 | $_SESSION['visual_verification_code'] = ''; |
831 | - for ($i = 0; $i < 6; $i++) |
|
832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
856 | + for ($i = 0; $i < 6; $i++) { |
|
857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
858 | + } |
|
833 | 859 | |
834 | 860 | // Some javascript for CAPTCHA. |
835 | 861 | $context['settings_post_javascript'] = ''; |
836 | - if ($context['use_graphic_library']) |
|
837 | - $context['settings_post_javascript'] .= ' |
|
862 | + if ($context['use_graphic_library']) { |
|
863 | + $context['settings_post_javascript'] .= ' |
|
838 | 864 | function refreshImages() |
839 | 865 | { |
840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
842 | 868 | }'; |
869 | + } |
|
843 | 870 | |
844 | 871 | // Show the image itself, or text saying we can't. |
845 | - if ($context['use_graphic_library']) |
|
846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
847 | - else |
|
848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
872 | + if ($context['use_graphic_library']) { |
|
873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
874 | + } else { |
|
875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + } |
|
849 | 877 | |
850 | 878 | // Hack for PM spam settings. |
851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
856 | 884 | |
857 | 885 | // Some minor javascript for the guest post setting. |
858 | - if ($modSettings['posts_require_captcha']) |
|
859 | - $context['settings_post_javascript'] .= ' |
|
886 | + if ($modSettings['posts_require_captcha']) { |
|
887 | + $context['settings_post_javascript'] .= ' |
|
860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
889 | + } |
|
861 | 890 | |
862 | 891 | // And everything else. |
863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
904 | 933 | |
905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
906 | 935 | |
907 | - if ($return_config) |
|
908 | - return $config_vars; |
|
936 | + if ($return_config) { |
|
937 | + return $config_vars; |
|
938 | + } |
|
909 | 939 | |
910 | 940 | // Setup the template. |
911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
961 | 991 | |
962 | 992 | // Max characters... |
963 | - if (!empty($sig_limits[1])) |
|
964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
993 | + if (!empty($sig_limits[1])) { |
|
994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
995 | + } |
|
965 | 996 | // Max lines... |
966 | 997 | if (!empty($sig_limits[2])) |
967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
971 | 1002 | if ($sig[$i] == "\n") |
972 | 1003 | { |
973 | 1004 | $count++; |
974 | - if ($count >= $sig_limits[2]) |
|
975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1005 | + if ($count >= $sig_limits[2]) { |
|
1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1007 | + } |
|
976 | 1008 | } |
977 | 1009 | } |
978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
983 | 1015 | { |
984 | 1016 | $limit_broke = 0; |
985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
993 | - $limit_broke = 'large'; |
|
994 | - |
|
995 | - if ($limit_broke) |
|
996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1025 | + $limit_broke = 'large'; |
|
1026 | + } |
|
1027 | + |
|
1028 | + if ($limit_broke) { |
|
1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1030 | + } |
|
997 | 1031 | } |
998 | 1032 | } |
999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
1049 | 1083 | $img_offset = false; |
1050 | 1084 | } |
1051 | 1085 | } |
1086 | + } else { |
|
1087 | + $replaces[$image] = ''; |
|
1052 | 1088 | } |
1053 | - else |
|
1054 | - $replaces[$image] = ''; |
|
1055 | 1089 | |
1056 | 1090 | continue; |
1057 | 1091 | } |
1058 | 1092 | |
1059 | 1093 | // Does it have predefined restraints? Width first. |
1060 | - if ($matches[6][$key]) |
|
1061 | - $matches[2][$key] = $matches[6][$key]; |
|
1094 | + if ($matches[6][$key]) { |
|
1095 | + $matches[2][$key] = $matches[6][$key]; |
|
1096 | + } |
|
1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1063 | 1098 | { |
1064 | 1099 | $width = $sig_limits[5]; |
1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1101 | + } elseif ($matches[2][$key]) { |
|
1102 | + $width = $matches[2][$key]; |
|
1066 | 1103 | } |
1067 | - elseif ($matches[2][$key]) |
|
1068 | - $width = $matches[2][$key]; |
|
1069 | 1104 | // ... and height. |
1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1071 | 1106 | { |
1072 | 1107 | $height = $sig_limits[6]; |
1073 | - if ($width != -1) |
|
1074 | - $width = $width * ($height / $matches[4][$key]); |
|
1108 | + if ($width != -1) { |
|
1109 | + $width = $width * ($height / $matches[4][$key]); |
|
1110 | + } |
|
1111 | + } elseif ($matches[4][$key]) { |
|
1112 | + $height = $matches[4][$key]; |
|
1075 | 1113 | } |
1076 | - elseif ($matches[4][$key]) |
|
1077 | - $height = $matches[4][$key]; |
|
1078 | 1114 | |
1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1093 | 1129 | { |
1094 | 1130 | $height = $sig_limits[6]; |
1095 | - if ($width == -1) |
|
1096 | - $width = $sizes[0]; |
|
1131 | + if ($width == -1) { |
|
1132 | + $width = $sizes[0]; |
|
1133 | + } |
|
1097 | 1134 | $width = $width * ($height / $sizes[1]); |
1135 | + } elseif ($width != -1) { |
|
1136 | + $height = $sizes[1]; |
|
1098 | 1137 | } |
1099 | - elseif ($width != -1) |
|
1100 | - $height = $sizes[1]; |
|
1101 | 1138 | } |
1102 | 1139 | } |
1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
1110 | 1147 | // Record that we got one. |
1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1112 | 1149 | } |
1113 | - if (!empty($replaces)) |
|
1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1150 | + if (!empty($replaces)) { |
|
1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1152 | + } |
|
1115 | 1153 | } |
1116 | 1154 | } |
1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
1123 | 1161 | |
1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1126 | - if ($sig != $row['signature']) |
|
1127 | - $changes[$row['id_member']] = $sig; |
|
1164 | + if ($sig != $row['signature']) { |
|
1165 | + $changes[$row['id_member']] = $sig; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1169 | + $done = true; |
|
1128 | 1170 | } |
1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1130 | - $done = true; |
|
1131 | 1171 | $smcFunc['db_free_result']($request); |
1132 | 1172 | |
1133 | 1173 | // Do we need to delete what we have? |
1134 | 1174 | if (!empty($changes)) |
1135 | 1175 | { |
1136 | - foreach ($changes as $id => $sig) |
|
1137 | - $smcFunc['db_query']('', ' |
|
1176 | + foreach ($changes as $id => $sig) { |
|
1177 | + $smcFunc['db_query']('', ' |
|
1138 | 1178 | UPDATE {db_prefix}members |
1139 | 1179 | SET signature = {string:signature} |
1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
1143 | 1183 | 'signature' => $sig, |
1144 | 1184 | ) |
1145 | 1185 | ); |
1186 | + } |
|
1146 | 1187 | } |
1147 | 1188 | |
1148 | 1189 | $_GET['step'] += 50; |
1149 | - if (!$done) |
|
1150 | - pauseSignatureApplySettings(); |
|
1190 | + if (!$done) { |
|
1191 | + pauseSignatureApplySettings(); |
|
1192 | + } |
|
1151 | 1193 | } |
1152 | 1194 | $settings_applied = true; |
1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
1165 | 1207 | ); |
1166 | 1208 | |
1167 | 1209 | // Temporarily make each setting a modSetting! |
1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
1169 | - $modSettings['signature_' . $key] = $value; |
|
1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1211 | + $modSettings['signature_' . $key] = $value; |
|
1212 | + } |
|
1170 | 1213 | |
1171 | 1214 | // Make sure we check the right tags! |
1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
1178 | 1221 | |
1179 | 1222 | // Clean up the tag stuff! |
1180 | 1223 | $bbcTags = array(); |
1181 | - foreach (parse_bbc(false) as $tag) |
|
1182 | - $bbcTags[] = $tag['tag']; |
|
1224 | + foreach (parse_bbc(false) as $tag) { |
|
1225 | + $bbcTags[] = $tag['tag']; |
|
1226 | + } |
|
1183 | 1227 | |
1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + } |
|
1188 | 1233 | |
1189 | 1234 | $sig_limits = array(); |
1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
1191 | 1236 | { |
1192 | - if ($key == 'allow_smileys') |
|
1193 | - continue; |
|
1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1195 | - $sig_limits[] = -1; |
|
1196 | - else |
|
1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1237 | + if ($key == 'allow_smileys') { |
|
1238 | + continue; |
|
1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1240 | + $sig_limits[] = -1; |
|
1241 | + } else { |
|
1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1243 | + } |
|
1198 | 1244 | } |
1199 | 1245 | |
1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
1227 | 1273 | |
1228 | 1274 | // Try get more time... |
1229 | 1275 | @set_time_limit(600); |
1230 | - if (function_exists('apache_reset_timeout')) |
|
1231 | - @apache_reset_timeout(); |
|
1276 | + if (function_exists('apache_reset_timeout')) { |
|
1277 | + @apache_reset_timeout(); |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | // Have we exhausted all the time we allowed? |
1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1235 | - return; |
|
1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1282 | + return; |
|
1283 | + } |
|
1236 | 1284 | |
1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
1278 | 1326 | $disable_fields = array_flip($standard_fields); |
1279 | 1327 | if (!empty($_POST['active'])) |
1280 | 1328 | { |
1281 | - foreach ($_POST['active'] as $value) |
|
1282 | - if (isset($disable_fields[$value])) |
|
1329 | + foreach ($_POST['active'] as $value) { |
|
1330 | + if (isset($disable_fields[$value])) |
|
1283 | 1331 | unset($disable_fields[$value]); |
1332 | + } |
|
1284 | 1333 | } |
1285 | 1334 | // What we have left! |
1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
1289 | 1338 | $reg_fields = array(); |
1290 | 1339 | if (!empty($_POST['reg'])) |
1291 | 1340 | { |
1292 | - foreach ($_POST['reg'] as $value) |
|
1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1341 | + foreach ($_POST['reg'] as $value) { |
|
1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1294 | 1343 | $reg_fields[] = $value; |
1344 | + } |
|
1295 | 1345 | } |
1296 | 1346 | // What we have left! |
1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1298 | 1348 | |
1299 | 1349 | $_SESSION['adm-save'] = true; |
1300 | - if (!empty($changes)) |
|
1301 | - updateSettings($changes); |
|
1350 | + if (!empty($changes)) { |
|
1351 | + updateSettings($changes); |
|
1352 | + } |
|
1302 | 1353 | } |
1303 | 1354 | |
1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
1401 | 1452 | { |
1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
1403 | 1454 | |
1404 | - if ($rowData['field_order'] > 1) |
|
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1455 | + if ($rowData['field_order'] > 1) { |
|
1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1457 | + } |
|
1406 | 1458 | |
1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | 1463 | $return .= '</p>'; |
1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1545 | 1598 | |
1546 | - foreach ($standard_fields as $field) |
|
1547 | - $list[] = array( |
|
1599 | + foreach ($standard_fields as $field) { |
|
1600 | + $list[] = array( |
|
1548 | 1601 | 'id' => $field, |
1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1553 | 1606 | ); |
1554 | - } |
|
1555 | - else |
|
1607 | + } |
|
1608 | + } else |
|
1556 | 1609 | { |
1557 | 1610 | // Load all the fields. |
1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
1566 | 1619 | 'items_per_page' => $items_per_page, |
1567 | 1620 | ) |
1568 | 1621 | ); |
1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1570 | - $list[] = $row; |
|
1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1623 | + $list[] = $row; |
|
1624 | + } |
|
1571 | 1625 | $smcFunc['db_free_result']($request); |
1572 | 1626 | } |
1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
1633 | 1687 | $context['field'] = array(); |
1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1635 | 1689 | { |
1636 | - if ($row['field_type'] == 'textarea') |
|
1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1638 | - else |
|
1690 | + if ($row['field_type'] == 'textarea') { |
|
1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1692 | + } else |
|
1639 | 1693 | { |
1640 | 1694 | $rows = 3; |
1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
1671 | 1725 | } |
1672 | 1726 | |
1673 | 1727 | // Setup the default values as needed. |
1674 | - if (empty($context['field'])) |
|
1675 | - $context['field'] = array( |
|
1728 | + if (empty($context['field'])) { |
|
1729 | + $context['field'] = array( |
|
1676 | 1730 | 'name' => '', |
1677 | 1731 | 'col_name' => '???', |
1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
1697 | 1751 | 'enclose' => '', |
1698 | 1752 | 'placement' => 0, |
1699 | 1753 | ); |
1754 | + } |
|
1700 | 1755 | |
1701 | 1756 | // Are we moving it? |
1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1706 | 1761 | |
1707 | 1762 | // Is this a valid position? |
1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1765 | + } |
|
1766 | + // @todo implement an error handler |
|
1710 | 1767 | |
1711 | 1768 | // All good, proceed. |
1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
1737 | 1794 | validateToken('admin-ecp'); |
1738 | 1795 | |
1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
1740 | - if (trim($_POST['field_name']) == '') |
|
1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1797 | + if (trim($_POST['field_name']) == '') { |
|
1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1799 | + } |
|
1742 | 1800 | |
1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1804 | + } |
|
1746 | 1805 | |
1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
1759 | 1818 | |
1760 | 1819 | // Some masking stuff... |
1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1763 | - $mask .= $_POST['regex']; |
|
1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1822 | + $mask .= $_POST['regex']; |
|
1823 | + } |
|
1764 | 1824 | |
1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
1779 | 1839 | $v = strtr($v, array(',' => '')); |
1780 | 1840 | |
1781 | 1841 | // Nada, zip, etc... |
1782 | - if (trim($v) == '') |
|
1783 | - continue; |
|
1842 | + if (trim($v) == '') { |
|
1843 | + continue; |
|
1844 | + } |
|
1784 | 1845 | |
1785 | 1846 | // Otherwise, save it boy. |
1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
1788 | 1849 | $newOptions[$k] = $v; |
1789 | 1850 | |
1790 | 1851 | // Is it default? |
1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1792 | - $default = $v; |
|
1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1853 | + $default = $v; |
|
1854 | + } |
|
1793 | 1855 | } |
1794 | 1856 | $field_options = substr($field_options, 0, -1); |
1795 | 1857 | } |
1796 | 1858 | |
1797 | 1859 | // Text area has default has dimensions |
1798 | - if ($_POST['field_type'] == 'textarea') |
|
1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1860 | + if ($_POST['field_type'] == 'textarea') { |
|
1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1862 | + } |
|
1800 | 1863 | |
1801 | 1864 | // Come up with the unique name? |
1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1806 | 1869 | |
1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1808 | - if (isset($matches[1])) |
|
1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1810 | - else |
|
1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1871 | + if (isset($matches[1])) { |
|
1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1873 | + } else { |
|
1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + } |
|
1812 | 1876 | |
1813 | 1877 | // Make sure this is unique. |
1814 | 1878 | $current_fields = array(); |
1815 | 1879 | $request = $smcFunc['db_query']('', ' |
1816 | 1880 | SELECT id_field, col_name |
1817 | 1881 | FROM {db_prefix}custom_fields'); |
1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1884 | + } |
|
1820 | 1885 | $smcFunc['db_free_result']($request); |
1821 | 1886 | |
1822 | 1887 | $unique = false; |
1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
1824 | 1889 | { |
1825 | - if (!in_array($col_name, $current_fields)) |
|
1826 | - $unique = true; |
|
1827 | - else |
|
1828 | - $col_name = $initial_col_name . $i; |
|
1890 | + if (!in_array($col_name, $current_fields)) { |
|
1891 | + $unique = true; |
|
1892 | + } else { |
|
1893 | + $col_name = $initial_col_name . $i; |
|
1894 | + } |
|
1829 | 1895 | } |
1830 | 1896 | |
1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
1832 | - if (!$unique) |
|
1833 | - fatal_lang_error('custom_option_not_unique'); |
|
1898 | + if (!$unique) { |
|
1899 | + fatal_lang_error('custom_option_not_unique'); |
|
1900 | + } |
|
1834 | 1901 | } |
1835 | 1902 | // Work out what to do with the user data otherwise... |
1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
1858 | 1925 | // Work out what's changed! |
1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
1860 | 1927 | { |
1861 | - if (trim($option) == '') |
|
1862 | - continue; |
|
1928 | + if (trim($option) == '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1863 | 1931 | |
1864 | 1932 | // Still exists? |
1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
1873 | 1941 | foreach ($optionChanges as $k => $option) |
1874 | 1942 | { |
1875 | 1943 | // Just been renamed? |
1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1877 | - $smcFunc['db_query']('', ' |
|
1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1945 | + $smcFunc['db_query']('', ' |
|
1878 | 1946 | UPDATE {db_prefix}themes |
1879 | 1947 | SET value = {string:new_value} |
1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
1887 | 1955 | 'old_value' => $option, |
1888 | 1956 | ) |
1889 | 1957 | ); |
1958 | + } |
|
1890 | 1959 | } |
1891 | 1960 | } |
1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
1929 | 1998 | ); |
1930 | 1999 | |
1931 | 2000 | // Just clean up any old selects - these are a pain! |
1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1933 | - $smcFunc['db_query']('', ' |
|
2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2002 | + $smcFunc['db_query']('', ' |
|
1934 | 2003 | DELETE FROM {db_prefix}themes |
1935 | 2004 | WHERE variable = {string:current_column} |
1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
1941 | 2010 | 'current_column' => $context['field']['col_name'], |
1942 | 2011 | ) |
1943 | 2012 | ); |
1944 | - } |
|
1945 | - else |
|
2013 | + } |
|
2014 | + } else |
|
1946 | 2015 | { |
1947 | 2016 | // Gotta figure it out the order. |
1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2117 | 2186 | |
2118 | 2187 | $prune_toggle_dt = array(); |
2119 | - foreach ($prune_toggle as $item) |
|
2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2188 | + foreach ($prune_toggle as $item) { |
|
2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2190 | + } |
|
2121 | 2191 | |
2122 | - if ($return_config) |
|
2123 | - return $config_vars; |
|
2192 | + if ($return_config) { |
|
2193 | + return $config_vars; |
|
2194 | + } |
|
2124 | 2195 | |
2125 | 2196 | addInlineJavaScript(' |
2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
2158 | 2229 | $vals = array(); |
2159 | 2230 | foreach ($config_vars as $index => $dummy) |
2160 | 2231 | { |
2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2162 | - continue; |
|
2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2233 | + continue; |
|
2234 | + } |
|
2163 | 2235 | |
2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2165 | 2237 | } |
2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
2239 | + } else { |
|
2240 | + $_POST['pruningOptions'] = ''; |
|
2167 | 2241 | } |
2168 | - else |
|
2169 | - $_POST['pruningOptions'] = ''; |
|
2170 | 2242 | |
2171 | 2243 | saveDBSettings($savevar); |
2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
2178 | 2250 | $context['sub_template'] = 'show_settings'; |
2179 | 2251 | |
2180 | 2252 | // Get the actual values |
2181 | - if (!empty($modSettings['pruningOptions'])) |
|
2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2183 | - else |
|
2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2255 | + } else { |
|
2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2257 | + } |
|
2185 | 2258 | |
2186 | 2259 | prepareDBSettingContext($config_vars); |
2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
2203 | 2276 | // Make it even easier to add new settings. |
2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2205 | 2278 | |
2206 | - if ($return_config) |
|
2207 | - return $config_vars; |
|
2279 | + if ($return_config) { |
|
2280 | + return $config_vars; |
|
2281 | + } |
|
2208 | 2282 | |
2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $query_where = array(); |
167 | 167 | $query_params = $search_data['params']; |
168 | 168 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
169 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
170 | 170 | $modSettings['search_simple_fulltext'] = true; |
171 | 171 | |
172 | 172 | if ($query_params['id_search']) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | if (!empty($modSettings['search_simple_fulltext'])) |
211 | 211 | { |
212 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
212 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
213 | 213 | { |
214 | 214 | $language_ftx = $smcFunc['db_search_language'](); |
215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // remove any indexed words that are used in the complex body search terms |
228 | 228 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
229 | 229 | |
230 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
230 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
231 | 231 | $row = 0; |
232 | 232 | foreach ($words['indexed_words'] as $fulltextWord) { |
233 | 233 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | // if we have bool terms to search, add them in |
245 | 245 | if ($query_params['boolean_match']) { |
246 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
246 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
247 | 247 | { |
248 | 248 | $language_ftx = $smcFunc['db_search_language'](); |
249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
259 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
260 | 260 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
261 | 261 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
262 | 262 | SELECT ' . implode(', ', $query_select) . ' |
@@ -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('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | $smcFunc['db_free_result']($request); |
99 | 100 | } |
100 | 101 | // 4 is the MySQL default... |
101 | - else |
|
102 | - $min_word_length = 4; |
|
102 | + else { |
|
103 | + $min_word_length = 4; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | return $min_word_length; |
105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
140 | 142 | } |
141 | - } |
|
142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | 144 | { |
144 | 145 | // short words have feelings too |
145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | |
150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
152 | - if ($isExcluded) |
|
153 | - $wordsExclude[] = $fulltextWord; |
|
153 | + if ($isExcluded) { |
|
154 | + $wordsExclude[] = $fulltextWord; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | |
156 | 158 | /** |
@@ -166,44 +168,54 @@ discard block |
||
166 | 168 | $query_where = array(); |
167 | 169 | $query_params = $search_data['params']; |
168 | 170 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
170 | - $modSettings['search_simple_fulltext'] = true; |
|
171 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
172 | + $modSettings['search_simple_fulltext'] = true; |
|
173 | + } |
|
171 | 174 | |
172 | - if ($query_params['id_search']) |
|
173 | - $query_select['id_search'] = '{int:id_search}'; |
|
175 | + if ($query_params['id_search']) { |
|
176 | + $query_select['id_search'] = '{int:id_search}'; |
|
177 | + } |
|
174 | 178 | |
175 | 179 | $count = 0; |
176 | - if (empty($modSettings['search_simple_fulltext'])) |
|
177 | - foreach ($words['words'] as $regularWord) |
|
180 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
181 | + foreach ($words['words'] as $regularWord) |
|
178 | 182 | { |
179 | 183 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
184 | + } |
|
180 | 185 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
181 | 186 | } |
182 | 187 | |
183 | - if ($query_params['user_query']) |
|
184 | - $query_where[] = '{raw:user_query}'; |
|
185 | - if ($query_params['board_query']) |
|
186 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
188 | + if ($query_params['user_query']) { |
|
189 | + $query_where[] = '{raw:user_query}'; |
|
190 | + } |
|
191 | + if ($query_params['board_query']) { |
|
192 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
193 | + } |
|
187 | 194 | |
188 | - if ($query_params['topic']) |
|
189 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
190 | - if ($query_params['min_msg_id']) |
|
191 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
192 | - if ($query_params['max_msg_id']) |
|
193 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
195 | + if ($query_params['topic']) { |
|
196 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
197 | + } |
|
198 | + if ($query_params['min_msg_id']) { |
|
199 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
200 | + } |
|
201 | + if ($query_params['max_msg_id']) { |
|
202 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | $count = 0; |
196 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
197 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
206 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
207 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
198 | 208 | { |
199 | 209 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
210 | + } |
|
200 | 211 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
201 | 212 | } |
202 | 213 | $count = 0; |
203 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
204 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
214 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
215 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
205 | 216 | { |
206 | 217 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
218 | + } |
|
207 | 219 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
208 | 220 | } |
209 | 221 | |
@@ -215,12 +227,11 @@ discard block |
||
215 | 227 | |
216 | 228 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})'; |
217 | 229 | $query_params['language_ftx'] = $language_ftx; |
230 | + } else { |
|
231 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
218 | 232 | } |
219 | - else |
|
220 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
221 | 233 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
222 | - } |
|
223 | - else |
|
234 | + } else |
|
224 | 235 | { |
225 | 236 | $query_params['boolean_match'] = ''; |
226 | 237 | |
@@ -234,10 +245,10 @@ discard block |
||
234 | 245 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
235 | 246 | $row++; |
236 | 247 | } |
237 | - } |
|
238 | - else |
|
239 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
248 | + } else { |
|
249 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
240 | 250 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
251 | + } |
|
241 | 252 | |
242 | 253 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
243 | 254 | |
@@ -249,9 +260,9 @@ discard block |
||
249 | 260 | |
250 | 261 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})'; |
251 | 262 | $query_params['language_ftx'] = $language_ftx; |
263 | + } else { |
|
264 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
252 | 265 | } |
253 | - else |
|
254 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
255 | 266 | } |
256 | 267 | |
257 | 268 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
257 | 257 | |
258 | 258 | $js_time_string = str_replace( |
259 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
259 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
261 | 261 | $time_string |
262 | 262 | ); |
263 | 263 | |
@@ -1305,14 +1305,14 @@ discard block |
||
1305 | 1305 | if (isset($context['name']) && isset($context['email'])) |
1306 | 1306 | { |
1307 | 1307 | $context['posting_fields']['guestname'] = array( |
1308 | - 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1308 | + 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1309 | 1309 | 'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" required>', |
1310 | 1310 | ); |
1311 | 1311 | |
1312 | 1312 | if (empty($modSettings['guest_post_no_email'])) |
1313 | 1313 | { |
1314 | 1314 | $context['posting_fields']['email'] = array( |
1315 | - 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1315 | + 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1316 | 1316 | 'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" required>', |
1317 | 1317 | ); |
1318 | 1318 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
55 | 58 | |
56 | 59 | // You must be posting to *some* board. |
57 | - if (empty($board) && !$context['make_event']) |
|
58 | - fatal_lang_error('no_board', false); |
|
60 | + if (empty($board) && !$context['make_event']) { |
|
61 | + fatal_lang_error('no_board', false); |
|
62 | + } |
|
59 | 63 | |
60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
61 | 65 | |
@@ -78,10 +82,11 @@ discard block |
||
78 | 82 | array( |
79 | 83 | 'msg' => (int) $_REQUEST['msg'], |
80 | 84 | )); |
81 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
82 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
83 | - else |
|
84 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
85 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
86 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
87 | + } else { |
|
88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
89 | + } |
|
85 | 90 | $smcFunc['db_free_result']($request); |
86 | 91 | } |
87 | 92 | |
@@ -108,33 +113,36 @@ discard block |
||
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | 115 | // If this topic already has a poll, they sure can't add another. |
111 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
112 | - unset($_REQUEST['poll']); |
|
116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
117 | + unset($_REQUEST['poll']); |
|
118 | + } |
|
113 | 119 | |
114 | 120 | if (empty($_REQUEST['msg'])) |
115 | 121 | { |
116 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
117 | - is_not_guest(); |
|
122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
123 | + is_not_guest(); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | // By default the reply will be approved... |
120 | 127 | $context['becomes_approved'] = true; |
121 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
122 | 129 | { |
123 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
124 | - $context['becomes_approved'] = false; |
|
125 | - else |
|
126 | - isAllowedTo('post_reply_any'); |
|
127 | - } |
|
128 | - elseif (!allowedTo('post_reply_any')) |
|
130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
131 | + $context['becomes_approved'] = false; |
|
132 | + } else { |
|
133 | + isAllowedTo('post_reply_any'); |
|
134 | + } |
|
135 | + } elseif (!allowedTo('post_reply_any')) |
|
129 | 136 | { |
130 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
131 | - $context['becomes_approved'] = false; |
|
132 | - else |
|
133 | - isAllowedTo('post_reply_own'); |
|
137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
138 | + $context['becomes_approved'] = false; |
|
139 | + } else { |
|
140 | + isAllowedTo('post_reply_own'); |
|
141 | + } |
|
134 | 142 | } |
143 | + } else { |
|
144 | + $context['becomes_approved'] = true; |
|
135 | 145 | } |
136 | - else |
|
137 | - $context['becomes_approved'] = true; |
|
138 | 146 | |
139 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
140 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -146,18 +154,19 @@ discard block |
||
146 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
147 | 155 | |
148 | 156 | // Check whether this is a really old post being bumped... |
149 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
150 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
151 | - } |
|
152 | - else |
|
157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
159 | + } |
|
160 | + } else |
|
153 | 161 | { |
154 | 162 | $context['becomes_approved'] = true; |
155 | 163 | if ((!$context['make_event'] || !empty($board))) |
156 | 164 | { |
157 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
158 | - $context['becomes_approved'] = false; |
|
159 | - else |
|
160 | - isAllowedTo('post_new'); |
|
165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
166 | + $context['becomes_approved'] = false; |
|
167 | + } else { |
|
168 | + isAllowedTo('post_new'); |
|
169 | + } |
|
161 | 170 | } |
162 | 171 | |
163 | 172 | $locked = 0; |
@@ -193,20 +202,24 @@ discard block |
||
193 | 202 | } |
194 | 203 | |
195 | 204 | // Don't allow a post if it's locked and you aren't all powerful. |
196 | - if ($locked && !allowedTo('moderate_board')) |
|
197 | - fatal_lang_error('topic_locked', false); |
|
205 | + if ($locked && !allowedTo('moderate_board')) { |
|
206 | + fatal_lang_error('topic_locked', false); |
|
207 | + } |
|
198 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
199 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
200 | 210 | { |
201 | 211 | // New topic, new poll. |
202 | - if (empty($topic)) |
|
203 | - isAllowedTo('poll_post'); |
|
212 | + if (empty($topic)) { |
|
213 | + isAllowedTo('poll_post'); |
|
214 | + } |
|
204 | 215 | // This is an old topic - but it is yours! Can you add to it? |
205 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
206 | - isAllowedTo('poll_add_own'); |
|
216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
217 | + isAllowedTo('poll_add_own'); |
|
218 | + } |
|
207 | 219 | // If you're not the owner, can you add to any poll? |
208 | - else |
|
209 | - isAllowedTo('poll_add_any'); |
|
220 | + else { |
|
221 | + isAllowedTo('poll_add_any'); |
|
222 | + } |
|
210 | 223 | |
211 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
212 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -235,8 +248,9 @@ discard block |
||
235 | 248 | if ($context['make_event']) |
236 | 249 | { |
237 | 250 | // They might want to pick a board. |
238 | - if (!isset($context['current_board'])) |
|
239 | - $context['current_board'] = 0; |
|
251 | + if (!isset($context['current_board'])) { |
|
252 | + $context['current_board'] = 0; |
|
253 | + } |
|
240 | 254 | |
241 | 255 | // Start loading up the event info. |
242 | 256 | $context['event'] = array(); |
@@ -250,10 +264,11 @@ discard block |
||
250 | 264 | isAllowedTo('calendar_post'); |
251 | 265 | |
252 | 266 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
253 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
254 | - $time_string = '%k:%M'; |
|
255 | - else |
|
256 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
268 | + $time_string = '%k:%M'; |
|
269 | + } else { |
|
270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
271 | + } |
|
257 | 272 | |
258 | 273 | $js_time_string = str_replace( |
259 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -275,8 +290,7 @@ discard block |
||
275 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
276 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
277 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
278 | - } |
|
279 | - else |
|
293 | + } else |
|
280 | 294 | { |
281 | 295 | // Get the current event information. |
282 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -284,15 +298,18 @@ discard block |
||
284 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
285 | 299 | |
286 | 300 | // Make sure the year and month are in the valid range. |
287 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
288 | - fatal_lang_error('invalid_month', false); |
|
289 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
290 | - fatal_lang_error('invalid_year', false); |
|
301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
302 | + fatal_lang_error('invalid_month', false); |
|
303 | + } |
|
304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
305 | + fatal_lang_error('invalid_year', false); |
|
306 | + } |
|
291 | 307 | |
292 | 308 | // Get a list of boards they can post in. |
293 | 309 | $boards = boardsAllowedTo('post_new'); |
294 | - if (empty($boards)) |
|
295 | - fatal_lang_error('cannot_post_new', 'user'); |
|
310 | + if (empty($boards)) { |
|
311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
312 | + } |
|
296 | 313 | |
297 | 314 | // Load a list of boards for this event in the context. |
298 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -411,10 +428,11 @@ discard block |
||
411 | 428 | |
412 | 429 | if (!empty($context['new_replies'])) |
413 | 430 | { |
414 | - if ($context['new_replies'] == 1) |
|
415 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
416 | - else |
|
417 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
431 | + if ($context['new_replies'] == 1) { |
|
432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
433 | + } else { |
|
434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | $post_errors[] = 'new_replies'; |
420 | 438 | |
@@ -426,9 +444,9 @@ discard block |
||
426 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
427 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
428 | 446 | { |
429 | - if ($language === $user_info['language']) |
|
430 | - $context['response_prefix'] = $txt['response_prefix']; |
|
431 | - else |
|
447 | + if ($language === $user_info['language']) { |
|
448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
449 | + } else |
|
432 | 450 | { |
433 | 451 | loadLanguage('index', $language, false); |
434 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -441,8 +459,9 @@ discard block |
||
441 | 459 | // Do we have a body, but an error happened. |
442 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
443 | 461 | { |
444 | - if (isset($_REQUEST['quickReply'])) |
|
445 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
462 | + if (isset($_REQUEST['quickReply'])) { |
|
463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
464 | + } |
|
446 | 465 | |
447 | 466 | // Validate inputs. |
448 | 467 | if (empty($context['post_error'])) |
@@ -450,15 +469,17 @@ discard block |
||
450 | 469 | // This means they didn't click Post and get an error. |
451 | 470 | $really_previewing = true; |
452 | 471 | |
453 | - } |
|
454 | - else |
|
472 | + } else |
|
455 | 473 | { |
456 | - if (!isset($_REQUEST['subject'])) |
|
457 | - $_REQUEST['subject'] = ''; |
|
458 | - if (!isset($_REQUEST['message'])) |
|
459 | - $_REQUEST['message'] = ''; |
|
460 | - if (!isset($_REQUEST['icon'])) |
|
461 | - $_REQUEST['icon'] = 'xx'; |
|
474 | + if (!isset($_REQUEST['subject'])) { |
|
475 | + $_REQUEST['subject'] = ''; |
|
476 | + } |
|
477 | + if (!isset($_REQUEST['message'])) { |
|
478 | + $_REQUEST['message'] = ''; |
|
479 | + } |
|
480 | + if (!isset($_REQUEST['icon'])) { |
|
481 | + $_REQUEST['icon'] = 'xx'; |
|
482 | + } |
|
462 | 483 | |
463 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
464 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -474,8 +495,9 @@ discard block |
||
474 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
475 | 496 | |
476 | 497 | // Make sure the subject isn't too long - taking into account special characters. |
477 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
478 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
500 | + } |
|
479 | 501 | |
480 | 502 | if (isset($_REQUEST['poll'])) |
481 | 503 | { |
@@ -487,8 +509,9 @@ discard block |
||
487 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
488 | 510 | foreach ($_POST['options'] as $option) |
489 | 511 | { |
490 | - if (trim($option) == '') |
|
491 | - continue; |
|
512 | + if (trim($option) == '') { |
|
513 | + continue; |
|
514 | + } |
|
492 | 515 | |
493 | 516 | $context['choices'][] = array( |
494 | 517 | 'id' => $choice_id++, |
@@ -550,13 +573,14 @@ discard block |
||
550 | 573 | $context['preview_subject'] = $form_subject; |
551 | 574 | |
552 | 575 | censorText($context['preview_subject']); |
576 | + } else { |
|
577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
553 | 578 | } |
554 | - else |
|
555 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
556 | 579 | |
557 | 580 | // Protect any CDATA blocks. |
558 | - if (isset($_REQUEST['xml'])) |
|
559 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
581 | + if (isset($_REQUEST['xml'])) { |
|
582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
599 | - fatal_lang_error('no_board', false); |
|
622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
623 | + fatal_lang_error('no_board', false); |
|
624 | + } |
|
600 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
601 | 626 | |
602 | 627 | $attachment_stuff = array($row); |
603 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
604 | - $attachment_stuff[] = $row2; |
|
628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
629 | + $attachment_stuff[] = $row2; |
|
630 | + } |
|
605 | 631 | $smcFunc['db_free_result']($request); |
606 | 632 | |
607 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
608 | 634 | { |
609 | 635 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
610 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
611 | - fatal_lang_error('modify_post_time_passed', false); |
|
612 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
613 | - isAllowedTo('modify_replies'); |
|
614 | - else |
|
615 | - isAllowedTo('modify_own'); |
|
636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
637 | + fatal_lang_error('modify_post_time_passed', false); |
|
638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
639 | + isAllowedTo('modify_replies'); |
|
640 | + } else { |
|
641 | + isAllowedTo('modify_own'); |
|
642 | + } |
|
643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
644 | + isAllowedTo('modify_replies'); |
|
645 | + } else { |
|
646 | + isAllowedTo('modify_any'); |
|
616 | 647 | } |
617 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
618 | - isAllowedTo('modify_replies'); |
|
619 | - else |
|
620 | - isAllowedTo('modify_any'); |
|
621 | 648 | |
622 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
623 | 650 | { |
@@ -641,8 +668,9 @@ discard block |
||
641 | 668 | |
642 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
643 | 670 | { |
644 | - if ($row['filesize'] <= 0) |
|
645 | - continue; |
|
671 | + if ($row['filesize'] <= 0) { |
|
672 | + continue; |
|
673 | + } |
|
646 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
647 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
648 | 676 | 'size' => $row['filesize'], |
@@ -712,29 +740,32 @@ discard block |
||
712 | 740 | ) |
713 | 741 | ); |
714 | 742 | // The message they were trying to edit was most likely deleted. |
715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
716 | - fatal_lang_error('no_message', false); |
|
743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
744 | + fatal_lang_error('no_message', false); |
|
745 | + } |
|
717 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
718 | 747 | |
719 | 748 | $attachment_stuff = array($row); |
720 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
721 | - $attachment_stuff[] = $row2; |
|
749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
750 | + $attachment_stuff[] = $row2; |
|
751 | + } |
|
722 | 752 | $smcFunc['db_free_result']($request); |
723 | 753 | |
724 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
725 | 755 | { |
726 | 756 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
727 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
728 | - fatal_lang_error('modify_post_time_passed', false); |
|
729 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
730 | - isAllowedTo('modify_replies'); |
|
731 | - else |
|
732 | - isAllowedTo('modify_own'); |
|
757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
758 | + fatal_lang_error('modify_post_time_passed', false); |
|
759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
760 | + isAllowedTo('modify_replies'); |
|
761 | + } else { |
|
762 | + isAllowedTo('modify_own'); |
|
763 | + } |
|
764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
765 | + isAllowedTo('modify_replies'); |
|
766 | + } else { |
|
767 | + isAllowedTo('modify_any'); |
|
733 | 768 | } |
734 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
735 | - isAllowedTo('modify_replies'); |
|
736 | - else |
|
737 | - isAllowedTo('modify_any'); |
|
738 | 769 | |
739 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
740 | 771 | { |
@@ -761,15 +792,17 @@ discard block |
||
761 | 792 | $context['icon'] = $row['icon']; |
762 | 793 | |
763 | 794 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
764 | - if (!$row['approved'] && !$context['show_approval']) |
|
765 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
797 | + } |
|
766 | 798 | |
767 | 799 | // Sort the attachments so they are in the order saved |
768 | 800 | $temp = array(); |
769 | 801 | foreach ($attachment_stuff as $attachment) |
770 | 802 | { |
771 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
772 | - $temp[$attachment['id_attach']] = $attachment; |
|
803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
804 | + $temp[$attachment['id_attach']] = $attachment; |
|
805 | + } |
|
773 | 806 | |
774 | 807 | } |
775 | 808 | ksort($temp); |
@@ -831,14 +864,16 @@ discard block |
||
831 | 864 | 'is_approved' => 1, |
832 | 865 | ) |
833 | 866 | ); |
834 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
835 | - fatal_lang_error('quoted_post_deleted', false); |
|
867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
868 | + fatal_lang_error('quoted_post_deleted', false); |
|
869 | + } |
|
836 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
837 | 871 | $smcFunc['db_free_result']($request); |
838 | 872 | |
839 | 873 | // Add 'Re: ' to the front of the quoted subject. |
840 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
841 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
876 | + } |
|
842 | 877 | |
843 | 878 | // Censor the message and subject. |
844 | 879 | censorText($form_message); |
@@ -851,10 +886,11 @@ discard block |
||
851 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
852 | 887 | { |
853 | 888 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
854 | - if ($i % 4 == 0) |
|
855 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
889 | + if ($i % 4 == 0) { |
|
890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
856 | 891 | { |
857 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
893 | + } |
|
858 | 894 | }, $parts[$i]); |
859 | 895 | } |
860 | 896 | $form_message = implode('', $parts); |
@@ -863,8 +899,9 @@ discard block |
||
863 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
864 | 900 | |
865 | 901 | // Remove any nested quotes, if necessary. |
866 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
867 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
904 | + } |
|
868 | 905 | |
869 | 906 | // Add a quote string on the front and end. |
870 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -876,15 +913,15 @@ discard block |
||
876 | 913 | $form_subject = $first_subject; |
877 | 914 | |
878 | 915 | // Add 'Re: ' to the front of the subject. |
879 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
880 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
918 | + } |
|
881 | 919 | |
882 | 920 | // Censor the subject. |
883 | 921 | censorText($form_subject); |
884 | 922 | |
885 | 923 | $form_message = ''; |
886 | - } |
|
887 | - else |
|
924 | + } else |
|
888 | 925 | { |
889 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
890 | 927 | $form_message = ''; |
@@ -902,13 +939,15 @@ discard block |
||
902 | 939 | if (isset($_REQUEST['msg'])) |
903 | 940 | { |
904 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
905 | - foreach ($context['current_attachments'] as $attachment) |
|
906 | - $context['attachments']['total_size'] += $attachment['size']; |
|
942 | + foreach ($context['current_attachments'] as $attachment) { |
|
943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
944 | + } |
|
907 | 945 | } |
908 | 946 | |
909 | 947 | // A bit of house keeping first. |
910 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
911 | - unset($_SESSION['temp_attachments']); |
|
948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
949 | + unset($_SESSION['temp_attachments']); |
|
950 | + } |
|
912 | 951 | |
913 | 952 | if (!empty($_SESSION['temp_attachments'])) |
914 | 953 | { |
@@ -917,9 +956,10 @@ discard block |
||
917 | 956 | { |
918 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
919 | 958 | { |
920 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
921 | - if (file_exists($attachment['tmp_name'])) |
|
959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
960 | + if (file_exists($attachment['tmp_name'])) |
|
922 | 961 | unlink($attachment['tmp_name']); |
962 | + } |
|
923 | 963 | } |
924 | 964 | $post_errors[] = 'temp_attachments_gone'; |
925 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -933,8 +973,9 @@ discard block |
||
933 | 973 | // See if any files still exist before showing the warning message and the files attached. |
934 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
935 | 975 | { |
936 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
937 | - continue; |
|
976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
977 | + continue; |
|
978 | + } |
|
938 | 979 | |
939 | 980 | if (file_exists($attachment['tmp_name'])) |
940 | 981 | { |
@@ -944,20 +985,21 @@ discard block |
||
944 | 985 | break; |
945 | 986 | } |
946 | 987 | } |
947 | - } |
|
948 | - else |
|
988 | + } else |
|
949 | 989 | { |
950 | 990 | // Since, they don't belong here. Let's inform the user that they exist.. |
951 | - if (!empty($topic)) |
|
952 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
953 | - else |
|
954 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
991 | + if (!empty($topic)) { |
|
992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
993 | + } else { |
|
994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
995 | + } |
|
955 | 996 | |
956 | 997 | // Compile a list of the files to show the user. |
957 | 998 | $file_list = array(); |
958 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
959 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
960 | 1001 | $file_list[] = $attachment['name']; |
1002 | + } |
|
961 | 1003 | |
962 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
963 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -969,8 +1011,7 @@ discard block |
||
969 | 1011 | |
970 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
971 | 1013 | $context['ignore_temp_attachments'] = true; |
972 | - } |
|
973 | - else |
|
1014 | + } else |
|
974 | 1015 | { |
975 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
976 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -978,16 +1019,19 @@ discard block |
||
978 | 1019 | } |
979 | 1020 | } |
980 | 1021 | |
981 | - if (!empty($context['we_are_history'])) |
|
982 | - $post_errors[] = $context['we_are_history']; |
|
1022 | + if (!empty($context['we_are_history'])) { |
|
1023 | + $post_errors[] = $context['we_are_history']; |
|
1024 | + } |
|
983 | 1025 | |
984 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
985 | 1027 | { |
986 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
987 | - break; |
|
1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1029 | + break; |
|
1030 | + } |
|
988 | 1031 | |
989 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
990 | - continue; |
|
1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1033 | + continue; |
|
1034 | + } |
|
991 | 1035 | |
992 | 1036 | if ($attachID == 'initial_error') |
993 | 1037 | { |
@@ -1002,15 +1046,17 @@ discard block |
||
1002 | 1046 | { |
1003 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1004 | 1048 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1005 | - foreach ($attachment['errors'] as $error) |
|
1006 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1049 | + foreach ($attachment['errors'] as $error) { |
|
1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1051 | + } |
|
1007 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
1008 | 1053 | $post_errors[] = 'attach_errors'; |
1009 | 1054 | |
1010 | 1055 | // Take out the trash. |
1011 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
1012 | - if (file_exists($attachment['tmp_name'])) |
|
1013 | - unlink($attachment['tmp_name']); |
|
1057 | + if (file_exists($attachment['tmp_name'])) { |
|
1058 | + unlink($attachment['tmp_name']); |
|
1059 | + } |
|
1014 | 1060 | continue; |
1015 | 1061 | } |
1016 | 1062 | |
@@ -1023,8 +1069,9 @@ discard block |
||
1023 | 1069 | |
1024 | 1070 | $context['attachments']['quantity']++; |
1025 | 1071 | $context['attachments']['total_size'] += $attachment['size']; |
1026 | - if (!isset($context['files_in_session_warning'])) |
|
1027 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1072 | + if (!isset($context['files_in_session_warning'])) { |
|
1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1074 | + } |
|
1028 | 1075 | |
1029 | 1076 | $context['current_attachments'][$attachID] = array( |
1030 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1052,8 +1099,9 @@ discard block |
||
1052 | 1099 | } |
1053 | 1100 | |
1054 | 1101 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1055 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1056 | - $post_errors[] = 'need_qr_verification'; |
|
1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1103 | + $post_errors[] = 'need_qr_verification'; |
|
1104 | + } |
|
1057 | 1105 | |
1058 | 1106 | /* |
1059 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1070,52 +1118,56 @@ discard block |
||
1070 | 1118 | { |
1071 | 1119 | loadLanguage('Errors'); |
1072 | 1120 | $context['error_type'] = 'minor'; |
1073 | - foreach ($post_errors as $post_error) |
|
1074 | - if (is_array($post_error)) |
|
1121 | + foreach ($post_errors as $post_error) { |
|
1122 | + if (is_array($post_error)) |
|
1075 | 1123 | { |
1076 | 1124 | $post_error_id = $post_error[0]; |
1125 | + } |
|
1077 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1078 | 1127 | |
1079 | 1128 | // If it's not a minor error flag it as such. |
1080 | - if (!in_array($post_error_id, $minor_errors)) |
|
1081 | - $context['error_type'] = 'serious'; |
|
1082 | - } |
|
1083 | - else |
|
1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1130 | + $context['error_type'] = 'serious'; |
|
1131 | + } |
|
1132 | + } else |
|
1084 | 1133 | { |
1085 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1086 | 1135 | |
1087 | 1136 | // If it's not a minor error flag it as such. |
1088 | - if (!in_array($post_error, $minor_errors)) |
|
1089 | - $context['error_type'] = 'serious'; |
|
1137 | + if (!in_array($post_error, $minor_errors)) { |
|
1138 | + $context['error_type'] = 'serious'; |
|
1139 | + } |
|
1090 | 1140 | } |
1091 | 1141 | } |
1092 | 1142 | |
1093 | 1143 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1094 | - if (isset($_REQUEST['poll'])) |
|
1095 | - $context['page_title'] = $txt['new_poll']; |
|
1096 | - elseif ($context['make_event']) |
|
1097 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1098 | - elseif (isset($_REQUEST['msg'])) |
|
1099 | - $context['page_title'] = $txt['modify_msg']; |
|
1100 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1101 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1102 | - elseif (empty($topic)) |
|
1103 | - $context['page_title'] = $txt['start_new_topic']; |
|
1104 | - else |
|
1105 | - $context['page_title'] = $txt['post_reply']; |
|
1144 | + if (isset($_REQUEST['poll'])) { |
|
1145 | + $context['page_title'] = $txt['new_poll']; |
|
1146 | + } elseif ($context['make_event']) { |
|
1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
1149 | + $context['page_title'] = $txt['modify_msg']; |
|
1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1152 | + } elseif (empty($topic)) { |
|
1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
1154 | + } else { |
|
1155 | + $context['page_title'] = $txt['post_reply']; |
|
1156 | + } |
|
1106 | 1157 | |
1107 | 1158 | // Build the link tree. |
1108 | - if (empty($topic)) |
|
1109 | - $context['linktree'][] = array( |
|
1159 | + if (empty($topic)) { |
|
1160 | + $context['linktree'][] = array( |
|
1110 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1111 | 1162 | ); |
1112 | - else |
|
1113 | - $context['linktree'][] = array( |
|
1163 | + } else { |
|
1164 | + $context['linktree'][] = array( |
|
1114 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1115 | 1166 | 'name' => $form_subject, |
1116 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1117 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1118 | 1169 | ); |
1170 | + } |
|
1119 | 1171 | |
1120 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
1121 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1159,8 +1211,9 @@ discard block |
||
1159 | 1211 | // Message icons - customized icons are off? |
1160 | 1212 | $context['icons'] = getMessageIcons($board); |
1161 | 1213 | |
1162 | - if (!empty($context['icons'])) |
|
1163 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1214 | + if (!empty($context['icons'])) { |
|
1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1216 | + } |
|
1164 | 1217 | |
1165 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
1166 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1180,8 +1233,9 @@ discard block |
||
1180 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1181 | 1234 | { |
1182 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1183 | - if ($context['icons'][$i]['selected']) |
|
1184 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1236 | + if ($context['icons'][$i]['selected']) { |
|
1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1238 | + } |
|
1185 | 1239 | } |
1186 | 1240 | if (empty($context['icon_url'])) |
1187 | 1241 | { |
@@ -1195,8 +1249,9 @@ discard block |
||
1195 | 1249 | )); |
1196 | 1250 | } |
1197 | 1251 | |
1198 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1199 | - getTopic(); |
|
1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1253 | + getTopic(); |
|
1254 | + } |
|
1200 | 1255 | |
1201 | 1256 | // If the user can post attachments prepare the warning labels. |
1202 | 1257 | if ($context['can_post_attachment']) |
@@ -1207,12 +1262,13 @@ discard block |
||
1207 | 1262 | $context['attachment_restrictions'] = array(); |
1208 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1209 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1210 | - foreach ($attachmentRestrictionTypes as $type) |
|
1211 | - if (!empty($modSettings[$type])) |
|
1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1266 | + if (!empty($modSettings[$type])) |
|
1212 | 1267 | { |
1213 | 1268 | // Show the max number of attachments if not 0. |
1214 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
1215 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1271 | + } |
|
1216 | 1272 | } |
1217 | 1273 | } |
1218 | 1274 | |
@@ -1246,8 +1302,8 @@ discard block |
||
1246 | 1302 | |
1247 | 1303 | if (!empty($context['current_attachments'])) |
1248 | 1304 | { |
1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1250 | - addInlineJavaScript(' |
|
1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1306 | + addInlineJavaScript(' |
|
1251 | 1307 | current_attachments.push({ |
1252 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
1253 | 1309 | size: '. $mock['size'] . ', |
@@ -1256,6 +1312,7 @@ discard block |
||
1256 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1257 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1258 | 1314 | });', true); |
1315 | + } |
|
1259 | 1316 | } |
1260 | 1317 | |
1261 | 1318 | // File Upload. |
@@ -1340,8 +1397,9 @@ discard block |
||
1340 | 1397 | |
1341 | 1398 | |
1342 | 1399 | // Finally, load the template. |
1343 | - if (!isset($_REQUEST['xml'])) |
|
1344 | - loadTemplate('Post'); |
|
1400 | + if (!isset($_REQUEST['xml'])) { |
|
1401 | + loadTemplate('Post'); |
|
1402 | + } |
|
1345 | 1403 | |
1346 | 1404 | call_integration_hook('integrate_post_end'); |
1347 | 1405 | } |
@@ -1362,13 +1420,14 @@ discard block |
||
1362 | 1420 | // Sneaking off, are we? |
1363 | 1421 | if (empty($_POST) && empty($topic)) |
1364 | 1422 | { |
1365 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1366 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1367 | - else |
|
1368 | - fatal_lang_error('post_upload_error', false); |
|
1423 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1424 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1425 | + } else { |
|
1426 | + fatal_lang_error('post_upload_error', false); |
|
1427 | + } |
|
1428 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1429 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1369 | 1430 | } |
1370 | - elseif (empty($_POST) && !empty($topic)) |
|
1371 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1372 | 1431 | |
1373 | 1432 | // No need! |
1374 | 1433 | $context['robot_no_index'] = true; |
@@ -1380,8 +1439,9 @@ discard block |
||
1380 | 1439 | $post_errors = array(); |
1381 | 1440 | |
1382 | 1441 | // If the session has timed out, let the user re-submit their form. |
1383 | - if (checkSession('post', '', false) != '') |
|
1384 | - $post_errors[] = 'session_timeout'; |
|
1442 | + if (checkSession('post', '', false) != '') { |
|
1443 | + $post_errors[] = 'session_timeout'; |
|
1444 | + } |
|
1385 | 1445 | |
1386 | 1446 | // Wrong verification code? |
1387 | 1447 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1391,33 +1451,38 @@ discard block |
||
1391 | 1451 | 'id' => 'post', |
1392 | 1452 | ); |
1393 | 1453 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1394 | - if (is_array($context['require_verification'])) |
|
1395 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1454 | + if (is_array($context['require_verification'])) { |
|
1455 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1456 | + } |
|
1396 | 1457 | } |
1397 | 1458 | |
1398 | 1459 | require_once($sourcedir . '/Subs-Post.php'); |
1399 | 1460 | loadLanguage('Post'); |
1400 | 1461 | |
1401 | 1462 | // Drafts enabled and needed? |
1402 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1403 | - require_once($sourcedir . '/Drafts.php'); |
|
1463 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1464 | + require_once($sourcedir . '/Drafts.php'); |
|
1465 | + } |
|
1404 | 1466 | |
1405 | 1467 | // First check to see if they are trying to delete any current attachments. |
1406 | 1468 | if (isset($_POST['attach_del'])) |
1407 | 1469 | { |
1408 | 1470 | $keep_temp = array(); |
1409 | 1471 | $keep_ids = array(); |
1410 | - foreach ($_POST['attach_del'] as $dummy) |
|
1411 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1472 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1473 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1412 | 1474 | $keep_temp[] = $dummy; |
1413 | - else |
|
1414 | - $keep_ids[] = (int) $dummy; |
|
1475 | + } |
|
1476 | + else { |
|
1477 | + $keep_ids[] = (int) $dummy; |
|
1478 | + } |
|
1415 | 1479 | |
1416 | - if (isset($_SESSION['temp_attachments'])) |
|
1417 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1480 | + if (isset($_SESSION['temp_attachments'])) { |
|
1481 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1418 | 1482 | { |
1419 | 1483 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1420 | 1484 | continue; |
1485 | + } |
|
1421 | 1486 | |
1422 | 1487 | unset($_SESSION['temp_attachments'][$attachID]); |
1423 | 1488 | unlink($attachment['tmp_name']); |
@@ -1459,12 +1524,14 @@ discard block |
||
1459 | 1524 | $smcFunc['db_free_result']($request); |
1460 | 1525 | |
1461 | 1526 | // Though the topic should be there, it might have vanished. |
1462 | - if (!is_array($topic_info)) |
|
1463 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1527 | + if (!is_array($topic_info)) { |
|
1528 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1529 | + } |
|
1464 | 1530 | |
1465 | 1531 | // Did this topic suddenly move? Just checking... |
1466 | - if ($topic_info['id_board'] != $board) |
|
1467 | - fatal_lang_error('not_a_topic'); |
|
1532 | + if ($topic_info['id_board'] != $board) { |
|
1533 | + fatal_lang_error('not_a_topic'); |
|
1534 | + } |
|
1468 | 1535 | |
1469 | 1536 | // Do the permissions and approval stuff... |
1470 | 1537 | $becomesApproved = true; |
@@ -1487,49 +1554,50 @@ discard block |
||
1487 | 1554 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1488 | 1555 | { |
1489 | 1556 | // Don't allow a post if it's locked. |
1490 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1491 | - fatal_lang_error('topic_locked', false); |
|
1557 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1558 | + fatal_lang_error('topic_locked', false); |
|
1559 | + } |
|
1492 | 1560 | |
1493 | 1561 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1494 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1495 | - unset($_REQUEST['poll']); |
|
1496 | - |
|
1497 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1498 | - { |
|
1499 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1500 | - $becomesApproved = false; |
|
1501 | - |
|
1502 | - else |
|
1503 | - isAllowedTo('post_reply_any'); |
|
1504 | - } |
|
1505 | - elseif (!allowedTo('post_reply_any')) |
|
1562 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1563 | + unset($_REQUEST['poll']); |
|
1564 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1565 | + { |
|
1566 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1567 | + $becomesApproved = false; |
|
1568 | + } else { |
|
1569 | + isAllowedTo('post_reply_any'); |
|
1570 | + } |
|
1571 | + } elseif (!allowedTo('post_reply_any')) |
|
1506 | 1572 | { |
1507 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1508 | - $becomesApproved = false; |
|
1509 | - |
|
1510 | - else |
|
1511 | - isAllowedTo('post_reply_own'); |
|
1573 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1574 | + $becomesApproved = false; |
|
1575 | + } else { |
|
1576 | + isAllowedTo('post_reply_own'); |
|
1577 | + } |
|
1512 | 1578 | } |
1513 | 1579 | |
1514 | 1580 | if (isset($_POST['lock'])) |
1515 | 1581 | { |
1516 | 1582 | // Nothing is changed to the lock. |
1517 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1518 | - unset($_POST['lock']); |
|
1583 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1584 | + unset($_POST['lock']); |
|
1585 | + } |
|
1519 | 1586 | |
1520 | 1587 | // You're have no permission to lock this topic. |
1521 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1522 | - unset($_POST['lock']); |
|
1588 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1589 | + unset($_POST['lock']); |
|
1590 | + } |
|
1523 | 1591 | |
1524 | 1592 | // You are allowed to (un)lock your own topic only. |
1525 | 1593 | elseif (!allowedTo('lock_any')) |
1526 | 1594 | { |
1527 | 1595 | // You cannot override a moderator lock. |
1528 | - if ($topic_info['locked'] == 1) |
|
1529 | - unset($_POST['lock']); |
|
1530 | - |
|
1531 | - else |
|
1532 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1596 | + if ($topic_info['locked'] == 1) { |
|
1597 | + unset($_POST['lock']); |
|
1598 | + } else { |
|
1599 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1600 | + } |
|
1533 | 1601 | } |
1534 | 1602 | // Hail mighty moderator, (un)lock this topic immediately. |
1535 | 1603 | else |
@@ -1537,19 +1605,21 @@ discard block |
||
1537 | 1605 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1538 | 1606 | |
1539 | 1607 | // Did someone (un)lock this while you were posting? |
1540 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1541 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1608 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1609 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1610 | + } |
|
1542 | 1611 | } |
1543 | 1612 | } |
1544 | 1613 | |
1545 | 1614 | // So you wanna (un)sticky this...let's see. |
1546 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1547 | - unset($_POST['sticky']); |
|
1548 | - elseif (isset($_POST['sticky'])) |
|
1615 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1616 | + unset($_POST['sticky']); |
|
1617 | + } elseif (isset($_POST['sticky'])) |
|
1549 | 1618 | { |
1550 | 1619 | // Did someone (un)sticky this while you were posting? |
1551 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1552 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1620 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1621 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1622 | + } |
|
1553 | 1623 | } |
1554 | 1624 | |
1555 | 1625 | // If drafts are enabled, then pass this off |
@@ -1576,26 +1646,31 @@ discard block |
||
1576 | 1646 | |
1577 | 1647 | // Do like, the permissions, for safety and stuff... |
1578 | 1648 | $becomesApproved = true; |
1579 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1580 | - $becomesApproved = false; |
|
1581 | - else |
|
1582 | - isAllowedTo('post_new'); |
|
1649 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1650 | + $becomesApproved = false; |
|
1651 | + } else { |
|
1652 | + isAllowedTo('post_new'); |
|
1653 | + } |
|
1583 | 1654 | |
1584 | 1655 | if (isset($_POST['lock'])) |
1585 | 1656 | { |
1586 | 1657 | // New topics are by default not locked. |
1587 | - if (empty($_POST['lock'])) |
|
1588 | - unset($_POST['lock']); |
|
1658 | + if (empty($_POST['lock'])) { |
|
1659 | + unset($_POST['lock']); |
|
1660 | + } |
|
1589 | 1661 | // Besides, you need permission. |
1590 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1591 | - unset($_POST['lock']); |
|
1662 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1663 | + unset($_POST['lock']); |
|
1664 | + } |
|
1592 | 1665 | // A moderator-lock (1) can override a user-lock (2). |
1593 | - else |
|
1594 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1666 | + else { |
|
1667 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1668 | + } |
|
1595 | 1669 | } |
1596 | 1670 | |
1597 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1598 | - unset($_POST['sticky']); |
|
1671 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1672 | + unset($_POST['sticky']); |
|
1673 | + } |
|
1599 | 1674 | |
1600 | 1675 | // Saving your new topic as a draft first? |
1601 | 1676 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1620,31 +1695,37 @@ discard block |
||
1620 | 1695 | 'id_msg' => $_REQUEST['msg'], |
1621 | 1696 | ) |
1622 | 1697 | ); |
1623 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1624 | - fatal_lang_error('cant_find_messages', false); |
|
1698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1699 | + fatal_lang_error('cant_find_messages', false); |
|
1700 | + } |
|
1625 | 1701 | $row = $smcFunc['db_fetch_assoc']($request); |
1626 | 1702 | $smcFunc['db_free_result']($request); |
1627 | 1703 | |
1628 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1629 | - fatal_lang_error('topic_locked', false); |
|
1704 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1705 | + fatal_lang_error('topic_locked', false); |
|
1706 | + } |
|
1630 | 1707 | |
1631 | 1708 | if (isset($_POST['lock'])) |
1632 | 1709 | { |
1633 | 1710 | // Nothing changes to the lock status. |
1634 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1635 | - unset($_POST['lock']); |
|
1711 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1712 | + unset($_POST['lock']); |
|
1713 | + } |
|
1636 | 1714 | // You're simply not allowed to (un)lock this. |
1637 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1638 | - unset($_POST['lock']); |
|
1715 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1716 | + unset($_POST['lock']); |
|
1717 | + } |
|
1639 | 1718 | // You're only allowed to lock your own topics. |
1640 | 1719 | elseif (!allowedTo('lock_any')) |
1641 | 1720 | { |
1642 | 1721 | // You're not allowed to break a moderator's lock. |
1643 | - if ($topic_info['locked'] == 1) |
|
1644 | - unset($_POST['lock']); |
|
1722 | + if ($topic_info['locked'] == 1) { |
|
1723 | + unset($_POST['lock']); |
|
1724 | + } |
|
1645 | 1725 | // Lock it with a soft lock or unlock it. |
1646 | - else |
|
1647 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1726 | + else { |
|
1727 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1728 | + } |
|
1648 | 1729 | } |
1649 | 1730 | // You must be the moderator. |
1650 | 1731 | else |
@@ -1652,44 +1733,46 @@ discard block |
||
1652 | 1733 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1653 | 1734 | |
1654 | 1735 | // Did someone (un)lock this while you were posting? |
1655 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1656 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1736 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1737 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1738 | + } |
|
1657 | 1739 | } |
1658 | 1740 | } |
1659 | 1741 | |
1660 | 1742 | // Change the sticky status of this topic? |
1661 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1662 | - unset($_POST['sticky']); |
|
1663 | - elseif (isset($_POST['sticky'])) |
|
1743 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1744 | + unset($_POST['sticky']); |
|
1745 | + } elseif (isset($_POST['sticky'])) |
|
1664 | 1746 | { |
1665 | 1747 | // Did someone (un)sticky this while you were posting? |
1666 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1667 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1748 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1749 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1750 | + } |
|
1668 | 1751 | } |
1669 | 1752 | |
1670 | 1753 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1671 | 1754 | { |
1672 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1673 | - fatal_lang_error('modify_post_time_passed', false); |
|
1674 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1675 | - isAllowedTo('modify_replies'); |
|
1676 | - else |
|
1677 | - isAllowedTo('modify_own'); |
|
1678 | - } |
|
1679 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1755 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1756 | + fatal_lang_error('modify_post_time_passed', false); |
|
1757 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1758 | + isAllowedTo('modify_replies'); |
|
1759 | + } else { |
|
1760 | + isAllowedTo('modify_own'); |
|
1761 | + } |
|
1762 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1680 | 1763 | { |
1681 | 1764 | isAllowedTo('modify_replies'); |
1682 | 1765 | |
1683 | 1766 | // If you're modifying a reply, I say it better be logged... |
1684 | 1767 | $moderationAction = true; |
1685 | - } |
|
1686 | - else |
|
1768 | + } else |
|
1687 | 1769 | { |
1688 | 1770 | isAllowedTo('modify_any'); |
1689 | 1771 | |
1690 | 1772 | // Log it, assuming you're not modifying your own post. |
1691 | - if ($row['id_member'] != $user_info['id']) |
|
1692 | - $moderationAction = true; |
|
1773 | + if ($row['id_member'] != $user_info['id']) { |
|
1774 | + $moderationAction = true; |
|
1775 | + } |
|
1693 | 1776 | } |
1694 | 1777 | |
1695 | 1778 | // If drafts are enabled, then lets send this off to save |
@@ -1727,20 +1810,24 @@ discard block |
||
1727 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1728 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1729 | 1812 | |
1730 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1731 | - $post_errors[] = 'no_name'; |
|
1732 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1733 | - $post_errors[] = 'long_name'; |
|
1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1814 | + $post_errors[] = 'no_name'; |
|
1815 | + } |
|
1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1817 | + $post_errors[] = 'long_name'; |
|
1818 | + } |
|
1734 | 1819 | |
1735 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
1736 | 1821 | { |
1737 | 1822 | // Only check if they changed it! |
1738 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1739 | 1824 | { |
1740 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1741 | - $post_errors[] = 'no_email'; |
|
1742 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1743 | - $post_errors[] = 'bad_email'; |
|
1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1826 | + $post_errors[] = 'no_email'; |
|
1827 | + } |
|
1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1829 | + $post_errors[] = 'bad_email'; |
|
1830 | + } |
|
1744 | 1831 | } |
1745 | 1832 | |
1746 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1756,75 +1843,89 @@ discard block |
||
1756 | 1843 | } |
1757 | 1844 | |
1758 | 1845 | // Coming from the quickReply? |
1759 | - if (isset($_POST['quickReply'])) |
|
1760 | - $_POST['message'] = $_POST['quickReply']; |
|
1846 | + if (isset($_POST['quickReply'])) { |
|
1847 | + $_POST['message'] = $_POST['quickReply']; |
|
1848 | + } |
|
1761 | 1849 | |
1762 | 1850 | // Check the subject and message. |
1763 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1764 | - $post_errors[] = 'no_subject'; |
|
1765 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1766 | - $post_errors[] = 'no_message'; |
|
1767 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1768 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1769 | - else |
|
1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1852 | + $post_errors[] = 'no_subject'; |
|
1853 | + } |
|
1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1855 | + $post_errors[] = 'no_message'; |
|
1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1858 | + } else |
|
1770 | 1859 | { |
1771 | 1860 | // Prepare the message a bit for some additional testing. |
1772 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1773 | 1862 | |
1774 | 1863 | // Preparse code. (Zef) |
1775 | - if ($user_info['is_guest']) |
|
1776 | - $user_info['name'] = $_POST['guestname']; |
|
1864 | + if ($user_info['is_guest']) { |
|
1865 | + $user_info['name'] = $_POST['guestname']; |
|
1866 | + } |
|
1777 | 1867 | preparsecode($_POST['message']); |
1778 | 1868 | |
1779 | 1869 | // Let's see if there's still some content left without the tags. |
1780 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1781 | - $post_errors[] = 'no_message'; |
|
1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1871 | + $post_errors[] = 'no_message'; |
|
1872 | + } |
|
1873 | + } |
|
1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1875 | + $post_errors[] = 'no_event'; |
|
1782 | 1876 | } |
1783 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1784 | - $post_errors[] = 'no_event'; |
|
1785 | 1877 | // You are not! |
1786 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1787 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1880 | + } |
|
1788 | 1881 | |
1789 | 1882 | // Validate the poll... |
1790 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1791 | 1884 | { |
1792 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1793 | - fatal_lang_error('no_access', false); |
|
1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1886 | + fatal_lang_error('no_access', false); |
|
1887 | + } |
|
1794 | 1888 | |
1795 | 1889 | // This is a new topic... so it's a new poll. |
1796 | - if (empty($topic)) |
|
1797 | - isAllowedTo('poll_post'); |
|
1890 | + if (empty($topic)) { |
|
1891 | + isAllowedTo('poll_post'); |
|
1892 | + } |
|
1798 | 1893 | // Can you add to your own topics? |
1799 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1800 | - isAllowedTo('poll_add_own'); |
|
1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1895 | + isAllowedTo('poll_add_own'); |
|
1896 | + } |
|
1801 | 1897 | // Can you add polls to any topic, then? |
1802 | - else |
|
1803 | - isAllowedTo('poll_add_any'); |
|
1898 | + else { |
|
1899 | + isAllowedTo('poll_add_any'); |
|
1900 | + } |
|
1804 | 1901 | |
1805 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1806 | - $post_errors[] = 'no_question'; |
|
1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1903 | + $post_errors[] = 'no_question'; |
|
1904 | + } |
|
1807 | 1905 | |
1808 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1809 | 1907 | |
1810 | 1908 | // Get rid of empty ones. |
1811 | - foreach ($_POST['options'] as $k => $option) |
|
1812 | - if ($option == '') |
|
1909 | + foreach ($_POST['options'] as $k => $option) { |
|
1910 | + if ($option == '') |
|
1813 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1912 | + } |
|
1814 | 1913 | |
1815 | 1914 | // What are you going to vote between with one choice?!? |
1816 | - if (count($_POST['options']) < 2) |
|
1817 | - $post_errors[] = 'poll_few'; |
|
1818 | - elseif (count($_POST['options']) > 256) |
|
1819 | - $post_errors[] = 'poll_many'; |
|
1915 | + if (count($_POST['options']) < 2) { |
|
1916 | + $post_errors[] = 'poll_few'; |
|
1917 | + } elseif (count($_POST['options']) > 256) { |
|
1918 | + $post_errors[] = 'poll_many'; |
|
1919 | + } |
|
1820 | 1920 | } |
1821 | 1921 | |
1822 | 1922 | if ($posterIsGuest) |
1823 | 1923 | { |
1824 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
1825 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
1826 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1827 | - $post_errors[] = 'bad_name'; |
|
1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1927 | + $post_errors[] = 'bad_name'; |
|
1928 | + } |
|
1828 | 1929 | } |
1829 | 1930 | // If the user isn't a guest, get his or her name and email. |
1830 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1855,8 +1956,9 @@ discard block |
||
1855 | 1956 | } |
1856 | 1957 | |
1857 | 1958 | // Make sure the user isn't spamming the board. |
1858 | - if (!isset($_REQUEST['msg'])) |
|
1859 | - spamProtection('post'); |
|
1959 | + if (!isset($_REQUEST['msg'])) { |
|
1960 | + spamProtection('post'); |
|
1961 | + } |
|
1860 | 1962 | |
1861 | 1963 | // At about this point, we're posting and that's that. |
1862 | 1964 | ignore_user_abort(true); |
@@ -1869,32 +1971,36 @@ discard block |
||
1869 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1870 | 1972 | |
1871 | 1973 | // At this point, we want to make sure the subject isn't too long. |
1872 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1873 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1976 | + } |
|
1874 | 1977 | |
1875 | 1978 | // Same with the "why did you edit this" text. |
1876 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1877 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1981 | + } |
|
1878 | 1982 | |
1879 | 1983 | // Make the poll... |
1880 | 1984 | if (isset($_REQUEST['poll'])) |
1881 | 1985 | { |
1882 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
1883 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1884 | - $_POST['poll_max_votes'] = 1; |
|
1885 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1886 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1887 | - else |
|
1888 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
1988 | + $_POST['poll_max_votes'] = 1; |
|
1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
1991 | + } else { |
|
1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1993 | + } |
|
1889 | 1994 | |
1890 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1891 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1892 | 1997 | |
1893 | 1998 | // Just set it to zero if it's not there.. |
1894 | - if (!isset($_POST['poll_hide'])) |
|
1895 | - $_POST['poll_hide'] = 0; |
|
1896 | - else |
|
1897 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1999 | + if (!isset($_POST['poll_hide'])) { |
|
2000 | + $_POST['poll_hide'] = 0; |
|
2001 | + } else { |
|
2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2003 | + } |
|
1898 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1899 | 2005 | |
1900 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1903,16 +2009,19 @@ discard block |
||
1903 | 2009 | { |
1904 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
1905 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1906 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1907 | - $_POST['poll_guest_vote'] = 0; |
|
2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2013 | + $_POST['poll_guest_vote'] = 0; |
|
2014 | + } |
|
1908 | 2015 | } |
1909 | 2016 | |
1910 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
1911 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1912 | - fatal_lang_error('poll_range_error', false); |
|
2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2019 | + fatal_lang_error('poll_range_error', false); |
|
2020 | + } |
|
1913 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1914 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1915 | - $_POST['poll_hide'] = 1; |
|
2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2023 | + $_POST['poll_hide'] = 1; |
|
2024 | + } |
|
1916 | 2025 | |
1917 | 2026 | // Clean up the question and answers. |
1918 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1926,13 +2035,15 @@ discard block |
||
1926 | 2035 | { |
1927 | 2036 | $attachIDs = array(); |
1928 | 2037 | $attach_errors = array(); |
1929 | - if (!empty($context['we_are_history'])) |
|
1930 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2038 | + if (!empty($context['we_are_history'])) { |
|
2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2040 | + } |
|
1931 | 2041 | |
1932 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1933 | 2043 | { |
1934 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1935 | - continue; |
|
2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2045 | + continue; |
|
2046 | + } |
|
1936 | 2047 | |
1937 | 2048 | // If there was an initial error just show that message. |
1938 | 2049 | if ($attachID == 'initial_error') |
@@ -1961,12 +2072,13 @@ discard block |
||
1961 | 2072 | if (createAttachment($attachmentOptions)) |
1962 | 2073 | { |
1963 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
1964 | - if (!empty($attachmentOptions['thumb'])) |
|
1965 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2077 | + } |
|
1966 | 2078 | } |
2079 | + } else { |
|
2080 | + $attach_errors[] = '<dt> </dt>'; |
|
1967 | 2081 | } |
1968 | - else |
|
1969 | - $attach_errors[] = '<dt> </dt>'; |
|
1970 | 2082 | |
1971 | 2083 | if (!empty($attachmentOptions['errors'])) |
1972 | 2084 | { |
@@ -1978,14 +2090,16 @@ discard block |
||
1978 | 2090 | if (!is_array($error)) |
1979 | 2091 | { |
1980 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
1981 | - if (in_array($error, $log_these)) |
|
1982 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2093 | + if (in_array($error, $log_these)) { |
|
2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2095 | + } |
|
2096 | + } else { |
|
2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1983 | 2098 | } |
1984 | - else |
|
1985 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1986 | 2099 | } |
1987 | - if (file_exists($attachment['tmp_name'])) |
|
1988 | - unlink($attachment['tmp_name']); |
|
2100 | + if (file_exists($attachment['tmp_name'])) { |
|
2101 | + unlink($attachment['tmp_name']); |
|
2102 | + } |
|
1989 | 2103 | } |
1990 | 2104 | } |
1991 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2026,24 +2140,24 @@ discard block |
||
2026 | 2140 | ); |
2027 | 2141 | |
2028 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2143 | + } else { |
|
2144 | + $id_poll = 0; |
|
2029 | 2145 | } |
2030 | - else |
|
2031 | - $id_poll = 0; |
|
2032 | 2146 | |
2033 | 2147 | // Creating a new topic? |
2034 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2035 | 2149 | |
2036 | 2150 | // Check the icon. |
2037 | - if (!isset($_POST['icon'])) |
|
2038 | - $_POST['icon'] = 'xx'; |
|
2039 | - |
|
2040 | - else |
|
2151 | + if (!isset($_POST['icon'])) { |
|
2152 | + $_POST['icon'] = 'xx'; |
|
2153 | + } else |
|
2041 | 2154 | { |
2042 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2043 | 2156 | |
2044 | 2157 | // Need to figure it out if this is a valid icon name. |
2045 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2046 | - $_POST['icon'] = 'xx'; |
|
2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2159 | + $_POST['icon'] = 'xx'; |
|
2160 | + } |
|
2047 | 2161 | } |
2048 | 2162 | |
2049 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2084,8 +2198,9 @@ discard block |
||
2084 | 2198 | } |
2085 | 2199 | |
2086 | 2200 | // This will save some time... |
2087 | - if (empty($approve_has_changed)) |
|
2088 | - unset($msgOptions['approved']); |
|
2201 | + if (empty($approve_has_changed)) { |
|
2202 | + unset($msgOptions['approved']); |
|
2203 | + } |
|
2089 | 2204 | |
2090 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2091 | 2206 | } |
@@ -2094,8 +2209,9 @@ discard block |
||
2094 | 2209 | { |
2095 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
2096 | 2211 | |
2097 | - if (isset($topicOptions['id'])) |
|
2098 | - $topic = $topicOptions['id']; |
|
2212 | + if (isset($topicOptions['id'])) { |
|
2213 | + $topic = $topicOptions['id']; |
|
2214 | + } |
|
2099 | 2215 | } |
2100 | 2216 | |
2101 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2107,8 +2223,9 @@ discard block |
||
2107 | 2223 | } |
2108 | 2224 | |
2109 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
2110 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2111 | - DeleteDraft($_POST['id_draft']); |
|
2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2227 | + DeleteDraft($_POST['id_draft']); |
|
2228 | + } |
|
2112 | 2229 | |
2113 | 2230 | // Editing or posting an event? |
2114 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2127,8 +2244,7 @@ discard block |
||
2127 | 2244 | 'member' => $user_info['id'], |
2128 | 2245 | ); |
2129 | 2246 | insertEvent($eventOptions); |
2130 | - } |
|
2131 | - elseif (isset($_POST['calendar'])) |
|
2247 | + } elseif (isset($_POST['calendar'])) |
|
2132 | 2248 | { |
2133 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2134 | 2250 | |
@@ -2156,14 +2272,15 @@ discard block |
||
2156 | 2272 | } |
2157 | 2273 | |
2158 | 2274 | // Delete it? |
2159 | - if (isset($_REQUEST['deleteevent'])) |
|
2160 | - $smcFunc['db_query']('', ' |
|
2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
2276 | + $smcFunc['db_query']('', ' |
|
2161 | 2277 | DELETE FROM {db_prefix}calendar |
2162 | 2278 | WHERE id_event = {int:id_event}', |
2163 | 2279 | array( |
2164 | 2280 | 'id_event' => $_REQUEST['eventid'], |
2165 | 2281 | ) |
2166 | 2282 | ); |
2283 | + } |
|
2167 | 2284 | // ... or just update it? |
2168 | 2285 | else |
2169 | 2286 | { |
@@ -2205,9 +2322,8 @@ discard block |
||
2205 | 2322 | array($user_info['id'], $topic, 0), |
2206 | 2323 | array('id_member', 'id_topic', 'id_board') |
2207 | 2324 | ); |
2208 | - } |
|
2209 | - elseif (!$newTopic) |
|
2210 | - $smcFunc['db_query']('', ' |
|
2325 | + } elseif (!$newTopic) { |
|
2326 | + $smcFunc['db_query']('', ' |
|
2211 | 2327 | DELETE FROM {db_prefix}log_notify |
2212 | 2328 | WHERE id_member = {int:current_member} |
2213 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2216,16 +2332,20 @@ discard block |
||
2216 | 2332 | 'current_topic' => $topic, |
2217 | 2333 | ) |
2218 | 2334 | ); |
2335 | + } |
|
2219 | 2336 | |
2220 | 2337 | // Log an act of moderation - modifying. |
2221 | - if (!empty($moderationAction)) |
|
2222 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2338 | + if (!empty($moderationAction)) { |
|
2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2340 | + } |
|
2223 | 2341 | |
2224 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2225 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2344 | + } |
|
2226 | 2345 | |
2227 | - if (isset($_POST['sticky'])) |
|
2228 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2346 | + if (isset($_POST['sticky'])) { |
|
2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2348 | + } |
|
2229 | 2349 | |
2230 | 2350 | // Returning to the topic? |
2231 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2244,26 +2364,31 @@ discard block |
||
2244 | 2364 | ); |
2245 | 2365 | } |
2246 | 2366 | |
2247 | - if ($board_info['num_topics'] == 0) |
|
2248 | - cache_put_data('board-' . $board, null, 120); |
|
2367 | + if ($board_info['num_topics'] == 0) { |
|
2368 | + cache_put_data('board-' . $board, null, 120); |
|
2369 | + } |
|
2249 | 2370 | |
2250 | 2371 | call_integration_hook('integrate_post2_end'); |
2251 | 2372 | |
2252 | - if (!empty($_POST['announce_topic'])) |
|
2253 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2373 | + if (!empty($_POST['announce_topic'])) { |
|
2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2375 | + } |
|
2254 | 2376 | |
2255 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2256 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2379 | + } |
|
2257 | 2380 | |
2258 | 2381 | // Return to post if the mod is on. |
2259 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2260 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2261 | - elseif (!empty($_REQUEST['goback'])) |
|
2262 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2386 | + } |
|
2263 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2264 | - else |
|
2265 | - redirectexit('board=' . $board . '.0'); |
|
2266 | -} |
|
2388 | + else { |
|
2389 | + redirectexit('board=' . $board . '.0'); |
|
2390 | + } |
|
2391 | + } |
|
2267 | 2392 | |
2268 | 2393 | /** |
2269 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2281,8 +2406,9 @@ discard block |
||
2281 | 2406 | |
2282 | 2407 | validateSession(); |
2283 | 2408 | |
2284 | - if (empty($topic)) |
|
2285 | - fatal_lang_error('topic_gone', false); |
|
2409 | + if (empty($topic)) { |
|
2410 | + fatal_lang_error('topic_gone', false); |
|
2411 | + } |
|
2286 | 2412 | |
2287 | 2413 | loadLanguage('Post'); |
2288 | 2414 | loadTemplate('Post'); |
@@ -2309,8 +2435,9 @@ discard block |
||
2309 | 2435 | global $txt, $context, $topic, $board_info, $smcFunc; |
2310 | 2436 | |
2311 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
2312 | - foreach ($groups as $id => $group) |
|
2313 | - $groups[$id] = (int) $group; |
|
2438 | + foreach ($groups as $id => $group) { |
|
2439 | + $groups[$id] = (int) $group; |
|
2440 | + } |
|
2314 | 2441 | |
2315 | 2442 | $context['groups'] = array(); |
2316 | 2443 | if (in_array(0, $groups)) |
@@ -2353,8 +2480,9 @@ discard block |
||
2353 | 2480 | 'group_list' => $groups, |
2354 | 2481 | ) |
2355 | 2482 | ); |
2356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2357 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2485 | + } |
|
2358 | 2486 | $smcFunc['db_free_result']($request); |
2359 | 2487 | |
2360 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2396,16 +2524,19 @@ discard block |
||
2396 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2397 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
2398 | 2526 | |
2399 | - if (isset($_POST['membergroups'])) |
|
2400 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2527 | + if (isset($_POST['membergroups'])) { |
|
2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2529 | + } |
|
2401 | 2530 | |
2402 | 2531 | // Check whether at least one membergroup was selected. |
2403 | - if (empty($_POST['who'])) |
|
2404 | - fatal_lang_error('no_membergroup_selected'); |
|
2532 | + if (empty($_POST['who'])) { |
|
2533 | + fatal_lang_error('no_membergroup_selected'); |
|
2534 | + } |
|
2405 | 2535 | |
2406 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
2407 | - foreach ($_POST['who'] as $id => $mg) |
|
2408 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2539 | + } |
|
2409 | 2540 | |
2410 | 2541 | // Get the topic subject and censor it. |
2411 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2451,12 +2582,13 @@ discard block |
||
2451 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
2452 | 2583 | { |
2453 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2454 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2455 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2456 | - elseif (!empty($_REQUEST['goback'])) |
|
2457 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2458 | - else |
|
2459 | - redirectexit('board=' . $board . '.0'); |
|
2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2589 | + } else { |
|
2590 | + redirectexit('board=' . $board . '.0'); |
|
2591 | + } |
|
2460 | 2592 | } |
2461 | 2593 | |
2462 | 2594 | $announcements = array(); |
@@ -2475,8 +2607,9 @@ discard block |
||
2475 | 2607 | foreach ($rows as $row) |
2476 | 2608 | { |
2477 | 2609 | // Force them to have it? |
2478 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2479 | - continue; |
|
2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2611 | + continue; |
|
2612 | + } |
|
2480 | 2613 | |
2481 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2482 | 2615 | |
@@ -2504,8 +2637,9 @@ discard block |
||
2504 | 2637 | } |
2505 | 2638 | |
2506 | 2639 | // For each language send a different mail - low priority... |
2507 | - foreach ($announcements as $lang => $mail) |
|
2508 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2640 | + foreach ($announcements as $lang => $mail) { |
|
2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2642 | + } |
|
2509 | 2643 | |
2510 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2511 | 2645 | |
@@ -2515,9 +2649,10 @@ discard block |
||
2515 | 2649 | $context['sub_template'] = 'announcement_send'; |
2516 | 2650 | |
2517 | 2651 | // Go back to the correct language for the user ;). |
2518 | - if (!empty($modSettings['userLanguage'])) |
|
2519 | - loadLanguage('Post'); |
|
2520 | -} |
|
2652 | + if (!empty($modSettings['userLanguage'])) { |
|
2653 | + loadLanguage('Post'); |
|
2654 | + } |
|
2655 | + } |
|
2521 | 2656 | |
2522 | 2657 | /** |
2523 | 2658 | * Get the topic for display purposes. |
@@ -2530,12 +2665,13 @@ discard block |
||
2530 | 2665 | { |
2531 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2532 | 2667 | |
2533 | - if (isset($_REQUEST['xml'])) |
|
2534 | - $limit = ' |
|
2668 | + if (isset($_REQUEST['xml'])) { |
|
2669 | + $limit = ' |
|
2535 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2536 | - else |
|
2537 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2671 | + } else { |
|
2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2538 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2674 | + } |
|
2539 | 2675 | |
2540 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2541 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2573,8 +2709,9 @@ discard block |
||
2573 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2574 | 2710 | ); |
2575 | 2711 | |
2576 | - if (!empty($context['new_replies'])) |
|
2577 | - $context['new_replies']--; |
|
2712 | + if (!empty($context['new_replies'])) { |
|
2713 | + $context['new_replies']--; |
|
2714 | + } |
|
2578 | 2715 | } |
2579 | 2716 | $smcFunc['db_free_result']($request); |
2580 | 2717 | } |
@@ -2591,8 +2728,9 @@ discard block |
||
2591 | 2728 | global $sourcedir, $smcFunc; |
2592 | 2729 | |
2593 | 2730 | loadLanguage('Post'); |
2594 | - if (!isset($_REQUEST['xml'])) |
|
2595 | - loadTemplate('Post'); |
|
2731 | + if (!isset($_REQUEST['xml'])) { |
|
2732 | + loadTemplate('Post'); |
|
2733 | + } |
|
2596 | 2734 | |
2597 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
2598 | 2736 | |
@@ -2623,8 +2761,9 @@ discard block |
||
2623 | 2761 | $smcFunc['db_free_result']($request); |
2624 | 2762 | |
2625 | 2763 | $context['sub_template'] = 'quotefast'; |
2626 | - if (!empty($row)) |
|
2627 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2764 | + if (!empty($row)) { |
|
2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2766 | + } |
|
2628 | 2767 | |
2629 | 2768 | if (!empty($can_view_post)) |
2630 | 2769 | { |
@@ -2657,8 +2796,9 @@ discard block |
||
2657 | 2796 | } |
2658 | 2797 | |
2659 | 2798 | // Remove any nested quotes. |
2660 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2661 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2801 | + } |
|
2662 | 2802 | |
2663 | 2803 | $lb = "\n"; |
2664 | 2804 | |
@@ -2684,14 +2824,14 @@ discard block |
||
2684 | 2824 | 'time' => '', |
2685 | 2825 | ), |
2686 | 2826 | ); |
2687 | - } |
|
2688 | - else |
|
2689 | - $context['quote'] = array( |
|
2827 | + } else { |
|
2828 | + $context['quote'] = array( |
|
2690 | 2829 | 'xml' => '', |
2691 | 2830 | 'mozilla' => '', |
2692 | 2831 | 'text' => '', |
2693 | 2832 | ); |
2694 | -} |
|
2833 | + } |
|
2834 | + } |
|
2695 | 2835 | |
2696 | 2836 | /** |
2697 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2703,8 +2843,9 @@ discard block |
||
2703 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
2704 | 2844 | |
2705 | 2845 | // We have to have a topic! |
2706 | - if (empty($topic)) |
|
2707 | - obExit(false); |
|
2846 | + if (empty($topic)) { |
|
2847 | + obExit(false); |
|
2848 | + } |
|
2708 | 2849 | |
2709 | 2850 | checkSession('get'); |
2710 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2730,31 +2871,35 @@ discard block |
||
2730 | 2871 | 'guest_id' => 0, |
2731 | 2872 | ) |
2732 | 2873 | ); |
2733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2734 | - fatal_lang_error('no_board', false); |
|
2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2875 | + fatal_lang_error('no_board', false); |
|
2876 | + } |
|
2735 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
2736 | 2878 | $smcFunc['db_free_result']($request); |
2737 | 2879 | |
2738 | 2880 | // Change either body or subject requires permissions to modify messages. |
2739 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2740 | 2882 | { |
2741 | - if (!empty($row['locked'])) |
|
2742 | - isAllowedTo('moderate_board'); |
|
2883 | + if (!empty($row['locked'])) { |
|
2884 | + isAllowedTo('moderate_board'); |
|
2885 | + } |
|
2743 | 2886 | |
2744 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2745 | 2888 | { |
2746 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2747 | - fatal_lang_error('modify_post_time_passed', false); |
|
2748 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2749 | - isAllowedTo('modify_replies'); |
|
2750 | - else |
|
2751 | - isAllowedTo('modify_own'); |
|
2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2892 | + isAllowedTo('modify_replies'); |
|
2893 | + } else { |
|
2894 | + isAllowedTo('modify_own'); |
|
2895 | + } |
|
2752 | 2896 | } |
2753 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2754 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2755 | - isAllowedTo('modify_replies'); |
|
2756 | - else |
|
2757 | - isAllowedTo('modify_any'); |
|
2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2899 | + isAllowedTo('modify_replies'); |
|
2900 | + } else { |
|
2901 | + isAllowedTo('modify_any'); |
|
2902 | + } |
|
2758 | 2903 | |
2759 | 2904 | // Only log this action if it wasn't your message. |
2760 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2766,10 +2911,10 @@ discard block |
||
2766 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2767 | 2912 | |
2768 | 2913 | // Maximum number of characters. |
2769 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2770 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2771 | - } |
|
2772 | - elseif (isset($_POST['subject'])) |
|
2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2916 | + } |
|
2917 | + } elseif (isset($_POST['subject'])) |
|
2773 | 2918 | { |
2774 | 2919 | $post_errors[] = 'no_subject'; |
2775 | 2920 | unset($_POST['subject']); |
@@ -2781,13 +2926,11 @@ discard block |
||
2781 | 2926 | { |
2782 | 2927 | $post_errors[] = 'no_message'; |
2783 | 2928 | unset($_POST['message']); |
2784 | - } |
|
2785 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2786 | 2930 | { |
2787 | 2931 | $post_errors[] = 'long_message'; |
2788 | 2932 | unset($_POST['message']); |
2789 | - } |
|
2790 | - else |
|
2933 | + } else |
|
2791 | 2934 | { |
2792 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2793 | 2936 | |
@@ -2803,31 +2946,34 @@ discard block |
||
2803 | 2946 | |
2804 | 2947 | if (isset($_POST['lock'])) |
2805 | 2948 | { |
2806 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2807 | - unset($_POST['lock']); |
|
2808 | - elseif (!allowedTo('lock_any')) |
|
2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
2950 | + unset($_POST['lock']); |
|
2951 | + } elseif (!allowedTo('lock_any')) |
|
2809 | 2952 | { |
2810 | - if ($row['locked'] == 1) |
|
2811 | - unset($_POST['lock']); |
|
2812 | - else |
|
2813 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2953 | + if ($row['locked'] == 1) { |
|
2954 | + unset($_POST['lock']); |
|
2955 | + } else { |
|
2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2957 | + } |
|
2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
2959 | + unset($_POST['lock']); |
|
2960 | + } else { |
|
2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2814 | 2962 | } |
2815 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2816 | - unset($_POST['lock']); |
|
2817 | - else |
|
2818 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2819 | 2963 | } |
2820 | 2964 | |
2821 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2822 | - unset($_POST['sticky']); |
|
2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
2966 | + unset($_POST['sticky']); |
|
2967 | + } |
|
2823 | 2968 | |
2824 | 2969 | if (isset($_POST['modify_reason'])) |
2825 | 2970 | { |
2826 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2827 | 2972 | |
2828 | 2973 | // Maximum number of characters. |
2829 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2830 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2976 | + } |
|
2831 | 2977 | } |
2832 | 2978 | |
2833 | 2979 | if (empty($post_errors)) |
@@ -2864,8 +3010,9 @@ discard block |
||
2864 | 3010 | } |
2865 | 3011 | } |
2866 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
2867 | - else |
|
2868 | - $moderationAction = false; |
|
3013 | + else { |
|
3014 | + $moderationAction = false; |
|
3015 | + } |
|
2869 | 3016 | |
2870 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2871 | 3018 | |
@@ -2883,9 +3030,9 @@ discard block |
||
2883 | 3030 | // Get the proper (default language) response prefix first. |
2884 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2885 | 3032 | { |
2886 | - if ($language === $user_info['language']) |
|
2887 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2888 | - else |
|
3033 | + if ($language === $user_info['language']) { |
|
3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3035 | + } else |
|
2889 | 3036 | { |
2890 | 3037 | loadLanguage('index', $language, false); |
2891 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2907,8 +3054,9 @@ discard block |
||
2907 | 3054 | ); |
2908 | 3055 | } |
2909 | 3056 | |
2910 | - if (!empty($moderationAction)) |
|
2911 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3057 | + if (!empty($moderationAction)) { |
|
3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3059 | + } |
|
2912 | 3060 | } |
2913 | 3061 | |
2914 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2949,8 +3097,7 @@ discard block |
||
2949 | 3097 | ); |
2950 | 3098 | |
2951 | 3099 | censorText($context['message']['subject']); |
2952 | - } |
|
2953 | - else |
|
3100 | + } else |
|
2954 | 3101 | { |
2955 | 3102 | $context['message'] = array( |
2956 | 3103 | 'id' => $row['id_msg'], |
@@ -2962,15 +3109,16 @@ discard block |
||
2962 | 3109 | loadLanguage('Errors'); |
2963 | 3110 | foreach ($post_errors as $post_error) |
2964 | 3111 | { |
2965 | - if ($post_error == 'long_message') |
|
2966 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
2967 | - else |
|
2968 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3112 | + if ($post_error == 'long_message') { |
|
3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3114 | + } else { |
|
3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3116 | + } |
|
2969 | 3117 | } |
2970 | 3118 | } |
3119 | + } else { |
|
3120 | + obExit(false); |
|
3121 | + } |
|
2971 | 3122 | } |
2972 | - else |
|
2973 | - obExit(false); |
|
2974 | -} |
|
2975 | 3123 | |
2976 | 3124 | ?> |
2977 | 3125 | \ No newline at end of file |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'class' => 'centercol', |
257 | 257 | ), |
258 | 258 | 'data' => array( |
259 | - 'function' => function ($entry) |
|
259 | + 'function' => function($entry) |
|
260 | 260 | { |
261 | 261 | return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | if (empty($entries[$k]['action_text'])) |
639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | - function ($matches) use ($entries, $k) |
|
641 | + function($matches) use ($entries, $k) |
|
642 | 642 | { |
643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
644 | 644 | }, $entries[$k]['action_text']); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
301 | 305 | $context['default_list'] = 'moderation_log_list'; |
302 | 306 | |
303 | 307 | // If a hook has changed this, respect it. |
304 | - if (!empty($moderation_menu_name)) |
|
305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
306 | - elseif (isset($context['moderation_menu_name'])) |
|
307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | + if (!empty($moderation_menu_name)) { |
|
309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
311 | 315 | ); |
312 | -} |
|
316 | + } |
|
317 | + } |
|
313 | 318 | |
314 | 319 | /** |
315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
413 | 418 | // Add on some of the column stuff info |
414 | 419 | if (!empty($row['id_board'])) |
415 | 420 | { |
416 | - if ($row['action'] == 'move') |
|
417 | - $row['extra']['board_to'] = $row['id_board']; |
|
418 | - else |
|
419 | - $row['extra']['board'] = $row['id_board']; |
|
421 | + if ($row['action'] == 'move') { |
|
422 | + $row['extra']['board_to'] = $row['id_board']; |
|
423 | + } else { |
|
424 | + $row['extra']['board'] = $row['id_board']; |
|
425 | + } |
|
420 | 426 | } |
421 | 427 | |
422 | - if (!empty($row['id_topic'])) |
|
423 | - $row['extra']['topic'] = $row['id_topic']; |
|
424 | - if (!empty($row['id_msg'])) |
|
425 | - $row['extra']['message'] = $row['id_msg']; |
|
428 | + if (!empty($row['id_topic'])) { |
|
429 | + $row['extra']['topic'] = $row['id_topic']; |
|
430 | + } |
|
431 | + if (!empty($row['id_msg'])) { |
|
432 | + $row['extra']['message'] = $row['id_msg']; |
|
433 | + } |
|
426 | 434 | |
427 | 435 | // Is this associated with a topic? |
428 | - if (isset($row['extra']['topic'])) |
|
429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
430 | - if (isset($row['extra']['new_topic'])) |
|
431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
436 | + if (isset($row['extra']['topic'])) { |
|
437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
438 | + } |
|
439 | + if (isset($row['extra']['new_topic'])) { |
|
440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
441 | + } |
|
432 | 442 | |
433 | 443 | // How about a member? |
434 | 444 | if (isset($row['extra']['member'])) |
435 | 445 | { |
436 | 446 | // Guests don't have names! |
437 | - if (empty($row['extra']['member'])) |
|
438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
439 | - else |
|
447 | + if (empty($row['extra']['member'])) { |
|
448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
449 | + } else |
|
440 | 450 | { |
441 | 451 | // Try to find it... |
442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
444 | 454 | } |
445 | 455 | |
446 | 456 | // Associated with a board? |
447 | - if (isset($row['extra']['board_to'])) |
|
448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
449 | - if (isset($row['extra']['board_from'])) |
|
450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
451 | - if (isset($row['extra']['board'])) |
|
452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
457 | + if (isset($row['extra']['board_to'])) { |
|
458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
459 | + } |
|
460 | + if (isset($row['extra']['board_from'])) { |
|
461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
462 | + } |
|
463 | + if (isset($row['extra']['board'])) { |
|
464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
465 | + } |
|
453 | 466 | |
454 | 467 | // A message? |
455 | - if (isset($row['extra']['message'])) |
|
456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
468 | + if (isset($row['extra']['message'])) { |
|
469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
470 | + } |
|
457 | 471 | |
458 | 472 | // IP Info? |
459 | - if (isset($row['extra']['ip_range'])) |
|
460 | - if ($seeIP) |
|
473 | + if (isset($row['extra']['ip_range'])) { |
|
474 | + if ($seeIP) |
|
461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
462 | - else |
|
463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
476 | + } else { |
|
477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
478 | + } |
|
464 | 479 | |
465 | 480 | // Email? |
466 | - if (isset($row['extra']['email'])) |
|
467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
481 | + if (isset($row['extra']['email'])) { |
|
482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
483 | + } |
|
468 | 484 | |
469 | 485 | // Bans are complex. |
470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
471 | 487 | { |
472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
474 | - if (isset($row['extra'][$type])) |
|
489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
490 | + if (isset($row['extra'][$type])) |
|
475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
492 | + } |
|
476 | 493 | } |
477 | 494 | |
478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
508 | 525 | foreach ($boards[$row['id_board']] as $action) |
509 | 526 | { |
510 | 527 | // Make the board number into a link - dealing with moving too. |
511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
534 | + } |
|
517 | 535 | } |
518 | 536 | } |
519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
547 | 565 | ); |
548 | 566 | |
549 | 567 | // Make the topic number into a link - dealing with splitting too. |
550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
572 | + } |
|
554 | 573 | } |
555 | 574 | } |
556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
583 | 602 | ); |
584 | 603 | |
585 | 604 | // Make the message number into a link. |
586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
607 | + } |
|
588 | 608 | } |
589 | 609 | } |
590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
624 | 644 | foreach ($entries as $k => $entry) |
625 | 645 | { |
626 | 646 | // Make any message info links so its easier to go find that message. |
627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
649 | + } |
|
629 | 650 | |
630 | 651 | // Mark up any deleted members, topics and boards. |
631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
655 | + } |
|
634 | 656 | |
635 | 657 | if (isset($entry['extra']['report'])) |
636 | 658 | { |
637 | 659 | // Member profile reports go in a different area |
638 | - if (stristr($entry['action'], 'user_report')) |
|
639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
640 | - else |
|
641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
660 | + if (stristr($entry['action'], 'user_report')) { |
|
661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
662 | + } else { |
|
663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
664 | + } |
|
642 | 665 | } |
643 | 666 | |
644 | - if (empty($entries[$k]['action_text'])) |
|
645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
667 | + if (empty($entries[$k]['action_text'])) { |
|
668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
669 | + } |
|
646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
647 | 671 | function ($matches) use ($entries, $k) |
648 | 672 | { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
102 | 106 | list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
103 | 107 | |
104 | 108 | // That didn't work... Maybe it's using serialize? |
105 | - if (is_null($timeout)) |
|
106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
107 | - } |
|
108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | + if (is_null($timeout)) { |
|
110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
111 | + } |
|
112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | 113 | { |
110 | 114 | list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
111 | 115 | |
112 | 116 | // Try for old format |
113 | - if (is_null($timeout)) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
117 | + if (is_null($timeout)) { |
|
118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
119 | + } |
|
120 | + } else { |
|
121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
115 | 122 | } |
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
118 | 123 | |
119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -127,10 +132,11 @@ discard block |
||
127 | 132 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
128 | 133 | |
129 | 134 | // If we're preserving the cookie, reset it with updated salt |
130 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
131 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
132 | - else |
|
133 | - setTFACookie(-3600, 0, ''); |
|
135 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
136 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
137 | + } else { |
|
138 | + setTFACookie(-3600, 0, ''); |
|
139 | + } |
|
134 | 140 | } |
135 | 141 | |
136 | 142 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -141,20 +147,20 @@ discard block |
||
141 | 147 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
142 | 148 | { |
143 | 149 | // Strike! You're outta there! |
144 | - if ($_GET['member'] != $user_info['id']) |
|
145 | - fatal_lang_error('login_cookie_error', false); |
|
150 | + if ($_GET['member'] != $user_info['id']) { |
|
151 | + fatal_lang_error('login_cookie_error', false); |
|
152 | + } |
|
146 | 153 | |
147 | 154 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
148 | 155 | |
149 | 156 | // Some whitelisting for login_url... |
150 | - if (empty($_SESSION['login_url'])) |
|
151 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
152 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
157 | + if (empty($_SESSION['login_url'])) { |
|
158 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
159 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
153 | 160 | { |
154 | 161 | unset ($_SESSION['login_url']); |
155 | 162 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
156 | - } |
|
157 | - else |
|
163 | + } else |
|
158 | 164 | { |
159 | 165 | // Best not to clutter the session data too much... |
160 | 166 | $temp = $_SESSION['login_url']; |
@@ -165,8 +171,9 @@ discard block |
||
165 | 171 | } |
166 | 172 | |
167 | 173 | // Beyond this point you are assumed to be a guest trying to login. |
168 | - if (!$user_info['is_guest']) |
|
169 | - redirectexit(); |
|
174 | + if (!$user_info['is_guest']) { |
|
175 | + redirectexit(); |
|
176 | + } |
|
170 | 177 | |
171 | 178 | // Are you guessing with a script? |
172 | 179 | checkSession(); |
@@ -174,18 +181,21 @@ discard block |
||
174 | 181 | spamProtection('login'); |
175 | 182 | |
176 | 183 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
177 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
178 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
184 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
185 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
186 | + } |
|
179 | 187 | |
180 | 188 | // Been guessing a lot, haven't we? |
181 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
182 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
189 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
190 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
191 | + } |
|
183 | 192 | |
184 | 193 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
185 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
186 | - $modSettings['cookieTime'] = 3153600; |
|
187 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
188 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
194 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
195 | + $modSettings['cookieTime'] = 3153600; |
|
196 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
197 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
198 | + } |
|
189 | 199 | |
190 | 200 | loadLanguage('Login'); |
191 | 201 | // Load the template stuff. |
@@ -305,8 +315,9 @@ discard block |
||
305 | 315 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
306 | 316 | |
307 | 317 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
308 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
309 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
318 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
319 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
320 | + } |
|
310 | 321 | |
311 | 322 | // phpBB3 users new hashing. We now support it as well ;). |
312 | 323 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -326,27 +337,29 @@ discard block |
||
326 | 337 | // Some common md5 ones. |
327 | 338 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
328 | 339 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
329 | - } |
|
330 | - elseif (strlen($user_settings['passwd']) == 40) |
|
340 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
331 | 341 | { |
332 | 342 | // Maybe they are using a hash from before the password fix. |
333 | 343 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
334 | 344 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
335 | 345 | |
336 | 346 | // BurningBoard3 style of hashing. |
337 | - if (!empty($modSettings['enable_password_conversion'])) |
|
338 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
347 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
348 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
349 | + } |
|
339 | 350 | |
340 | 351 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
341 | 352 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
342 | 353 | { |
343 | 354 | // Try iconv first, for no particular reason. |
344 | - if (function_exists('iconv')) |
|
345 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
355 | + if (function_exists('iconv')) { |
|
356 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
357 | + } |
|
346 | 358 | |
347 | 359 | // Say it aint so, iconv failed! |
348 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
349 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
360 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
361 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
362 | + } |
|
350 | 363 | } |
351 | 364 | } |
352 | 365 | |
@@ -376,8 +389,9 @@ discard block |
||
376 | 389 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
377 | 390 | |
378 | 391 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
379 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
380 | - redirectexit('action=reminder'); |
|
392 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
393 | + redirectexit('action=reminder'); |
|
394 | + } |
|
381 | 395 | // We'll give you another chance... |
382 | 396 | else |
383 | 397 | { |
@@ -388,8 +402,7 @@ discard block |
||
388 | 402 | return; |
389 | 403 | } |
390 | 404 | } |
391 | - } |
|
392 | - elseif (!empty($user_settings['passwd_flood'])) |
|
405 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
393 | 406 | { |
394 | 407 | // Let's be sure they weren't a little hacker. |
395 | 408 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -406,8 +419,9 @@ discard block |
||
406 | 419 | } |
407 | 420 | |
408 | 421 | // Check their activation status. |
409 | - if (!checkActivation()) |
|
410 | - return; |
|
422 | + if (!checkActivation()) { |
|
423 | + return; |
|
424 | + } |
|
411 | 425 | |
412 | 426 | DoLogin(); |
413 | 427 | } |
@@ -419,8 +433,9 @@ discard block |
||
419 | 433 | { |
420 | 434 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
421 | 435 | |
422 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
423 | - fatal_lang_error('no_access', false); |
|
436 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
437 | + fatal_lang_error('no_access', false); |
|
438 | + } |
|
424 | 439 | |
425 | 440 | loadLanguage('Profile'); |
426 | 441 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -428,8 +443,9 @@ discard block |
||
428 | 443 | $member = $context['tfa_member']; |
429 | 444 | |
430 | 445 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
431 | - if (time() - $member['last_login'] < 120) |
|
432 | - fatal_lang_error('tfa_wait', false); |
|
446 | + if (time() - $member['last_login'] < 120) { |
|
447 | + fatal_lang_error('tfa_wait', false); |
|
448 | + } |
|
433 | 449 | |
434 | 450 | $totp = new \TOTP\Auth($member['tfa_secret']); |
435 | 451 | $totp->setRange(1); |
@@ -443,8 +459,9 @@ discard block |
||
443 | 459 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
444 | 460 | { |
445 | 461 | // Check to ensure we're forcing SSL for authentication |
446 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
447 | - fatal_lang_error('login_ssl_required'); |
|
462 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
463 | + fatal_lang_error('login_ssl_required'); |
|
464 | + } |
|
448 | 465 | |
449 | 466 | $code = $_POST['tfa_code']; |
450 | 467 | |
@@ -454,20 +471,19 @@ discard block |
||
454 | 471 | |
455 | 472 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
456 | 473 | redirectexit(); |
457 | - } |
|
458 | - else |
|
474 | + } else |
|
459 | 475 | { |
460 | 476 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
461 | 477 | |
462 | 478 | $context['tfa_error'] = true; |
463 | 479 | $context['tfa_value'] = $_POST['tfa_code']; |
464 | 480 | } |
465 | - } |
|
466 | - elseif (!empty($_POST['tfa_backup'])) |
|
481 | + } elseif (!empty($_POST['tfa_backup'])) |
|
467 | 482 | { |
468 | 483 | // Check to ensure we're forcing SSL for authentication |
469 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
470 | - fatal_lang_error('login_ssl_required'); |
|
484 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
485 | + fatal_lang_error('login_ssl_required'); |
|
486 | + } |
|
471 | 487 | |
472 | 488 | $backup = $_POST['tfa_backup']; |
473 | 489 | |
@@ -481,8 +497,7 @@ discard block |
||
481 | 497 | )); |
482 | 498 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
483 | 499 | redirectexit('action=profile;area=tfasetup;backup'); |
484 | - } |
|
485 | - else |
|
500 | + } else |
|
486 | 501 | { |
487 | 502 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
488 | 503 | |
@@ -505,8 +520,9 @@ discard block |
||
505 | 520 | { |
506 | 521 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
507 | 522 | |
508 | - if (!isset($context['login_errors'])) |
|
509 | - $context['login_errors'] = array(); |
|
523 | + if (!isset($context['login_errors'])) { |
|
524 | + $context['login_errors'] = array(); |
|
525 | + } |
|
510 | 526 | |
511 | 527 | // What is the true activation status of this account? |
512 | 528 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -518,8 +534,9 @@ discard block |
||
518 | 534 | return false; |
519 | 535 | } |
520 | 536 | // Awaiting approval still? |
521 | - elseif ($activation_status == 3) |
|
522 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
537 | + elseif ($activation_status == 3) { |
|
538 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
539 | + } |
|
523 | 540 | // Awaiting deletion, changed their mind? |
524 | 541 | elseif ($activation_status == 4) |
525 | 542 | { |
@@ -527,8 +544,7 @@ discard block |
||
527 | 544 | { |
528 | 545 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
529 | 546 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
530 | - } |
|
531 | - else |
|
547 | + } else |
|
532 | 548 | { |
533 | 549 | $context['disable_login_hashing'] = true; |
534 | 550 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
569 | 585 | |
570 | 586 | // Reset the login threshold. |
571 | - if (isset($_SESSION['failed_login'])) |
|
572 | - unset($_SESSION['failed_login']); |
|
587 | + if (isset($_SESSION['failed_login'])) { |
|
588 | + unset($_SESSION['failed_login']); |
|
589 | + } |
|
573 | 590 | |
574 | 591 | $user_info['is_guest'] = false; |
575 | 592 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -591,16 +608,18 @@ discard block |
||
591 | 608 | 'id_member' => $user_info['id'], |
592 | 609 | ) |
593 | 610 | ); |
594 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
595 | - $_SESSION['first_login'] = true; |
|
596 | - else |
|
597 | - unset($_SESSION['first_login']); |
|
611 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
612 | + $_SESSION['first_login'] = true; |
|
613 | + } else { |
|
614 | + unset($_SESSION['first_login']); |
|
615 | + } |
|
598 | 616 | $smcFunc['db_free_result']($request); |
599 | 617 | |
600 | 618 | // You've logged in, haven't you? |
601 | 619 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
602 | - if (empty($user_settings['tfa_secret'])) |
|
603 | - $update['last_login'] = time(); |
|
620 | + if (empty($user_settings['tfa_secret'])) { |
|
621 | + $update['last_login'] = time(); |
|
622 | + } |
|
604 | 623 | updateMemberData($user_info['id'], $update); |
605 | 624 | |
606 | 625 | // Get rid of the online entry for that old guest.... |
@@ -614,8 +633,8 @@ discard block |
||
614 | 633 | $_SESSION['log_time'] = 0; |
615 | 634 | |
616 | 635 | // Log this entry, only if we have it enabled. |
617 | - if (!empty($modSettings['loginHistoryDays'])) |
|
618 | - $smcFunc['db_insert']('insert', |
|
636 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
637 | + $smcFunc['db_insert']('insert', |
|
619 | 638 | '{db_prefix}member_logins', |
620 | 639 | array( |
621 | 640 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -627,13 +646,15 @@ discard block |
||
627 | 646 | 'id_member', 'time' |
628 | 647 | ) |
629 | 648 | ); |
649 | + } |
|
630 | 650 | |
631 | 651 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
632 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
633 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
634 | - else |
|
635 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
636 | -} |
|
652 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
653 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
654 | + } else { |
|
655 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
656 | + } |
|
657 | + } |
|
637 | 658 | |
638 | 659 | /** |
639 | 660 | * Logs the current user out of their account. |
@@ -649,13 +670,15 @@ discard block |
||
649 | 670 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
650 | 671 | |
651 | 672 | // Make sure they aren't being auto-logged out. |
652 | - if (!$internal) |
|
653 | - checkSession('get'); |
|
673 | + if (!$internal) { |
|
674 | + checkSession('get'); |
|
675 | + } |
|
654 | 676 | |
655 | 677 | require_once($sourcedir . '/Subs-Auth.php'); |
656 | 678 | |
657 | - if (isset($_SESSION['pack_ftp'])) |
|
658 | - $_SESSION['pack_ftp'] = null; |
|
679 | + if (isset($_SESSION['pack_ftp'])) { |
|
680 | + $_SESSION['pack_ftp'] = null; |
|
681 | + } |
|
659 | 682 | |
660 | 683 | // It won't be first login anymore. |
661 | 684 | unset($_SESSION['first_login']); |
@@ -683,8 +706,9 @@ discard block |
||
683 | 706 | |
684 | 707 | // And some other housekeeping while we're at it. |
685 | 708 | $salt = substr(md5(mt_rand()), 0, 4); |
686 | - if (!empty($user_info['id'])) |
|
687 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
709 | + if (!empty($user_info['id'])) { |
|
710 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
711 | + } |
|
688 | 712 | |
689 | 713 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
690 | 714 | { |
@@ -693,10 +717,11 @@ discard block |
||
693 | 717 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
694 | 718 | |
695 | 719 | // If we're preserving the cookie, reset it with updated salt |
696 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
697 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
698 | - else |
|
699 | - setTFACookie(-3600, 0, ''); |
|
720 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
721 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
722 | + } else { |
|
723 | + setTFACookie(-3600, 0, ''); |
|
724 | + } |
|
700 | 725 | } |
701 | 726 | |
702 | 727 | session_destroy(); |
@@ -704,14 +729,13 @@ discard block |
||
704 | 729 | // Off to the merry board index we go! |
705 | 730 | if ($redirect) |
706 | 731 | { |
707 | - if (empty($_SESSION['logout_url'])) |
|
708 | - redirectexit('', $context['server']['needs_login_fix']); |
|
709 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
732 | + if (empty($_SESSION['logout_url'])) { |
|
733 | + redirectexit('', $context['server']['needs_login_fix']); |
|
734 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
710 | 735 | { |
711 | 736 | unset ($_SESSION['logout_url']); |
712 | 737 | redirectexit(); |
713 | - } |
|
714 | - else |
|
738 | + } else |
|
715 | 739 | { |
716 | 740 | $temp = $_SESSION['logout_url']; |
717 | 741 | unset($_SESSION['logout_url']); |
@@ -744,8 +768,9 @@ discard block |
||
744 | 768 | function phpBB3_password_check($passwd, $passwd_hash) |
745 | 769 | { |
746 | 770 | // Too long or too short? |
747 | - if (strlen($passwd_hash) != 34) |
|
748 | - return; |
|
771 | + if (strlen($passwd_hash) != 34) { |
|
772 | + return; |
|
773 | + } |
|
749 | 774 | |
750 | 775 | // Range of characters allowed. |
751 | 776 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -756,8 +781,9 @@ discard block |
||
756 | 781 | $salt = substr($passwd_hash, 4, 8); |
757 | 782 | |
758 | 783 | $hash = md5($salt . $passwd, true); |
759 | - for (; $count != 0; --$count) |
|
760 | - $hash = md5($hash . $passwd, true); |
|
784 | + for (; $count != 0; --$count) { |
|
785 | + $hash = md5($hash . $passwd, true); |
|
786 | + } |
|
761 | 787 | |
762 | 788 | $output = substr($passwd_hash, 0, 12); |
763 | 789 | $i = 0; |
@@ -766,21 +792,25 @@ discard block |
||
766 | 792 | $value = ord($hash[$i++]); |
767 | 793 | $output .= $range[$value & 0x3f]; |
768 | 794 | |
769 | - if ($i < 16) |
|
770 | - $value |= ord($hash[$i]) << 8; |
|
795 | + if ($i < 16) { |
|
796 | + $value |= ord($hash[$i]) << 8; |
|
797 | + } |
|
771 | 798 | |
772 | 799 | $output .= $range[($value >> 6) & 0x3f]; |
773 | 800 | |
774 | - if ($i++ >= 16) |
|
775 | - break; |
|
801 | + if ($i++ >= 16) { |
|
802 | + break; |
|
803 | + } |
|
776 | 804 | |
777 | - if ($i < 16) |
|
778 | - $value |= ord($hash[$i]) << 16; |
|
805 | + if ($i < 16) { |
|
806 | + $value |= ord($hash[$i]) << 16; |
|
807 | + } |
|
779 | 808 | |
780 | 809 | $output .= $range[($value >> 12) & 0x3f]; |
781 | 810 | |
782 | - if ($i++ >= 16) |
|
783 | - break; |
|
811 | + if ($i++ >= 16) { |
|
812 | + break; |
|
813 | + } |
|
784 | 814 | |
785 | 815 | $output .= $range[($value >> 18) & 0x3f]; |
786 | 816 | } |
@@ -812,8 +842,9 @@ discard block |
||
812 | 842 | require_once($sourcedir . '/Subs-Auth.php'); |
813 | 843 | setLoginCookie(-3600, 0); |
814 | 844 | |
815 | - if (isset($_SESSION['login_' . $cookiename])) |
|
816 | - unset($_SESSION['login_' . $cookiename]); |
|
845 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
846 | + unset($_SESSION['login_' . $cookiename]); |
|
847 | + } |
|
817 | 848 | } |
818 | 849 | |
819 | 850 | // We need a member! |
@@ -827,8 +858,9 @@ discard block |
||
827 | 858 | } |
828 | 859 | |
829 | 860 | // Right, have we got a flood value? |
830 | - if ($password_flood_value !== false) |
|
831 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
861 | + if ($password_flood_value !== false) { |
|
862 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
863 | + } |
|
832 | 864 | |
833 | 865 | // Timestamp or number of tries invalid? |
834 | 866 | if (empty($number_tries) || empty($time_stamp)) |
@@ -844,15 +876,17 @@ discard block |
||
844 | 876 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
845 | 877 | |
846 | 878 | // They are trying too fast, make them wait longer |
847 | - if ($time_stamp < time() - 10) |
|
848 | - $time_stamp = time(); |
|
879 | + if ($time_stamp < time() - 10) { |
|
880 | + $time_stamp = time(); |
|
881 | + } |
|
849 | 882 | } |
850 | 883 | |
851 | 884 | $number_tries++; |
852 | 885 | |
853 | 886 | // Broken the law? |
854 | - if ($number_tries > 5) |
|
855 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
887 | + if ($number_tries > 5) { |
|
888 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
889 | + } |
|
856 | 890 | |
857 | 891 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
858 | 892 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -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 entrance point for the Manage Members screen. |
@@ -62,16 +63,18 @@ discard block |
||
62 | 63 | $context['activation_numbers'] = array(); |
63 | 64 | $context['awaiting_activation'] = 0; |
64 | 65 | $context['awaiting_approval'] = 0; |
65 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
66 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
66 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
67 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
68 | + } |
|
67 | 69 | $smcFunc['db_free_result']($request); |
68 | 70 | |
69 | 71 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
70 | 72 | { |
71 | - if (in_array($activation_type, array(0, 2))) |
|
72 | - $context['awaiting_activation'] += $total_members; |
|
73 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
74 | - $context['awaiting_approval'] += $total_members; |
|
73 | + if (in_array($activation_type, array(0, 2))) { |
|
74 | + $context['awaiting_activation'] += $total_members; |
|
75 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
76 | + $context['awaiting_approval'] += $total_members; |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | // For the page header... do we show activation? |
@@ -124,8 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve')) |
126 | 129 | { |
127 | - if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) |
|
128 | - $context['tabs']['search']['is_last'] = true; |
|
130 | + if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) { |
|
131 | + $context['tabs']['search']['is_last'] = true; |
|
132 | + } |
|
129 | 133 | unset($context['tabs']['approve']); |
130 | 134 | } |
131 | 135 | |
@@ -157,8 +161,9 @@ discard block |
||
157 | 161 | foreach ($_POST['delete'] as $key => $value) |
158 | 162 | { |
159 | 163 | // Don't delete yourself, idiot. |
160 | - if ($value != $user_info['id']) |
|
161 | - $delete[$key] = (int) $value; |
|
164 | + if ($value != $user_info['id']) { |
|
165 | + $delete[$key] = (int) $value; |
|
166 | + } |
|
162 | 167 | } |
163 | 168 | |
164 | 169 | if (!empty($delete)) |
@@ -194,17 +199,18 @@ discard block |
||
194 | 199 | ); |
195 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
196 | 201 | { |
197 | - if ($row['min_posts'] == -1) |
|
198 | - $context['membergroups'][] = array( |
|
202 | + if ($row['min_posts'] == -1) { |
|
203 | + $context['membergroups'][] = array( |
|
199 | 204 | 'id' => $row['id_group'], |
200 | 205 | 'name' => $row['group_name'], |
201 | 206 | 'can_be_additional' => true |
202 | 207 | ); |
203 | - else |
|
204 | - $context['postgroups'][] = array( |
|
208 | + } else { |
|
209 | + $context['postgroups'][] = array( |
|
205 | 210 | 'id' => $row['id_group'], |
206 | 211 | 'name' => $row['group_name'] |
207 | 212 | ); |
213 | + } |
|
208 | 214 | } |
209 | 215 | $smcFunc['db_free_result']($request); |
210 | 216 | |
@@ -268,14 +274,15 @@ discard block |
||
268 | 274 | call_integration_hook('integrate_view_members_params', array(&$params)); |
269 | 275 | |
270 | 276 | $search_params = array(); |
271 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
272 | - $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
273 | - elseif (!empty($_POST)) |
|
277 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
278 | + $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
279 | + } elseif (!empty($_POST)) |
|
274 | 280 | { |
275 | 281 | $search_params['types'] = $_POST['types']; |
276 | - foreach ($params as $param_name => $param_info) |
|
277 | - if (isset($_POST[$param_name])) |
|
282 | + foreach ($params as $param_name => $param_info) { |
|
283 | + if (isset($_POST[$param_name])) |
|
278 | 284 | $search_params[$param_name] = $_POST[$param_name]; |
285 | + } |
|
279 | 286 | } |
280 | 287 | |
281 | 288 | $search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null; |
@@ -288,18 +295,21 @@ discard block |
||
288 | 295 | foreach ($params as $param_name => $param_info) |
289 | 296 | { |
290 | 297 | // Not filled in? |
291 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
292 | - continue; |
|
298 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
299 | + continue; |
|
300 | + } |
|
293 | 301 | |
294 | 302 | // Make sure numeric values are really numeric. |
295 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
296 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
303 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
304 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
305 | + } |
|
297 | 306 | // Date values have to match the specified format. |
298 | 307 | elseif ($param_info['type'] == 'date') |
299 | 308 | { |
300 | 309 | // Check if this date format is valid. |
301 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
302 | - continue; |
|
310 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
311 | + continue; |
|
312 | + } |
|
303 | 313 | |
304 | 314 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
305 | 315 | } |
@@ -308,8 +318,9 @@ discard block |
||
308 | 318 | if (!empty($param_info['range'])) |
309 | 319 | { |
310 | 320 | // Default to '=', just in case... |
311 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
312 | - $search_params['types'][$param_name] = '='; |
|
321 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
322 | + $search_params['types'][$param_name] = '='; |
|
323 | + } |
|
313 | 324 | |
314 | 325 | // Handle special case 'age'. |
315 | 326 | if ($param_info['type'] == 'age') |
@@ -337,29 +348,30 @@ discard block |
||
337 | 348 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
338 | 349 | { |
339 | 350 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
351 | + } else { |
|
352 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
340 | 353 | } |
341 | - else |
|
342 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
343 | 354 | } |
344 | 355 | // Checkboxes. |
345 | 356 | elseif ($param_info['type'] == 'checkbox') |
346 | 357 | { |
347 | 358 | // Each checkbox or no checkbox at all is checked -> ignore. |
348 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
349 | - continue; |
|
359 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
360 | + continue; |
|
361 | + } |
|
350 | 362 | |
351 | 363 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
352 | 364 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
353 | - } |
|
354 | - else |
|
365 | + } else |
|
355 | 366 | { |
356 | 367 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
357 | 368 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
358 | 369 | |
359 | - if ($smcFunc['db_case_sensitive']) |
|
360 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
361 | - else |
|
362 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
370 | + if ($smcFunc['db_case_sensitive']) { |
|
371 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
372 | + } else { |
|
373 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
374 | + } |
|
363 | 375 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
364 | 376 | } |
365 | 377 | } |
@@ -375,16 +387,18 @@ discard block |
||
375 | 387 | } |
376 | 388 | |
377 | 389 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
378 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
379 | - foreach ($search_params['membergroups'][2] as $mg) |
|
390 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
391 | + foreach ($search_params['membergroups'][2] as $mg) |
|
380 | 392 | { |
381 | 393 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
394 | + } |
|
382 | 395 | $where_params['add_group_' . $mg] = $mg; |
383 | 396 | } |
384 | 397 | |
385 | 398 | // Combine the one or two membergroup parts into one query part linked with an OR. |
386 | - if (!empty($mg_query_parts)) |
|
387 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
399 | + if (!empty($mg_query_parts)) { |
|
400 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
401 | + } |
|
388 | 402 | |
389 | 403 | // Get all selected post count related membergroups. |
390 | 404 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -396,9 +410,9 @@ discard block |
||
396 | 410 | // Construct the where part of the query. |
397 | 411 | $where = empty($query_parts) ? '1=1' : implode(' |
398 | 412 | AND ', $query_parts); |
413 | + } else { |
|
414 | + $search_url_params = null; |
|
399 | 415 | } |
400 | - else |
|
401 | - $search_url_params = null; |
|
402 | 416 | |
403 | 417 | // Construct the additional URL part with the query info in it. |
404 | 418 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -521,28 +535,32 @@ discard block |
||
521 | 535 | 'function' => function($rowData) use ($txt) |
522 | 536 | { |
523 | 537 | // Calculate number of days since last online. |
524 | - if (empty($rowData['last_login'])) |
|
525 | - $difference = $txt['never']; |
|
526 | - else |
|
538 | + if (empty($rowData['last_login'])) { |
|
539 | + $difference = $txt['never']; |
|
540 | + } else |
|
527 | 541 | { |
528 | 542 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
529 | 543 | |
530 | 544 | // Today. |
531 | - if (empty($num_days_difference)) |
|
532 | - $difference = $txt['viewmembers_today']; |
|
545 | + if (empty($num_days_difference)) { |
|
546 | + $difference = $txt['viewmembers_today']; |
|
547 | + } |
|
533 | 548 | |
534 | 549 | // Yesterday. |
535 | - elseif ($num_days_difference == 1) |
|
536 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
550 | + elseif ($num_days_difference == 1) { |
|
551 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
552 | + } |
|
537 | 553 | |
538 | 554 | // X days ago. |
539 | - else |
|
540 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
555 | + else { |
|
556 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
557 | + } |
|
541 | 558 | } |
542 | 559 | |
543 | 560 | // Show it in italics if they're not activated... |
544 | - if ($rowData['is_activated'] % 10 != 1) |
|
545 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
561 | + if ($rowData['is_activated'] % 10 != 1) { |
|
562 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
563 | + } |
|
546 | 564 | |
547 | 565 | return $difference; |
548 | 566 | }, |
@@ -594,8 +612,9 @@ discard block |
||
594 | 612 | ); |
595 | 613 | |
596 | 614 | // Without enough permissions, don't show 'delete members' checkboxes. |
597 | - if (!allowedTo('profile_remove_any')) |
|
598 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
615 | + if (!allowedTo('profile_remove_any')) { |
|
616 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
617 | + } |
|
599 | 618 | |
600 | 619 | require_once($sourcedir . '/Subs-List.php'); |
601 | 620 | createList($listOptions); |
@@ -638,17 +657,18 @@ discard block |
||
638 | 657 | ); |
639 | 658 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
640 | 659 | { |
641 | - if ($row['min_posts'] == -1) |
|
642 | - $context['membergroups'][] = array( |
|
660 | + if ($row['min_posts'] == -1) { |
|
661 | + $context['membergroups'][] = array( |
|
643 | 662 | 'id' => $row['id_group'], |
644 | 663 | 'name' => $row['group_name'], |
645 | 664 | 'can_be_additional' => true |
646 | 665 | ); |
647 | - else |
|
648 | - $context['postgroups'][] = array( |
|
666 | + } else { |
|
667 | + $context['postgroups'][] = array( |
|
649 | 668 | 'id' => $row['id_group'], |
650 | 669 | 'name' => $row['group_name'] |
651 | 670 | ); |
671 | + } |
|
652 | 672 | } |
653 | 673 | $smcFunc['db_free_result']($request); |
654 | 674 | |
@@ -675,8 +695,9 @@ discard block |
||
675 | 695 | $context['page_title'] = $txt['admin_members']; |
676 | 696 | $context['sub_template'] = 'admin_browse'; |
677 | 697 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
678 | - if (isset($context['tabs'][$context['browse_type']])) |
|
679 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
698 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
699 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
700 | + } |
|
680 | 701 | |
681 | 702 | // Allowed filters are those we can have, in theory. |
682 | 703 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -687,18 +708,20 @@ discard block |
||
687 | 708 | foreach ($context['activation_numbers'] as $type => $amount) |
688 | 709 | { |
689 | 710 | // We have some of these... |
690 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
691 | - $context['available_filters'][] = array( |
|
711 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
712 | + $context['available_filters'][] = array( |
|
692 | 713 | 'type' => $type, |
693 | 714 | 'amount' => $amount, |
694 | 715 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
695 | 716 | 'selected' => $type == $context['current_filter'] |
696 | 717 | ); |
718 | + } |
|
697 | 719 | } |
698 | 720 | |
699 | 721 | // If the filter was not sent, set it to whatever has people in it! |
700 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
701 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
722 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
723 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
724 | + } |
|
702 | 725 | |
703 | 726 | // This little variable is used to determine if we should flag where we are looking. |
704 | 727 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -713,44 +736,47 @@ discard block |
||
713 | 736 | ); |
714 | 737 | |
715 | 738 | // Are we showing duplicate information? |
716 | - if (isset($_GET['showdupes'])) |
|
717 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
739 | + if (isset($_GET['showdupes'])) { |
|
740 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
741 | + } |
|
718 | 742 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
719 | 743 | |
720 | 744 | // Determine which actions we should allow on this page. |
721 | 745 | if ($context['browse_type'] == 'approve') |
722 | 746 | { |
723 | 747 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
724 | - if ($context['current_filter'] == 4) |
|
725 | - $context['allowed_actions'] = array( |
|
748 | + if ($context['current_filter'] == 4) { |
|
749 | + $context['allowed_actions'] = array( |
|
726 | 750 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
727 | 751 | 'ok' => $txt['admin_browse_w_reject'], |
728 | 752 | ); |
729 | - else |
|
730 | - $context['allowed_actions'] = array( |
|
753 | + } else { |
|
754 | + $context['allowed_actions'] = array( |
|
731 | 755 | 'ok' => $txt['admin_browse_w_approve'], |
732 | 756 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
733 | 757 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
734 | 758 | 'reject' => $txt['admin_browse_w_reject'], |
735 | 759 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
736 | 760 | ); |
737 | - } |
|
738 | - elseif ($context['browse_type'] == 'activate') |
|
739 | - $context['allowed_actions'] = array( |
|
761 | + } |
|
762 | + } elseif ($context['browse_type'] == 'activate') { |
|
763 | + $context['allowed_actions'] = array( |
|
740 | 764 | 'ok' => $txt['admin_browse_w_activate'], |
741 | 765 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
742 | 766 | 'delete' => $txt['admin_browse_w_delete'], |
743 | 767 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
744 | 768 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
745 | 769 | ); |
770 | + } |
|
746 | 771 | |
747 | 772 | // Create an option list for actions allowed to be done with selected members. |
748 | 773 | $allowed_actions = ' |
749 | 774 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
750 | 775 | <option value="" disabled>-----------------------------</option>'; |
751 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
752 | - $allowed_actions .= ' |
|
776 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
777 | + $allowed_actions .= ' |
|
753 | 778 | <option value="' . $key . '">' . $desc . '</option>'; |
779 | + } |
|
754 | 780 | |
755 | 781 | // Setup the Javascript function for selecting an action for the list. |
756 | 782 | $javascript = ' |
@@ -762,15 +788,16 @@ discard block |
||
762 | 788 | var message = "";'; |
763 | 789 | |
764 | 790 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
765 | - if ($context['current_filter'] == 4) |
|
766 | - $javascript .= ' |
|
791 | + if ($context['current_filter'] == 4) { |
|
792 | + $javascript .= ' |
|
767 | 793 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
768 | 794 | message = "' . $txt['admin_browse_w_delete'] . '"; |
769 | 795 | else |
770 | 796 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
797 | + } |
|
771 | 798 | // Otherwise a nice standard message. |
772 | - else |
|
773 | - $javascript .= ' |
|
799 | + else { |
|
800 | + $javascript .= ' |
|
774 | 801 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
775 | 802 | message = "' . $txt['admin_browse_w_delete'] . '"; |
776 | 803 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -779,6 +806,7 @@ discard block |
||
779 | 806 | message = "' . $txt['admin_browse_w_remind'] . '"; |
780 | 807 | else |
781 | 808 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
809 | + } |
|
782 | 810 | $javascript .= ' |
783 | 811 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
784 | 812 | document.forms.postForm.submit(); |
@@ -911,10 +939,11 @@ discard block |
||
911 | 939 | $member_links = array(); |
912 | 940 | foreach ($rowData['duplicate_members'] as $member) |
913 | 941 | { |
914 | - if ($member['id']) |
|
915 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
916 | - else |
|
917 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
942 | + if ($member['id']) { |
|
943 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
944 | + } else { |
|
945 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
946 | + } |
|
918 | 947 | } |
919 | 948 | return implode(', ', $member_links); |
920 | 949 | }, |
@@ -963,14 +992,16 @@ discard block |
||
963 | 992 | ); |
964 | 993 | |
965 | 994 | // Pick what column to actually include if we're showing duplicates. |
966 | - if ($context['show_duplicates']) |
|
967 | - unset($listOptions['columns']['email']); |
|
968 | - else |
|
969 | - unset($listOptions['columns']['duplicates']); |
|
995 | + if ($context['show_duplicates']) { |
|
996 | + unset($listOptions['columns']['email']); |
|
997 | + } else { |
|
998 | + unset($listOptions['columns']['duplicates']); |
|
999 | + } |
|
970 | 1000 | |
971 | 1001 | // Only show hostname on duplicates as it takes a lot of time. |
972 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
973 | - unset($listOptions['columns']['hostname']); |
|
1002 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
1003 | + unset($listOptions['columns']['hostname']); |
|
1004 | + } |
|
974 | 1005 | |
975 | 1006 | // Is there any need to show filters? |
976 | 1007 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -978,9 +1009,10 @@ discard block |
||
978 | 1009 | $filterOptions = ' |
979 | 1010 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
980 | 1011 | <select name="filter" onchange="this.form.submit();">'; |
981 | - foreach ($context['available_filters'] as $filter) |
|
982 | - $filterOptions .= ' |
|
1012 | + foreach ($context['available_filters'] as $filter) { |
|
1013 | + $filterOptions .= ' |
|
983 | 1014 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
1015 | + } |
|
984 | 1016 | $filterOptions .= ' |
985 | 1017 | </select> |
986 | 1018 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>'; |
@@ -992,12 +1024,13 @@ discard block |
||
992 | 1024 | } |
993 | 1025 | |
994 | 1026 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
995 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
996 | - $listOptions['additional_rows'][] = array( |
|
1027 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
1028 | + $listOptions['additional_rows'][] = array( |
|
997 | 1029 | 'position' => 'above_column_headers', |
998 | 1030 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
999 | 1031 | 'class' => 'smalltext floatright', |
1000 | 1032 | ); |
1033 | + } |
|
1001 | 1034 | |
1002 | 1035 | // Now that we have all the options, create the list. |
1003 | 1036 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1027,12 +1060,14 @@ discard block |
||
1027 | 1060 | $current_filter = (int) $_REQUEST['orig_filter']; |
1028 | 1061 | |
1029 | 1062 | // If we are applying a filter do just that - then redirect. |
1030 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
1031 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1063 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
1064 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1065 | + } |
|
1032 | 1066 | |
1033 | 1067 | // Nothing to do? |
1034 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
1035 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1068 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
1069 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1070 | + } |
|
1036 | 1071 | |
1037 | 1072 | // Are we dealing with members who have been waiting for > set amount of time? |
1038 | 1073 | if (isset($_POST['time_passed'])) |
@@ -1045,8 +1080,9 @@ discard block |
||
1045 | 1080 | else |
1046 | 1081 | { |
1047 | 1082 | $members = array(); |
1048 | - foreach ($_POST['todoAction'] as $id) |
|
1049 | - $members[] = (int) $id; |
|
1083 | + foreach ($_POST['todoAction'] as $id) { |
|
1084 | + $members[] = (int) $id; |
|
1085 | + } |
|
1050 | 1086 | $condition = ' |
1051 | 1087 | AND id_member IN ({array_int:members})'; |
1052 | 1088 | } |
@@ -1067,8 +1103,9 @@ discard block |
||
1067 | 1103 | $member_count = $smcFunc['db_num_rows']($request); |
1068 | 1104 | |
1069 | 1105 | // If no results then just return! |
1070 | - if ($member_count == 0) |
|
1071 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1106 | + if ($member_count == 0) { |
|
1107 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1108 | + } |
|
1072 | 1109 | |
1073 | 1110 | $member_info = array(); |
1074 | 1111 | $members = array(); |
@@ -1107,8 +1144,9 @@ discard block |
||
1107 | 1144 | // Do we have to let the integration code know about the activations? |
1108 | 1145 | if (!empty($modSettings['integrate_activate'])) |
1109 | 1146 | { |
1110 | - foreach ($member_info as $member) |
|
1111 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
1147 | + foreach ($member_info as $member) { |
|
1148 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
1149 | + } |
|
1112 | 1150 | } |
1113 | 1151 | |
1114 | 1152 | // Check for email. |
@@ -1238,20 +1276,23 @@ discard block |
||
1238 | 1276 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
1239 | 1277 | |
1240 | 1278 | require_once($sourcedir . '/Logging.php'); |
1241 | - foreach ($member_info as $member) |
|
1242 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1279 | + foreach ($member_info as $member) { |
|
1280 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1281 | + } |
|
1243 | 1282 | } |
1244 | 1283 | |
1245 | 1284 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
1246 | - if (in_array($current_filter, array(3, 4, 5))) |
|
1247 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1285 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
1286 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1287 | + } |
|
1248 | 1288 | |
1249 | 1289 | // Update the member's stats. (but, we know the member didn't change their name.) |
1250 | 1290 | updateStats('member', false); |
1251 | 1291 | |
1252 | 1292 | // If they haven't been deleted, update the post group statistics on them... |
1253 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
1254 | - updateStats('postgroups', $members); |
|
1293 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
1294 | + updateStats('postgroups', $members); |
|
1295 | + } |
|
1255 | 1296 | |
1256 | 1297 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
1257 | 1298 | } |
@@ -1276,10 +1317,11 @@ discard block |
||
1276 | 1317 | $dis = time() - $old; |
1277 | 1318 | |
1278 | 1319 | // Before midnight? |
1279 | - if ($dis < $sinceMidnight) |
|
1280 | - return 0; |
|
1281 | - else |
|
1282 | - $dis -= $sinceMidnight; |
|
1320 | + if ($dis < $sinceMidnight) { |
|
1321 | + return 0; |
|
1322 | + } else { |
|
1323 | + $dis -= $sinceMidnight; |
|
1324 | + } |
|
1283 | 1325 | |
1284 | 1326 | // Divide out the seconds in a day to get the number of days. |
1285 | 1327 | return ceil($dis / (24 * 60 * 60)); |
@@ -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 | * Class Likes |
@@ -106,8 +107,9 @@ discard block |
||
106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
107 | 108 | |
108 | 109 | // We do not want to output debug information here. |
109 | - if ($this->_js) |
|
110 | - $db_show_debug = false; |
|
110 | + if ($this->_js) { |
|
111 | + $db_show_debug = false; |
|
112 | + } |
|
111 | 113 | } |
112 | 114 | |
113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
141 | 143 | $call = $this->_sa; |
142 | 144 | |
143 | 145 | // Guest can only view likes. |
144 | - if ($call != 'view') |
|
145 | - is_not_guest(); |
|
146 | + if ($call != 'view') { |
|
147 | + is_not_guest(); |
|
148 | + } |
|
146 | 149 | |
147 | 150 | checkSession('get'); |
148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
180 | 183 | global $smcFunc, $modSettings; |
181 | 184 | |
182 | 185 | // This feature is currently disable. |
183 | - if (empty($modSettings['enable_likes'])) |
|
184 | - return $this->_error = 'like_disable'; |
|
186 | + if (empty($modSettings['enable_likes'])) { |
|
187 | + return $this->_error = 'like_disable'; |
|
188 | + } |
|
185 | 189 | |
186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
189 | 193 | |
190 | - if ($this->_type == '' || $this->_content <= 0) |
|
191 | - return $this->_error = 'cannot_'; |
|
194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
195 | + return $this->_error = 'cannot_'; |
|
196 | + } |
|
192 | 197 | |
193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
207 | 212 | 'msg' => $this->_content, |
208 | 213 | ) |
209 | 214 | ); |
210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
217 | + } |
|
212 | 218 | |
213 | 219 | $smcFunc['db_free_result']($request); |
214 | - if (empty($this->_idTopic)) |
|
215 | - return $this->_error = 'cannot_'; |
|
220 | + if (empty($this->_idTopic)) { |
|
221 | + return $this->_error = 'cannot_'; |
|
222 | + } |
|
216 | 223 | |
217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
222 | 229 | |
223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
224 | - } |
|
225 | - |
|
226 | - else |
|
231 | + } else |
|
227 | 232 | { |
228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
241 | 246 | if ($result !== false) |
242 | 247 | { |
243 | 248 | // Match the type with what we already have. |
244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
245 | - return $this->_error = 'not_valid_like_type'; |
|
249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
250 | + return $this->_error = 'not_valid_like_type'; |
|
251 | + } |
|
246 | 252 | |
247 | 253 | // Fill out the rest. |
248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
253 | 259 | } |
254 | 260 | } |
255 | 261 | |
256 | - if (!$found) |
|
257 | - return $this->_error = 'cannot_'; |
|
262 | + if (!$found) { |
|
263 | + return $this->_error = 'cannot_'; |
|
264 | + } |
|
258 | 265 | } |
259 | 266 | |
260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
262 | - return $this->_error = $this->_validLikes['can_like']; |
|
268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
269 | + return $this->_error = $this->_validLikes['can_like']; |
|
270 | + } |
|
263 | 271 | } |
264 | 272 | |
265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
284 | 292 | ); |
285 | 293 | |
286 | 294 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
287 | - if ($this->_sa == __FUNCTION__) |
|
288 | - $this->_data = __FUNCTION__; |
|
295 | + if ($this->_sa == __FUNCTION__) { |
|
296 | + $this->_data = __FUNCTION__; |
|
297 | + } |
|
289 | 298 | } |
290 | 299 | |
291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
315 | 324 | |
316 | 325 | // Add a background task to process sending alerts. |
317 | 326 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
318 | - if ($this->_type == 'msg') |
|
319 | - $smcFunc['db_insert']('insert', |
|
327 | + if ($this->_type == 'msg') { |
|
328 | + $smcFunc['db_insert']('insert', |
|
320 | 329 | '{db_prefix}background_tasks', |
321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
328 | 337 | )), 0), |
329 | 338 | array('id_task') |
330 | 339 | ); |
340 | + } |
|
331 | 341 | |
332 | 342 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
333 | - if ($this->_sa == __FUNCTION__) |
|
334 | - $this->_data = __FUNCTION__; |
|
343 | + if ($this->_sa == __FUNCTION__) { |
|
344 | + $this->_data = __FUNCTION__; |
|
345 | + } |
|
335 | 346 | } |
336 | 347 | |
337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
357 | 368 | $smcFunc['db_free_result']($request); |
358 | 369 | |
359 | 370 | // If you want to call this directly, fill out _data property too. |
360 | - if ($this->_sa == __FUNCTION__) |
|
361 | - $this->_data = $this->_numLikes; |
|
371 | + if ($this->_sa == __FUNCTION__) { |
|
372 | + $this->_data = $this->_numLikes; |
|
373 | + } |
|
362 | 374 | } |
363 | 375 | |
364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
371 | 383 | global $smcFunc; |
372 | 384 | |
373 | 385 | // Safety first! |
374 | - if (empty($this->_type) || empty($this->_content)) |
|
375 | - return $this->_error = 'cannot_'; |
|
386 | + if (empty($this->_type) || empty($this->_content)) { |
|
387 | + return $this->_error = 'cannot_'; |
|
388 | + } |
|
376 | 389 | |
377 | 390 | // Do we already like this? |
378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
391 | 404 | $smcFunc['db_free_result']($request); |
392 | 405 | |
393 | - if ($this->_alreadyLiked) |
|
394 | - $this->delete(); |
|
395 | - |
|
396 | - else |
|
397 | - $this->insert(); |
|
406 | + if ($this->_alreadyLiked) { |
|
407 | + $this->delete(); |
|
408 | + } else { |
|
409 | + $this->insert(); |
|
410 | + } |
|
398 | 411 | |
399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
400 | 413 | $this->_count(); |
401 | 414 | |
402 | 415 | // Update the likes count for messages. |
403 | - if ($this->_type == 'msg') |
|
404 | - $this->msgIssueLike(); |
|
416 | + if ($this->_type == 'msg') { |
|
417 | + $this->msgIssueLike(); |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Any callbacks? |
407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
408 | 422 | { |
409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
410 | 424 | |
411 | - if (!empty($call)) |
|
412 | - call_user_func_array($call, array($this)); |
|
425 | + if (!empty($call)) { |
|
426 | + call_user_func_array($call, array($this)); |
|
427 | + } |
|
413 | 428 | } |
414 | 429 | |
415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
438 | + } |
|
423 | 439 | |
424 | 440 | // All done, start building the data to pass as response. |
425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
442 | 458 | { |
443 | 459 | global $smcFunc; |
444 | 460 | |
445 | - if ($this->_type !== 'msg') |
|
446 | - return; |
|
461 | + if ($this->_type !== 'msg') { |
|
462 | + return; |
|
463 | + } |
|
447 | 464 | |
448 | 465 | $smcFunc['db_query']('', ' |
449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
484 | 501 | 'like_type' => $this->_type, |
485 | 502 | ) |
486 | 503 | ); |
487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
506 | + } |
|
489 | 507 | |
490 | 508 | // Now to get member data, including avatars and so on. |
491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
493 | 511 | if (count($loaded) != count($members)) |
494 | 512 | { |
495 | 513 | $members = array_diff($members, $loaded); |
496 | - foreach ($members as $not_loaded) |
|
497 | - unset ($context['likers'][$not_loaded]); |
|
514 | + foreach ($members as $not_loaded) { |
|
515 | + unset ($context['likers'][$not_loaded]); |
|
516 | + } |
|
498 | 517 | } |
499 | 518 | |
500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
536 | 555 | global $context, $txt; |
537 | 556 | |
538 | 557 | // Don't do anything if someone else has already take care of the response. |
539 | - if (!$this->_setResponse) |
|
540 | - return; |
|
558 | + if (!$this->_setResponse) { |
|
559 | + return; |
|
560 | + } |
|
541 | 561 | |
542 | 562 | // Want a json response huh? |
543 | - if ($this->_validLikes['json']) |
|
544 | - return $this->jsonResponse(); |
|
563 | + if ($this->_validLikes['json']) { |
|
564 | + return $this->jsonResponse(); |
|
565 | + } |
|
545 | 566 | |
546 | 567 | // Set everything up for display. |
547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
551 | 572 | if ($this->_error) |
552 | 573 | { |
553 | 574 | // If this is a generic error, set it up good. |
554 | - if ($this->_error == 'cannot_') |
|
555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
575 | + if ($this->_error == 'cannot_') { |
|
576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
577 | + } |
|
556 | 578 | |
557 | 579 | // Is this request coming from an ajax call? |
558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
562 | 584 | } |
563 | 585 | |
564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
565 | - else |
|
566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
587 | + else { |
|
588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
589 | + } |
|
567 | 590 | |
568 | 591 | return; |
569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
572 | 595 | else |
573 | 596 | { |
574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
575 | - if (!$this->_js) |
|
576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
598 | + if (!$this->_js) { |
|
599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
600 | + } |
|
577 | 601 | |
578 | 602 | // These fine gentlemen all share the same template. |
579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
606 | 630 | // If there is an error, send it. |
607 | 631 | if ($this->_error) |
608 | 632 | { |
609 | - if ($this->_error == 'cannot_') |
|
610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
633 | + if ($this->_error == 'cannot_') { |
|
634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
635 | + } |
|
611 | 636 | |
612 | 637 | $print['error'] = $this->_error; |
613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
645 | 670 | |
646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
647 | - $_GET['verse'] = '4:16'; |
|
671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
672 | + $_GET['verse'] = '4:16'; |
|
673 | + } |
|
648 | 674 | |
649 | - if ($_GET['verse'] == '2:18') |
|
650 | - echo ' |
|
675 | + if ($_GET['verse'] == '2:18') { |
|
676 | + echo ' |
|
651 | 677 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
652 | - elseif ($_GET['verse'] == '4:16') |
|
653 | - echo ' |
|
678 | + } elseif ($_GET['verse'] == '4:16') { |
|
679 | + echo ' |
|
654 | 680 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
655 | - elseif ($_GET['verse'] == '22:1-2') |
|
656 | - echo ' |
|
681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
682 | + echo ' |
|
657 | 683 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
658 | 684 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
685 | + } |
|
659 | 686 | |
660 | 687 | echo ' |
661 | 688 | </div> |
662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
663 | 690 | |
664 | - if ($_GET['verse'] == '2:18') |
|
665 | - echo ' |
|
691 | + if ($_GET['verse'] == '2:18') { |
|
692 | + echo ' |
|
666 | 693 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
667 | - elseif ($_GET['verse'] == '4:16') |
|
668 | - echo ' |
|
694 | + } elseif ($_GET['verse'] == '4:16') { |
|
695 | + echo ' |
|
669 | 696 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
670 | - elseif ($_GET['verse'] == '22:1-2') |
|
671 | - echo ' |
|
697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
698 | + echo ' |
|
672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
700 | + } |
|
673 | 701 | |
674 | 702 | echo ' |
675 | 703 | </div> |
@@ -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 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
60 | 61 | 'max_year' => $year_high, |
61 | 62 | ) |
62 | 63 | ); |
63 | - } |
|
64 | - else |
|
64 | + } else |
|
65 | 65 | { |
66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
91 | 91 | $bday = array(); |
92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
93 | 93 | { |
94 | - if ($year_low != $year_high) |
|
95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | - else |
|
97 | - $age_year = $year_low; |
|
94 | + if ($year_low != $year_high) { |
|
95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | + } else { |
|
97 | + $age_year = $year_low; |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | ksort($bday); |
109 | 110 | |
110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
111 | - foreach ($bday as $mday => $array) |
|
112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
112 | + foreach ($bday as $mday => $array) { |
|
113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | return $bday; |
115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | static $timezone_array = array(); |
134 | 136 | require_once($sourcedir . '/Subs.php'); |
135 | 137 | |
136 | - if (empty($timezone_array['default'])) |
|
137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
138 | + if (empty($timezone_array['default'])) { |
|
139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
140 | + } |
|
138 | 141 | |
139 | 142 | $low_object = date_create($low_date); |
140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
162 | 165 | { |
163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
165 | - continue; |
|
167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
168 | + continue; |
|
169 | + } |
|
166 | 170 | |
167 | 171 | // Force a censor of the title - as often these are used by others. |
168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
170 | 174 | // Get the various time and date properties for this event |
171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
172 | 176 | |
173 | - if (empty($timezone_array[$tz])) |
|
174 | - $timezone_array[$tz] = timezone_open($tz); |
|
177 | + if (empty($timezone_array[$tz])) { |
|
178 | + $timezone_array[$tz] = timezone_open($tz); |
|
179 | + } |
|
175 | 180 | |
176 | 181 | // Sanity check |
177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
178 | - continue; |
|
182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
183 | + continue; |
|
184 | + } |
|
179 | 185 | |
180 | 186 | // Get set up for the loop |
181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
239 | 245 | ); |
240 | 246 | |
241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
242 | - if ($use_permissions) |
|
243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
248 | + if ($use_permissions) { |
|
249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
250 | 256 | )); |
257 | + } |
|
251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
252 | - else |
|
253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
259 | + else { |
|
260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
260 | 267 | 'poster' => $row['id_member'], |
261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
262 | 269 | )); |
270 | + } |
|
263 | 271 | |
264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
270 | 278 | if ($use_permissions) |
271 | 279 | { |
272 | - foreach ($events as $mday => $array) |
|
273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
280 | + foreach ($events as $mday => $array) { |
|
281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
282 | + } |
|
274 | 283 | } |
275 | 284 | |
276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
290 | 299 | global $smcFunc; |
291 | 300 | |
292 | 301 | // Get the lowest and highest dates for "all years". |
293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
296 | - else |
|
297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
305 | + } else { |
|
306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
307 | + } |
|
298 | 308 | |
299 | 309 | // Find some holidays... ;). |
300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
314 | 324 | $holidays = array(); |
315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
316 | 326 | { |
317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
319 | - else |
|
320 | - $event_year = substr($low_date, 0, 4); |
|
327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
329 | + } else { |
|
330 | + $event_year = substr($low_date, 0, 4); |
|
331 | + } |
|
321 | 332 | |
322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
343 | 354 | isAllowedTo('calendar_post'); |
344 | 355 | |
345 | 356 | // No board? No topic?!? |
346 | - if (empty($board)) |
|
347 | - fatal_lang_error('missing_board_id', false); |
|
348 | - if (empty($topic)) |
|
349 | - fatal_lang_error('missing_topic_id', false); |
|
357 | + if (empty($board)) { |
|
358 | + fatal_lang_error('missing_board_id', false); |
|
359 | + } |
|
360 | + if (empty($topic)) { |
|
361 | + fatal_lang_error('missing_topic_id', false); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Administrator, Moderator, or owner. Period. |
352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 378 | { |
366 | 379 | // Not the owner of the topic. |
367 | - if ($row['id_member_started'] != $user_info['id']) |
|
368 | - fatal_lang_error('not_your_topic', 'user'); |
|
380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
381 | + fatal_lang_error('not_your_topic', 'user'); |
|
382 | + } |
|
369 | 383 | } |
370 | 384 | // Topic/Board doesn't exist..... |
371 | - else |
|
372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
385 | + else { |
|
386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
387 | + } |
|
373 | 388 | $smcFunc['db_free_result']($result); |
374 | 389 | } |
375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
457 | 472 | if (!empty($calendarOptions['start_day'])) |
458 | 473 | { |
459 | 474 | $nShift -= $calendarOptions['start_day']; |
460 | - if ($nShift < 0) |
|
461 | - $nShift = 7 + $nShift; |
|
475 | + if ($nShift < 0) { |
|
476 | + $nShift = 7 + $nShift; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Number of rows required to fit the month. |
465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
467 | - $nRows++; |
|
482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
483 | + $nRows++; |
|
484 | + } |
|
468 | 485 | |
469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
477 | 494 | { |
478 | 495 | $calendarGrid['week_days'][] = $count; |
479 | 496 | $count++; |
480 | - if ($count == 7) |
|
481 | - $count = 0; |
|
497 | + if ($count == 7) { |
|
498 | + $count = 0; |
|
499 | + } |
|
482 | 500 | } |
483 | 501 | |
484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
495 | 513 | { |
496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
497 | 515 | |
498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
499 | - $nDay = 0; |
|
516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
517 | + $nDay = 0; |
|
518 | + } |
|
500 | 519 | |
501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
514 | 533 | } |
515 | 534 | |
516 | 535 | // What is the last day of the month? |
517 | - if ($is_previous === true) |
|
518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
536 | + if ($is_previous === true) { |
|
537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
538 | + } |
|
519 | 539 | |
520 | 540 | // We'll use the shift in the template. |
521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
549 | 569 | { |
550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
552 | - if ($date_diff < 0) |
|
553 | - $date_diff += 7; |
|
572 | + if ($date_diff < 0) { |
|
573 | + $date_diff += 7; |
|
574 | + } |
|
554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
680 | 701 | { |
681 | 702 | foreach ($date_events as $event_key => $event_val) |
682 | 703 | { |
683 | - if (in_array($event_val['id'], $temp)) |
|
684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
685 | - else |
|
686 | - $temp[] = $event_val['id']; |
|
704 | + if (in_array($event_val['id'], $temp)) { |
|
705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
706 | + } else { |
|
707 | + $temp[] = $event_val['id']; |
|
708 | + } |
|
687 | 709 | } |
688 | 710 | } |
689 | 711 | |
690 | 712 | // Give birthdays and holidays a friendly format, without the year |
691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
692 | - $date_format = '%b %d'; |
|
693 | - else |
|
694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
714 | + $date_format = '%b %d'; |
|
715 | + } else { |
|
716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
717 | + } |
|
695 | 718 | |
696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
790 | 813 | // Holidays between now and now + days. |
791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
792 | 815 | { |
793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
818 | + } |
|
795 | 819 | } |
796 | 820 | } |
797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
805 | 829 | { |
806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
832 | + } |
|
808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
809 | 834 | } |
810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
820 | 845 | |
821 | 846 | // No events today? Check the next day. |
822 | - if (empty($cached_data['events'][$loop_date])) |
|
823 | - continue; |
|
847 | + if (empty($cached_data['events'][$loop_date])) { |
|
848 | + continue; |
|
849 | + } |
|
824 | 850 | |
825 | 851 | // Loop through all events to add a few last-minute values. |
826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
833 | 859 | { |
834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
835 | 861 | continue; |
862 | + } else { |
|
863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
836 | 864 | } |
837 | - else |
|
838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
839 | 865 | |
840 | 866 | // Might be set to true afterwards, depending on the permissions. |
841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
843 | 869 | $this_event['date'] = $loop_date; |
844 | 870 | } |
845 | 871 | |
846 | - if (!empty($cached_data['events'][$loop_date])) |
|
847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
874 | + } |
|
848 | 875 | } |
849 | 876 | } |
850 | 877 | |
851 | 878 | // Mark the last item so that a list separator can be used in the template. |
852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
881 | + } |
|
882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
884 | + } |
|
856 | 885 | |
857 | 886 | return array( |
858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
900 | 929 | if (isset($_POST['start_date'])) |
901 | 930 | { |
902 | 931 | $d = date_parse($_POST['start_date']); |
903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
904 | - fatal_lang_error('invalid_date', false); |
|
905 | - if (empty($d['year'])) |
|
906 | - fatal_lang_error('event_year_missing', false); |
|
907 | - if (empty($d['month'])) |
|
908 | - fatal_lang_error('event_month_missing', false); |
|
909 | - } |
|
910 | - elseif (isset($_POST['start_datetime'])) |
|
932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
933 | + fatal_lang_error('invalid_date', false); |
|
934 | + } |
|
935 | + if (empty($d['year'])) { |
|
936 | + fatal_lang_error('event_year_missing', false); |
|
937 | + } |
|
938 | + if (empty($d['month'])) { |
|
939 | + fatal_lang_error('event_month_missing', false); |
|
940 | + } |
|
941 | + } elseif (isset($_POST['start_datetime'])) |
|
911 | 942 | { |
912 | 943 | $d = date_parse($_POST['start_datetime']); |
913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
914 | - fatal_lang_error('invalid_date', false); |
|
915 | - if (empty($d['year'])) |
|
916 | - fatal_lang_error('event_year_missing', false); |
|
917 | - if (empty($d['month'])) |
|
918 | - fatal_lang_error('event_month_missing', false); |
|
944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
945 | + fatal_lang_error('invalid_date', false); |
|
946 | + } |
|
947 | + if (empty($d['year'])) { |
|
948 | + fatal_lang_error('event_year_missing', false); |
|
949 | + } |
|
950 | + if (empty($d['month'])) { |
|
951 | + fatal_lang_error('event_month_missing', false); |
|
952 | + } |
|
919 | 953 | } |
920 | 954 | // The 2.0 way |
921 | 955 | else |
922 | 956 | { |
923 | 957 | // No month? No year? |
924 | - if (!isset($_POST['month'])) |
|
925 | - fatal_lang_error('event_month_missing', false); |
|
926 | - if (!isset($_POST['year'])) |
|
927 | - fatal_lang_error('event_year_missing', false); |
|
958 | + if (!isset($_POST['month'])) { |
|
959 | + fatal_lang_error('event_month_missing', false); |
|
960 | + } |
|
961 | + if (!isset($_POST['year'])) { |
|
962 | + fatal_lang_error('event_year_missing', false); |
|
963 | + } |
|
928 | 964 | |
929 | 965 | // Check the month and year... |
930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
931 | - fatal_lang_error('invalid_month', false); |
|
932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
933 | - fatal_lang_error('invalid_year', false); |
|
966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
967 | + fatal_lang_error('invalid_month', false); |
|
968 | + } |
|
969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
970 | + fatal_lang_error('invalid_year', false); |
|
971 | + } |
|
934 | 972 | } |
935 | 973 | } |
936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
941 | 979 | if (isset($_POST['span'])) |
942 | 980 | { |
943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
944 | - fatal_lang_error('invalid_days_numb', false); |
|
981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
982 | + fatal_lang_error('invalid_days_numb', false); |
|
983 | + } |
|
945 | 984 | } |
946 | 985 | |
947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
952 | 991 | { |
953 | 992 | // No day? |
954 | - if (!isset($_POST['day'])) |
|
955 | - fatal_lang_error('event_day_missing', false); |
|
993 | + if (!isset($_POST['day'])) { |
|
994 | + fatal_lang_error('event_day_missing', false); |
|
995 | + } |
|
956 | 996 | |
957 | 997 | // Bad day? |
958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
959 | - fatal_lang_error('invalid_date', false); |
|
998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
999 | + fatal_lang_error('invalid_date', false); |
|
1000 | + } |
|
960 | 1001 | } |
961 | 1002 | |
962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
963 | - fatal_lang_error('event_title_missing', false); |
|
964 | - elseif (!isset($_POST['evtitle'])) |
|
965 | - $_POST['evtitle'] = $_POST['subject']; |
|
1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
1004 | + fatal_lang_error('event_title_missing', false); |
|
1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
1007 | + } |
|
966 | 1008 | |
967 | 1009 | // No title? |
968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
969 | - fatal_lang_error('no_event_title', false); |
|
970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1011 | + fatal_lang_error('no_event_title', false); |
|
1012 | + } |
|
1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1015 | + } |
|
972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
973 | 1017 | } |
974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
995 | 1039 | ); |
996 | 1040 | |
997 | 1041 | // No results, return false. |
998 | - if ($smcFunc['db_num_rows'] === 0) |
|
999 | - return false; |
|
1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1043 | + return false; |
|
1044 | + } |
|
1000 | 1045 | |
1001 | 1046 | // Grab the results and return. |
1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1131 | 1176 | |
1132 | 1177 | $column_clauses = array(); |
1133 | - foreach ($event_columns as $col => $crit) |
|
1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1178 | + foreach ($event_columns as $col => $crit) { |
|
1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1180 | + } |
|
1135 | 1181 | |
1136 | 1182 | $smcFunc['db_query']('', ' |
1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
1216 | 1262 | ); |
1217 | 1263 | |
1218 | 1264 | // If nothing returned, we are in poo, poo. |
1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1220 | - return false; |
|
1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1266 | + return false; |
|
1267 | + } |
|
1221 | 1268 | |
1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1226 | 1273 | |
1227 | 1274 | // Sanity check |
1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1229 | - return false; |
|
1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1276 | + return false; |
|
1277 | + } |
|
1230 | 1278 | |
1231 | 1279 | $return_value = array( |
1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
1363 | 1411 | |
1364 | 1412 | // Set $span, in case we need it |
1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1366 | - if ($span > 0) |
|
1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1414 | + if ($span > 0) { |
|
1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1416 | + } |
|
1368 | 1417 | |
1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1371 | - $tz = $eventOptions['tz']; |
|
1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1373 | - $tz = $_POST['tz']; |
|
1374 | - else |
|
1375 | - $tz = getUserTimezone(); |
|
1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1420 | + $tz = $eventOptions['tz']; |
|
1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1422 | + $tz = $_POST['tz']; |
|
1423 | + } else { |
|
1424 | + $tz = getUserTimezone(); |
|
1425 | + } |
|
1376 | 1426 | |
1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1378 | - if (isset($eventOptions['allday'])) |
|
1379 | - $allday = $eventOptions['allday']; |
|
1380 | - elseif (empty($_POST['allday'])) |
|
1381 | - $allday = false; |
|
1382 | - else |
|
1383 | - $allday = true; |
|
1428 | + if (isset($eventOptions['allday'])) { |
|
1429 | + $allday = $eventOptions['allday']; |
|
1430 | + } elseif (empty($_POST['allday'])) { |
|
1431 | + $allday = false; |
|
1432 | + } else { |
|
1433 | + $allday = true; |
|
1434 | + } |
|
1384 | 1435 | |
1385 | 1436 | // Input might come as individual parameters... |
1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1408 | 1459 | |
1409 | 1460 | // If the date and time were given in separate strings, combine them |
1410 | - if (empty($start_string) && isset($start_date_string)) |
|
1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1412 | - if (empty($end_string) && isset($end_date_string)) |
|
1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1463 | + } |
|
1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1466 | + } |
|
1414 | 1467 | |
1415 | 1468 | // If some form of string input was given, override individually defined options with it |
1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
1501 | 1554 | if ($start_object >= $end_object) |
1502 | 1555 | { |
1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1504 | - if ($span > 0) |
|
1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1506 | - else |
|
1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1557 | + if ($span > 0) { |
|
1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1559 | + } else { |
|
1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1561 | + } |
|
1508 | 1562 | } |
1509 | 1563 | |
1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
1517 | 1571 | { |
1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1574 | + } else { |
|
1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1520 | 1576 | } |
1521 | - else |
|
1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1523 | 1577 | } |
1524 | 1578 | } |
1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
1532 | 1586 | $start_time = null; |
1533 | 1587 | $end_time = null; |
1534 | 1588 | $tz = null; |
1535 | - } |
|
1536 | - else |
|
1589 | + } else |
|
1537 | 1590 | { |
1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
1560 | 1613 | if (empty($date_format)) |
1561 | 1614 | { |
1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1563 | - $date_format = '%F'; |
|
1564 | - else |
|
1565 | - $date_format = $matches[0]; |
|
1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1616 | + $date_format = '%F'; |
|
1617 | + } else { |
|
1618 | + $date_format = $matches[0]; |
|
1619 | + } |
|
1566 | 1620 | } |
1567 | 1621 | |
1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1569 | 1623 | if (empty($time_format)) |
1570 | 1624 | { |
1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1572 | - $time_format = '%k:%M'; |
|
1573 | - else |
|
1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1626 | + $time_format = '%k:%M'; |
|
1627 | + } else { |
|
1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1629 | + } |
|
1575 | 1630 | } |
1576 | 1631 | |
1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1582 | 1637 | |
1583 | 1638 | // We need to have a defined timezone in the steps below |
1584 | - if (empty($row['timezone'])) |
|
1585 | - $row['timezone'] = getUserTimezone(); |
|
1639 | + if (empty($row['timezone'])) { |
|
1640 | + $row['timezone'] = getUserTimezone(); |
|
1641 | + } |
|
1586 | 1642 | |
1587 | - if (empty($timezone_array[$row['timezone']])) |
|
1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1645 | + } |
|
1589 | 1646 | |
1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
1634 | 1691 | static $member_cache = array(); |
1635 | 1692 | |
1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1637 | - $id_member = $context['user']['id']; |
|
1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1694 | + $id_member = $context['user']['id']; |
|
1695 | + } |
|
1638 | 1696 | |
1639 | 1697 | //check if the cache got the data |
1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
1663 | 1721 | $smcFunc['db_free_result']($request); |
1664 | 1722 | } |
1665 | 1723 | |
1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1726 | + } |
|
1668 | 1727 | |
1669 | - if (isset($id_member)) |
|
1670 | - $member_cache[$id_member] = $timezone; |
|
1728 | + if (isset($id_member)) { |
|
1729 | + $member_cache[$id_member] = $timezone; |
|
1730 | + } |
|
1671 | 1731 | |
1672 | 1732 | return $timezone; |
1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
1696 | 1756 | ) |
1697 | 1757 | ); |
1698 | 1758 | $holidays = array(); |
1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1700 | - $holidays[] = $row; |
|
1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1760 | + $holidays[] = $row; |
|
1761 | + } |
|
1701 | 1762 | $smcFunc['db_free_result']($request); |
1702 | 1763 | |
1703 | 1764 | return $holidays; |