@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** |
82 | 82 | * Make files writable. First try to use regular chmod, but if that fails, try to use FTP. |
83 | 83 | * |
84 | - * @param $files |
|
84 | + * @param string[] $files |
|
85 | 85 | * @return bool |
86 | 86 | */ |
87 | 87 | function makeFilesWritable(&$files) |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | /** |
323 | 323 | * Prints an error to stderr. |
324 | 324 | * |
325 | - * @param $message |
|
325 | + * @param string $message |
|
326 | 326 | * @param bool $fatal |
327 | 327 | */ |
328 | 328 | function print_error($message, $fatal = false) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * This file contains helper functions for upgrade.php |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF_VERSION')) |
|
16 | +if (!defined('SMF_VERSION')) { |
|
17 | 17 | die('No direct access!'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Clean the cache using the SMF 2.1 CacheAPI. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | global $smcFunc; |
46 | 47 | static $member_groups = array(); |
47 | 48 | |
48 | - if (!empty($member_groups)) |
|
49 | - return $member_groups; |
|
49 | + if (!empty($member_groups)) { |
|
50 | + return $member_groups; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $request = $smcFunc['db_query']('', ' |
52 | 54 | SELECT group_name, id_group |
@@ -71,8 +73,9 @@ discard block |
||
71 | 73 | ) |
72 | 74 | ); |
73 | 75 | } |
74 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
75 | - $member_groups[trim($row[0])] = $row[1]; |
|
76 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
77 | + $member_groups[trim($row[0])] = $row[1]; |
|
78 | + } |
|
76 | 79 | $smcFunc['db_free_result']($request); |
77 | 80 | |
78 | 81 | return $member_groups; |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | { |
89 | 92 | global $upcontext, $boarddir, $sourcedir; |
90 | 93 | |
91 | - if (empty($files)) |
|
92 | - return true; |
|
94 | + if (empty($files)) { |
|
95 | + return true; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | $failure = false; |
95 | 99 | // On linux, it's easy - just use is_writable! |
@@ -100,22 +104,25 @@ discard block |
||
100 | 104 | foreach ($files as $k => $file) |
101 | 105 | { |
102 | 106 | // Some files won't exist, try to address up front |
103 | - if (!file_exists($file)) |
|
104 | - @touch($file); |
|
107 | + if (!file_exists($file)) { |
|
108 | + @touch($file); |
|
109 | + } |
|
105 | 110 | // NOW do the writable check... |
106 | 111 | if (!is_writable($file)) |
107 | 112 | { |
108 | 113 | @chmod($file, 0755); |
109 | 114 | |
110 | 115 | // Well, 755 hopefully worked... if not, try 777. |
111 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
112 | - $failure = true; |
|
116 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
117 | + $failure = true; |
|
118 | + } |
|
113 | 119 | // Otherwise remove it as it's good! |
114 | - else |
|
115 | - unset($files[$k]); |
|
120 | + else { |
|
121 | + unset($files[$k]); |
|
122 | + } |
|
123 | + } else { |
|
124 | + unset($files[$k]); |
|
116 | 125 | } |
117 | - else |
|
118 | - unset($files[$k]); |
|
119 | 126 | } |
120 | 127 | } |
121 | 128 | // Windows is trickier. Let's try opening for r+... |
@@ -126,30 +133,35 @@ discard block |
||
126 | 133 | foreach ($files as $k => $file) |
127 | 134 | { |
128 | 135 | // Folders can't be opened for write... but the index.php in them can ;). |
129 | - if (is_dir($file)) |
|
130 | - $file .= '/index.php'; |
|
136 | + if (is_dir($file)) { |
|
137 | + $file .= '/index.php'; |
|
138 | + } |
|
131 | 139 | |
132 | 140 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
133 | 141 | @chmod($file, 0777); |
134 | 142 | $fp = @fopen($file, 'r+'); |
135 | 143 | |
136 | 144 | // Hmm, okay, try just for write in that case... |
137 | - if (!$fp) |
|
138 | - $fp = @fopen($file, 'w'); |
|
145 | + if (!$fp) { |
|
146 | + $fp = @fopen($file, 'w'); |
|
147 | + } |
|
139 | 148 | |
140 | - if (!$fp) |
|
141 | - $failure = true; |
|
142 | - else |
|
143 | - unset($files[$k]); |
|
149 | + if (!$fp) { |
|
150 | + $failure = true; |
|
151 | + } else { |
|
152 | + unset($files[$k]); |
|
153 | + } |
|
144 | 154 | @fclose($fp); |
145 | 155 | } |
146 | 156 | } |
147 | 157 | |
148 | - if (empty($files)) |
|
149 | - return true; |
|
158 | + if (empty($files)) { |
|
159 | + return true; |
|
160 | + } |
|
150 | 161 | |
151 | - if (!isset($_SERVER)) |
|
152 | - return !$failure; |
|
162 | + if (!isset($_SERVER)) { |
|
163 | + return !$failure; |
|
164 | + } |
|
153 | 165 | |
154 | 166 | // What still needs to be done? |
155 | 167 | $upcontext['chmod']['files'] = $files; |
@@ -201,36 +213,40 @@ discard block |
||
201 | 213 | |
202 | 214 | if (!isset($ftp) || $ftp->error !== false) |
203 | 215 | { |
204 | - if (!isset($ftp)) |
|
205 | - $ftp = new ftp_connection(null); |
|
216 | + if (!isset($ftp)) { |
|
217 | + $ftp = new ftp_connection(null); |
|
218 | + } |
|
206 | 219 | // Save the error so we can mess with listing... |
207 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
208 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
220 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
221 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
222 | + } |
|
209 | 223 | |
210 | 224 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
211 | 225 | |
212 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
213 | - $upcontext['chmod']['path'] = $detect_path; |
|
226 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
227 | + $upcontext['chmod']['path'] = $detect_path; |
|
228 | + } |
|
214 | 229 | |
215 | - if (!isset($upcontext['chmod']['username'])) |
|
216 | - $upcontext['chmod']['username'] = $username; |
|
230 | + if (!isset($upcontext['chmod']['username'])) { |
|
231 | + $upcontext['chmod']['username'] = $username; |
|
232 | + } |
|
217 | 233 | |
218 | 234 | // Don't forget the login token. |
219 | 235 | $upcontext += createToken('login'); |
220 | 236 | |
221 | 237 | return false; |
222 | - } |
|
223 | - else |
|
238 | + } else |
|
224 | 239 | { |
225 | 240 | // We want to do a relative path for FTP. |
226 | 241 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
227 | 242 | { |
228 | 243 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
229 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
230 | - $ftp_root = substr($ftp_root, 0, -1); |
|
244 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
245 | + $ftp_root = substr($ftp_root, 0, -1); |
|
246 | + } |
|
247 | + } else { |
|
248 | + $ftp_root = $boarddir; |
|
231 | 249 | } |
232 | - else |
|
233 | - $ftp_root = $boarddir; |
|
234 | 250 | |
235 | 251 | // Save the info for next time! |
236 | 252 | $_SESSION['installer_temp_ftp'] = array( |
@@ -244,10 +260,12 @@ discard block |
||
244 | 260 | |
245 | 261 | foreach ($files as $k => $file) |
246 | 262 | { |
247 | - if (!is_writable($file)) |
|
248 | - $ftp->chmod($file, 0755); |
|
249 | - if (!is_writable($file)) |
|
250 | - $ftp->chmod($file, 0777); |
|
263 | + if (!is_writable($file)) { |
|
264 | + $ftp->chmod($file, 0755); |
|
265 | + } |
|
266 | + if (!is_writable($file)) { |
|
267 | + $ftp->chmod($file, 0777); |
|
268 | + } |
|
251 | 269 | |
252 | 270 | // Assuming that didn't work calculate the path without the boarddir. |
253 | 271 | if (!is_writable($file)) |
@@ -256,19 +274,23 @@ discard block |
||
256 | 274 | { |
257 | 275 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
258 | 276 | $ftp->chmod($ftp_file, 0755); |
259 | - if (!is_writable($file)) |
|
260 | - $ftp->chmod($ftp_file, 0777); |
|
277 | + if (!is_writable($file)) { |
|
278 | + $ftp->chmod($ftp_file, 0777); |
|
279 | + } |
|
261 | 280 | // Sometimes an extra slash can help... |
262 | 281 | $ftp_file = '/' . $ftp_file; |
263 | - if (!is_writable($file)) |
|
264 | - $ftp->chmod($ftp_file, 0755); |
|
265 | - if (!is_writable($file)) |
|
266 | - $ftp->chmod($ftp_file, 0777); |
|
282 | + if (!is_writable($file)) { |
|
283 | + $ftp->chmod($ftp_file, 0755); |
|
284 | + } |
|
285 | + if (!is_writable($file)) { |
|
286 | + $ftp->chmod($ftp_file, 0777); |
|
287 | + } |
|
267 | 288 | } |
268 | 289 | } |
269 | 290 | |
270 | - if (is_writable($file)) |
|
271 | - unset($files[$k]); |
|
291 | + if (is_writable($file)) { |
|
292 | + unset($files[$k]); |
|
293 | + } |
|
272 | 294 | } |
273 | 295 | |
274 | 296 | $ftp->close(); |
@@ -278,8 +300,9 @@ discard block |
||
278 | 300 | // What remains? |
279 | 301 | $upcontext['chmod']['files'] = $files; |
280 | 302 | |
281 | - if (empty($files)) |
|
282 | - return true; |
|
303 | + if (empty($files)) { |
|
304 | + return true; |
|
305 | + } |
|
283 | 306 | |
284 | 307 | return false; |
285 | 308 | } |
@@ -293,12 +316,14 @@ discard block |
||
293 | 316 | function quickFileWritable($file) |
294 | 317 | { |
295 | 318 | // Some files won't exist, try to address up front |
296 | - if (!file_exists($file)) |
|
297 | - @touch($file); |
|
319 | + if (!file_exists($file)) { |
|
320 | + @touch($file); |
|
321 | + } |
|
298 | 322 | |
299 | 323 | // NOW do the writable check... |
300 | - if (is_writable($file)) |
|
301 | - return true; |
|
324 | + if (is_writable($file)) { |
|
325 | + return true; |
|
326 | + } |
|
302 | 327 | |
303 | 328 | @chmod($file, 0755); |
304 | 329 | |
@@ -308,10 +333,11 @@ discard block |
||
308 | 333 | foreach ($chmod_values as $val) |
309 | 334 | { |
310 | 335 | // If it's writable, break out of the loop |
311 | - if (is_writable($file)) |
|
312 | - break; |
|
313 | - else |
|
314 | - @chmod($file, $val); |
|
336 | + if (is_writable($file)) { |
|
337 | + break; |
|
338 | + } else { |
|
339 | + @chmod($file, $val); |
|
340 | + } |
|
315 | 341 | } |
316 | 342 | |
317 | 343 | return is_writable($file); |
@@ -338,14 +364,16 @@ discard block |
||
338 | 364 | { |
339 | 365 | static $fp = null; |
340 | 366 | |
341 | - if ($fp === null) |
|
342 | - $fp = fopen('php://stderr', 'wb'); |
|
367 | + if ($fp === null) { |
|
368 | + $fp = fopen('php://stderr', 'wb'); |
|
369 | + } |
|
343 | 370 | |
344 | 371 | fwrite($fp, $message . "\n"); |
345 | 372 | |
346 | - if ($fatal) |
|
347 | - exit; |
|
348 | -} |
|
373 | + if ($fatal) { |
|
374 | + exit; |
|
375 | + } |
|
376 | + } |
|
349 | 377 | |
350 | 378 | /** |
351 | 379 | * Throws a graphical error message. |
@@ -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 | * Entry point for this section. |
@@ -38,8 +39,7 @@ discard block |
||
38 | 39 | 'stats' => 'SpiderStats', |
39 | 40 | ); |
40 | 41 | $default = 'stats'; |
41 | - } |
|
42 | - else |
|
42 | + } else |
|
43 | 43 | { |
44 | 44 | $subActions = array( |
45 | 45 | 'settings' => 'ManageSearchEngineSettings', |
@@ -90,11 +90,12 @@ discard block |
||
90 | 90 | { |
91 | 91 | disabledState = document.getElementById(\'spider_mode\').value == 0;'; |
92 | 92 | |
93 | - foreach ($config_vars as $variable) |
|
94 | - if ($variable[1] != 'spider_mode') |
|
93 | + foreach ($config_vars as $variable) { |
|
94 | + if ($variable[1] != 'spider_mode') |
|
95 | 95 | $javascript_function .= ' |
96 | 96 | if (document.getElementById(\'' . $variable[1] . '\')) |
97 | 97 | document.getElementById(\'' . $variable[1] . '\').disabled = disabledState;'; |
98 | + } |
|
98 | 99 | |
99 | 100 | $javascript_function .= ' |
100 | 101 | } |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | |
103 | 104 | call_integration_hook('integrate_modify_search_engine_settings', array(&$config_vars)); |
104 | 105 | |
105 | - if ($return_config) |
|
106 | - return $config_vars; |
|
106 | + if ($return_config) { |
|
107 | + return $config_vars; |
|
108 | + } |
|
107 | 109 | |
108 | 110 | // We need to load the groups for the spider group thingy. |
109 | 111 | $request = $smcFunc['db_query']('', ' |
@@ -116,13 +118,15 @@ discard block |
||
116 | 118 | 'moderator_group' => 3, |
117 | 119 | ) |
118 | 120 | ); |
119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
120 | - $config_vars['spider_group'][2][$row['id_group']] = $row['group_name']; |
|
121 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
122 | + $config_vars['spider_group'][2][$row['id_group']] = $row['group_name']; |
|
123 | + } |
|
121 | 124 | $smcFunc['db_free_result']($request); |
122 | 125 | |
123 | 126 | // Make sure it's valid - note that regular members are given id_group = 1 which is reversed in Load.php - no admins here! |
124 | - if (isset($_POST['spider_group']) && !isset($config_vars['spider_group'][2][$_POST['spider_group']])) |
|
125 | - $_POST['spider_group'] = 0; |
|
127 | + if (isset($_POST['spider_group']) && !isset($config_vars['spider_group'][2][$_POST['spider_group']])) { |
|
128 | + $_POST['spider_group'] = 0; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | // We'll want this for our easy save. |
128 | 132 | require_once($sourcedir . '/ManageServer.php'); |
@@ -166,8 +170,9 @@ discard block |
||
166 | 170 | } |
167 | 171 | |
168 | 172 | // Are we adding a new one? |
169 | - if (!empty($_POST['addSpider'])) |
|
170 | - return EditSpider(); |
|
173 | + if (!empty($_POST['addSpider'])) { |
|
174 | + return EditSpider(); |
|
175 | + } |
|
171 | 176 | // User pressed the 'remove selection button'. |
172 | 177 | elseif (!empty($_POST['removeSpiders']) && !empty($_POST['remove']) && is_array($_POST['remove'])) |
173 | 178 | { |
@@ -175,8 +180,9 @@ discard block |
||
175 | 180 | validateToken('admin-ser'); |
176 | 181 | |
177 | 182 | // Make sure every entry is a proper integer. |
178 | - foreach ($_POST['remove'] as $index => $spider_id) |
|
179 | - $_POST['remove'][(int) $index] = (int) $spider_id; |
|
183 | + foreach ($_POST['remove'] as $index => $spider_id) { |
|
184 | + $_POST['remove'][(int) $index] = (int) $spider_id; |
|
185 | + } |
|
180 | 186 | |
181 | 187 | // Delete them all! |
182 | 188 | $smcFunc['db_query']('', ' |
@@ -215,8 +221,9 @@ discard block |
||
215 | 221 | ); |
216 | 222 | |
217 | 223 | $context['spider_last_seen'] = array(); |
218 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
219 | - $context['spider_last_seen'][$row['id_spider']] = $row['last_seen_time']; |
|
224 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
225 | + $context['spider_last_seen'][$row['id_spider']] = $row['last_seen_time']; |
|
226 | + } |
|
220 | 227 | $smcFunc['db_free_result']($request); |
221 | 228 | |
222 | 229 | createToken('admin-ser'); |
@@ -346,8 +353,9 @@ discard block |
||
346 | 353 | ) |
347 | 354 | ); |
348 | 355 | $spiders = array(); |
349 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
350 | - $spiders[$row['id_spider']] = $row; |
|
356 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
357 | + $spiders[$row['id_spider']] = $row; |
|
358 | + } |
|
351 | 359 | $smcFunc['db_free_result']($request); |
352 | 360 | |
353 | 361 | return $spiders; |
@@ -397,14 +405,15 @@ discard block |
||
397 | 405 | foreach ($ip_sets as $set) |
398 | 406 | { |
399 | 407 | $test = ip2range(trim($set)); |
400 | - if (!empty($test)) |
|
401 | - $ips[] = $set; |
|
408 | + if (!empty($test)) { |
|
409 | + $ips[] = $set; |
|
410 | + } |
|
402 | 411 | } |
403 | 412 | $ips = implode(',', $ips); |
404 | 413 | |
405 | 414 | // Goes in as it is... |
406 | - if ($context['id_spider']) |
|
407 | - $smcFunc['db_query']('', ' |
|
415 | + if ($context['id_spider']) { |
|
416 | + $smcFunc['db_query']('', ' |
|
408 | 417 | UPDATE {db_prefix}spiders |
409 | 418 | SET spider_name = {string:spider_name}, user_agent = {string:spider_agent}, |
410 | 419 | ip_info = {string:ip_info} |
@@ -416,8 +425,8 @@ discard block |
||
416 | 425 | 'ip_info' => $ips, |
417 | 426 | ) |
418 | 427 | ); |
419 | - else |
|
420 | - $smcFunc['db_insert']('insert', |
|
428 | + } else { |
|
429 | + $smcFunc['db_insert']('insert', |
|
421 | 430 | '{db_prefix}spiders', |
422 | 431 | array( |
423 | 432 | 'spider_name' => 'string', 'user_agent' => 'string', 'ip_info' => 'string', |
@@ -427,6 +436,7 @@ discard block |
||
427 | 436 | ), |
428 | 437 | array('id_spider') |
429 | 438 | ); |
439 | + } |
|
430 | 440 | |
431 | 441 | |
432 | 442 | cache_put_data('spider_search', null); |
@@ -454,13 +464,14 @@ discard block |
||
454 | 464 | 'current_spider' => $context['id_spider'], |
455 | 465 | ) |
456 | 466 | ); |
457 | - if ($row = $smcFunc['db_fetch_assoc']($request)) |
|
458 | - $context['spider'] = array( |
|
467 | + if ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
468 | + $context['spider'] = array( |
|
459 | 469 | 'id' => $row['id_spider'], |
460 | 470 | 'name' => $row['spider_name'], |
461 | 471 | 'agent' => $row['user_agent'], |
462 | 472 | 'ip_info' => $row['ip_info'], |
463 | 473 | ); |
474 | + } |
|
464 | 475 | $smcFunc['db_free_result']($request); |
465 | 476 | } |
466 | 477 | |
@@ -477,8 +488,9 @@ discard block |
||
477 | 488 | { |
478 | 489 | global $modSettings, $smcFunc; |
479 | 490 | |
480 | - if (isset($_SESSION['id_robot'])) |
|
481 | - unset($_SESSION['id_robot']); |
|
491 | + if (isset($_SESSION['id_robot'])) { |
|
492 | + unset($_SESSION['id_robot']); |
|
493 | + } |
|
482 | 494 | $_SESSION['robot_check'] = time(); |
483 | 495 | |
484 | 496 | // We cache the spider data for ten minutes if we can. |
@@ -492,15 +504,17 @@ discard block |
||
492 | 504 | ) |
493 | 505 | ); |
494 | 506 | $spider_data = array(); |
495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
496 | - $spider_data[] = $row; |
|
507 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
508 | + $spider_data[] = $row; |
|
509 | + } |
|
497 | 510 | $smcFunc['db_free_result']($request); |
498 | 511 | |
499 | 512 | cache_put_data('spider_search', $spider_data, 600); |
500 | 513 | } |
501 | 514 | |
502 | - if (empty($spider_data)) |
|
503 | - return false; |
|
515 | + if (empty($spider_data)) { |
|
516 | + return false; |
|
517 | + } |
|
504 | 518 | |
505 | 519 | // Only do these bits once. |
506 | 520 | $ci_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); |
@@ -508,33 +522,38 @@ discard block |
||
508 | 522 | foreach ($spider_data as $spider) |
509 | 523 | { |
510 | 524 | // User agent is easy. |
511 | - if (!empty($spider['user_agent']) && strpos($ci_user_agent, strtolower($spider['user_agent'])) !== false) |
|
512 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
525 | + if (!empty($spider['user_agent']) && strpos($ci_user_agent, strtolower($spider['user_agent'])) !== false) { |
|
526 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
527 | + } |
|
513 | 528 | // IP stuff is harder. |
514 | 529 | elseif ($_SERVER['REMOTE_ADDR']) |
515 | 530 | { |
516 | 531 | $ips = explode(',', $spider['ip_info']); |
517 | 532 | foreach ($ips as $ip) |
518 | 533 | { |
519 | - if ($ip === '') |
|
520 | - continue; |
|
534 | + if ($ip === '') { |
|
535 | + continue; |
|
536 | + } |
|
521 | 537 | |
522 | 538 | $ip = ip2range($ip); |
523 | 539 | if (!empty($ip)) |
524 | 540 | { |
525 | - if (inet_ptod($ip['low']) <= inet_ptod($_SERVER['REMOTE_ADDR']) && inet_ptod($ip['high']) >= inet_ptod($_SERVER['REMOTE_ADDR'])) |
|
526 | - $_SESSION['id_robot'] = $spider['id_spider']; |
|
541 | + if (inet_ptod($ip['low']) <= inet_ptod($_SERVER['REMOTE_ADDR']) && inet_ptod($ip['high']) >= inet_ptod($_SERVER['REMOTE_ADDR'])) { |
|
542 | + $_SESSION['id_robot'] = $spider['id_spider']; |
|
543 | + } |
|
527 | 544 | } |
528 | 545 | } |
529 | 546 | } |
530 | 547 | |
531 | - if (isset($_SESSION['id_robot'])) |
|
532 | - break; |
|
548 | + if (isset($_SESSION['id_robot'])) { |
|
549 | + break; |
|
550 | + } |
|
533 | 551 | } |
534 | 552 | |
535 | 553 | // If this is low server tracking then log the spider here as opposed to the main logging function. |
536 | - if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot'])) |
|
537 | - logSpider(); |
|
554 | + if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot'])) { |
|
555 | + logSpider(); |
|
556 | + } |
|
538 | 557 | |
539 | 558 | return !empty($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
540 | 559 | } |
@@ -548,8 +567,9 @@ discard block |
||
548 | 567 | { |
549 | 568 | global $smcFunc, $modSettings, $context; |
550 | 569 | |
551 | - if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) |
|
552 | - return; |
|
570 | + if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) { |
|
571 | + return; |
|
572 | + } |
|
553 | 573 | |
554 | 574 | // Attempt to update today's entry. |
555 | 575 | if ($modSettings['spider_mode'] == 1) |
@@ -590,9 +610,9 @@ discard block |
||
590 | 610 | $url = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
591 | 611 | unset($url['sesc'], $url[$context['session_var']]); |
592 | 612 | $url = $smcFunc['json_encode']($url); |
613 | + } else { |
|
614 | + $url = ''; |
|
593 | 615 | } |
594 | - else |
|
595 | - $url = ''; |
|
596 | 616 | |
597 | 617 | $smcFunc['db_insert']('insert', |
598 | 618 | '{db_prefix}log_spider_hits', |
@@ -620,12 +640,14 @@ discard block |
||
620 | 640 | ) |
621 | 641 | ); |
622 | 642 | $spider_hits = array(); |
623 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
624 | - $spider_hits[] = $row; |
|
643 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
644 | + $spider_hits[] = $row; |
|
645 | + } |
|
625 | 646 | $smcFunc['db_free_result']($request); |
626 | 647 | |
627 | - if (empty($spider_hits)) |
|
628 | - return; |
|
648 | + if (empty($spider_hits)) { |
|
649 | + return; |
|
650 | + } |
|
629 | 651 | |
630 | 652 | // Attempt to update the master data. |
631 | 653 | $stat_inserts = array(); |
@@ -646,18 +668,20 @@ discard block |
||
646 | 668 | 'hits' => $stat['num_hits'], |
647 | 669 | ) |
648 | 670 | ); |
649 | - if ($smcFunc['db_affected_rows']() == 0) |
|
650 | - $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
671 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
672 | + $stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']); |
|
673 | + } |
|
651 | 674 | } |
652 | 675 | |
653 | 676 | // New stats? |
654 | - if (!empty($stat_inserts)) |
|
655 | - $smcFunc['db_insert']('ignore', |
|
677 | + if (!empty($stat_inserts)) { |
|
678 | + $smcFunc['db_insert']('ignore', |
|
656 | 679 | '{db_prefix}log_spider_stats', |
657 | 680 | array('stat_date' => 'date', 'id_spider' => 'int', 'page_hits' => 'int', 'last_seen' => 'int'), |
658 | 681 | $stat_inserts, |
659 | 682 | array('stat_date', 'id_spider') |
660 | 683 | ); |
684 | + } |
|
661 | 685 | |
662 | 686 | // All processed. |
663 | 687 | $smcFunc['db_query']('', ' |
@@ -700,8 +724,7 @@ discard block |
||
700 | 724 | 'delete_period' => $deleteTime, |
701 | 725 | ) |
702 | 726 | ); |
703 | - } |
|
704 | - else |
|
727 | + } else |
|
705 | 728 | { |
706 | 729 | // Deleting all of them |
707 | 730 | $smcFunc['db_query']('', ' |
@@ -791,10 +814,11 @@ discard block |
||
791 | 814 | foreach ($context['spider_logs']['rows'] as $k => $row) |
792 | 815 | { |
793 | 816 | // Feature disabled? |
794 | - if (empty($row['data']['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) |
|
795 | - $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; |
|
796 | - else |
|
797 | - $urls[$k] = array($row['data']['viewing']['value'], -1); |
|
817 | + if (empty($row['data']['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) { |
|
818 | + $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; |
|
819 | + } else { |
|
820 | + $urls[$k] = array($row['data']['viewing']['value'], -1); |
|
821 | + } |
|
798 | 822 | } |
799 | 823 | |
800 | 824 | // Now stick in the new URLs. |
@@ -836,8 +860,9 @@ discard block |
||
836 | 860 | ) |
837 | 861 | ); |
838 | 862 | $spider_logs = array(); |
839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
840 | - $spider_logs[] = $row; |
|
863 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
864 | + $spider_logs[] = $row; |
|
865 | + } |
|
841 | 866 | $smcFunc['db_free_result']($request); |
842 | 867 | |
843 | 868 | return $spider_logs; |
@@ -913,14 +938,18 @@ discard block |
||
913 | 938 | |
914 | 939 | // Prepare the dates for the drop down. |
915 | 940 | $date_choices = array(); |
916 | - for ($y = $min_year; $y <= $max_year; $y++) |
|
917 | - for ($m = 1; $m <= 12; $m++) |
|
941 | + for ($y = $min_year; $y <= $max_year; $y++) { |
|
942 | + for ($m = 1; |
|
943 | + } |
|
944 | + $m <= 12; $m++) |
|
918 | 945 | { |
919 | 946 | // This doesn't count? |
920 | - if ($y == $min_year && $m < $min_month) |
|
921 | - continue; |
|
922 | - if ($y == $max_year && $m > $max_month) |
|
923 | - break; |
|
947 | + if ($y == $min_year && $m < $min_month) { |
|
948 | + continue; |
|
949 | + } |
|
950 | + if ($y == $max_year && $m > $max_month) { |
|
951 | + break; |
|
952 | + } |
|
924 | 953 | |
925 | 954 | $date_choices[$y . $m] = $txt['months_short'][$m] . ' ' . $y; |
926 | 955 | } |
@@ -933,13 +962,14 @@ discard block |
||
933 | 962 | ' . $txt['spider_stats_select_month'] . ': |
934 | 963 | <select name="new_date" onchange="document.spider_stat_list.submit();">'; |
935 | 964 | |
936 | - if (empty($date_choices)) |
|
937 | - $date_select .= ' |
|
965 | + if (empty($date_choices)) { |
|
966 | + $date_select .= ' |
|
938 | 967 | <option></option>'; |
939 | - else |
|
940 | - foreach ($date_choices as $id => $text) |
|
968 | + } else { |
|
969 | + foreach ($date_choices as $id => $text) |
|
941 | 970 | $date_select .= ' |
942 | 971 | <option value="' . $id . '"' . ($current_date == $id ? ' selected' : '') . '>' . $text . '</option>'; |
972 | + } |
|
943 | 973 | |
944 | 974 | $date_select .= ' |
945 | 975 | </select> |
@@ -1063,8 +1093,9 @@ discard block |
||
1063 | 1093 | ) |
1064 | 1094 | ); |
1065 | 1095 | $spider_stats = array(); |
1066 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1067 | - $spider_stats[] = $row; |
|
1096 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1097 | + $spider_stats[] = $row; |
|
1098 | + } |
|
1068 | 1099 | $smcFunc['db_free_result']($request); |
1069 | 1100 | |
1070 | 1101 | return $spider_stats; |
@@ -1105,8 +1136,9 @@ discard block |
||
1105 | 1136 | array() |
1106 | 1137 | ); |
1107 | 1138 | $spiders = array(); |
1108 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1109 | - $spiders[$row['id_spider']] = $row['spider_name']; |
|
1139 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1140 | + $spiders[$row['id_spider']] = $row['spider_name']; |
|
1141 | + } |
|
1110 | 1142 | $smcFunc['db_free_result']($request); |
1111 | 1143 | |
1112 | 1144 | updateSettings(array('spider_name_cache' => $smcFunc['json_encode']($spiders))); |
@@ -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 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
35 | 36 | isAllowedTo('who_view'); |
36 | 37 | |
37 | 38 | // You can't do anything if this is off. |
38 | - if (empty($modSettings['who_enabled'])) |
|
39 | - fatal_lang_error('who_off', false); |
|
39 | + if (empty($modSettings['who_enabled'])) { |
|
40 | + fatal_lang_error('who_off', false); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // Load the 'Who' template. |
42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
77 | + unset($_SESSION['who_online_filter']); |
|
74 | 78 | } |
75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
76 | - unset($_SESSION['who_online_filter']); |
|
77 | 79 | |
78 | 80 | // Does the user prefer a different sort direction? |
79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
98 | 100 | |
99 | 101 | $conditions = array(); |
100 | - if (!allowedTo('moderate_forum')) |
|
101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
102 | + if (!allowedTo('moderate_forum')) { |
|
103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
104 | + } |
|
102 | 105 | |
103 | 106 | // Fallback to top filter? |
104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
109 | + } |
|
106 | 110 | // Does the user wish to apply a filter? |
107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
113 | + } |
|
109 | 114 | // Perhaps we saved a filter earlier in the session? |
110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
112 | - else |
|
113 | - $context['show_by'] = 'members'; |
|
115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
117 | + } else { |
|
118 | + $context['show_by'] = 'members'; |
|
119 | + } |
|
114 | 120 | |
115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
157 | 163 | { |
158 | 164 | $actions = $smcFunc['json_decode']($row['url'], true); |
159 | - if ($actions === false) |
|
160 | - continue; |
|
165 | + if ($actions === false) { |
|
166 | + continue; |
|
167 | + } |
|
161 | 168 | |
162 | 169 | // Send the information to the template. |
163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
195 | 202 | $spiderContext = array(); |
196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
197 | 204 | { |
198 | - foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) |
|
199 | - $spiderContext[$id] = array( |
|
205 | + foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) { |
|
206 | + $spiderContext[$id] = array( |
|
200 | 207 | 'id' => 0, |
201 | 208 | 'name' => $name, |
202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
205 | 212 | 'email' => $name, |
206 | 213 | 'is_guest' => true |
207 | 214 | ); |
215 | + } |
|
208 | 216 | } |
209 | 217 | |
210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
219 | 227 | // Put it in the context variables. |
220 | 228 | foreach ($context['members'] as $i => $member) |
221 | 229 | { |
222 | - if ($member['id'] != 0) |
|
223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
230 | + if ($member['id'] != 0) { |
|
231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
232 | + } |
|
224 | 233 | |
225 | 234 | // Keep the IP that came from the database. |
226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
230 | - else |
|
231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
239 | + } else { |
|
240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
241 | + } |
|
232 | 242 | } |
233 | 243 | |
234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
263 | 273 | { |
264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
265 | 275 | |
266 | - if (!allowedTo('who_view')) |
|
267 | - return array(); |
|
276 | + if (!allowedTo('who_view')) { |
|
277 | + return array(); |
|
278 | + } |
|
268 | 279 | loadLanguage('Who'); |
269 | 280 | |
270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
292 | 303 | ); |
293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
294 | 305 | |
295 | - if (!is_array($urls)) |
|
296 | - $url_list = array(array($urls, $user_info['id'])); |
|
297 | - else |
|
298 | - $url_list = $urls; |
|
306 | + if (!is_array($urls)) { |
|
307 | + $url_list = array(array($urls, $user_info['id'])); |
|
308 | + } else { |
|
309 | + $url_list = $urls; |
|
310 | + } |
|
299 | 311 | |
300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
307 | 319 | { |
308 | 320 | // Get the request parameters.. |
309 | 321 | $actions = $smcFunc['json_decode']($url[0], true); |
310 | - if ($actions === false) |
|
311 | - continue; |
|
322 | + if ($actions === false) { |
|
323 | + continue; |
|
324 | + } |
|
312 | 325 | |
313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
315 | - $actions['action'] = $actions['area']; |
|
327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
328 | + $actions['action'] = $actions['area']; |
|
329 | + } |
|
316 | 330 | |
317 | 331 | // Check if there was no action or the action is display. |
318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
333 | 347 | } |
334 | 348 | // It's the board index!! It must be! |
335 | - else |
|
336 | - $data[$k] = $txt['who_index']; |
|
349 | + else { |
|
350 | + $data[$k] = $txt['who_index']; |
|
351 | + } |
|
337 | 352 | } |
338 | 353 | // Probably an error or some goon? |
339 | - elseif ($actions['action'] == '') |
|
340 | - $data[$k] = $txt['who_index']; |
|
354 | + elseif ($actions['action'] == '') { |
|
355 | + $data[$k] = $txt['who_index']; |
|
356 | + } |
|
341 | 357 | // Some other normal action...? |
342 | 358 | else |
343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
345 | 361 | if ($actions['action'] == 'profile') |
346 | 362 | { |
347 | 363 | // Whose? Their own? |
348 | - if (empty($actions['u'])) |
|
349 | - $actions['u'] = $url[1]; |
|
364 | + if (empty($actions['u'])) { |
|
365 | + $actions['u'] = $url[1]; |
|
366 | + } |
|
350 | 367 | |
351 | 368 | $data[$k] = $txt['who_hidden']; |
352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
353 | - } |
|
354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
355 | 371 | { |
356 | 372 | $data[$k] = $txt['who_hidden']; |
357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
358 | 374 | } |
359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
378 | + } |
|
362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
382 | + } |
|
365 | 383 | // Viewable if and only if they can see the board... |
366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
370 | 388 | |
371 | 389 | $data[$k] = $txt['who_hidden']; |
372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
373 | - } |
|
374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
375 | 392 | { |
376 | 393 | // Find out what message they are accessing. |
377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
395 | 412 | $smcFunc['db_free_result']($result); |
396 | 413 | |
397 | - if (empty($id_topic)) |
|
398 | - $data[$k] = $txt['who_hidden']; |
|
414 | + if (empty($id_topic)) { |
|
415 | + $data[$k] = $txt['who_hidden']; |
|
416 | + } |
|
399 | 417 | } |
400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
421 | + } |
|
403 | 422 | // Viewable by permission level. |
404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
405 | 424 | { |
406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
409 | - $data[$k] = $txt['who_moderate']; |
|
410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
411 | - $data[$k] = $txt['who_admin']; |
|
412 | - else |
|
413 | - $data[$k] = $txt['who_hidden']; |
|
425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
428 | + $data[$k] = $txt['who_moderate']; |
|
429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
430 | + $data[$k] = $txt['who_admin']; |
|
431 | + } else { |
|
432 | + $data[$k] = $txt['who_hidden']; |
|
433 | + } |
|
434 | + } elseif (!empty($actions['action'])) { |
|
435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
436 | + } else { |
|
437 | + $data[$k] = $txt['who_unknown']; |
|
414 | 438 | } |
415 | - elseif (!empty($actions['action'])) |
|
416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
417 | - else |
|
418 | - $data[$k] = $txt['who_unknown']; |
|
419 | 439 | } |
420 | 440 | |
421 | 441 | if (isset($actions['error'])) |
422 | 442 | { |
423 | - if (isset($txt[$actions['error']])) |
|
424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
425 | - elseif ($actions['error'] == 'guest_login') |
|
426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
427 | - else |
|
428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
429 | - |
|
430 | - if (!empty($error_message)) |
|
431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
443 | + if (isset($txt[$actions['error']])) { |
|
444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
445 | + } elseif ($actions['error'] == 'guest_login') { |
|
446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
447 | + } else { |
|
448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
449 | + } |
|
450 | + |
|
451 | + if (!empty($error_message)) { |
|
452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
453 | + } |
|
432 | 454 | } |
433 | 455 | |
434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
439 | 461 | if (!empty($integrate_action)) |
440 | 462 | { |
441 | 463 | $data[$k] = $integrate_action; |
442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
466 | + } |
|
467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
469 | + } |
|
470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
472 | + } |
|
448 | 473 | break; |
449 | 474 | } |
450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
473 | 498 | { |
474 | 499 | // Show the topic's subject for each of the actions. |
475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
502 | + } |
|
477 | 503 | } |
478 | 504 | $smcFunc['db_free_result']($result); |
479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
496 | 522 | { |
497 | 523 | // Put the board name into the string for each member... |
498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
526 | + } |
|
500 | 527 | } |
501 | 528 | $smcFunc['db_free_result']($result); |
502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
519 | 546 | { |
520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
522 | - continue; |
|
548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
549 | + continue; |
|
550 | + } |
|
523 | 551 | |
524 | 552 | // Set their action on each - session/text to sprintf. |
525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
555 | + } |
|
527 | 556 | } |
528 | 557 | $smcFunc['db_free_result']($result); |
529 | 558 | } |
530 | 559 | |
531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
532 | 561 | |
533 | - if (!is_array($urls)) |
|
534 | - return isset($data[0]) ? $data[0] : false; |
|
535 | - else |
|
536 | - return $data; |
|
537 | -} |
|
562 | + if (!is_array($urls)) { |
|
563 | + return isset($data[0]) ? $data[0] : false; |
|
564 | + } else { |
|
565 | + return $data; |
|
566 | + } |
|
567 | + } |
|
538 | 568 | |
539 | 569 | /** |
540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -710,8 +740,8 @@ discard block |
||
710 | 740 | ); |
711 | 741 | |
712 | 742 | // Give the translators some credit for their hard work. |
713 | - if (!empty($txt['translation_credits'])) |
|
714 | - $context['credits'][] = array( |
|
743 | + if (!empty($txt['translation_credits'])) { |
|
744 | + $context['credits'][] = array( |
|
715 | 745 | 'title' => $txt['credits_groups_translation'], |
716 | 746 | 'groups' => array( |
717 | 747 | array( |
@@ -720,6 +750,7 @@ discard block |
||
720 | 750 | ), |
721 | 751 | ), |
722 | 752 | ); |
753 | + } |
|
723 | 754 | |
724 | 755 | $context['credits'][] = array( |
725 | 756 | 'title' => $txt['credits_special'], |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | 'Jessica "Suki" González', |
593 | 593 | 'Karl "RegularExpression" Benson', |
594 | 594 | 'Matthew "Labradoodle-360" Kerle', |
595 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
595 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
596 | 596 | 'Michael "Thantos" Miller', |
597 | 597 | 'Norv', |
598 | 598 | 'Peter "Arantor" Spicer', |
@@ -824,13 +824,13 @@ discard block |
||
824 | 824 | $credit_info = $smcFunc['json_decode']($row['credits'], true); |
825 | 825 | |
826 | 826 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
827 | - $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
827 | + $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
828 | 828 | $version = $txt['credits_version'] . ' ' . $row['version']; |
829 | 829 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
830 | 830 | |
831 | 831 | // build this one out and stash it away |
832 | 832 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
833 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
833 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
834 | 834 | } |
835 | 835 | cache_put_data('mods_credits', $mods, 86400); |
836 | 836 | } |
@@ -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 | * Check if the current directory is still valid or not. |
@@ -28,22 +29,24 @@ discard block |
||
28 | 29 | global $smcFunc, $boarddir, $modSettings, $context; |
29 | 30 | |
30 | 31 | // Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found. |
31 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') |
|
32 | - $doit = true; |
|
33 | - elseif (empty($modSettings['automanage_attachments'])) |
|
34 | - return; |
|
35 | - elseif (!isset($_FILES)) |
|
36 | - return; |
|
37 | - elseif (isset($_FILES['attachment'])) |
|
38 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
32 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') { |
|
33 | + $doit = true; |
|
34 | + } elseif (empty($modSettings['automanage_attachments'])) { |
|
35 | + return; |
|
36 | + } elseif (!isset($_FILES)) { |
|
37 | + return; |
|
38 | + } elseif (isset($_FILES['attachment'])) { |
|
39 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
39 | 40 | if (!empty($dummy)) |
40 | 41 | { |
41 | 42 | $doit = true; |
43 | + } |
|
42 | 44 | break; |
43 | 45 | } |
44 | 46 | |
45 | - if (!isset($doit)) |
|
46 | - return; |
|
47 | + if (!isset($doit)) { |
|
48 | + return; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | $year = date('Y'); |
49 | 52 | $month = date('m'); |
@@ -54,21 +57,25 @@ discard block |
||
54 | 57 | |
55 | 58 | if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments'])) |
56 | 59 | { |
57 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
58 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
60 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
61 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
62 | + } |
|
59 | 63 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
64 | + } else { |
|
65 | + $base_dir = 0; |
|
60 | 66 | } |
61 | - else |
|
62 | - $base_dir = 0; |
|
63 | 67 | |
64 | 68 | if ($modSettings['automanage_attachments'] == 1) |
65 | 69 | { |
66 | - if (!isset($modSettings['last_attachments_directory'])) |
|
67 | - $modSettings['last_attachments_directory'] = array(); |
|
68 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
69 | - $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
70 | - if (!isset($modSettings['last_attachments_directory'][$base_dir])) |
|
71 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
70 | + if (!isset($modSettings['last_attachments_directory'])) { |
|
71 | + $modSettings['last_attachments_directory'] = array(); |
|
72 | + } |
|
73 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
74 | + $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
75 | + } |
|
76 | + if (!isset($modSettings['last_attachments_directory'][$base_dir])) { |
|
77 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
78 | + } |
|
72 | 79 | } |
73 | 80 | |
74 | 81 | $basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
@@ -97,12 +104,14 @@ discard block |
||
97 | 104 | $updir = ''; |
98 | 105 | } |
99 | 106 | |
100 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
101 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
102 | - if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) |
|
103 | - $outputCreation = automanage_attachments_create_directory($updir); |
|
104 | - elseif (in_array($updir, $modSettings['attachmentUploadDir'])) |
|
105 | - $outputCreation = true; |
|
107 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
108 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
109 | + } |
|
110 | + if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) { |
|
111 | + $outputCreation = automanage_attachments_create_directory($updir); |
|
112 | + } elseif (in_array($updir, $modSettings['attachmentUploadDir'])) { |
|
113 | + $outputCreation = true; |
|
114 | + } |
|
106 | 115 | |
107 | 116 | if ($outputCreation) |
108 | 117 | { |
@@ -139,8 +148,9 @@ discard block |
||
139 | 148 | $count = count($tree); |
140 | 149 | |
141 | 150 | $directory = attachments_init_dir($tree, $count); |
142 | - if ($directory === false) |
|
143 | - return false; |
|
151 | + if ($directory === false) { |
|
152 | + return false; |
|
153 | + } |
|
144 | 154 | } |
145 | 155 | |
146 | 156 | $directory .= DIRECTORY_SEPARATOR . array_shift($tree); |
@@ -168,8 +178,9 @@ discard block |
||
168 | 178 | } |
169 | 179 | |
170 | 180 | // Everything seems fine...let's create the .htaccess |
171 | - if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) |
|
172 | - secureDirectory($updir, true); |
|
181 | + if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) { |
|
182 | + secureDirectory($updir, true); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | $sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR; |
175 | 186 | $updir = rtrim($updir, $sep); |
@@ -201,8 +212,9 @@ discard block |
||
201 | 212 | { |
202 | 213 | global $smcFunc, $modSettings, $boarddir; |
203 | 214 | |
204 | - if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) |
|
205 | - return; |
|
215 | + if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) { |
|
216 | + return; |
|
217 | + } |
|
206 | 218 | |
207 | 219 | $basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir; |
208 | 220 | // Just to be sure: I don't want directory separators at the end |
@@ -214,13 +226,14 @@ discard block |
||
214 | 226 | { |
215 | 227 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
216 | 228 | $base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0; |
229 | + } else { |
|
230 | + $base_dir = 0; |
|
217 | 231 | } |
218 | - else |
|
219 | - $base_dir = 0; |
|
220 | 232 | |
221 | 233 | // Get the last attachment directory for that base directory |
222 | - if (empty($modSettings['last_attachments_directory'][$base_dir])) |
|
223 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
234 | + if (empty($modSettings['last_attachments_directory'][$base_dir])) { |
|
235 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
236 | + } |
|
224 | 237 | // And increment it. |
225 | 238 | $modSettings['last_attachments_directory'][$base_dir]++; |
226 | 239 | |
@@ -235,10 +248,10 @@ discard block |
||
235 | 248 | $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
236 | 249 | |
237 | 250 | return true; |
251 | + } else { |
|
252 | + return false; |
|
253 | + } |
|
238 | 254 | } |
239 | - else |
|
240 | - return false; |
|
241 | -} |
|
242 | 255 | |
243 | 256 | /** |
244 | 257 | * Split a path into a list of all directories and subdirectories |
@@ -256,12 +269,13 @@ discard block |
||
256 | 269 | * in Windows we need to explode for both \ and / |
257 | 270 | * while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR) |
258 | 271 | */ |
259 | - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') |
|
260 | - $tree = preg_split('#[\\\/]#', $directory); |
|
261 | - else |
|
272 | + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
273 | + $tree = preg_split('#[\\\/]#', $directory); |
|
274 | + } else |
|
262 | 275 | { |
263 | - if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) |
|
264 | - return false; |
|
276 | + if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) { |
|
277 | + return false; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | $tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR)); |
267 | 281 | } |
@@ -285,10 +299,11 @@ discard block |
||
285 | 299 | //Better be sure that the first part of the path is actually a drive letter... |
286 | 300 | //...even if, I should check this in the admin page...isn't it? |
287 | 301 | //...NHAAA Let's leave space for users' complains! :P |
288 | - if (preg_match('/^[a-z]:$/i', $tree[0])) |
|
289 | - $directory = array_shift($tree); |
|
290 | - else |
|
291 | - return false; |
|
302 | + if (preg_match('/^[a-z]:$/i', $tree[0])) { |
|
303 | + $directory = array_shift($tree); |
|
304 | + } else { |
|
305 | + return false; |
|
306 | + } |
|
292 | 307 | |
293 | 308 | $count--; |
294 | 309 | } |
@@ -303,18 +318,20 @@ discard block |
||
303 | 318 | global $context, $modSettings, $smcFunc, $txt, $user_info; |
304 | 319 | |
305 | 320 | // Make sure we're uploading to the right place. |
306 | - if (!empty($modSettings['automanage_attachments'])) |
|
307 | - automanage_attachments_check_directory(); |
|
321 | + if (!empty($modSettings['automanage_attachments'])) { |
|
322 | + automanage_attachments_check_directory(); |
|
323 | + } |
|
308 | 324 | |
309 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
310 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
325 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
326 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
327 | + } |
|
311 | 328 | |
312 | 329 | $context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
313 | 330 | |
314 | 331 | // Is the attachments folder actualy there? |
315 | - if (!empty($context['dir_creation_error'])) |
|
316 | - $initial_error = $context['dir_creation_error']; |
|
317 | - elseif (!is_dir($context['attach_dir'])) |
|
332 | + if (!empty($context['dir_creation_error'])) { |
|
333 | + $initial_error = $context['dir_creation_error']; |
|
334 | + } elseif (!is_dir($context['attach_dir'])) |
|
318 | 335 | { |
319 | 336 | $initial_error = 'attach_folder_warning'; |
320 | 337 | log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical'); |
@@ -337,12 +354,12 @@ discard block |
||
337 | 354 | ); |
338 | 355 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
339 | 356 | $smcFunc['db_free_result']($request); |
340 | - } |
|
341 | - else |
|
342 | - $context['attachments'] = array( |
|
357 | + } else { |
|
358 | + $context['attachments'] = array( |
|
343 | 359 | 'quantity' => 0, |
344 | 360 | 'total_size' => 0, |
345 | 361 | ); |
362 | + } |
|
346 | 363 | } |
347 | 364 | |
348 | 365 | // Hmm. There are still files in session. |
@@ -352,39 +369,44 @@ discard block |
||
352 | 369 | // Let's try to keep them. But... |
353 | 370 | $ignore_temp = true; |
354 | 371 | // If new files are being added. We can't ignore those |
355 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
356 | - if (!empty($dummy)) |
|
372 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) { |
|
373 | + if (!empty($dummy)) |
|
357 | 374 | { |
358 | 375 | $ignore_temp = false; |
376 | + } |
|
359 | 377 | break; |
360 | 378 | } |
361 | 379 | |
362 | 380 | // Need to make space for the new files. So, bye bye. |
363 | 381 | if (!$ignore_temp) |
364 | 382 | { |
365 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
366 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
383 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
384 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
367 | 385 | unlink($attachment['tmp_name']); |
386 | + } |
|
368 | 387 | |
369 | 388 | $context['we_are_history'] = $txt['error_temp_attachments_flushed']; |
370 | 389 | $_SESSION['temp_attachments'] = array(); |
371 | 390 | } |
372 | 391 | } |
373 | 392 | |
374 | - if (!isset($_FILES['attachment']['name'])) |
|
375 | - $_FILES['attachment']['tmp_name'] = array(); |
|
393 | + if (!isset($_FILES['attachment']['name'])) { |
|
394 | + $_FILES['attachment']['tmp_name'] = array(); |
|
395 | + } |
|
376 | 396 | |
377 | - if (!isset($_SESSION['temp_attachments'])) |
|
378 | - $_SESSION['temp_attachments'] = array(); |
|
397 | + if (!isset($_SESSION['temp_attachments'])) { |
|
398 | + $_SESSION['temp_attachments'] = array(); |
|
399 | + } |
|
379 | 400 | |
380 | 401 | // Remember where we are at. If it's anywhere at all. |
381 | - if (!$ignore_temp) |
|
382 | - $_SESSION['temp_attachments']['post'] = array( |
|
402 | + if (!$ignore_temp) { |
|
403 | + $_SESSION['temp_attachments']['post'] = array( |
|
383 | 404 | 'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0, |
384 | 405 | 'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0, |
385 | 406 | 'topic' => !empty($topic) ? $topic : 0, |
386 | 407 | 'board' => !empty($board) ? $board : 0, |
387 | 408 | ); |
409 | + } |
|
388 | 410 | |
389 | 411 | // If we have an initial error, lets just display it. |
390 | 412 | if (!empty($initial_error)) |
@@ -392,9 +414,10 @@ discard block |
||
392 | 414 | $_SESSION['temp_attachments']['initial_error'] = $initial_error; |
393 | 415 | |
394 | 416 | // And delete the files 'cos they ain't going nowhere. |
395 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
396 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
417 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
418 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
397 | 419 | unlink($_FILES['attachment']['tmp_name'][$n]); |
420 | + } |
|
398 | 421 | |
399 | 422 | $_FILES['attachment']['tmp_name'] = array(); |
400 | 423 | } |
@@ -402,21 +425,24 @@ discard block |
||
402 | 425 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
403 | 426 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
404 | 427 | { |
405 | - if ($_FILES['attachment']['name'][$n] == '') |
|
406 | - continue; |
|
428 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
429 | + continue; |
|
430 | + } |
|
407 | 431 | |
408 | 432 | // First, let's first check for PHP upload errors. |
409 | 433 | $errors = array(); |
410 | 434 | if (!empty($_FILES['attachment']['error'][$n])) |
411 | 435 | { |
412 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
413 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
414 | - elseif ($_FILES['attachment']['error'][$n] == 6) |
|
415 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
416 | - else |
|
417 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
418 | - if (empty($errors)) |
|
419 | - $errors[] = 'attach_php_error'; |
|
436 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
437 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
438 | + } elseif ($_FILES['attachment']['error'][$n] == 6) { |
|
439 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
440 | + } else { |
|
441 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
442 | + } |
|
443 | + if (empty($errors)) { |
|
444 | + $errors[] = 'attach_php_error'; |
|
445 | + } |
|
420 | 446 | } |
421 | 447 | |
422 | 448 | // Try to move and rename the file before doing any more checks on it. |
@@ -426,8 +452,9 @@ discard block |
||
426 | 452 | { |
427 | 453 | // The reported MIME type of the attachment might not be reliable. |
428 | 454 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
429 | - if (function_exists('mime_content_type')) |
|
430 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
455 | + if (function_exists('mime_content_type')) { |
|
456 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
457 | + } |
|
431 | 458 | |
432 | 459 | $_SESSION['temp_attachments'][$attachID] = array( |
433 | 460 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -439,16 +466,16 @@ discard block |
||
439 | 466 | ); |
440 | 467 | |
441 | 468 | // Move the file to the attachments folder with a temp name for now. |
442 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
443 | - smf_chmod($destName, 0644); |
|
444 | - else |
|
469 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
470 | + smf_chmod($destName, 0644); |
|
471 | + } else |
|
445 | 472 | { |
446 | 473 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
447 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
448 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
474 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
475 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
476 | + } |
|
449 | 477 | } |
450 | - } |
|
451 | - else |
|
478 | + } else |
|
452 | 479 | { |
453 | 480 | $_SESSION['temp_attachments'][$attachID] = array( |
454 | 481 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -456,12 +483,14 @@ discard block |
||
456 | 483 | 'errors' => $errors, |
457 | 484 | ); |
458 | 485 | |
459 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
460 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
486 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
487 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
488 | + } |
|
461 | 489 | } |
462 | 490 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
463 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
464 | - attachmentChecks($attachID); |
|
491 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
492 | + attachmentChecks($attachID); |
|
493 | + } |
|
465 | 494 | } |
466 | 495 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
467 | 496 | // Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand()) |
@@ -488,21 +517,20 @@ discard block |
||
488 | 517 | global $modSettings, $context, $sourcedir, $smcFunc; |
489 | 518 | |
490 | 519 | // No data or missing data .... Not necessarily needed, but in case a mod author missed something. |
491 | - if (empty($_SESSION['temp_attachments'][$attachID])) |
|
492 | - $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
493 | - |
|
494 | - elseif (empty($attachID)) |
|
495 | - $error = '$attachID'; |
|
496 | - |
|
497 | - elseif (empty($context['attachments'])) |
|
498 | - $error = '$context[\'attachments\']'; |
|
499 | - |
|
500 | - elseif (empty($context['attach_dir'])) |
|
501 | - $error = '$context[\'attach_dir\']'; |
|
520 | + if (empty($_SESSION['temp_attachments'][$attachID])) { |
|
521 | + $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
522 | + } elseif (empty($attachID)) { |
|
523 | + $error = '$attachID'; |
|
524 | + } elseif (empty($context['attachments'])) { |
|
525 | + $error = '$context[\'attachments\']'; |
|
526 | + } elseif (empty($context['attach_dir'])) { |
|
527 | + $error = '$context[\'attach_dir\']'; |
|
528 | + } |
|
502 | 529 | |
503 | 530 | // Let's get their attention. |
504 | - if (!empty($error)) |
|
505 | - fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
531 | + if (!empty($error)) { |
|
532 | + fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
533 | + } |
|
506 | 534 | |
507 | 535 | // Just in case this slipped by the first checks, we stop it here and now |
508 | 536 | if ($_SESSION['temp_attachments'][$attachID]['size'] == 0) |
@@ -531,8 +559,9 @@ discard block |
||
531 | 559 | $size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']); |
532 | 560 | if (!(empty($size)) && ($size[2] != $old_format)) |
533 | 561 | { |
534 | - if (isset($context['validImageTypes'][$size[2]])) |
|
535 | - $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
562 | + if (isset($context['validImageTypes'][$size[2]])) { |
|
563 | + $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
564 | + } |
|
536 | 565 | } |
537 | 566 | } |
538 | 567 | } |
@@ -586,42 +615,48 @@ discard block |
||
586 | 615 | // Or, let the user know that it ain't gonna happen. |
587 | 616 | else |
588 | 617 | { |
589 | - if (isset($context['dir_creation_error'])) |
|
590 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
591 | - else |
|
592 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
618 | + if (isset($context['dir_creation_error'])) { |
|
619 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
620 | + } else { |
|
621 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
622 | + } |
|
593 | 623 | } |
624 | + } else { |
|
625 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
594 | 626 | } |
595 | - else |
|
596 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
597 | 627 | } |
598 | 628 | } |
599 | 629 | |
600 | 630 | // Is the file too big? |
601 | 631 | $context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size']; |
602 | - if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) |
|
603 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
632 | + if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) { |
|
633 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
634 | + } |
|
604 | 635 | |
605 | 636 | // Check the total upload size for this post... |
606 | - if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) |
|
607 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
637 | + if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) { |
|
638 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
639 | + } |
|
608 | 640 | |
609 | 641 | // Have we reached the maximum number of files we are allowed? |
610 | 642 | $context['attachments']['quantity']++; |
611 | 643 | |
612 | 644 | // Set a max limit if none exists |
613 | - if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) |
|
614 | - $modSettings['attachmentNumPerPostLimit'] = 50; |
|
645 | + if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) { |
|
646 | + $modSettings['attachmentNumPerPostLimit'] = 50; |
|
647 | + } |
|
615 | 648 | |
616 | - if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) |
|
617 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
649 | + if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) { |
|
650 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
651 | + } |
|
618 | 652 | |
619 | 653 | // File extension check |
620 | 654 | if (!empty($modSettings['attachmentCheckExtensions'])) |
621 | 655 | { |
622 | 656 | $allowed = explode(',', strtolower($modSettings['attachmentExtensions'])); |
623 | - foreach ($allowed as $k => $dummy) |
|
624 | - $allowed[$k] = trim($dummy); |
|
657 | + foreach ($allowed as $k => $dummy) { |
|
658 | + $allowed[$k] = trim($dummy); |
|
659 | + } |
|
625 | 660 | |
626 | 661 | if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed)) |
627 | 662 | { |
@@ -633,10 +668,12 @@ discard block |
||
633 | 668 | // Undo the math if there's an error |
634 | 669 | if (!empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
635 | 670 | { |
636 | - if (isset($context['dir_size'])) |
|
637 | - $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
638 | - if (isset($context['dir_files'])) |
|
639 | - $context['dir_files']--; |
|
671 | + if (isset($context['dir_size'])) { |
|
672 | + $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
673 | + } |
|
674 | + if (isset($context['dir_files'])) { |
|
675 | + $context['dir_files']--; |
|
676 | + } |
|
640 | 677 | $context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
641 | 678 | $context['attachments']['quantity']--; |
642 | 679 | return false; |
@@ -668,12 +705,14 @@ discard block |
||
668 | 705 | if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width']) |
669 | 706 | { |
670 | 707 | // Got a proper mime type? |
671 | - if (!empty($size['mime'])) |
|
672 | - $attachmentOptions['mime_type'] = $size['mime']; |
|
708 | + if (!empty($size['mime'])) { |
|
709 | + $attachmentOptions['mime_type'] = $size['mime']; |
|
710 | + } |
|
673 | 711 | |
674 | 712 | // Otherwise a valid one? |
675 | - elseif (isset($context['validImageTypes'][$size[2]])) |
|
676 | - $attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
713 | + elseif (isset($context['validImageTypes'][$size[2]])) { |
|
714 | + $attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
715 | + } |
|
677 | 716 | } |
678 | 717 | |
679 | 718 | // It is possible we might have a MIME type that isn't actually an image but still have a size. |
@@ -685,15 +724,17 @@ discard block |
||
685 | 724 | } |
686 | 725 | |
687 | 726 | // Get the hash if no hash has been given yet. |
688 | - if (empty($attachmentOptions['file_hash'])) |
|
689 | - $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
727 | + if (empty($attachmentOptions['file_hash'])) { |
|
728 | + $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
729 | + } |
|
690 | 730 | |
691 | 731 | // Assuming no-one set the extension let's take a look at it. |
692 | 732 | if (empty($attachmentOptions['fileext'])) |
693 | 733 | { |
694 | 734 | $attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : ''); |
695 | - if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) |
|
696 | - $attachmentOptions['fileext'] = ''; |
|
735 | + if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) { |
|
736 | + $attachmentOptions['fileext'] = ''; |
|
737 | + } |
|
697 | 738 | } |
698 | 739 | |
699 | 740 | // Last chance to change stuff! |
@@ -702,8 +743,9 @@ discard block |
||
702 | 743 | // Make sure the folder is valid... |
703 | 744 | $tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
704 | 745 | $folders = array_keys($tmp); |
705 | - if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) |
|
706 | - $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
746 | + if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) { |
|
747 | + $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
748 | + } |
|
707 | 749 | |
708 | 750 | $attachmentOptions['id'] = $smcFunc['db_insert']('', |
709 | 751 | '{db_prefix}attachments', |
@@ -734,8 +776,8 @@ discard block |
||
734 | 776 | rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']); |
735 | 777 | |
736 | 778 | // If it's not approved then add to the approval queue. |
737 | - if (!$attachmentOptions['approved']) |
|
738 | - $smcFunc['db_insert']('', |
|
779 | + if (!$attachmentOptions['approved']) { |
|
780 | + $smcFunc['db_insert']('', |
|
739 | 781 | '{db_prefix}approval_queue', |
740 | 782 | array( |
741 | 783 | 'id_attach' => 'int', 'id_msg' => 'int', |
@@ -745,9 +787,11 @@ discard block |
||
745 | 787 | ), |
746 | 788 | array() |
747 | 789 | ); |
790 | + } |
|
748 | 791 | |
749 | - if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) |
|
750 | - return true; |
|
792 | + if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) { |
|
793 | + return true; |
|
794 | + } |
|
751 | 795 | |
752 | 796 | // Like thumbnails, do we? |
753 | 797 | if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight'])) |
@@ -758,13 +802,15 @@ discard block |
||
758 | 802 | $size = @getimagesize($attachmentOptions['destination'] . '_thumb'); |
759 | 803 | list ($thumb_width, $thumb_height) = $size; |
760 | 804 | |
761 | - if (!empty($size['mime'])) |
|
762 | - $thumb_mime = $size['mime']; |
|
763 | - elseif (isset($context['validImageTypes'][$size[2]])) |
|
764 | - $thumb_mime = 'image/' . $context['validImageTypes'][$size[2]]; |
|
805 | + if (!empty($size['mime'])) { |
|
806 | + $thumb_mime = $size['mime']; |
|
807 | + } elseif (isset($context['validImageTypes'][$size[2]])) { |
|
808 | + $thumb_mime = 'image/' . $context['validImageTypes'][$size[2]]; |
|
809 | + } |
|
765 | 810 | // Lord only knows how this happened... |
766 | - else |
|
767 | - $thumb_mime = ''; |
|
811 | + else { |
|
812 | + $thumb_mime = ''; |
|
813 | + } |
|
768 | 814 | |
769 | 815 | $thumb_filename = $attachmentOptions['name'] . '_thumb'; |
770 | 816 | $thumb_size = filesize($attachmentOptions['destination'] . '_thumb'); |
@@ -844,15 +890,17 @@ discard block |
||
844 | 890 | global $smcFunc; |
845 | 891 | |
846 | 892 | // Oh, come on! |
847 | - if (empty($attachIDs) || empty($msgID)) |
|
848 | - return false; |
|
893 | + if (empty($attachIDs) || empty($msgID)) { |
|
894 | + return false; |
|
895 | + } |
|
849 | 896 | |
850 | 897 | // "I see what is right and approve, but I do what is wrong." |
851 | 898 | call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID)); |
852 | 899 | |
853 | 900 | // One last check |
854 | - if (empty($attachIDs)) |
|
855 | - return false; |
|
901 | + if (empty($attachIDs)) { |
|
902 | + return false; |
|
903 | + } |
|
856 | 904 | |
857 | 905 | // Perform. |
858 | 906 | $smcFunc['db_query']('', ' |
@@ -880,8 +928,9 @@ discard block |
||
880 | 928 | global $board, $modSettings, $context, $scripturl, $smcFunc; |
881 | 929 | |
882 | 930 | // Meh... |
883 | - if (empty($attachID)) |
|
884 | - return 'attachments_no_data_loaded'; |
|
931 | + if (empty($attachID)) { |
|
932 | + return 'attachments_no_data_loaded'; |
|
933 | + } |
|
885 | 934 | |
886 | 935 | // Make it easy. |
887 | 936 | $msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0; |
@@ -890,20 +939,23 @@ discard block |
||
890 | 939 | $externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID)); |
891 | 940 | |
892 | 941 | // "I am innocent of the blood of this just person: see ye to it." |
893 | - if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) |
|
894 | - return $externalParse; |
|
942 | + if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) { |
|
943 | + return $externalParse; |
|
944 | + } |
|
895 | 945 | |
896 | 946 | //Are attachments enable? |
897 | - if (empty($modSettings['attachmentEnable'])) |
|
898 | - return 'attachments_not_enable'; |
|
947 | + if (empty($modSettings['attachmentEnable'])) { |
|
948 | + return 'attachments_not_enable'; |
|
949 | + } |
|
899 | 950 | |
900 | 951 | // Previewing much? no msg ID has been set yet. |
901 | 952 | if (!empty($context['preview_message'])) |
902 | 953 | { |
903 | 954 | $allAttachments = getAttachsByMsg(0); |
904 | 955 | |
905 | - if (empty($allAttachments[0][$attachID])) |
|
906 | - return 'attachments_no_data_loaded'; |
|
956 | + if (empty($allAttachments[0][$attachID])) { |
|
957 | + return 'attachments_no_data_loaded'; |
|
958 | + } |
|
907 | 959 | |
908 | 960 | $attachLoaded = loadAttachmentContext(0, $allAttachments); |
909 | 961 | |
@@ -915,57 +967,66 @@ discard block |
||
915 | 967 | $attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>'; |
916 | 968 | |
917 | 969 | // Fix the thumbnail too, if the image has one. |
918 | - if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) |
|
919 | - $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
970 | + if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) { |
|
971 | + $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
972 | + } |
|
920 | 973 | |
921 | 974 | return $attachContext; |
922 | 975 | } |
923 | 976 | |
924 | 977 | // There is always the chance someone else has already done our dirty work... |
925 | 978 | // If so, all pertinent checks were already done. Hopefully... |
926 | - if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) |
|
927 | - return $context['current_attachments'][$attachID]; |
|
979 | + if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) { |
|
980 | + return $context['current_attachments'][$attachID]; |
|
981 | + } |
|
928 | 982 | |
929 | 983 | // If we are lucky enough to be in $board's scope then check it! |
930 | - if (!empty($board) && !allowedTo('view_attachments', $board)) |
|
931 | - return 'attachments_not_allowed_to_see'; |
|
984 | + if (!empty($board) && !allowedTo('view_attachments', $board)) { |
|
985 | + return 'attachments_not_allowed_to_see'; |
|
986 | + } |
|
932 | 987 | |
933 | 988 | // Get the message info associated with this particular attach ID. |
934 | 989 | $attachInfo = getAttachMsgInfo($attachID); |
935 | 990 | |
936 | 991 | // There is always the chance this attachment no longer exists or isn't associated to a message anymore... |
937 | - if (empty($attachInfo) || empty($attachInfo['msg'])) |
|
938 | - return 'attachments_no_msg_associated'; |
|
992 | + if (empty($attachInfo) || empty($attachInfo['msg'])) { |
|
993 | + return 'attachments_no_msg_associated'; |
|
994 | + } |
|
939 | 995 | |
940 | 996 | // Hold it! got the info now check if you can see this attachment. |
941 | - if (!allowedTo('view_attachments', $attachInfo['board'])) |
|
942 | - return 'attachments_not_allowed_to_see'; |
|
997 | + if (!allowedTo('view_attachments', $attachInfo['board'])) { |
|
998 | + return 'attachments_not_allowed_to_see'; |
|
999 | + } |
|
943 | 1000 | |
944 | 1001 | $allAttachments = getAttachsByMsg($attachInfo['msg']); |
945 | 1002 | $attachContext = $allAttachments[$attachInfo['msg']][$attachID]; |
946 | 1003 | |
947 | 1004 | // No point in keep going further. |
948 | - if (!allowedTo('view_attachments', $attachContext['board'])) |
|
949 | - return 'attachments_not_allowed_to_see'; |
|
1005 | + if (!allowedTo('view_attachments', $attachContext['board'])) { |
|
1006 | + return 'attachments_not_allowed_to_see'; |
|
1007 | + } |
|
950 | 1008 | |
951 | 1009 | // Load this particular attach's context. |
952 | - if (!empty($attachContext)) |
|
953 | - $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1010 | + if (!empty($attachContext)) { |
|
1011 | + $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1012 | + } |
|
954 | 1013 | |
955 | 1014 | // One last check, you know, gotta be paranoid... |
956 | - else |
|
957 | - return 'attachments_no_data_loaded'; |
|
1015 | + else { |
|
1016 | + return 'attachments_no_data_loaded'; |
|
1017 | + } |
|
958 | 1018 | |
959 | 1019 | // This is the last "if" I promise! |
960 | - if (empty($attachLoaded)) |
|
961 | - return 'attachments_no_data_loaded'; |
|
962 | - |
|
963 | - else |
|
964 | - $attachContext = $attachLoaded[$attachID]; |
|
1020 | + if (empty($attachLoaded)) { |
|
1021 | + return 'attachments_no_data_loaded'; |
|
1022 | + } else { |
|
1023 | + $attachContext = $attachLoaded[$attachID]; |
|
1024 | + } |
|
965 | 1025 | |
966 | 1026 | // You may or may not want to show this under the post. |
967 | - if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) |
|
968 | - $context['show_attach_under_post'][$attachID] = $attachID; |
|
1027 | + if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) { |
|
1028 | + $context['show_attach_under_post'][$attachID] = $attachID; |
|
1029 | + } |
|
969 | 1030 | |
970 | 1031 | // Last minute changes? |
971 | 1032 | call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext)); |
@@ -985,8 +1046,9 @@ discard block |
||
985 | 1046 | { |
986 | 1047 | global $smcFunc, $modSettings; |
987 | 1048 | |
988 | - if (empty($attachIDs)) |
|
989 | - return array(); |
|
1049 | + if (empty($attachIDs)) { |
|
1050 | + return array(); |
|
1051 | + } |
|
990 | 1052 | |
991 | 1053 | $return = array(); |
992 | 1054 | |
@@ -1002,11 +1064,12 @@ discard block |
||
1002 | 1064 | ) |
1003 | 1065 | ); |
1004 | 1066 | |
1005 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1006 | - return array(); |
|
1067 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1068 | + return array(); |
|
1069 | + } |
|
1007 | 1070 | |
1008 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1009 | - $return[$row['id_attach']] = array( |
|
1071 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1072 | + $return[$row['id_attach']] = array( |
|
1010 | 1073 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
1011 | 1074 | 'size' => $row['size'], |
1012 | 1075 | 'attachID' => $row['id_attach'], |
@@ -1015,6 +1078,7 @@ discard block |
||
1015 | 1078 | 'mime_type' => $row['mime_type'], |
1016 | 1079 | 'thumb' => $row['id_thumb'], |
1017 | 1080 | ); |
1081 | + } |
|
1018 | 1082 | $smcFunc['db_free_result']($request); |
1019 | 1083 | |
1020 | 1084 | return $return; |
@@ -1031,8 +1095,9 @@ discard block |
||
1031 | 1095 | { |
1032 | 1096 | global $smcFunc; |
1033 | 1097 | |
1034 | - if (empty($attachID)) |
|
1035 | - return array(); |
|
1098 | + if (empty($attachID)) { |
|
1099 | + return array(); |
|
1100 | + } |
|
1036 | 1101 | |
1037 | 1102 | $request = $smcFunc['db_query']('', ' |
1038 | 1103 | SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board |
@@ -1045,8 +1110,9 @@ discard block |
||
1045 | 1110 | ) |
1046 | 1111 | ); |
1047 | 1112 | |
1048 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1049 | - return array(); |
|
1113 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1114 | + return array(); |
|
1115 | + } |
|
1050 | 1116 | |
1051 | 1117 | $row = $smcFunc['db_fetch_assoc']($request); |
1052 | 1118 | $smcFunc['db_free_result']($request); |
@@ -1087,8 +1153,9 @@ discard block |
||
1087 | 1153 | $temp = array(); |
1088 | 1154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1089 | 1155 | { |
1090 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1091 | - continue; |
|
1156 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1157 | + continue; |
|
1158 | + } |
|
1092 | 1159 | |
1093 | 1160 | $temp[$row['id_attach']] = $row; |
1094 | 1161 | } |
@@ -1117,8 +1184,9 @@ discard block |
||
1117 | 1184 | { |
1118 | 1185 | global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc; |
1119 | 1186 | |
1120 | - if (empty($attachments) || empty($attachments[$id_msg])) |
|
1121 | - return array(); |
|
1187 | + if (empty($attachments) || empty($attachments[$id_msg])) { |
|
1188 | + return array(); |
|
1189 | + } |
|
1122 | 1190 | |
1123 | 1191 | // Set up the attachment info - based on code by Meriadoc. |
1124 | 1192 | $attachmentData = array(); |
@@ -1142,11 +1210,13 @@ discard block |
||
1142 | 1210 | ); |
1143 | 1211 | |
1144 | 1212 | // If something is unapproved we'll note it so we can sort them. |
1145 | - if (!$attachment['approved']) |
|
1146 | - $have_unapproved = true; |
|
1213 | + if (!$attachment['approved']) { |
|
1214 | + $have_unapproved = true; |
|
1215 | + } |
|
1147 | 1216 | |
1148 | - if (!$attachmentData[$i]['is_image']) |
|
1149 | - continue; |
|
1217 | + if (!$attachmentData[$i]['is_image']) { |
|
1218 | + continue; |
|
1219 | + } |
|
1150 | 1220 | |
1151 | 1221 | $attachmentData[$i]['real_width'] = $attachment['width']; |
1152 | 1222 | $attachmentData[$i]['width'] = $attachment['width']; |
@@ -1167,11 +1237,11 @@ discard block |
||
1167 | 1237 | // So what folder are we putting this image in? |
1168 | 1238 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1169 | 1239 | { |
1170 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1171 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1240 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1241 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1242 | + } |
|
1172 | 1243 | $id_folder_thumb = $modSettings['currentAttachmentUploadDir']; |
1173 | - } |
|
1174 | - else |
|
1244 | + } else |
|
1175 | 1245 | { |
1176 | 1246 | $id_folder_thumb = 1; |
1177 | 1247 | } |
@@ -1185,10 +1255,11 @@ discard block |
||
1185 | 1255 | $thumb_ext = isset($context['validImageTypes'][$size[2]]) ? $context['validImageTypes'][$size[2]] : ''; |
1186 | 1256 | |
1187 | 1257 | // Figure out the mime type. |
1188 | - if (!empty($size['mime'])) |
|
1189 | - $thumb_mime = $size['mime']; |
|
1190 | - else |
|
1191 | - $thumb_mime = 'image/' . $thumb_ext; |
|
1258 | + if (!empty($size['mime'])) { |
|
1259 | + $thumb_mime = $size['mime']; |
|
1260 | + } else { |
|
1261 | + $thumb_mime = 'image/' . $thumb_ext; |
|
1262 | + } |
|
1192 | 1263 | |
1193 | 1264 | $thumb_filename = $attachment['filename'] . '_thumb'; |
1194 | 1265 | $thumb_hash = getAttachmentFilename($thumb_filename, false, null, true); |
@@ -1235,11 +1306,12 @@ discard block |
||
1235 | 1306 | } |
1236 | 1307 | } |
1237 | 1308 | |
1238 | - if (!empty($attachment['id_thumb'])) |
|
1239 | - $attachmentData[$i]['thumbnail'] = array( |
|
1309 | + if (!empty($attachment['id_thumb'])) { |
|
1310 | + $attachmentData[$i]['thumbnail'] = array( |
|
1240 | 1311 | 'id' => $attachment['id_thumb'], |
1241 | 1312 | 'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image', |
1242 | 1313 | ); |
1314 | + } |
|
1243 | 1315 | $attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']); |
1244 | 1316 | |
1245 | 1317 | // If thumbnails are disabled, check the maximum size of the image. |
@@ -1249,30 +1321,31 @@ discard block |
||
1249 | 1321 | { |
1250 | 1322 | $attachmentData[$i]['width'] = $modSettings['max_image_width']; |
1251 | 1323 | $attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']); |
1252 | - } |
|
1253 | - elseif (!empty($modSettings['max_image_width'])) |
|
1324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
1254 | 1325 | { |
1255 | 1326 | $attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']); |
1256 | 1327 | $attachmentData[$i]['height'] = $modSettings['max_image_height']; |
1257 | 1328 | } |
1258 | - } |
|
1259 | - elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1329 | + } elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1260 | 1330 | { |
1261 | 1331 | // If the image is too large to show inline, make it a popup. |
1262 | - if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) |
|
1263 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1264 | - else |
|
1265 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1332 | + if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) { |
|
1333 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1334 | + } else { |
|
1335 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1336 | + } |
|
1266 | 1337 | } |
1267 | 1338 | |
1268 | - if (!$attachmentData[$i]['thumbnail']['has_thumb']) |
|
1269 | - $attachmentData[$i]['downloads']++; |
|
1339 | + if (!$attachmentData[$i]['thumbnail']['has_thumb']) { |
|
1340 | + $attachmentData[$i]['downloads']++; |
|
1341 | + } |
|
1270 | 1342 | } |
1271 | 1343 | } |
1272 | 1344 | |
1273 | 1345 | // Do we need to instigate a sort? |
1274 | - if ($have_unapproved) |
|
1275 | - usort($attachmentData, 'approved_attach_sort'); |
|
1346 | + if ($have_unapproved) { |
|
1347 | + usort($attachmentData, 'approved_attach_sort'); |
|
1348 | + } |
|
1276 | 1349 | |
1277 | 1350 | return $attachmentData; |
1278 | 1351 | } |
@@ -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 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | return; |
55 | 56 | } |
56 | 57 | |
57 | - if (empty($modSettings['search_custom_index_config'])) |
|
58 | - return; |
|
58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $this->indexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
61 | 63 | |
@@ -117,21 +119,23 @@ discard block |
||
117 | 119 | |
118 | 120 | $subwords = text2words($word, $this->min_word_length, true); |
119 | 121 | |
120 | - if (empty($modSettings['search_force_index'])) |
|
121 | - $wordsSearch['words'][] = $word; |
|
122 | + if (empty($modSettings['search_force_index'])) { |
|
123 | + $wordsSearch['words'][] = $word; |
|
124 | + } |
|
122 | 125 | |
123 | 126 | // Excluded phrases don't benefit from being split into subwords. |
124 | - if (count($subwords) > 1 && $isExcluded) |
|
125 | - return; |
|
126 | - else |
|
127 | + if (count($subwords) > 1 && $isExcluded) { |
|
128 | + return; |
|
129 | + } else |
|
127 | 130 | { |
128 | 131 | foreach ($subwords as $subword) |
129 | 132 | { |
130 | 133 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
131 | 134 | { |
132 | 135 | $wordsSearch['indexed_words'][] = $subword; |
133 | - if ($isExcluded) |
|
134 | - $wordsExclude[] = $subword; |
|
136 | + if ($isExcluded) { |
|
137 | + $wordsExclude[] = $subword; |
|
138 | + } |
|
135 | 139 | } |
136 | 140 | } |
137 | 141 | } |
@@ -152,8 +156,9 @@ discard block |
||
152 | 156 | $query_where = array(); |
153 | 157 | $query_params = $search_data['params']; |
154 | 158 | |
155 | - if ($query_params['id_search']) |
|
156 | - $query_select['id_search'] = '{int:id_search}'; |
|
159 | + if ($query_params['id_search']) { |
|
160 | + $query_select['id_search'] = '{int:id_search}'; |
|
161 | + } |
|
157 | 162 | |
158 | 163 | $count = 0; |
159 | 164 | foreach ($words['words'] as $regularWord) |
@@ -162,30 +167,37 @@ discard block |
||
162 | 167 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
163 | 168 | } |
164 | 169 | |
165 | - if ($query_params['user_query']) |
|
166 | - $query_where[] = '{raw:user_query}'; |
|
167 | - if ($query_params['board_query']) |
|
168 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
170 | + if ($query_params['user_query']) { |
|
171 | + $query_where[] = '{raw:user_query}'; |
|
172 | + } |
|
173 | + if ($query_params['board_query']) { |
|
174 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
175 | + } |
|
169 | 176 | |
170 | - if ($query_params['topic']) |
|
171 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
172 | - if ($query_params['min_msg_id']) |
|
173 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
174 | - if ($query_params['max_msg_id']) |
|
175 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
177 | + if ($query_params['topic']) { |
|
178 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
179 | + } |
|
180 | + if ($query_params['min_msg_id']) { |
|
181 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
182 | + } |
|
183 | + if ($query_params['max_msg_id']) { |
|
184 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
185 | + } |
|
176 | 186 | |
177 | 187 | $count = 0; |
178 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
179 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
188 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
189 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
180 | 190 | { |
181 | 191 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
192 | + } |
|
182 | 193 | $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), '\\\'') . '[[:>:]]'; |
183 | 194 | } |
184 | 195 | $count = 0; |
185 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
186 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
196 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
197 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
187 | 198 | { |
188 | 199 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
200 | + } |
|
189 | 201 | $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), '\\\'') . '[[:>:]]'; |
190 | 202 | } |
191 | 203 | |
@@ -198,8 +210,7 @@ discard block |
||
198 | 210 | { |
199 | 211 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
200 | 212 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
201 | - } |
|
202 | - else |
|
213 | + } else |
|
203 | 214 | { |
204 | 215 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
205 | 216 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -235,16 +246,18 @@ discard block |
||
235 | 246 | $customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
236 | 247 | |
237 | 248 | $inserts = array(); |
238 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
239 | - $inserts[] = array($word, $msgOptions['id']); |
|
249 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
250 | + $inserts[] = array($word, $msgOptions['id']); |
|
251 | + } |
|
240 | 252 | |
241 | - if (!empty($inserts)) |
|
242 | - $smcFunc['db_insert']('ignore', |
|
253 | + if (!empty($inserts)) { |
|
254 | + $smcFunc['db_insert']('ignore', |
|
243 | 255 | '{db_prefix}log_search_words', |
244 | 256 | array('id_word' => 'int', 'id_msg' => 'int'), |
245 | 257 | $inserts, |
246 | 258 | array('id_word', 'id_msg') |
247 | 259 | ); |
260 | + } |
|
248 | 261 | } |
249 | 262 | |
250 | 263 | /** |
@@ -287,8 +300,9 @@ discard block |
||
287 | 300 | if (!empty($inserted_words)) |
288 | 301 | { |
289 | 302 | $inserts = array(); |
290 | - foreach ($inserted_words as $word) |
|
291 | - $inserts[] = array($word, $msgOptions['id']); |
|
303 | + foreach ($inserted_words as $word) { |
|
304 | + $inserts[] = array($word, $msgOptions['id']); |
|
305 | + } |
|
292 | 306 | $smcFunc['db_insert']('insert', |
293 | 307 | '{db_prefix}log_search_words', |
294 | 308 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -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 | loadLanguage('Drafts'); |
21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
34 | 35 | |
35 | 36 | // can you be, should you be ... here? |
36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
37 | - return false; |
|
37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
38 | + return false; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | // read in what they sent us, if anything |
40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
47 | 49 | |
48 | 50 | // since we were called from the autosave function, send something back |
49 | - if (!empty($id_draft)) |
|
50 | - XmlDraft($id_draft); |
|
51 | + if (!empty($id_draft)) { |
|
52 | + XmlDraft($id_draft); |
|
53 | + } |
|
51 | 54 | |
52 | 55 | return true; |
53 | 56 | } |
54 | 57 | |
55 | - if (!isset($_POST['message'])) |
|
56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
58 | + if (!isset($_POST['message'])) { |
|
59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
60 | + } |
|
57 | 61 | |
58 | 62 | // prepare any data from the form |
59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
66 | 70 | |
67 | 71 | // message and subject still need a bit more work |
68 | 72 | preparsecode($draft['body']); |
69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
75 | + } |
|
71 | 76 | |
72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
148 | 153 | { |
149 | 154 | $context['draft_saved'] = true; |
150 | 155 | $context['id_draft'] = $id_draft; |
156 | + } else { |
|
157 | + $post_errors[] = 'draft_not_saved'; |
|
151 | 158 | } |
152 | - else |
|
153 | - $post_errors[] = 'draft_not_saved'; |
|
154 | 159 | |
155 | 160 | // cleanup |
156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
181 | 186 | |
182 | 187 | // PM survey says ... can you stay or must you go |
183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
184 | - return false; |
|
188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
189 | + return false; |
|
190 | + } |
|
185 | 191 | |
186 | 192 | // read in what you sent us |
187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
194 | 200 | |
195 | 201 | // Send something back to the javascript caller |
196 | - if (!empty($id_draft)) |
|
197 | - XmlDraft($id_draft); |
|
202 | + if (!empty($id_draft)) { |
|
203 | + XmlDraft($id_draft); |
|
204 | + } |
|
198 | 205 | |
199 | 206 | return true; |
200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
204 | 211 | { |
205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
215 | + $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
207 | 216 | } |
208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
209 | - $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
210 | 217 | |
211 | 218 | // prepare the data we got from the form |
212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | |
216 | 223 | // message and subject always need a bit more work |
217 | 224 | preparsecode($draft['body']); |
218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | // Modifying an existing PM draft? |
222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
280 | 288 | { |
281 | 289 | $context['draft_saved'] = true; |
282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
291 | + } else { |
|
292 | + $post_errors[] = 'draft_not_saved'; |
|
283 | 293 | } |
284 | - else |
|
285 | - $post_errors[] = 'draft_not_saved'; |
|
286 | 294 | } |
287 | 295 | |
288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
315 | 323 | $type = (int) $type; |
316 | 324 | |
317 | 325 | // nothing to read, nothing to do |
318 | - if (empty($id_draft)) |
|
319 | - return false; |
|
326 | + if (empty($id_draft)) { |
|
327 | + return false; |
|
328 | + } |
|
320 | 329 | |
321 | 330 | // load in this draft from the DB |
322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
337 | 346 | ); |
338 | 347 | |
339 | 348 | // no results? |
340 | - if (!$smcFunc['db_num_rows']($request)) |
|
341 | - return false; |
|
349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
350 | + return false; |
|
351 | + } |
|
342 | 352 | |
343 | 353 | // load up the data |
344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
361 | - } |
|
362 | - elseif ($type === 1) |
|
371 | + } elseif ($type === 1) |
|
363 | 372 | { |
364 | 373 | // one of those pm drafts? then set it up like we have an error |
365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
395 | 404 | global $user_info, $smcFunc; |
396 | 405 | |
397 | 406 | // Only a single draft. |
398 | - if (is_numeric($id_draft)) |
|
399 | - $id_draft = array($id_draft); |
|
407 | + if (is_numeric($id_draft)) { |
|
408 | + $id_draft = array($id_draft); |
|
409 | + } |
|
400 | 410 | |
401 | 411 | // can't delete nothing |
402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
403 | - return false; |
|
412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
413 | + return false; |
|
414 | + } |
|
404 | 415 | |
405 | 416 | $smcFunc['db_query']('', ' |
406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
430 | 441 | |
431 | 442 | // Permissions |
432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
433 | - return false; |
|
443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
444 | + return false; |
|
445 | + } |
|
434 | 446 | |
435 | 447 | $context['drafts'] = array(); |
436 | 448 | |
437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
452 | + } |
|
440 | 453 | |
441 | 454 | // load the drafts this user has available |
442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
459 | 472 | // add them to the draft array for display |
460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
461 | 474 | { |
462 | - if (empty($row['subject'])) |
|
463 | - $row['subject'] = $txt['no_subject']; |
|
475 | + if (empty($row['subject'])) { |
|
476 | + $row['subject'] = $txt['no_subject']; |
|
477 | + } |
|
464 | 478 | |
465 | 479 | // Post drafts |
466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | } |
546 | 560 | |
547 | 561 | // Default to 10. |
548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
549 | - $_REQUEST['viewscount'] = 10; |
|
562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
563 | + $_REQUEST['viewscount'] = 10; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
612 | 627 | { |
613 | 628 | // Censor.... |
614 | - if (empty($row['body'])) |
|
615 | - $row['body'] = ''; |
|
629 | + if (empty($row['body'])) { |
|
630 | + $row['body'] = ''; |
|
631 | + } |
|
616 | 632 | |
617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
618 | - if (empty($row['subject'])) |
|
619 | - $row['subject'] = $txt['no_subject']; |
|
634 | + if (empty($row['subject'])) { |
|
635 | + $row['subject'] = $txt['no_subject']; |
|
636 | + } |
|
620 | 637 | |
621 | 638 | censorText($row['body']); |
622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
648 | 665 | $smcFunc['db_free_result']($request); |
649 | 666 | |
650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
651 | - if ($reverse) |
|
652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
668 | + if ($reverse) { |
|
669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
670 | + } |
|
653 | 671 | |
654 | 672 | // Menu tab |
655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
707 | 725 | } |
708 | 726 | |
709 | 727 | // Default to 10. |
710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
711 | - $_REQUEST['viewscount'] = 10; |
|
728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
729 | + $_REQUEST['viewscount'] = 10; |
|
730 | + } |
|
712 | 731 | |
713 | 732 | // Get the count of applicable drafts |
714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
768 | 787 | { |
769 | 788 | // Censor.... |
770 | - if (empty($row['body'])) |
|
771 | - $row['body'] = ''; |
|
789 | + if (empty($row['body'])) { |
|
790 | + $row['body'] = ''; |
|
791 | + } |
|
772 | 792 | |
773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
774 | - if (empty($row['subject'])) |
|
775 | - $row['subject'] = $txt['no_subject']; |
|
794 | + if (empty($row['subject'])) { |
|
795 | + $row['subject'] = $txt['no_subject']; |
|
796 | + } |
|
776 | 797 | |
777 | 798 | censorText($row['body']); |
778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
827 | 848 | $smcFunc['db_free_result']($request); |
828 | 849 | |
829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
830 | - if ($reverse) |
|
831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
851 | + if ($reverse) { |
|
852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
853 | + } |
|
832 | 854 | |
833 | 855 | // off to the template we go |
834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param string $post_errors A string of info about errors encountered trying to save this draft |
175 | 175 | * @param array $recipientList An array of data about who this PM is being sent to |
176 | - * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
176 | + * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
177 | 177 | */ |
178 | 178 | function SavePMDraft(&$post_errors, $recipientList) |
179 | 179 | { |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @param int $id_draft The ID of the draft to delete |
390 | 390 | * @param boolean $check Whether or not to check that the draft belongs to the current user |
391 | - * @return boolean False if it couldn't be deleted (doesn't return anything otherwise) |
|
391 | + * @return false|null False if it couldn't be deleted (doesn't return anything otherwise) |
|
392 | 392 | */ |
393 | 393 | function DeleteDraft($id_draft, $check = true) |
394 | 394 | { |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param int $member_id ID of the member to show drafts for |
423 | 423 | * @param boolean|integer $topic If $type is 1, this can be set to only load drafts for posts in the specific topic |
424 | 424 | * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts |
425 | - * @return boolean False if the drafts couldn't be loaded, nothing otherwise |
|
425 | + * @return false|null False if the drafts couldn't be loaded, nothing otherwise |
|
426 | 426 | */ |
427 | 427 | function ShowDrafts($member_id, $topic = false, $draft_type = 0) |
428 | 428 | { |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | // Start things rolling by getting SMF alive... |
18 | 18 | $ssi_guest_access = true; |
19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
20 | 20 | die('Cannot find SSI.php'); |
21 | +} |
|
21 | 22 | |
22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
35 | 36 | } |
36 | 37 | |
37 | 38 | // I assume we're even active? |
38 | -if (empty($modSettings['paid_enabled'])) |
|
39 | +if (empty($modSettings['paid_enabled'])) { |
|
39 | 40 | exit; |
41 | +} |
|
40 | 42 | |
41 | 43 | // If we have some custom people who find out about problems load them here. |
42 | 44 | $notify_users = array(); |
43 | 45 | if (!empty($modSettings['paid_email_to'])) |
44 | 46 | { |
45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
46 | - $notify_users[] = array( |
|
47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
48 | + $notify_users[] = array( |
|
47 | 49 | 'email' => $email, |
48 | 50 | 'name' => $txt['who_member'], |
49 | 51 | 'id' => 0, |
50 | 52 | ); |
51 | -} |
|
53 | + } |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // We need to see whether we can find the correct payment gateway, |
54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | } |
66 | 69 | } |
67 | 70 | |
68 | -if (empty($txnType)) |
|
71 | +if (empty($txnType)) { |
|
69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
73 | +} |
|
70 | 74 | |
71 | 75 | // Get the subscription and member ID amoungst others... |
72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
76 | 80 | $member_id = (int) $member_id; |
77 | 81 | |
78 | 82 | // This would be bad... |
79 | -if (empty($member_id)) |
|
83 | +if (empty($member_id)) { |
|
80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
85 | +} |
|
81 | 86 | |
82 | 87 | // Verify the member. |
83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
89 | 94 | ) |
90 | 95 | ); |
91 | 96 | // Didn't find them? |
92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
99 | +} |
|
94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
95 | 101 | $smcFunc['db_free_result']($request); |
96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | ); |
106 | 112 | |
107 | 113 | // Didn't find it? |
108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
116 | +} |
|
110 | 117 | |
111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
123 | 130 | 'current_member' => $member_id, |
124 | 131 | ) |
125 | 132 | ); |
126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
135 | +} |
|
128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
129 | 137 | $smcFunc['db_free_result']($request); |
130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
139 | 147 | removeSubscription($subscription_id, $member_id); |
140 | 148 | $subscription_act = time(); |
141 | 149 | $status = 0; |
142 | - } |
|
143 | - else |
|
150 | + } else |
|
144 | 151 | { |
145 | 152 | loadSubscriptions(); |
146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
188 | 195 | if (!$gatewayClass->isSubscription()) |
189 | 196 | { |
190 | 197 | $real_details = $smcFunc['json_decode']($subscription_info['pending_details'], true); |
191 | - if (empty($real_details)) |
|
192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
198 | + if (empty($real_details)) { |
|
199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
200 | + } |
|
193 | 201 | |
194 | 202 | // Now we just try to find anything pending. |
195 | 203 | // We don't really care which it is as security happens later. |
196 | 204 | foreach ($real_details as $id => $detail) |
197 | 205 | { |
198 | 206 | unset($real_details[$id]); |
199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
200 | - $subscription_info['payments_pending']--; |
|
207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
208 | + $subscription_info['payments_pending']--; |
|
209 | + } |
|
201 | 210 | break; |
202 | 211 | } |
203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
223 | 232 | // This is a little harder, can we find the right duration? |
224 | 233 | foreach ($cost as $duration => $value) |
225 | 234 | { |
226 | - if ($duration == 'fixed') |
|
227 | - continue; |
|
228 | - elseif ((float) $value == (float) $total_cost) |
|
229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
235 | + if ($duration == 'fixed') { |
|
236 | + continue; |
|
237 | + } elseif ((float) $value == (float) $total_cost) { |
|
238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
239 | + } |
|
230 | 240 | } |
231 | 241 | |
232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
235 | 245 | $notify = true; |
236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
237 | 247 | } |
238 | - } |
|
239 | - else |
|
248 | + } else |
|
240 | 249 | { |
241 | 250 | $actual_cost = $cost['fixed']; |
242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
269 | 278 | elseif ($gatewayClass->isCancellation()) |
270 | 279 | { |
271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
273 | -} |
|
274 | -else |
|
280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
282 | + } |
|
283 | + } else |
|
275 | 284 | { |
276 | 285 | // Some other "valid" transaction such as: |
277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
308 | 317 | // Maybe we can try to give them the post data? |
309 | 318 | if (!empty($_POST)) |
310 | 319 | { |
311 | - foreach ($_POST as $key => $val) |
|
312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
320 | + foreach ($_POST as $key => $val) { |
|
321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
322 | + } |
|
313 | 323 | } |
314 | 324 | |
315 | 325 | // Then just log and die. |
@@ -86,7 +86,7 @@ |
||
86 | 86 | foreach ($board['children'] as $child) |
87 | 87 | { |
88 | 88 | if (!$child['is_redirect']) |
89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
90 | 90 | else |
91 | 91 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
92 | 92 |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $settings, $options, $scripturl, $modSettings, $txt; |
19 | 19 | |
20 | 20 | // Let them know why their message became unapproved. |
21 | - if ($context['becomesUnapproved']) |
|
22 | - echo ' |
|
21 | + if ($context['becomesUnapproved']) { |
|
22 | + echo ' |
|
23 | 23 | <div class="noticebox"> |
24 | 24 | ', $txt['post_becomesUnapproved'], ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0)) |
28 | 29 | { |
@@ -46,17 +47,19 @@ discard block |
||
46 | 47 | </a>'; |
47 | 48 | |
48 | 49 | // Has it outstanding posts for approval? |
49 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
50 | - echo ' |
|
50 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
51 | + echo ' |
|
51 | 52 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
53 | + } |
|
52 | 54 | |
53 | 55 | echo ' |
54 | 56 | <p class="board_description">', $board['description'], '</p>'; |
55 | 57 | |
56 | 58 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
57 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
58 | - echo ' |
|
59 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
60 | + echo ' |
|
59 | 61 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | // Show some basic information about the number of posts, etc. |
62 | 65 | echo ' |
@@ -68,9 +71,10 @@ discard block |
||
68 | 71 | </div> |
69 | 72 | <div class="lastpost lpr_border">'; |
70 | 73 | |
71 | - if (!empty($board['last_post']['id'])) |
|
72 | - echo ' |
|
74 | + if (!empty($board['last_post']['id'])) { |
|
75 | + echo ' |
|
73 | 76 | <p>', $board['last_post']['last_post_message'], '</p>'; |
77 | + } |
|
74 | 78 | |
75 | 79 | echo ' |
76 | 80 | </div>'; |
@@ -84,14 +88,16 @@ discard block |
||
84 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
85 | 89 | foreach ($board['children'] as $child) |
86 | 90 | { |
87 | - if (!$child['is_redirect']) |
|
88 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | - else |
|
90 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
91 | + if (!$child['is_redirect']) { |
|
92 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
93 | + } else { |
|
94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | // Has it posts awaiting approval? |
93 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
94 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
99 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
100 | + } |
|
95 | 101 | |
96 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
97 | 103 | } |
@@ -135,13 +141,15 @@ discard block |
||
135 | 141 | <h3>', $context['name'], '</h3> |
136 | 142 | <p>'; |
137 | 143 | |
138 | - if ($context['description'] != '') |
|
139 | - echo ' |
|
144 | + if ($context['description'] != '') { |
|
145 | + echo ' |
|
140 | 146 | ', $context['description']; |
147 | + } |
|
141 | 148 | |
142 | - if (!empty($context['moderators'])) |
|
143 | - echo ' |
|
149 | + if (!empty($context['moderators'])) { |
|
150 | + echo ' |
|
144 | 151 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
152 | + } |
|
145 | 153 | |
146 | 154 | echo ' |
147 | 155 | </p> |
@@ -149,9 +157,10 @@ discard block |
||
149 | 157 | } |
150 | 158 | |
151 | 159 | // If Quick Moderation is enabled start the form. |
152 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
153 | - echo ' |
|
160 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
161 | + echo ' |
|
154 | 162 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
163 | + } |
|
155 | 164 | |
156 | 165 | echo ' |
157 | 166 | <div id="messageindex">'; |
@@ -161,11 +170,11 @@ discard block |
||
161 | 170 | echo ' |
162 | 171 | <div class="information">'; |
163 | 172 | |
164 | - if ($settings['display_who_viewing'] == 1) |
|
165 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
166 | - |
|
167 | - else |
|
168 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
173 | + if ($settings['display_who_viewing'] == 1) { |
|
174 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
175 | + } else { |
|
176 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
177 | + } |
|
169 | 178 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
170 | 179 | |
171 | 180 | echo ' |
@@ -185,32 +194,36 @@ discard block |
||
185 | 194 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
186 | 195 | |
187 | 196 | // Show a "select all" box for quick moderation? |
188 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
189 | - echo ' |
|
197 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
198 | + echo ' |
|
190 | 199 | <div class="moderation"> |
191 | 200 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
192 | 201 | </div>'; |
202 | + } |
|
193 | 203 | |
194 | 204 | // If it's on in "image" mode, don't show anything but the column. |
195 | - elseif (!empty($context['can_quick_mod'])) |
|
196 | - echo ' |
|
205 | + elseif (!empty($context['can_quick_mod'])) { |
|
206 | + echo ' |
|
197 | 207 | <div class="moderation"></div>'; |
208 | + } |
|
198 | 209 | } |
199 | 210 | |
200 | 211 | // No topics... just say, "sorry bub". |
201 | - else |
|
202 | - echo ' |
|
212 | + else { |
|
213 | + echo ' |
|
203 | 214 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
215 | + } |
|
204 | 216 | |
205 | 217 | echo ' |
206 | 218 | </div><!-- #topic_header -->'; |
207 | 219 | |
208 | 220 | // If this person can approve items and we have some awaiting approval tell them. |
209 | - if (!empty($context['unapproved_posts_message'])) |
|
210 | - echo ' |
|
221 | + if (!empty($context['unapproved_posts_message'])) { |
|
222 | + echo ' |
|
211 | 223 | <div class="information"> |
212 | 224 | <span class="alert">!</span> ', $context['unapproved_posts_message'], ' |
213 | 225 | </div>'; |
226 | + } |
|
214 | 227 | |
215 | 228 | // Contain the topic list |
216 | 229 | echo ' |
@@ -231,25 +244,30 @@ discard block |
||
231 | 244 | echo ' |
232 | 245 | <div class="icons floatright">'; |
233 | 246 | |
234 | - if ($topic['is_watched']) |
|
235 | - echo ' |
|
247 | + if ($topic['is_watched']) { |
|
248 | + echo ' |
|
236 | 249 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
250 | + } |
|
237 | 251 | |
238 | - if ($topic['is_locked']) |
|
239 | - echo ' |
|
252 | + if ($topic['is_locked']) { |
|
253 | + echo ' |
|
240 | 254 | <span class="generic_icons lock"></span>'; |
255 | + } |
|
241 | 256 | |
242 | - if ($topic['is_sticky']) |
|
243 | - echo ' |
|
257 | + if ($topic['is_sticky']) { |
|
258 | + echo ' |
|
244 | 259 | <span class="generic_icons sticky"></span>'; |
260 | + } |
|
245 | 261 | |
246 | - if ($topic['is_redirect']) |
|
247 | - echo ' |
|
262 | + if ($topic['is_redirect']) { |
|
263 | + echo ' |
|
248 | 264 | <span class="generic_icons move"></span>'; |
265 | + } |
|
249 | 266 | |
250 | - if ($topic['is_poll']) |
|
251 | - echo ' |
|
267 | + if ($topic['is_poll']) { |
|
268 | + echo ' |
|
252 | 269 | <span class="generic_icons poll"></span>'; |
270 | + } |
|
253 | 271 | |
254 | 272 | echo ' |
255 | 273 | </div>'; |
@@ -281,26 +299,31 @@ discard block |
||
281 | 299 | echo ' |
282 | 300 | <div class="moderation">'; |
283 | 301 | |
284 | - if ($options['display_quick_mod'] == 1) |
|
285 | - echo ' |
|
302 | + if ($options['display_quick_mod'] == 1) { |
|
303 | + echo ' |
|
286 | 304 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
287 | - else |
|
305 | + } else |
|
288 | 306 | { |
289 | 307 | // Check permissions on each and show only the ones they are allowed to use. |
290 | - if ($topic['quick_mod']['remove']) |
|
291 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
308 | + if ($topic['quick_mod']['remove']) { |
|
309 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
310 | + } |
|
292 | 311 | |
293 | - if ($topic['quick_mod']['lock']) |
|
294 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
312 | + if ($topic['quick_mod']['lock']) { |
|
313 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
314 | + } |
|
295 | 315 | |
296 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
297 | - echo '<br>'; |
|
316 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
317 | + echo '<br>'; |
|
318 | + } |
|
298 | 319 | |
299 | - if ($topic['quick_mod']['sticky']) |
|
300 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
320 | + if ($topic['quick_mod']['sticky']) { |
|
321 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
322 | + } |
|
301 | 323 | |
302 | - if ($topic['quick_mod']['move']) |
|
303 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
324 | + if ($topic['quick_mod']['move']) { |
|
325 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
326 | + } |
|
304 | 327 | } |
305 | 328 | echo ' |
306 | 329 | </div><!-- .moderation -->'; |
@@ -318,18 +341,20 @@ discard block |
||
318 | 341 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
319 | 342 | <option value="">--------</option>'; |
320 | 343 | |
321 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
322 | - if ($context['can_' . $qmod_action]) |
|
344 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
345 | + if ($context['can_' . $qmod_action]) |
|
323 | 346 | echo ' |
324 | 347 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
348 | + } |
|
325 | 349 | |
326 | 350 | echo ' |
327 | 351 | </select>'; |
328 | 352 | |
329 | 353 | // Show a list of boards they can move the topic to. |
330 | - if ($context['can_move']) |
|
331 | - echo ' |
|
354 | + if ($context['can_move']) { |
|
355 | + echo ' |
|
332 | 356 | <span id="quick_mod_jump_to"></span>'; |
357 | + } |
|
333 | 358 | |
334 | 359 | echo ' |
335 | 360 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -340,10 +365,11 @@ discard block |
||
340 | 365 | </div><!-- #messageindex -->'; |
341 | 366 | |
342 | 367 | // Finish off the form - again. |
343 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
344 | - echo ' |
|
368 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
369 | + echo ' |
|
345 | 370 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
346 | 371 | </form>'; |
372 | + } |
|
347 | 373 | |
348 | 374 | // Mobile action buttons (bottom) |
349 | 375 | echo ' |
@@ -365,8 +391,8 @@ discard block |
||
365 | 391 | // Show breadcrumbs at the bottom too. |
366 | 392 | theme_linktree(); |
367 | 393 | |
368 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
369 | - echo ' |
|
394 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
395 | + echo ' |
|
370 | 396 | <script> |
371 | 397 | if (typeof(window.XMLHttpRequest) != "undefined") |
372 | 398 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -385,6 +411,7 @@ discard block |
||
385 | 411 | sCustomName: "move_to" |
386 | 412 | }); |
387 | 413 | </script>'; |
414 | + } |
|
388 | 415 | |
389 | 416 | // Javascript for inline editing. |
390 | 417 | echo ' |
@@ -421,8 +448,8 @@ discard block |
||
421 | 448 | <div class="information"> |
422 | 449 | <p class="floatright" id="message_index_jump_to"></p>'; |
423 | 450 | |
424 | - if (empty($context['no_topic_listing'])) |
|
425 | - echo ' |
|
451 | + if (empty($context['no_topic_listing'])) { |
|
452 | + echo ' |
|
426 | 453 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
427 | 454 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
428 | 455 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -432,9 +459,10 @@ discard block |
||
432 | 459 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
433 | 460 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
434 | 461 | </p>'; |
462 | + } |
|
435 | 463 | |
436 | - if (!empty($context['jump_to'])) |
|
437 | - echo ' |
|
464 | + if (!empty($context['jump_to'])) { |
|
465 | + echo ' |
|
438 | 466 | <script> |
439 | 467 | if (typeof(window.XMLHttpRequest) != "undefined") |
440 | 468 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -450,6 +478,7 @@ discard block |
||
450 | 478 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
451 | 479 | }); |
452 | 480 | </script>'; |
481 | + } |
|
453 | 482 | |
454 | 483 | echo ' |
455 | 484 | <br class="clear"> |
@@ -2259,9 +2259,9 @@ discard block |
||
2259 | 2259 | * |
2260 | 2260 | * @uses the template_include() function to include the file. |
2261 | 2261 | * @param string $template_name The name of the template to load |
2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2264 | - * @return boolean Whether or not the template was loaded |
|
2264 | + * @return boolean|null Whether or not the template was loaded |
|
2265 | 2265 | */ |
2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2445 | 2445 | * |
2446 | 2446 | * @param string $css Some css code |
2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2448 | 2448 | */ |
2449 | 2449 | function addInlineCss($css) |
2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
2558 | 2558 | * |
2559 | 2559 | * @param string $javascript Some JS code |
2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2562 | 2562 | */ |
2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
2792 | 2792 | * |
2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
2794 | - * @return array An array of information about available languages |
|
2794 | + * @return string An array of information about available languages |
|
2795 | 2795 | */ |
2796 | 2796 | function getLanguages($use_cache = true) |
2797 | 2797 | { |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | // We already load the basic stuff? |
1745 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
1745 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
1746 | 1746 | { |
1747 | 1747 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1748 | 1748 | |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | SELECT variable, value, id_member, id_theme |
1768 | 1768 | FROM {db_prefix}themes |
1769 | 1769 | WHERE id_member' . (empty($themeData[0]) ? ' IN (-1, 0, {int:id_member})' : ' = {int:id_member}') . ' |
1770 | - AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') .' |
|
1770 | + AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') . ' |
|
1771 | 1771 | ORDER BY id_theme asc', |
1772 | 1772 | array( |
1773 | 1773 | 'id_theme' => $id_theme, |
@@ -1997,7 +1997,7 @@ discard block |
||
1997 | 1997 | if (!isset($context['javascript_vars'])) |
1998 | 1998 | $context['javascript_vars'] = array(); |
1999 | 1999 | |
2000 | - $context['login_url'] = $scripturl . '?action=login2'; |
|
2000 | + $context['login_url'] = $scripturl . '?action=login2'; |
|
2001 | 2001 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
2002 | 2002 | $context['session_var'] = $_SESSION['session_var']; |
2003 | 2003 | $context['session_id'] = $_SESSION['session_value']; |
@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -392,9 +409,9 @@ discard block |
||
392 | 409 | break; |
393 | 410 | } |
394 | 411 | } |
412 | + } else { |
|
413 | + $id_member = 0; |
|
395 | 414 | } |
396 | - else |
|
397 | - $id_member = 0; |
|
398 | 415 | |
399 | 416 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
400 | 417 | { |
@@ -402,8 +419,9 @@ discard block |
||
402 | 419 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
403 | 420 | |
404 | 421 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
405 | - if (empty($cookie_data)) |
|
406 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
422 | + if (empty($cookie_data)) { |
|
423 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
424 | + } |
|
407 | 425 | |
408 | 426 | list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, ''); |
409 | 427 | |
@@ -411,16 +429,17 @@ discard block |
||
411 | 429 | |
412 | 430 | // Make sure the cookie is set to the correct domain and path |
413 | 431 | require_once($sourcedir . '/Subs-Auth.php'); |
414 | - if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) |
|
415 | - setLoginCookie((int) $login_span - time(), $id_member); |
|
416 | - } |
|
417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
432 | + if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) { |
|
433 | + setLoginCookie((int) $login_span - time(), $id_member); |
|
434 | + } |
|
435 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
418 | 436 | { |
419 | 437 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
420 | 438 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true); |
421 | 439 | |
422 | - if (empty($cookie_data)) |
|
423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
440 | + if (empty($cookie_data)) { |
|
441 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
442 | + } |
|
424 | 443 | |
425 | 444 | list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, ''); |
426 | 445 | $id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +464,34 @@ discard block |
||
445 | 464 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
446 | 465 | $smcFunc['db_free_result']($request); |
447 | 466 | |
448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
449 | - $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
467 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
468 | + $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
469 | + } |
|
450 | 470 | |
451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
471 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
472 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
473 | + } |
|
453 | 474 | } |
454 | 475 | |
455 | 476 | // Did we find 'im? If not, junk it. |
456 | 477 | if (!empty($user_settings)) |
457 | 478 | { |
458 | 479 | // As much as the password should be right, we can assume the integration set things up. |
459 | - if (!empty($already_verified) && $already_verified === true) |
|
460 | - $check = true; |
|
480 | + if (!empty($already_verified) && $already_verified === true) { |
|
481 | + $check = true; |
|
482 | + } |
|
461 | 483 | // SHA-512 hash should be 128 characters long. |
462 | - elseif (strlen($password) == 128) |
|
463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
464 | - else |
|
465 | - $check = false; |
|
484 | + elseif (strlen($password) == 128) { |
|
485 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
486 | + } else { |
|
487 | + $check = false; |
|
488 | + } |
|
466 | 489 | |
467 | 490 | // Wrong password or not activated - either way, you're going nowhere. |
468 | 491 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
492 | + } else { |
|
493 | + $id_member = 0; |
|
469 | 494 | } |
470 | - else |
|
471 | - $id_member = 0; |
|
472 | 495 | |
473 | 496 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
474 | 497 | if (!$id_member) |
@@ -497,8 +520,9 @@ discard block |
||
497 | 520 | |
498 | 521 | list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, ''); |
499 | 522 | |
500 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
501 | - $tfasecret = null; |
|
523 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
524 | + $tfasecret = null; |
|
525 | + } |
|
502 | 526 | } |
503 | 527 | |
504 | 528 | // They didn't finish logging in before coming here? Then they're no one to us. |
@@ -520,10 +544,12 @@ discard block |
||
520 | 544 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
521 | 545 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
522 | 546 | { |
523 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
547 | + if ($modSettings['tfa_mode'] == 2) { |
|
548 | + //only do this if we are just forcing SOME membergroups |
|
524 | 549 | { |
525 | 550 | //Build an array of ALL user membergroups. |
526 | 551 | $full_groups = array($user_settings['id_group']); |
552 | + } |
|
527 | 553 | if (!empty($user_settings['additional_groups'])) |
528 | 554 | { |
529 | 555 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -543,15 +569,17 @@ discard block |
||
543 | 569 | ); |
544 | 570 | $row = $smcFunc['db_fetch_assoc']($request); |
545 | 571 | $smcFunc['db_free_result']($request); |
572 | + } else { |
|
573 | + $row['total'] = 1; |
|
546 | 574 | } |
547 | - else |
|
548 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
575 | + //simplifies logics in the next "if" |
|
549 | 576 | |
550 | 577 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
551 | 578 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
552 | 579 | |
553 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
554 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
580 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
581 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + } |
|
555 | 583 | } |
556 | 584 | } |
557 | 585 | |
@@ -588,33 +616,37 @@ discard block |
||
588 | 616 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
589 | 617 | $user_settings['last_login'] = time(); |
590 | 618 | |
591 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
592 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
619 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
620 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + } |
|
593 | 622 | |
594 | - if (!empty($modSettings['cache_enable'])) |
|
595 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
623 | + if (!empty($modSettings['cache_enable'])) { |
|
624 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + } |
|
596 | 626 | } |
627 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
628 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
597 | 629 | } |
598 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
599 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
600 | 630 | |
601 | 631 | $username = $user_settings['member_name']; |
602 | 632 | |
603 | - if (empty($user_settings['additional_groups'])) |
|
604 | - $user_info = array( |
|
633 | + if (empty($user_settings['additional_groups'])) { |
|
634 | + $user_info = array( |
|
605 | 635 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
606 | 636 | ); |
607 | - else |
|
608 | - $user_info = array( |
|
637 | + } else { |
|
638 | + $user_info = array( |
|
609 | 639 | 'groups' => array_merge( |
610 | 640 | array($user_settings['id_group'], $user_settings['id_post_group']), |
611 | 641 | explode(',', $user_settings['additional_groups']) |
612 | 642 | ) |
613 | 643 | ); |
644 | + } |
|
614 | 645 | |
615 | 646 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
616 | - foreach ($user_info['groups'] as $k => $v) |
|
617 | - $user_info['groups'][$k] = (int) $v; |
|
647 | + foreach ($user_info['groups'] as $k => $v) { |
|
648 | + $user_info['groups'][$k] = (int) $v; |
|
649 | + } |
|
618 | 650 | |
619 | 651 | // This is a logged in user, so definitely not a spider. |
620 | 652 | $user_info['possibly_robot'] = false; |
@@ -628,8 +660,7 @@ discard block |
||
628 | 660 | $time_system = new DateTime('now', $tz_system); |
629 | 661 | $time_user = new DateTime('now', $tz_user); |
630 | 662 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
631 | - } |
|
632 | - else |
|
663 | + } else |
|
633 | 664 | { |
634 | 665 | // !!! Compatibility. |
635 | 666 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -643,8 +674,9 @@ discard block |
||
643 | 674 | $user_info = array('groups' => array(-1)); |
644 | 675 | $user_settings = array(); |
645 | 676 | |
646 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
647 | - $_COOKIE[$cookiename] = ''; |
|
677 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
678 | + $_COOKIE[$cookiename] = ''; |
|
679 | + } |
|
648 | 680 | |
649 | 681 | // Expire the 2FA cookie |
650 | 682 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -661,19 +693,20 @@ discard block |
||
661 | 693 | } |
662 | 694 | |
663 | 695 | // Create a login token if it doesn't exist yet. |
664 | - if (!isset($_SESSION['token']['post-login'])) |
|
665 | - createToken('login'); |
|
666 | - else |
|
667 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
697 | + createToken('login'); |
|
698 | + } else { |
|
699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
700 | + } |
|
668 | 701 | |
669 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
670 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
671 | 704 | { |
672 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
673 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
674 | 709 | } |
675 | - elseif (!empty($modSettings['spider_mode'])) |
|
676 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
677 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
678 | 711 | else |
679 | 712 | { |
@@ -721,8 +754,9 @@ discard block |
||
721 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
722 | 755 | |
723 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
724 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
725 | - unset($user_info['ignoreboards'][$tmp]); |
|
757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
758 | + unset($user_info['ignoreboards'][$tmp]); |
|
759 | + } |
|
726 | 760 | |
727 | 761 | // Allow the user to change their language. |
728 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -735,13 +769,14 @@ discard block |
||
735 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
736 | 770 | |
737 | 771 | // Make it permanent for members. |
738 | - if (!empty($user_info['id'])) |
|
739 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
740 | - else |
|
741 | - $_SESSION['language'] = $user_info['language']; |
|
772 | + if (!empty($user_info['id'])) { |
|
773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
774 | + } else { |
|
775 | + $_SESSION['language'] = $user_info['language']; |
|
776 | + } |
|
777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
742 | 779 | } |
743 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
744 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
745 | 780 | } |
746 | 781 | |
747 | 782 | $temp = build_query_board($user_info['id']); |
@@ -804,9 +839,9 @@ discard block |
||
804 | 839 | } |
805 | 840 | |
806 | 841 | // Remember redirection is the key to avoiding fallout from your bosses. |
807 | - if (!empty($topic)) |
|
808 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
809 | - else |
|
842 | + if (!empty($topic)) { |
|
843 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
844 | + } else |
|
810 | 845 | { |
811 | 846 | loadPermissions(); |
812 | 847 | loadTheme(); |
@@ -824,10 +859,11 @@ discard block |
||
824 | 859 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
825 | 860 | { |
826 | 861 | // @todo SLOW? |
827 | - if (!empty($topic)) |
|
828 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
829 | - else |
|
830 | - $temp = cache_get_data('board-' . $board, 120); |
|
862 | + if (!empty($topic)) { |
|
863 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
864 | + } else { |
|
865 | + $temp = cache_get_data('board-' . $board, 120); |
|
866 | + } |
|
831 | 867 | |
832 | 868 | if (!empty($temp)) |
833 | 869 | { |
@@ -865,8 +901,9 @@ discard block |
||
865 | 901 | $row = $smcFunc['db_fetch_assoc']($request); |
866 | 902 | |
867 | 903 | // Set the current board. |
868 | - if (!empty($row['id_board'])) |
|
869 | - $board = $row['id_board']; |
|
904 | + if (!empty($row['id_board'])) { |
|
905 | + $board = $row['id_board']; |
|
906 | + } |
|
870 | 907 | |
871 | 908 | // Basic operating information. (globals... :/) |
872 | 909 | $board_info = array( |
@@ -902,21 +939,23 @@ discard block |
||
902 | 939 | |
903 | 940 | do |
904 | 941 | { |
905 | - if (!empty($row['id_moderator'])) |
|
906 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
942 | + if (!empty($row['id_moderator'])) { |
|
943 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
907 | 944 | 'id' => $row['id_moderator'], |
908 | 945 | 'name' => $row['real_name'], |
909 | 946 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
910 | 947 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
911 | 948 | ); |
949 | + } |
|
912 | 950 | |
913 | - if (!empty($row['id_moderator_group'])) |
|
914 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
951 | + if (!empty($row['id_moderator_group'])) { |
|
952 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
915 | 953 | 'id' => $row['id_moderator_group'], |
916 | 954 | 'name' => $row['group_name'], |
917 | 955 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
918 | 956 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
919 | 957 | ); |
958 | + } |
|
920 | 959 | } |
921 | 960 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
922 | 961 | |
@@ -948,12 +987,12 @@ discard block |
||
948 | 987 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
949 | 988 | { |
950 | 989 | // @todo SLOW? |
951 | - if (!empty($topic)) |
|
952 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
990 | + if (!empty($topic)) { |
|
991 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
992 | + } |
|
953 | 993 | cache_put_data('board-' . $board, $board_info, 120); |
954 | 994 | } |
955 | - } |
|
956 | - else |
|
995 | + } else |
|
957 | 996 | { |
958 | 997 | // Otherwise the topic is invalid, there are no moderators, etc. |
959 | 998 | $board_info = array( |
@@ -967,8 +1006,9 @@ discard block |
||
967 | 1006 | $smcFunc['db_free_result']($request); |
968 | 1007 | } |
969 | 1008 | |
970 | - if (!empty($topic)) |
|
971 | - $_GET['board'] = (int) $board; |
|
1009 | + if (!empty($topic)) { |
|
1010 | + $_GET['board'] = (int) $board; |
|
1011 | + } |
|
972 | 1012 | |
973 | 1013 | if (!empty($board)) |
974 | 1014 | { |
@@ -978,10 +1018,12 @@ discard block |
||
978 | 1018 | // Now check if the user is a moderator. |
979 | 1019 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
980 | 1020 | |
981 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
982 | - $board_info['error'] = 'access'; |
|
983 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
984 | - $board_info['error'] = 'access'; |
|
1021 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1022 | + $board_info['error'] = 'access'; |
|
1023 | + } |
|
1024 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1025 | + $board_info['error'] = 'access'; |
|
1026 | + } |
|
985 | 1027 | |
986 | 1028 | // Build up the linktree. |
987 | 1029 | $context['linktree'] = array_merge( |
@@ -1004,8 +1046,9 @@ discard block |
||
1004 | 1046 | $context['current_board'] = $board; |
1005 | 1047 | |
1006 | 1048 | // No posting in redirection boards! |
1007 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1008 | - $board_info['error'] == 'post_in_redirect'; |
|
1049 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1050 | + $board_info['error'] == 'post_in_redirect'; |
|
1051 | + } |
|
1009 | 1052 | |
1010 | 1053 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1011 | 1054 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1031,24 +1074,23 @@ discard block |
||
1031 | 1074 | ob_end_clean(); |
1032 | 1075 | header('HTTP/1.1 403 Forbidden'); |
1033 | 1076 | die; |
1034 | - } |
|
1035 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1077 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1036 | 1078 | { |
1037 | 1079 | // Slightly different error message here... |
1038 | 1080 | fatal_lang_error('cannot_post_redirect', false); |
1039 | - } |
|
1040 | - elseif ($user_info['is_guest']) |
|
1081 | + } elseif ($user_info['is_guest']) |
|
1041 | 1082 | { |
1042 | 1083 | loadLanguage('Errors'); |
1043 | 1084 | is_not_guest($txt['topic_gone']); |
1085 | + } else { |
|
1086 | + fatal_lang_error('topic_gone', false); |
|
1044 | 1087 | } |
1045 | - else |
|
1046 | - fatal_lang_error('topic_gone', false); |
|
1047 | 1088 | } |
1048 | 1089 | |
1049 | - if ($user_info['is_mod']) |
|
1050 | - $user_info['groups'][] = 3; |
|
1051 | -} |
|
1090 | + if ($user_info['is_mod']) { |
|
1091 | + $user_info['groups'][] = 3; |
|
1092 | + } |
|
1093 | + } |
|
1052 | 1094 | |
1053 | 1095 | /** |
1054 | 1096 | * Load this user's permissions. |
@@ -1069,8 +1111,9 @@ discard block |
||
1069 | 1111 | asort($cache_groups); |
1070 | 1112 | $cache_groups = implode(',', $cache_groups); |
1071 | 1113 | // If it's a spider then cache it different. |
1072 | - if ($user_info['possibly_robot']) |
|
1073 | - $cache_groups .= '-spider'; |
|
1114 | + if ($user_info['possibly_robot']) { |
|
1115 | + $cache_groups .= '-spider'; |
|
1116 | + } |
|
1074 | 1117 | |
1075 | 1118 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1076 | 1119 | { |
@@ -1078,9 +1121,9 @@ discard block |
||
1078 | 1121 | banPermissions(); |
1079 | 1122 | |
1080 | 1123 | return; |
1124 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1125 | + list ($user_info['permissions'], $removals) = $temp; |
|
1081 | 1126 | } |
1082 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1083 | - list ($user_info['permissions'], $removals) = $temp; |
|
1084 | 1127 | } |
1085 | 1128 | |
1086 | 1129 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1102,23 +1145,26 @@ discard block |
||
1102 | 1145 | $removals = array(); |
1103 | 1146 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1104 | 1147 | { |
1105 | - if (empty($row['add_deny'])) |
|
1106 | - $removals[] = $row['permission']; |
|
1107 | - else |
|
1108 | - $user_info['permissions'][] = $row['permission']; |
|
1148 | + if (empty($row['add_deny'])) { |
|
1149 | + $removals[] = $row['permission']; |
|
1150 | + } else { |
|
1151 | + $user_info['permissions'][] = $row['permission']; |
|
1152 | + } |
|
1109 | 1153 | } |
1110 | 1154 | $smcFunc['db_free_result']($request); |
1111 | 1155 | |
1112 | - if (isset($cache_groups)) |
|
1113 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1156 | + if (isset($cache_groups)) { |
|
1157 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1158 | + } |
|
1114 | 1159 | } |
1115 | 1160 | |
1116 | 1161 | // Get the board permissions. |
1117 | 1162 | if (!empty($board)) |
1118 | 1163 | { |
1119 | 1164 | // Make sure the board (if any) has been loaded by loadBoard(). |
1120 | - if (!isset($board_info['profile'])) |
|
1121 | - fatal_lang_error('no_board'); |
|
1165 | + if (!isset($board_info['profile'])) { |
|
1166 | + fatal_lang_error('no_board'); |
|
1167 | + } |
|
1122 | 1168 | |
1123 | 1169 | $request = $smcFunc['db_query']('', ' |
1124 | 1170 | SELECT permission, add_deny |
@@ -1134,20 +1180,23 @@ discard block |
||
1134 | 1180 | ); |
1135 | 1181 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1136 | 1182 | { |
1137 | - if (empty($row['add_deny'])) |
|
1138 | - $removals[] = $row['permission']; |
|
1139 | - else |
|
1140 | - $user_info['permissions'][] = $row['permission']; |
|
1183 | + if (empty($row['add_deny'])) { |
|
1184 | + $removals[] = $row['permission']; |
|
1185 | + } else { |
|
1186 | + $user_info['permissions'][] = $row['permission']; |
|
1187 | + } |
|
1141 | 1188 | } |
1142 | 1189 | $smcFunc['db_free_result']($request); |
1143 | 1190 | } |
1144 | 1191 | |
1145 | 1192 | // Remove all the permissions they shouldn't have ;). |
1146 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1147 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1193 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1194 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1195 | + } |
|
1148 | 1196 | |
1149 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1150 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1197 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1198 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1199 | + } |
|
1151 | 1200 | |
1152 | 1201 | // Banned? Watch, don't touch.. |
1153 | 1202 | banPermissions(); |
@@ -1159,17 +1208,18 @@ discard block |
||
1159 | 1208 | { |
1160 | 1209 | require_once($sourcedir . '/Subs-Auth.php'); |
1161 | 1210 | rebuildModCache(); |
1211 | + } else { |
|
1212 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1162 | 1213 | } |
1163 | - else |
|
1164 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1165 | 1214 | |
1166 | 1215 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1167 | 1216 | // For example this drastically simplifies certain changes to the profile area. |
1168 | 1217 | $user_info['permissions'][] = 'is_not_guest'; |
1169 | 1218 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1170 | 1219 | $user_info['permissions'][] = 'profile_view_own'; |
1171 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1172 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1220 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1221 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1222 | + } |
|
1173 | 1223 | } |
1174 | 1224 | } |
1175 | 1225 | |
@@ -1187,8 +1237,9 @@ discard block |
||
1187 | 1237 | global $image_proxy_enabled, $boardurl, $user_info; |
1188 | 1238 | |
1189 | 1239 | // Can't just look for no users :P. |
1190 | - if (empty($users)) |
|
1191 | - return array(); |
|
1240 | + if (empty($users)) { |
|
1241 | + return array(); |
|
1242 | + } |
|
1192 | 1243 | |
1193 | 1244 | // Pass the set value |
1194 | 1245 | $context['loadMemberContext_set'] = $set; |
@@ -1203,8 +1254,9 @@ discard block |
||
1203 | 1254 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1204 | 1255 | { |
1205 | 1256 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1206 | - if ($data == null) |
|
1207 | - continue; |
|
1257 | + if ($data == null) { |
|
1258 | + continue; |
|
1259 | + } |
|
1208 | 1260 | |
1209 | 1261 | $loaded_ids[] = $data['id_member']; |
1210 | 1262 | $user_profile[$data['id_member']] = $data; |
@@ -1271,16 +1323,19 @@ discard block |
||
1271 | 1323 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1272 | 1324 | |
1273 | 1325 | // Take care of proxying avatar if required, do this here for maximum reach |
1274 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
1275 | - $row['avatar'] = get_proxied_url($row['avatar']); |
|
1326 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
1327 | + $row['avatar'] = get_proxied_url($row['avatar']); |
|
1328 | + } |
|
1276 | 1329 | |
1277 | 1330 | // Keep track of the member's normal member group |
1278 | 1331 | $row['primary_group'] = $row['member_group']; |
1279 | 1332 | |
1280 | - if (isset($row['member_ip'])) |
|
1281 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1282 | - if (isset($row['member_ip2'])) |
|
1283 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1333 | + if (isset($row['member_ip'])) { |
|
1334 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1335 | + } |
|
1336 | + if (isset($row['member_ip2'])) { |
|
1337 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1338 | + } |
|
1284 | 1339 | $new_loaded_ids[] = $row['id_member']; |
1285 | 1340 | $loaded_ids[] = $row['id_member']; |
1286 | 1341 | $row['options'] = array(); |
@@ -1299,8 +1354,9 @@ discard block |
||
1299 | 1354 | 'loaded_ids' => $new_loaded_ids, |
1300 | 1355 | ) |
1301 | 1356 | ); |
1302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1303 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1357 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1358 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1359 | + } |
|
1304 | 1360 | $smcFunc['db_free_result']($request); |
1305 | 1361 | } |
1306 | 1362 | |
@@ -1311,10 +1367,11 @@ discard block |
||
1311 | 1367 | { |
1312 | 1368 | foreach ($loaded_ids as $a_member) |
1313 | 1369 | { |
1314 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1315 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1316 | - else |
|
1317 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1370 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1371 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1372 | + } else { |
|
1373 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1374 | + } |
|
1318 | 1375 | |
1319 | 1376 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1320 | 1377 | |
@@ -1327,8 +1384,9 @@ discard block |
||
1327 | 1384 | |
1328 | 1385 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1329 | 1386 | { |
1330 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1331 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1387 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1388 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1389 | + } |
|
1332 | 1390 | } |
1333 | 1391 | |
1334 | 1392 | // Are we loading any moderators? If so, fix their group data... |
@@ -1354,14 +1412,17 @@ discard block |
||
1354 | 1412 | foreach ($temp_mods as $id) |
1355 | 1413 | { |
1356 | 1414 | // By popular demand, don't show admins or global moderators as moderators. |
1357 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1358 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1415 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1416 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1417 | + } |
|
1359 | 1418 | |
1360 | 1419 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1361 | - if (!empty($row['icons'])) |
|
1362 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1363 | - if (!empty($row['member_group_color'])) |
|
1364 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1420 | + if (!empty($row['icons'])) { |
|
1421 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1422 | + } |
|
1423 | + if (!empty($row['member_group_color'])) { |
|
1424 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1425 | + } |
|
1365 | 1426 | } |
1366 | 1427 | } |
1367 | 1428 | |
@@ -1383,12 +1444,14 @@ discard block |
||
1383 | 1444 | static $loadedLanguages = array(); |
1384 | 1445 | |
1385 | 1446 | // If this person's data is already loaded, skip it. |
1386 | - if (isset($dataLoaded[$user])) |
|
1387 | - return true; |
|
1447 | + if (isset($dataLoaded[$user])) { |
|
1448 | + return true; |
|
1449 | + } |
|
1388 | 1450 | |
1389 | 1451 | // We can't load guests or members not loaded by loadMemberData()! |
1390 | - if ($user == 0) |
|
1391 | - return false; |
|
1452 | + if ($user == 0) { |
|
1453 | + return false; |
|
1454 | + } |
|
1392 | 1455 | if (!isset($user_profile[$user])) |
1393 | 1456 | { |
1394 | 1457 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1414,12 +1477,16 @@ discard block |
||
1414 | 1477 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1415 | 1478 | |
1416 | 1479 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1417 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1480 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1481 | + //icon is set and exists |
|
1418 | 1482 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1419 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1483 | + } elseif (isset($profile['icons'][1])) { |
|
1484 | + //icon is set and doesn't exist, fallback to default |
|
1420 | 1485 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1421 | - else //not set, bye bye |
|
1486 | + } else { |
|
1487 | + //not set, bye bye |
|
1422 | 1488 | $group_icon_url = ''; |
1489 | + } |
|
1423 | 1490 | |
1424 | 1491 | // These minimal values are always loaded |
1425 | 1492 | $memberContext[$user] = array( |
@@ -1438,8 +1505,9 @@ discard block |
||
1438 | 1505 | if ($context['loadMemberContext_set'] != 'minimal') |
1439 | 1506 | { |
1440 | 1507 | // Go the extra mile and load the user's native language name. |
1441 | - if (empty($loadedLanguages)) |
|
1442 | - $loadedLanguages = getLanguages(); |
|
1508 | + if (empty($loadedLanguages)) { |
|
1509 | + $loadedLanguages = getLanguages(); |
|
1510 | + } |
|
1443 | 1511 | |
1444 | 1512 | $memberContext[$user] += array( |
1445 | 1513 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1494,31 +1562,33 @@ discard block |
||
1494 | 1562 | { |
1495 | 1563 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1496 | 1564 | { |
1497 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1498 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1499 | - else |
|
1500 | - $image = get_gravatar_url($profile['email_address']); |
|
1501 | - } |
|
1502 | - else |
|
1565 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1566 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1567 | + } else { |
|
1568 | + $image = get_gravatar_url($profile['email_address']); |
|
1569 | + } |
|
1570 | + } else |
|
1503 | 1571 | { |
1504 | 1572 | // So it's stored in the member table? |
1505 | 1573 | if (!empty($profile['avatar'])) |
1506 | 1574 | { |
1507 | 1575 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1576 | + } elseif (!empty($profile['filename'])) { |
|
1577 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1508 | 1578 | } |
1509 | - elseif (!empty($profile['filename'])) |
|
1510 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1511 | 1579 | // Right... no avatar...use the default one |
1512 | - else |
|
1513 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1580 | + else { |
|
1581 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1582 | + } |
|
1514 | 1583 | } |
1515 | - if (!empty($image)) |
|
1516 | - $memberContext[$user]['avatar'] = array( |
|
1584 | + if (!empty($image)) { |
|
1585 | + $memberContext[$user]['avatar'] = array( |
|
1517 | 1586 | 'name' => $profile['avatar'], |
1518 | 1587 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1519 | 1588 | 'href' => $image, |
1520 | 1589 | 'url' => $image, |
1521 | 1590 | ); |
1591 | + } |
|
1522 | 1592 | } |
1523 | 1593 | |
1524 | 1594 | // Are we also loading the members custom fields into context? |
@@ -1526,13 +1596,15 @@ discard block |
||
1526 | 1596 | { |
1527 | 1597 | $memberContext[$user]['custom_fields'] = array(); |
1528 | 1598 | |
1529 | - if (!isset($context['display_fields'])) |
|
1530 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1599 | + if (!isset($context['display_fields'])) { |
|
1600 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1601 | + } |
|
1531 | 1602 | |
1532 | 1603 | foreach ($context['display_fields'] as $custom) |
1533 | 1604 | { |
1534 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1535 | - continue; |
|
1605 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1606 | + continue; |
|
1607 | + } |
|
1536 | 1608 | |
1537 | 1609 | $value = $profile['options'][$custom['col_name']]; |
1538 | 1610 | |
@@ -1540,31 +1612,36 @@ discard block |
||
1540 | 1612 | $currentKey = 0; |
1541 | 1613 | |
1542 | 1614 | // Create a key => value array for multiple options fields |
1543 | - if (!empty($custom['options'])) |
|
1544 | - foreach ($custom['options'] as $k => $v) |
|
1615 | + if (!empty($custom['options'])) { |
|
1616 | + foreach ($custom['options'] as $k => $v) |
|
1545 | 1617 | { |
1546 | 1618 | $fieldOptions[] = $v; |
1547 | - if (empty($currentKey)) |
|
1548 | - $currentKey = $v == $value ? $k : 0; |
|
1619 | + } |
|
1620 | + if (empty($currentKey)) { |
|
1621 | + $currentKey = $v == $value ? $k : 0; |
|
1622 | + } |
|
1549 | 1623 | } |
1550 | 1624 | |
1551 | 1625 | // BBC? |
1552 | - if ($custom['bbc']) |
|
1553 | - $value = parse_bbc($value); |
|
1626 | + if ($custom['bbc']) { |
|
1627 | + $value = parse_bbc($value); |
|
1628 | + } |
|
1554 | 1629 | |
1555 | 1630 | // ... or checkbox? |
1556 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1557 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1631 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1632 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1633 | + } |
|
1558 | 1634 | |
1559 | 1635 | // Enclosing the user input within some other text? |
1560 | - if (!empty($custom['enclose'])) |
|
1561 | - $value = strtr($custom['enclose'], array( |
|
1636 | + if (!empty($custom['enclose'])) { |
|
1637 | + $value = strtr($custom['enclose'], array( |
|
1562 | 1638 | '{SCRIPTURL}' => $scripturl, |
1563 | 1639 | '{IMAGES_URL}' => $settings['images_url'], |
1564 | 1640 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1565 | 1641 | '{INPUT}' => $value, |
1566 | 1642 | '{KEY}' => $currentKey, |
1567 | 1643 | )); |
1644 | + } |
|
1568 | 1645 | |
1569 | 1646 | $memberContext[$user]['custom_fields'][] = array( |
1570 | 1647 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1591,8 +1668,9 @@ discard block |
||
1591 | 1668 | global $smcFunc, $txt, $scripturl, $settings; |
1592 | 1669 | |
1593 | 1670 | // Do not waste my time... |
1594 | - if (empty($users) || empty($params)) |
|
1595 | - return false; |
|
1671 | + if (empty($users) || empty($params)) { |
|
1672 | + return false; |
|
1673 | + } |
|
1596 | 1674 | |
1597 | 1675 | // Make sure it's an array. |
1598 | 1676 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1619,41 +1697,48 @@ discard block |
||
1619 | 1697 | $currentKey = 0; |
1620 | 1698 | |
1621 | 1699 | // Create a key => value array for multiple options fields |
1622 | - if (!empty($row['field_options'])) |
|
1623 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1700 | + if (!empty($row['field_options'])) { |
|
1701 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
1624 | 1702 | { |
1625 | 1703 | $fieldOptions[] = $v; |
1626 | - if (empty($currentKey)) |
|
1627 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
1704 | + } |
|
1705 | + if (empty($currentKey)) { |
|
1706 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
1707 | + } |
|
1628 | 1708 | } |
1629 | 1709 | |
1630 | 1710 | // BBC? |
1631 | - if (!empty($row['bbc'])) |
|
1632 | - $row['value'] = parse_bbc($row['value']); |
|
1711 | + if (!empty($row['bbc'])) { |
|
1712 | + $row['value'] = parse_bbc($row['value']); |
|
1713 | + } |
|
1633 | 1714 | |
1634 | 1715 | // ... or checkbox? |
1635 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1636 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1716 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1717 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1718 | + } |
|
1637 | 1719 | |
1638 | 1720 | // Enclosing the user input within some other text? |
1639 | - if (!empty($row['enclose'])) |
|
1640 | - $row['value'] = strtr($row['enclose'], array( |
|
1721 | + if (!empty($row['enclose'])) { |
|
1722 | + $row['value'] = strtr($row['enclose'], array( |
|
1641 | 1723 | '{SCRIPTURL}' => $scripturl, |
1642 | 1724 | '{IMAGES_URL}' => $settings['images_url'], |
1643 | 1725 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1644 | 1726 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1645 | 1727 | '{KEY}' => $currentKey, |
1646 | 1728 | )); |
1729 | + } |
|
1647 | 1730 | |
1648 | 1731 | // Send a simple array if there is just 1 param |
1649 | - if (count($params) == 1) |
|
1650 | - $return[$row['id_member']] = $row; |
|
1732 | + if (count($params) == 1) { |
|
1733 | + $return[$row['id_member']] = $row; |
|
1734 | + } |
|
1651 | 1735 | |
1652 | 1736 | // More than 1? knock yourself out... |
1653 | 1737 | else |
1654 | 1738 | { |
1655 | - if (!isset($return[$row['id_member']])) |
|
1656 | - $return[$row['id_member']] = array(); |
|
1739 | + if (!isset($return[$row['id_member']])) { |
|
1740 | + $return[$row['id_member']] = array(); |
|
1741 | + } |
|
1657 | 1742 | |
1658 | 1743 | $return[$row['id_member']][$row['variable']] = $row; |
1659 | 1744 | } |
@@ -1687,8 +1772,9 @@ discard block |
||
1687 | 1772 | global $context; |
1688 | 1773 | |
1689 | 1774 | // Don't know any browser! |
1690 | - if (empty($context['browser'])) |
|
1691 | - detectBrowser(); |
|
1775 | + if (empty($context['browser'])) { |
|
1776 | + detectBrowser(); |
|
1777 | + } |
|
1692 | 1778 | |
1693 | 1779 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1694 | 1780 | } |
@@ -1706,8 +1792,9 @@ discard block |
||
1706 | 1792 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1707 | 1793 | |
1708 | 1794 | // The theme was specified by parameter. |
1709 | - if (!empty($id_theme)) |
|
1710 | - $id_theme = (int) $id_theme; |
|
1795 | + if (!empty($id_theme)) { |
|
1796 | + $id_theme = (int) $id_theme; |
|
1797 | + } |
|
1711 | 1798 | // The theme was specified by REQUEST. |
1712 | 1799 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1713 | 1800 | { |
@@ -1715,32 +1802,38 @@ discard block |
||
1715 | 1802 | $_SESSION['id_theme'] = $id_theme; |
1716 | 1803 | } |
1717 | 1804 | // The theme was specified by REQUEST... previously. |
1718 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1719 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1805 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1806 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1807 | + } |
|
1720 | 1808 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1721 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1722 | - $id_theme = $user_info['theme']; |
|
1809 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1810 | + $id_theme = $user_info['theme']; |
|
1811 | + } |
|
1723 | 1812 | // The theme was specified by the board. |
1724 | - elseif (!empty($board_info['theme'])) |
|
1725 | - $id_theme = $board_info['theme']; |
|
1813 | + elseif (!empty($board_info['theme'])) { |
|
1814 | + $id_theme = $board_info['theme']; |
|
1815 | + } |
|
1726 | 1816 | // The theme is the forum's default. |
1727 | - else |
|
1728 | - $id_theme = $modSettings['theme_guests']; |
|
1817 | + else { |
|
1818 | + $id_theme = $modSettings['theme_guests']; |
|
1819 | + } |
|
1729 | 1820 | |
1730 | 1821 | // Verify the id_theme... no foul play. |
1731 | 1822 | // Always allow the board specific theme, if they are overriding. |
1732 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1733 | - $id_theme = $board_info['theme']; |
|
1823 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1824 | + $id_theme = $board_info['theme']; |
|
1825 | + } |
|
1734 | 1826 | // If they have specified a particular theme to use with SSI allow it to be used. |
1735 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1736 | - $id_theme = (int) $id_theme; |
|
1737 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1827 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1828 | + $id_theme = (int) $id_theme; |
|
1829 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1738 | 1830 | { |
1739 | 1831 | $themes = explode(',', $modSettings['enableThemes']); |
1740 | - if (!in_array($id_theme, $themes)) |
|
1741 | - $id_theme = $modSettings['theme_guests']; |
|
1742 | - else |
|
1743 | - $id_theme = (int) $id_theme; |
|
1832 | + if (!in_array($id_theme, $themes)) { |
|
1833 | + $id_theme = $modSettings['theme_guests']; |
|
1834 | + } else { |
|
1835 | + $id_theme = (int) $id_theme; |
|
1836 | + } |
|
1744 | 1837 | } |
1745 | 1838 | |
1746 | 1839 | // We already load the basic stuff? |
@@ -1749,18 +1842,19 @@ discard block |
||
1749 | 1842 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1750 | 1843 | |
1751 | 1844 | // Disable image proxy if we don't have SSL enabled |
1752 | - if (empty($modSettings['force_ssl'])) |
|
1753 | - $image_proxy_enabled = false; |
|
1845 | + if (empty($modSettings['force_ssl'])) { |
|
1846 | + $image_proxy_enabled = false; |
|
1847 | + } |
|
1754 | 1848 | |
1755 | 1849 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1756 | 1850 | { |
1757 | 1851 | $themeData = $temp; |
1758 | 1852 | $flag = true; |
1853 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1854 | + $themeData = $temp + array($member => array()); |
|
1855 | + } else { |
|
1856 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1759 | 1857 | } |
1760 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1761 | - $themeData = $temp + array($member => array()); |
|
1762 | - else |
|
1763 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1764 | 1858 | |
1765 | 1859 | if (empty($flag)) |
1766 | 1860 | { |
@@ -1780,31 +1874,37 @@ discard block |
||
1780 | 1874 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1781 | 1875 | { |
1782 | 1876 | // There are just things we shouldn't be able to change as members. |
1783 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1784 | - continue; |
|
1877 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1878 | + continue; |
|
1879 | + } |
|
1785 | 1880 | |
1786 | 1881 | // If this is the theme_dir of the default theme, store it. |
1787 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1788 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1882 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1883 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1884 | + } |
|
1789 | 1885 | |
1790 | 1886 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1791 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1792 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1887 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1888 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1889 | + } |
|
1793 | 1890 | } |
1794 | 1891 | $smcFunc['db_free_result']($result); |
1795 | 1892 | |
1796 | - if (!empty($themeData[-1])) |
|
1797 | - foreach ($themeData[-1] as $k => $v) |
|
1893 | + if (!empty($themeData[-1])) { |
|
1894 | + foreach ($themeData[-1] as $k => $v) |
|
1798 | 1895 | { |
1799 | 1896 | if (!isset($themeData[$member][$k])) |
1800 | 1897 | $themeData[$member][$k] = $v; |
1898 | + } |
|
1801 | 1899 | } |
1802 | 1900 | |
1803 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1804 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1901 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1902 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1903 | + } |
|
1805 | 1904 | // Only if we didn't already load that part of the cache... |
1806 | - elseif (!isset($temp)) |
|
1807 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1905 | + elseif (!isset($temp)) { |
|
1906 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1907 | + } |
|
1808 | 1908 | } |
1809 | 1909 | |
1810 | 1910 | $settings = $themeData[0]; |
@@ -1821,17 +1921,20 @@ discard block |
||
1821 | 1921 | $settings['template_dirs'][] = $settings['theme_dir']; |
1822 | 1922 | |
1823 | 1923 | // Based on theme (if there is one). |
1824 | - if (!empty($settings['base_theme_dir'])) |
|
1825 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1924 | + if (!empty($settings['base_theme_dir'])) { |
|
1925 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1926 | + } |
|
1826 | 1927 | |
1827 | 1928 | // Lastly the default theme. |
1828 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1829 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1929 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1930 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1931 | + } |
|
1830 | 1932 | } |
1831 | 1933 | |
1832 | 1934 | |
1833 | - if (!$initialize) |
|
1834 | - return; |
|
1935 | + if (!$initialize) { |
|
1936 | + return; |
|
1937 | + } |
|
1835 | 1938 | |
1836 | 1939 | // Check to see if we're forcing SSL |
1837 | 1940 | if (!empty($modSettings['force_ssl']) && empty($maintenance) && |
@@ -1852,8 +1955,9 @@ discard block |
||
1852 | 1955 | $detected_url = httpsOn() ? 'https://' : 'http://'; |
1853 | 1956 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1854 | 1957 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1855 | - if ($temp != '/') |
|
1856 | - $detected_url .= $temp; |
|
1958 | + if ($temp != '/') { |
|
1959 | + $detected_url .= $temp; |
|
1960 | + } |
|
1857 | 1961 | } |
1858 | 1962 | if (isset($detected_url) && $detected_url != $boardurl) |
1859 | 1963 | { |
@@ -1865,8 +1969,9 @@ discard block |
||
1865 | 1969 | foreach ($aliases as $alias) |
1866 | 1970 | { |
1867 | 1971 | // Rip off all the boring parts, spaces, etc. |
1868 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1869 | - $do_fix = true; |
|
1972 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1973 | + $do_fix = true; |
|
1974 | + } |
|
1870 | 1975 | } |
1871 | 1976 | } |
1872 | 1977 | |
@@ -1874,21 +1979,23 @@ discard block |
||
1874 | 1979 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1875 | 1980 | { |
1876 | 1981 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1877 | - if (empty($_GET)) |
|
1878 | - redirectexit('wwwRedirect'); |
|
1879 | - else |
|
1982 | + if (empty($_GET)) { |
|
1983 | + redirectexit('wwwRedirect'); |
|
1984 | + } else |
|
1880 | 1985 | { |
1881 | 1986 | $k = key($_GET); |
1882 | 1987 | $v = current($_GET); |
1883 | 1988 | |
1884 | - if ($k != 'wwwRedirect') |
|
1885 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1989 | + if ($k != 'wwwRedirect') { |
|
1990 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1991 | + } |
|
1886 | 1992 | } |
1887 | 1993 | } |
1888 | 1994 | |
1889 | 1995 | // #3 is just a check for SSL... |
1890 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1891 | - $do_fix = true; |
|
1996 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1997 | + $do_fix = true; |
|
1998 | + } |
|
1892 | 1999 | |
1893 | 2000 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1894 | 2001 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1923,8 +2030,9 @@ discard block |
||
1923 | 2030 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1924 | 2031 | } |
1925 | 2032 | } |
1926 | - foreach ($context['linktree'] as $k => $dummy) |
|
1927 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2033 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2034 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2035 | + } |
|
1928 | 2036 | } |
1929 | 2037 | } |
1930 | 2038 | // Set up the contextual user array. |
@@ -1943,16 +2051,16 @@ discard block |
||
1943 | 2051 | 'email' => $user_info['email'], |
1944 | 2052 | 'ignoreusers' => $user_info['ignoreusers'], |
1945 | 2053 | ); |
1946 | - if (!$context['user']['is_guest']) |
|
1947 | - $context['user']['name'] = $user_info['name']; |
|
1948 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1949 | - $context['user']['name'] = $txt['guest_title']; |
|
2054 | + if (!$context['user']['is_guest']) { |
|
2055 | + $context['user']['name'] = $user_info['name']; |
|
2056 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2057 | + $context['user']['name'] = $txt['guest_title']; |
|
2058 | + } |
|
1950 | 2059 | |
1951 | 2060 | // Determine the current smiley set. |
1952 | 2061 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1953 | 2062 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1954 | - } |
|
1955 | - else |
|
2063 | + } else |
|
1956 | 2064 | { |
1957 | 2065 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1958 | 2066 | $context['user'] = array( |
@@ -1986,18 +2094,24 @@ discard block |
||
1986 | 2094 | } |
1987 | 2095 | |
1988 | 2096 | // Some basic information... |
1989 | - if (!isset($context['html_headers'])) |
|
1990 | - $context['html_headers'] = ''; |
|
1991 | - if (!isset($context['javascript_files'])) |
|
1992 | - $context['javascript_files'] = array(); |
|
1993 | - if (!isset($context['css_files'])) |
|
1994 | - $context['css_files'] = array(); |
|
1995 | - if (!isset($context['css_header'])) |
|
1996 | - $context['css_header'] = array(); |
|
1997 | - if (!isset($context['javascript_inline'])) |
|
1998 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1999 | - if (!isset($context['javascript_vars'])) |
|
2000 | - $context['javascript_vars'] = array(); |
|
2097 | + if (!isset($context['html_headers'])) { |
|
2098 | + $context['html_headers'] = ''; |
|
2099 | + } |
|
2100 | + if (!isset($context['javascript_files'])) { |
|
2101 | + $context['javascript_files'] = array(); |
|
2102 | + } |
|
2103 | + if (!isset($context['css_files'])) { |
|
2104 | + $context['css_files'] = array(); |
|
2105 | + } |
|
2106 | + if (!isset($context['css_header'])) { |
|
2107 | + $context['css_header'] = array(); |
|
2108 | + } |
|
2109 | + if (!isset($context['javascript_inline'])) { |
|
2110 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2111 | + } |
|
2112 | + if (!isset($context['javascript_vars'])) { |
|
2113 | + $context['javascript_vars'] = array(); |
|
2114 | + } |
|
2001 | 2115 | |
2002 | 2116 | $context['login_url'] = $scripturl . '?action=login2'; |
2003 | 2117 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2009,16 +2123,18 @@ discard block |
||
2009 | 2123 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
2010 | 2124 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
2011 | 2125 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
2012 | - if (isset($modSettings['load_average'])) |
|
2013 | - $context['load_average'] = $modSettings['load_average']; |
|
2126 | + if (isset($modSettings['load_average'])) { |
|
2127 | + $context['load_average'] = $modSettings['load_average']; |
|
2128 | + } |
|
2014 | 2129 | |
2015 | 2130 | // Detect the browser. This is separated out because it's also used in attachment downloads |
2016 | 2131 | detectBrowser(); |
2017 | 2132 | |
2018 | 2133 | // Set the top level linktree up. |
2019 | 2134 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
2020 | - if (empty($context['linktree'])) |
|
2021 | - $context['linktree'] = array(); |
|
2135 | + if (empty($context['linktree'])) { |
|
2136 | + $context['linktree'] = array(); |
|
2137 | + } |
|
2022 | 2138 | array_unshift($context['linktree'], array( |
2023 | 2139 | 'url' => $scripturl, |
2024 | 2140 | 'name' => $context['forum_name_html_safe'] |
@@ -2027,8 +2143,9 @@ discard block |
||
2027 | 2143 | // This allows sticking some HTML on the page output - useful for controls. |
2028 | 2144 | $context['insert_after_template'] = ''; |
2029 | 2145 | |
2030 | - if (!isset($txt)) |
|
2031 | - $txt = array(); |
|
2146 | + if (!isset($txt)) { |
|
2147 | + $txt = array(); |
|
2148 | + } |
|
2032 | 2149 | |
2033 | 2150 | $simpleActions = array( |
2034 | 2151 | 'findmember', |
@@ -2074,9 +2191,10 @@ discard block |
||
2074 | 2191 | |
2075 | 2192 | // See if theres any extra param to check. |
2076 | 2193 | $requiresXML = false; |
2077 | - foreach ($extraParams as $key => $extra) |
|
2078 | - if (isset($_REQUEST[$extra])) |
|
2194 | + foreach ($extraParams as $key => $extra) { |
|
2195 | + if (isset($_REQUEST[$extra])) |
|
2079 | 2196 | $requiresXML = true; |
2197 | + } |
|
2080 | 2198 | |
2081 | 2199 | // Output is fully XML, so no need for the index template. |
2082 | 2200 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2091,37 +2209,39 @@ discard block |
||
2091 | 2209 | { |
2092 | 2210 | loadLanguage('index+Modifications'); |
2093 | 2211 | $context['template_layers'] = array(); |
2094 | - } |
|
2095 | - |
|
2096 | - else |
|
2212 | + } else |
|
2097 | 2213 | { |
2098 | 2214 | // Custom templates to load, or just default? |
2099 | - if (isset($settings['theme_templates'])) |
|
2100 | - $templates = explode(',', $settings['theme_templates']); |
|
2101 | - else |
|
2102 | - $templates = array('index'); |
|
2215 | + if (isset($settings['theme_templates'])) { |
|
2216 | + $templates = explode(',', $settings['theme_templates']); |
|
2217 | + } else { |
|
2218 | + $templates = array('index'); |
|
2219 | + } |
|
2103 | 2220 | |
2104 | 2221 | // Load each template... |
2105 | - foreach ($templates as $template) |
|
2106 | - loadTemplate($template); |
|
2222 | + foreach ($templates as $template) { |
|
2223 | + loadTemplate($template); |
|
2224 | + } |
|
2107 | 2225 | |
2108 | 2226 | // ...and attempt to load their associated language files. |
2109 | 2227 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2110 | 2228 | loadLanguage($required_files, '', false); |
2111 | 2229 | |
2112 | 2230 | // Custom template layers? |
2113 | - if (isset($settings['theme_layers'])) |
|
2114 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2115 | - else |
|
2116 | - $context['template_layers'] = array('html', 'body'); |
|
2231 | + if (isset($settings['theme_layers'])) { |
|
2232 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2233 | + } else { |
|
2234 | + $context['template_layers'] = array('html', 'body'); |
|
2235 | + } |
|
2117 | 2236 | } |
2118 | 2237 | |
2119 | 2238 | // Initialize the theme. |
2120 | 2239 | loadSubTemplate('init', 'ignore'); |
2121 | 2240 | |
2122 | 2241 | // Allow overriding the board wide time/number formats. |
2123 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2124 | - $user_info['time_format'] = $txt['time_format']; |
|
2242 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2243 | + $user_info['time_format'] = $txt['time_format']; |
|
2244 | + } |
|
2125 | 2245 | |
2126 | 2246 | // Set the character set from the template. |
2127 | 2247 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2129,12 +2249,14 @@ discard block |
||
2129 | 2249 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2130 | 2250 | |
2131 | 2251 | // Guests may still need a name. |
2132 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2133 | - $context['user']['name'] = $txt['guest_title']; |
|
2252 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2253 | + $context['user']['name'] = $txt['guest_title']; |
|
2254 | + } |
|
2134 | 2255 | |
2135 | 2256 | // Any theme-related strings that need to be loaded? |
2136 | - if (!empty($settings['require_theme_strings'])) |
|
2137 | - loadLanguage('ThemeStrings', '', false); |
|
2257 | + if (!empty($settings['require_theme_strings'])) { |
|
2258 | + loadLanguage('ThemeStrings', '', false); |
|
2259 | + } |
|
2138 | 2260 | |
2139 | 2261 | // Make a special URL for the language. |
2140 | 2262 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2145,8 +2267,9 @@ discard block |
||
2145 | 2267 | // Here is my luvly Responsive CSS |
2146 | 2268 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive'); |
2147 | 2269 | |
2148 | - if ($context['right_to_left']) |
|
2149 | - loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
2270 | + if ($context['right_to_left']) { |
|
2271 | + loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
2272 | + } |
|
2150 | 2273 | |
2151 | 2274 | // We allow theme variants, because we're cool. |
2152 | 2275 | $context['theme_variant'] = ''; |
@@ -2154,14 +2277,17 @@ discard block |
||
2154 | 2277 | if (!empty($settings['theme_variants'])) |
2155 | 2278 | { |
2156 | 2279 | // Overriding - for previews and that ilk. |
2157 | - if (!empty($_REQUEST['variant'])) |
|
2158 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2280 | + if (!empty($_REQUEST['variant'])) { |
|
2281 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2282 | + } |
|
2159 | 2283 | // User selection? |
2160 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2161 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2284 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2285 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2286 | + } |
|
2162 | 2287 | // If not a user variant, select the default. |
2163 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2164 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2288 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2289 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2290 | + } |
|
2165 | 2291 | |
2166 | 2292 | // Do this to keep things easier in the templates. |
2167 | 2293 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2170,20 +2296,23 @@ discard block |
||
2170 | 2296 | if (!empty($context['theme_variant'])) |
2171 | 2297 | { |
2172 | 2298 | loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']); |
2173 | - if ($context['right_to_left']) |
|
2174 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
2299 | + if ($context['right_to_left']) { |
|
2300 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
2301 | + } |
|
2175 | 2302 | } |
2176 | 2303 | } |
2177 | 2304 | |
2178 | 2305 | // Let's be compatible with old themes! |
2179 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2180 | - $context['template_layers'] = array('main'); |
|
2306 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2307 | + $context['template_layers'] = array('main'); |
|
2308 | + } |
|
2181 | 2309 | |
2182 | 2310 | $context['tabindex'] = 1; |
2183 | 2311 | |
2184 | 2312 | // Compatibility. |
2185 | - if (!isset($settings['theme_version'])) |
|
2186 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2313 | + if (!isset($settings['theme_version'])) { |
|
2314 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2315 | + } |
|
2187 | 2316 | |
2188 | 2317 | // Default JS variables for use in every theme |
2189 | 2318 | $context['javascript_vars'] = array( |
@@ -2202,18 +2331,18 @@ discard block |
||
2202 | 2331 | ); |
2203 | 2332 | |
2204 | 2333 | // Add the JQuery library to the list of files to load. |
2205 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2206 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2207 | - |
|
2208 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2209 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2210 | - |
|
2211 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2212 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2334 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2335 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2336 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2337 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2338 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2339 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2340 | + } |
|
2213 | 2341 | |
2214 | 2342 | // Auto loading? template_javascript() will take care of the local half of this. |
2215 | - else |
|
2216 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2343 | + else { |
|
2344 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2345 | + } |
|
2217 | 2346 | |
2218 | 2347 | // Queue our JQuery plugins! |
2219 | 2348 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2236,12 +2365,12 @@ discard block |
||
2236 | 2365 | require_once($sourcedir . '/ScheduledTasks.php'); |
2237 | 2366 | |
2238 | 2367 | // What to do, what to do?! |
2239 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2240 | - AutoTask(); |
|
2241 | - else |
|
2242 | - ReduceMailQueue(); |
|
2243 | - } |
|
2244 | - else |
|
2368 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2369 | + AutoTask(); |
|
2370 | + } else { |
|
2371 | + ReduceMailQueue(); |
|
2372 | + } |
|
2373 | + } else |
|
2245 | 2374 | { |
2246 | 2375 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2247 | 2376 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2292,8 +2421,9 @@ discard block |
||
2292 | 2421 | foreach ($theme_includes as $include) |
2293 | 2422 | { |
2294 | 2423 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2295 | - if (file_exists($include)) |
|
2296 | - require_once($include); |
|
2424 | + if (file_exists($include)) { |
|
2425 | + require_once($include); |
|
2426 | + } |
|
2297 | 2427 | } |
2298 | 2428 | } |
2299 | 2429 | |
@@ -2323,16 +2453,19 @@ discard block |
||
2323 | 2453 | // Do any style sheets first, cause we're easy with those. |
2324 | 2454 | if (!empty($style_sheets)) |
2325 | 2455 | { |
2326 | - if (!is_array($style_sheets)) |
|
2327 | - $style_sheets = array($style_sheets); |
|
2456 | + if (!is_array($style_sheets)) { |
|
2457 | + $style_sheets = array($style_sheets); |
|
2458 | + } |
|
2328 | 2459 | |
2329 | - foreach ($style_sheets as $sheet) |
|
2330 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2460 | + foreach ($style_sheets as $sheet) { |
|
2461 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2462 | + } |
|
2331 | 2463 | } |
2332 | 2464 | |
2333 | 2465 | // No template to load? |
2334 | - if ($template_name === false) |
|
2335 | - return true; |
|
2466 | + if ($template_name === false) { |
|
2467 | + return true; |
|
2468 | + } |
|
2336 | 2469 | |
2337 | 2470 | $loaded = false; |
2338 | 2471 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2347,12 +2480,14 @@ discard block |
||
2347 | 2480 | |
2348 | 2481 | if ($loaded) |
2349 | 2482 | { |
2350 | - if ($db_show_debug === true) |
|
2351 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2483 | + if ($db_show_debug === true) { |
|
2484 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2485 | + } |
|
2352 | 2486 | |
2353 | 2487 | // If they have specified an initialization function for this template, go ahead and call it now. |
2354 | - if (function_exists('template_' . $template_name . '_init')) |
|
2355 | - call_user_func('template_' . $template_name . '_init'); |
|
2488 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2489 | + call_user_func('template_' . $template_name . '_init'); |
|
2490 | + } |
|
2356 | 2491 | } |
2357 | 2492 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2358 | 2493 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2372,13 +2507,14 @@ discard block |
||
2372 | 2507 | loadTemplate($template_name); |
2373 | 2508 | } |
2374 | 2509 | // Cause an error otherwise. |
2375 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2376 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2377 | - elseif ($fatal) |
|
2378 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2379 | - else |
|
2380 | - return false; |
|
2381 | -} |
|
2510 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2511 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2512 | + } elseif ($fatal) { |
|
2513 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2514 | + } else { |
|
2515 | + return false; |
|
2516 | + } |
|
2517 | + } |
|
2382 | 2518 | |
2383 | 2519 | /** |
2384 | 2520 | * Load a sub-template. |
@@ -2396,17 +2532,19 @@ discard block |
||
2396 | 2532 | { |
2397 | 2533 | global $context, $txt, $db_show_debug; |
2398 | 2534 | |
2399 | - if ($db_show_debug === true) |
|
2400 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2535 | + if ($db_show_debug === true) { |
|
2536 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2537 | + } |
|
2401 | 2538 | |
2402 | 2539 | // Figure out what the template function is named. |
2403 | 2540 | $theme_function = 'template_' . $sub_template_name; |
2404 | - if (function_exists($theme_function)) |
|
2405 | - $theme_function(); |
|
2406 | - elseif ($fatal === false) |
|
2407 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2408 | - elseif ($fatal !== 'ignore') |
|
2409 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2541 | + if (function_exists($theme_function)) { |
|
2542 | + $theme_function(); |
|
2543 | + } elseif ($fatal === false) { |
|
2544 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2545 | + } elseif ($fatal !== 'ignore') { |
|
2546 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2547 | + } |
|
2410 | 2548 | |
2411 | 2549 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2412 | 2550 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2436,8 +2574,9 @@ discard block |
||
2436 | 2574 | { |
2437 | 2575 | global $settings, $context, $modSettings; |
2438 | 2576 | |
2439 | - if (empty($context['css_files_order'])) |
|
2440 | - $context['css_files_order'] = array(); |
|
2577 | + if (empty($context['css_files_order'])) { |
|
2578 | + $context['css_files_order'] = array(); |
|
2579 | + } |
|
2441 | 2580 | |
2442 | 2581 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : ''); |
2443 | 2582 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
@@ -2448,8 +2587,9 @@ discard block |
||
2448 | 2587 | $params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000; |
2449 | 2588 | |
2450 | 2589 | // If this is an external file, automatically set this to false. |
2451 | - if (!empty($params['external'])) |
|
2452 | - $params['minimize'] = false; |
|
2590 | + if (!empty($params['external'])) { |
|
2591 | + $params['minimize'] = false; |
|
2592 | + } |
|
2453 | 2593 | |
2454 | 2594 | // Account for shorthand like admin.css?alp21 filenames |
2455 | 2595 | $has_seed = strpos($fileName, '.css?'); |
@@ -2466,16 +2606,12 @@ discard block |
||
2466 | 2606 | { |
2467 | 2607 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2468 | 2608 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2469 | - } |
|
2470 | - |
|
2471 | - else |
|
2609 | + } else |
|
2472 | 2610 | { |
2473 | 2611 | $fileUrl = false; |
2474 | 2612 | $filePath = false; |
2475 | 2613 | } |
2476 | - } |
|
2477 | - |
|
2478 | - else |
|
2614 | + } else |
|
2479 | 2615 | { |
2480 | 2616 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2481 | 2617 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2493,16 +2629,18 @@ discard block |
||
2493 | 2629 | if (!empty($fileName)) |
2494 | 2630 | { |
2495 | 2631 | // find a free number/position |
2496 | - while (isset($context['css_files_order'][$params['order_pos']])) |
|
2497 | - $params['order_pos']++; |
|
2632 | + while (isset($context['css_files_order'][$params['order_pos']])) { |
|
2633 | + $params['order_pos']++; |
|
2634 | + } |
|
2498 | 2635 | $context['css_files_order'][$params['order_pos']] = $id; |
2499 | 2636 | |
2500 | 2637 | $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
2501 | 2638 | } |
2502 | 2639 | |
2503 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2504 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2505 | -} |
|
2640 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2641 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2642 | + } |
|
2643 | + } |
|
2506 | 2644 | |
2507 | 2645 | /** |
2508 | 2646 | * Add a block of inline css code to be executed later |
@@ -2519,8 +2657,9 @@ discard block |
||
2519 | 2657 | global $context; |
2520 | 2658 | |
2521 | 2659 | // Gotta add something... |
2522 | - if (empty($css)) |
|
2523 | - return false; |
|
2660 | + if (empty($css)) { |
|
2661 | + return false; |
|
2662 | + } |
|
2524 | 2663 | |
2525 | 2664 | $context['css_header'][] = $css; |
2526 | 2665 | } |
@@ -2556,8 +2695,9 @@ discard block |
||
2556 | 2695 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2557 | 2696 | |
2558 | 2697 | // If this is an external file, automatically set this to false. |
2559 | - if (!empty($params['external'])) |
|
2560 | - $params['minimize'] = false; |
|
2698 | + if (!empty($params['external'])) { |
|
2699 | + $params['minimize'] = false; |
|
2700 | + } |
|
2561 | 2701 | |
2562 | 2702 | // Account for shorthand like admin.js?alp21 filenames |
2563 | 2703 | $has_seed = strpos($fileName, '.js?'); |
@@ -2574,16 +2714,12 @@ discard block |
||
2574 | 2714 | { |
2575 | 2715 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2576 | 2716 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2577 | - } |
|
2578 | - |
|
2579 | - else |
|
2717 | + } else |
|
2580 | 2718 | { |
2581 | 2719 | $fileUrl = false; |
2582 | 2720 | $filePath = false; |
2583 | 2721 | } |
2584 | - } |
|
2585 | - |
|
2586 | - else |
|
2722 | + } else |
|
2587 | 2723 | { |
2588 | 2724 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2589 | 2725 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2598,9 +2734,10 @@ discard block |
||
2598 | 2734 | } |
2599 | 2735 | |
2600 | 2736 | // Add it to the array for use in the template |
2601 | - if (!empty($fileName)) |
|
2602 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2603 | -} |
|
2737 | + if (!empty($fileName)) { |
|
2738 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2739 | + } |
|
2740 | + } |
|
2604 | 2741 | |
2605 | 2742 | /** |
2606 | 2743 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2614,9 +2751,10 @@ discard block |
||
2614 | 2751 | { |
2615 | 2752 | global $context; |
2616 | 2753 | |
2617 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2618 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2619 | -} |
|
2754 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2755 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2756 | + } |
|
2757 | + } |
|
2620 | 2758 | |
2621 | 2759 | /** |
2622 | 2760 | * Add a block of inline Javascript code to be executed later |
@@ -2633,8 +2771,9 @@ discard block |
||
2633 | 2771 | { |
2634 | 2772 | global $context; |
2635 | 2773 | |
2636 | - if (empty($javascript)) |
|
2637 | - return false; |
|
2774 | + if (empty($javascript)) { |
|
2775 | + return false; |
|
2776 | + } |
|
2638 | 2777 | |
2639 | 2778 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2640 | 2779 | } |
@@ -2655,15 +2794,18 @@ discard block |
||
2655 | 2794 | static $already_loaded = array(); |
2656 | 2795 | |
2657 | 2796 | // Default to the user's language. |
2658 | - if ($lang == '') |
|
2659 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2797 | + if ($lang == '') { |
|
2798 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2799 | + } |
|
2660 | 2800 | |
2661 | 2801 | // Do we want the English version of language file as fallback? |
2662 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2663 | - loadLanguage($template_name, 'english', false); |
|
2802 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2803 | + loadLanguage($template_name, 'english', false); |
|
2804 | + } |
|
2664 | 2805 | |
2665 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2666 | - return $lang; |
|
2806 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2807 | + return $lang; |
|
2808 | + } |
|
2667 | 2809 | |
2668 | 2810 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2669 | 2811 | if (empty($settings['default_theme_dir'])) |
@@ -2674,8 +2816,9 @@ discard block |
||
2674 | 2816 | |
2675 | 2817 | // What theme are we in? |
2676 | 2818 | $theme_name = basename($settings['theme_url']); |
2677 | - if (empty($theme_name)) |
|
2678 | - $theme_name = 'unknown'; |
|
2819 | + if (empty($theme_name)) { |
|
2820 | + $theme_name = 'unknown'; |
|
2821 | + } |
|
2679 | 2822 | |
2680 | 2823 | // For each file open it up and write it out! |
2681 | 2824 | foreach (explode('+', $template_name) as $template) |
@@ -2717,8 +2860,9 @@ discard block |
||
2717 | 2860 | $found = true; |
2718 | 2861 | |
2719 | 2862 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2720 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2721 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2863 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2864 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2865 | + } |
|
2722 | 2866 | |
2723 | 2867 | break; |
2724 | 2868 | } |
@@ -2758,8 +2902,9 @@ discard block |
||
2758 | 2902 | } |
2759 | 2903 | |
2760 | 2904 | // Keep track of what we're up to soldier. |
2761 | - if ($db_show_debug === true) |
|
2762 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2905 | + if ($db_show_debug === true) { |
|
2906 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2907 | + } |
|
2763 | 2908 | |
2764 | 2909 | // Remember what we have loaded, and in which language. |
2765 | 2910 | $already_loaded[$template_name] = $lang; |
@@ -2805,8 +2950,9 @@ discard block |
||
2805 | 2950 | ) |
2806 | 2951 | ); |
2807 | 2952 | // In the EXTREMELY unlikely event this happens, give an error message. |
2808 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2809 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2953 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2954 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2955 | + } |
|
2810 | 2956 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2811 | 2957 | { |
2812 | 2958 | if (!isset($boards[$row['id_board']])) |
@@ -2823,8 +2969,8 @@ discard block |
||
2823 | 2969 | ); |
2824 | 2970 | } |
2825 | 2971 | // If a moderator exists for this board, add that moderator for all children too. |
2826 | - if (!empty($row['id_moderator'])) |
|
2827 | - foreach ($boards as $id => $dummy) |
|
2972 | + if (!empty($row['id_moderator'])) { |
|
2973 | + foreach ($boards as $id => $dummy) |
|
2828 | 2974 | { |
2829 | 2975 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2830 | 2976 | 'id' => $row['id_moderator'], |
@@ -2832,11 +2978,12 @@ discard block |
||
2832 | 2978 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2833 | 2979 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2834 | 2980 | ); |
2981 | + } |
|
2835 | 2982 | } |
2836 | 2983 | |
2837 | 2984 | // If a moderator group exists for this board, add that moderator group for all children too |
2838 | - if (!empty($row['id_moderator_group'])) |
|
2839 | - foreach ($boards as $id => $dummy) |
|
2985 | + if (!empty($row['id_moderator_group'])) { |
|
2986 | + foreach ($boards as $id => $dummy) |
|
2840 | 2987 | { |
2841 | 2988 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2842 | 2989 | 'id' => $row['id_moderator_group'], |
@@ -2844,6 +2991,7 @@ discard block |
||
2844 | 2991 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2845 | 2992 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2846 | 2993 | ); |
2994 | + } |
|
2847 | 2995 | } |
2848 | 2996 | } |
2849 | 2997 | $smcFunc['db_free_result']($result); |
@@ -2870,23 +3018,27 @@ discard block |
||
2870 | 3018 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2871 | 3019 | { |
2872 | 3020 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2873 | - if (empty($smcFunc['ucwords'])) |
|
2874 | - reloadSettings(); |
|
3021 | + if (empty($smcFunc['ucwords'])) { |
|
3022 | + reloadSettings(); |
|
3023 | + } |
|
2875 | 3024 | |
2876 | 3025 | // If we don't have our theme information yet, let's get it. |
2877 | - if (empty($settings['default_theme_dir'])) |
|
2878 | - loadTheme(0, false); |
|
3026 | + if (empty($settings['default_theme_dir'])) { |
|
3027 | + loadTheme(0, false); |
|
3028 | + } |
|
2879 | 3029 | |
2880 | 3030 | // Default language directories to try. |
2881 | 3031 | $language_directories = array( |
2882 | 3032 | $settings['default_theme_dir'] . '/languages', |
2883 | 3033 | ); |
2884 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2885 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3034 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
3035 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3036 | + } |
|
2886 | 3037 | |
2887 | 3038 | // We possibly have a base theme directory. |
2888 | - if (!empty($settings['base_theme_dir'])) |
|
2889 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3039 | + if (!empty($settings['base_theme_dir'])) { |
|
3040 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3041 | + } |
|
2890 | 3042 | |
2891 | 3043 | // Remove any duplicates. |
2892 | 3044 | $language_directories = array_unique($language_directories); |
@@ -2900,20 +3052,21 @@ discard block |
||
2900 | 3052 | foreach ($language_directories as $language_dir) |
2901 | 3053 | { |
2902 | 3054 | // Can't look in here... doesn't exist! |
2903 | - if (!file_exists($language_dir)) |
|
2904 | - continue; |
|
3055 | + if (!file_exists($language_dir)) { |
|
3056 | + continue; |
|
3057 | + } |
|
2905 | 3058 | |
2906 | 3059 | $dir = dir($language_dir); |
2907 | 3060 | while ($entry = $dir->read()) |
2908 | 3061 | { |
2909 | 3062 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2910 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2911 | - continue; |
|
2912 | - |
|
2913 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2914 | - $langName = $langList[$matches[1]]; |
|
3063 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3064 | + continue; |
|
3065 | + } |
|
2915 | 3066 | |
2916 | - else |
|
3067 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3068 | + $langName = $langList[$matches[1]]; |
|
3069 | + } else |
|
2917 | 3070 | { |
2918 | 3071 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2919 | 3072 | |
@@ -2954,12 +3107,14 @@ discard block |
||
2954 | 3107 | } |
2955 | 3108 | |
2956 | 3109 | // Do we need to store the lang list? |
2957 | - if (empty($langList)) |
|
2958 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3110 | + if (empty($langList)) { |
|
3111 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3112 | + } |
|
2959 | 3113 | |
2960 | 3114 | // Let's cash in on this deal. |
2961 | - if (!empty($modSettings['cache_enable'])) |
|
2962 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3115 | + if (!empty($modSettings['cache_enable'])) { |
|
3116 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3117 | + } |
|
2963 | 3118 | } |
2964 | 3119 | |
2965 | 3120 | return $context['languages']; |
@@ -2982,8 +3137,9 @@ discard block |
||
2982 | 3137 | global $modSettings, $options, $txt; |
2983 | 3138 | static $censor_vulgar = null, $censor_proper; |
2984 | 3139 | |
2985 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2986 | - return $text; |
|
3140 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3141 | + return $text; |
|
3142 | + } |
|
2987 | 3143 | |
2988 | 3144 | // If they haven't yet been loaded, load them. |
2989 | 3145 | if ($censor_vulgar == null) |
@@ -3014,9 +3170,9 @@ discard block |
||
3014 | 3170 | { |
3015 | 3171 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
3016 | 3172 | $text = $func($censor_vulgar, $censor_proper, $text); |
3173 | + } else { |
|
3174 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3017 | 3175 | } |
3018 | - else |
|
3019 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3020 | 3176 | |
3021 | 3177 | return $text; |
3022 | 3178 | } |
@@ -3042,30 +3198,35 @@ discard block |
||
3042 | 3198 | @ini_set('track_errors', '1'); |
3043 | 3199 | |
3044 | 3200 | // Don't include the file more than once, if $once is true. |
3045 | - if ($once && in_array($filename, $templates)) |
|
3046 | - return; |
|
3201 | + if ($once && in_array($filename, $templates)) { |
|
3202 | + return; |
|
3203 | + } |
|
3047 | 3204 | // Add this file to the include list, whether $once is true or not. |
3048 | - else |
|
3049 | - $templates[] = $filename; |
|
3205 | + else { |
|
3206 | + $templates[] = $filename; |
|
3207 | + } |
|
3050 | 3208 | |
3051 | 3209 | |
3052 | 3210 | $file_found = file_exists($filename); |
3053 | 3211 | |
3054 | - if ($once && $file_found) |
|
3055 | - require_once($filename); |
|
3056 | - elseif ($file_found) |
|
3057 | - require($filename); |
|
3212 | + if ($once && $file_found) { |
|
3213 | + require_once($filename); |
|
3214 | + } elseif ($file_found) { |
|
3215 | + require($filename); |
|
3216 | + } |
|
3058 | 3217 | |
3059 | 3218 | if ($file_found !== true) |
3060 | 3219 | { |
3061 | 3220 | ob_end_clean(); |
3062 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3063 | - @ob_start('ob_gzhandler'); |
|
3064 | - else |
|
3065 | - ob_start(); |
|
3221 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3222 | + @ob_start('ob_gzhandler'); |
|
3223 | + } else { |
|
3224 | + ob_start(); |
|
3225 | + } |
|
3066 | 3226 | |
3067 | - if (isset($_GET['debug'])) |
|
3068 | - header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3227 | + if (isset($_GET['debug'])) { |
|
3228 | + header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3229 | + } |
|
3069 | 3230 | |
3070 | 3231 | // Don't cache error pages!! |
3071 | 3232 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3084,12 +3245,13 @@ discard block |
||
3084 | 3245 | echo '<!DOCTYPE html> |
3085 | 3246 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3086 | 3247 | <head>'; |
3087 | - if (isset($context['character_set'])) |
|
3088 | - echo ' |
|
3248 | + if (isset($context['character_set'])) { |
|
3249 | + echo ' |
|
3089 | 3250 | <meta charset="', $context['character_set'], '">'; |
3251 | + } |
|
3090 | 3252 | |
3091 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3092 | - echo ' |
|
3253 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3254 | + echo ' |
|
3093 | 3255 | <title>', $mtitle, '</title> |
3094 | 3256 | </head> |
3095 | 3257 | <body> |
@@ -3097,8 +3259,8 @@ discard block |
||
3097 | 3259 | ', $mmessage, ' |
3098 | 3260 | </body> |
3099 | 3261 | </html>'; |
3100 | - elseif (!allowedTo('admin_forum')) |
|
3101 | - echo ' |
|
3262 | + } elseif (!allowedTo('admin_forum')) { |
|
3263 | + echo ' |
|
3102 | 3264 | <title>', $txt['template_parse_error'], '</title> |
3103 | 3265 | </head> |
3104 | 3266 | <body> |
@@ -3106,14 +3268,16 @@ discard block |
||
3106 | 3268 | ', $txt['template_parse_error_message'], ' |
3107 | 3269 | </body> |
3108 | 3270 | </html>'; |
3109 | - else |
|
3271 | + } else |
|
3110 | 3272 | { |
3111 | 3273 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3112 | 3274 | $error_array = error_get_last(); |
3113 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3114 | - $error = $error_array['message']; |
|
3115 | - if (empty($error)) |
|
3116 | - $error = $txt['template_parse_errmsg']; |
|
3275 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3276 | + $error = $error_array['message']; |
|
3277 | + } |
|
3278 | + if (empty($error)) { |
|
3279 | + $error = $txt['template_parse_errmsg']; |
|
3280 | + } |
|
3117 | 3281 | |
3118 | 3282 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3119 | 3283 | |
@@ -3124,11 +3288,12 @@ discard block |
||
3124 | 3288 | <h3>', $txt['template_parse_error'], '</h3> |
3125 | 3289 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3126 | 3290 | |
3127 | - if (!empty($error)) |
|
3128 | - echo ' |
|
3291 | + if (!empty($error)) { |
|
3292 | + echo ' |
|
3129 | 3293 | <hr> |
3130 | 3294 | |
3131 | 3295 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3296 | + } |
|
3132 | 3297 | |
3133 | 3298 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3134 | 3299 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3138,10 +3303,11 @@ discard block |
||
3138 | 3303 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3139 | 3304 | |
3140 | 3305 | // Fix the PHP code stuff... |
3141 | - if (!isBrowser('gecko')) |
|
3142 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3143 | - else |
|
3144 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3306 | + if (!isBrowser('gecko')) { |
|
3307 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3308 | + } else { |
|
3309 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3310 | + } |
|
3145 | 3311 | |
3146 | 3312 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3147 | 3313 | $j = -1; |
@@ -3149,8 +3315,9 @@ discard block |
||
3149 | 3315 | { |
3150 | 3316 | $j++; |
3151 | 3317 | |
3152 | - if (substr_count($line, '<br>') == 0) |
|
3153 | - continue; |
|
3318 | + if (substr_count($line, '<br>') == 0) { |
|
3319 | + continue; |
|
3320 | + } |
|
3154 | 3321 | |
3155 | 3322 | $n = substr_count($line, '<br>'); |
3156 | 3323 | for ($i = 0; $i < $n; $i++) |
@@ -3169,38 +3336,42 @@ discard block |
||
3169 | 3336 | // Figure out what the color coding was before... |
3170 | 3337 | $line = max($match[1] - 9, 1); |
3171 | 3338 | $last_line = ''; |
3172 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3173 | - if (strpos($data2[$line2], '<') !== false) |
|
3339 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3340 | + if (strpos($data2[$line2], '<') !== false) |
|
3174 | 3341 | { |
3175 | 3342 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3176 | 3343 | $last_line = $color_match[1]; |
3344 | + } |
|
3177 | 3345 | break; |
3178 | 3346 | } |
3179 | 3347 | |
3180 | 3348 | // Show the relevant lines... |
3181 | 3349 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3182 | 3350 | { |
3183 | - if ($line == $match[1]) |
|
3184 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3351 | + if ($line == $match[1]) { |
|
3352 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3353 | + } |
|
3185 | 3354 | |
3186 | 3355 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3187 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3188 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3356 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3357 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3358 | + } |
|
3189 | 3359 | |
3190 | 3360 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3191 | 3361 | { |
3192 | 3362 | $last_line = $color_match[1]; |
3193 | 3363 | echo '</', substr($last_line, 1, 4), '>'; |
3364 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3365 | + $last_line = ''; |
|
3366 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3367 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3194 | 3368 | } |
3195 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3196 | - $last_line = ''; |
|
3197 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3198 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3199 | 3369 | |
3200 | - if ($line == $match[1]) |
|
3201 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3202 | - else |
|
3203 | - echo "\n"; |
|
3370 | + if ($line == $match[1]) { |
|
3371 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3372 | + } else { |
|
3373 | + echo "\n"; |
|
3374 | + } |
|
3204 | 3375 | } |
3205 | 3376 | |
3206 | 3377 | echo '</pre></div>'; |
@@ -3224,8 +3395,9 @@ discard block |
||
3224 | 3395 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3225 | 3396 | |
3226 | 3397 | // Figure out what type of database we are using. |
3227 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3228 | - $db_type = 'mysql'; |
|
3398 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3399 | + $db_type = 'mysql'; |
|
3400 | + } |
|
3229 | 3401 | |
3230 | 3402 | // Load the file for the database. |
3231 | 3403 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3233,8 +3405,9 @@ discard block |
||
3233 | 3405 | $db_options = array(); |
3234 | 3406 | |
3235 | 3407 | // Add in the port if needed |
3236 | - if (!empty($db_port)) |
|
3237 | - $db_options['port'] = $db_port; |
|
3408 | + if (!empty($db_port)) { |
|
3409 | + $db_options['port'] = $db_port; |
|
3410 | + } |
|
3238 | 3411 | |
3239 | 3412 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3240 | 3413 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3253,13 +3426,15 @@ discard block |
||
3253 | 3426 | } |
3254 | 3427 | |
3255 | 3428 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3256 | - if (!$db_connection) |
|
3257 | - display_db_error(); |
|
3429 | + if (!$db_connection) { |
|
3430 | + display_db_error(); |
|
3431 | + } |
|
3258 | 3432 | |
3259 | 3433 | // If in SSI mode fix up the prefix. |
3260 | - if (SMF == 'SSI') |
|
3261 | - db_fix_prefix($db_prefix, $db_name); |
|
3262 | -} |
|
3434 | + if (SMF == 'SSI') { |
|
3435 | + db_fix_prefix($db_prefix, $db_name); |
|
3436 | + } |
|
3437 | + } |
|
3263 | 3438 | |
3264 | 3439 | /** |
3265 | 3440 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3273,10 +3448,11 @@ discard block |
||
3273 | 3448 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3274 | 3449 | |
3275 | 3450 | // Not overriding this and we have a cacheAPI, send it back. |
3276 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3277 | - return $cacheAPI; |
|
3278 | - elseif (is_null($cacheAPI)) |
|
3279 | - $cacheAPI = false; |
|
3451 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3452 | + return $cacheAPI; |
|
3453 | + } elseif (is_null($cacheAPI)) { |
|
3454 | + $cacheAPI = false; |
|
3455 | + } |
|
3280 | 3456 | |
3281 | 3457 | // Make sure our class is in session. |
3282 | 3458 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3297,8 +3473,9 @@ discard block |
||
3297 | 3473 | if (!$testAPI->isSupported()) |
3298 | 3474 | { |
3299 | 3475 | // Can we save ourselves? |
3300 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3301 | - return loadCacheAccelerator(null, false); |
|
3476 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3477 | + return loadCacheAccelerator(null, false); |
|
3478 | + } |
|
3302 | 3479 | return false; |
3303 | 3480 | } |
3304 | 3481 | |
@@ -3310,9 +3487,9 @@ discard block |
||
3310 | 3487 | { |
3311 | 3488 | $cacheAPI = $testAPI; |
3312 | 3489 | return $cacheAPI; |
3490 | + } else { |
|
3491 | + return $testAPI; |
|
3313 | 3492 | } |
3314 | - else |
|
3315 | - return $testAPI; |
|
3316 | 3493 | } |
3317 | 3494 | } |
3318 | 3495 | |
@@ -3332,8 +3509,9 @@ discard block |
||
3332 | 3509 | |
3333 | 3510 | // @todo Why are we doing this if caching is disabled? |
3334 | 3511 | |
3335 | - if (function_exists('call_integration_hook')) |
|
3336 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3512 | + if (function_exists('call_integration_hook')) { |
|
3513 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3514 | + } |
|
3337 | 3515 | |
3338 | 3516 | /* Refresh the cache if either: |
3339 | 3517 | 1. Caching is disabled. |
@@ -3347,16 +3525,19 @@ discard block |
||
3347 | 3525 | require_once($sourcedir . '/' . $file); |
3348 | 3526 | $cache_block = call_user_func_array($function, $params); |
3349 | 3527 | |
3350 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3351 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3528 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3529 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3530 | + } |
|
3352 | 3531 | } |
3353 | 3532 | |
3354 | 3533 | // Some cached data may need a freshening up after retrieval. |
3355 | - if (!empty($cache_block['post_retri_eval'])) |
|
3356 | - eval($cache_block['post_retri_eval']); |
|
3534 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3535 | + eval($cache_block['post_retri_eval']); |
|
3536 | + } |
|
3357 | 3537 | |
3358 | - if (function_exists('call_integration_hook')) |
|
3359 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3538 | + if (function_exists('call_integration_hook')) { |
|
3539 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3540 | + } |
|
3360 | 3541 | |
3361 | 3542 | return $cache_block['data']; |
3362 | 3543 | } |
@@ -3383,8 +3564,9 @@ discard block |
||
3383 | 3564 | global $smcFunc, $cache_enable, $cacheAPI; |
3384 | 3565 | global $cache_hits, $cache_count, $db_show_debug; |
3385 | 3566 | |
3386 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3387 | - return; |
|
3567 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3568 | + return; |
|
3569 | + } |
|
3388 | 3570 | |
3389 | 3571 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3390 | 3572 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3397,12 +3579,14 @@ discard block |
||
3397 | 3579 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3398 | 3580 | $cacheAPI->putData($key, $value, $ttl); |
3399 | 3581 | |
3400 | - if (function_exists('call_integration_hook')) |
|
3401 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3582 | + if (function_exists('call_integration_hook')) { |
|
3583 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3584 | + } |
|
3402 | 3585 | |
3403 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3404 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3405 | -} |
|
3586 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3587 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3588 | + } |
|
3589 | + } |
|
3406 | 3590 | |
3407 | 3591 | /** |
3408 | 3592 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3418,8 +3602,9 @@ discard block |
||
3418 | 3602 | global $smcFunc, $cache_enable, $cacheAPI; |
3419 | 3603 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3420 | 3604 | |
3421 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3422 | - return; |
|
3605 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3606 | + return; |
|
3607 | + } |
|
3423 | 3608 | |
3424 | 3609 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3425 | 3610 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3439,16 +3624,18 @@ discard block |
||
3439 | 3624 | |
3440 | 3625 | if (empty($value)) |
3441 | 3626 | { |
3442 | - if (!is_array($cache_misses)) |
|
3443 | - $cache_misses = array(); |
|
3627 | + if (!is_array($cache_misses)) { |
|
3628 | + $cache_misses = array(); |
|
3629 | + } |
|
3444 | 3630 | |
3445 | 3631 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3446 | 3632 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3447 | 3633 | } |
3448 | 3634 | } |
3449 | 3635 | |
3450 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3451 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3636 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3637 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3638 | + } |
|
3452 | 3639 | |
3453 | 3640 | return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3454 | 3641 | } |
@@ -3470,8 +3657,9 @@ discard block |
||
3470 | 3657 | global $cacheAPI; |
3471 | 3658 | |
3472 | 3659 | // If we can't get to the API, can't do this. |
3473 | - if (empty($cacheAPI)) |
|
3474 | - return; |
|
3660 | + if (empty($cacheAPI)) { |
|
3661 | + return; |
|
3662 | + } |
|
3475 | 3663 | |
3476 | 3664 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3477 | 3665 | $cacheAPI->cleanCache($type); |
@@ -3496,8 +3684,9 @@ discard block |
||
3496 | 3684 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $user_info; |
3497 | 3685 | |
3498 | 3686 | // Come on! |
3499 | - if (empty($data)) |
|
3500 | - return array(); |
|
3687 | + if (empty($data)) { |
|
3688 | + return array(); |
|
3689 | + } |
|
3501 | 3690 | |
3502 | 3691 | // Set a nice default var. |
3503 | 3692 | $image = ''; |
@@ -3505,11 +3694,11 @@ discard block |
||
3505 | 3694 | // Gravatar has been set as mandatory! |
3506 | 3695 | if (!empty($modSettings['gravatarOverride'])) |
3507 | 3696 | { |
3508 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3509 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3510 | - |
|
3511 | - else if (!empty($data['email'])) |
|
3512 | - $image = get_gravatar_url($data['email']); |
|
3697 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3698 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3699 | + } else if (!empty($data['email'])) { |
|
3700 | + $image = get_gravatar_url($data['email']); |
|
3701 | + } |
|
3513 | 3702 | } |
3514 | 3703 | |
3515 | 3704 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3521,54 +3710,60 @@ discard block |
||
3521 | 3710 | // Gravatar. |
3522 | 3711 | if (stristr($data['avatar'], 'gravatar://')) |
3523 | 3712 | { |
3524 | - if ($data['avatar'] == 'gravatar://') |
|
3525 | - $image = get_gravatar_url($data['email']); |
|
3526 | - |
|
3527 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3528 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3713 | + if ($data['avatar'] == 'gravatar://') { |
|
3714 | + $image = get_gravatar_url($data['email']); |
|
3715 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3716 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3717 | + } |
|
3529 | 3718 | } |
3530 | 3719 | |
3531 | 3720 | // External url. |
3532 | 3721 | else |
3533 | 3722 | { |
3534 | 3723 | // Using ssl? |
3535 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
3536 | - $image = get_proxied_url($data['avatar']); |
|
3724 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
3725 | + $image = get_proxied_url($data['avatar']); |
|
3726 | + } |
|
3537 | 3727 | |
3538 | 3728 | // Just a plain external url. |
3539 | - else |
|
3540 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3729 | + else { |
|
3730 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3731 | + } |
|
3541 | 3732 | } |
3542 | 3733 | } |
3543 | 3734 | |
3544 | 3735 | // Perhaps this user has an attachment as avatar... |
3545 | - else if (!empty($data['filename'])) |
|
3546 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3736 | + else if (!empty($data['filename'])) { |
|
3737 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3738 | + } |
|
3547 | 3739 | |
3548 | 3740 | // Right... no avatar... use our default image. |
3549 | - else |
|
3550 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3741 | + else { |
|
3742 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3743 | + } |
|
3551 | 3744 | } |
3552 | 3745 | |
3553 | 3746 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3554 | 3747 | |
3555 | 3748 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3556 | - if (!empty($image)) |
|
3557 | - return array( |
|
3749 | + if (!empty($image)) { |
|
3750 | + return array( |
|
3558 | 3751 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3559 | 3752 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3560 | 3753 | 'href' => $image, |
3561 | 3754 | 'url' => $image, |
3562 | 3755 | ); |
3756 | + } |
|
3563 | 3757 | |
3564 | 3758 | // Fallback to make life easier for everyone... |
3565 | - else |
|
3566 | - return array( |
|
3759 | + else { |
|
3760 | + return array( |
|
3567 | 3761 | 'name' => '', |
3568 | 3762 | 'image' => '', |
3569 | 3763 | 'href' => '', |
3570 | 3764 | 'url' => '', |
3571 | 3765 | ); |
3572 | -} |
|
3766 | + } |
|
3767 | + } |
|
3573 | 3768 | |
3574 | 3769 | ?> |
3575 | 3770 | \ No newline at end of file |