@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,26 +83,30 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | /** |
103 | 112 | * An autoloader for certain classes. |
@@ -146,9 +155,9 @@ discard block |
||
146 | 155 | ob_start('ob_sessrewrite'); |
147 | 156 | |
148 | 157 | // Start the session... known to scramble SSI includes in cases... |
149 | -if (!headers_sent()) |
|
158 | +if (!headers_sent()) { |
|
150 | 159 | loadSession(); |
151 | -else |
|
160 | +} else |
|
152 | 161 | { |
153 | 162 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
154 | 163 | { |
@@ -182,12 +191,14 @@ discard block |
||
182 | 191 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
183 | 192 | |
184 | 193 | // @todo: probably not the best place, but somewhere it should be set... |
185 | -if (!headers_sent()) |
|
194 | +if (!headers_sent()) { |
|
186 | 195 | header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
196 | +} |
|
187 | 197 | |
188 | 198 | // Take care of any banning that needs to be done. |
189 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
199 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
190 | 200 | is_not_banned(); |
201 | +} |
|
191 | 202 | |
192 | 203 | // Do we allow guests in here? |
193 | 204 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -202,17 +213,19 @@ discard block |
||
202 | 213 | { |
203 | 214 | $context['template_layers'] = $ssi_layers; |
204 | 215 | template_header(); |
205 | -} |
|
206 | -else |
|
216 | +} else { |
|
207 | 217 | setupThemeContext(); |
218 | +} |
|
208 | 219 | |
209 | 220 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
210 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
221 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
211 | 222 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
223 | +} |
|
212 | 224 | |
213 | 225 | // Without visiting the forum this session variable might not be set on submit. |
214 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
226 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
215 | 227 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
228 | +} |
|
216 | 229 | |
217 | 230 | // Have the ability to easily add functions to SSI. |
218 | 231 | call_integration_hook('integrate_SSI'); |
@@ -221,11 +234,13 @@ discard block |
||
221 | 234 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
222 | 235 | { |
223 | 236 | // You shouldn't just access SSI.php directly by URL!! |
224 | - if (!isset($_GET['ssi_function'])) |
|
225 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
237 | + if (!isset($_GET['ssi_function'])) { |
|
238 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
239 | + } |
|
226 | 240 | // Call a function passed by GET. |
227 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
228 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
241 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
242 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
243 | + } |
|
229 | 244 | exit; |
230 | 245 | } |
231 | 246 | |
@@ -242,9 +257,10 @@ discard block |
||
242 | 257 | */ |
243 | 258 | function ssi_shutdown() |
244 | 259 | { |
245 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
246 | - template_footer(); |
|
247 | -} |
|
260 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
261 | + template_footer(); |
|
262 | + } |
|
263 | + } |
|
248 | 264 | |
249 | 265 | /** |
250 | 266 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -257,15 +273,17 @@ discard block |
||
257 | 273 | |
258 | 274 | if ($output_method == 'echo') |
259 | 275 | { |
260 | - if ($context['user']['is_guest']) |
|
261 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
262 | - else |
|
263 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
276 | + if ($context['user']['is_guest']) { |
|
277 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
278 | + } else { |
|
279 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
280 | + } |
|
264 | 281 | } |
265 | 282 | // Don't echo... then do what?! |
266 | - else |
|
267 | - return $context['user']; |
|
268 | -} |
|
283 | + else { |
|
284 | + return $context['user']; |
|
285 | + } |
|
286 | + } |
|
269 | 287 | |
270 | 288 | /** |
271 | 289 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -276,12 +294,14 @@ discard block |
||
276 | 294 | { |
277 | 295 | global $context; |
278 | 296 | |
279 | - if ($output_method == 'echo') |
|
280 | - template_menu(); |
|
297 | + if ($output_method == 'echo') { |
|
298 | + template_menu(); |
|
299 | + } |
|
281 | 300 | // What else could this do? |
282 | - else |
|
283 | - return $context['menu_buttons']; |
|
284 | -} |
|
301 | + else { |
|
302 | + return $context['menu_buttons']; |
|
303 | + } |
|
304 | + } |
|
285 | 305 | |
286 | 306 | /** |
287 | 307 | * Show a logout link. |
@@ -293,20 +313,23 @@ discard block |
||
293 | 313 | { |
294 | 314 | global $context, $txt, $scripturl; |
295 | 315 | |
296 | - if ($redirect_to != '') |
|
297 | - $_SESSION['logout_url'] = $redirect_to; |
|
316 | + if ($redirect_to != '') { |
|
317 | + $_SESSION['logout_url'] = $redirect_to; |
|
318 | + } |
|
298 | 319 | |
299 | 320 | // Guests can't log out. |
300 | - if ($context['user']['is_guest']) |
|
301 | - return false; |
|
321 | + if ($context['user']['is_guest']) { |
|
322 | + return false; |
|
323 | + } |
|
302 | 324 | |
303 | 325 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
304 | 326 | |
305 | - if ($output_method == 'echo') |
|
306 | - echo $link; |
|
307 | - else |
|
308 | - return $link; |
|
309 | -} |
|
327 | + if ($output_method == 'echo') { |
|
328 | + echo $link; |
|
329 | + } else { |
|
330 | + return $link; |
|
331 | + } |
|
332 | + } |
|
310 | 333 | |
311 | 334 | /** |
312 | 335 | * Recent post list: [board] Subject by Poster Date |
@@ -322,17 +345,17 @@ discard block |
||
322 | 345 | global $modSettings, $context; |
323 | 346 | |
324 | 347 | // Excluding certain boards... |
325 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
326 | - $exclude_boards = array($modSettings['recycle_board']); |
|
327 | - else |
|
328 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
348 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
349 | + $exclude_boards = array($modSettings['recycle_board']); |
|
350 | + } else { |
|
351 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
352 | + } |
|
329 | 353 | |
330 | 354 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
331 | 355 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
332 | 356 | { |
333 | 357 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
334 | - } |
|
335 | - elseif ($include_boards != null) |
|
358 | + } elseif ($include_boards != null) |
|
336 | 359 | { |
337 | 360 | $include_boards = array(); |
338 | 361 | } |
@@ -369,8 +392,9 @@ discard block |
||
369 | 392 | { |
370 | 393 | global $modSettings; |
371 | 394 | |
372 | - if (empty($post_ids)) |
|
373 | - return; |
|
395 | + if (empty($post_ids)) { |
|
396 | + return; |
|
397 | + } |
|
374 | 398 | |
375 | 399 | // Allow the user to request more than one - why not? |
376 | 400 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -405,8 +429,9 @@ discard block |
||
405 | 429 | global $scripturl, $txt, $user_info; |
406 | 430 | global $modSettings, $smcFunc, $context; |
407 | 431 | |
408 | - if (!empty($modSettings['enable_likes'])) |
|
409 | - $context['can_like'] = allowedTo('likes_like'); |
|
432 | + if (!empty($modSettings['enable_likes'])) { |
|
433 | + $context['can_like'] = allowedTo('likes_like'); |
|
434 | + } |
|
410 | 435 | |
411 | 436 | // Find all the posts. Newer ones will have higher IDs. |
412 | 437 | $request = $smcFunc['db_query']('substring', ' |
@@ -472,12 +497,13 @@ discard block |
||
472 | 497 | ); |
473 | 498 | |
474 | 499 | // Get the likes for each message. |
475 | - if (!empty($modSettings['enable_likes'])) |
|
476 | - $posts[$row['id_msg']]['likes'] = array( |
|
500 | + if (!empty($modSettings['enable_likes'])) { |
|
501 | + $posts[$row['id_msg']]['likes'] = array( |
|
477 | 502 | 'count' => $row['likes'], |
478 | 503 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
479 | 504 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
480 | 505 | ); |
506 | + } |
|
481 | 507 | } |
482 | 508 | $smcFunc['db_free_result']($request); |
483 | 509 | |
@@ -485,13 +511,14 @@ discard block |
||
485 | 511 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
486 | 512 | |
487 | 513 | // Just return it. |
488 | - if ($output_method != 'echo' || empty($posts)) |
|
489 | - return $posts; |
|
514 | + if ($output_method != 'echo' || empty($posts)) { |
|
515 | + return $posts; |
|
516 | + } |
|
490 | 517 | |
491 | 518 | echo ' |
492 | 519 | <table style="border: none" class="ssi_table">'; |
493 | - foreach ($posts as $post) |
|
494 | - echo ' |
|
520 | + foreach ($posts as $post) { |
|
521 | + echo ' |
|
495 | 522 | <tr> |
496 | 523 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
497 | 524 | [', $post['board']['link'], '] |
@@ -505,6 +532,7 @@ discard block |
||
505 | 532 | ', $post['time'], ' |
506 | 533 | </td> |
507 | 534 | </tr>'; |
535 | + } |
|
508 | 536 | echo ' |
509 | 537 | </table>'; |
510 | 538 | } |
@@ -522,25 +550,26 @@ discard block |
||
522 | 550 | global $settings, $scripturl, $txt, $user_info; |
523 | 551 | global $modSettings, $smcFunc, $context; |
524 | 552 | |
525 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
526 | - $exclude_boards = array($modSettings['recycle_board']); |
|
527 | - else |
|
528 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
553 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
554 | + $exclude_boards = array($modSettings['recycle_board']); |
|
555 | + } else { |
|
556 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
557 | + } |
|
529 | 558 | |
530 | 559 | // Only some boards?. |
531 | 560 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
532 | 561 | { |
533 | 562 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
534 | - } |
|
535 | - elseif ($include_boards != null) |
|
563 | + } elseif ($include_boards != null) |
|
536 | 564 | { |
537 | 565 | $output_method = $include_boards; |
538 | 566 | $include_boards = array(); |
539 | 567 | } |
540 | 568 | |
541 | 569 | $icon_sources = array(); |
542 | - foreach ($context['stable_icons'] as $icon) |
|
543 | - $icon_sources[$icon] = 'images_url'; |
|
570 | + foreach ($context['stable_icons'] as $icon) { |
|
571 | + $icon_sources[$icon] = 'images_url'; |
|
572 | + } |
|
544 | 573 | |
545 | 574 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
546 | 575 | $request = $smcFunc['db_query']('substring', ' |
@@ -565,13 +594,15 @@ discard block |
||
565 | 594 | ) |
566 | 595 | ); |
567 | 596 | $topics = array(); |
568 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
569 | - $topics[$row['id_topic']] = $row; |
|
597 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
598 | + $topics[$row['id_topic']] = $row; |
|
599 | + } |
|
570 | 600 | $smcFunc['db_free_result']($request); |
571 | 601 | |
572 | 602 | // Did we find anything? If not, bail. |
573 | - if (empty($topics)) |
|
574 | - return array(); |
|
603 | + if (empty($topics)) { |
|
604 | + return array(); |
|
605 | + } |
|
575 | 606 | |
576 | 607 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
577 | 608 | |
@@ -599,21 +630,24 @@ discard block |
||
599 | 630 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
600 | 631 | { |
601 | 632 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
602 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
603 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
633 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
634 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
635 | + } |
|
604 | 636 | |
605 | 637 | // Censor the subject. |
606 | 638 | censorText($row['subject']); |
607 | 639 | censorText($row['body']); |
608 | 640 | |
609 | 641 | // Recycled icon |
610 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
611 | - $row['icon'] = 'recycled'; |
|
642 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
643 | + $row['icon'] = 'recycled'; |
|
644 | + } |
|
612 | 645 | |
613 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
614 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
615 | - elseif (!isset($icon_sources[$row['icon']])) |
|
616 | - $icon_sources[$row['icon']] = 'images_url'; |
|
646 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
647 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
648 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
649 | + $icon_sources[$row['icon']] = 'images_url'; |
|
650 | + } |
|
617 | 651 | |
618 | 652 | // Build the array. |
619 | 653 | $posts[] = array( |
@@ -652,13 +686,14 @@ discard block |
||
652 | 686 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
653 | 687 | |
654 | 688 | // Just return it. |
655 | - if ($output_method != 'echo' || empty($posts)) |
|
656 | - return $posts; |
|
689 | + if ($output_method != 'echo' || empty($posts)) { |
|
690 | + return $posts; |
|
691 | + } |
|
657 | 692 | |
658 | 693 | echo ' |
659 | 694 | <table style="border: none" class="ssi_table">'; |
660 | - foreach ($posts as $post) |
|
661 | - echo ' |
|
695 | + foreach ($posts as $post) { |
|
696 | + echo ' |
|
662 | 697 | <tr> |
663 | 698 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
664 | 699 | [', $post['board']['link'], '] |
@@ -672,6 +707,7 @@ discard block |
||
672 | 707 | ', $post['time'], ' |
673 | 708 | </td> |
674 | 709 | </tr>'; |
710 | + } |
|
675 | 711 | echo ' |
676 | 712 | </table>'; |
677 | 713 | } |
@@ -696,27 +732,30 @@ discard block |
||
696 | 732 | ) |
697 | 733 | ); |
698 | 734 | $return = array(); |
699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
700 | - $return[] = array( |
|
735 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
736 | + $return[] = array( |
|
701 | 737 | 'id' => $row['id_member'], |
702 | 738 | 'name' => $row['real_name'], |
703 | 739 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
704 | 740 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
705 | 741 | 'posts' => $row['posts'] |
706 | 742 | ); |
743 | + } |
|
707 | 744 | $smcFunc['db_free_result']($request); |
708 | 745 | |
709 | 746 | // If mods want to do somthing with this list of members, let them do that now. |
710 | 747 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
711 | 748 | |
712 | 749 | // Just return all the top posters. |
713 | - if ($output_method != 'echo') |
|
714 | - return $return; |
|
750 | + if ($output_method != 'echo') { |
|
751 | + return $return; |
|
752 | + } |
|
715 | 753 | |
716 | 754 | // Make a quick array to list the links in. |
717 | 755 | $temp_array = array(); |
718 | - foreach ($return as $member) |
|
719 | - $temp_array[] = $member['link']; |
|
756 | + foreach ($return as $member) { |
|
757 | + $temp_array[] = $member['link']; |
|
758 | + } |
|
720 | 759 | |
721 | 760 | echo implode(', ', $temp_array); |
722 | 761 | } |
@@ -748,8 +787,8 @@ discard block |
||
748 | 787 | ) |
749 | 788 | ); |
750 | 789 | $boards = array(); |
751 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
752 | - $boards[] = array( |
|
790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
791 | + $boards[] = array( |
|
753 | 792 | 'id' => $row['id_board'], |
754 | 793 | 'num_posts' => $row['num_posts'], |
755 | 794 | 'num_topics' => $row['num_topics'], |
@@ -758,14 +797,16 @@ discard block |
||
758 | 797 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
759 | 798 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
760 | 799 | ); |
800 | + } |
|
761 | 801 | $smcFunc['db_free_result']($request); |
762 | 802 | |
763 | 803 | // If mods want to do somthing with this list of boards, let them do that now. |
764 | 804 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
765 | 805 | |
766 | 806 | // If we shouldn't output or have nothing to output, just jump out. |
767 | - if ($output_method != 'echo' || empty($boards)) |
|
768 | - return $boards; |
|
807 | + if ($output_method != 'echo' || empty($boards)) { |
|
808 | + return $boards; |
|
809 | + } |
|
769 | 810 | |
770 | 811 | echo ' |
771 | 812 | <table class="ssi_table"> |
@@ -774,13 +815,14 @@ discard block |
||
774 | 815 | <th style="text-align: left">', $txt['board_topics'], '</th> |
775 | 816 | <th style="text-align: left">', $txt['posts'], '</th> |
776 | 817 | </tr>'; |
777 | - foreach ($boards as $sBoard) |
|
778 | - echo ' |
|
818 | + foreach ($boards as $sBoard) { |
|
819 | + echo ' |
|
779 | 820 | <tr> |
780 | 821 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '" class="new_posts">' . $txt['new'] . '</a>' : '', '</td> |
781 | 822 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
782 | 823 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
783 | 824 | </tr>'; |
825 | + } |
|
784 | 826 | echo ' |
785 | 827 | </table>'; |
786 | 828 | } |
@@ -813,12 +855,13 @@ discard block |
||
813 | 855 | ) |
814 | 856 | ); |
815 | 857 | $topic_ids = array(); |
816 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
817 | - $topic_ids[] = $row['id_topic']; |
|
858 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
859 | + $topic_ids[] = $row['id_topic']; |
|
860 | + } |
|
818 | 861 | $smcFunc['db_free_result']($request); |
862 | + } else { |
|
863 | + $topic_ids = array(); |
|
819 | 864 | } |
820 | - else |
|
821 | - $topic_ids = array(); |
|
822 | 865 | |
823 | 866 | $request = $smcFunc['db_query']('', ' |
824 | 867 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -857,8 +900,9 @@ discard block |
||
857 | 900 | // If mods want to do somthing with this list of topics, let them do that now. |
858 | 901 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
859 | 902 | |
860 | - if ($output_method != 'echo' || empty($topics)) |
|
861 | - return $topics; |
|
903 | + if ($output_method != 'echo' || empty($topics)) { |
|
904 | + return $topics; |
|
905 | + } |
|
862 | 906 | |
863 | 907 | echo ' |
864 | 908 | <table class="ssi_table"> |
@@ -867,8 +911,8 @@ discard block |
||
867 | 911 | <th style="text-align: left">', $txt['views'], '</th> |
868 | 912 | <th style="text-align: left">', $txt['replies'], '</th> |
869 | 913 | </tr>'; |
870 | - foreach ($topics as $sTopic) |
|
871 | - echo ' |
|
914 | + foreach ($topics as $sTopic) { |
|
915 | + echo ' |
|
872 | 916 | <tr> |
873 | 917 | <td style="text-align: left"> |
874 | 918 | ', $sTopic['link'], ' |
@@ -876,6 +920,7 @@ discard block |
||
876 | 920 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
877 | 921 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
878 | 922 | </tr>'; |
923 | + } |
|
879 | 924 | echo ' |
880 | 925 | </table>'; |
881 | 926 | } |
@@ -911,12 +956,13 @@ discard block |
||
911 | 956 | { |
912 | 957 | global $txt, $context; |
913 | 958 | |
914 | - if ($output_method == 'echo') |
|
915 | - echo ' |
|
959 | + if ($output_method == 'echo') { |
|
960 | + echo ' |
|
916 | 961 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
917 | - else |
|
918 | - return $context['common_stats']['latest_member']; |
|
919 | -} |
|
962 | + } else { |
|
963 | + return $context['common_stats']['latest_member']; |
|
964 | + } |
|
965 | + } |
|
920 | 966 | |
921 | 967 | /** |
922 | 968 | * Fetches a random member. |
@@ -965,8 +1011,9 @@ discard block |
||
965 | 1011 | } |
966 | 1012 | |
967 | 1013 | // Just to be sure put the random generator back to something... random. |
968 | - if ($random_type != '') |
|
969 | - mt_srand(time()); |
|
1014 | + if ($random_type != '') { |
|
1015 | + mt_srand(time()); |
|
1016 | + } |
|
970 | 1017 | |
971 | 1018 | return $result; |
972 | 1019 | } |
@@ -979,8 +1026,9 @@ discard block |
||
979 | 1026 | */ |
980 | 1027 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
981 | 1028 | { |
982 | - if (empty($member_ids)) |
|
983 | - return; |
|
1029 | + if (empty($member_ids)) { |
|
1030 | + return; |
|
1031 | + } |
|
984 | 1032 | |
985 | 1033 | // Can have more than one member if you really want... |
986 | 1034 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -1005,8 +1053,9 @@ discard block |
||
1005 | 1053 | */ |
1006 | 1054 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
1007 | 1055 | { |
1008 | - if ($group_id === null) |
|
1009 | - return; |
|
1056 | + if ($group_id === null) { |
|
1057 | + return; |
|
1058 | + } |
|
1010 | 1059 | |
1011 | 1060 | $query_where = ' |
1012 | 1061 | id_group = {int:id_group} |
@@ -1033,8 +1082,9 @@ discard block |
||
1033 | 1082 | { |
1034 | 1083 | global $smcFunc, $memberContext; |
1035 | 1084 | |
1036 | - if ($query_where === null) |
|
1037 | - return; |
|
1085 | + if ($query_where === null) { |
|
1086 | + return; |
|
1087 | + } |
|
1038 | 1088 | |
1039 | 1089 | // Fetch the members in question. |
1040 | 1090 | $request = $smcFunc['db_query']('', ' |
@@ -1047,12 +1097,14 @@ discard block |
||
1047 | 1097 | )) |
1048 | 1098 | ); |
1049 | 1099 | $members = array(); |
1050 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1051 | - $members[] = $row['id_member']; |
|
1100 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1101 | + $members[] = $row['id_member']; |
|
1102 | + } |
|
1052 | 1103 | $smcFunc['db_free_result']($request); |
1053 | 1104 | |
1054 | - if (empty($members)) |
|
1055 | - return array(); |
|
1105 | + if (empty($members)) { |
|
1106 | + return array(); |
|
1107 | + } |
|
1056 | 1108 | |
1057 | 1109 | // If mods want to do somthing with this list of members, let them do that now. |
1058 | 1110 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1061,23 +1113,25 @@ discard block |
||
1061 | 1113 | loadMemberData($members); |
1062 | 1114 | |
1063 | 1115 | // Draw the table! |
1064 | - if ($output_method == 'echo') |
|
1065 | - echo ' |
|
1116 | + if ($output_method == 'echo') { |
|
1117 | + echo ' |
|
1066 | 1118 | <table style="border: none" class="ssi_table">'; |
1119 | + } |
|
1067 | 1120 | |
1068 | 1121 | $query_members = array(); |
1069 | 1122 | foreach ($members as $member) |
1070 | 1123 | { |
1071 | 1124 | // Load their context data. |
1072 | - if (!loadMemberContext($member)) |
|
1073 | - continue; |
|
1125 | + if (!loadMemberContext($member)) { |
|
1126 | + continue; |
|
1127 | + } |
|
1074 | 1128 | |
1075 | 1129 | // Store this member's information. |
1076 | 1130 | $query_members[$member] = $memberContext[$member]; |
1077 | 1131 | |
1078 | 1132 | // Only do something if we're echo'ing. |
1079 | - if ($output_method == 'echo') |
|
1080 | - echo ' |
|
1133 | + if ($output_method == 'echo') { |
|
1134 | + echo ' |
|
1081 | 1135 | <tr> |
1082 | 1136 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1083 | 1137 | ', $query_members[$member]['link'], ' |
@@ -1085,12 +1139,14 @@ discard block |
||
1085 | 1139 | <br>', $query_members[$member]['avatar']['image'], ' |
1086 | 1140 | </td> |
1087 | 1141 | </tr>'; |
1142 | + } |
|
1088 | 1143 | } |
1089 | 1144 | |
1090 | 1145 | // End the table if appropriate. |
1091 | - if ($output_method == 'echo') |
|
1092 | - echo ' |
|
1146 | + if ($output_method == 'echo') { |
|
1147 | + echo ' |
|
1093 | 1148 | </table>'; |
1149 | + } |
|
1094 | 1150 | |
1095 | 1151 | // Send back the data. |
1096 | 1152 | return $query_members; |
@@ -1105,8 +1161,9 @@ discard block |
||
1105 | 1161 | { |
1106 | 1162 | global $txt, $scripturl, $modSettings, $smcFunc; |
1107 | 1163 | |
1108 | - if (!allowedTo('view_stats')) |
|
1109 | - return; |
|
1164 | + if (!allowedTo('view_stats')) { |
|
1165 | + return; |
|
1166 | + } |
|
1110 | 1167 | |
1111 | 1168 | $totals = array( |
1112 | 1169 | 'members' => $modSettings['totalMembers'], |
@@ -1135,8 +1192,9 @@ discard block |
||
1135 | 1192 | // If mods want to do somthing with the board stats, let them do that now. |
1136 | 1193 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1137 | 1194 | |
1138 | - if ($output_method != 'echo') |
|
1139 | - return $totals; |
|
1195 | + if ($output_method != 'echo') { |
|
1196 | + return $totals; |
|
1197 | + } |
|
1140 | 1198 | |
1141 | 1199 | echo ' |
1142 | 1200 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1165,8 +1223,8 @@ discard block |
||
1165 | 1223 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1166 | 1224 | |
1167 | 1225 | // Add some redundancy for backwards compatibility reasons. |
1168 | - if ($output_method != 'echo') |
|
1169 | - return $return + array( |
|
1226 | + if ($output_method != 'echo') { |
|
1227 | + return $return + array( |
|
1170 | 1228 | 'users' => $return['users_online'], |
1171 | 1229 | 'guests' => $return['num_guests'], |
1172 | 1230 | 'hidden' => $return['num_users_hidden'], |
@@ -1174,29 +1232,35 @@ discard block |
||
1174 | 1232 | 'num_users' => $return['num_users_online'], |
1175 | 1233 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1176 | 1234 | ); |
1235 | + } |
|
1177 | 1236 | |
1178 | 1237 | echo ' |
1179 | 1238 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1180 | 1239 | |
1181 | 1240 | $bracketList = array(); |
1182 | - if (!empty($user_info['buddies'])) |
|
1183 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1184 | - if (!empty($return['num_spiders'])) |
|
1185 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1186 | - if (!empty($return['num_users_hidden'])) |
|
1187 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1241 | + if (!empty($user_info['buddies'])) { |
|
1242 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1243 | + } |
|
1244 | + if (!empty($return['num_spiders'])) { |
|
1245 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1246 | + } |
|
1247 | + if (!empty($return['num_users_hidden'])) { |
|
1248 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1249 | + } |
|
1188 | 1250 | |
1189 | - if (!empty($bracketList)) |
|
1190 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1251 | + if (!empty($bracketList)) { |
|
1252 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1253 | + } |
|
1191 | 1254 | |
1192 | 1255 | echo '<br> |
1193 | 1256 | ', implode(', ', $return['list_users_online']); |
1194 | 1257 | |
1195 | 1258 | // Showing membergroups? |
1196 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1197 | - echo '<br> |
|
1259 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1260 | + echo '<br> |
|
1198 | 1261 | [' . implode('] [', $return['membergroups']) . ']'; |
1199 | -} |
|
1262 | + } |
|
1263 | + } |
|
1200 | 1264 | |
1201 | 1265 | /** |
1202 | 1266 | * Just like whosOnline except it also logs the online presence. |
@@ -1207,11 +1271,12 @@ discard block |
||
1207 | 1271 | { |
1208 | 1272 | writeLog(); |
1209 | 1273 | |
1210 | - if ($output_method != 'echo') |
|
1211 | - return ssi_whosOnline($output_method); |
|
1212 | - else |
|
1213 | - ssi_whosOnline($output_method); |
|
1214 | -} |
|
1274 | + if ($output_method != 'echo') { |
|
1275 | + return ssi_whosOnline($output_method); |
|
1276 | + } else { |
|
1277 | + ssi_whosOnline($output_method); |
|
1278 | + } |
|
1279 | + } |
|
1215 | 1280 | |
1216 | 1281 | // Shows a login box. |
1217 | 1282 | /** |
@@ -1224,11 +1289,13 @@ discard block |
||
1224 | 1289 | { |
1225 | 1290 | global $scripturl, $txt, $user_info, $context; |
1226 | 1291 | |
1227 | - if ($redirect_to != '') |
|
1228 | - $_SESSION['login_url'] = $redirect_to; |
|
1292 | + if ($redirect_to != '') { |
|
1293 | + $_SESSION['login_url'] = $redirect_to; |
|
1294 | + } |
|
1229 | 1295 | |
1230 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1231 | - return $user_info['is_guest']; |
|
1296 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1297 | + return $user_info['is_guest']; |
|
1298 | + } |
|
1232 | 1299 | |
1233 | 1300 | // Create a login token |
1234 | 1301 | createToken('login'); |
@@ -1280,8 +1347,9 @@ discard block |
||
1280 | 1347 | |
1281 | 1348 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1282 | 1349 | |
1283 | - if (empty($boardsAllowed)) |
|
1284 | - return array(); |
|
1350 | + if (empty($boardsAllowed)) { |
|
1351 | + return array(); |
|
1352 | + } |
|
1285 | 1353 | |
1286 | 1354 | $request = $smcFunc['db_query']('', ' |
1287 | 1355 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1314,12 +1382,14 @@ discard block |
||
1314 | 1382 | $smcFunc['db_free_result']($request); |
1315 | 1383 | |
1316 | 1384 | // This user has voted on all the polls. |
1317 | - if (empty($row) || !is_array($row)) |
|
1318 | - return array(); |
|
1385 | + if (empty($row) || !is_array($row)) { |
|
1386 | + return array(); |
|
1387 | + } |
|
1319 | 1388 | |
1320 | 1389 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1321 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1322 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1390 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1391 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1392 | + } |
|
1323 | 1393 | |
1324 | 1394 | $request = $smcFunc['db_query']('', ' |
1325 | 1395 | SELECT COUNT(DISTINCT id_member) |
@@ -1383,8 +1453,9 @@ discard block |
||
1383 | 1453 | // If mods want to do somthing with this list of polls, let them do that now. |
1384 | 1454 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1385 | 1455 | |
1386 | - if ($output_method != 'echo') |
|
1387 | - return $return; |
|
1456 | + if ($output_method != 'echo') { |
|
1457 | + return $return; |
|
1458 | + } |
|
1388 | 1459 | |
1389 | 1460 | if ($allow_view_results) |
1390 | 1461 | { |
@@ -1393,19 +1464,20 @@ discard block |
||
1393 | 1464 | <strong>', $return['question'], '</strong><br> |
1394 | 1465 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1395 | 1466 | |
1396 | - foreach ($return['options'] as $option) |
|
1397 | - echo ' |
|
1467 | + foreach ($return['options'] as $option) { |
|
1468 | + echo ' |
|
1398 | 1469 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1470 | + } |
|
1399 | 1471 | |
1400 | 1472 | echo ' |
1401 | 1473 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1402 | 1474 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1403 | 1475 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1404 | 1476 | </form>'; |
1477 | + } else { |
|
1478 | + echo $txt['poll_cannot_see']; |
|
1479 | + } |
|
1405 | 1480 | } |
1406 | - else |
|
1407 | - echo $txt['poll_cannot_see']; |
|
1408 | -} |
|
1409 | 1481 | |
1410 | 1482 | /** |
1411 | 1483 | * Shows the poll from the specified topic |
@@ -1419,13 +1491,15 @@ discard block |
||
1419 | 1491 | |
1420 | 1492 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1421 | 1493 | |
1422 | - if (empty($boardsAllowed)) |
|
1423 | - return array(); |
|
1494 | + if (empty($boardsAllowed)) { |
|
1495 | + return array(); |
|
1496 | + } |
|
1424 | 1497 | |
1425 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1426 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1427 | - else |
|
1428 | - $topic = (int) $topic; |
|
1498 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1499 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1500 | + } else { |
|
1501 | + $topic = (int) $topic; |
|
1502 | + } |
|
1429 | 1503 | |
1430 | 1504 | $request = $smcFunc['db_query']('', ' |
1431 | 1505 | SELECT |
@@ -1446,17 +1520,18 @@ discard block |
||
1446 | 1520 | ); |
1447 | 1521 | |
1448 | 1522 | // Either this topic has no poll, or the user cannot view it. |
1449 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1450 | - return array(); |
|
1523 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1524 | + return array(); |
|
1525 | + } |
|
1451 | 1526 | |
1452 | 1527 | $row = $smcFunc['db_fetch_assoc']($request); |
1453 | 1528 | $smcFunc['db_free_result']($request); |
1454 | 1529 | |
1455 | 1530 | // Check if they can vote. |
1456 | 1531 | $already_voted = false; |
1457 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1458 | - $allow_vote = false; |
|
1459 | - elseif ($user_info['is_guest']) |
|
1532 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1533 | + $allow_vote = false; |
|
1534 | + } elseif ($user_info['is_guest']) |
|
1460 | 1535 | { |
1461 | 1536 | // There's a difference between "allowed to vote" and "already voted"... |
1462 | 1537 | $allow_vote = $row['guest_vote']; |
@@ -1466,10 +1541,9 @@ discard block |
||
1466 | 1541 | { |
1467 | 1542 | $already_voted = true; |
1468 | 1543 | } |
1469 | - } |
|
1470 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1471 | - $allow_vote = false; |
|
1472 | - else |
|
1544 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1545 | + $allow_vote = false; |
|
1546 | + } else |
|
1473 | 1547 | { |
1474 | 1548 | $request = $smcFunc['db_query']('', ' |
1475 | 1549 | SELECT id_member |
@@ -1551,8 +1625,9 @@ discard block |
||
1551 | 1625 | // If mods want to do somthing with this poll, let them do that now. |
1552 | 1626 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1553 | 1627 | |
1554 | - if ($output_method != 'echo') |
|
1555 | - return $return; |
|
1628 | + if ($output_method != 'echo') { |
|
1629 | + return $return; |
|
1630 | + } |
|
1556 | 1631 | |
1557 | 1632 | if ($return['allow_vote']) |
1558 | 1633 | { |
@@ -1561,17 +1636,17 @@ discard block |
||
1561 | 1636 | <strong>', $return['question'], '</strong><br> |
1562 | 1637 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1563 | 1638 | |
1564 | - foreach ($return['options'] as $option) |
|
1565 | - echo ' |
|
1639 | + foreach ($return['options'] as $option) { |
|
1640 | + echo ' |
|
1566 | 1641 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1642 | + } |
|
1567 | 1643 | |
1568 | 1644 | echo ' |
1569 | 1645 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1570 | 1646 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1571 | 1647 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1572 | 1648 | </form>'; |
1573 | - } |
|
1574 | - else |
|
1649 | + } else |
|
1575 | 1650 | { |
1576 | 1651 | echo ' |
1577 | 1652 | <div class="ssi_poll"> |
@@ -1651,27 +1726,32 @@ discard block |
||
1651 | 1726 | 'is_approved' => 1, |
1652 | 1727 | ) |
1653 | 1728 | ); |
1654 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1655 | - die; |
|
1729 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1730 | + die; |
|
1731 | + } |
|
1656 | 1732 | $row = $smcFunc['db_fetch_assoc']($request); |
1657 | 1733 | $smcFunc['db_free_result']($request); |
1658 | 1734 | |
1659 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1660 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1735 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1736 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1737 | + } |
|
1661 | 1738 | |
1662 | 1739 | // Too many options checked? |
1663 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1664 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1740 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1741 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1742 | + } |
|
1665 | 1743 | |
1666 | 1744 | // It's a guest who has already voted? |
1667 | 1745 | if ($user_info['is_guest']) |
1668 | 1746 | { |
1669 | 1747 | // Guest voting disabled? |
1670 | - if (!$row['guest_vote']) |
|
1671 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1748 | + if (!$row['guest_vote']) { |
|
1749 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1750 | + } |
|
1672 | 1751 | // Already voted? |
1673 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1674 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1752 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1753 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1754 | + } |
|
1675 | 1755 | } |
1676 | 1756 | |
1677 | 1757 | $sOptions = array(); |
@@ -1725,11 +1805,13 @@ discard block |
||
1725 | 1805 | { |
1726 | 1806 | global $scripturl, $txt, $context; |
1727 | 1807 | |
1728 | - if (!allowedTo('search_posts')) |
|
1729 | - return; |
|
1808 | + if (!allowedTo('search_posts')) { |
|
1809 | + return; |
|
1810 | + } |
|
1730 | 1811 | |
1731 | - if ($output_method != 'echo') |
|
1732 | - return $scripturl . '?action=search'; |
|
1812 | + if ($output_method != 'echo') { |
|
1813 | + return $scripturl . '?action=search'; |
|
1814 | + } |
|
1733 | 1815 | |
1734 | 1816 | echo ' |
1735 | 1817 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1751,8 +1833,9 @@ discard block |
||
1751 | 1833 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1752 | 1834 | call_integration_hook('integrate_ssi_news'); |
1753 | 1835 | |
1754 | - if ($output_method != 'echo') |
|
1755 | - return $context['random_news_line']; |
|
1836 | + if ($output_method != 'echo') { |
|
1837 | + return $context['random_news_line']; |
|
1838 | + } |
|
1756 | 1839 | |
1757 | 1840 | echo $context['random_news_line']; |
1758 | 1841 | } |
@@ -1766,8 +1849,9 @@ discard block |
||
1766 | 1849 | { |
1767 | 1850 | global $scripturl, $modSettings, $user_info; |
1768 | 1851 | |
1769 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1770 | - return; |
|
1852 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1853 | + return; |
|
1854 | + } |
|
1771 | 1855 | |
1772 | 1856 | $eventOptions = array( |
1773 | 1857 | 'include_birthdays' => true, |
@@ -1778,13 +1862,15 @@ discard block |
||
1778 | 1862 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1779 | 1863 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1780 | 1864 | |
1781 | - if ($output_method != 'echo') |
|
1782 | - return $return['calendar_birthdays']; |
|
1865 | + if ($output_method != 'echo') { |
|
1866 | + return $return['calendar_birthdays']; |
|
1867 | + } |
|
1783 | 1868 | |
1784 | - foreach ($return['calendar_birthdays'] as $member) |
|
1785 | - echo ' |
|
1869 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1870 | + echo ' |
|
1786 | 1871 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
1787 | -} |
|
1872 | + } |
|
1873 | + } |
|
1788 | 1874 | |
1789 | 1875 | /** |
1790 | 1876 | * Shows today's holidays. |
@@ -1795,8 +1881,9 @@ discard block |
||
1795 | 1881 | { |
1796 | 1882 | global $modSettings, $user_info; |
1797 | 1883 | |
1798 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1799 | - return; |
|
1884 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1885 | + return; |
|
1886 | + } |
|
1800 | 1887 | |
1801 | 1888 | $eventOptions = array( |
1802 | 1889 | 'include_holidays' => true, |
@@ -1807,8 +1894,9 @@ discard block |
||
1807 | 1894 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1808 | 1895 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1809 | 1896 | |
1810 | - if ($output_method != 'echo') |
|
1811 | - return $return['calendar_holidays']; |
|
1897 | + if ($output_method != 'echo') { |
|
1898 | + return $return['calendar_holidays']; |
|
1899 | + } |
|
1812 | 1900 | |
1813 | 1901 | echo ' |
1814 | 1902 | ', implode(', ', $return['calendar_holidays']); |
@@ -1822,8 +1910,9 @@ discard block |
||
1822 | 1910 | { |
1823 | 1911 | global $modSettings, $user_info; |
1824 | 1912 | |
1825 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1826 | - return; |
|
1913 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1914 | + return; |
|
1915 | + } |
|
1827 | 1916 | |
1828 | 1917 | $eventOptions = array( |
1829 | 1918 | 'include_events' => true, |
@@ -1834,14 +1923,16 @@ discard block |
||
1834 | 1923 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1835 | 1924 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1836 | 1925 | |
1837 | - if ($output_method != 'echo') |
|
1838 | - return $return['calendar_events']; |
|
1926 | + if ($output_method != 'echo') { |
|
1927 | + return $return['calendar_events']; |
|
1928 | + } |
|
1839 | 1929 | |
1840 | 1930 | foreach ($return['calendar_events'] as $event) |
1841 | 1931 | { |
1842 | - if ($event['can_edit']) |
|
1843 | - echo ' |
|
1932 | + if ($event['can_edit']) { |
|
1933 | + echo ' |
|
1844 | 1934 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1935 | + } |
|
1845 | 1936 | echo ' |
1846 | 1937 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1847 | 1938 | } |
@@ -1856,8 +1947,9 @@ discard block |
||
1856 | 1947 | { |
1857 | 1948 | global $modSettings, $txt, $scripturl, $user_info; |
1858 | 1949 | |
1859 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1860 | - return; |
|
1950 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1951 | + return; |
|
1952 | + } |
|
1861 | 1953 | |
1862 | 1954 | $eventOptions = array( |
1863 | 1955 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1870,19 +1962,22 @@ discard block |
||
1870 | 1962 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1871 | 1963 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1872 | 1964 | |
1873 | - if ($output_method != 'echo') |
|
1874 | - return $return; |
|
1965 | + if ($output_method != 'echo') { |
|
1966 | + return $return; |
|
1967 | + } |
|
1875 | 1968 | |
1876 | - if (!empty($return['calendar_holidays'])) |
|
1877 | - echo ' |
|
1969 | + if (!empty($return['calendar_holidays'])) { |
|
1970 | + echo ' |
|
1878 | 1971 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1972 | + } |
|
1879 | 1973 | if (!empty($return['calendar_birthdays'])) |
1880 | 1974 | { |
1881 | 1975 | echo ' |
1882 | 1976 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1883 | - foreach ($return['calendar_birthdays'] as $member) |
|
1884 | - echo ' |
|
1977 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1978 | + echo ' |
|
1885 | 1979 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
1980 | + } |
|
1886 | 1981 | echo ' |
1887 | 1982 | <br>'; |
1888 | 1983 | } |
@@ -1892,9 +1987,10 @@ discard block |
||
1892 | 1987 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1893 | 1988 | foreach ($return['calendar_events'] as $event) |
1894 | 1989 | { |
1895 | - if ($event['can_edit']) |
|
1896 | - echo ' |
|
1990 | + if ($event['can_edit']) { |
|
1991 | + echo ' |
|
1897 | 1992 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1993 | + } |
|
1898 | 1994 | echo ' |
1899 | 1995 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1900 | 1996 | } |
@@ -1918,25 +2014,29 @@ discard block |
||
1918 | 2014 | loadLanguage('Stats'); |
1919 | 2015 | |
1920 | 2016 | // Must be integers.... |
1921 | - if ($limit === null) |
|
1922 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1923 | - else |
|
1924 | - $limit = (int) $limit; |
|
1925 | - |
|
1926 | - if ($start === null) |
|
1927 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1928 | - else |
|
1929 | - $start = (int) $start; |
|
1930 | - |
|
1931 | - if ($board !== null) |
|
1932 | - $board = (int) $board; |
|
1933 | - elseif (isset($_GET['board'])) |
|
1934 | - $board = (int) $_GET['board']; |
|
1935 | - |
|
1936 | - if ($length === null) |
|
1937 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1938 | - else |
|
1939 | - $length = (int) $length; |
|
2017 | + if ($limit === null) { |
|
2018 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
2019 | + } else { |
|
2020 | + $limit = (int) $limit; |
|
2021 | + } |
|
2022 | + |
|
2023 | + if ($start === null) { |
|
2024 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
2025 | + } else { |
|
2026 | + $start = (int) $start; |
|
2027 | + } |
|
2028 | + |
|
2029 | + if ($board !== null) { |
|
2030 | + $board = (int) $board; |
|
2031 | + } elseif (isset($_GET['board'])) { |
|
2032 | + $board = (int) $_GET['board']; |
|
2033 | + } |
|
2034 | + |
|
2035 | + if ($length === null) { |
|
2036 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
2037 | + } else { |
|
2038 | + $length = (int) $length; |
|
2039 | + } |
|
1940 | 2040 | |
1941 | 2041 | $limit = max(0, $limit); |
1942 | 2042 | $start = max(0, $start); |
@@ -1954,17 +2054,19 @@ discard block |
||
1954 | 2054 | ); |
1955 | 2055 | if ($smcFunc['db_num_rows']($request) == 0) |
1956 | 2056 | { |
1957 | - if ($output_method == 'echo') |
|
1958 | - die($txt['ssi_no_guests']); |
|
1959 | - else |
|
1960 | - return array(); |
|
2057 | + if ($output_method == 'echo') { |
|
2058 | + die($txt['ssi_no_guests']); |
|
2059 | + } else { |
|
2060 | + return array(); |
|
2061 | + } |
|
1961 | 2062 | } |
1962 | 2063 | list ($board) = $smcFunc['db_fetch_row']($request); |
1963 | 2064 | $smcFunc['db_free_result']($request); |
1964 | 2065 | |
1965 | 2066 | $icon_sources = array(); |
1966 | - foreach ($context['stable_icons'] as $icon) |
|
1967 | - $icon_sources[$icon] = 'images_url'; |
|
2067 | + foreach ($context['stable_icons'] as $icon) { |
|
2068 | + $icon_sources[$icon] = 'images_url'; |
|
2069 | + } |
|
1968 | 2070 | |
1969 | 2071 | if (!empty($modSettings['enable_likes'])) |
1970 | 2072 | { |
@@ -1987,12 +2089,14 @@ discard block |
||
1987 | 2089 | ) |
1988 | 2090 | ); |
1989 | 2091 | $posts = array(); |
1990 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1991 | - $posts[] = $row['id_first_msg']; |
|
2092 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2093 | + $posts[] = $row['id_first_msg']; |
|
2094 | + } |
|
1992 | 2095 | $smcFunc['db_free_result']($request); |
1993 | 2096 | |
1994 | - if (empty($posts)) |
|
1995 | - return array(); |
|
2097 | + if (empty($posts)) { |
|
2098 | + return array(); |
|
2099 | + } |
|
1996 | 2100 | |
1997 | 2101 | // Find the posts. |
1998 | 2102 | $request = $smcFunc['db_query']('', ' |
@@ -2022,26 +2126,30 @@ discard block |
||
2022 | 2126 | $last_space = strrpos($row['body'], ' '); |
2023 | 2127 | $last_open = strrpos($row['body'], '<'); |
2024 | 2128 | $last_close = strrpos($row['body'], '>'); |
2025 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
2026 | - $cutoff = $last_open; |
|
2027 | - elseif (empty($last_close) || $last_close < $last_open) |
|
2028 | - $cutoff = $last_space; |
|
2129 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2130 | + $cutoff = $last_open; |
|
2131 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2132 | + $cutoff = $last_space; |
|
2133 | + } |
|
2029 | 2134 | |
2030 | - if ($cutoff !== false) |
|
2031 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2135 | + if ($cutoff !== false) { |
|
2136 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2137 | + } |
|
2032 | 2138 | $row['body'] .= '...'; |
2033 | 2139 | } |
2034 | 2140 | |
2035 | 2141 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
2036 | 2142 | |
2037 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
2038 | - $row['icon'] = 'recycled'; |
|
2143 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2144 | + $row['icon'] = 'recycled'; |
|
2145 | + } |
|
2039 | 2146 | |
2040 | 2147 | // Check that this message icon is there... |
2041 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
2042 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2043 | - elseif (!isset($icon_sources[$row['icon']])) |
|
2044 | - $icon_sources[$row['icon']] = 'images_url'; |
|
2148 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2149 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2150 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
2151 | + $icon_sources[$row['icon']] = 'images_url'; |
|
2152 | + } |
|
2045 | 2153 | |
2046 | 2154 | censorText($row['subject']); |
2047 | 2155 | censorText($row['body']); |
@@ -2078,16 +2186,18 @@ discard block |
||
2078 | 2186 | } |
2079 | 2187 | $smcFunc['db_free_result']($request); |
2080 | 2188 | |
2081 | - if (empty($return)) |
|
2082 | - return $return; |
|
2189 | + if (empty($return)) { |
|
2190 | + return $return; |
|
2191 | + } |
|
2083 | 2192 | |
2084 | 2193 | $return[count($return) - 1]['is_last'] = true; |
2085 | 2194 | |
2086 | 2195 | // If mods want to do somthing with this list of posts, let them do that now. |
2087 | 2196 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2088 | 2197 | |
2089 | - if ($output_method != 'echo') |
|
2090 | - return $return; |
|
2198 | + if ($output_method != 'echo') { |
|
2199 | + return $return; |
|
2200 | + } |
|
2091 | 2201 | |
2092 | 2202 | foreach ($return as $news) |
2093 | 2203 | { |
@@ -2139,9 +2249,10 @@ discard block |
||
2139 | 2249 | echo ' |
2140 | 2250 | </div>'; |
2141 | 2251 | |
2142 | - if (!$news['is_last']) |
|
2143 | - echo ' |
|
2252 | + if (!$news['is_last']) { |
|
2253 | + echo ' |
|
2144 | 2254 | <hr>'; |
2255 | + } |
|
2145 | 2256 | } |
2146 | 2257 | } |
2147 | 2258 | |
@@ -2155,8 +2266,9 @@ discard block |
||
2155 | 2266 | { |
2156 | 2267 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2157 | 2268 | |
2158 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2159 | - return; |
|
2269 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2270 | + return; |
|
2271 | + } |
|
2160 | 2272 | |
2161 | 2273 | // Find all events which are happening in the near future that the member can see. |
2162 | 2274 | $request = $smcFunc['db_query']('', ' |
@@ -2182,20 +2294,23 @@ discard block |
||
2182 | 2294 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2183 | 2295 | { |
2184 | 2296 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2185 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2186 | - continue; |
|
2297 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2298 | + continue; |
|
2299 | + } |
|
2187 | 2300 | |
2188 | 2301 | // Censor the title. |
2189 | 2302 | censorText($row['title']); |
2190 | 2303 | |
2191 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2192 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2193 | - else |
|
2194 | - $date = $row['start_date']; |
|
2304 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2305 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2306 | + } else { |
|
2307 | + $date = $row['start_date']; |
|
2308 | + } |
|
2195 | 2309 | |
2196 | 2310 | // If the topic it is attached to is not approved then don't link it. |
2197 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2198 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2311 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2312 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2313 | + } |
|
2199 | 2314 | |
2200 | 2315 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2201 | 2316 | |
@@ -2221,24 +2336,27 @@ discard block |
||
2221 | 2336 | } |
2222 | 2337 | $smcFunc['db_free_result']($request); |
2223 | 2338 | |
2224 | - foreach ($return as $mday => $array) |
|
2225 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2339 | + foreach ($return as $mday => $array) { |
|
2340 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2341 | + } |
|
2226 | 2342 | |
2227 | 2343 | // If mods want to do somthing with this list of events, let them do that now. |
2228 | 2344 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2229 | 2345 | |
2230 | - if ($output_method != 'echo' || empty($return)) |
|
2231 | - return $return; |
|
2346 | + if ($output_method != 'echo' || empty($return)) { |
|
2347 | + return $return; |
|
2348 | + } |
|
2232 | 2349 | |
2233 | 2350 | // Well the output method is echo. |
2234 | 2351 | echo ' |
2235 | 2352 | <span class="event">' . $txt['events'] . '</span> '; |
2236 | - foreach ($return as $mday => $array) |
|
2237 | - foreach ($array as $event) |
|
2353 | + foreach ($return as $mday => $array) { |
|
2354 | + foreach ($array as $event) |
|
2238 | 2355 | { |
2239 | 2356 | if ($event['can_edit']) |
2240 | 2357 | echo ' |
2241 | 2358 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2359 | + } |
|
2242 | 2360 | |
2243 | 2361 | echo ' |
2244 | 2362 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2257,8 +2375,9 @@ discard block |
||
2257 | 2375 | global $smcFunc; |
2258 | 2376 | |
2259 | 2377 | // If $id is null, this was most likely called from a query string and should do nothing. |
2260 | - if ($id === null) |
|
2261 | - return; |
|
2378 | + if ($id === null) { |
|
2379 | + return; |
|
2380 | + } |
|
2262 | 2381 | |
2263 | 2382 | $request = $smcFunc['db_query']('', ' |
2264 | 2383 | SELECT passwd, member_name, is_activated |
@@ -2290,8 +2409,9 @@ discard block |
||
2290 | 2409 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2291 | 2410 | |
2292 | 2411 | // No boards? Adios amigo. |
2293 | - if (empty($attachments_boards)) |
|
2294 | - return array(); |
|
2412 | + if (empty($attachments_boards)) { |
|
2413 | + return array(); |
|
2414 | + } |
|
2295 | 2415 | |
2296 | 2416 | // Is it an array? |
2297 | 2417 | $attachment_ext = (array) $attachment_ext; |
@@ -2375,8 +2495,9 @@ discard block |
||
2375 | 2495 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2376 | 2496 | |
2377 | 2497 | // So you just want an array? Here you can have it. |
2378 | - if ($output_method == 'array' || empty($attachments)) |
|
2379 | - return $attachments; |
|
2498 | + if ($output_method == 'array' || empty($attachments)) { |
|
2499 | + return $attachments; |
|
2500 | + } |
|
2380 | 2501 | |
2381 | 2502 | // Give them the default. |
2382 | 2503 | echo ' |
@@ -2387,14 +2508,15 @@ discard block |
||
2387 | 2508 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2388 | 2509 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2389 | 2510 | </tr>'; |
2390 | - foreach ($attachments as $attach) |
|
2391 | - echo ' |
|
2511 | + foreach ($attachments as $attach) { |
|
2512 | + echo ' |
|
2392 | 2513 | <tr> |
2393 | 2514 | <td>', $attach['file']['link'], '</td> |
2394 | 2515 | <td>', $attach['member']['link'], '</td> |
2395 | 2516 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2396 | 2517 | <td>', $attach['file']['filesize'], '</td> |
2397 | 2518 | </tr>'; |
2519 | + } |
|
2398 | 2520 | echo ' |
2399 | 2521 | </table>'; |
2400 | 2522 | } |