@@ -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 | |
@@ -26,21 +27,24 @@ discard block |
||
| 26 | 27 | |
| 27 | 28 | // Remember the current configuration so it can be set back. |
| 28 | 29 | $ssi_magic_quotes_runtime = function_exists('get_magic_quotes_gpc') && get_magic_quotes_runtime(); |
| 29 | -if (function_exists('set_magic_quotes_runtime')) |
|
| 30 | +if (function_exists('set_magic_quotes_runtime')) { |
|
| 30 | 31 | @set_magic_quotes_runtime(0); |
| 32 | +} |
|
| 31 | 33 | $time_start = microtime(); |
| 32 | 34 | |
| 33 | 35 | // Just being safe... |
| 34 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 36 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 35 | 37 | if (isset($GLOBALS[$variable])) |
| 36 | 38 | unset($GLOBALS[$variable]); |
| 39 | +} |
|
| 37 | 40 | |
| 38 | 41 | // Get the forum's settings for database and file paths. |
| 39 | 42 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 40 | 43 | |
| 41 | 44 | // Make absolutely sure the cache directory is defined. |
| 42 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 45 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 43 | 46 | $cachedir = $boarddir . '/cache'; |
| 47 | +} |
|
| 44 | 48 | |
| 45 | 49 | $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 46 | 50 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -51,12 +55,14 @@ discard block |
||
| 51 | 55 | $ssi_on_error_method = false; |
| 52 | 56 | |
| 53 | 57 | // Don't do john didley if the forum's been shut down completely. |
| 54 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
| 58 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
| 55 | 59 | die($mmessage); |
| 60 | +} |
|
| 56 | 61 | |
| 57 | 62 | // Fix for using the current directory as a path. |
| 58 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 59 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 60 | 66 | |
| 61 | 67 | // Load the important includes. |
| 62 | 68 | require_once($sourcedir . '/QueryString.php'); |
@@ -81,34 +87,38 @@ discard block |
||
| 81 | 87 | cleanRequest(); |
| 82 | 88 | |
| 83 | 89 | // Seed the random generator? |
| 84 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 90 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 85 | 91 | smf_seed_generator(); |
| 92 | +} |
|
| 86 | 93 | |
| 87 | 94 | // Check on any hacking attempts. |
| 88 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 95 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 89 | 96 | die('No direct access...'); |
| 90 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
| 97 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
| 91 | 98 | die('No direct access...'); |
| 92 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
| 99 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
| 93 | 100 | die('No direct access...'); |
| 94 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
| 101 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
| 95 | 102 | die('No direct access...'); |
| 96 | -if (isset($_REQUEST['context'])) |
|
| 103 | +} |
|
| 104 | +if (isset($_REQUEST['context'])) { |
|
| 97 | 105 | die('No direct access...'); |
| 106 | +} |
|
| 98 | 107 | |
| 99 | 108 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
| 100 | -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', '>=')) |
|
| 109 | +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', '>=')) { |
|
| 101 | 110 | ob_start('ob_gzhandler'); |
| 102 | -else |
|
| 111 | +} else { |
|
| 103 | 112 | $modSettings['enableCompressedOutput'] = '0'; |
| 113 | +} |
|
| 104 | 114 | |
| 105 | 115 | // Primarily, this is to fix the URLs... |
| 106 | 116 | ob_start('ob_sessrewrite'); |
| 107 | 117 | |
| 108 | 118 | // Start the session... known to scramble SSI includes in cases... |
| 109 | -if (!headers_sent()) |
|
| 119 | +if (!headers_sent()) { |
|
| 110 | 120 | loadSession(); |
| 111 | -else |
|
| 121 | +} else |
|
| 112 | 122 | { |
| 113 | 123 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
| 114 | 124 | { |
@@ -142,12 +152,14 @@ discard block |
||
| 142 | 152 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
| 143 | 153 | |
| 144 | 154 | // @todo: probably not the best place, but somewhere it should be set... |
| 145 | -if (!headers_sent()) |
|
| 155 | +if (!headers_sent()) { |
|
| 146 | 156 | 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'])); |
| 157 | +} |
|
| 147 | 158 | |
| 148 | 159 | // Take care of any banning that needs to be done. |
| 149 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
| 160 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
| 150 | 161 | is_not_banned(); |
| 162 | +} |
|
| 151 | 163 | |
| 152 | 164 | // Do we allow guests in here? |
| 153 | 165 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -162,39 +174,45 @@ discard block |
||
| 162 | 174 | { |
| 163 | 175 | $context['template_layers'] = $ssi_layers; |
| 164 | 176 | template_header(); |
| 165 | -} |
|
| 166 | -else |
|
| 177 | +} else { |
|
| 167 | 178 | setupThemeContext(); |
| 179 | +} |
|
| 168 | 180 | |
| 169 | 181 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
| 170 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
| 182 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
| 171 | 183 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
| 184 | +} |
|
| 172 | 185 | |
| 173 | 186 | // Without visiting the forum this session variable might not be set on submit. |
| 174 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
| 187 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
| 175 | 188 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
| 189 | +} |
|
| 176 | 190 | |
| 177 | 191 | // Have the ability to easily add functions to SSI. |
| 178 | 192 | call_integration_hook('integrate_SSI'); |
| 179 | 193 | |
| 180 | 194 | // Ignore a call to ssi_* functions if we are not using SSI.php |
| 181 | -if (empty($modSettings['allow_ssi_functions_anywhere']) && isset($_GET['ssi_function']) && basename($_SERVER['PHP_SELF']) !== 'SSI.php') |
|
| 195 | +if (empty($modSettings['allow_ssi_functions_anywhere']) && isset($_GET['ssi_function']) && basename($_SERVER['PHP_SELF']) !== 'SSI.php') { |
|
| 182 | 196 | unset($_GET['ssi_function']); |
| 197 | +} |
|
| 183 | 198 | // Call a function passed by GET. |
| 184 | 199 | if (isset($_GET['ssi_function']) && function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
| 185 | 200 | { |
| 186 | 201 | call_user_func('ssi_' . $_GET['ssi_function']); |
| 187 | 202 | exit; |
| 188 | 203 | } |
| 189 | -if (isset($_GET['ssi_function'])) |
|
| 204 | +if (isset($_GET['ssi_function'])) { |
|
| 190 | 205 | exit; |
| 206 | +} |
|
| 191 | 207 | // You shouldn't just access SSI.php directly by URL!! |
| 192 | -elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
|
| 208 | +elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php') { |
|
| 193 | 209 | die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
| 210 | +} |
|
| 194 | 211 | |
| 195 | 212 | error_reporting($ssi_error_reporting); |
| 196 | -if (function_exists('set_magic_quotes_runtime')) |
|
| 213 | +if (function_exists('set_magic_quotes_runtime')) { |
|
| 197 | 214 | @set_magic_quotes_runtime($ssi_magic_quotes_runtime); |
| 215 | +} |
|
| 198 | 216 | |
| 199 | 217 | return true; |
| 200 | 218 | |
@@ -204,9 +222,10 @@ discard block |
||
| 204 | 222 | */ |
| 205 | 223 | function ssi_shutdown() |
| 206 | 224 | { |
| 207 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
| 208 | - template_footer(); |
|
| 209 | -} |
|
| 225 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
| 226 | + template_footer(); |
|
| 227 | + } |
|
| 228 | + } |
|
| 210 | 229 | |
| 211 | 230 | /** |
| 212 | 231 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -219,15 +238,17 @@ discard block |
||
| 219 | 238 | |
| 220 | 239 | if ($output_method == 'echo') |
| 221 | 240 | { |
| 222 | - if ($context['user']['is_guest']) |
|
| 223 | - 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'); |
|
| 224 | - else |
|
| 225 | - 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'])))) : ''; |
|
| 241 | + if ($context['user']['is_guest']) { |
|
| 242 | + 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'); |
|
| 243 | + } else { |
|
| 244 | + 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'])))) : ''; |
|
| 245 | + } |
|
| 226 | 246 | } |
| 227 | 247 | // Don't echo... then do what?! |
| 228 | - else |
|
| 229 | - return $context['user']; |
|
| 230 | -} |
|
| 248 | + else { |
|
| 249 | + return $context['user']; |
|
| 250 | + } |
|
| 251 | + } |
|
| 231 | 252 | |
| 232 | 253 | /** |
| 233 | 254 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -238,12 +259,14 @@ discard block |
||
| 238 | 259 | { |
| 239 | 260 | global $context; |
| 240 | 261 | |
| 241 | - if ($output_method == 'echo') |
|
| 242 | - template_menu(); |
|
| 262 | + if ($output_method == 'echo') { |
|
| 263 | + template_menu(); |
|
| 264 | + } |
|
| 243 | 265 | // What else could this do? |
| 244 | - else |
|
| 245 | - return $context['menu_buttons']; |
|
| 246 | -} |
|
| 266 | + else { |
|
| 267 | + return $context['menu_buttons']; |
|
| 268 | + } |
|
| 269 | + } |
|
| 247 | 270 | |
| 248 | 271 | /** |
| 249 | 272 | * Show a logout link. |
@@ -255,20 +278,23 @@ discard block |
||
| 255 | 278 | { |
| 256 | 279 | global $context, $txt, $scripturl; |
| 257 | 280 | |
| 258 | - if ($redirect_to != '') |
|
| 259 | - $_SESSION['logout_url'] = $redirect_to; |
|
| 281 | + if ($redirect_to != '') { |
|
| 282 | + $_SESSION['logout_url'] = $redirect_to; |
|
| 283 | + } |
|
| 260 | 284 | |
| 261 | 285 | // Guests can't log out. |
| 262 | - if ($context['user']['is_guest']) |
|
| 263 | - return false; |
|
| 286 | + if ($context['user']['is_guest']) { |
|
| 287 | + return false; |
|
| 288 | + } |
|
| 264 | 289 | |
| 265 | 290 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
| 266 | 291 | |
| 267 | - if ($output_method == 'echo') |
|
| 268 | - echo $link; |
|
| 269 | - else |
|
| 270 | - return $link; |
|
| 271 | -} |
|
| 292 | + if ($output_method == 'echo') { |
|
| 293 | + echo $link; |
|
| 294 | + } else { |
|
| 295 | + return $link; |
|
| 296 | + } |
|
| 297 | + } |
|
| 272 | 298 | |
| 273 | 299 | /** |
| 274 | 300 | * Recent post list: [board] Subject by Poster Date |
@@ -284,17 +310,17 @@ discard block |
||
| 284 | 310 | global $modSettings, $context; |
| 285 | 311 | |
| 286 | 312 | // Excluding certain boards... |
| 287 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 288 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 289 | - else |
|
| 290 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 313 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 314 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 315 | + } else { |
|
| 316 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 317 | + } |
|
| 291 | 318 | |
| 292 | 319 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
| 293 | 320 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 294 | 321 | { |
| 295 | 322 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 296 | - } |
|
| 297 | - elseif ($include_boards != null) |
|
| 323 | + } elseif ($include_boards != null) |
|
| 298 | 324 | { |
| 299 | 325 | $include_boards = array(); |
| 300 | 326 | } |
@@ -331,8 +357,9 @@ discard block |
||
| 331 | 357 | { |
| 332 | 358 | global $modSettings; |
| 333 | 359 | |
| 334 | - if (empty($post_ids)) |
|
| 335 | - return; |
|
| 360 | + if (empty($post_ids)) { |
|
| 361 | + return; |
|
| 362 | + } |
|
| 336 | 363 | |
| 337 | 364 | // Allow the user to request more than one - why not? |
| 338 | 365 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -367,8 +394,9 @@ discard block |
||
| 367 | 394 | global $scripturl, $txt, $user_info; |
| 368 | 395 | global $modSettings, $smcFunc, $context; |
| 369 | 396 | |
| 370 | - if (!empty($modSettings['enable_likes'])) |
|
| 371 | - $context['can_like'] = allowedTo('likes_like'); |
|
| 397 | + if (!empty($modSettings['enable_likes'])) { |
|
| 398 | + $context['can_like'] = allowedTo('likes_like'); |
|
| 399 | + } |
|
| 372 | 400 | |
| 373 | 401 | // Find all the posts. Newer ones will have higher IDs. |
| 374 | 402 | $request = $smcFunc['db_query']('substring', ' |
@@ -434,12 +462,13 @@ discard block |
||
| 434 | 462 | ); |
| 435 | 463 | |
| 436 | 464 | // Get the likes for each message. |
| 437 | - if (!empty($modSettings['enable_likes'])) |
|
| 438 | - $posts[$row['id_msg']]['likes'] = array( |
|
| 465 | + if (!empty($modSettings['enable_likes'])) { |
|
| 466 | + $posts[$row['id_msg']]['likes'] = array( |
|
| 439 | 467 | 'count' => $row['likes'], |
| 440 | 468 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
| 441 | 469 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 442 | 470 | ); |
| 471 | + } |
|
| 443 | 472 | } |
| 444 | 473 | $smcFunc['db_free_result']($request); |
| 445 | 474 | |
@@ -447,13 +476,14 @@ discard block |
||
| 447 | 476 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
| 448 | 477 | |
| 449 | 478 | // Just return it. |
| 450 | - if ($output_method != 'echo' || empty($posts)) |
|
| 451 | - return $posts; |
|
| 479 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 480 | + return $posts; |
|
| 481 | + } |
|
| 452 | 482 | |
| 453 | 483 | echo ' |
| 454 | 484 | <table style="border: none" class="ssi_table">'; |
| 455 | - foreach ($posts as $post) |
|
| 456 | - echo ' |
|
| 485 | + foreach ($posts as $post) { |
|
| 486 | + echo ' |
|
| 457 | 487 | <tr> |
| 458 | 488 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 459 | 489 | [', $post['board']['link'], '] |
@@ -467,6 +497,7 @@ discard block |
||
| 467 | 497 | ', $post['time'], ' |
| 468 | 498 | </td> |
| 469 | 499 | </tr>'; |
| 500 | + } |
|
| 470 | 501 | echo ' |
| 471 | 502 | </table>'; |
| 472 | 503 | } |
@@ -484,25 +515,26 @@ discard block |
||
| 484 | 515 | global $settings, $scripturl, $txt, $user_info; |
| 485 | 516 | global $modSettings, $smcFunc, $context; |
| 486 | 517 | |
| 487 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 488 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 489 | - else |
|
| 490 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 518 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 519 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 520 | + } else { |
|
| 521 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 522 | + } |
|
| 491 | 523 | |
| 492 | 524 | // Only some boards?. |
| 493 | 525 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 494 | 526 | { |
| 495 | 527 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 496 | - } |
|
| 497 | - elseif ($include_boards != null) |
|
| 528 | + } elseif ($include_boards != null) |
|
| 498 | 529 | { |
| 499 | 530 | $output_method = $include_boards; |
| 500 | 531 | $include_boards = array(); |
| 501 | 532 | } |
| 502 | 533 | |
| 503 | 534 | $icon_sources = array(); |
| 504 | - foreach ($context['stable_icons'] as $icon) |
|
| 505 | - $icon_sources[$icon] = 'images_url'; |
|
| 535 | + foreach ($context['stable_icons'] as $icon) { |
|
| 536 | + $icon_sources[$icon] = 'images_url'; |
|
| 537 | + } |
|
| 506 | 538 | |
| 507 | 539 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
| 508 | 540 | $request = $smcFunc['db_query']('substring', ' |
@@ -527,13 +559,15 @@ discard block |
||
| 527 | 559 | ) |
| 528 | 560 | ); |
| 529 | 561 | $topics = array(); |
| 530 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 531 | - $topics[$row['id_topic']] = $row; |
|
| 562 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 563 | + $topics[$row['id_topic']] = $row; |
|
| 564 | + } |
|
| 532 | 565 | $smcFunc['db_free_result']($request); |
| 533 | 566 | |
| 534 | 567 | // Did we find anything? If not, bail. |
| 535 | - if (empty($topics)) |
|
| 536 | - return array(); |
|
| 568 | + if (empty($topics)) { |
|
| 569 | + return array(); |
|
| 570 | + } |
|
| 537 | 571 | |
| 538 | 572 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 539 | 573 | |
@@ -561,19 +595,22 @@ discard block |
||
| 561 | 595 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 562 | 596 | { |
| 563 | 597 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 564 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 565 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 598 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 599 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 600 | + } |
|
| 566 | 601 | |
| 567 | 602 | // Censor the subject. |
| 568 | 603 | censorText($row['subject']); |
| 569 | 604 | censorText($row['body']); |
| 570 | 605 | |
| 571 | 606 | // Recycled icon |
| 572 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
| 573 | - $row['icon'] = 'recycled'; |
|
| 607 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
| 608 | + $row['icon'] = 'recycled'; |
|
| 609 | + } |
|
| 574 | 610 | |
| 575 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 576 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 611 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 612 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 613 | + } |
|
| 577 | 614 | |
| 578 | 615 | // Build the array. |
| 579 | 616 | $posts[] = array( |
@@ -612,13 +649,14 @@ discard block |
||
| 612 | 649 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
| 613 | 650 | |
| 614 | 651 | // Just return it. |
| 615 | - if ($output_method != 'echo' || empty($posts)) |
|
| 616 | - return $posts; |
|
| 652 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 653 | + return $posts; |
|
| 654 | + } |
|
| 617 | 655 | |
| 618 | 656 | echo ' |
| 619 | 657 | <table style="border: none" class="ssi_table">'; |
| 620 | - foreach ($posts as $post) |
|
| 621 | - echo ' |
|
| 658 | + foreach ($posts as $post) { |
|
| 659 | + echo ' |
|
| 622 | 660 | <tr> |
| 623 | 661 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 624 | 662 | [', $post['board']['link'], '] |
@@ -632,6 +670,7 @@ discard block |
||
| 632 | 670 | ', $post['time'], ' |
| 633 | 671 | </td> |
| 634 | 672 | </tr>'; |
| 673 | + } |
|
| 635 | 674 | echo ' |
| 636 | 675 | </table>'; |
| 637 | 676 | } |
@@ -656,27 +695,30 @@ discard block |
||
| 656 | 695 | ) |
| 657 | 696 | ); |
| 658 | 697 | $return = array(); |
| 659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 660 | - $return[] = array( |
|
| 698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 699 | + $return[] = array( |
|
| 661 | 700 | 'id' => $row['id_member'], |
| 662 | 701 | 'name' => $row['real_name'], |
| 663 | 702 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
| 664 | 703 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
| 665 | 704 | 'posts' => $row['posts'] |
| 666 | 705 | ); |
| 706 | + } |
|
| 667 | 707 | $smcFunc['db_free_result']($request); |
| 668 | 708 | |
| 669 | 709 | // If mods want to do somthing with this list of members, let them do that now. |
| 670 | 710 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
| 671 | 711 | |
| 672 | 712 | // Just return all the top posters. |
| 673 | - if ($output_method != 'echo') |
|
| 674 | - return $return; |
|
| 713 | + if ($output_method != 'echo') { |
|
| 714 | + return $return; |
|
| 715 | + } |
|
| 675 | 716 | |
| 676 | 717 | // Make a quick array to list the links in. |
| 677 | 718 | $temp_array = array(); |
| 678 | - foreach ($return as $member) |
|
| 679 | - $temp_array[] = $member['link']; |
|
| 719 | + foreach ($return as $member) { |
|
| 720 | + $temp_array[] = $member['link']; |
|
| 721 | + } |
|
| 680 | 722 | |
| 681 | 723 | echo implode(', ', $temp_array); |
| 682 | 724 | } |
@@ -708,8 +750,8 @@ discard block |
||
| 708 | 750 | ) |
| 709 | 751 | ); |
| 710 | 752 | $boards = array(); |
| 711 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 712 | - $boards[] = array( |
|
| 753 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 754 | + $boards[] = array( |
|
| 713 | 755 | 'id' => $row['id_board'], |
| 714 | 756 | 'num_posts' => $row['num_posts'], |
| 715 | 757 | 'num_topics' => $row['num_topics'], |
@@ -718,14 +760,16 @@ discard block |
||
| 718 | 760 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
| 719 | 761 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
| 720 | 762 | ); |
| 763 | + } |
|
| 721 | 764 | $smcFunc['db_free_result']($request); |
| 722 | 765 | |
| 723 | 766 | // If mods want to do somthing with this list of boards, let them do that now. |
| 724 | 767 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
| 725 | 768 | |
| 726 | 769 | // If we shouldn't output or have nothing to output, just jump out. |
| 727 | - if ($output_method != 'echo' || empty($boards)) |
|
| 728 | - return $boards; |
|
| 770 | + if ($output_method != 'echo' || empty($boards)) { |
|
| 771 | + return $boards; |
|
| 772 | + } |
|
| 729 | 773 | |
| 730 | 774 | echo ' |
| 731 | 775 | <table class="ssi_table"> |
@@ -734,13 +778,14 @@ discard block |
||
| 734 | 778 | <th style="text-align: left">', $txt['board_topics'], '</th> |
| 735 | 779 | <th style="text-align: left">', $txt['posts'], '</th> |
| 736 | 780 | </tr>'; |
| 737 | - foreach ($boards as $sBoard) |
|
| 738 | - echo ' |
|
| 781 | + foreach ($boards as $sBoard) { |
|
| 782 | + echo ' |
|
| 739 | 783 | <tr> |
| 740 | 784 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
| 741 | 785 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
| 742 | 786 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
| 743 | 787 | </tr>'; |
| 788 | + } |
|
| 744 | 789 | echo ' |
| 745 | 790 | </table>'; |
| 746 | 791 | } |
@@ -773,12 +818,13 @@ discard block |
||
| 773 | 818 | ) |
| 774 | 819 | ); |
| 775 | 820 | $topic_ids = array(); |
| 776 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 777 | - $topic_ids[] = $row['id_topic']; |
|
| 821 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 822 | + $topic_ids[] = $row['id_topic']; |
|
| 823 | + } |
|
| 778 | 824 | $smcFunc['db_free_result']($request); |
| 825 | + } else { |
|
| 826 | + $topic_ids = array(); |
|
| 779 | 827 | } |
| 780 | - else |
|
| 781 | - $topic_ids = array(); |
|
| 782 | 828 | |
| 783 | 829 | $request = $smcFunc['db_query']('', ' |
| 784 | 830 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -817,8 +863,9 @@ discard block |
||
| 817 | 863 | // If mods want to do somthing with this list of topics, let them do that now. |
| 818 | 864 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
| 819 | 865 | |
| 820 | - if ($output_method != 'echo' || empty($topics)) |
|
| 821 | - return $topics; |
|
| 866 | + if ($output_method != 'echo' || empty($topics)) { |
|
| 867 | + return $topics; |
|
| 868 | + } |
|
| 822 | 869 | |
| 823 | 870 | echo ' |
| 824 | 871 | <table class="ssi_table"> |
@@ -827,8 +874,8 @@ discard block |
||
| 827 | 874 | <th style="text-align: left">', $txt['views'], '</th> |
| 828 | 875 | <th style="text-align: left">', $txt['replies'], '</th> |
| 829 | 876 | </tr>'; |
| 830 | - foreach ($topics as $sTopic) |
|
| 831 | - echo ' |
|
| 877 | + foreach ($topics as $sTopic) { |
|
| 878 | + echo ' |
|
| 832 | 879 | <tr> |
| 833 | 880 | <td style="text-align: left"> |
| 834 | 881 | ', $sTopic['link'], ' |
@@ -836,6 +883,7 @@ discard block |
||
| 836 | 883 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
| 837 | 884 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
| 838 | 885 | </tr>'; |
| 886 | + } |
|
| 839 | 887 | echo ' |
| 840 | 888 | </table>'; |
| 841 | 889 | } |
@@ -871,12 +919,13 @@ discard block |
||
| 871 | 919 | { |
| 872 | 920 | global $txt, $context; |
| 873 | 921 | |
| 874 | - if ($output_method == 'echo') |
|
| 875 | - echo ' |
|
| 922 | + if ($output_method == 'echo') { |
|
| 923 | + echo ' |
|
| 876 | 924 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
| 877 | - else |
|
| 878 | - return $context['common_stats']['latest_member']; |
|
| 879 | -} |
|
| 925 | + } else { |
|
| 926 | + return $context['common_stats']['latest_member']; |
|
| 927 | + } |
|
| 928 | + } |
|
| 880 | 929 | |
| 881 | 930 | /** |
| 882 | 931 | * Fetches a random member. |
@@ -925,8 +974,9 @@ discard block |
||
| 925 | 974 | } |
| 926 | 975 | |
| 927 | 976 | // Just to be sure put the random generator back to something... random. |
| 928 | - if ($random_type != '') |
|
| 929 | - mt_srand(time()); |
|
| 977 | + if ($random_type != '') { |
|
| 978 | + mt_srand(time()); |
|
| 979 | + } |
|
| 930 | 980 | |
| 931 | 981 | return $result; |
| 932 | 982 | } |
@@ -939,8 +989,9 @@ discard block |
||
| 939 | 989 | */ |
| 940 | 990 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
| 941 | 991 | { |
| 942 | - if (empty($member_ids)) |
|
| 943 | - return; |
|
| 992 | + if (empty($member_ids)) { |
|
| 993 | + return; |
|
| 994 | + } |
|
| 944 | 995 | |
| 945 | 996 | // Can have more than one member if you really want... |
| 946 | 997 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -965,8 +1016,9 @@ discard block |
||
| 965 | 1016 | */ |
| 966 | 1017 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
| 967 | 1018 | { |
| 968 | - if ($group_id === null) |
|
| 969 | - return; |
|
| 1019 | + if ($group_id === null) { |
|
| 1020 | + return; |
|
| 1021 | + } |
|
| 970 | 1022 | |
| 971 | 1023 | $query_where = ' |
| 972 | 1024 | id_group = {int:id_group} |
@@ -993,8 +1045,9 @@ discard block |
||
| 993 | 1045 | { |
| 994 | 1046 | global $smcFunc, $memberContext; |
| 995 | 1047 | |
| 996 | - if ($query_where === null) |
|
| 997 | - return; |
|
| 1048 | + if ($query_where === null) { |
|
| 1049 | + return; |
|
| 1050 | + } |
|
| 998 | 1051 | |
| 999 | 1052 | // Fetch the members in question. |
| 1000 | 1053 | $request = $smcFunc['db_query']('', ' |
@@ -1007,12 +1060,14 @@ discard block |
||
| 1007 | 1060 | )) |
| 1008 | 1061 | ); |
| 1009 | 1062 | $members = array(); |
| 1010 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1011 | - $members[] = $row['id_member']; |
|
| 1063 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1064 | + $members[] = $row['id_member']; |
|
| 1065 | + } |
|
| 1012 | 1066 | $smcFunc['db_free_result']($request); |
| 1013 | 1067 | |
| 1014 | - if (empty($members)) |
|
| 1015 | - return array(); |
|
| 1068 | + if (empty($members)) { |
|
| 1069 | + return array(); |
|
| 1070 | + } |
|
| 1016 | 1071 | |
| 1017 | 1072 | // If mods want to do somthing with this list of members, let them do that now. |
| 1018 | 1073 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1021,23 +1076,25 @@ discard block |
||
| 1021 | 1076 | loadMemberData($members); |
| 1022 | 1077 | |
| 1023 | 1078 | // Draw the table! |
| 1024 | - if ($output_method == 'echo') |
|
| 1025 | - echo ' |
|
| 1079 | + if ($output_method == 'echo') { |
|
| 1080 | + echo ' |
|
| 1026 | 1081 | <table style="border: none" class="ssi_table">'; |
| 1082 | + } |
|
| 1027 | 1083 | |
| 1028 | 1084 | $query_members = array(); |
| 1029 | 1085 | foreach ($members as $member) |
| 1030 | 1086 | { |
| 1031 | 1087 | // Load their context data. |
| 1032 | - if (!loadMemberContext($member)) |
|
| 1033 | - continue; |
|
| 1088 | + if (!loadMemberContext($member)) { |
|
| 1089 | + continue; |
|
| 1090 | + } |
|
| 1034 | 1091 | |
| 1035 | 1092 | // Store this member's information. |
| 1036 | 1093 | $query_members[$member] = $memberContext[$member]; |
| 1037 | 1094 | |
| 1038 | 1095 | // Only do something if we're echo'ing. |
| 1039 | - if ($output_method == 'echo') |
|
| 1040 | - echo ' |
|
| 1096 | + if ($output_method == 'echo') { |
|
| 1097 | + echo ' |
|
| 1041 | 1098 | <tr> |
| 1042 | 1099 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 1043 | 1100 | ', $query_members[$member]['link'], ' |
@@ -1045,12 +1102,14 @@ discard block |
||
| 1045 | 1102 | <br>', $query_members[$member]['avatar']['image'], ' |
| 1046 | 1103 | </td> |
| 1047 | 1104 | </tr>'; |
| 1105 | + } |
|
| 1048 | 1106 | } |
| 1049 | 1107 | |
| 1050 | 1108 | // End the table if appropriate. |
| 1051 | - if ($output_method == 'echo') |
|
| 1052 | - echo ' |
|
| 1109 | + if ($output_method == 'echo') { |
|
| 1110 | + echo ' |
|
| 1053 | 1111 | </table>'; |
| 1112 | + } |
|
| 1054 | 1113 | |
| 1055 | 1114 | // Send back the data. |
| 1056 | 1115 | return $query_members; |
@@ -1065,8 +1124,9 @@ discard block |
||
| 1065 | 1124 | { |
| 1066 | 1125 | global $txt, $scripturl, $modSettings, $smcFunc; |
| 1067 | 1126 | |
| 1068 | - if (!allowedTo('view_stats')) |
|
| 1069 | - return; |
|
| 1127 | + if (!allowedTo('view_stats')) { |
|
| 1128 | + return; |
|
| 1129 | + } |
|
| 1070 | 1130 | |
| 1071 | 1131 | $totals = array( |
| 1072 | 1132 | 'members' => $modSettings['totalMembers'], |
@@ -1095,8 +1155,9 @@ discard block |
||
| 1095 | 1155 | // If mods want to do somthing with the board stats, let them do that now. |
| 1096 | 1156 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
| 1097 | 1157 | |
| 1098 | - if ($output_method != 'echo') |
|
| 1099 | - return $totals; |
|
| 1158 | + if ($output_method != 'echo') { |
|
| 1159 | + return $totals; |
|
| 1160 | + } |
|
| 1100 | 1161 | |
| 1101 | 1162 | echo ' |
| 1102 | 1163 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1125,8 +1186,8 @@ discard block |
||
| 1125 | 1186 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
| 1126 | 1187 | |
| 1127 | 1188 | // Add some redundancy for backwards compatibility reasons. |
| 1128 | - if ($output_method != 'echo') |
|
| 1129 | - return $return + array( |
|
| 1189 | + if ($output_method != 'echo') { |
|
| 1190 | + return $return + array( |
|
| 1130 | 1191 | 'users' => $return['users_online'], |
| 1131 | 1192 | 'guests' => $return['num_guests'], |
| 1132 | 1193 | 'hidden' => $return['num_users_hidden'], |
@@ -1134,29 +1195,35 @@ discard block |
||
| 1134 | 1195 | 'num_users' => $return['num_users_online'], |
| 1135 | 1196 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
| 1136 | 1197 | ); |
| 1198 | + } |
|
| 1137 | 1199 | |
| 1138 | 1200 | echo ' |
| 1139 | 1201 | ', 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']; |
| 1140 | 1202 | |
| 1141 | 1203 | $bracketList = array(); |
| 1142 | - if (!empty($user_info['buddies'])) |
|
| 1143 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1144 | - if (!empty($return['num_spiders'])) |
|
| 1145 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1146 | - if (!empty($return['num_users_hidden'])) |
|
| 1147 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1204 | + if (!empty($user_info['buddies'])) { |
|
| 1205 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1206 | + } |
|
| 1207 | + if (!empty($return['num_spiders'])) { |
|
| 1208 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1209 | + } |
|
| 1210 | + if (!empty($return['num_users_hidden'])) { |
|
| 1211 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1212 | + } |
|
| 1148 | 1213 | |
| 1149 | - if (!empty($bracketList)) |
|
| 1150 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1214 | + if (!empty($bracketList)) { |
|
| 1215 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1216 | + } |
|
| 1151 | 1217 | |
| 1152 | 1218 | echo '<br> |
| 1153 | 1219 | ', implode(', ', $return['list_users_online']); |
| 1154 | 1220 | |
| 1155 | 1221 | // Showing membergroups? |
| 1156 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
| 1157 | - echo '<br> |
|
| 1222 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
| 1223 | + echo '<br> |
|
| 1158 | 1224 | [' . implode('] [', $return['membergroups']) . ']'; |
| 1159 | -} |
|
| 1225 | + } |
|
| 1226 | + } |
|
| 1160 | 1227 | |
| 1161 | 1228 | /** |
| 1162 | 1229 | * Just like whosOnline except it also logs the online presence. |
@@ -1167,11 +1234,12 @@ discard block |
||
| 1167 | 1234 | { |
| 1168 | 1235 | writeLog(); |
| 1169 | 1236 | |
| 1170 | - if ($output_method != 'echo') |
|
| 1171 | - return ssi_whosOnline($output_method); |
|
| 1172 | - else |
|
| 1173 | - ssi_whosOnline($output_method); |
|
| 1174 | -} |
|
| 1237 | + if ($output_method != 'echo') { |
|
| 1238 | + return ssi_whosOnline($output_method); |
|
| 1239 | + } else { |
|
| 1240 | + ssi_whosOnline($output_method); |
|
| 1241 | + } |
|
| 1242 | + } |
|
| 1175 | 1243 | |
| 1176 | 1244 | // Shows a login box. |
| 1177 | 1245 | /** |
@@ -1184,11 +1252,13 @@ discard block |
||
| 1184 | 1252 | { |
| 1185 | 1253 | global $scripturl, $txt, $user_info, $context; |
| 1186 | 1254 | |
| 1187 | - if ($redirect_to != '') |
|
| 1188 | - $_SESSION['login_url'] = $redirect_to; |
|
| 1255 | + if ($redirect_to != '') { |
|
| 1256 | + $_SESSION['login_url'] = $redirect_to; |
|
| 1257 | + } |
|
| 1189 | 1258 | |
| 1190 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
| 1191 | - return $user_info['is_guest']; |
|
| 1259 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
| 1260 | + return $user_info['is_guest']; |
|
| 1261 | + } |
|
| 1192 | 1262 | |
| 1193 | 1263 | // Create a login token |
| 1194 | 1264 | createToken('login'); |
@@ -1240,8 +1310,9 @@ discard block |
||
| 1240 | 1310 | |
| 1241 | 1311 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
| 1242 | 1312 | |
| 1243 | - if (empty($boardsAllowed)) |
|
| 1244 | - return array(); |
|
| 1313 | + if (empty($boardsAllowed)) { |
|
| 1314 | + return array(); |
|
| 1315 | + } |
|
| 1245 | 1316 | |
| 1246 | 1317 | $request = $smcFunc['db_query']('', ' |
| 1247 | 1318 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1274,12 +1345,14 @@ discard block |
||
| 1274 | 1345 | $smcFunc['db_free_result']($request); |
| 1275 | 1346 | |
| 1276 | 1347 | // This user has voted on all the polls. |
| 1277 | - if (empty($row) || !is_array($row)) |
|
| 1278 | - return array(); |
|
| 1348 | + if (empty($row) || !is_array($row)) { |
|
| 1349 | + return array(); |
|
| 1350 | + } |
|
| 1279 | 1351 | |
| 1280 | 1352 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
| 1281 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
| 1282 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1353 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
| 1354 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1355 | + } |
|
| 1283 | 1356 | |
| 1284 | 1357 | $request = $smcFunc['db_query']('', ' |
| 1285 | 1358 | SELECT COUNT(DISTINCT id_member) |
@@ -1343,8 +1416,9 @@ discard block |
||
| 1343 | 1416 | // If mods want to do somthing with this list of polls, let them do that now. |
| 1344 | 1417 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
| 1345 | 1418 | |
| 1346 | - if ($output_method != 'echo') |
|
| 1347 | - return $return; |
|
| 1419 | + if ($output_method != 'echo') { |
|
| 1420 | + return $return; |
|
| 1421 | + } |
|
| 1348 | 1422 | |
| 1349 | 1423 | if ($allow_view_results) |
| 1350 | 1424 | { |
@@ -1353,19 +1427,20 @@ discard block |
||
| 1353 | 1427 | <strong>', $return['question'], '</strong><br> |
| 1354 | 1428 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1355 | 1429 | |
| 1356 | - foreach ($return['options'] as $option) |
|
| 1357 | - echo ' |
|
| 1430 | + foreach ($return['options'] as $option) { |
|
| 1431 | + echo ' |
|
| 1358 | 1432 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1433 | + } |
|
| 1359 | 1434 | |
| 1360 | 1435 | echo ' |
| 1361 | 1436 | <input type="submit" value="', $txt['poll_vote'], '" class="button_submit"> |
| 1362 | 1437 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1363 | 1438 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1364 | 1439 | </form>'; |
| 1440 | + } else { |
|
| 1441 | + echo $txt['poll_cannot_see']; |
|
| 1442 | + } |
|
| 1365 | 1443 | } |
| 1366 | - else |
|
| 1367 | - echo $txt['poll_cannot_see']; |
|
| 1368 | -} |
|
| 1369 | 1444 | |
| 1370 | 1445 | /** |
| 1371 | 1446 | * Shows the poll from the specified topic |
@@ -1379,13 +1454,15 @@ discard block |
||
| 1379 | 1454 | |
| 1380 | 1455 | $boardsAllowed = boardsAllowedTo('poll_view'); |
| 1381 | 1456 | |
| 1382 | - if (empty($boardsAllowed)) |
|
| 1383 | - return array(); |
|
| 1457 | + if (empty($boardsAllowed)) { |
|
| 1458 | + return array(); |
|
| 1459 | + } |
|
| 1384 | 1460 | |
| 1385 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
| 1386 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1387 | - else |
|
| 1388 | - $topic = (int) $topic; |
|
| 1461 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
| 1462 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1463 | + } else { |
|
| 1464 | + $topic = (int) $topic; |
|
| 1465 | + } |
|
| 1389 | 1466 | |
| 1390 | 1467 | $request = $smcFunc['db_query']('', ' |
| 1391 | 1468 | SELECT |
@@ -1406,17 +1483,18 @@ discard block |
||
| 1406 | 1483 | ); |
| 1407 | 1484 | |
| 1408 | 1485 | // Either this topic has no poll, or the user cannot view it. |
| 1409 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1410 | - return array(); |
|
| 1486 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1487 | + return array(); |
|
| 1488 | + } |
|
| 1411 | 1489 | |
| 1412 | 1490 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1413 | 1491 | $smcFunc['db_free_result']($request); |
| 1414 | 1492 | |
| 1415 | 1493 | // Check if they can vote. |
| 1416 | 1494 | $already_voted = false; |
| 1417 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
| 1418 | - $allow_vote = false; |
|
| 1419 | - elseif ($user_info['is_guest']) |
|
| 1495 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
| 1496 | + $allow_vote = false; |
|
| 1497 | + } elseif ($user_info['is_guest']) |
|
| 1420 | 1498 | { |
| 1421 | 1499 | // There's a difference between "allowed to vote" and "already voted"... |
| 1422 | 1500 | $allow_vote = $row['guest_vote']; |
@@ -1426,10 +1504,9 @@ discard block |
||
| 1426 | 1504 | { |
| 1427 | 1505 | $already_voted = true; |
| 1428 | 1506 | } |
| 1429 | - } |
|
| 1430 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
| 1431 | - $allow_vote = false; |
|
| 1432 | - else |
|
| 1507 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
| 1508 | + $allow_vote = false; |
|
| 1509 | + } else |
|
| 1433 | 1510 | { |
| 1434 | 1511 | $request = $smcFunc['db_query']('', ' |
| 1435 | 1512 | SELECT id_member |
@@ -1511,8 +1588,9 @@ discard block |
||
| 1511 | 1588 | // If mods want to do somthing with this poll, let them do that now. |
| 1512 | 1589 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
| 1513 | 1590 | |
| 1514 | - if ($output_method != 'echo') |
|
| 1515 | - return $return; |
|
| 1591 | + if ($output_method != 'echo') { |
|
| 1592 | + return $return; |
|
| 1593 | + } |
|
| 1516 | 1594 | |
| 1517 | 1595 | if ($return['allow_vote']) |
| 1518 | 1596 | { |
@@ -1521,17 +1599,17 @@ discard block |
||
| 1521 | 1599 | <strong>', $return['question'], '</strong><br> |
| 1522 | 1600 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1523 | 1601 | |
| 1524 | - foreach ($return['options'] as $option) |
|
| 1525 | - echo ' |
|
| 1602 | + foreach ($return['options'] as $option) { |
|
| 1603 | + echo ' |
|
| 1526 | 1604 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1605 | + } |
|
| 1527 | 1606 | |
| 1528 | 1607 | echo ' |
| 1529 | 1608 | <input type="submit" value="', $txt['poll_vote'], '" class="button_submit"> |
| 1530 | 1609 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1531 | 1610 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1532 | 1611 | </form>'; |
| 1533 | - } |
|
| 1534 | - else |
|
| 1612 | + } else |
|
| 1535 | 1613 | { |
| 1536 | 1614 | echo ' |
| 1537 | 1615 | <div class="ssi_poll"> |
@@ -1611,27 +1689,32 @@ discard block |
||
| 1611 | 1689 | 'is_approved' => 1, |
| 1612 | 1690 | ) |
| 1613 | 1691 | ); |
| 1614 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1615 | - die; |
|
| 1692 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1693 | + die; |
|
| 1694 | + } |
|
| 1616 | 1695 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1617 | 1696 | $smcFunc['db_free_result']($request); |
| 1618 | 1697 | |
| 1619 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
| 1620 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1698 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
| 1699 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1700 | + } |
|
| 1621 | 1701 | |
| 1622 | 1702 | // Too many options checked? |
| 1623 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
| 1624 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1703 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
| 1704 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1705 | + } |
|
| 1625 | 1706 | |
| 1626 | 1707 | // It's a guest who has already voted? |
| 1627 | 1708 | if ($user_info['is_guest']) |
| 1628 | 1709 | { |
| 1629 | 1710 | // Guest voting disabled? |
| 1630 | - if (!$row['guest_vote']) |
|
| 1631 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1711 | + if (!$row['guest_vote']) { |
|
| 1712 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1713 | + } |
|
| 1632 | 1714 | // Already voted? |
| 1633 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
| 1634 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1715 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
| 1716 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1717 | + } |
|
| 1635 | 1718 | } |
| 1636 | 1719 | |
| 1637 | 1720 | $sOptions = array(); |
@@ -1685,11 +1768,13 @@ discard block |
||
| 1685 | 1768 | { |
| 1686 | 1769 | global $scripturl, $txt, $context; |
| 1687 | 1770 | |
| 1688 | - if (!allowedTo('search_posts')) |
|
| 1689 | - return; |
|
| 1771 | + if (!allowedTo('search_posts')) { |
|
| 1772 | + return; |
|
| 1773 | + } |
|
| 1690 | 1774 | |
| 1691 | - if ($output_method != 'echo') |
|
| 1692 | - return $scripturl . '?action=search'; |
|
| 1775 | + if ($output_method != 'echo') { |
|
| 1776 | + return $scripturl . '?action=search'; |
|
| 1777 | + } |
|
| 1693 | 1778 | |
| 1694 | 1779 | echo ' |
| 1695 | 1780 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1711,8 +1796,9 @@ discard block |
||
| 1711 | 1796 | // 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. |
| 1712 | 1797 | call_integration_hook('integrate_ssi_news'); |
| 1713 | 1798 | |
| 1714 | - if ($output_method != 'echo') |
|
| 1715 | - return $context['random_news_line']; |
|
| 1799 | + if ($output_method != 'echo') { |
|
| 1800 | + return $context['random_news_line']; |
|
| 1801 | + } |
|
| 1716 | 1802 | |
| 1717 | 1803 | echo $context['random_news_line']; |
| 1718 | 1804 | } |
@@ -1726,8 +1812,9 @@ discard block |
||
| 1726 | 1812 | { |
| 1727 | 1813 | global $scripturl, $modSettings, $user_info; |
| 1728 | 1814 | |
| 1729 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
| 1730 | - return; |
|
| 1815 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
| 1816 | + return; |
|
| 1817 | + } |
|
| 1731 | 1818 | |
| 1732 | 1819 | $eventOptions = array( |
| 1733 | 1820 | 'include_birthdays' => true, |
@@ -1738,13 +1825,15 @@ discard block |
||
| 1738 | 1825 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1739 | 1826 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1740 | 1827 | |
| 1741 | - if ($output_method != 'echo') |
|
| 1742 | - return $return['calendar_birthdays']; |
|
| 1828 | + if ($output_method != 'echo') { |
|
| 1829 | + return $return['calendar_birthdays']; |
|
| 1830 | + } |
|
| 1743 | 1831 | |
| 1744 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1745 | - echo ' |
|
| 1832 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1833 | + echo ' |
|
| 1746 | 1834 | <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'] ? ', ' : ''); |
| 1747 | -} |
|
| 1835 | + } |
|
| 1836 | + } |
|
| 1748 | 1837 | |
| 1749 | 1838 | /** |
| 1750 | 1839 | * Shows today's holidays. |
@@ -1755,8 +1844,9 @@ discard block |
||
| 1755 | 1844 | { |
| 1756 | 1845 | global $modSettings, $user_info; |
| 1757 | 1846 | |
| 1758 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1759 | - return; |
|
| 1847 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1848 | + return; |
|
| 1849 | + } |
|
| 1760 | 1850 | |
| 1761 | 1851 | $eventOptions = array( |
| 1762 | 1852 | 'include_holidays' => true, |
@@ -1767,8 +1857,9 @@ discard block |
||
| 1767 | 1857 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1768 | 1858 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1769 | 1859 | |
| 1770 | - if ($output_method != 'echo') |
|
| 1771 | - return $return['calendar_holidays']; |
|
| 1860 | + if ($output_method != 'echo') { |
|
| 1861 | + return $return['calendar_holidays']; |
|
| 1862 | + } |
|
| 1772 | 1863 | |
| 1773 | 1864 | echo ' |
| 1774 | 1865 | ', implode(', ', $return['calendar_holidays']); |
@@ -1782,8 +1873,9 @@ discard block |
||
| 1782 | 1873 | { |
| 1783 | 1874 | global $modSettings, $user_info; |
| 1784 | 1875 | |
| 1785 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1786 | - return; |
|
| 1876 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1877 | + return; |
|
| 1878 | + } |
|
| 1787 | 1879 | |
| 1788 | 1880 | $eventOptions = array( |
| 1789 | 1881 | 'include_events' => true, |
@@ -1794,14 +1886,16 @@ discard block |
||
| 1794 | 1886 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1795 | 1887 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1796 | 1888 | |
| 1797 | - if ($output_method != 'echo') |
|
| 1798 | - return $return['calendar_events']; |
|
| 1889 | + if ($output_method != 'echo') { |
|
| 1890 | + return $return['calendar_events']; |
|
| 1891 | + } |
|
| 1799 | 1892 | |
| 1800 | 1893 | foreach ($return['calendar_events'] as $event) |
| 1801 | 1894 | { |
| 1802 | - if ($event['can_edit']) |
|
| 1803 | - echo ' |
|
| 1895 | + if ($event['can_edit']) { |
|
| 1896 | + echo ' |
|
| 1804 | 1897 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1898 | + } |
|
| 1805 | 1899 | echo ' |
| 1806 | 1900 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1807 | 1901 | } |
@@ -1816,8 +1910,9 @@ discard block |
||
| 1816 | 1910 | { |
| 1817 | 1911 | global $modSettings, $txt, $scripturl, $user_info; |
| 1818 | 1912 | |
| 1819 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1820 | - return; |
|
| 1913 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1914 | + return; |
|
| 1915 | + } |
|
| 1821 | 1916 | |
| 1822 | 1917 | $eventOptions = array( |
| 1823 | 1918 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1830,19 +1925,22 @@ discard block |
||
| 1830 | 1925 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1831 | 1926 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1832 | 1927 | |
| 1833 | - if ($output_method != 'echo') |
|
| 1834 | - return $return; |
|
| 1928 | + if ($output_method != 'echo') { |
|
| 1929 | + return $return; |
|
| 1930 | + } |
|
| 1835 | 1931 | |
| 1836 | - if (!empty($return['calendar_holidays'])) |
|
| 1837 | - echo ' |
|
| 1932 | + if (!empty($return['calendar_holidays'])) { |
|
| 1933 | + echo ' |
|
| 1838 | 1934 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
| 1935 | + } |
|
| 1839 | 1936 | if (!empty($return['calendar_birthdays'])) |
| 1840 | 1937 | { |
| 1841 | 1938 | echo ' |
| 1842 | 1939 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
| 1843 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1844 | - echo ' |
|
| 1940 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1941 | + echo ' |
|
| 1845 | 1942 | <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'] ? ', ' : ''; |
| 1943 | + } |
|
| 1846 | 1944 | echo ' |
| 1847 | 1945 | <br>'; |
| 1848 | 1946 | } |
@@ -1852,9 +1950,10 @@ discard block |
||
| 1852 | 1950 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
| 1853 | 1951 | foreach ($return['calendar_events'] as $event) |
| 1854 | 1952 | { |
| 1855 | - if ($event['can_edit']) |
|
| 1856 | - echo ' |
|
| 1953 | + if ($event['can_edit']) { |
|
| 1954 | + echo ' |
|
| 1857 | 1955 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1956 | + } |
|
| 1858 | 1957 | echo ' |
| 1859 | 1958 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1860 | 1959 | } |
@@ -1878,25 +1977,29 @@ discard block |
||
| 1878 | 1977 | loadLanguage('Stats'); |
| 1879 | 1978 | |
| 1880 | 1979 | // Must be integers.... |
| 1881 | - if ($limit === null) |
|
| 1882 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1883 | - else |
|
| 1884 | - $limit = (int) $limit; |
|
| 1885 | - |
|
| 1886 | - if ($start === null) |
|
| 1887 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1888 | - else |
|
| 1889 | - $start = (int) $start; |
|
| 1890 | - |
|
| 1891 | - if ($board !== null) |
|
| 1892 | - $board = (int) $board; |
|
| 1893 | - elseif (isset($_GET['board'])) |
|
| 1894 | - $board = (int) $_GET['board']; |
|
| 1895 | - |
|
| 1896 | - if ($length === null) |
|
| 1897 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1898 | - else |
|
| 1899 | - $length = (int) $length; |
|
| 1980 | + if ($limit === null) { |
|
| 1981 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1982 | + } else { |
|
| 1983 | + $limit = (int) $limit; |
|
| 1984 | + } |
|
| 1985 | + |
|
| 1986 | + if ($start === null) { |
|
| 1987 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1988 | + } else { |
|
| 1989 | + $start = (int) $start; |
|
| 1990 | + } |
|
| 1991 | + |
|
| 1992 | + if ($board !== null) { |
|
| 1993 | + $board = (int) $board; |
|
| 1994 | + } elseif (isset($_GET['board'])) { |
|
| 1995 | + $board = (int) $_GET['board']; |
|
| 1996 | + } |
|
| 1997 | + |
|
| 1998 | + if ($length === null) { |
|
| 1999 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 2000 | + } else { |
|
| 2001 | + $length = (int) $length; |
|
| 2002 | + } |
|
| 1900 | 2003 | |
| 1901 | 2004 | $limit = max(0, $limit); |
| 1902 | 2005 | $start = max(0, $start); |
@@ -1914,17 +2017,19 @@ discard block |
||
| 1914 | 2017 | ); |
| 1915 | 2018 | if ($smcFunc['db_num_rows']($request) == 0) |
| 1916 | 2019 | { |
| 1917 | - if ($output_method == 'echo') |
|
| 1918 | - die($txt['ssi_no_guests']); |
|
| 1919 | - else |
|
| 1920 | - return array(); |
|
| 2020 | + if ($output_method == 'echo') { |
|
| 2021 | + die($txt['ssi_no_guests']); |
|
| 2022 | + } else { |
|
| 2023 | + return array(); |
|
| 2024 | + } |
|
| 1921 | 2025 | } |
| 1922 | 2026 | list ($board) = $smcFunc['db_fetch_row']($request); |
| 1923 | 2027 | $smcFunc['db_free_result']($request); |
| 1924 | 2028 | |
| 1925 | 2029 | $icon_sources = array(); |
| 1926 | - foreach ($context['stable_icons'] as $icon) |
|
| 1927 | - $icon_sources[$icon] = 'images_url'; |
|
| 2030 | + foreach ($context['stable_icons'] as $icon) { |
|
| 2031 | + $icon_sources[$icon] = 'images_url'; |
|
| 2032 | + } |
|
| 1928 | 2033 | |
| 1929 | 2034 | if (!empty($modSettings['enable_likes'])) |
| 1930 | 2035 | { |
@@ -1948,12 +2053,14 @@ discard block |
||
| 1948 | 2053 | ) |
| 1949 | 2054 | ); |
| 1950 | 2055 | $posts = array(); |
| 1951 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1952 | - $posts[] = $row['id_first_msg']; |
|
| 2056 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2057 | + $posts[] = $row['id_first_msg']; |
|
| 2058 | + } |
|
| 1953 | 2059 | $smcFunc['db_free_result']($request); |
| 1954 | 2060 | |
| 1955 | - if (empty($posts)) |
|
| 1956 | - return array(); |
|
| 2061 | + if (empty($posts)) { |
|
| 2062 | + return array(); |
|
| 2063 | + } |
|
| 1957 | 2064 | |
| 1958 | 2065 | // Find the posts. |
| 1959 | 2066 | $request = $smcFunc['db_query']('', ' |
@@ -1983,24 +2090,28 @@ discard block |
||
| 1983 | 2090 | $last_space = strrpos($row['body'], ' '); |
| 1984 | 2091 | $last_open = strrpos($row['body'], '<'); |
| 1985 | 2092 | $last_close = strrpos($row['body'], '>'); |
| 1986 | - 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) |
|
| 1987 | - $cutoff = $last_open; |
|
| 1988 | - elseif (empty($last_close) || $last_close < $last_open) |
|
| 1989 | - $cutoff = $last_space; |
|
| 2093 | + 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) { |
|
| 2094 | + $cutoff = $last_open; |
|
| 2095 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
| 2096 | + $cutoff = $last_space; |
|
| 2097 | + } |
|
| 1990 | 2098 | |
| 1991 | - if ($cutoff !== false) |
|
| 1992 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2099 | + if ($cutoff !== false) { |
|
| 2100 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2101 | + } |
|
| 1993 | 2102 | $row['body'] .= '...'; |
| 1994 | 2103 | } |
| 1995 | 2104 | |
| 1996 | 2105 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 1997 | 2106 | |
| 1998 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
| 1999 | - $row['icon'] = 'recycled'; |
|
| 2107 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
| 2108 | + $row['icon'] = 'recycled'; |
|
| 2109 | + } |
|
| 2000 | 2110 | |
| 2001 | 2111 | // Check that this message icon is there... |
| 2002 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 2003 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2112 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 2113 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2114 | + } |
|
| 2004 | 2115 | |
| 2005 | 2116 | censorText($row['subject']); |
| 2006 | 2117 | censorText($row['body']); |
@@ -2037,16 +2148,18 @@ discard block |
||
| 2037 | 2148 | } |
| 2038 | 2149 | $smcFunc['db_free_result']($request); |
| 2039 | 2150 | |
| 2040 | - if (empty($return)) |
|
| 2041 | - return $return; |
|
| 2151 | + if (empty($return)) { |
|
| 2152 | + return $return; |
|
| 2153 | + } |
|
| 2042 | 2154 | |
| 2043 | 2155 | $return[count($return) - 1]['is_last'] = true; |
| 2044 | 2156 | |
| 2045 | 2157 | // If mods want to do somthing with this list of posts, let them do that now. |
| 2046 | 2158 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
| 2047 | 2159 | |
| 2048 | - if ($output_method != 'echo') |
|
| 2049 | - return $return; |
|
| 2160 | + if ($output_method != 'echo') { |
|
| 2161 | + return $return; |
|
| 2162 | + } |
|
| 2050 | 2163 | |
| 2051 | 2164 | foreach ($return as $news) |
| 2052 | 2165 | { |
@@ -2098,9 +2211,10 @@ discard block |
||
| 2098 | 2211 | echo ' |
| 2099 | 2212 | </div>'; |
| 2100 | 2213 | |
| 2101 | - if (!$news['is_last']) |
|
| 2102 | - echo ' |
|
| 2214 | + if (!$news['is_last']) { |
|
| 2215 | + echo ' |
|
| 2103 | 2216 | <hr>'; |
| 2217 | + } |
|
| 2104 | 2218 | } |
| 2105 | 2219 | } |
| 2106 | 2220 | |
@@ -2114,8 +2228,9 @@ discard block |
||
| 2114 | 2228 | { |
| 2115 | 2229 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
| 2116 | 2230 | |
| 2117 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 2118 | - return; |
|
| 2231 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 2232 | + return; |
|
| 2233 | + } |
|
| 2119 | 2234 | |
| 2120 | 2235 | // Find all events which are happening in the near future that the member can see. |
| 2121 | 2236 | $request = $smcFunc['db_query']('', ' |
@@ -2141,20 +2256,23 @@ discard block |
||
| 2141 | 2256 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2142 | 2257 | { |
| 2143 | 2258 | // 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. |
| 2144 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
| 2145 | - continue; |
|
| 2259 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
| 2260 | + continue; |
|
| 2261 | + } |
|
| 2146 | 2262 | |
| 2147 | 2263 | // Censor the title. |
| 2148 | 2264 | censorText($row['title']); |
| 2149 | 2265 | |
| 2150 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
| 2151 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2152 | - else |
|
| 2153 | - $date = $row['start_date']; |
|
| 2266 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
| 2267 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2268 | + } else { |
|
| 2269 | + $date = $row['start_date']; |
|
| 2270 | + } |
|
| 2154 | 2271 | |
| 2155 | 2272 | // If the topic it is attached to is not approved then don't link it. |
| 2156 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
| 2157 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2273 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
| 2274 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2275 | + } |
|
| 2158 | 2276 | |
| 2159 | 2277 | $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; |
| 2160 | 2278 | |
@@ -2180,24 +2298,27 @@ discard block |
||
| 2180 | 2298 | } |
| 2181 | 2299 | $smcFunc['db_free_result']($request); |
| 2182 | 2300 | |
| 2183 | - foreach ($return as $mday => $array) |
|
| 2184 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2301 | + foreach ($return as $mday => $array) { |
|
| 2302 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2303 | + } |
|
| 2185 | 2304 | |
| 2186 | 2305 | // If mods want to do somthing with this list of events, let them do that now. |
| 2187 | 2306 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
| 2188 | 2307 | |
| 2189 | - if ($output_method != 'echo' || empty($return)) |
|
| 2190 | - return $return; |
|
| 2308 | + if ($output_method != 'echo' || empty($return)) { |
|
| 2309 | + return $return; |
|
| 2310 | + } |
|
| 2191 | 2311 | |
| 2192 | 2312 | // Well the output method is echo. |
| 2193 | 2313 | echo ' |
| 2194 | 2314 | <span class="event">' . $txt['events'] . '</span> '; |
| 2195 | - foreach ($return as $mday => $array) |
|
| 2196 | - foreach ($array as $event) |
|
| 2315 | + foreach ($return as $mday => $array) { |
|
| 2316 | + foreach ($array as $event) |
|
| 2197 | 2317 | { |
| 2198 | 2318 | if ($event['can_edit']) |
| 2199 | 2319 | echo ' |
| 2200 | 2320 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 2321 | + } |
|
| 2201 | 2322 | |
| 2202 | 2323 | echo ' |
| 2203 | 2324 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2216,8 +2337,9 @@ discard block |
||
| 2216 | 2337 | global $smcFunc; |
| 2217 | 2338 | |
| 2218 | 2339 | // If $id is null, this was most likely called from a query string and should do nothing. |
| 2219 | - if ($id === null) |
|
| 2220 | - return; |
|
| 2340 | + if ($id === null) { |
|
| 2341 | + return; |
|
| 2342 | + } |
|
| 2221 | 2343 | |
| 2222 | 2344 | $request = $smcFunc['db_query']('', ' |
| 2223 | 2345 | SELECT passwd, member_name, is_activated |
@@ -2249,8 +2371,9 @@ discard block |
||
| 2249 | 2371 | $attachments_boards = boardsAllowedTo('view_attachments'); |
| 2250 | 2372 | |
| 2251 | 2373 | // No boards? Adios amigo. |
| 2252 | - if (empty($attachments_boards)) |
|
| 2253 | - return array(); |
|
| 2374 | + if (empty($attachments_boards)) { |
|
| 2375 | + return array(); |
|
| 2376 | + } |
|
| 2254 | 2377 | |
| 2255 | 2378 | // Is it an array? |
| 2256 | 2379 | $attachment_ext = (array) $attachment_ext; |
@@ -2334,8 +2457,9 @@ discard block |
||
| 2334 | 2457 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
| 2335 | 2458 | |
| 2336 | 2459 | // So you just want an array? Here you can have it. |
| 2337 | - if ($output_method == 'array' || empty($attachments)) |
|
| 2338 | - return $attachments; |
|
| 2460 | + if ($output_method == 'array' || empty($attachments)) { |
|
| 2461 | + return $attachments; |
|
| 2462 | + } |
|
| 2339 | 2463 | |
| 2340 | 2464 | // Give them the default. |
| 2341 | 2465 | echo ' |
@@ -2346,14 +2470,15 @@ discard block |
||
| 2346 | 2470 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
| 2347 | 2471 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
| 2348 | 2472 | </tr>'; |
| 2349 | - foreach ($attachments as $attach) |
|
| 2350 | - echo ' |
|
| 2473 | + foreach ($attachments as $attach) { |
|
| 2474 | + echo ' |
|
| 2351 | 2475 | <tr> |
| 2352 | 2476 | <td>', $attach['file']['link'], '</td> |
| 2353 | 2477 | <td>', $attach['member']['link'], '</td> |
| 2354 | 2478 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
| 2355 | 2479 | <td>', $attach['file']['filesize'], '</td> |
| 2356 | 2480 | </tr>'; |
| 2481 | + } |
|
| 2357 | 2482 | echo ' |
| 2358 | 2483 | </table>'; |
| 2359 | 2484 | } |