@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | // This defines two version types for checking the API's are compatible with this version of SMF. |
| 20 | 21 | $GLOBALS['search_versions'] = array( |
@@ -39,8 +40,9 @@ discard block |
||
| 39 | 40 | global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir; |
| 40 | 41 | |
| 41 | 42 | // Is the load average too high to allow searching just now? |
| 42 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 43 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 43 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 44 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | loadLanguage('Search'); |
| 46 | 48 | // Don't load this in XML mode. |
@@ -88,23 +90,30 @@ discard block |
||
| 88 | 90 | @list ($k, $v) = explode('|\'|', $data); |
| 89 | 91 | $context['search_params'][$k] = $v; |
| 90 | 92 | } |
| 91 | - if (isset($context['search_params']['brd'])) |
|
| 92 | - $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
| 93 | + if (isset($context['search_params']['brd'])) { |
|
| 94 | + $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
| 95 | + } |
|
| 93 | 96 | } |
| 94 | 97 | |
| 95 | - if (isset($_REQUEST['search'])) |
|
| 96 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 98 | + if (isset($_REQUEST['search'])) { |
|
| 99 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 100 | + } |
|
| 97 | 101 | |
| 98 | - if (isset($context['search_params']['search'])) |
|
| 99 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 100 | - if (isset($context['search_params']['userspec'])) |
|
| 101 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 102 | - if (!empty($context['search_params']['searchtype'])) |
|
| 103 | - $context['search_params']['searchtype'] = 2; |
|
| 104 | - if (!empty($context['search_params']['minage'])) |
|
| 105 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 106 | - if (!empty($context['search_params']['maxage'])) |
|
| 107 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 102 | + if (isset($context['search_params']['search'])) { |
|
| 103 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 104 | + } |
|
| 105 | + if (isset($context['search_params']['userspec'])) { |
|
| 106 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 107 | + } |
|
| 108 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 109 | + $context['search_params']['searchtype'] = 2; |
|
| 110 | + } |
|
| 111 | + if (!empty($context['search_params']['minage'])) { |
|
| 112 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 113 | + } |
|
| 114 | + if (!empty($context['search_params']['maxage'])) { |
|
| 115 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 116 | + } |
|
| 108 | 117 | |
| 109 | 118 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
| 110 | 119 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -116,11 +125,13 @@ discard block |
||
| 116 | 125 | $context['search_errors']['messages'] = array(); |
| 117 | 126 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 118 | 127 | { |
| 119 | - if ($search_error === 'messages') |
|
| 120 | - continue; |
|
| 128 | + if ($search_error === 'messages') { |
|
| 129 | + continue; |
|
| 130 | + } |
|
| 121 | 131 | |
| 122 | - if ($search_error == 'string_too_long') |
|
| 123 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
| 132 | + if ($search_error == 'string_too_long') { |
|
| 133 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
| 134 | + } |
|
| 124 | 135 | |
| 125 | 136 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 126 | 137 | } |
@@ -143,12 +154,13 @@ discard block |
||
| 143 | 154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 144 | 155 | { |
| 145 | 156 | // This category hasn't been set up yet.. |
| 146 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 147 | - $context['categories'][$row['id_cat']] = array( |
|
| 157 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 158 | + $context['categories'][$row['id_cat']] = array( |
|
| 148 | 159 | 'id' => $row['id_cat'], |
| 149 | 160 | 'name' => $row['cat_name'], |
| 150 | 161 | 'boards' => array() |
| 151 | 162 | ); |
| 163 | + } |
|
| 152 | 164 | |
| 153 | 165 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 154 | 166 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -159,8 +171,9 @@ discard block |
||
| 159 | 171 | ); |
| 160 | 172 | |
| 161 | 173 | // If a board wasn't checked that probably should have been ensure the board selection is selected, yo! |
| 162 | - if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) |
|
| 163 | - $context['boards_check_all'] = false; |
|
| 174 | + if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) { |
|
| 175 | + $context['boards_check_all'] = false; |
|
| 176 | + } |
|
| 164 | 177 | } |
| 165 | 178 | $smcFunc['db_free_result']($request); |
| 166 | 179 | |
@@ -182,18 +195,20 @@ discard block |
||
| 182 | 195 | } |
| 183 | 196 | |
| 184 | 197 | $max_boards = ceil(count($temp_boards) / 2); |
| 185 | - if ($max_boards == 1) |
|
| 186 | - $max_boards = 2; |
|
| 198 | + if ($max_boards == 1) { |
|
| 199 | + $max_boards = 2; |
|
| 200 | + } |
|
| 187 | 201 | |
| 188 | 202 | // Now, alternate them so they can be shown left and right ;). |
| 189 | 203 | $context['board_columns'] = array(); |
| 190 | 204 | for ($i = 0; $i < $max_boards; $i++) |
| 191 | 205 | { |
| 192 | 206 | $context['board_columns'][] = $temp_boards[$i]; |
| 193 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 194 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 195 | - else |
|
| 196 | - $context['board_columns'][] = array(); |
|
| 207 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 208 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 209 | + } else { |
|
| 210 | + $context['board_columns'][] = array(); |
|
| 211 | + } |
|
| 197 | 212 | } |
| 198 | 213 | |
| 199 | 214 | if (!empty($_REQUEST['topic'])) |
@@ -225,8 +240,9 @@ discard block |
||
| 225 | 240 | ) |
| 226 | 241 | ); |
| 227 | 242 | |
| 228 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 229 | - fatal_lang_error('topic_gone', false); |
|
| 243 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 244 | + fatal_lang_error('topic_gone', false); |
|
| 245 | + } |
|
| 230 | 246 | |
| 231 | 247 | list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request); |
| 232 | 248 | $smcFunc['db_free_result']($request); |
@@ -256,11 +272,13 @@ discard block |
||
| 256 | 272 | global $excludedWords, $participants, $smcFunc; |
| 257 | 273 | |
| 258 | 274 | // if comming from the quick search box, and we want to search on members, well we need to do that ;) |
| 259 | - if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') |
|
| 260 | - redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
| 275 | + if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') { |
|
| 276 | + redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
| 277 | + } |
|
| 261 | 278 | |
| 262 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 263 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 279 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 280 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 281 | + } |
|
| 264 | 282 | |
| 265 | 283 | // No, no, no... this is a bit hard on the server, so don't you go prefetching it! |
| 266 | 284 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -307,8 +325,9 @@ discard block |
||
| 307 | 325 | } |
| 308 | 326 | |
| 309 | 327 | // Zero weight. Weightless :P. |
| 310 | - if (empty($weight_total)) |
|
| 311 | - fatal_lang_error('search_invalid_weights'); |
|
| 328 | + if (empty($weight_total)) { |
|
| 329 | + fatal_lang_error('search_invalid_weights'); |
|
| 330 | + } |
|
| 312 | 331 | |
| 313 | 332 | // These vars don't require an interface, they're just here for tweaking. |
| 314 | 333 | $recentPercentage = 0.30; |
@@ -326,11 +345,13 @@ discard block |
||
| 326 | 345 | $context['search_string_limit'] = 100; |
| 327 | 346 | |
| 328 | 347 | loadLanguage('Search'); |
| 329 | - if (!isset($_REQUEST['xml'])) |
|
| 330 | - loadTemplate('Search'); |
|
| 348 | + if (!isset($_REQUEST['xml'])) { |
|
| 349 | + loadTemplate('Search'); |
|
| 350 | + } |
|
| 331 | 351 | //If we're doing XML we need to use the results template regardless really. |
| 332 | - else |
|
| 333 | - $context['sub_template'] = 'results'; |
|
| 352 | + else { |
|
| 353 | + $context['sub_template'] = 'results'; |
|
| 354 | + } |
|
| 334 | 355 | |
| 335 | 356 | // Are you allowed? |
| 336 | 357 | isAllowedTo('search_posts'); |
@@ -363,34 +384,39 @@ discard block |
||
| 363 | 384 | $search_params[$k] = $v; |
| 364 | 385 | } |
| 365 | 386 | |
| 366 | - if (isset($search_params['brd'])) |
|
| 367 | - $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
| 387 | + if (isset($search_params['brd'])) { |
|
| 388 | + $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
| 389 | + } |
|
| 368 | 390 | } |
| 369 | 391 | |
| 370 | 392 | // Store whether simple search was used (needed if the user wants to do another query). |
| 371 | - if (!isset($search_params['advanced'])) |
|
| 372 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 393 | + if (!isset($search_params['advanced'])) { |
|
| 394 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 395 | + } |
|
| 373 | 396 | |
| 374 | 397 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 375 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 376 | - $search_params['searchtype'] = 2; |
|
| 398 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 399 | + $search_params['searchtype'] = 2; |
|
| 400 | + } |
|
| 377 | 401 | |
| 378 | 402 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 379 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 380 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 403 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 404 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 405 | + } |
|
| 381 | 406 | |
| 382 | 407 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 383 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) |
|
| 384 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 408 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) { |
|
| 409 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 410 | + } |
|
| 385 | 411 | |
| 386 | 412 | // Searching a specific topic? |
| 387 | 413 | if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic')) |
| 388 | 414 | { |
| 389 | 415 | $search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : ''); |
| 390 | 416 | $search_params['show_complete'] = true; |
| 417 | + } elseif (!empty($search_params['topic'])) { |
|
| 418 | + $search_params['topic'] = (int) $search_params['topic']; |
|
| 391 | 419 | } |
| 392 | - elseif (!empty($search_params['topic'])) |
|
| 393 | - $search_params['topic'] = (int) $search_params['topic']; |
|
| 394 | 420 | |
| 395 | 421 | if (!empty($search_params['minage']) || !empty($search_params['maxage'])) |
| 396 | 422 | { |
@@ -408,19 +434,21 @@ discard block |
||
| 408 | 434 | ) |
| 409 | 435 | ); |
| 410 | 436 | list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request); |
| 411 | - if ($minMsgID < 0 || $maxMsgID < 0) |
|
| 412 | - $context['search_errors']['no_messages_in_time_frame'] = true; |
|
| 437 | + if ($minMsgID < 0 || $maxMsgID < 0) { |
|
| 438 | + $context['search_errors']['no_messages_in_time_frame'] = true; |
|
| 439 | + } |
|
| 413 | 440 | $smcFunc['db_free_result']($request); |
| 414 | 441 | } |
| 415 | 442 | |
| 416 | 443 | // Default the user name to a wildcard matching every user (*). |
| 417 | - if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 418 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 444 | + if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 445 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 446 | + } |
|
| 419 | 447 | |
| 420 | 448 | // If there's no specific user, then don't mention it in the main query. |
| 421 | - if (empty($search_params['userspec'])) |
|
| 422 | - $userQuery = ''; |
|
| 423 | - else |
|
| 449 | + if (empty($search_params['userspec'])) { |
|
| 450 | + $userQuery = ''; |
|
| 451 | + } else |
|
| 424 | 452 | { |
| 425 | 453 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 426 | 454 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -432,19 +460,21 @@ discard block |
||
| 432 | 460 | { |
| 433 | 461 | $possible_users[$k] = trim($possible_users[$k]); |
| 434 | 462 | |
| 435 | - if (strlen($possible_users[$k]) == 0) |
|
| 436 | - unset($possible_users[$k]); |
|
| 463 | + if (strlen($possible_users[$k]) == 0) { |
|
| 464 | + unset($possible_users[$k]); |
|
| 465 | + } |
|
| 437 | 466 | } |
| 438 | 467 | |
| 439 | 468 | // Create a list of database-escaped search names. |
| 440 | 469 | $realNameMatches = array(); |
| 441 | - foreach ($possible_users as $possible_user) |
|
| 442 | - $realNameMatches[] = $smcFunc['db_quote']( |
|
| 470 | + foreach ($possible_users as $possible_user) { |
|
| 471 | + $realNameMatches[] = $smcFunc['db_quote']( |
|
| 443 | 472 | '{string:possible_user}', |
| 444 | 473 | array( |
| 445 | 474 | 'possible_user' => $possible_user |
| 446 | 475 | ) |
| 447 | 476 | ); |
| 477 | + } |
|
| 448 | 478 | |
| 449 | 479 | // Retrieve a list of possible members. |
| 450 | 480 | $request = $smcFunc['db_query']('', ' |
@@ -456,9 +486,9 @@ discard block |
||
| 456 | 486 | ) |
| 457 | 487 | ); |
| 458 | 488 | // Simply do nothing if there're too many members matching the criteria. |
| 459 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 460 | - $userQuery = ''; |
|
| 461 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 489 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 490 | + $userQuery = ''; |
|
| 491 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 462 | 492 | { |
| 463 | 493 | $userQuery = $smcFunc['db_quote']( |
| 464 | 494 | 'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})', |
@@ -467,12 +497,12 @@ discard block |
||
| 467 | 497 | 'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches), |
| 468 | 498 | ) |
| 469 | 499 | ); |
| 470 | - } |
|
| 471 | - else |
|
| 500 | + } else |
|
| 472 | 501 | { |
| 473 | 502 | $memberlist = array(); |
| 474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 475 | - $memberlist[] = $row['id_member']; |
|
| 503 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 504 | + $memberlist[] = $row['id_member']; |
|
| 505 | + } |
|
| 476 | 506 | $userQuery = $smcFunc['db_quote']( |
| 477 | 507 | '(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))', |
| 478 | 508 | array( |
@@ -486,22 +516,25 @@ discard block |
||
| 486 | 516 | } |
| 487 | 517 | |
| 488 | 518 | // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST. |
| 489 | - if (!empty($search_params['brd']) && is_array($search_params['brd'])) |
|
| 490 | - $_REQUEST['brd'] = $search_params['brd']; |
|
| 519 | + if (!empty($search_params['brd']) && is_array($search_params['brd'])) { |
|
| 520 | + $_REQUEST['brd'] = $search_params['brd']; |
|
| 521 | + } |
|
| 491 | 522 | |
| 492 | 523 | // Ensure that brd is an array. |
| 493 | 524 | if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board')) |
| 494 | 525 | { |
| 495 | - if (!empty($_REQUEST['brd'])) |
|
| 496 | - $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
| 497 | - else |
|
| 498 | - $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
| 526 | + if (!empty($_REQUEST['brd'])) { |
|
| 527 | + $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
| 528 | + } else { |
|
| 529 | + $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
| 530 | + } |
|
| 499 | 531 | } |
| 500 | 532 | |
| 501 | 533 | // Make sure all boards are integers. |
| 502 | - if (!empty($_REQUEST['brd'])) |
|
| 503 | - foreach ($_REQUEST['brd'] as $id => $brd) |
|
| 534 | + if (!empty($_REQUEST['brd'])) { |
|
| 535 | + foreach ($_REQUEST['brd'] as $id => $brd) |
|
| 504 | 536 | $_REQUEST['brd'][$id] = (int) $brd; |
| 537 | + } |
|
| 505 | 538 | |
| 506 | 539 | // Special case for boards: searching just one topic? |
| 507 | 540 | if (!empty($search_params['topic'])) |
@@ -520,17 +553,18 @@ discard block |
||
| 520 | 553 | ) |
| 521 | 554 | ); |
| 522 | 555 | |
| 523 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 524 | - fatal_lang_error('topic_gone', false); |
|
| 556 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 557 | + fatal_lang_error('topic_gone', false); |
|
| 558 | + } |
|
| 525 | 559 | |
| 526 | 560 | $search_params['brd'] = array(); |
| 527 | 561 | list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request); |
| 528 | 562 | $smcFunc['db_free_result']($request); |
| 529 | 563 | } |
| 530 | 564 | // Select all boards you've selected AND are allowed to see. |
| 531 | - elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) |
|
| 532 | - $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
| 533 | - else |
|
| 565 | + elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) { |
|
| 566 | + $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
| 567 | + } else |
|
| 534 | 568 | { |
| 535 | 569 | $see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board'; |
| 536 | 570 | $request = $smcFunc['db_query']('', ' |
@@ -548,19 +582,22 @@ discard block |
||
| 548 | 582 | ) |
| 549 | 583 | ); |
| 550 | 584 | $search_params['brd'] = array(); |
| 551 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 552 | - $search_params['brd'][] = $row['id_board']; |
|
| 585 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 586 | + $search_params['brd'][] = $row['id_board']; |
|
| 587 | + } |
|
| 553 | 588 | $smcFunc['db_free_result']($request); |
| 554 | 589 | |
| 555 | 590 | // This error should pro'bly only happen for hackers. |
| 556 | - if (empty($search_params['brd'])) |
|
| 557 | - $context['search_errors']['no_boards_selected'] = true; |
|
| 591 | + if (empty($search_params['brd'])) { |
|
| 592 | + $context['search_errors']['no_boards_selected'] = true; |
|
| 593 | + } |
|
| 558 | 594 | } |
| 559 | 595 | |
| 560 | 596 | if (count($search_params['brd']) != 0) |
| 561 | 597 | { |
| 562 | - foreach ($search_params['brd'] as $k => $v) |
|
| 563 | - $search_params['brd'][$k] = (int) $v; |
|
| 598 | + foreach ($search_params['brd'] as $k => $v) { |
|
| 599 | + $search_params['brd'][$k] = (int) $v; |
|
| 600 | + } |
|
| 564 | 601 | |
| 565 | 602 | // If we've selected all boards, this parameter can be left empty. |
| 566 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -574,15 +611,16 @@ discard block |
||
| 574 | 611 | list ($num_boards) = $smcFunc['db_fetch_row']($request); |
| 575 | 612 | $smcFunc['db_free_result']($request); |
| 576 | 613 | |
| 577 | - if (count($search_params['brd']) == $num_boards) |
|
| 614 | + if (count($search_params['brd']) == $num_boards) { |
|
| 615 | + $boardQuery = ''; |
|
| 616 | + } elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) { |
|
| 617 | + $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
| 618 | + } else { |
|
| 619 | + $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
| 620 | + } |
|
| 621 | + } else { |
|
| 578 | 622 | $boardQuery = ''; |
| 579 | - elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) |
|
| 580 | - $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
| 581 | - else |
|
| 582 | - $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
| 583 | 623 | } |
| 584 | - else |
|
| 585 | - $boardQuery = ''; |
|
| 586 | 624 | |
| 587 | 625 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 588 | 626 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
@@ -596,11 +634,13 @@ discard block |
||
| 596 | 634 | 'id_msg', |
| 597 | 635 | ); |
| 598 | 636 | call_integration_hook('integrate_search_sort_columns', array(&$sort_columns)); |
| 599 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 600 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 637 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 638 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 639 | + } |
|
| 601 | 640 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance'; |
| 602 | - if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') |
|
| 603 | - $search_params['sort'] = 'id_msg'; |
|
| 641 | + if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') { |
|
| 642 | + $search_params['sort'] = 'id_msg'; |
|
| 643 | + } |
|
| 604 | 644 | |
| 605 | 645 | // Sorting direction: descending unless stated otherwise. |
| 606 | 646 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
@@ -624,17 +664,19 @@ discard block |
||
| 624 | 664 | // What are we searching for? |
| 625 | 665 | if (empty($search_params['search'])) |
| 626 | 666 | { |
| 627 | - if (isset($_GET['search'])) |
|
| 628 | - $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
| 629 | - elseif (isset($_POST['search'])) |
|
| 630 | - $search_params['search'] = $_POST['search']; |
|
| 631 | - else |
|
| 632 | - $search_params['search'] = ''; |
|
| 667 | + if (isset($_GET['search'])) { |
|
| 668 | + $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
| 669 | + } elseif (isset($_POST['search'])) { |
|
| 670 | + $search_params['search'] = $_POST['search']; |
|
| 671 | + } else { |
|
| 672 | + $search_params['search'] = ''; |
|
| 673 | + } |
|
| 633 | 674 | } |
| 634 | 675 | |
| 635 | 676 | // Nothing?? |
| 636 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 637 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 677 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 678 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 679 | + } |
|
| 638 | 680 | // Too long? |
| 639 | 681 | elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit']) |
| 640 | 682 | { |
@@ -648,8 +690,9 @@ discard block |
||
| 648 | 690 | $stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query)); |
| 649 | 691 | |
| 650 | 692 | // This (hidden) setting will do fulltext searching in the most basic way. |
| 651 | - if (!empty($modSettings['search_simple_fulltext'])) |
|
| 652 | - $stripped_query = strtr($stripped_query, array('"' => '')); |
|
| 693 | + if (!empty($modSettings['search_simple_fulltext'])) { |
|
| 694 | + $stripped_query = strtr($stripped_query, array('"' => '')); |
|
| 695 | + } |
|
| 653 | 696 | |
| 654 | 697 | $no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1; |
| 655 | 698 | |
@@ -672,8 +715,9 @@ discard block |
||
| 672 | 715 | { |
| 673 | 716 | if ($word === '-') |
| 674 | 717 | { |
| 675 | - if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
| 676 | - $excludedWords[] = $word; |
|
| 718 | + if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
| 719 | + $excludedWords[] = $word; |
|
| 720 | + } |
|
| 677 | 721 | unset($phraseArray[$index]); |
| 678 | 722 | } |
| 679 | 723 | } |
@@ -683,8 +727,9 @@ discard block |
||
| 683 | 727 | { |
| 684 | 728 | if (strpos(trim($word), '-') === 0) |
| 685 | 729 | { |
| 686 | - if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
| 687 | - $excludedWords[] = $word; |
|
| 730 | + if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
| 731 | + $excludedWords[] = $word; |
|
| 732 | + } |
|
| 688 | 733 | unset($wordArray[$index]); |
| 689 | 734 | } |
| 690 | 735 | } |
@@ -697,8 +742,9 @@ discard block |
||
| 697 | 742 | foreach ($searchArray as $index => $value) |
| 698 | 743 | { |
| 699 | 744 | // Skip anything practically empty. |
| 700 | - if (($searchArray[$index] = trim($value, '-_\' ')) === '') |
|
| 701 | - unset($searchArray[$index]); |
|
| 745 | + if (($searchArray[$index] = trim($value, '-_\' ')) === '') { |
|
| 746 | + unset($searchArray[$index]); |
|
| 747 | + } |
|
| 702 | 748 | // Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing. |
| 703 | 749 | elseif (in_array($searchArray[$index], $blacklisted_words)) |
| 704 | 750 | { |
@@ -716,31 +762,37 @@ discard block |
||
| 716 | 762 | |
| 717 | 763 | // Create an array of replacements for highlighting. |
| 718 | 764 | $context['mark'] = array(); |
| 719 | - foreach ($searchArray as $word) |
|
| 720 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 765 | + foreach ($searchArray as $word) { |
|
| 766 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 767 | + } |
|
| 721 | 768 | |
| 722 | 769 | // Initialize two arrays storing the words that have to be searched for. |
| 723 | 770 | $orParts = array(); |
| 724 | 771 | $searchWords = array(); |
| 725 | 772 | |
| 726 | 773 | // Make sure at least one word is being searched for. |
| 727 | - if (empty($searchArray)) |
|
| 728 | - $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
| 774 | + if (empty($searchArray)) { |
|
| 775 | + $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
| 776 | + } |
|
| 729 | 777 | // All words/sentences must match. |
| 730 | - elseif (empty($search_params['searchtype'])) |
|
| 731 | - $orParts[0] = $searchArray; |
|
| 778 | + elseif (empty($search_params['searchtype'])) { |
|
| 779 | + $orParts[0] = $searchArray; |
|
| 780 | + } |
|
| 732 | 781 | // Any word/sentence must match. |
| 733 | - else |
|
| 734 | - foreach ($searchArray as $index => $value) |
|
| 782 | + else { |
|
| 783 | + foreach ($searchArray as $index => $value) |
|
| 735 | 784 | $orParts[$index] = array($value); |
| 785 | + } |
|
| 736 | 786 | |
| 737 | 787 | // Don't allow duplicate error messages if one string is too short. |
| 738 | - if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
|
| 739 | - unset($context['search_errors']['invalid_search_string']); |
|
| 788 | + if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) { |
|
| 789 | + unset($context['search_errors']['invalid_search_string']); |
|
| 790 | + } |
|
| 740 | 791 | // Make sure the excluded words are in all or-branches. |
| 741 | - foreach ($orParts as $orIndex => $andParts) |
|
| 742 | - foreach ($excludedWords as $word) |
|
| 792 | + foreach ($orParts as $orIndex => $andParts) { |
|
| 793 | + foreach ($excludedWords as $word) |
|
| 743 | 794 | $orParts[$orIndex][] = $word; |
| 795 | + } |
|
| 744 | 796 | |
| 745 | 797 | // Determine the or-branches and the fulltext search words. |
| 746 | 798 | foreach ($orParts as $orIndex => $andParts) |
@@ -754,8 +806,9 @@ discard block |
||
| 754 | 806 | ); |
| 755 | 807 | |
| 756 | 808 | // Sort the indexed words (large words -> small words -> excluded words). |
| 757 | - if ($searchAPI->supportsMethod('searchSort')) |
|
| 758 | - usort($orParts[$orIndex], 'searchSort'); |
|
| 809 | + if ($searchAPI->supportsMethod('searchSort')) { |
|
| 810 | + usort($orParts[$orIndex], 'searchSort'); |
|
| 811 | + } |
|
| 759 | 812 | |
| 760 | 813 | foreach ($orParts[$orIndex] as $word) |
| 761 | 814 | { |
@@ -767,15 +820,17 @@ discard block |
||
| 767 | 820 | if (!$is_excluded || count($subjectWords) === 1) |
| 768 | 821 | { |
| 769 | 822 | $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords); |
| 770 | - if ($is_excluded) |
|
| 771 | - $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
| 823 | + if ($is_excluded) { |
|
| 824 | + $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
| 825 | + } |
|
| 826 | + } else { |
|
| 827 | + $excludedPhrases[] = $word; |
|
| 772 | 828 | } |
| 773 | - else |
|
| 774 | - $excludedPhrases[] = $word; |
|
| 775 | 829 | |
| 776 | 830 | // Have we got indexes to prepare? |
| 777 | - if ($searchAPI->supportsMethod('prepareIndexes')) |
|
| 778 | - $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
| 831 | + if ($searchAPI->supportsMethod('prepareIndexes')) { |
|
| 832 | + $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
| 833 | + } |
|
| 779 | 834 | } |
| 780 | 835 | |
| 781 | 836 | // Search_force_index requires all AND parts to have at least one fulltext word. |
@@ -783,8 +838,7 @@ discard block |
||
| 783 | 838 | { |
| 784 | 839 | $context['search_errors']['query_not_specific_enough'] = true; |
| 785 | 840 | break; |
| 786 | - } |
|
| 787 | - elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
| 841 | + } elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
| 788 | 842 | { |
| 789 | 843 | $context['search_errors']['query_not_specific_enough'] = true; |
| 790 | 844 | break; |
@@ -812,8 +866,9 @@ discard block |
||
| 812 | 866 | $found_misspelling = false; |
| 813 | 867 | foreach ($searchArray as $word) |
| 814 | 868 | { |
| 815 | - if (empty($link)) |
|
| 816 | - continue; |
|
| 869 | + if (empty($link)) { |
|
| 870 | + continue; |
|
| 871 | + } |
|
| 817 | 872 | |
| 818 | 873 | // Don't check phrases. |
| 819 | 874 | if (preg_match('~^\w+$~', $word) === 0) |
@@ -828,8 +883,7 @@ discard block |
||
| 828 | 883 | $did_you_mean['search'][] = $word; |
| 829 | 884 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
| 830 | 885 | continue; |
| 831 | - } |
|
| 832 | - elseif (spell_check($link, $word)) |
|
| 886 | + } elseif (spell_check($link, $word)) |
|
| 833 | 887 | { |
| 834 | 888 | $did_you_mean['search'][] = $word; |
| 835 | 889 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -840,11 +894,13 @@ discard block |
||
| 840 | 894 | foreach ($suggestions as $i => $s) |
| 841 | 895 | { |
| 842 | 896 | // Search is case insensitive. |
| 843 | - if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) |
|
| 844 | - unset($suggestions[$i]); |
|
| 897 | + if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) { |
|
| 898 | + unset($suggestions[$i]); |
|
| 899 | + } |
|
| 845 | 900 | // Plus, don't suggest something the user thinks is rude! |
| 846 | - elseif ($suggestions[$i] != censorText($s)) |
|
| 847 | - unset($suggestions[$i]); |
|
| 901 | + elseif ($suggestions[$i] != censorText($s)) { |
|
| 902 | + unset($suggestions[$i]); |
|
| 903 | + } |
|
| 848 | 904 | } |
| 849 | 905 | |
| 850 | 906 | // Anything found? If so, correct it! |
@@ -854,8 +910,7 @@ discard block |
||
| 854 | 910 | $did_you_mean['search'][] = $suggestions[0]; |
| 855 | 911 | $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>'; |
| 856 | 912 | $found_misspelling = true; |
| 857 | - } |
|
| 858 | - else |
|
| 913 | + } else |
|
| 859 | 914 | { |
| 860 | 915 | $did_you_mean['search'][] = $word; |
| 861 | 916 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -872,8 +927,7 @@ discard block |
||
| 872 | 927 | { |
| 873 | 928 | $temp_excluded['search'][] = '-"' . $word . '"'; |
| 874 | 929 | $temp_excluded['display'][] = '-"' . $smcFunc['htmlspecialchars']($word) . '"'; |
| 875 | - } |
|
| 876 | - else |
|
| 930 | + } else |
|
| 877 | 931 | { |
| 878 | 932 | $temp_excluded['search'][] = '-' . $word; |
| 879 | 933 | $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word); |
@@ -885,11 +939,13 @@ discard block |
||
| 885 | 939 | |
| 886 | 940 | $temp_params = $search_params; |
| 887 | 941 | $temp_params['search'] = implode(' ', $did_you_mean['search']); |
| 888 | - if (isset($temp_params['brd'])) |
|
| 889 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 942 | + if (isset($temp_params['brd'])) { |
|
| 943 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 944 | + } |
|
| 890 | 945 | $context['params'] = array(); |
| 891 | - foreach ($temp_params as $k => $v) |
|
| 892 | - $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
| 946 | + foreach ($temp_params as $k => $v) { |
|
| 947 | + $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
| 948 | + } |
|
| 893 | 949 | $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params'])); |
| 894 | 950 | $context['did_you_mean'] = implode(' ', $did_you_mean['display']); |
| 895 | 951 | } |
@@ -897,18 +953,20 @@ discard block |
||
| 897 | 953 | |
| 898 | 954 | // Let the user adjust the search query, should they wish? |
| 899 | 955 | $context['search_params'] = $search_params; |
| 900 | - if (isset($context['search_params']['search'])) |
|
| 901 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 902 | - if (isset($context['search_params']['userspec'])) |
|
| 903 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 956 | + if (isset($context['search_params']['search'])) { |
|
| 957 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 958 | + } |
|
| 959 | + if (isset($context['search_params']['userspec'])) { |
|
| 960 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 961 | + } |
|
| 904 | 962 | |
| 905 | 963 | // Do we have captcha enabled? |
| 906 | 964 | if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])) |
| 907 | 965 | { |
| 908 | 966 | // If we come from another search box tone down the error... |
| 909 | - if (!isset($_REQUEST['search_vv'])) |
|
| 910 | - $context['search_errors']['need_verification_code'] = true; |
|
| 911 | - else |
|
| 967 | + if (!isset($_REQUEST['search_vv'])) { |
|
| 968 | + $context['search_errors']['need_verification_code'] = true; |
|
| 969 | + } else |
|
| 912 | 970 | { |
| 913 | 971 | require_once($sourcedir . '/Subs-Editor.php'); |
| 914 | 972 | $verificationOptions = array( |
@@ -918,12 +976,14 @@ discard block |
||
| 918 | 976 | |
| 919 | 977 | if (is_array($context['require_verification'])) |
| 920 | 978 | { |
| 921 | - foreach ($context['require_verification'] as $error) |
|
| 922 | - $context['search_errors'][$error] = true; |
|
| 979 | + foreach ($context['require_verification'] as $error) { |
|
| 980 | + $context['search_errors'][$error] = true; |
|
| 981 | + } |
|
| 923 | 982 | } |
| 924 | 983 | // Don't keep asking for it - they've proven themselves worthy. |
| 925 | - else |
|
| 926 | - $_SESSION['ss_vv_passed'] = true; |
|
| 984 | + else { |
|
| 985 | + $_SESSION['ss_vv_passed'] = true; |
|
| 986 | + } |
|
| 927 | 987 | } |
| 928 | 988 | } |
| 929 | 989 | |
@@ -931,19 +991,22 @@ discard block |
||
| 931 | 991 | |
| 932 | 992 | // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below. |
| 933 | 993 | $temp_params = $search_params; |
| 934 | - if (isset($temp_params['brd'])) |
|
| 935 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 994 | + if (isset($temp_params['brd'])) { |
|
| 995 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
| 996 | + } |
|
| 936 | 997 | $context['params'] = array(); |
| 937 | - foreach ($temp_params as $k => $v) |
|
| 938 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 998 | + foreach ($temp_params as $k => $v) { |
|
| 999 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1000 | + } |
|
| 939 | 1001 | |
| 940 | 1002 | if (!empty($context['params'])) |
| 941 | 1003 | { |
| 942 | 1004 | // Due to old IE's 2083 character limit, we have to compress long search strings |
| 943 | 1005 | $params = @gzcompress(implode('|"|', $context['params'])); |
| 944 | 1006 | // Gzcompress failed, use try non-gz |
| 945 | - if (empty($params)) |
|
| 946 | - $params = implode('|"|', $context['params']); |
|
| 1007 | + if (empty($params)) { |
|
| 1008 | + $params = implode('|"|', $context['params']); |
|
| 1009 | + } |
|
| 947 | 1010 | // Base64 encode, then replace +/= with uri safe ones that can be reverted |
| 948 | 1011 | $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params)); |
| 949 | 1012 | } |
@@ -969,8 +1032,9 @@ discard block |
||
| 969 | 1032 | } |
| 970 | 1033 | |
| 971 | 1034 | // Spam me not, Spam-a-lot? |
| 972 | - if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) |
|
| 973 | - spamProtection('search'); |
|
| 1035 | + if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) { |
|
| 1036 | + spamProtection('search'); |
|
| 1037 | + } |
|
| 974 | 1038 | // Store the last search string to allow pages of results to be browsed. |
| 975 | 1039 | $_SESSION['last_ss'] = $search_params['search']; |
| 976 | 1040 | |
@@ -1030,8 +1094,9 @@ discard block |
||
| 1030 | 1094 | 'where' => array(), |
| 1031 | 1095 | ); |
| 1032 | 1096 | |
| 1033 | - if ($modSettings['postmod_active']) |
|
| 1034 | - $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
| 1097 | + if ($modSettings['postmod_active']) { |
|
| 1098 | + $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
| 1099 | + } |
|
| 1035 | 1100 | |
| 1036 | 1101 | $numTables = 0; |
| 1037 | 1102 | $prev_join = 0; |
@@ -1043,8 +1108,7 @@ discard block |
||
| 1043 | 1108 | { |
| 1044 | 1109 | $subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)'; |
| 1045 | 1110 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
| 1046 | - } |
|
| 1047 | - else |
|
| 1111 | + } else |
|
| 1048 | 1112 | { |
| 1049 | 1113 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
| 1050 | 1114 | $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}'); |
@@ -1062,14 +1126,18 @@ discard block |
||
| 1062 | 1126 | } |
| 1063 | 1127 | $subject_query['where'][] = $userQuery; |
| 1064 | 1128 | } |
| 1065 | - if (!empty($search_params['topic'])) |
|
| 1066 | - $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
| 1067 | - if (!empty($minMsgID)) |
|
| 1068 | - $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
| 1069 | - if (!empty($maxMsgID)) |
|
| 1070 | - $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
| 1071 | - if (!empty($boardQuery)) |
|
| 1072 | - $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
| 1129 | + if (!empty($search_params['topic'])) { |
|
| 1130 | + $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
| 1131 | + } |
|
| 1132 | + if (!empty($minMsgID)) { |
|
| 1133 | + $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
| 1134 | + } |
|
| 1135 | + if (!empty($maxMsgID)) { |
|
| 1136 | + $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
| 1137 | + } |
|
| 1138 | + if (!empty($boardQuery)) { |
|
| 1139 | + $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
| 1140 | + } |
|
| 1073 | 1141 | if (!empty($excludedPhrases)) |
| 1074 | 1142 | { |
| 1075 | 1143 | if ($subject_query['from'] != '{db_prefix}messages AS m') |
@@ -1089,8 +1157,9 @@ discard block |
||
| 1089 | 1157 | foreach ($weight_factors as $type => $value) |
| 1090 | 1158 | { |
| 1091 | 1159 | $relevance .= $weight[$type]; |
| 1092 | - if (!empty($value['results'])) |
|
| 1093 | - $relevance .= ' * ' . $value['results']; |
|
| 1160 | + if (!empty($value['results'])) { |
|
| 1161 | + $relevance .= ' * ' . $value['results']; |
|
| 1162 | + } |
|
| 1094 | 1163 | $relevance .= ' + '; |
| 1095 | 1164 | } |
| 1096 | 1165 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1128,20 +1197,23 @@ discard block |
||
| 1128 | 1197 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1129 | 1198 | { |
| 1130 | 1199 | // No duplicates! |
| 1131 | - if (isset($inserts[$row[1]])) |
|
| 1132 | - continue; |
|
| 1200 | + if (isset($inserts[$row[1]])) { |
|
| 1201 | + continue; |
|
| 1202 | + } |
|
| 1133 | 1203 | |
| 1134 | - foreach ($row as $key => $value) |
|
| 1135 | - $inserts[$row[1]][] = (int) $row[$key]; |
|
| 1204 | + foreach ($row as $key => $value) { |
|
| 1205 | + $inserts[$row[1]][] = (int) $row[$key]; |
|
| 1206 | + } |
|
| 1136 | 1207 | } |
| 1137 | 1208 | $smcFunc['db_free_result']($ignoreRequest); |
| 1138 | 1209 | $numSubjectResults = count($inserts); |
| 1210 | + } else { |
|
| 1211 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1139 | 1212 | } |
| 1140 | - else |
|
| 1141 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1142 | 1213 | |
| 1143 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
| 1144 | - break; |
|
| 1214 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
| 1215 | + break; |
|
| 1216 | + } |
|
| 1145 | 1217 | } |
| 1146 | 1218 | |
| 1147 | 1219 | // If there's data to be inserted for non-IGNORE databases do it here! |
@@ -1156,8 +1228,7 @@ discard block |
||
| 1156 | 1228 | } |
| 1157 | 1229 | |
| 1158 | 1230 | $_SESSION['search_cache']['num_results'] = $numSubjectResults; |
| 1159 | - } |
|
| 1160 | - else |
|
| 1231 | + } else |
|
| 1161 | 1232 | { |
| 1162 | 1233 | $main_query = array( |
| 1163 | 1234 | 'select' => array( |
@@ -1189,8 +1260,7 @@ discard block |
||
| 1189 | 1260 | $main_query['weights'] = $weight_factors; |
| 1190 | 1261 | |
| 1191 | 1262 | $main_query['group_by'][] = 't.id_topic'; |
| 1192 | - } |
|
| 1193 | - else |
|
| 1263 | + } else |
|
| 1194 | 1264 | { |
| 1195 | 1265 | // This is outrageous! |
| 1196 | 1266 | $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; |
@@ -1211,8 +1281,9 @@ discard block |
||
| 1211 | 1281 | $main_query['where'][] = 't.id_topic = {int:topic}'; |
| 1212 | 1282 | $main_query['parameters']['topic'] = $search_params['topic']; |
| 1213 | 1283 | } |
| 1214 | - if (!empty($search_params['show_complete'])) |
|
| 1215 | - $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
| 1284 | + if (!empty($search_params['show_complete'])) { |
|
| 1285 | + $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
| 1286 | + } |
|
| 1216 | 1287 | } |
| 1217 | 1288 | |
| 1218 | 1289 | // *** Get the subject results. |
@@ -1239,14 +1310,15 @@ discard block |
||
| 1239 | 1310 | ) !== false; |
| 1240 | 1311 | |
| 1241 | 1312 | // Clean up some previous cache. |
| 1242 | - if (!$createTemporary) |
|
| 1243 | - $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
| 1313 | + if (!$createTemporary) { |
|
| 1314 | + $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
| 1244 | 1315 | DELETE FROM {db_prefix}log_search_topics |
| 1245 | 1316 | WHERE id_search = {int:search_id}', |
| 1246 | 1317 | array( |
| 1247 | 1318 | 'search_id' => $_SESSION['search_cache']['id_search'], |
| 1248 | 1319 | ) |
| 1249 | 1320 | ); |
| 1321 | + } |
|
| 1250 | 1322 | |
| 1251 | 1323 | foreach ($searchWords as $orIndex => $words) |
| 1252 | 1324 | { |
@@ -1278,8 +1350,7 @@ discard block |
||
| 1278 | 1350 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
| 1279 | 1351 | $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}'; |
| 1280 | 1352 | $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]'; |
| 1281 | - } |
|
| 1282 | - else |
|
| 1353 | + } else |
|
| 1283 | 1354 | { |
| 1284 | 1355 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
| 1285 | 1356 | $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}'; |
@@ -1334,8 +1405,9 @@ discard block |
||
| 1334 | 1405 | call_integration_hook('integrate_subject_search_query', array(&$subject_query)); |
| 1335 | 1406 | |
| 1336 | 1407 | // Nothing to search for? |
| 1337 | - if (empty($subject_query['where'])) |
|
| 1338 | - continue; |
|
| 1408 | + if (empty($subject_query['where'])) { |
|
| 1409 | + continue; |
|
| 1410 | + } |
|
| 1339 | 1411 | |
| 1340 | 1412 | $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
| 1341 | 1413 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
@@ -1358,19 +1430,21 @@ discard block |
||
| 1358 | 1430 | { |
| 1359 | 1431 | $ind = $createTemporary ? 0 : 1; |
| 1360 | 1432 | // No duplicates! |
| 1361 | - if (isset($inserts[$row[$ind]])) |
|
| 1362 | - continue; |
|
| 1433 | + if (isset($inserts[$row[$ind]])) { |
|
| 1434 | + continue; |
|
| 1435 | + } |
|
| 1363 | 1436 | |
| 1364 | 1437 | $inserts[$row[$ind]] = $row; |
| 1365 | 1438 | } |
| 1366 | 1439 | $smcFunc['db_free_result']($ignoreRequest); |
| 1367 | 1440 | $numSubjectResults = count($inserts); |
| 1441 | + } else { |
|
| 1442 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1368 | 1443 | } |
| 1369 | - else |
|
| 1370 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
| 1371 | 1444 | |
| 1372 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
| 1373 | - break; |
|
| 1445 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
| 1446 | + break; |
|
| 1447 | + } |
|
| 1374 | 1448 | } |
| 1375 | 1449 | |
| 1376 | 1450 | // Got some non-MySQL data to plonk in? |
@@ -1388,8 +1462,9 @@ discard block |
||
| 1388 | 1462 | { |
| 1389 | 1463 | $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END'; |
| 1390 | 1464 | $main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)'; |
| 1391 | - if (!$createTemporary) |
|
| 1392 | - $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
| 1465 | + if (!$createTemporary) { |
|
| 1466 | + $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
| 1467 | + } |
|
| 1393 | 1468 | } |
| 1394 | 1469 | } |
| 1395 | 1470 | |
@@ -1417,14 +1492,15 @@ discard block |
||
| 1417 | 1492 | ) !== false; |
| 1418 | 1493 | |
| 1419 | 1494 | // Clear, all clear! |
| 1420 | - if (!$createTemporary) |
|
| 1421 | - $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
| 1495 | + if (!$createTemporary) { |
|
| 1496 | + $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
| 1422 | 1497 | DELETE FROM {db_prefix}log_search_messages |
| 1423 | 1498 | WHERE id_search = {int:id_search}', |
| 1424 | 1499 | array( |
| 1425 | 1500 | 'id_search' => $_SESSION['search_cache']['id_search'], |
| 1426 | 1501 | ) |
| 1427 | 1502 | ); |
| 1503 | + } |
|
| 1428 | 1504 | |
| 1429 | 1505 | foreach ($searchWords as $orIndex => $words) |
| 1430 | 1506 | { |
@@ -1458,19 +1534,21 @@ discard block |
||
| 1458 | 1534 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1459 | 1535 | { |
| 1460 | 1536 | // No duplicates! |
| 1461 | - if (isset($inserts[$row[0]])) |
|
| 1462 | - continue; |
|
| 1537 | + if (isset($inserts[$row[0]])) { |
|
| 1538 | + continue; |
|
| 1539 | + } |
|
| 1463 | 1540 | |
| 1464 | 1541 | $inserts[$row[0]] = $row; |
| 1465 | 1542 | } |
| 1466 | 1543 | $smcFunc['db_free_result']($ignoreRequest); |
| 1467 | 1544 | $indexedResults = count($inserts); |
| 1545 | + } else { |
|
| 1546 | + $indexedResults += $smcFunc['db_affected_rows'](); |
|
| 1468 | 1547 | } |
| 1469 | - else |
|
| 1470 | - $indexedResults += $smcFunc['db_affected_rows'](); |
|
| 1471 | 1548 | |
| 1472 | - if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) |
|
| 1473 | - break; |
|
| 1549 | + if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) { |
|
| 1550 | + break; |
|
| 1551 | + } |
|
| 1474 | 1552 | } |
| 1475 | 1553 | } |
| 1476 | 1554 | |
@@ -1490,8 +1568,7 @@ discard block |
||
| 1490 | 1568 | $context['search_errors']['query_not_specific_enough'] = true; |
| 1491 | 1569 | $_REQUEST['params'] = $context['params']; |
| 1492 | 1570 | return PlushSearch1(); |
| 1493 | - } |
|
| 1494 | - elseif (!empty($indexedResults)) |
|
| 1571 | + } elseif (!empty($indexedResults)) |
|
| 1495 | 1572 | { |
| 1496 | 1573 | $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)'; |
| 1497 | 1574 | if (!$createTemporary) |
@@ -1513,15 +1590,18 @@ discard block |
||
| 1513 | 1590 | foreach ($words['all_words'] as $regularWord) |
| 1514 | 1591 | { |
| 1515 | 1592 | $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
| 1516 | - if (in_array($regularWord, $excludedWords)) |
|
| 1517 | - $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
| 1593 | + if (in_array($regularWord, $excludedWords)) { |
|
| 1594 | + $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
| 1595 | + } |
|
| 1518 | 1596 | $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 1519 | 1597 | } |
| 1520 | - if (!empty($where)) |
|
| 1521 | - $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
| 1598 | + if (!empty($where)) { |
|
| 1599 | + $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
| 1600 | + } |
|
| 1601 | + } |
|
| 1602 | + if (!empty($orWhere)) { |
|
| 1603 | + $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
| 1522 | 1604 | } |
| 1523 | - if (!empty($orWhere)) |
|
| 1524 | - $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
| 1525 | 1605 | |
| 1526 | 1606 | if (!empty($userQuery)) |
| 1527 | 1607 | { |
@@ -1559,8 +1639,9 @@ discard block |
||
| 1559 | 1639 | foreach ($main_query['weights'] as $type => $value) |
| 1560 | 1640 | { |
| 1561 | 1641 | $relevance .= $weight[$type]; |
| 1562 | - if (!empty($value['search'])) |
|
| 1563 | - $relevance .= ' * ' . $value['search']; |
|
| 1642 | + if (!empty($value['search'])) { |
|
| 1643 | + $relevance .= ' * ' . $value['search']; |
|
| 1644 | + } |
|
| 1564 | 1645 | $relevance .= ' + '; |
| 1565 | 1646 | $new_weight_total += $weight[$type]; |
| 1566 | 1647 | } |
@@ -1591,11 +1672,13 @@ discard block |
||
| 1591 | 1672 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1592 | 1673 | { |
| 1593 | 1674 | // No duplicates! |
| 1594 | - if (isset($inserts[$row[2]])) |
|
| 1595 | - continue; |
|
| 1675 | + if (isset($inserts[$row[2]])) { |
|
| 1676 | + continue; |
|
| 1677 | + } |
|
| 1596 | 1678 | |
| 1597 | - foreach ($row as $key => $value) |
|
| 1598 | - $inserts[$row[2]][] = (int) $row[$key]; |
|
| 1679 | + foreach ($row as $key => $value) { |
|
| 1680 | + $inserts[$row[2]][] = (int) $row[$key]; |
|
| 1681 | + } |
|
| 1599 | 1682 | } |
| 1600 | 1683 | $smcFunc['db_free_result']($ignoreRequest); |
| 1601 | 1684 | |
@@ -1603,8 +1686,9 @@ discard block |
||
| 1603 | 1686 | if (!empty($inserts)) |
| 1604 | 1687 | { |
| 1605 | 1688 | $query_columns = array(); |
| 1606 | - foreach ($main_query['select'] as $k => $v) |
|
| 1607 | - $query_columns[$k] = 'int'; |
|
| 1689 | + foreach ($main_query['select'] as $k => $v) { |
|
| 1690 | + $query_columns[$k] = 'int'; |
|
| 1691 | + } |
|
| 1608 | 1692 | |
| 1609 | 1693 | $smcFunc['db_insert']('', |
| 1610 | 1694 | '{db_prefix}log_search_results', |
@@ -1614,21 +1698,23 @@ discard block |
||
| 1614 | 1698 | ); |
| 1615 | 1699 | } |
| 1616 | 1700 | $_SESSION['search_cache']['num_results'] += count($inserts); |
| 1701 | + } else { |
|
| 1702 | + $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
| 1617 | 1703 | } |
| 1618 | - else |
|
| 1619 | - $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
| 1620 | 1704 | } |
| 1621 | 1705 | |
| 1622 | 1706 | // Insert subject-only matches. |
| 1623 | 1707 | if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0) |
| 1624 | 1708 | { |
| 1625 | 1709 | $relevance = '1000 * ('; |
| 1626 | - foreach ($weight_factors as $type => $value) |
|
| 1627 | - if (isset($value['results'])) |
|
| 1710 | + foreach ($weight_factors as $type => $value) { |
|
| 1711 | + if (isset($value['results'])) |
|
| 1628 | 1712 | { |
| 1629 | 1713 | $relevance .= $weight[$type]; |
| 1630 | - if (!empty($value['results'])) |
|
| 1631 | - $relevance .= ' * ' . $value['results']; |
|
| 1714 | + } |
|
| 1715 | + if (!empty($value['results'])) { |
|
| 1716 | + $relevance .= ' * ' . $value['results']; |
|
| 1717 | + } |
|
| 1632 | 1718 | $relevance .= ' + '; |
| 1633 | 1719 | } |
| 1634 | 1720 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1662,8 +1748,9 @@ discard block |
||
| 1662 | 1748 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
| 1663 | 1749 | { |
| 1664 | 1750 | // No duplicates! |
| 1665 | - if (isset($usedIDs[$row[1]])) |
|
| 1666 | - continue; |
|
| 1751 | + if (isset($usedIDs[$row[1]])) { |
|
| 1752 | + continue; |
|
| 1753 | + } |
|
| 1667 | 1754 | |
| 1668 | 1755 | $usedIDs[$row[1]] = true; |
| 1669 | 1756 | $inserts[] = $row; |
@@ -1681,12 +1768,12 @@ discard block |
||
| 1681 | 1768 | ); |
| 1682 | 1769 | } |
| 1683 | 1770 | $_SESSION['search_cache']['num_results'] += count($inserts); |
| 1771 | + } else { |
|
| 1772 | + $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
| 1684 | 1773 | } |
| 1685 | - else |
|
| 1686 | - $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
| 1774 | + } elseif ($_SESSION['search_cache']['num_results'] == -1) { |
|
| 1775 | + $_SESSION['search_cache']['num_results'] = 0; |
|
| 1687 | 1776 | } |
| 1688 | - elseif ($_SESSION['search_cache']['num_results'] == -1) |
|
| 1689 | - $_SESSION['search_cache']['num_results'] = 0; |
|
| 1690 | 1777 | } |
| 1691 | 1778 | } |
| 1692 | 1779 | |
@@ -1756,14 +1843,16 @@ discard block |
||
| 1756 | 1843 | ) |
| 1757 | 1844 | ); |
| 1758 | 1845 | $posters = array(); |
| 1759 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1760 | - $posters[] = $row['id_member']; |
|
| 1846 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1847 | + $posters[] = $row['id_member']; |
|
| 1848 | + } |
|
| 1761 | 1849 | $smcFunc['db_free_result']($request); |
| 1762 | 1850 | |
| 1763 | 1851 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
| 1764 | 1852 | |
| 1765 | - if (!empty($posters)) |
|
| 1766 | - loadMemberData(array_unique($posters)); |
|
| 1853 | + if (!empty($posters)) { |
|
| 1854 | + loadMemberData(array_unique($posters)); |
|
| 1855 | + } |
|
| 1767 | 1856 | |
| 1768 | 1857 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
| 1769 | 1858 | $messages_request = $smcFunc['db_query']('', ' |
@@ -1797,8 +1886,9 @@ discard block |
||
| 1797 | 1886 | ); |
| 1798 | 1887 | |
| 1799 | 1888 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
| 1800 | - if ($smcFunc['db_num_rows']($messages_request) == 0) |
|
| 1801 | - $context['topics'] = array(); |
|
| 1889 | + if ($smcFunc['db_num_rows']($messages_request) == 0) { |
|
| 1890 | + $context['topics'] = array(); |
|
| 1891 | + } |
|
| 1802 | 1892 | |
| 1803 | 1893 | // If we want to know who participated in what then load this now. |
| 1804 | 1894 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -1816,8 +1906,9 @@ discard block |
||
| 1816 | 1906 | 'limit' => count($participants), |
| 1817 | 1907 | ) |
| 1818 | 1908 | ); |
| 1819 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1820 | - $participants[$row['id_topic']] = true; |
|
| 1909 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1910 | + $participants[$row['id_topic']] = true; |
|
| 1911 | + } |
|
| 1821 | 1912 | $smcFunc['db_free_result']($result); |
| 1822 | 1913 | } |
| 1823 | 1914 | } |
@@ -1826,15 +1917,17 @@ discard block |
||
| 1826 | 1917 | $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false); |
| 1827 | 1918 | |
| 1828 | 1919 | // Consider the search complete! |
| 1829 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1830 | - cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
| 1920 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1921 | + cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
| 1922 | + } |
|
| 1831 | 1923 | |
| 1832 | 1924 | $context['key_words'] = &$searchArray; |
| 1833 | 1925 | |
| 1834 | 1926 | // Setup the default topic icons... for checking they exist and the like! |
| 1835 | 1927 | $context['icon_sources'] = array(); |
| 1836 | - foreach ($context['stable_icons'] as $icon) |
|
| 1837 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1928 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1929 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1930 | + } |
|
| 1838 | 1931 | |
| 1839 | 1932 | $context['sub_template'] = 'results'; |
| 1840 | 1933 | $context['page_title'] = $txt['search_results']; |
@@ -1865,26 +1958,31 @@ discard block |
||
| 1865 | 1958 | global $boards_can, $participants, $smcFunc; |
| 1866 | 1959 | static $recycle_board = null; |
| 1867 | 1960 | |
| 1868 | - if ($recycle_board === null) |
|
| 1869 | - $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
| 1961 | + if ($recycle_board === null) { |
|
| 1962 | + $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
| 1963 | + } |
|
| 1870 | 1964 | |
| 1871 | 1965 | // Remember which message this is. (ie. reply #83) |
| 1872 | 1966 | static $counter = null; |
| 1873 | - if ($counter == null || $reset) |
|
| 1874 | - $counter = $_REQUEST['start'] + 1; |
|
| 1967 | + if ($counter == null || $reset) { |
|
| 1968 | + $counter = $_REQUEST['start'] + 1; |
|
| 1969 | + } |
|
| 1875 | 1970 | |
| 1876 | 1971 | // If the query returned false, bail. |
| 1877 | - if ($messages_request == false) |
|
| 1878 | - return false; |
|
| 1972 | + if ($messages_request == false) { |
|
| 1973 | + return false; |
|
| 1974 | + } |
|
| 1879 | 1975 | |
| 1880 | 1976 | // Start from the beginning... |
| 1881 | - if ($reset) |
|
| 1882 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1977 | + if ($reset) { |
|
| 1978 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1979 | + } |
|
| 1883 | 1980 | |
| 1884 | 1981 | // Attempt to get the next message. |
| 1885 | 1982 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1886 | - if (!$message) |
|
| 1887 | - return false; |
|
| 1983 | + if (!$message) { |
|
| 1984 | + return false; |
|
| 1985 | + } |
|
| 1888 | 1986 | |
| 1889 | 1987 | // Can't have an empty subject can we? |
| 1890 | 1988 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1923,9 +2021,9 @@ discard block |
||
| 1923 | 2021 | |
| 1924 | 2022 | if ($smcFunc['strlen']($message['body']) > $charLimit) |
| 1925 | 2023 | { |
| 1926 | - if (empty($context['key_words'])) |
|
| 1927 | - $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
| 1928 | - else |
|
| 2024 | + if (empty($context['key_words'])) { |
|
| 2025 | + $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
| 2026 | + } else |
|
| 1929 | 2027 | { |
| 1930 | 2028 | $matchString = ''; |
| 1931 | 2029 | $force_partial_word = false; |
@@ -1934,18 +2032,20 @@ discard block |
||
| 1934 | 2032 | $keyword = un_htmlspecialchars($keyword); |
| 1935 | 2033 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
| 1936 | 2034 | |
| 1937 | - if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
|
| 1938 | - $force_partial_word = true; |
|
| 2035 | + if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) { |
|
| 2036 | + $force_partial_word = true; |
|
| 2037 | + } |
|
| 1939 | 2038 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
| 1940 | 2039 | } |
| 1941 | 2040 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
| 1942 | 2041 | |
| 1943 | 2042 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br>' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
| 1944 | 2043 | |
| 1945 | - if (empty($modSettings['search_method']) || $force_partial_word) |
|
| 1946 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 1947 | - else |
|
| 1948 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 2044 | + if (empty($modSettings['search_method']) || $force_partial_word) { |
|
| 2045 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 2046 | + } else { |
|
| 2047 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
| 2048 | + } |
|
| 1949 | 2049 | |
| 1950 | 2050 | $message['body'] = ''; |
| 1951 | 2051 | foreach ($matches[0] as $index => $match) |
@@ -1958,8 +2058,7 @@ discard block |
||
| 1958 | 2058 | // Re-fix the international characters. |
| 1959 | 2059 | $message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']); |
| 1960 | 2060 | } |
| 1961 | - } |
|
| 1962 | - else |
|
| 2061 | + } else |
|
| 1963 | 2062 | { |
| 1964 | 2063 | // Run BBC interpreter on the message. |
| 1965 | 2064 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
@@ -1978,21 +2077,26 @@ discard block |
||
| 1978 | 2077 | // Sadly, we need to check the icon ain't broke. |
| 1979 | 2078 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 1980 | 2079 | { |
| 1981 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
| 1982 | - $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1983 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
| 1984 | - $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1985 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1986 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1987 | - } |
|
| 1988 | - else |
|
| 2080 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
| 2081 | + $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2082 | + } |
|
| 2083 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
| 2084 | + $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2085 | + } |
|
| 2086 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 2087 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2088 | + } |
|
| 2089 | + } else |
|
| 1989 | 2090 | { |
| 1990 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
| 1991 | - $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
| 1992 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
| 1993 | - $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
| 1994 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1995 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 2091 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
| 2092 | + $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
| 2093 | + } |
|
| 2094 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
| 2095 | + $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
| 2096 | + } |
|
| 2097 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 2098 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 2099 | + } |
|
| 1996 | 2100 | } |
| 1997 | 2101 | |
| 1998 | 2102 | // Do we have quote tag enabled? |
@@ -2002,12 +2106,14 @@ discard block |
||
| 2002 | 2106 | $colorClass = 'windowbg'; |
| 2003 | 2107 | |
| 2004 | 2108 | // Sticky topics should get a different color, too. |
| 2005 | - if ($message['is_sticky']) |
|
| 2006 | - $colorClass .= ' sticky'; |
|
| 2109 | + if ($message['is_sticky']) { |
|
| 2110 | + $colorClass .= ' sticky'; |
|
| 2111 | + } |
|
| 2007 | 2112 | |
| 2008 | 2113 | // Locked topics get special treatment as well. |
| 2009 | - if ($message['locked']) |
|
| 2010 | - $colorClass .= ' locked'; |
|
| 2114 | + if ($message['locked']) { |
|
| 2115 | + $colorClass .= ' locked'; |
|
| 2116 | + } |
|
| 2011 | 2117 | |
| 2012 | 2118 | $output = array_merge($context['topics'][$message['id_msg']], array( |
| 2013 | 2119 | 'id' => $message['id_topic'], |
@@ -2151,8 +2257,9 @@ discard block |
||
| 2151 | 2257 | |
| 2152 | 2258 | // Load up the search API we are going to use. |
| 2153 | 2259 | $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index']; |
| 2154 | - if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) |
|
| 2155 | - fatal_lang_error('search_api_missing'); |
|
| 2260 | + if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) { |
|
| 2261 | + fatal_lang_error('search_api_missing'); |
|
| 2262 | + } |
|
| 2156 | 2263 | require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'); |
| 2157 | 2264 | |
| 2158 | 2265 | // Create an instance of the search API and check it is valid for this version of SMF. |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | <div id="personal_messages">'; |
| 22 | 22 | |
| 23 | 23 | // Show the capacity bar, if available. |
| 24 | - if (!empty($context['limit_bar'])) |
|
| 25 | - echo ' |
|
| 24 | + if (!empty($context['limit_bar'])) { |
|
| 25 | + echo ' |
|
| 26 | 26 | <div class="cat_bar"> |
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
@@ -32,14 +32,16 @@ discard block |
||
| 32 | 32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
| 33 | 33 | </h3> |
| 34 | 34 | </div>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | // Message sent? Show a small indication. |
| 37 | - if (isset($context['pm_sent'])) |
|
| 38 | - echo ' |
|
| 38 | + if (isset($context['pm_sent'])) { |
|
| 39 | + echo ' |
|
| 39 | 40 | <div class="infobox"> |
| 40 | 41 | ', $txt['pm_sent'], ' |
| 41 | 42 | </div>'; |
| 42 | -} |
|
| 43 | + } |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | /** |
| 45 | 47 | * Just the end of the index bar, nothing special. |
@@ -68,13 +70,13 @@ discard block |
||
| 68 | 70 | </div> |
| 69 | 71 | <div class="pm_unread">'; |
| 70 | 72 | |
| 71 | - if (empty($context['unread_pms'])) |
|
| 72 | - echo ' |
|
| 73 | + if (empty($context['unread_pms'])) { |
|
| 74 | + echo ' |
|
| 73 | 75 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
| 74 | - else |
|
| 76 | + } else |
|
| 75 | 77 | { |
| 76 | - foreach ($context['unread_pms'] as $id_pm => $pm_details) |
|
| 77 | - echo ' |
|
| 78 | + foreach ($context['unread_pms'] as $id_pm => $pm_details) { |
|
| 79 | + echo ' |
|
| 78 | 80 | <div class="unread"> |
| 79 | 81 | ', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', ' |
| 80 | 82 | <div class="details"> |
@@ -85,6 +87,7 @@ discard block |
||
| 85 | 87 | </div> |
| 86 | 88 | </div> |
| 87 | 89 | </div>'; |
| 90 | + } |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | echo ' |
@@ -193,14 +196,15 @@ discard block |
||
| 193 | 196 | if ($context['get_pmessage']('message', true)) |
| 194 | 197 | { |
| 195 | 198 | // Show the helpful titlebar - generally. |
| 196 | - if ($context['display_mode'] != 1) |
|
| 197 | - echo ' |
|
| 199 | + if ($context['display_mode'] != 1) { |
|
| 200 | + echo ' |
|
| 198 | 201 | <div class="cat_bar"> |
| 199 | 202 | <h3 class="catbg"> |
| 200 | 203 | <span id="author">', $txt['author'], '</span> |
| 201 | 204 | <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span> |
| 202 | 205 | </h3> |
| 203 | 206 | </div>'; |
| 207 | + } |
|
| 204 | 208 | |
| 205 | 209 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 206 | 210 | if ($context['display_mode'] == 2) |
@@ -229,9 +233,10 @@ discard block |
||
| 229 | 233 | <div class="custom_fields_above_member"> |
| 230 | 234 | <ul class="nolist">'; |
| 231 | 235 | |
| 232 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 233 | - echo ' |
|
| 236 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 237 | + echo ' |
|
| 234 | 238 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 239 | + } |
|
| 235 | 240 | |
| 236 | 241 | echo ' |
| 237 | 242 | </ul> |
@@ -243,25 +248,28 @@ discard block |
||
| 243 | 248 | <a id="msg', $message['id'], '"></a>'; |
| 244 | 249 | |
| 245 | 250 | // Show online and offline buttons? |
| 246 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 247 | - echo ' |
|
| 251 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 252 | + echo ' |
|
| 248 | 253 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
| 254 | + } |
|
| 249 | 255 | |
| 250 | 256 | // Custom fields BEFORE the username? |
| 251 | - if (!empty($message['custom_fields']['before_member'])) |
|
| 252 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 257 | + if (!empty($message['custom_fields']['before_member'])) { |
|
| 258 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 253 | 259 | echo ' |
| 254 | 260 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 261 | + } |
|
| 255 | 262 | |
| 256 | 263 | // Show a link to the member's profile. |
| 257 | 264 | echo ' |
| 258 | 265 | ', $message['member']['link']; |
| 259 | 266 | |
| 260 | 267 | // Custom fields AFTER the username? |
| 261 | - if (!empty($message['custom_fields']['after_member'])) |
|
| 262 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 268 | + if (!empty($message['custom_fields']['after_member'])) { |
|
| 269 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 263 | 270 | echo ' |
| 264 | 271 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 272 | + } |
|
| 265 | 273 | |
| 266 | 274 | echo ' |
| 267 | 275 | </h4>'; |
@@ -270,48 +278,56 @@ discard block |
||
| 270 | 278 | <ul class="user_info">'; |
| 271 | 279 | |
| 272 | 280 | // Show the user's avatar. |
| 273 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 274 | - echo ' |
|
| 281 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 282 | + echo ' |
|
| 275 | 283 | <li class="avatar"> |
| 276 | 284 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
| 277 | 285 | </li>'; |
| 286 | + } |
|
| 278 | 287 | |
| 279 | 288 | // Are there any custom fields below the avatar? |
| 280 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 281 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 289 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 290 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 282 | 291 | echo ' |
| 283 | 292 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 293 | + } |
|
| 284 | 294 | |
| 285 | - if (!$message['member']['is_guest']) |
|
| 286 | - echo ' |
|
| 295 | + if (!$message['member']['is_guest']) { |
|
| 296 | + echo ' |
|
| 287 | 297 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 298 | + } |
|
| 288 | 299 | // Show the member's primary group (like 'Administrator') if they have one. |
| 289 | - if (isset($message['member']['group']) && $message['member']['group'] != '') |
|
| 290 | - echo ' |
|
| 300 | + if (isset($message['member']['group']) && $message['member']['group'] != '') { |
|
| 301 | + echo ' |
|
| 291 | 302 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 303 | + } |
|
| 292 | 304 | |
| 293 | 305 | // Show the member's custom title, if they have one. |
| 294 | - if (isset($message['member']['title']) && $message['member']['title'] != '') |
|
| 295 | - echo ' |
|
| 306 | + if (isset($message['member']['title']) && $message['member']['title'] != '') { |
|
| 307 | + echo ' |
|
| 296 | 308 | <li class="title">', $message['member']['title'], '</li>'; |
| 309 | + } |
|
| 297 | 310 | |
| 298 | 311 | // Don't show these things for guests. |
| 299 | 312 | if (!$message['member']['is_guest']) |
| 300 | 313 | { |
| 301 | 314 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 302 | - if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
|
| 303 | - echo ' |
|
| 315 | + if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') { |
|
| 316 | + echo ' |
|
| 304 | 317 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 318 | + } |
|
| 305 | 319 | |
| 306 | 320 | // Show how many posts they have made. |
| 307 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 308 | - echo ' |
|
| 321 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 322 | + echo ' |
|
| 309 | 323 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 324 | + } |
|
| 310 | 325 | |
| 311 | 326 | // Show their personal text? |
| 312 | - if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
|
| 313 | - echo ' |
|
| 327 | + if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') { |
|
| 328 | + echo ' |
|
| 314 | 329 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 330 | + } |
|
| 315 | 331 | |
| 316 | 332 | // Any custom fields to show as icons? |
| 317 | 333 | if (!empty($message['custom_fields']['icons'])) |
@@ -320,9 +336,10 @@ discard block |
||
| 320 | 336 | <li class="im_icons"> |
| 321 | 337 | <ol>'; |
| 322 | 338 | |
| 323 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 324 | - echo ' |
|
| 339 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 340 | + echo ' |
|
| 325 | 341 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 342 | + } |
|
| 326 | 343 | |
| 327 | 344 | echo ' |
| 328 | 345 | </ol> |
@@ -330,25 +347,28 @@ discard block |
||
| 330 | 347 | } |
| 331 | 348 | |
| 332 | 349 | // Show the IP to this user for this post - because you can moderate? |
| 333 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 334 | - echo ' |
|
| 350 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 351 | + echo ' |
|
| 335 | 352 | <li class="poster_ip"> |
| 336 | 353 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
| 337 | 354 | </li>'; |
| 355 | + } |
|
| 338 | 356 | |
| 339 | 357 | // Or, should we show it because this is you? |
| 340 | - elseif ($message['can_see_ip']) |
|
| 341 | - echo ' |
|
| 358 | + elseif ($message['can_see_ip']) { |
|
| 359 | + echo ' |
|
| 342 | 360 | <li class="poster_ip"> |
| 343 | 361 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
| 344 | 362 | </li>'; |
| 363 | + } |
|
| 345 | 364 | |
| 346 | 365 | // Okay, you are logged in, then we can show something about why IPs are logged... |
| 347 | - else |
|
| 348 | - echo ' |
|
| 366 | + else { |
|
| 367 | + echo ' |
|
| 349 | 368 | <li class="poster_ip"> |
| 350 | 369 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
| 351 | 370 | </li>'; |
| 371 | + } |
|
| 352 | 372 | |
| 353 | 373 | // Show the profile, website, email address, and personal message buttons. |
| 354 | 374 | if ($message['member']['show_profile_buttons']) |
@@ -358,24 +378,28 @@ discard block |
||
| 358 | 378 | <ol class="profile_icons">'; |
| 359 | 379 | |
| 360 | 380 | // Show the profile button |
| 361 | - if ($message['member']['can_view_profile']) |
|
| 362 | - echo ' |
|
| 381 | + if ($message['member']['can_view_profile']) { |
|
| 382 | + echo ' |
|
| 363 | 383 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
| 384 | + } |
|
| 364 | 385 | |
| 365 | 386 | // Don't show an icon if they haven't specified a website. |
| 366 | - if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
|
| 367 | - echo ' |
|
| 387 | + if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) { |
|
| 388 | + echo ' |
|
| 368 | 389 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 390 | + } |
|
| 369 | 391 | |
| 370 | 392 | // Don't show the email address if they want it hidden. |
| 371 | - if ($message['member']['show_email']) |
|
| 372 | - echo ' |
|
| 393 | + if ($message['member']['show_email']) { |
|
| 394 | + echo ' |
|
| 373 | 395 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 396 | + } |
|
| 374 | 397 | |
| 375 | 398 | // Since we know this person isn't a guest, you *can* message them. |
| 376 | - if ($context['can_send_pm']) |
|
| 377 | - echo ' |
|
| 399 | + if ($context['can_send_pm']) { |
|
| 400 | + echo ' |
|
| 378 | 401 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 402 | + } |
|
| 379 | 403 | |
| 380 | 404 | echo ' |
| 381 | 405 | </ol> |
@@ -383,21 +407,24 @@ discard block |
||
| 383 | 407 | } |
| 384 | 408 | |
| 385 | 409 | // Any custom fields for standard placement? |
| 386 | - if (!empty($message['custom_fields']['standard'])) |
|
| 387 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 410 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 411 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 388 | 412 | echo ' |
| 389 | 413 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 414 | + } |
|
| 390 | 415 | |
| 391 | 416 | // Are we showing the warning status? |
| 392 | - if ($message['member']['can_see_warning']) |
|
| 393 | - echo ' |
|
| 417 | + if ($message['member']['can_see_warning']) { |
|
| 418 | + echo ' |
|
| 394 | 419 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 420 | + } |
|
| 395 | 421 | |
| 396 | 422 | // Are there any custom fields to show at the bottom of the poster info? |
| 397 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 398 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 423 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 424 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 399 | 425 | echo ' |
| 400 | 426 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 427 | + } |
|
| 401 | 428 | } |
| 402 | 429 | |
| 403 | 430 | // Done with the information about the poster... on to the post itself. |
@@ -416,25 +443,29 @@ discard block |
||
| 416 | 443 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
| 417 | 444 | |
| 418 | 445 | // People it was sent directly to.... |
| 419 | - if (!empty($message['recipients']['to'])) |
|
| 420 | - echo implode(', ', $message['recipients']['to']); |
|
| 446 | + if (!empty($message['recipients']['to'])) { |
|
| 447 | + echo implode(', ', $message['recipients']['to']); |
|
| 448 | + } |
|
| 421 | 449 | |
| 422 | 450 | // Otherwise, we're just going to say "some people"... |
| 423 | - elseif ($context['folder'] != 'sent') |
|
| 424 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 451 | + elseif ($context['folder'] != 'sent') { |
|
| 452 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 453 | + } |
|
| 425 | 454 | |
| 426 | 455 | echo ' |
| 427 | 456 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
| 428 | 457 | </span>'; |
| 429 | 458 | |
| 430 | 459 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
| 431 | - if (!empty($message['recipients']['bcc'])) |
|
| 432 | - echo '<br> |
|
| 460 | + if (!empty($message['recipients']['bcc'])) { |
|
| 461 | + echo '<br> |
|
| 433 | 462 | <span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
| 463 | + } |
|
| 434 | 464 | |
| 435 | - if (!empty($message['is_replied_to'])) |
|
| 436 | - echo '<br> |
|
| 465 | + if (!empty($message['is_replied_to'])) { |
|
| 466 | + echo '<br> |
|
| 437 | 467 | <span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
| 468 | + } |
|
| 438 | 469 | |
| 439 | 470 | echo ' |
| 440 | 471 | </div><!-- .keyinfo --> |
@@ -444,13 +475,15 @@ discard block |
||
| 444 | 475 | ', $message['body'], ' |
| 445 | 476 | </div>'; |
| 446 | 477 | |
| 447 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 448 | - echo ' |
|
| 478 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 479 | + echo ' |
|
| 449 | 480 | <div class="under_message">'; |
| 481 | + } |
|
| 450 | 482 | |
| 451 | - if ($message['can_report']) |
|
| 452 | - echo ' |
|
| 483 | + if ($message['can_report']) { |
|
| 484 | + echo ' |
|
| 453 | 485 | <a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>'; |
| 486 | + } |
|
| 454 | 487 | |
| 455 | 488 | echo ' |
| 456 | 489 | <ul class="quickbuttons">'; |
@@ -462,32 +495,36 @@ discard block |
||
| 462 | 495 | if (!$message['member']['is_guest']) |
| 463 | 496 | { |
| 464 | 497 | // Is there than more than one recipient you can reply to? |
| 465 | - if ($message['number_recipients'] > 1) |
|
| 466 | - echo ' |
|
| 498 | + if ($message['number_recipients'] > 1) { |
|
| 499 | + echo ' |
|
| 467 | 500 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>'; |
| 501 | + } |
|
| 468 | 502 | |
| 469 | 503 | echo ' |
| 470 | 504 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li> |
| 471 | 505 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 472 | 506 | } |
| 473 | 507 | // This is for "forwarding" - even if the member is gone. |
| 474 | - else |
|
| 475 | - echo ' |
|
| 508 | + else { |
|
| 509 | + echo ' |
|
| 476 | 510 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>'; |
| 511 | + } |
|
| 477 | 512 | } |
| 478 | 513 | echo ' |
| 479 | 514 | <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>'; |
| 480 | 515 | |
| 481 | - if (empty($context['display_mode'])) |
|
| 482 | - echo ' |
|
| 516 | + if (empty($context['display_mode'])) { |
|
| 517 | + echo ' |
|
| 483 | 518 | <li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>'; |
| 519 | + } |
|
| 484 | 520 | |
| 485 | 521 | echo ' |
| 486 | 522 | </ul>'; |
| 487 | 523 | |
| 488 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 489 | - echo ' |
|
| 524 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 525 | + echo ' |
|
| 490 | 526 | </div><!-- .under_message -->'; |
| 527 | + } |
|
| 491 | 528 | |
| 492 | 529 | // Are there any custom profile fields for above the signature? |
| 493 | 530 | if (!empty($message['custom_fields']['above_signature'])) |
@@ -496,9 +533,10 @@ discard block |
||
| 496 | 533 | <div class="custom_fields_above_signature"> |
| 497 | 534 | <ul class="nolist">'; |
| 498 | 535 | |
| 499 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 500 | - echo ' |
|
| 536 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 537 | + echo ' |
|
| 501 | 538 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 539 | + } |
|
| 502 | 540 | |
| 503 | 541 | echo ' |
| 504 | 542 | </ul> |
@@ -506,11 +544,12 @@ discard block |
||
| 506 | 544 | } |
| 507 | 545 | |
| 508 | 546 | // Show the member's signature? |
| 509 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 510 | - echo ' |
|
| 547 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 548 | + echo ' |
|
| 511 | 549 | <div class="signature"> |
| 512 | 550 | ', $message['member']['signature'], ' |
| 513 | 551 | </div>'; |
| 552 | + } |
|
| 514 | 553 | |
| 515 | 554 | // Are there any custom profile fields for below the signature? |
| 516 | 555 | if (!empty($message['custom_fields']['below_signature'])) |
@@ -519,9 +558,10 @@ discard block |
||
| 519 | 558 | <div class="custom_fields_below_signature"> |
| 520 | 559 | <ul class="nolist">'; |
| 521 | 560 | |
| 522 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 523 | - echo ' |
|
| 561 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 562 | + echo ' |
|
| 524 | 563 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 564 | + } |
|
| 525 | 565 | |
| 526 | 566 | echo ' |
| 527 | 567 | </ul> |
@@ -548,10 +588,11 @@ discard block |
||
| 548 | 588 | echo ' |
| 549 | 589 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
| 550 | 590 | |
| 551 | - foreach ($context['labels'] as $label) |
|
| 552 | - if (!isset($message['labels'][$label['id']])) |
|
| 591 | + foreach ($context['labels'] as $label) { |
|
| 592 | + if (!isset($message['labels'][$label['id']])) |
|
| 553 | 593 | echo ' |
| 554 | 594 | <option value="', $label['id'], '">', $label['name'], '</option>'; |
| 595 | + } |
|
| 555 | 596 | } |
| 556 | 597 | |
| 557 | 598 | // ... and are there any that can be removed? |
@@ -560,9 +601,10 @@ discard block |
||
| 560 | 601 | echo ' |
| 561 | 602 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
| 562 | 603 | |
| 563 | - foreach ($message['labels'] as $label) |
|
| 564 | - echo ' |
|
| 604 | + foreach ($message['labels'] as $label) { |
|
| 605 | + echo ' |
|
| 565 | 606 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
| 607 | + } |
|
| 566 | 608 | } |
| 567 | 609 | echo ' |
| 568 | 610 | </select> |
@@ -581,14 +623,15 @@ discard block |
||
| 581 | 623 | </div><!-- .windowbg -->'; |
| 582 | 624 | } |
| 583 | 625 | |
| 584 | - if (empty($context['display_mode'])) |
|
| 585 | - echo ' |
|
| 626 | + if (empty($context['display_mode'])) { |
|
| 627 | + echo ' |
|
| 586 | 628 | <div class="pagesection"> |
| 587 | 629 | <div class="floatleft">', $context['page_index'], '</div> |
| 588 | 630 | <div class="floatright"> |
| 589 | 631 | <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button"> |
| 590 | 632 | </div> |
| 591 | 633 | </div>'; |
| 634 | + } |
|
| 592 | 635 | |
| 593 | 636 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 594 | 637 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
@@ -648,11 +691,12 @@ discard block |
||
| 648 | 691 | </thead> |
| 649 | 692 | <tbody>'; |
| 650 | 693 | |
| 651 | - if (!$context['show_delete']) |
|
| 652 | - echo ' |
|
| 694 | + if (!$context['show_delete']) { |
|
| 695 | + echo ' |
|
| 653 | 696 | <tr class="windowbg"> |
| 654 | 697 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
| 655 | 698 | </tr>'; |
| 699 | + } |
|
| 656 | 700 | |
| 657 | 701 | while ($message = $context['get_pmessage']('subject')) |
| 658 | 702 | { |
@@ -710,17 +754,19 @@ discard block |
||
| 710 | 754 | |
| 711 | 755 | foreach ($context['labels'] as $label) |
| 712 | 756 | { |
| 713 | - if ($label['id'] != $context['current_label_id']) |
|
| 714 | - echo ' |
|
| 757 | + if ($label['id'] != $context['current_label_id']) { |
|
| 758 | + echo ' |
|
| 715 | 759 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
| 760 | + } |
|
| 716 | 761 | } |
| 717 | 762 | |
| 718 | 763 | echo ' |
| 719 | 764 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
| 720 | 765 | |
| 721 | - foreach ($context['labels'] as $label) |
|
| 722 | - echo ' |
|
| 766 | + foreach ($context['labels'] as $label) { |
|
| 767 | + echo ' |
|
| 723 | 768 | <option value="rem_', $label['id'], '"> ', $label['name'], '</option>'; |
| 769 | + } |
|
| 724 | 770 | |
| 725 | 771 | echo ' |
| 726 | 772 | </select> |
@@ -751,11 +797,12 @@ discard block |
||
| 751 | 797 | <h3 class="catbg">', $txt['pm_search_title'], '</h3> |
| 752 | 798 | </div>'; |
| 753 | 799 | |
| 754 | - if (!empty($context['search_errors'])) |
|
| 755 | - echo ' |
|
| 800 | + if (!empty($context['search_errors'])) { |
|
| 801 | + echo ' |
|
| 756 | 802 | <div class="errorbox"> |
| 757 | 803 | ', implode('<br>', $context['search_errors']['messages']), ' |
| 758 | 804 | </div>'; |
| 805 | + } |
|
| 759 | 806 | |
| 760 | 807 | |
| 761 | 808 | echo ' |
@@ -804,9 +851,10 @@ discard block |
||
| 804 | 851 | </dd> |
| 805 | 852 | </dl>'; |
| 806 | 853 | |
| 807 | - if (!$context['currently_using_labels']) |
|
| 808 | - echo ' |
|
| 854 | + if (!$context['currently_using_labels']) { |
|
| 855 | + echo ' |
|
| 809 | 856 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button">'; |
| 857 | + } |
|
| 810 | 858 | |
| 811 | 859 | echo ' |
| 812 | 860 | <br class="clear_right"> |
@@ -827,12 +875,13 @@ discard block |
||
| 827 | 875 | <div id="advanced_panel_div"> |
| 828 | 876 | <ul id="searchLabelsExpand">'; |
| 829 | 877 | |
| 830 | - foreach ($context['search_labels'] as $label) |
|
| 831 | - echo ' |
|
| 878 | + foreach ($context['search_labels'] as $label) { |
|
| 879 | + echo ' |
|
| 832 | 880 | <li> |
| 833 | 881 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '> |
| 834 | 882 | ', $label['name'], '</label> |
| 835 | 883 | </li>'; |
| 884 | + } |
|
| 836 | 885 | |
| 837 | 886 | echo ' |
| 838 | 887 | </ul> |
@@ -894,8 +943,8 @@ discard block |
||
| 894 | 943 | </div>'; |
| 895 | 944 | |
| 896 | 945 | // Complete results? |
| 897 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 898 | - echo ' |
|
| 946 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 947 | + echo ' |
|
| 899 | 948 | <table class="table_grid"> |
| 900 | 949 | <thead> |
| 901 | 950 | <tr class="title_bar"> |
@@ -905,6 +954,7 @@ discard block |
||
| 905 | 954 | </tr> |
| 906 | 955 | </thead> |
| 907 | 956 | <tbody>'; |
| 957 | + } |
|
| 908 | 958 | |
| 909 | 959 | // Print each message out... |
| 910 | 960 | foreach ($context['personal_messages'] as $message) |
@@ -924,12 +974,14 @@ discard block |
||
| 924 | 974 | |
| 925 | 975 | // Show the recipients. |
| 926 | 976 | // @todo This doesn't deal with the sent item searching quite right for bcc. |
| 927 | - if (!empty($message['recipients']['to'])) |
|
| 928 | - echo implode(', ', $message['recipients']['to']); |
|
| 977 | + if (!empty($message['recipients']['to'])) { |
|
| 978 | + echo implode(', ', $message['recipients']['to']); |
|
| 979 | + } |
|
| 929 | 980 | |
| 930 | 981 | // Otherwise, we're just going to say "some people"... |
| 931 | - elseif ($context['folder'] != 'sent') |
|
| 932 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 982 | + elseif ($context['folder'] != 'sent') { |
|
| 983 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 984 | + } |
|
| 933 | 985 | |
| 934 | 986 | echo ' |
| 935 | 987 | </h3> |
@@ -944,15 +996,17 @@ discard block |
||
| 944 | 996 | $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"'); |
| 945 | 997 | |
| 946 | 998 | // You can only reply if they are not a guest... |
| 947 | - if (!$message['member']['is_guest']) |
|
| 948 | - echo ' |
|
| 999 | + if (!$message['member']['is_guest']) { |
|
| 1000 | + echo ' |
|
| 949 | 1001 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
| 950 | 1002 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
| 1003 | + } |
|
| 951 | 1004 | |
| 952 | 1005 | // This is for "forwarding" - even if the member is gone. |
| 953 | - else |
|
| 954 | - echo ' |
|
| 1006 | + else { |
|
| 1007 | + echo ' |
|
| 955 | 1008 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
| 1009 | + } |
|
| 956 | 1010 | } |
| 957 | 1011 | |
| 958 | 1012 | echo ' |
@@ -961,27 +1015,30 @@ discard block |
||
| 961 | 1015 | } |
| 962 | 1016 | // Otherwise just a simple list! |
| 963 | 1017 | // @todo No context at all of the search? |
| 964 | - else |
|
| 965 | - echo ' |
|
| 1018 | + else { |
|
| 1019 | + echo ' |
|
| 966 | 1020 | <tr class="windowbg"> |
| 967 | 1021 | <td>', $message['time'], '</td> |
| 968 | 1022 | <td>', $message['link'], '</td> |
| 969 | 1023 | <td>', $message['member']['link'], '</td> |
| 970 | 1024 | </tr>'; |
| 1025 | + } |
|
| 971 | 1026 | } |
| 972 | 1027 | |
| 973 | 1028 | // Finish off the page... |
| 974 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 975 | - echo ' |
|
| 1029 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 1030 | + echo ' |
|
| 976 | 1031 | </tbody> |
| 977 | 1032 | </table>'; |
| 1033 | + } |
|
| 978 | 1034 | |
| 979 | 1035 | // No results? |
| 980 | - if (empty($context['personal_messages'])) |
|
| 981 | - echo ' |
|
| 1036 | + if (empty($context['personal_messages'])) { |
|
| 1037 | + echo ' |
|
| 982 | 1038 | <div class="windowbg"> |
| 983 | 1039 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
| 984 | 1040 | </div>'; |
| 1041 | + } |
|
| 985 | 1042 | |
| 986 | 1043 | echo ' |
| 987 | 1044 | <div class="pagesection"> |
@@ -1006,15 +1063,17 @@ discard block |
||
| 1006 | 1063 | </div> |
| 1007 | 1064 | <div class="windowbg">'; |
| 1008 | 1065 | |
| 1009 | - if (!empty($context['send_log']['sent'])) |
|
| 1010 | - foreach ($context['send_log']['sent'] as $log_entry) |
|
| 1066 | + if (!empty($context['send_log']['sent'])) { |
|
| 1067 | + foreach ($context['send_log']['sent'] as $log_entry) |
|
| 1011 | 1068 | echo ' |
| 1012 | 1069 | <span class="error">', $log_entry, '</span><br>'; |
| 1070 | + } |
|
| 1013 | 1071 | |
| 1014 | - if (!empty($context['send_log']['failed'])) |
|
| 1015 | - foreach ($context['send_log']['failed'] as $log_entry) |
|
| 1072 | + if (!empty($context['send_log']['failed'])) { |
|
| 1073 | + foreach ($context['send_log']['failed'] as $log_entry) |
|
| 1016 | 1074 | echo ' |
| 1017 | 1075 | <span class="error">', $log_entry, '</span><br>'; |
| 1076 | + } |
|
| 1018 | 1077 | |
| 1019 | 1078 | echo ' |
| 1020 | 1079 | </div> |
@@ -1063,12 +1122,13 @@ discard block |
||
| 1063 | 1122 | </dl> |
| 1064 | 1123 | </div>'; |
| 1065 | 1124 | |
| 1066 | - if (!empty($modSettings['drafts_pm_enabled'])) |
|
| 1067 | - echo ' |
|
| 1125 | + if (!empty($modSettings['drafts_pm_enabled'])) { |
|
| 1126 | + echo ' |
|
| 1068 | 1127 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
| 1069 | 1128 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
| 1070 | 1129 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
| 1071 | 1130 | </div>'; |
| 1131 | + } |
|
| 1072 | 1132 | |
| 1073 | 1133 | echo ' |
| 1074 | 1134 | <dl id="post_header">'; |
@@ -1117,26 +1177,29 @@ discard block |
||
| 1117 | 1177 | <hr>'; |
| 1118 | 1178 | |
| 1119 | 1179 | // Showing BBC? |
| 1120 | - if ($context['show_bbc']) |
|
| 1121 | - echo ' |
|
| 1180 | + if ($context['show_bbc']) { |
|
| 1181 | + echo ' |
|
| 1122 | 1182 | <div id="bbcBox_message"></div>'; |
| 1183 | + } |
|
| 1123 | 1184 | |
| 1124 | 1185 | // What about smileys? |
| 1125 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
| 1126 | - echo ' |
|
| 1186 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
| 1187 | + echo ' |
|
| 1127 | 1188 | <div id="smileyBox_message"></div>'; |
| 1189 | + } |
|
| 1128 | 1190 | |
| 1129 | 1191 | // Show BBC buttons, smileys and textbox. |
| 1130 | 1192 | echo ' |
| 1131 | 1193 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
| 1132 | 1194 | |
| 1133 | 1195 | // Require an image to be typed to save spamming? |
| 1134 | - if ($context['require_verification']) |
|
| 1135 | - echo ' |
|
| 1196 | + if ($context['require_verification']) { |
|
| 1197 | + echo ' |
|
| 1136 | 1198 | <div class="post_verification"> |
| 1137 | 1199 | <strong>', $txt['pm_visual_verification_label'], ':</strong> |
| 1138 | 1200 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 1139 | 1201 | </div>'; |
| 1202 | + } |
|
| 1140 | 1203 | |
| 1141 | 1204 | // Send, Preview, spellcheck buttons. |
| 1142 | 1205 | echo ' |
@@ -1169,10 +1232,11 @@ discard block |
||
| 1169 | 1232 | <dt><strong>', $txt['subject'], '</strong></dt> |
| 1170 | 1233 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
| 1171 | 1234 | |
| 1172 | - foreach ($context['drafts'] as $draft) |
|
| 1173 | - echo ' |
|
| 1235 | + foreach ($context['drafts'] as $draft) { |
|
| 1236 | + echo ' |
|
| 1174 | 1237 | <dt>', $draft['link'], '</dt> |
| 1175 | 1238 | <dd>', $draft['poster_time'], '</dd>'; |
| 1239 | + } |
|
| 1176 | 1240 | echo ' |
| 1177 | 1241 | </dl> |
| 1178 | 1242 | </div>'; |
@@ -1279,8 +1343,8 @@ discard block |
||
| 1279 | 1343 | }'; |
| 1280 | 1344 | |
| 1281 | 1345 | // Code for showing and hiding drafts |
| 1282 | - if (!empty($context['drafts'])) |
|
| 1283 | - echo ' |
|
| 1346 | + if (!empty($context['drafts'])) { |
|
| 1347 | + echo ' |
|
| 1284 | 1348 | var oSwapDraftOptions = new smc_Toggle({ |
| 1285 | 1349 | bToggleEnabled: true, |
| 1286 | 1350 | bCurrentlyCollapsed: true, |
@@ -1302,13 +1366,14 @@ discard block |
||
| 1302 | 1366 | } |
| 1303 | 1367 | ] |
| 1304 | 1368 | });'; |
| 1369 | + } |
|
| 1305 | 1370 | |
| 1306 | 1371 | echo ' |
| 1307 | 1372 | </script>'; |
| 1308 | 1373 | |
| 1309 | 1374 | // Show the message you're replying to. |
| 1310 | - if ($context['reply']) |
|
| 1311 | - echo ' |
|
| 1375 | + if ($context['reply']) { |
|
| 1376 | + echo ' |
|
| 1312 | 1377 | <br><br> |
| 1313 | 1378 | <div class="cat_bar"> |
| 1314 | 1379 | <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3> |
@@ -1322,6 +1387,7 @@ discard block |
||
| 1322 | 1387 | ', $context['quoted_message']['body'], ' |
| 1323 | 1388 | </div> |
| 1324 | 1389 | <br class="clear">'; |
| 1390 | + } |
|
| 1325 | 1391 | |
| 1326 | 1392 | echo ' |
| 1327 | 1393 | <script> |
@@ -1333,23 +1399,25 @@ discard block |
||
| 1333 | 1399 | sToControlId: \'to_control\', |
| 1334 | 1400 | aToRecipients: ['; |
| 1335 | 1401 | |
| 1336 | - foreach ($context['recipients']['to'] as $i => $member) |
|
| 1337 | - echo ' |
|
| 1402 | + foreach ($context['recipients']['to'] as $i => $member) { |
|
| 1403 | + echo ' |
|
| 1338 | 1404 | { |
| 1339 | 1405 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1340 | 1406 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1341 | 1407 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
| 1408 | + } |
|
| 1342 | 1409 | |
| 1343 | 1410 | echo ' |
| 1344 | 1411 | ], |
| 1345 | 1412 | aBccRecipients: ['; |
| 1346 | 1413 | |
| 1347 | - foreach ($context['recipients']['bcc'] as $i => $member) |
|
| 1348 | - echo ' |
|
| 1414 | + foreach ($context['recipients']['bcc'] as $i => $member) { |
|
| 1415 | + echo ' |
|
| 1349 | 1416 | { |
| 1350 | 1417 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1351 | 1418 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1352 | 1419 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
| 1420 | + } |
|
| 1353 | 1421 | |
| 1354 | 1422 | echo ' |
| 1355 | 1423 | ], |
@@ -1438,26 +1506,28 @@ discard block |
||
| 1438 | 1506 | </th> |
| 1439 | 1507 | <th class="centertext table_icon">'; |
| 1440 | 1508 | |
| 1441 | - if (count($context['labels']) > 2) |
|
| 1442 | - echo ' |
|
| 1509 | + if (count($context['labels']) > 2) { |
|
| 1510 | + echo ' |
|
| 1443 | 1511 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
| 1512 | + } |
|
| 1444 | 1513 | |
| 1445 | 1514 | echo ' |
| 1446 | 1515 | </th> |
| 1447 | 1516 | </tr> |
| 1448 | 1517 | </thead> |
| 1449 | 1518 | <tbody>'; |
| 1450 | - if (count($context['labels']) < 2) |
|
| 1451 | - echo ' |
|
| 1519 | + if (count($context['labels']) < 2) { |
|
| 1520 | + echo ' |
|
| 1452 | 1521 | <tr class="windowbg"> |
| 1453 | 1522 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
| 1454 | 1523 | </tr>'; |
| 1455 | - else |
|
| 1524 | + } else |
|
| 1456 | 1525 | { |
| 1457 | 1526 | foreach ($context['labels'] as $label) |
| 1458 | 1527 | { |
| 1459 | - if ($label['id'] == -1) |
|
| 1460 | - continue; |
|
| 1528 | + if ($label['id'] == -1) { |
|
| 1529 | + continue; |
|
| 1530 | + } |
|
| 1461 | 1531 | |
| 1462 | 1532 | echo ' |
| 1463 | 1533 | <tr class="windowbg"> |
@@ -1472,12 +1542,13 @@ discard block |
||
| 1472 | 1542 | </tbody> |
| 1473 | 1543 | </table>'; |
| 1474 | 1544 | |
| 1475 | - if (!count($context['labels']) < 2) |
|
| 1476 | - echo ' |
|
| 1545 | + if (!count($context['labels']) < 2) { |
|
| 1546 | + echo ' |
|
| 1477 | 1547 | <div class="padding"> |
| 1478 | 1548 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
| 1479 | 1549 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure"> |
| 1480 | 1550 | </div>'; |
| 1551 | + } |
|
| 1481 | 1552 | |
| 1482 | 1553 | echo ' |
| 1483 | 1554 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1534,9 +1605,10 @@ discard block |
||
| 1534 | 1605 | <select name="id_admin"> |
| 1535 | 1606 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
| 1536 | 1607 | |
| 1537 | - foreach ($context['admins'] as $id => $name) |
|
| 1538 | - echo ' |
|
| 1608 | + foreach ($context['admins'] as $id => $name) { |
|
| 1609 | + echo ' |
|
| 1539 | 1610 | <option value="', $id, '">', $name, '</option>'; |
| 1611 | + } |
|
| 1540 | 1612 | |
| 1541 | 1613 | echo ' |
| 1542 | 1614 | </select> |
@@ -1599,9 +1671,10 @@ discard block |
||
| 1599 | 1671 | </th> |
| 1600 | 1672 | <th class="centertext table_icon">'; |
| 1601 | 1673 | |
| 1602 | - if (!empty($context['rules'])) |
|
| 1603 | - echo ' |
|
| 1674 | + if (!empty($context['rules'])) { |
|
| 1675 | + echo ' |
|
| 1604 | 1676 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
| 1677 | + } |
|
| 1605 | 1678 | |
| 1606 | 1679 | echo ' |
| 1607 | 1680 | </th> |
@@ -1609,16 +1682,17 @@ discard block |
||
| 1609 | 1682 | </thead> |
| 1610 | 1683 | <tbody>'; |
| 1611 | 1684 | |
| 1612 | - if (empty($context['rules'])) |
|
| 1613 | - echo ' |
|
| 1685 | + if (empty($context['rules'])) { |
|
| 1686 | + echo ' |
|
| 1614 | 1687 | <tr class="windowbg"> |
| 1615 | 1688 | <td colspan="2"> |
| 1616 | 1689 | ', $txt['pm_rules_none'], ' |
| 1617 | 1690 | </td> |
| 1618 | 1691 | </tr>'; |
| 1692 | + } |
|
| 1619 | 1693 | |
| 1620 | - foreach ($context['rules'] as $rule) |
|
| 1621 | - echo ' |
|
| 1694 | + foreach ($context['rules'] as $rule) { |
|
| 1695 | + echo ' |
|
| 1622 | 1696 | <tr class="windowbg"> |
| 1623 | 1697 | <td> |
| 1624 | 1698 | <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a> |
@@ -1627,6 +1701,7 @@ discard block |
||
| 1627 | 1701 | <input type="checkbox" name="delrule[', $rule['id'], ']"> |
| 1628 | 1702 | </td> |
| 1629 | 1703 | </tr>'; |
| 1704 | + } |
|
| 1630 | 1705 | |
| 1631 | 1706 | echo ' |
| 1632 | 1707 | </tbody> |
@@ -1634,14 +1709,16 @@ discard block |
||
| 1634 | 1709 | <div class="righttext"> |
| 1635 | 1710 | <a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
| 1636 | 1711 | |
| 1637 | - if (!empty($context['rules'])) |
|
| 1638 | - echo ' |
|
| 1712 | + if (!empty($context['rules'])) { |
|
| 1713 | + echo ' |
|
| 1639 | 1714 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
| 1715 | + } |
|
| 1640 | 1716 | |
| 1641 | - if (!empty($context['rules'])) |
|
| 1642 | - echo ' |
|
| 1717 | + if (!empty($context['rules'])) { |
|
| 1718 | + echo ' |
|
| 1643 | 1719 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1644 | 1720 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">'; |
| 1721 | + } |
|
| 1645 | 1722 | |
| 1646 | 1723 | echo ' |
| 1647 | 1724 | </div> |
@@ -1663,14 +1740,16 @@ discard block |
||
| 1663 | 1740 | var groups = new Array() |
| 1664 | 1741 | var labels = new Array()'; |
| 1665 | 1742 | |
| 1666 | - foreach ($context['groups'] as $id => $title) |
|
| 1667 | - echo ' |
|
| 1743 | + foreach ($context['groups'] as $id => $title) { |
|
| 1744 | + echo ' |
|
| 1668 | 1745 | groups[', $id, '] = "', addslashes($title), '";'; |
| 1746 | + } |
|
| 1669 | 1747 | |
| 1670 | - foreach ($context['labels'] as $label) |
|
| 1671 | - if ($label['id'] != -1) |
|
| 1748 | + foreach ($context['labels'] as $label) { |
|
| 1749 | + if ($label['id'] != -1) |
|
| 1672 | 1750 | echo ' |
| 1673 | 1751 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
| 1752 | + } |
|
| 1674 | 1753 | |
| 1675 | 1754 | echo ' |
| 1676 | 1755 | function addCriteriaOption() |
@@ -1685,8 +1764,9 @@ discard block |
||
| 1685 | 1764 | |
| 1686 | 1765 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
| 1687 | 1766 | |
| 1688 | - foreach ($context['groups'] as $id => $group) |
|
| 1689 | - echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1767 | + foreach ($context['groups'] as $id => $group) { |
|
| 1768 | + echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1769 | + } |
|
| 1690 | 1770 | |
| 1691 | 1771 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
| 1692 | 1772 | } |
@@ -1703,9 +1783,10 @@ discard block |
||
| 1703 | 1783 | |
| 1704 | 1784 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
| 1705 | 1785 | |
| 1706 | - foreach ($context['labels'] as $label) |
|
| 1707 | - if ($label['id'] != -1) |
|
| 1786 | + foreach ($context['labels'] as $label) { |
|
| 1787 | + if ($label['id'] != -1) |
|
| 1708 | 1788 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
| 1789 | + } |
|
| 1709 | 1790 | |
| 1710 | 1791 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
| 1711 | 1792 | } |
@@ -1819,19 +1900,20 @@ discard block |
||
| 1819 | 1900 | $isFirst = true; |
| 1820 | 1901 | foreach ($context['rule']['criteria'] as $k => $criteria) |
| 1821 | 1902 | { |
| 1822 | - if (!$isFirst && $criteria['t'] == '') |
|
| 1823 | - echo '<div id="removeonjs1">'; |
|
| 1824 | - |
|
| 1825 | - elseif (!$isFirst) |
|
| 1826 | - echo '<br>'; |
|
| 1903 | + if (!$isFirst && $criteria['t'] == '') { |
|
| 1904 | + echo '<div id="removeonjs1">'; |
|
| 1905 | + } elseif (!$isFirst) { |
|
| 1906 | + echo '<br>'; |
|
| 1907 | + } |
|
| 1827 | 1908 | |
| 1828 | 1909 | echo ' |
| 1829 | 1910 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
| 1830 | 1911 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
| 1831 | 1912 | |
| 1832 | - foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
|
| 1833 | - echo ' |
|
| 1913 | + foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) { |
|
| 1914 | + echo ' |
|
| 1834 | 1915 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
| 1916 | + } |
|
| 1835 | 1917 | |
| 1836 | 1918 | echo ' |
| 1837 | 1919 | </select> |
@@ -1842,19 +1924,20 @@ discard block |
||
| 1842 | 1924 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
| 1843 | 1925 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
| 1844 | 1926 | |
| 1845 | - foreach ($context['groups'] as $id => $group) |
|
| 1846 | - echo ' |
|
| 1927 | + foreach ($context['groups'] as $id => $group) { |
|
| 1928 | + echo ' |
|
| 1847 | 1929 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
| 1930 | + } |
|
| 1848 | 1931 | echo ' |
| 1849 | 1932 | </select> |
| 1850 | 1933 | </span>'; |
| 1851 | 1934 | |
| 1852 | 1935 | // If this is the dummy we add a means to hide for non js users. |
| 1853 | - if ($isFirst) |
|
| 1854 | - $isFirst = false; |
|
| 1855 | - |
|
| 1856 | - elseif ($criteria['t'] == '') |
|
| 1857 | - echo '</div><!-- .removeonjs1 -->'; |
|
| 1936 | + if ($isFirst) { |
|
| 1937 | + $isFirst = false; |
|
| 1938 | + } elseif ($criteria['t'] == '') { |
|
| 1939 | + echo '</div><!-- .removeonjs1 -->'; |
|
| 1940 | + } |
|
| 1858 | 1941 | } |
| 1859 | 1942 | |
| 1860 | 1943 | echo ' |
@@ -1877,10 +1960,11 @@ discard block |
||
| 1877 | 1960 | $isFirst = true; |
| 1878 | 1961 | foreach ($context['rule']['actions'] as $k => $action) |
| 1879 | 1962 | { |
| 1880 | - if (!$isFirst && $action['t'] == '') |
|
| 1881 | - echo '<div id="removeonjs2">'; |
|
| 1882 | - elseif (!$isFirst) |
|
| 1883 | - echo '<br>'; |
|
| 1963 | + if (!$isFirst && $action['t'] == '') { |
|
| 1964 | + echo '<div id="removeonjs2">'; |
|
| 1965 | + } elseif (!$isFirst) { |
|
| 1966 | + echo '<br>'; |
|
| 1967 | + } |
|
| 1884 | 1968 | |
| 1885 | 1969 | echo ' |
| 1886 | 1970 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
@@ -1892,20 +1976,21 @@ discard block |
||
| 1892 | 1976 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
| 1893 | 1977 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
| 1894 | 1978 | |
| 1895 | - foreach ($context['labels'] as $label) |
|
| 1896 | - if ($label['id'] != -1) |
|
| 1979 | + foreach ($context['labels'] as $label) { |
|
| 1980 | + if ($label['id'] != -1) |
|
| 1897 | 1981 | echo ' |
| 1898 | 1982 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
| 1983 | + } |
|
| 1899 | 1984 | |
| 1900 | 1985 | echo ' |
| 1901 | 1986 | </select> |
| 1902 | 1987 | </span>'; |
| 1903 | 1988 | |
| 1904 | - if ($isFirst) |
|
| 1905 | - $isFirst = false; |
|
| 1906 | - |
|
| 1907 | - elseif ($action['t'] == '') |
|
| 1908 | - echo '</div><!-- .removeonjs2 -->'; |
|
| 1989 | + if ($isFirst) { |
|
| 1990 | + $isFirst = false; |
|
| 1991 | + } elseif ($action['t'] == '') { |
|
| 1992 | + echo '</div><!-- .removeonjs2 -->'; |
|
| 1993 | + } |
|
| 1909 | 1994 | } |
| 1910 | 1995 | |
| 1911 | 1996 | echo ' |
@@ -1929,22 +2014,25 @@ discard block |
||
| 1929 | 2014 | echo ' |
| 1930 | 2015 | <script>'; |
| 1931 | 2016 | |
| 1932 | - foreach ($context['rule']['criteria'] as $k => $c) |
|
| 1933 | - echo ' |
|
| 2017 | + foreach ($context['rule']['criteria'] as $k => $c) { |
|
| 2018 | + echo ' |
|
| 1934 | 2019 | updateRuleDef(', $k, ');'; |
| 2020 | + } |
|
| 1935 | 2021 | |
| 1936 | - foreach ($context['rule']['actions'] as $k => $c) |
|
| 1937 | - echo ' |
|
| 2022 | + foreach ($context['rule']['actions'] as $k => $c) { |
|
| 2023 | + echo ' |
|
| 1938 | 2024 | updateActionDef(', $k, ');'; |
| 2025 | + } |
|
| 1939 | 2026 | |
| 1940 | 2027 | echo ' |
| 1941 | 2028 | rebuildRuleDesc();'; |
| 1942 | 2029 | |
| 1943 | 2030 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
| 1944 | - if ($context['rid']) |
|
| 1945 | - echo ' |
|
| 2031 | + if ($context['rid']) { |
|
| 2032 | + echo ' |
|
| 1946 | 2033 | document.getElementById("removeonjs1").style.display = "none"; |
| 1947 | 2034 | document.getElementById("removeonjs2").style.display = "none";'; |
| 2035 | + } |
|
| 1948 | 2036 | |
| 1949 | 2037 | echo ' |
| 1950 | 2038 | document.getElementById("addonjs1").style.display = ""; |
@@ -1972,12 +2060,12 @@ discard block |
||
| 1972 | 2060 | </div>'; |
| 1973 | 2061 | |
| 1974 | 2062 | // No drafts? Just show an informative message. |
| 1975 | - if (empty($context['drafts'])) |
|
| 1976 | - echo ' |
|
| 2063 | + if (empty($context['drafts'])) { |
|
| 2064 | + echo ' |
|
| 1977 | 2065 | <div class="windowbg2 centertext"> |
| 1978 | 2066 | ', $txt['draft_none'], ' |
| 1979 | 2067 | </div>'; |
| 1980 | - else |
|
| 2068 | + } else |
|
| 1981 | 2069 | { |
| 1982 | 2070 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 1983 | 2071 | foreach ($context['drafts'] as $draft) |
@@ -18,23 +18,25 @@ discard block |
||
| 18 | 18 | global $context; |
| 19 | 19 | |
| 20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
| 21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
| 22 | - echo ' |
|
| 21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <script> |
| 24 | 24 | disableAutoComplete(); |
| 25 | 25 | </script>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
| 28 | 29 | echo ' |
| 29 | 30 | ', template_error_message(); |
| 30 | 31 | |
| 31 | 32 | // If the profile was update successfully, let the user know this. |
| 32 | - if (!empty($context['profile_updated'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['profile_updated'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <div class="infobox"> |
| 35 | 36 | ', $context['profile_updated'], ' |
| 36 | 37 | </div>'; |
| 37 | -} |
|
| 38 | + } |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | /** |
| 40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -99,19 +101,19 @@ discard block |
||
| 99 | 101 | </div> |
| 100 | 102 | <div class="alerts_unread">'; |
| 101 | 103 | |
| 102 | - if (empty($context['unread_alerts'])) |
|
| 103 | - template_alerts_all_read(); |
|
| 104 | - |
|
| 105 | - else |
|
| 104 | + if (empty($context['unread_alerts'])) { |
|
| 105 | + template_alerts_all_read(); |
|
| 106 | + } else |
|
| 106 | 107 | { |
| 107 | - foreach ($context['unread_alerts'] as $id_alert => $details) |
|
| 108 | - echo ' |
|
| 108 | + foreach ($context['unread_alerts'] as $id_alert => $details) { |
|
| 109 | + echo ' |
|
| 109 | 110 | <div class="unread"> |
| 110 | 111 | ', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', ' |
| 111 | 112 | <div class="details"> |
| 112 | 113 | ', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], ' |
| 113 | 114 | </div> |
| 114 | 115 | </div>'; |
| 116 | + } |
|
| 115 | 117 | } |
| 116 | 118 | |
| 117 | 119 | echo ' |
@@ -161,10 +163,11 @@ discard block |
||
| 161 | 163 | <div class="custom_fields_above_name"> |
| 162 | 164 | <ul>'; |
| 163 | 165 | |
| 164 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
| 165 | - if (!empty($field['output_html'])) |
|
| 166 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
| 167 | + if (!empty($field['output_html'])) |
|
| 166 | 168 | echo ' |
| 167 | 169 | <li>', $field['output_html'], '</li>'; |
| 170 | + } |
|
| 168 | 171 | |
| 169 | 172 | echo ' |
| 170 | 173 | </ul> |
@@ -176,20 +179,22 @@ discard block |
||
| 176 | 179 | <div class="username clear"> |
| 177 | 180 | <h4>'; |
| 178 | 181 | |
| 179 | - if (!empty($context['print_custom_fields']['before_member'])) |
|
| 180 | - foreach ($context['print_custom_fields']['before_member'] as $field) |
|
| 182 | + if (!empty($context['print_custom_fields']['before_member'])) { |
|
| 183 | + foreach ($context['print_custom_fields']['before_member'] as $field) |
|
| 181 | 184 | if (!empty($field['output_html'])) |
| 182 | 185 | echo ' |
| 183 | 186 | <span>', $field['output_html'], '</span>'; |
| 187 | + } |
|
| 184 | 188 | |
| 185 | 189 | echo ' |
| 186 | 190 | ', $context['member']['name']; |
| 187 | 191 | |
| 188 | - if (!empty($context['print_custom_fields']['after_member'])) |
|
| 189 | - foreach ($context['print_custom_fields']['after_member'] as $field) |
|
| 192 | + if (!empty($context['print_custom_fields']['after_member'])) { |
|
| 193 | + foreach ($context['print_custom_fields']['after_member'] as $field) |
|
| 190 | 194 | if (!empty($field['output_html'])) |
| 191 | 195 | echo ' |
| 192 | 196 | <span>', $field['output_html'], '</span>'; |
| 197 | + } |
|
| 193 | 198 | |
| 194 | 199 | |
| 195 | 200 | echo ' |
@@ -205,10 +210,11 @@ discard block |
||
| 205 | 210 | <div class="custom_fields_below_avatar"> |
| 206 | 211 | <ul>'; |
| 207 | 212 | |
| 208 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
| 209 | - if (!empty($field['output_html'])) |
|
| 213 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
| 214 | + if (!empty($field['output_html'])) |
|
| 210 | 215 | echo ' |
| 211 | 216 | <li>', $field['output_html'], '</li>'; |
| 217 | + } |
|
| 212 | 218 | |
| 213 | 219 | echo ' |
| 214 | 220 | </ul> |
@@ -220,22 +226,25 @@ discard block |
||
| 220 | 226 | <ul class="clear">'; |
| 221 | 227 | |
| 222 | 228 | // Email is only visible if it's your profile or you have the moderate_forum permission |
| 223 | - if ($context['member']['show_email']) |
|
| 224 | - echo ' |
|
| 229 | + if ($context['member']['show_email']) { |
|
| 230 | + echo ' |
|
| 225 | 231 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
| 232 | + } |
|
| 226 | 233 | |
| 227 | 234 | // Don't show an icon if they haven't specified a website. |
| 228 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
| 229 | - echo ' |
|
| 235 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
| 236 | + echo ' |
|
| 230 | 237 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 238 | + } |
|
| 231 | 239 | |
| 232 | 240 | // Are there any custom profile fields as icons? |
| 233 | 241 | if (!empty($context['print_custom_fields']['icons'])) |
| 234 | 242 | { |
| 235 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
| 236 | - if (!empty($field['output_html'])) |
|
| 243 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
| 244 | + if (!empty($field['output_html'])) |
|
| 237 | 245 | echo ' |
| 238 | 246 | <li class="custom_field">', $field['output_html'], '</li>'; |
| 247 | + } |
|
| 239 | 248 | } |
| 240 | 249 | |
| 241 | 250 | echo ' |
@@ -244,24 +253,27 @@ discard block |
||
| 244 | 253 | ', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
| 245 | 254 | |
| 246 | 255 | // Can they add this member as a buddy? |
| 247 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
| 248 | - echo ' |
|
| 256 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
| 257 | + echo ' |
|
| 249 | 258 | <br> |
| 250 | 259 | <a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
| 260 | + } |
|
| 251 | 261 | |
| 252 | 262 | echo ' |
| 253 | 263 | </span>'; |
| 254 | 264 | |
| 255 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
| 256 | - echo ' |
|
| 265 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
| 266 | + echo ' |
|
| 257 | 267 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
| 268 | + } |
|
| 258 | 269 | |
| 259 | 270 | echo ' |
| 260 | 271 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
| 261 | 272 | |
| 262 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
| 263 | - echo ' |
|
| 273 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
| 274 | + echo ' |
|
| 264 | 275 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
| 276 | + } |
|
| 265 | 277 | |
| 266 | 278 | echo ' |
| 267 | 279 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -273,10 +285,11 @@ discard block |
||
| 273 | 285 | <div class="custom_fields_bottom"> |
| 274 | 286 | <ul class="nolist">'; |
| 275 | 287 | |
| 276 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
| 277 | - if (!empty($field['output_html'])) |
|
| 288 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
| 289 | + if (!empty($field['output_html'])) |
|
| 278 | 290 | echo ' |
| 279 | 291 | <li>', $field['output_html'], '</li>'; |
| 292 | + } |
|
| 280 | 293 | |
| 281 | 294 | echo ' |
| 282 | 295 | </ul> |
@@ -289,30 +302,35 @@ discard block |
||
| 289 | 302 | <div id="detailedinfo"> |
| 290 | 303 | <dl class="settings">'; |
| 291 | 304 | |
| 292 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
| 293 | - echo ' |
|
| 305 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
| 306 | + echo ' |
|
| 294 | 307 | <dt>', $txt['username'], ': </dt> |
| 295 | 308 | <dd>', $context['member']['username'], '</dd>'; |
| 309 | + } |
|
| 296 | 310 | |
| 297 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 298 | - echo ' |
|
| 311 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 312 | + echo ' |
|
| 299 | 313 | <dt>', $txt['profile_posts'], ': </dt> |
| 300 | 314 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
| 315 | + } |
|
| 301 | 316 | |
| 302 | - if ($context['member']['show_email']) |
|
| 303 | - echo ' |
|
| 317 | + if ($context['member']['show_email']) { |
|
| 318 | + echo ' |
|
| 304 | 319 | <dt>', $txt['email'], ': </dt> |
| 305 | 320 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
| 321 | + } |
|
| 306 | 322 | |
| 307 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
| 308 | - echo ' |
|
| 323 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
| 324 | + echo ' |
|
| 309 | 325 | <dt>', $txt['custom_title'], ': </dt> |
| 310 | 326 | <dd>', $context['member']['title'], '</dd>'; |
| 327 | + } |
|
| 311 | 328 | |
| 312 | - if (!empty($context['member']['blurb'])) |
|
| 313 | - echo ' |
|
| 329 | + if (!empty($context['member']['blurb'])) { |
|
| 330 | + echo ' |
|
| 314 | 331 | <dt>', $txt['personal_text'], ': </dt> |
| 315 | 332 | <dd>', $context['member']['blurb'], '</dd>'; |
| 333 | + } |
|
| 316 | 334 | |
| 317 | 335 | echo ' |
| 318 | 336 | <dt>', $txt['age'], ':</dt> |
@@ -326,19 +344,21 @@ discard block |
||
| 326 | 344 | { |
| 327 | 345 | $fields = array(); |
| 328 | 346 | |
| 329 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
| 330 | - if (!empty($field['output_html'])) |
|
| 347 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
| 348 | + if (!empty($field['output_html'])) |
|
| 331 | 349 | $fields[] = $field; |
| 350 | + } |
|
| 332 | 351 | |
| 333 | 352 | if (count($fields) > 0) |
| 334 | 353 | { |
| 335 | 354 | echo ' |
| 336 | 355 | <dl class="settings">'; |
| 337 | 356 | |
| 338 | - foreach ($fields as $field) |
|
| 339 | - echo ' |
|
| 357 | + foreach ($fields as $field) { |
|
| 358 | + echo ' |
|
| 340 | 359 | <dt>', $field['name'], ':</dt> |
| 341 | 360 | <dd>', $field['output_html'], '</dd>'; |
| 361 | + } |
|
| 342 | 362 | |
| 343 | 363 | echo ' |
| 344 | 364 | </dl>'; |
@@ -358,9 +378,10 @@ discard block |
||
| 358 | 378 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
| 359 | 379 | |
| 360 | 380 | // Can we provide information on what this means? |
| 361 | - if (!empty($context['warning_status'])) |
|
| 362 | - echo ' |
|
| 381 | + if (!empty($context['warning_status'])) { |
|
| 382 | + echo ' |
|
| 363 | 383 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
| 384 | + } |
|
| 364 | 385 | |
| 365 | 386 | echo ' |
| 366 | 387 | </dd>'; |
@@ -371,11 +392,12 @@ discard block |
||
| 371 | 392 | { |
| 372 | 393 | |
| 373 | 394 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
| 374 | - if (!empty($context['activate_message'])) |
|
| 375 | - echo ' |
|
| 395 | + if (!empty($context['activate_message'])) { |
|
| 396 | + echo ' |
|
| 376 | 397 | <dt class="clear"> |
| 377 | 398 | <span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>) |
| 378 | 399 | </dt>'; |
| 400 | + } |
|
| 379 | 401 | |
| 380 | 402 | // If the current member is banned, show a message and possibly a link to the ban. |
| 381 | 403 | if (!empty($context['member']['bans'])) |
@@ -387,10 +409,11 @@ discard block |
||
| 387 | 409 | <dt class="clear" id="ban_info" style="display: none;"> |
| 388 | 410 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
| 389 | 411 | |
| 390 | - foreach ($context['member']['bans'] as $ban) |
|
| 391 | - echo ' |
|
| 412 | + foreach ($context['member']['bans'] as $ban) { |
|
| 413 | + echo ' |
|
| 392 | 414 | <br> |
| 393 | 415 | <span class="smalltext">', $ban['explanation'], '</span>'; |
| 416 | + } |
|
| 394 | 417 | |
| 395 | 418 | echo ' |
| 396 | 419 | </dt>'; |
@@ -404,30 +427,34 @@ discard block |
||
| 404 | 427 | // If the person looking is allowed, they can check the members IP address and hostname. |
| 405 | 428 | if ($context['can_see_ip']) |
| 406 | 429 | { |
| 407 | - if (!empty($context['member']['ip'])) |
|
| 408 | - echo ' |
|
| 430 | + if (!empty($context['member']['ip'])) { |
|
| 431 | + echo ' |
|
| 409 | 432 | <dt>', $txt['ip'], ': </dt> |
| 410 | 433 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
| 434 | + } |
|
| 411 | 435 | |
| 412 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
| 413 | - echo ' |
|
| 436 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
| 437 | + echo ' |
|
| 414 | 438 | <dt>', $txt['hostname'], ': </dt> |
| 415 | 439 | <dd>', $context['member']['hostname'], '</dd>'; |
| 440 | + } |
|
| 416 | 441 | } |
| 417 | 442 | |
| 418 | 443 | echo ' |
| 419 | 444 | <dt>', $txt['local_time'], ':</dt> |
| 420 | 445 | <dd>', $context['member']['local_time'], '</dd>'; |
| 421 | 446 | |
| 422 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
| 423 | - echo ' |
|
| 447 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
| 448 | + echo ' |
|
| 424 | 449 | <dt>', $txt['language'], ':</dt> |
| 425 | 450 | <dd>', $context['member']['language'], '</dd>'; |
| 451 | + } |
|
| 426 | 452 | |
| 427 | - if ($context['member']['show_last_login']) |
|
| 428 | - echo ' |
|
| 453 | + if ($context['member']['show_last_login']) { |
|
| 454 | + echo ' |
|
| 429 | 455 | <dt>', $txt['lastLoggedIn'], ': </dt> |
| 430 | 456 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
| 457 | + } |
|
| 431 | 458 | |
| 432 | 459 | echo ' |
| 433 | 460 | </dl>'; |
@@ -439,10 +466,11 @@ discard block |
||
| 439 | 466 | <div class="custom_fields_above_signature"> |
| 440 | 467 | <ul class="nolist">'; |
| 441 | 468 | |
| 442 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
| 443 | - if (!empty($field['output_html'])) |
|
| 469 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
| 470 | + if (!empty($field['output_html'])) |
|
| 444 | 471 | echo ' |
| 445 | 472 | <li>', $field['output_html'], '</li>'; |
| 473 | + } |
|
| 446 | 474 | |
| 447 | 475 | echo ' |
| 448 | 476 | </ul> |
@@ -450,12 +478,13 @@ discard block |
||
| 450 | 478 | } |
| 451 | 479 | |
| 452 | 480 | // Show the users signature. |
| 453 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
| 454 | - echo ' |
|
| 481 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
| 482 | + echo ' |
|
| 455 | 483 | <div class="signature"> |
| 456 | 484 | <h5>', $txt['signature'], ':</h5> |
| 457 | 485 | ', $context['member']['signature'], ' |
| 458 | 486 | </div>'; |
| 487 | + } |
|
| 459 | 488 | |
| 460 | 489 | // Are there any custom profile fields for below the signature? |
| 461 | 490 | if (!empty($context['print_custom_fields']['below_signature'])) |
@@ -464,10 +493,11 @@ discard block |
||
| 464 | 493 | <div class="custom_fields_below_signature"> |
| 465 | 494 | <ul class="nolist">'; |
| 466 | 495 | |
| 467 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
| 468 | - if (!empty($field['output_html'])) |
|
| 496 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
| 497 | + if (!empty($field['output_html'])) |
|
| 469 | 498 | echo ' |
| 470 | 499 | <li>', $field['output_html'], '</li>'; |
| 500 | + } |
|
| 471 | 501 | |
| 472 | 502 | echo ' |
| 473 | 503 | </ul> |
@@ -513,62 +543,70 @@ discard block |
||
| 513 | 543 | </div> |
| 514 | 544 | <div class="list_posts">'; |
| 515 | 545 | |
| 516 | - if (!$post['approved']) |
|
| 517 | - echo ' |
|
| 546 | + if (!$post['approved']) { |
|
| 547 | + echo ' |
|
| 518 | 548 | <div class="approve_post"> |
| 519 | 549 | <em>', $txt['post_awaiting_approval'], '</em> |
| 520 | 550 | </div>'; |
| 551 | + } |
|
| 521 | 552 | |
| 522 | 553 | echo ' |
| 523 | 554 | ', $post['body'], ' |
| 524 | 555 | </div>'; |
| 525 | 556 | |
| 526 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 527 | - echo ' |
|
| 557 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 558 | + echo ' |
|
| 528 | 559 | <div class="floatright"> |
| 529 | 560 | <ul class="quickbuttons">'; |
| 561 | + } |
|
| 530 | 562 | |
| 531 | 563 | // If they *can* reply? |
| 532 | - if ($post['can_reply']) |
|
| 533 | - echo ' |
|
| 564 | + if ($post['can_reply']) { |
|
| 565 | + echo ' |
|
| 534 | 566 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 567 | + } |
|
| 535 | 568 | |
| 536 | 569 | // If they *can* quote? |
| 537 | - if ($post['can_quote']) |
|
| 538 | - echo ' |
|
| 570 | + if ($post['can_quote']) { |
|
| 571 | + echo ' |
|
| 539 | 572 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 573 | + } |
|
| 540 | 574 | |
| 541 | 575 | // How about... even... remove it entirely?! |
| 542 | - if ($post['can_delete']) |
|
| 543 | - echo ' |
|
| 576 | + if ($post['can_delete']) { |
|
| 577 | + echo ' |
|
| 544 | 578 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 579 | + } |
|
| 545 | 580 | |
| 546 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 547 | - echo ' |
|
| 581 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 582 | + echo ' |
|
| 548 | 583 | </ul> |
| 549 | 584 | </div><!-- .floatright -->'; |
| 585 | + } |
|
| 550 | 586 | |
| 551 | 587 | echo ' |
| 552 | 588 | </div><!-- $post[css_class] -->'; |
| 553 | 589 | } |
| 590 | + } else { |
|
| 591 | + template_show_list('attachments'); |
|
| 554 | 592 | } |
| 555 | - else |
|
| 556 | - template_show_list('attachments'); |
|
| 557 | 593 | |
| 558 | 594 | // No posts? Just end with a informative message. |
| 559 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
| 560 | - echo ' |
|
| 595 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
| 596 | + echo ' |
|
| 561 | 597 | <div class="windowbg2"> |
| 562 | 598 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
| 563 | 599 | </div>'; |
| 600 | + } |
|
| 564 | 601 | |
| 565 | 602 | // Show more page numbers. |
| 566 | - if (!empty($context['page_index'])) |
|
| 567 | - echo ' |
|
| 603 | + if (!empty($context['page_index'])) { |
|
| 604 | + echo ' |
|
| 568 | 605 | <div class="pagesection"> |
| 569 | 606 | <div class="pagelinks">', $context['page_index'], '</div> |
| 570 | 607 | </div>'; |
| 571 | -} |
|
| 608 | + } |
|
| 609 | + } |
|
| 572 | 610 | |
| 573 | 611 | /** |
| 574 | 612 | * Template for showing alerts within the alerts popup |
@@ -578,11 +616,12 @@ discard block |
||
| 578 | 616 | global $context, $txt, $scripturl; |
| 579 | 617 | |
| 580 | 618 | // Do we have an update message? |
| 581 | - if (!empty($context['update_message'])) |
|
| 582 | - echo ' |
|
| 619 | + if (!empty($context['update_message'])) { |
|
| 620 | + echo ' |
|
| 583 | 621 | <div class="infobox"> |
| 584 | 622 | ', $context['update_message'], '. |
| 585 | 623 | </div>'; |
| 624 | + } |
|
| 586 | 625 | |
| 587 | 626 | echo ' |
| 588 | 627 | <div class="cat_bar"> |
@@ -591,13 +630,12 @@ discard block |
||
| 591 | 630 | </h3> |
| 592 | 631 | </div>'; |
| 593 | 632 | |
| 594 | - if (empty($context['alerts'])) |
|
| 595 | - echo ' |
|
| 633 | + if (empty($context['alerts'])) { |
|
| 634 | + echo ' |
|
| 596 | 635 | <div class="information"> |
| 597 | 636 | ', $txt['alerts_none'], ' |
| 598 | 637 | </div>'; |
| 599 | - |
|
| 600 | - else |
|
| 638 | + } else |
|
| 601 | 639 | { |
| 602 | 640 | // Start the form. |
| 603 | 641 | echo ' |
@@ -659,12 +697,12 @@ discard block |
||
| 659 | 697 | </div>' : ''; |
| 660 | 698 | |
| 661 | 699 | // No drafts? Just show an informative message. |
| 662 | - if (empty($context['drafts'])) |
|
| 663 | - echo ' |
|
| 700 | + if (empty($context['drafts'])) { |
|
| 701 | + echo ' |
|
| 664 | 702 | <div class="windowbg2 centertext"> |
| 665 | 703 | ', $txt['draft_none'], ' |
| 666 | 704 | </div>'; |
| 667 | - else |
|
| 705 | + } else |
|
| 668 | 706 | { |
| 669 | 707 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 670 | 708 | foreach ($context['drafts'] as $draft) |
@@ -676,13 +714,15 @@ discard block |
||
| 676 | 714 | <h5> |
| 677 | 715 | <strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
| 678 | 716 | |
| 679 | - if (!empty($draft['sticky'])) |
|
| 680 | - echo ' |
|
| 717 | + if (!empty($draft['sticky'])) { |
|
| 718 | + echo ' |
|
| 681 | 719 | <span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
| 720 | + } |
|
| 682 | 721 | |
| 683 | - if (!empty($draft['locked'])) |
|
| 684 | - echo ' |
|
| 722 | + if (!empty($draft['locked'])) { |
|
| 723 | + echo ' |
|
| 685 | 724 | <span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
| 725 | + } |
|
| 686 | 726 | |
| 687 | 727 | echo ' |
| 688 | 728 | </h5> |
@@ -715,13 +755,13 @@ discard block |
||
| 715 | 755 | { |
| 716 | 756 | global $context, $scripturl, $txt; |
| 717 | 757 | |
| 718 | - if (!empty($context['saved_successful'])) |
|
| 719 | - echo ' |
|
| 758 | + if (!empty($context['saved_successful'])) { |
|
| 759 | + echo ' |
|
| 720 | 760 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 721 | - |
|
| 722 | - elseif (!empty($context['saved_failed'])) |
|
| 723 | - echo ' |
|
| 761 | + } elseif (!empty($context['saved_failed'])) { |
|
| 762 | + echo ' |
|
| 724 | 763 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 764 | + } |
|
| 725 | 765 | |
| 726 | 766 | echo ' |
| 727 | 767 | <div id="edit_buddies"> |
@@ -736,14 +776,16 @@ discard block |
||
| 736 | 776 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 737 | 777 | <th scope="col">', $txt['status'], '</th>'; |
| 738 | 778 | |
| 739 | - if (allowedTo('moderate_forum')) |
|
| 740 | - echo ' |
|
| 779 | + if (allowedTo('moderate_forum')) { |
|
| 780 | + echo ' |
|
| 741 | 781 | <th scope="col">', $txt['email'], '</th>'; |
| 782 | + } |
|
| 742 | 783 | |
| 743 | - if (!empty($context['custom_pf'])) |
|
| 744 | - foreach ($context['custom_pf'] as $column) |
|
| 784 | + if (!empty($context['custom_pf'])) { |
|
| 785 | + foreach ($context['custom_pf'] as $column) |
|
| 745 | 786 | echo ' |
| 746 | 787 | <th scope="col">', $column['label'], '</th>'; |
| 788 | + } |
|
| 747 | 789 | |
| 748 | 790 | echo ' |
| 749 | 791 | <th scope="col">', $txt['remove'], '</th> |
@@ -752,13 +794,14 @@ discard block |
||
| 752 | 794 | <tbody>'; |
| 753 | 795 | |
| 754 | 796 | // If they don't have any buddies don't list them! |
| 755 | - if (empty($context['buddies'])) |
|
| 756 | - echo ' |
|
| 797 | + if (empty($context['buddies'])) { |
|
| 798 | + echo ' |
|
| 757 | 799 | <tr class="windowbg"> |
| 758 | 800 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"> |
| 759 | 801 | <strong>', $txt['no_buddies'], '</strong> |
| 760 | 802 | </td> |
| 761 | 803 | </tr>'; |
| 804 | + } |
|
| 762 | 805 | |
| 763 | 806 | // Now loop through each buddy showing info on each. |
| 764 | 807 | else |
@@ -772,17 +815,19 @@ discard block |
||
| 772 | 815 | <a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a> |
| 773 | 816 | </td>'; |
| 774 | 817 | |
| 775 | - if ($buddy['show_email']) |
|
| 776 | - echo ' |
|
| 818 | + if ($buddy['show_email']) { |
|
| 819 | + echo ' |
|
| 777 | 820 | <td> |
| 778 | 821 | <a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a> |
| 779 | 822 | </td>'; |
| 823 | + } |
|
| 780 | 824 | |
| 781 | 825 | // Show the custom profile fields for this user. |
| 782 | - if (!empty($context['custom_pf'])) |
|
| 783 | - foreach ($context['custom_pf'] as $key => $column) |
|
| 826 | + if (!empty($context['custom_pf'])) { |
|
| 827 | + foreach ($context['custom_pf'] as $key => $column) |
|
| 784 | 828 | echo ' |
| 785 | 829 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
| 830 | + } |
|
| 786 | 831 | |
| 787 | 832 | echo ' |
| 788 | 833 | <td> |
@@ -815,9 +860,10 @@ discard block |
||
| 815 | 860 | </dl> |
| 816 | 861 | </div>'; |
| 817 | 862 | |
| 818 | - if (!empty($context['token_check'])) |
|
| 819 | - echo ' |
|
| 863 | + if (!empty($context['token_check'])) { |
|
| 864 | + echo ' |
|
| 820 | 865 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 866 | + } |
|
| 821 | 867 | |
| 822 | 868 | echo ' |
| 823 | 869 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -843,13 +889,13 @@ discard block |
||
| 843 | 889 | { |
| 844 | 890 | global $context, $scripturl, $txt; |
| 845 | 891 | |
| 846 | - if (!empty($context['saved_successful'])) |
|
| 847 | - echo ' |
|
| 892 | + if (!empty($context['saved_successful'])) { |
|
| 893 | + echo ' |
|
| 848 | 894 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 849 | - |
|
| 850 | - elseif (!empty($context['saved_failed'])) |
|
| 851 | - echo ' |
|
| 895 | + } elseif (!empty($context['saved_failed'])) { |
|
| 896 | + echo ' |
|
| 852 | 897 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 898 | + } |
|
| 853 | 899 | |
| 854 | 900 | echo ' |
| 855 | 901 | <div id="edit_buddies"> |
@@ -864,9 +910,10 @@ discard block |
||
| 864 | 910 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 865 | 911 | <th scope="col">', $txt['status'], '</th>'; |
| 866 | 912 | |
| 867 | - if (allowedTo('moderate_forum')) |
|
| 868 | - echo ' |
|
| 913 | + if (allowedTo('moderate_forum')) { |
|
| 914 | + echo ' |
|
| 869 | 915 | <th scope="col">', $txt['email'], '</th>'; |
| 916 | + } |
|
| 870 | 917 | |
| 871 | 918 | echo ' |
| 872 | 919 | <th scope="col">', $txt['ignore_remove'], '</th> |
@@ -875,13 +922,14 @@ discard block |
||
| 875 | 922 | <tbody>'; |
| 876 | 923 | |
| 877 | 924 | // If they don't have anyone on their ignore list, don't list it! |
| 878 | - if (empty($context['ignore_list'])) |
|
| 879 | - echo ' |
|
| 925 | + if (empty($context['ignore_list'])) { |
|
| 926 | + echo ' |
|
| 880 | 927 | <tr class="windowbg"> |
| 881 | 928 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"> |
| 882 | 929 | <strong>', $txt['no_ignore'], '</strong> |
| 883 | 930 | </td> |
| 884 | 931 | </tr>'; |
| 932 | + } |
|
| 885 | 933 | |
| 886 | 934 | // Now loop through each buddy showing info on each. |
| 887 | 935 | foreach ($context['ignore_list'] as $member) |
@@ -893,11 +941,12 @@ discard block |
||
| 893 | 941 | <a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a> |
| 894 | 942 | </td>'; |
| 895 | 943 | |
| 896 | - if ($member['show_email']) |
|
| 897 | - echo ' |
|
| 944 | + if ($member['show_email']) { |
|
| 945 | + echo ' |
|
| 898 | 946 | <td> |
| 899 | 947 | <a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a> |
| 900 | 948 | </td>'; |
| 949 | + } |
|
| 901 | 950 | echo ' |
| 902 | 951 | <td> |
| 903 | 952 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a> |
@@ -927,9 +976,10 @@ discard block |
||
| 927 | 976 | </dl> |
| 928 | 977 | </div>'; |
| 929 | 978 | |
| 930 | - if (!empty($context['token_check'])) |
|
| 931 | - echo ' |
|
| 979 | + if (!empty($context['token_check'])) { |
|
| 980 | + echo ' |
|
| 932 | 981 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 982 | + } |
|
| 933 | 983 | |
| 934 | 984 | echo ' |
| 935 | 985 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -975,9 +1025,10 @@ discard block |
||
| 975 | 1025 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
| 976 | 1026 | |
| 977 | 1027 | // Second address detected? |
| 978 | - if (!empty($context['last_ip2'])) |
|
| 979 | - echo ' |
|
| 1028 | + if (!empty($context['last_ip2'])) { |
|
| 1029 | + echo ' |
|
| 980 | 1030 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
| 1031 | + } |
|
| 981 | 1032 | |
| 982 | 1033 | echo ' |
| 983 | 1034 | </dd>'; |
@@ -1043,9 +1094,10 @@ discard block |
||
| 1043 | 1094 | </div> |
| 1044 | 1095 | <div class="windowbg2 noup">'; |
| 1045 | 1096 | |
| 1046 | - foreach ($context['whois_servers'] as $server) |
|
| 1047 | - echo ' |
|
| 1097 | + foreach ($context['whois_servers'] as $server) { |
|
| 1098 | + echo ' |
|
| 1048 | 1099 | <a href="', $server['url'], '" target="_blank" rel="noopener"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>'; |
| 1100 | + } |
|
| 1049 | 1101 | echo ' |
| 1050 | 1102 | </div> |
| 1051 | 1103 | <br>'; |
@@ -1057,13 +1109,12 @@ discard block |
||
| 1057 | 1109 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
| 1058 | 1110 | </div>'; |
| 1059 | 1111 | |
| 1060 | - if (empty($context['ips'])) |
|
| 1061 | - echo ' |
|
| 1112 | + if (empty($context['ips'])) { |
|
| 1113 | + echo ' |
|
| 1062 | 1114 | <p class="windowbg2 description"> |
| 1063 | 1115 | <em>', $txt['no_members_from_ip'], '</em> |
| 1064 | 1116 | </p>'; |
| 1065 | - |
|
| 1066 | - else |
|
| 1117 | + } else |
|
| 1067 | 1118 | { |
| 1068 | 1119 | echo ' |
| 1069 | 1120 | <table class="table_grid"> |
@@ -1076,12 +1127,13 @@ discard block |
||
| 1076 | 1127 | <tbody>'; |
| 1077 | 1128 | |
| 1078 | 1129 | // Loop through each of the members and display them. |
| 1079 | - foreach ($context['ips'] as $ip => $memberlist) |
|
| 1080 | - echo ' |
|
| 1130 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
| 1131 | + echo ' |
|
| 1081 | 1132 | <tr class="windowbg"> |
| 1082 | 1133 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
| 1083 | 1134 | <td>', implode(', ', $memberlist), '</td> |
| 1084 | 1135 | </tr>'; |
| 1136 | + } |
|
| 1085 | 1137 | |
| 1086 | 1138 | echo ' |
| 1087 | 1139 | </tbody> |
@@ -1123,11 +1175,10 @@ discard block |
||
| 1123 | 1175 | </h3> |
| 1124 | 1176 | </div>'; |
| 1125 | 1177 | |
| 1126 | - if ($context['member']['has_all_permissions']) |
|
| 1127 | - echo ' |
|
| 1178 | + if ($context['member']['has_all_permissions']) { |
|
| 1179 | + echo ' |
|
| 1128 | 1180 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
| 1129 | - |
|
| 1130 | - else |
|
| 1181 | + } else |
|
| 1131 | 1182 | { |
| 1132 | 1183 | echo ' |
| 1133 | 1184 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1142,9 +1193,10 @@ discard block |
||
| 1142 | 1193 | <div class="windowbg smalltext"> |
| 1143 | 1194 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
| 1144 | 1195 | |
| 1145 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
| 1146 | - echo ' |
|
| 1196 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
| 1197 | + echo ' |
|
| 1147 | 1198 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
| 1199 | + } |
|
| 1148 | 1200 | echo ' |
| 1149 | 1201 | </div>'; |
| 1150 | 1202 | } |
@@ -1176,12 +1228,13 @@ discard block |
||
| 1176 | 1228 | </td> |
| 1177 | 1229 | <td class="smalltext">'; |
| 1178 | 1230 | |
| 1179 | - if ($permission['is_denied']) |
|
| 1180 | - echo ' |
|
| 1231 | + if ($permission['is_denied']) { |
|
| 1232 | + echo ' |
|
| 1181 | 1233 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1182 | - else |
|
| 1183 | - echo ' |
|
| 1234 | + } else { |
|
| 1235 | + echo ' |
|
| 1184 | 1236 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1237 | + } |
|
| 1185 | 1238 | |
| 1186 | 1239 | echo ' |
| 1187 | 1240 | </td> |
@@ -1192,10 +1245,10 @@ discard block |
||
| 1192 | 1245 | </table> |
| 1193 | 1246 | </div><!-- .tborder --> |
| 1194 | 1247 | <br>'; |
| 1195 | - } |
|
| 1196 | - else |
|
| 1197 | - echo ' |
|
| 1248 | + } else { |
|
| 1249 | + echo ' |
|
| 1198 | 1250 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
| 1251 | + } |
|
| 1199 | 1252 | |
| 1200 | 1253 | // Board permission section. |
| 1201 | 1254 | echo ' |
@@ -1206,14 +1259,16 @@ discard block |
||
| 1206 | 1259 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
| 1207 | 1260 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>'; |
| 1208 | 1261 | |
| 1209 | - if (!empty($context['boards'])) |
|
| 1210 | - echo ' |
|
| 1262 | + if (!empty($context['boards'])) { |
|
| 1263 | + echo ' |
|
| 1211 | 1264 | <option value="" disabled>---------------------------</option>'; |
| 1265 | + } |
|
| 1212 | 1266 | |
| 1213 | 1267 | // Fill the box with any local permission boards. |
| 1214 | - foreach ($context['boards'] as $board) |
|
| 1215 | - echo ' |
|
| 1268 | + foreach ($context['boards'] as $board) { |
|
| 1269 | + echo ' |
|
| 1216 | 1270 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
| 1271 | + } |
|
| 1217 | 1272 | |
| 1218 | 1273 | echo ' |
| 1219 | 1274 | </select> |
@@ -1242,13 +1297,13 @@ discard block |
||
| 1242 | 1297 | </td> |
| 1243 | 1298 | <td class="smalltext">'; |
| 1244 | 1299 | |
| 1245 | - if ($permission['is_denied']) |
|
| 1246 | - echo ' |
|
| 1300 | + if ($permission['is_denied']) { |
|
| 1301 | + echo ' |
|
| 1247 | 1302 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1248 | - |
|
| 1249 | - else |
|
| 1250 | - echo ' |
|
| 1303 | + } else { |
|
| 1304 | + echo ' |
|
| 1251 | 1305 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1306 | + } |
|
| 1252 | 1307 | |
| 1253 | 1308 | echo ' |
| 1254 | 1309 | </td> |
@@ -1257,10 +1312,10 @@ discard block |
||
| 1257 | 1312 | echo ' |
| 1258 | 1313 | </tbody> |
| 1259 | 1314 | </table>'; |
| 1260 | - } |
|
| 1261 | - else |
|
| 1262 | - echo ' |
|
| 1315 | + } else { |
|
| 1316 | + echo ' |
|
| 1263 | 1317 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
| 1318 | + } |
|
| 1264 | 1319 | echo ' |
| 1265 | 1320 | </div><!-- #permissions -->'; |
| 1266 | 1321 | } |
@@ -1301,9 +1356,10 @@ discard block |
||
| 1301 | 1356 | </div>'; |
| 1302 | 1357 | |
| 1303 | 1358 | // If they haven't post at all, don't draw the graph. |
| 1304 | - if (empty($context['posts_by_time'])) |
|
| 1305 | - echo ' |
|
| 1359 | + if (empty($context['posts_by_time'])) { |
|
| 1360 | + echo ' |
|
| 1306 | 1361 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1362 | + } |
|
| 1307 | 1363 | |
| 1308 | 1364 | // Otherwise do! |
| 1309 | 1365 | else |
@@ -1312,8 +1368,8 @@ discard block |
||
| 1312 | 1368 | <ul class="activity_stats flow_hidden">'; |
| 1313 | 1369 | |
| 1314 | 1370 | // The labels. |
| 1315 | - foreach ($context['posts_by_time'] as $time_of_day) |
|
| 1316 | - echo ' |
|
| 1371 | + foreach ($context['posts_by_time'] as $time_of_day) { |
|
| 1372 | + echo ' |
|
| 1317 | 1373 | <li', $time_of_day['is_last'] ? ' class="last"' : '', '> |
| 1318 | 1374 | <div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '"> |
| 1319 | 1375 | <div style="height: ', (int) $time_of_day['relative_percent'], 'px;"> |
@@ -1322,6 +1378,7 @@ discard block |
||
| 1322 | 1378 | </div> |
| 1323 | 1379 | <span class="stats_hour">', $time_of_day['hour_format'], '</span> |
| 1324 | 1380 | </li>'; |
| 1381 | + } |
|
| 1325 | 1382 | |
| 1326 | 1383 | echo ' |
| 1327 | 1384 | </ul>'; |
@@ -1340,11 +1397,10 @@ discard block |
||
| 1340 | 1397 | </h3> |
| 1341 | 1398 | </div>'; |
| 1342 | 1399 | |
| 1343 | - if (empty($context['popular_boards'])) |
|
| 1344 | - echo ' |
|
| 1400 | + if (empty($context['popular_boards'])) { |
|
| 1401 | + echo ' |
|
| 1345 | 1402 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1346 | - |
|
| 1347 | - else |
|
| 1403 | + } else |
|
| 1348 | 1404 | { |
| 1349 | 1405 | echo ' |
| 1350 | 1406 | <dl class="stats">'; |
@@ -1374,10 +1430,10 @@ discard block |
||
| 1374 | 1430 | </h3> |
| 1375 | 1431 | </div>'; |
| 1376 | 1432 | |
| 1377 | - if (empty($context['board_activity'])) |
|
| 1378 | - echo ' |
|
| 1433 | + if (empty($context['board_activity'])) { |
|
| 1434 | + echo ' |
|
| 1379 | 1435 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1380 | - else |
|
| 1436 | + } else |
|
| 1381 | 1437 | { |
| 1382 | 1438 | echo ' |
| 1383 | 1439 | <dl class="stats">'; |
@@ -1428,90 +1484,97 @@ discard block |
||
| 1428 | 1484 | <h3 class="catbg profile_hd">'; |
| 1429 | 1485 | |
| 1430 | 1486 | // Don't say "Profile" if this isn't the profile... |
| 1431 | - if (!empty($context['profile_header_text'])) |
|
| 1432 | - echo ' |
|
| 1487 | + if (!empty($context['profile_header_text'])) { |
|
| 1488 | + echo ' |
|
| 1433 | 1489 | ', $context['profile_header_text']; |
| 1434 | - else |
|
| 1435 | - echo ' |
|
| 1490 | + } else { |
|
| 1491 | + echo ' |
|
| 1436 | 1492 | ', $txt['profile']; |
| 1493 | + } |
|
| 1437 | 1494 | |
| 1438 | 1495 | echo ' |
| 1439 | 1496 | </h3> |
| 1440 | 1497 | </div>'; |
| 1441 | 1498 | |
| 1442 | 1499 | // Have we some description? |
| 1443 | - if ($context['page_desc']) |
|
| 1444 | - echo ' |
|
| 1500 | + if ($context['page_desc']) { |
|
| 1501 | + echo ' |
|
| 1445 | 1502 | <p class="information">', $context['page_desc'], '</p>'; |
| 1503 | + } |
|
| 1446 | 1504 | |
| 1447 | 1505 | echo ' |
| 1448 | 1506 | <div class="roundframe">'; |
| 1449 | 1507 | |
| 1450 | 1508 | // Any bits at the start? |
| 1451 | - if (!empty($context['profile_prehtml'])) |
|
| 1452 | - echo ' |
|
| 1509 | + if (!empty($context['profile_prehtml'])) { |
|
| 1510 | + echo ' |
|
| 1453 | 1511 | <div>', $context['profile_prehtml'], '</div>'; |
| 1512 | + } |
|
| 1454 | 1513 | |
| 1455 | - if (!empty($context['profile_fields'])) |
|
| 1456 | - echo ' |
|
| 1514 | + if (!empty($context['profile_fields'])) { |
|
| 1515 | + echo ' |
|
| 1457 | 1516 | <dl class="settings">'; |
| 1517 | + } |
|
| 1458 | 1518 | |
| 1459 | 1519 | // Start the big old loop 'of love. |
| 1460 | 1520 | $lastItem = 'hr'; |
| 1461 | 1521 | foreach ($context['profile_fields'] as $key => $field) |
| 1462 | 1522 | { |
| 1463 | 1523 | // We add a little hack to be sure we never get more than one hr in a row! |
| 1464 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
| 1465 | - continue; |
|
| 1524 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
| 1525 | + continue; |
|
| 1526 | + } |
|
| 1466 | 1527 | |
| 1467 | 1528 | $lastItem = $field['type']; |
| 1468 | - if ($field['type'] == 'hr') |
|
| 1469 | - echo ' |
|
| 1529 | + if ($field['type'] == 'hr') { |
|
| 1530 | + echo ' |
|
| 1470 | 1531 | </dl> |
| 1471 | 1532 | <hr> |
| 1472 | 1533 | <dl class="settings">'; |
| 1473 | - |
|
| 1474 | - elseif ($field['type'] == 'callback') |
|
| 1534 | + } elseif ($field['type'] == 'callback') |
|
| 1475 | 1535 | { |
| 1476 | 1536 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
| 1477 | 1537 | { |
| 1478 | 1538 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 1479 | 1539 | $callback_func(); |
| 1480 | 1540 | } |
| 1481 | - } |
|
| 1482 | - else |
|
| 1541 | + } else |
|
| 1483 | 1542 | { |
| 1484 | 1543 | echo ' |
| 1485 | 1544 | <dt> |
| 1486 | 1545 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
| 1487 | 1546 | |
| 1488 | 1547 | // Does it have any subtext to show? |
| 1489 | - if (!empty($field['subtext'])) |
|
| 1490 | - echo ' |
|
| 1548 | + if (!empty($field['subtext'])) { |
|
| 1549 | + echo ' |
|
| 1491 | 1550 | <br> |
| 1492 | 1551 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 1552 | + } |
|
| 1493 | 1553 | |
| 1494 | 1554 | echo ' |
| 1495 | 1555 | </dt> |
| 1496 | 1556 | <dd>'; |
| 1497 | 1557 | |
| 1498 | 1558 | // Want to put something infront of the box? |
| 1499 | - if (!empty($field['preinput'])) |
|
| 1500 | - echo ' |
|
| 1559 | + if (!empty($field['preinput'])) { |
|
| 1560 | + echo ' |
|
| 1501 | 1561 | ', $field['preinput']; |
| 1562 | + } |
|
| 1502 | 1563 | |
| 1503 | 1564 | // What type of data are we showing? |
| 1504 | - if ($field['type'] == 'label') |
|
| 1505 | - echo ' |
|
| 1565 | + if ($field['type'] == 'label') { |
|
| 1566 | + echo ' |
|
| 1506 | 1567 | ', $field['value']; |
| 1568 | + } |
|
| 1507 | 1569 | |
| 1508 | 1570 | // Maybe it's a text box - very likely! |
| 1509 | 1571 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
| 1510 | 1572 | { |
| 1511 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
| 1512 | - $type = 'number'; |
|
| 1513 | - else |
|
| 1514 | - $type = $field['type']; |
|
| 1573 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
| 1574 | + $type = 'number'; |
|
| 1575 | + } else { |
|
| 1576 | + $type = $field['type']; |
|
| 1577 | + } |
|
| 1515 | 1578 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
| 1516 | 1579 | |
| 1517 | 1580 | |
@@ -1519,10 +1582,11 @@ discard block |
||
| 1519 | 1582 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
| 1520 | 1583 | } |
| 1521 | 1584 | // You "checking" me out? ;) |
| 1522 | - elseif ($field['type'] == 'check') |
|
| 1523 | - echo ' |
|
| 1585 | + elseif ($field['type'] == 'check') { |
|
| 1586 | + echo ' |
|
| 1524 | 1587 | <input type="hidden" name="', $key, '" value="0"> |
| 1525 | 1588 | <input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
| 1589 | + } |
|
| 1526 | 1590 | |
| 1527 | 1591 | // Always fun - select boxes! |
| 1528 | 1592 | elseif ($field['type'] == 'select') |
@@ -1533,14 +1597,16 @@ discard block |
||
| 1533 | 1597 | if (isset($field['options'])) |
| 1534 | 1598 | { |
| 1535 | 1599 | // Is this some code to generate the options? |
| 1536 | - if (!is_array($field['options'])) |
|
| 1537 | - $field['options'] = $field['options'](); |
|
| 1600 | + if (!is_array($field['options'])) { |
|
| 1601 | + $field['options'] = $field['options'](); |
|
| 1602 | + } |
|
| 1538 | 1603 | |
| 1539 | 1604 | // Assuming we now have some! |
| 1540 | - if (is_array($field['options'])) |
|
| 1541 | - foreach ($field['options'] as $value => $name) |
|
| 1605 | + if (is_array($field['options'])) { |
|
| 1606 | + foreach ($field['options'] as $value => $name) |
|
| 1542 | 1607 | echo ' |
| 1543 | 1608 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 1609 | + } |
|
| 1544 | 1610 | } |
| 1545 | 1611 | |
| 1546 | 1612 | echo ' |
@@ -1548,31 +1614,34 @@ discard block |
||
| 1548 | 1614 | } |
| 1549 | 1615 | |
| 1550 | 1616 | // Something to end with? |
| 1551 | - if (!empty($field['postinput'])) |
|
| 1552 | - echo ' |
|
| 1617 | + if (!empty($field['postinput'])) { |
|
| 1618 | + echo ' |
|
| 1553 | 1619 | ', $field['postinput']; |
| 1620 | + } |
|
| 1554 | 1621 | |
| 1555 | 1622 | echo ' |
| 1556 | 1623 | </dd>'; |
| 1557 | 1624 | } |
| 1558 | 1625 | } |
| 1559 | 1626 | |
| 1560 | - if (!empty($context['profile_fields'])) |
|
| 1561 | - echo ' |
|
| 1627 | + if (!empty($context['profile_fields'])) { |
|
| 1628 | + echo ' |
|
| 1562 | 1629 | </dl>'; |
| 1630 | + } |
|
| 1563 | 1631 | |
| 1564 | 1632 | // Are there any custom profile fields - if so print them! |
| 1565 | 1633 | if (!empty($context['custom_fields'])) |
| 1566 | 1634 | { |
| 1567 | - if ($lastItem != 'hr') |
|
| 1568 | - echo ' |
|
| 1635 | + if ($lastItem != 'hr') { |
|
| 1636 | + echo ' |
|
| 1569 | 1637 | <hr>'; |
| 1638 | + } |
|
| 1570 | 1639 | |
| 1571 | 1640 | echo ' |
| 1572 | 1641 | <dl class="settings">'; |
| 1573 | 1642 | |
| 1574 | - foreach ($context['custom_fields'] as $field) |
|
| 1575 | - echo ' |
|
| 1643 | + foreach ($context['custom_fields'] as $field) { |
|
| 1644 | + echo ' |
|
| 1576 | 1645 | <dt> |
| 1577 | 1646 | <strong>', $field['name'], ': </strong><br> |
| 1578 | 1647 | <span class="smalltext">', $field['desc'], '</span> |
@@ -1580,6 +1649,7 @@ discard block |
||
| 1580 | 1649 | <dd> |
| 1581 | 1650 | ', $field['input_html'], ' |
| 1582 | 1651 | </dd>'; |
| 1652 | + } |
|
| 1583 | 1653 | |
| 1584 | 1654 | echo ' |
| 1585 | 1655 | </dl>'; |
@@ -1587,13 +1657,14 @@ discard block |
||
| 1587 | 1657 | } |
| 1588 | 1658 | |
| 1589 | 1659 | // Any closing HTML? |
| 1590 | - if (!empty($context['profile_posthtml'])) |
|
| 1591 | - echo ' |
|
| 1660 | + if (!empty($context['profile_posthtml'])) { |
|
| 1661 | + echo ' |
|
| 1592 | 1662 | <div>', $context['profile_posthtml'], '</div>'; |
| 1663 | + } |
|
| 1593 | 1664 | |
| 1594 | 1665 | // Only show the password box if it's actually needed. |
| 1595 | - if ($context['require_password']) |
|
| 1596 | - echo ' |
|
| 1666 | + if ($context['require_password']) { |
|
| 1667 | + echo ' |
|
| 1597 | 1668 | <dl class="settings"> |
| 1598 | 1669 | <dt> |
| 1599 | 1670 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1603,18 +1674,21 @@ discard block |
||
| 1603 | 1674 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
| 1604 | 1675 | </dd> |
| 1605 | 1676 | </dl>'; |
| 1677 | + } |
|
| 1606 | 1678 | |
| 1607 | 1679 | // The button shouldn't say "Change profile" unless we're changing the profile... |
| 1608 | - if (!empty($context['submit_button_text'])) |
|
| 1609 | - echo ' |
|
| 1680 | + if (!empty($context['submit_button_text'])) { |
|
| 1681 | + echo ' |
|
| 1610 | 1682 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">'; |
| 1611 | - else |
|
| 1612 | - echo ' |
|
| 1683 | + } else { |
|
| 1684 | + echo ' |
|
| 1613 | 1685 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button">'; |
| 1686 | + } |
|
| 1614 | 1687 | |
| 1615 | - if (!empty($context['token_check'])) |
|
| 1616 | - echo ' |
|
| 1688 | + if (!empty($context['token_check'])) { |
|
| 1689 | + echo ' |
|
| 1617 | 1690 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 1691 | + } |
|
| 1618 | 1692 | |
| 1619 | 1693 | echo ' |
| 1620 | 1694 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1624,10 +1698,11 @@ discard block |
||
| 1624 | 1698 | </form>'; |
| 1625 | 1699 | |
| 1626 | 1700 | // Any final spellchecking stuff? |
| 1627 | - if (!empty($context['show_spellchecking'])) |
|
| 1628 | - echo ' |
|
| 1701 | + if (!empty($context['show_spellchecking'])) { |
|
| 1702 | + echo ' |
|
| 1629 | 1703 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
| 1630 | -} |
|
| 1704 | + } |
|
| 1705 | + } |
|
| 1631 | 1706 | |
| 1632 | 1707 | /** |
| 1633 | 1708 | * Personal Message settings. |
@@ -1664,10 +1739,11 @@ discard block |
||
| 1664 | 1739 | <select name="pm_receive_from" id="pm_receive_from"> |
| 1665 | 1740 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
| 1666 | 1741 | |
| 1667 | - if (!empty($modSettings['enable_buddylist'])) |
|
| 1668 | - echo ' |
|
| 1742 | + if (!empty($modSettings['enable_buddylist'])) { |
|
| 1743 | + echo ' |
|
| 1669 | 1744 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
| 1670 | 1745 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
| 1746 | + } |
|
| 1671 | 1747 | |
| 1672 | 1748 | echo ' |
| 1673 | 1749 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1710,11 +1786,12 @@ discard block |
||
| 1710 | 1786 | if (empty($setting) || !is_array($setting)) |
| 1711 | 1787 | { |
| 1712 | 1788 | // Insert a separator (unless this is the first item in the list) |
| 1713 | - if ($i !== $first_option_key) |
|
| 1714 | - echo ' |
|
| 1789 | + if ($i !== $first_option_key) { |
|
| 1790 | + echo ' |
|
| 1715 | 1791 | </dl> |
| 1716 | 1792 | <hr> |
| 1717 | 1793 | <dl class="settings">'; |
| 1794 | + } |
|
| 1718 | 1795 | |
| 1719 | 1796 | // Should we give a name to this section? |
| 1720 | 1797 | if (is_string($setting) && !empty($setting)) |
@@ -1723,69 +1800,67 @@ discard block |
||
| 1723 | 1800 | echo ' |
| 1724 | 1801 | <dt><strong>' . $setting . '</strong></dt> |
| 1725 | 1802 | <dd></dd>'; |
| 1803 | + } else { |
|
| 1804 | + $titled_section = false; |
|
| 1726 | 1805 | } |
| 1727 | - else |
|
| 1728 | - $titled_section = false; |
|
| 1729 | 1806 | |
| 1730 | 1807 | continue; |
| 1731 | 1808 | } |
| 1732 | 1809 | |
| 1733 | 1810 | // Is this disabled? |
| 1734 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
| 1735 | - continue; |
|
| 1736 | - |
|
| 1737 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 1738 | - continue; |
|
| 1739 | - |
|
| 1740 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
| 1741 | - continue; |
|
| 1742 | - |
|
| 1743 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
| 1744 | - continue; |
|
| 1745 | - |
|
| 1746 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
| 1747 | - continue; |
|
| 1748 | - |
|
| 1749 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1750 | - continue; |
|
| 1751 | - |
|
| 1752 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1753 | - continue; |
|
| 1811 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
| 1812 | + continue; |
|
| 1813 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1814 | + continue; |
|
| 1815 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
| 1816 | + continue; |
|
| 1817 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
| 1818 | + continue; |
|
| 1819 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
| 1820 | + continue; |
|
| 1821 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1822 | + continue; |
|
| 1823 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1824 | + continue; |
|
| 1825 | + } |
|
| 1754 | 1826 | |
| 1755 | 1827 | // Some of these may not be set... Set to defaults here |
| 1756 | 1828 | $opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod'); |
| 1757 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
| 1758 | - $context['member']['options'][$setting['id']] = 0; |
|
| 1759 | - |
|
| 1760 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 1761 | - $setting['type'] = 'checkbox'; |
|
| 1762 | - |
|
| 1763 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 1764 | - $setting['type'] = 'number'; |
|
| 1829 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
| 1830 | + $context['member']['options'][$setting['id']] = 0; |
|
| 1831 | + } |
|
| 1765 | 1832 | |
| 1766 | - elseif ($setting['type'] == 'string') |
|
| 1767 | - $setting['type'] = 'text'; |
|
| 1833 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 1834 | + $setting['type'] = 'checkbox'; |
|
| 1835 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 1836 | + $setting['type'] = 'number'; |
|
| 1837 | + } elseif ($setting['type'] == 'string') { |
|
| 1838 | + $setting['type'] = 'text'; |
|
| 1839 | + } |
|
| 1768 | 1840 | |
| 1769 | - if (isset($setting['options'])) |
|
| 1770 | - $setting['type'] = 'list'; |
|
| 1841 | + if (isset($setting['options'])) { |
|
| 1842 | + $setting['type'] = 'list'; |
|
| 1843 | + } |
|
| 1771 | 1844 | |
| 1772 | 1845 | echo ' |
| 1773 | 1846 | <dt> |
| 1774 | 1847 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
| 1775 | 1848 | |
| 1776 | - if (isset($setting['description'])) |
|
| 1777 | - echo ' |
|
| 1849 | + if (isset($setting['description'])) { |
|
| 1850 | + echo ' |
|
| 1778 | 1851 | <br> |
| 1779 | 1852 | <span class="smalltext">', $setting['description'], '</span>'; |
| 1853 | + } |
|
| 1780 | 1854 | echo ' |
| 1781 | 1855 | </dt> |
| 1782 | 1856 | <dd>'; |
| 1783 | 1857 | |
| 1784 | 1858 | // Display checkbox options |
| 1785 | - if ($setting['type'] == 'checkbox') |
|
| 1786 | - echo ' |
|
| 1859 | + if ($setting['type'] == 'checkbox') { |
|
| 1860 | + echo ' |
|
| 1787 | 1861 | <input type="hidden" name="default_options[' . $setting['id'] . ']" value="0"> |
| 1788 | 1862 | <input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">'; |
| 1863 | + } |
|
| 1789 | 1864 | |
| 1790 | 1865 | // How about selection lists, we all love them |
| 1791 | 1866 | elseif ($setting['type'] == 'list') |
@@ -1793,9 +1868,10 @@ discard block |
||
| 1793 | 1868 | echo ' |
| 1794 | 1869 | <select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>'; |
| 1795 | 1870 | |
| 1796 | - foreach ($setting['options'] as $value => $label) |
|
| 1797 | - echo ' |
|
| 1871 | + foreach ($setting['options'] as $value => $label) { |
|
| 1872 | + echo ' |
|
| 1798 | 1873 | <option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>'; |
| 1874 | + } |
|
| 1799 | 1875 | |
| 1800 | 1876 | echo ' |
| 1801 | 1877 | </select>'; |
@@ -1811,14 +1887,13 @@ discard block |
||
| 1811 | 1887 | |
| 1812 | 1888 | echo ' |
| 1813 | 1889 | <input type="number"', $min . $max . $step; |
| 1814 | - } |
|
| 1815 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1816 | - echo' |
|
| 1890 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
| 1891 | + echo' |
|
| 1817 | 1892 | <input type="url"'; |
| 1818 | - |
|
| 1819 | - else |
|
| 1820 | - echo ' |
|
| 1893 | + } else { |
|
| 1894 | + echo ' |
|
| 1821 | 1895 | <input type="text"'; |
| 1896 | + } |
|
| 1822 | 1897 | |
| 1823 | 1898 | echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>'; |
| 1824 | 1899 | } |
@@ -1855,8 +1930,8 @@ discard block |
||
| 1855 | 1930 | <dl class="settings">'; |
| 1856 | 1931 | |
| 1857 | 1932 | // Allow notification on announcements to be disabled? |
| 1858 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
| 1859 | - echo ' |
|
| 1933 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
| 1934 | + echo ' |
|
| 1860 | 1935 | <dt> |
| 1861 | 1936 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
| 1862 | 1937 | </dt> |
@@ -1864,15 +1939,17 @@ discard block |
||
| 1864 | 1939 | <input type="hidden" name="notify_announcements" value="0"> |
| 1865 | 1940 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
| 1866 | 1941 | </dd>'; |
| 1942 | + } |
|
| 1867 | 1943 | |
| 1868 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
| 1869 | - echo ' |
|
| 1944 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
| 1945 | + echo ' |
|
| 1870 | 1946 | <dt> |
| 1871 | 1947 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
| 1872 | 1948 | </dt> |
| 1873 | 1949 | <dd> |
| 1874 | 1950 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
| 1875 | 1951 | </dd>'; |
| 1952 | + } |
|
| 1876 | 1953 | |
| 1877 | 1954 | echo ' |
| 1878 | 1955 | </dl> |
@@ -1904,9 +1981,10 @@ discard block |
||
| 1904 | 1981 | |
| 1905 | 1982 | $label = $txt['alert_opt_' . $opts[1]]; |
| 1906 | 1983 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
| 1907 | - if ($label_pos == 'before') |
|
| 1908 | - echo ' |
|
| 1984 | + if ($label_pos == 'before') { |
|
| 1985 | + echo ' |
|
| 1909 | 1986 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1987 | + } |
|
| 1910 | 1988 | |
| 1911 | 1989 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
| 1912 | 1990 | switch ($opts[0]) |
@@ -1920,17 +1998,19 @@ discard block |
||
| 1920 | 1998 | echo ' |
| 1921 | 1999 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
| 1922 | 2000 | |
| 1923 | - foreach ($opts['opts'] as $k => $v) |
|
| 1924 | - echo ' |
|
| 2001 | + foreach ($opts['opts'] as $k => $v) { |
|
| 2002 | + echo ' |
|
| 1925 | 2003 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
| 2004 | + } |
|
| 1926 | 2005 | echo ' |
| 1927 | 2006 | </select>'; |
| 1928 | 2007 | break; |
| 1929 | 2008 | } |
| 1930 | 2009 | |
| 1931 | - if ($label_pos == 'after') |
|
| 1932 | - echo ' |
|
| 2010 | + if ($label_pos == 'after') { |
|
| 2011 | + echo ' |
|
| 1933 | 2012 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 2013 | + } |
|
| 1934 | 2014 | |
| 1935 | 2015 | echo ' |
| 1936 | 2016 | </td> |
@@ -2047,11 +2127,12 @@ discard block |
||
| 2047 | 2127 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
| 2048 | 2128 | |
| 2049 | 2129 | // Do we have an update message? |
| 2050 | - if (!empty($context['update_message'])) |
|
| 2051 | - echo ' |
|
| 2130 | + if (!empty($context['update_message'])) { |
|
| 2131 | + echo ' |
|
| 2052 | 2132 | <div class="infobox"> |
| 2053 | 2133 | ', $context['update_message'], '. |
| 2054 | 2134 | </div>'; |
| 2135 | + } |
|
| 2055 | 2136 | |
| 2056 | 2137 | echo ' |
| 2057 | 2138 | <div id="groups">'; |
@@ -2073,8 +2154,7 @@ discard block |
||
| 2073 | 2154 | </div> |
| 2074 | 2155 | </div> |
| 2075 | 2156 | </div><!-- .groupmembership -->'; |
| 2076 | - } |
|
| 2077 | - else |
|
| 2157 | + } else |
|
| 2078 | 2158 | { |
| 2079 | 2159 | echo ' |
| 2080 | 2160 | <div class="title_bar"> |
@@ -2086,27 +2166,30 @@ discard block |
||
| 2086 | 2166 | echo ' |
| 2087 | 2167 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
| 2088 | 2168 | |
| 2089 | - if ($context['can_edit_primary']) |
|
| 2090 | - echo ' |
|
| 2169 | + if ($context['can_edit_primary']) { |
|
| 2170 | + echo ' |
|
| 2091 | 2171 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
| 2172 | + } |
|
| 2092 | 2173 | |
| 2093 | 2174 | echo ' |
| 2094 | 2175 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
| 2095 | 2176 | |
| 2096 | 2177 | // Can they leave their group? |
| 2097 | - if ($group['can_leave']) |
|
| 2098 | - echo ' |
|
| 2178 | + if ($group['can_leave']) { |
|
| 2179 | + echo ' |
|
| 2099 | 2180 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
| 2181 | + } |
|
| 2100 | 2182 | |
| 2101 | 2183 | echo ' |
| 2102 | 2184 | </div><!-- .windowbg -->'; |
| 2103 | 2185 | } |
| 2104 | 2186 | |
| 2105 | - if ($context['can_edit_primary']) |
|
| 2106 | - echo ' |
|
| 2187 | + if ($context['can_edit_primary']) { |
|
| 2188 | + echo ' |
|
| 2107 | 2189 | <div class="padding righttext"> |
| 2108 | 2190 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
| 2109 | 2191 | </div>'; |
| 2192 | + } |
|
| 2110 | 2193 | |
| 2111 | 2194 | // Any groups they can join? |
| 2112 | 2195 | if (!empty($context['groups']['available'])) |
@@ -2122,17 +2205,16 @@ discard block |
||
| 2122 | 2205 | <div class="windowbg"> |
| 2123 | 2206 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
| 2124 | 2207 | |
| 2125 | - if ($group['type'] == 3) |
|
| 2126 | - echo ' |
|
| 2208 | + if ($group['type'] == 3) { |
|
| 2209 | + echo ' |
|
| 2127 | 2210 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
| 2128 | - |
|
| 2129 | - elseif ($group['type'] == 2 && $group['pending']) |
|
| 2130 | - echo ' |
|
| 2211 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
| 2212 | + echo ' |
|
| 2131 | 2213 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
| 2132 | - |
|
| 2133 | - elseif ($group['type'] == 2) |
|
| 2134 | - echo ' |
|
| 2214 | + } elseif ($group['type'] == 2) { |
|
| 2215 | + echo ' |
|
| 2135 | 2216 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
| 2217 | + } |
|
| 2136 | 2218 | |
| 2137 | 2219 | echo ' |
| 2138 | 2220 | </div><!-- .windowbg -->'; |
@@ -2155,9 +2237,10 @@ discard block |
||
| 2155 | 2237 | |
| 2156 | 2238 | prevDiv.className = "windowbg"; |
| 2157 | 2239 | }'; |
| 2158 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
| 2159 | - echo ' |
|
| 2240 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
| 2241 | + echo ' |
|
| 2160 | 2242 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
| 2243 | + } |
|
| 2161 | 2244 | |
| 2162 | 2245 | echo ' |
| 2163 | 2246 | </script>'; |
@@ -2166,9 +2249,10 @@ discard block |
||
| 2166 | 2249 | echo ' |
| 2167 | 2250 | </div><!-- #groups -->'; |
| 2168 | 2251 | |
| 2169 | - if (!empty($context['token_check'])) |
|
| 2170 | - echo ' |
|
| 2252 | + if (!empty($context['token_check'])) { |
|
| 2253 | + echo ' |
|
| 2171 | 2254 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2255 | + } |
|
| 2172 | 2256 | |
| 2173 | 2257 | echo ' |
| 2174 | 2258 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2216,14 +2300,15 @@ discard block |
||
| 2216 | 2300 | |
| 2217 | 2301 | foreach ($category['boards'] as $board) |
| 2218 | 2302 | { |
| 2219 | - if ($i == $limit) |
|
| 2220 | - echo ' |
|
| 2303 | + if ($i == $limit) { |
|
| 2304 | + echo ' |
|
| 2221 | 2305 | </ul> |
| 2222 | 2306 | </li> |
| 2223 | 2307 | </ul> |
| 2224 | 2308 | <ul class="ignoreboards floatright"> |
| 2225 | 2309 | <li class="category"> |
| 2226 | 2310 | <ul>'; |
| 2311 | + } |
|
| 2227 | 2312 | |
| 2228 | 2313 | echo ' |
| 2229 | 2314 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2269,10 +2354,11 @@ discard block |
||
| 2269 | 2354 | |
| 2270 | 2355 | // Work out the starting color. |
| 2271 | 2356 | $context['current_color'] = $context['colors'][0]; |
| 2272 | - foreach ($context['colors'] as $limit => $color) |
|
| 2273 | - if ($context['member']['warning'] >= $limit) |
|
| 2357 | + foreach ($context['colors'] as $limit => $color) { |
|
| 2358 | + if ($context['member']['warning'] >= $limit) |
|
| 2274 | 2359 | $context['current_color'] = $color; |
| 2275 | -} |
|
| 2360 | + } |
|
| 2361 | + } |
|
| 2276 | 2362 | |
| 2277 | 2363 | // Show all warnings of a user? |
| 2278 | 2364 | function template_viewWarning() |
@@ -2311,14 +2397,15 @@ discard block |
||
| 2311 | 2397 | </dd>'; |
| 2312 | 2398 | |
| 2313 | 2399 | // There's some impact of this? |
| 2314 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
| 2315 | - echo ' |
|
| 2400 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
| 2401 | + echo ' |
|
| 2316 | 2402 | <dt> |
| 2317 | 2403 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
| 2318 | 2404 | </dt> |
| 2319 | 2405 | <dd> |
| 2320 | 2406 | ', $context['level_effects'][$context['current_level']], ' |
| 2321 | 2407 | </dd>'; |
| 2408 | + } |
|
| 2322 | 2409 | |
| 2323 | 2410 | echo ' |
| 2324 | 2411 | </dl> |
@@ -2356,10 +2443,11 @@ discard block |
||
| 2356 | 2443 | |
| 2357 | 2444 | // Otherwise see what we can do...'; |
| 2358 | 2445 | |
| 2359 | - foreach ($context['notification_templates'] as $k => $type) |
|
| 2360 | - echo ' |
|
| 2446 | + foreach ($context['notification_templates'] as $k => $type) { |
|
| 2447 | + echo ' |
|
| 2361 | 2448 | if (index == ', $k, ') |
| 2362 | 2449 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
| 2450 | + } |
|
| 2363 | 2451 | |
| 2364 | 2452 | echo ' |
| 2365 | 2453 | } |
@@ -2369,10 +2457,11 @@ discard block |
||
| 2369 | 2457 | // Also set the right effect. |
| 2370 | 2458 | effectText = "";'; |
| 2371 | 2459 | |
| 2372 | - foreach ($context['level_effects'] as $limit => $text) |
|
| 2373 | - echo ' |
|
| 2460 | + foreach ($context['level_effects'] as $limit => $text) { |
|
| 2461 | + echo ' |
|
| 2374 | 2462 | if (slideAmount >= ', $limit, ') |
| 2375 | 2463 | effectText = "', $text, '";'; |
| 2464 | + } |
|
| 2376 | 2465 | |
| 2377 | 2466 | echo ' |
| 2378 | 2467 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2387,32 +2476,35 @@ discard block |
||
| 2387 | 2476 | </h3> |
| 2388 | 2477 | </div>'; |
| 2389 | 2478 | |
| 2390 | - if (!$context['user']['is_owner']) |
|
| 2391 | - echo ' |
|
| 2479 | + if (!$context['user']['is_owner']) { |
|
| 2480 | + echo ' |
|
| 2392 | 2481 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
| 2482 | + } |
|
| 2393 | 2483 | |
| 2394 | 2484 | echo ' |
| 2395 | 2485 | <div class="windowbg"> |
| 2396 | 2486 | <dl class="settings">'; |
| 2397 | 2487 | |
| 2398 | - if (!$context['user']['is_owner']) |
|
| 2399 | - echo ' |
|
| 2488 | + if (!$context['user']['is_owner']) { |
|
| 2489 | + echo ' |
|
| 2400 | 2490 | <dt> |
| 2401 | 2491 | <strong>', $txt['profile_warning_name'], ':</strong> |
| 2402 | 2492 | </dt> |
| 2403 | 2493 | <dd> |
| 2404 | 2494 | <strong>', $context['member']['name'], '</strong> |
| 2405 | 2495 | </dd>'; |
| 2496 | + } |
|
| 2406 | 2497 | |
| 2407 | 2498 | echo ' |
| 2408 | 2499 | <dt> |
| 2409 | 2500 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
| 2410 | 2501 | |
| 2411 | 2502 | // Is there only so much they can apply? |
| 2412 | - if ($context['warning_limit']) |
|
| 2413 | - echo ' |
|
| 2503 | + if ($context['warning_limit']) { |
|
| 2504 | + echo ' |
|
| 2414 | 2505 | <br> |
| 2415 | 2506 | <span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
| 2507 | + } |
|
| 2416 | 2508 | |
| 2417 | 2509 | echo ' |
| 2418 | 2510 | </dt> |
@@ -2467,9 +2559,10 @@ discard block |
||
| 2467 | 2559 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
| 2468 | 2560 | <option value="-1" disabled>------------------------------</option>'; |
| 2469 | 2561 | |
| 2470 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
| 2471 | - echo ' |
|
| 2562 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
| 2563 | + echo ' |
|
| 2472 | 2564 | <option value="', $id_template, '">', $template['title'], '</option>'; |
| 2565 | + } |
|
| 2473 | 2566 | |
| 2474 | 2567 | echo ' |
| 2475 | 2568 | </select> |
@@ -2482,9 +2575,10 @@ discard block |
||
| 2482 | 2575 | </dl> |
| 2483 | 2576 | <div class="righttext">'; |
| 2484 | 2577 | |
| 2485 | - if (!empty($context['token_check'])) |
|
| 2486 | - echo ' |
|
| 2578 | + if (!empty($context['token_check'])) { |
|
| 2579 | + echo ' |
|
| 2487 | 2580 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2581 | + } |
|
| 2488 | 2582 | |
| 2489 | 2583 | echo ' |
| 2490 | 2584 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2500,8 +2594,8 @@ discard block |
||
| 2500 | 2594 | echo ' |
| 2501 | 2595 | <script>'; |
| 2502 | 2596 | |
| 2503 | - if (!$context['user']['is_owner']) |
|
| 2504 | - echo ' |
|
| 2597 | + if (!$context['user']['is_owner']) { |
|
| 2598 | + echo ' |
|
| 2505 | 2599 | modifyWarnNotify(); |
| 2506 | 2600 | $(document).ready(function() { |
| 2507 | 2601 | $("#preview_button").click(function() { |
@@ -2540,6 +2634,7 @@ discard block |
||
| 2540 | 2634 | }); |
| 2541 | 2635 | return false; |
| 2542 | 2636 | }'; |
| 2637 | + } |
|
| 2543 | 2638 | |
| 2544 | 2639 | echo ' |
| 2545 | 2640 | </script>'; |
@@ -2562,17 +2657,19 @@ discard block |
||
| 2562 | 2657 | </div>'; |
| 2563 | 2658 | |
| 2564 | 2659 | // If deleting another account give them a lovely info box. |
| 2565 | - if (!$context['user']['is_owner']) |
|
| 2566 | - echo ' |
|
| 2660 | + if (!$context['user']['is_owner']) { |
|
| 2661 | + echo ' |
|
| 2567 | 2662 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
| 2663 | + } |
|
| 2568 | 2664 | |
| 2569 | 2665 | echo ' |
| 2570 | 2666 | <div class="windowbg2">'; |
| 2571 | 2667 | |
| 2572 | 2668 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
| 2573 | - if ($context['needs_approval']) |
|
| 2574 | - echo ' |
|
| 2669 | + if ($context['needs_approval']) { |
|
| 2670 | + echo ' |
|
| 2575 | 2671 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
| 2672 | + } |
|
| 2576 | 2673 | |
| 2577 | 2674 | // If the user is deleting their own account warn them first - and require a password! |
| 2578 | 2675 | if ($context['user']['is_owner']) |
@@ -2584,9 +2681,10 @@ discard block |
||
| 2584 | 2681 | <input type="password" name="oldpasswrd" size="20"> |
| 2585 | 2682 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
| 2586 | 2683 | |
| 2587 | - if (!empty($context['token_check'])) |
|
| 2588 | - echo ' |
|
| 2684 | + if (!empty($context['token_check'])) { |
|
| 2685 | + echo ' |
|
| 2589 | 2686 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2687 | + } |
|
| 2590 | 2688 | |
| 2591 | 2689 | echo ' |
| 2592 | 2690 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2616,10 +2714,11 @@ discard block |
||
| 2616 | 2714 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
| 2617 | 2715 | </select>'; |
| 2618 | 2716 | |
| 2619 | - if ($context['show_perma_delete']) |
|
| 2620 | - echo ' |
|
| 2717 | + if ($context['show_perma_delete']) { |
|
| 2718 | + echo ' |
|
| 2621 | 2719 | <br> |
| 2622 | 2720 | <label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
| 2721 | + } |
|
| 2623 | 2722 | |
| 2624 | 2723 | echo ' |
| 2625 | 2724 | </div>'; |
@@ -2632,9 +2731,10 @@ discard block |
||
| 2632 | 2731 | <div> |
| 2633 | 2732 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
| 2634 | 2733 | |
| 2635 | - if (!empty($context['token_check'])) |
|
| 2636 | - echo ' |
|
| 2734 | + if (!empty($context['token_check'])) { |
|
| 2735 | + echo ' |
|
| 2637 | 2736 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2737 | + } |
|
| 2638 | 2738 | |
| 2639 | 2739 | echo ' |
| 2640 | 2740 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2660,8 +2760,8 @@ discard block |
||
| 2660 | 2760 | <hr>'; |
| 2661 | 2761 | |
| 2662 | 2762 | // Only show the password box if it's actually needed. |
| 2663 | - if ($context['require_password']) |
|
| 2664 | - echo ' |
|
| 2763 | + if ($context['require_password']) { |
|
| 2764 | + echo ' |
|
| 2665 | 2765 | <dl class="settings"> |
| 2666 | 2766 | <dt> |
| 2667 | 2767 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2671,13 +2771,15 @@ discard block |
||
| 2671 | 2771 | <input type="password" name="oldpasswrd" size="20"> |
| 2672 | 2772 | </dd> |
| 2673 | 2773 | </dl>'; |
| 2774 | + } |
|
| 2674 | 2775 | |
| 2675 | 2776 | echo ' |
| 2676 | 2777 | <div class="righttext">'; |
| 2677 | 2778 | |
| 2678 | - if (!empty($context['token_check'])) |
|
| 2679 | - echo ' |
|
| 2779 | + if (!empty($context['token_check'])) { |
|
| 2780 | + echo ' |
|
| 2680 | 2781 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2782 | + } |
|
| 2681 | 2783 | |
| 2682 | 2784 | echo ' |
| 2683 | 2785 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2704,9 +2806,10 @@ discard block |
||
| 2704 | 2806 | <ul id="list_errors">'; |
| 2705 | 2807 | |
| 2706 | 2808 | // Cycle through each error and display an error message. |
| 2707 | - foreach ($context['post_errors'] as $error) |
|
| 2708 | - echo ' |
|
| 2809 | + foreach ($context['post_errors'] as $error) { |
|
| 2810 | + echo ' |
|
| 2709 | 2811 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
| 2812 | + } |
|
| 2710 | 2813 | |
| 2711 | 2814 | echo ' |
| 2712 | 2815 | </ul>'; |
@@ -2732,12 +2835,13 @@ discard block |
||
| 2732 | 2835 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
| 2733 | 2836 | |
| 2734 | 2837 | // Fill the select box with all primary member groups that can be assigned to a member. |
| 2735 | - foreach ($context['member_groups'] as $member_group) |
|
| 2736 | - if (!empty($member_group['can_be_primary'])) |
|
| 2838 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2839 | + if (!empty($member_group['can_be_primary'])) |
|
| 2737 | 2840 | echo ' |
| 2738 | 2841 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
| 2739 | 2842 | ', $member_group['name'], ' |
| 2740 | 2843 | </option>'; |
| 2844 | + } |
|
| 2741 | 2845 | |
| 2742 | 2846 | echo ' |
| 2743 | 2847 | </select> |
@@ -2750,10 +2854,11 @@ discard block |
||
| 2750 | 2854 | <input type="hidden" name="additional_groups[]" value="0">'; |
| 2751 | 2855 | |
| 2752 | 2856 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
| 2753 | - foreach ($context['member_groups'] as $member_group) |
|
| 2754 | - if ($member_group['can_be_additional']) |
|
| 2857 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2858 | + if ($member_group['can_be_additional']) |
|
| 2755 | 2859 | echo ' |
| 2756 | 2860 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
| 2861 | + } |
|
| 2757 | 2862 | |
| 2758 | 2863 | echo ' |
| 2759 | 2864 | </span> |
@@ -2813,9 +2918,10 @@ discard block |
||
| 2813 | 2918 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
| 2814 | 2919 | <br>'; |
| 2815 | 2920 | |
| 2816 | - if ($context['show_spellchecking']) |
|
| 2817 | - echo ' |
|
| 2921 | + if ($context['show_spellchecking']) { |
|
| 2922 | + echo ' |
|
| 2818 | 2923 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
| 2924 | + } |
|
| 2819 | 2925 | |
| 2820 | 2926 | echo ' |
| 2821 | 2927 | </dt> |
@@ -2823,17 +2929,20 @@ discard block |
||
| 2823 | 2929 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
| 2824 | 2930 | |
| 2825 | 2931 | // If there is a limit at all! |
| 2826 | - if (!empty($context['signature_limits']['max_length'])) |
|
| 2827 | - echo ' |
|
| 2932 | + if (!empty($context['signature_limits']['max_length'])) { |
|
| 2933 | + echo ' |
|
| 2828 | 2934 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
| 2935 | + } |
|
| 2829 | 2936 | |
| 2830 | - if (!empty($context['show_preview_button'])) |
|
| 2831 | - echo ' |
|
| 2937 | + if (!empty($context['show_preview_button'])) { |
|
| 2938 | + echo ' |
|
| 2832 | 2939 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">'; |
| 2940 | + } |
|
| 2833 | 2941 | |
| 2834 | - if ($context['signature_warning']) |
|
| 2835 | - echo ' |
|
| 2942 | + if ($context['signature_warning']) { |
|
| 2943 | + echo ' |
|
| 2836 | 2944 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
| 2945 | + } |
|
| 2837 | 2946 | |
| 2838 | 2947 | // Some javascript used to count how many characters have been used so far in the signature. |
| 2839 | 2948 | echo ' |
@@ -2878,9 +2987,10 @@ discard block |
||
| 2878 | 2987 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
| 2879 | 2988 | |
| 2880 | 2989 | // This lists all the file categories. |
| 2881 | - foreach ($context['avatars'] as $avatar) |
|
| 2882 | - echo ' |
|
| 2990 | + foreach ($context['avatars'] as $avatar) { |
|
| 2991 | + echo ' |
|
| 2883 | 2992 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
| 2993 | + } |
|
| 2884 | 2994 | |
| 2885 | 2995 | echo ' |
| 2886 | 2996 | </select> |
@@ -2912,20 +3022,22 @@ discard block |
||
| 2912 | 3022 | } |
| 2913 | 3023 | |
| 2914 | 3024 | // If the user can link to an off server avatar, show them a box to input the address. |
| 2915 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
| 2916 | - echo ' |
|
| 3025 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
| 3026 | + echo ' |
|
| 2917 | 3027 | <div id="avatar_external"> |
| 2918 | 3028 | <div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', ' |
| 2919 | 3029 | <input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);"> |
| 2920 | 3030 | </div>'; |
| 3031 | + } |
|
| 2921 | 3032 | |
| 2922 | 3033 | // If the user is able to upload avatars to the server show them an upload box. |
| 2923 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
| 2924 | - echo ' |
|
| 3034 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
| 3035 | + echo ' |
|
| 2925 | 3036 | <div id="avatar_upload"> |
| 2926 | 3037 | <input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), ' |
| 2927 | 3038 | ', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), ' |
| 2928 | 3039 | </div>'; |
| 3040 | + } |
|
| 2929 | 3041 | |
| 2930 | 3042 | // if the user is able to use Gravatar avatars show then the image preview |
| 2931 | 3043 | if (!empty($context['member']['avatar']['allow_gravatar'])) |
@@ -2934,16 +3046,17 @@ discard block |
||
| 2934 | 3046 | <div id="avatar_gravatar"> |
| 2935 | 3047 | <img src="' . $context['member']['avatar']['href'] . '" alt="">'; |
| 2936 | 3048 | |
| 2937 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 2938 | - echo ' |
|
| 3049 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3050 | + echo ' |
|
| 2939 | 3051 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
| 2940 | - else |
|
| 3052 | + } else |
|
| 2941 | 3053 | { |
| 2942 | 3054 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
| 2943 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
| 2944 | - $textbox_value = ''; |
|
| 2945 | - else |
|
| 2946 | - $textbox_value = $context['member']['avatar']['external']; |
|
| 3055 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
| 3056 | + $textbox_value = ''; |
|
| 3057 | + } else { |
|
| 3058 | + $textbox_value = $context['member']['avatar']['external']; |
|
| 3059 | + } |
|
| 2947 | 3060 | |
| 2948 | 3061 | echo ' |
| 2949 | 3062 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -3015,8 +3128,9 @@ discard block |
||
| 3015 | 3128 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
| 3016 | 3129 | |
| 3017 | 3130 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
| 3018 | - if (empty($suffix)) |
|
| 3019 | - return; |
|
| 3131 | + if (empty($suffix)) { |
|
| 3132 | + return; |
|
| 3133 | + } |
|
| 3020 | 3134 | |
| 3021 | 3135 | echo ' |
| 3022 | 3136 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -3041,9 +3155,10 @@ discard block |
||
| 3041 | 3155 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
| 3042 | 3156 | |
| 3043 | 3157 | // Help the user by showing a list of common time formats. |
| 3044 | - foreach ($context['easy_timeformats'] as $time_format) |
|
| 3045 | - echo ' |
|
| 3158 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
| 3159 | + echo ' |
|
| 3046 | 3160 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
| 3161 | + } |
|
| 3047 | 3162 | |
| 3048 | 3163 | echo ' |
| 3049 | 3164 | </select><br> |
@@ -3081,9 +3196,10 @@ discard block |
||
| 3081 | 3196 | <dd> |
| 3082 | 3197 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">'; |
| 3083 | 3198 | |
| 3084 | - foreach ($context['smiley_sets'] as $set) |
|
| 3085 | - echo ' |
|
| 3199 | + foreach ($context['smiley_sets'] as $set) { |
|
| 3200 | + echo ' |
|
| 3086 | 3201 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
| 3202 | + } |
|
| 3087 | 3203 | |
| 3088 | 3204 | echo ' |
| 3089 | 3205 | </select> |
@@ -3135,10 +3251,11 @@ discard block |
||
| 3135 | 3251 | <img src="', $context['tfa_qr_url'], '" alt=""> |
| 3136 | 3252 | </div>'; |
| 3137 | 3253 | |
| 3138 | - if (!empty($context['from_ajax'])) |
|
| 3139 | - echo ' |
|
| 3254 | + if (!empty($context['from_ajax'])) { |
|
| 3255 | + echo ' |
|
| 3140 | 3256 | <br> |
| 3141 | 3257 | <a href="javascript:self.close();"></a>'; |
| 3258 | + } |
|
| 3142 | 3259 | |
| 3143 | 3260 | echo ' |
| 3144 | 3261 | </div> |
@@ -3178,17 +3295,16 @@ discard block |
||
| 3178 | 3295 | </dt> |
| 3179 | 3296 | <dd>'; |
| 3180 | 3297 | |
| 3181 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
| 3182 | - echo ' |
|
| 3298 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
| 3299 | + echo ' |
|
| 3183 | 3300 | <a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
| 3184 | - |
|
| 3185 | - elseif (!$context['tfa_enabled']) |
|
| 3186 | - echo ' |
|
| 3301 | + } elseif (!$context['tfa_enabled']) { |
|
| 3302 | + echo ' |
|
| 3187 | 3303 | ', $txt['tfa_profile_disabled']; |
| 3188 | - |
|
| 3189 | - else |
|
| 3190 | - echo ' |
|
| 3304 | + } else { |
|
| 3305 | + echo ' |
|
| 3191 | 3306 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
| 3307 | + } |
|
| 3192 | 3308 | |
| 3193 | 3309 | echo ' |
| 3194 | 3310 | </dd>'; |
@@ -86,11 +86,12 @@ discard block |
||
| 86 | 86 | <span class="smalltext"><em>', $txt['find_wildcards'], '</em></span><br>'; |
| 87 | 87 | |
| 88 | 88 | // Only offer to search for buddies if we have some! |
| 89 | - if (!empty($context['show_buddies'])) |
|
| 90 | - echo ' |
|
| 89 | + if (!empty($context['show_buddies'])) { |
|
| 90 | + echo ' |
|
| 91 | 91 | <span class="smalltext"> |
| 92 | 92 | <label for="buddies"><input type="checkbox" name="buddies" id="buddies"', !empty($context['buddy_search']) ? ' checked' : '', '> ', $txt['find_buddies'], '</label> |
| 93 | 93 | </span><br>'; |
| 94 | + } |
|
| 94 | 95 | |
| 95 | 96 | echo ' |
| 96 | 97 | <div class="padding righttext"> |
@@ -105,20 +106,21 @@ discard block |
||
| 105 | 106 | <h3 class="catbg">', $txt['find_results'], '</h3> |
| 106 | 107 | </div>'; |
| 107 | 108 | |
| 108 | - if (empty($context['results'])) |
|
| 109 | - echo ' |
|
| 109 | + if (empty($context['results'])) { |
|
| 110 | + echo ' |
|
| 110 | 111 | <p class="error">', $txt['find_no_results'], '</p>'; |
| 111 | - else |
|
| 112 | + } else |
|
| 112 | 113 | { |
| 113 | 114 | echo ' |
| 114 | 115 | <ul class="padding">'; |
| 115 | 116 | |
| 116 | - foreach ($context['results'] as $result) |
|
| 117 | - echo ' |
|
| 117 | + foreach ($context['results'] as $result) { |
|
| 118 | + echo ' |
|
| 118 | 119 | <li class="windowbg"> |
| 119 | 120 | <a href="', $result['href'], '" target="_blank" rel="noopener"> <span class="generic_icons profile_sm"></span> |
| 120 | 121 | <a href="javascript:void(0);" onclick="addMember(this.innerHTML); return false;">', $result['name'], '</a> |
| 121 | 122 | </li>'; |
| 123 | + } |
|
| 122 | 124 | |
| 123 | 125 | echo ' |
| 124 | 126 | </ul> |
@@ -134,11 +136,12 @@ discard block |
||
| 134 | 136 | <input type="hidden" name="quote" value="', $context['quote_results'] ? '1' : '0', '"> |
| 135 | 137 | </form>'; |
| 136 | 138 | |
| 137 | - if (empty($context['results'])) |
|
| 138 | - echo ' |
|
| 139 | + if (empty($context['results'])) { |
|
| 140 | + echo ' |
|
| 139 | 141 | <script> |
| 140 | 142 | document.getElementById("search").focus(); |
| 141 | 143 | </script>'; |
| 144 | + } |
|
| 142 | 145 | |
| 143 | 146 | echo ' |
| 144 | 147 | </body> |
@@ -162,9 +165,10 @@ discard block |
||
| 162 | 165 | <p>', $txt['manual_introduction'], '</p> |
| 163 | 166 | <ul>'; |
| 164 | 167 | |
| 165 | - foreach ($context['manual_sections'] as $section_id => $wiki_id) |
|
| 166 | - echo ' |
|
| 168 | + foreach ($context['manual_sections'] as $section_id => $wiki_id) { |
|
| 169 | + echo ' |
|
| 167 | 170 | <li><a href="', $context['wiki_url'], '/', $context['wiki_prefix'], $wiki_id, ($txt['lang_dictionary'] != 'en' ? '/' . $txt['lang_dictionary'] : ''), '" target="_blank" rel="noopener">', $txt['manual_section_' . $section_id . '_title'], '</a> - ', $txt['manual_section_' . $section_id . '_desc'], '</li>'; |
| 171 | + } |
|
| 168 | 172 | |
| 169 | 173 | echo ' |
| 170 | 174 | </ul> |
@@ -180,8 +184,8 @@ discard block |
||
| 180 | 184 | { |
| 181 | 185 | global $txt, $context, $modSettings; |
| 182 | 186 | |
| 183 | - if (!empty($modSettings['requireAgreement'])) |
|
| 184 | - echo ' |
|
| 187 | + if (!empty($modSettings['requireAgreement'])) { |
|
| 188 | + echo ' |
|
| 185 | 189 | <div class="cat_bar"> |
| 186 | 190 | <h3 class="catbg"> |
| 187 | 191 | ', $txt['terms_and_rules'], ' - ', $context['forum_name_html_safe'], ' |
@@ -190,11 +194,12 @@ discard block |
||
| 190 | 194 | <div class="roundframe"> |
| 191 | 195 | ', $context['agreement'], ' |
| 192 | 196 | </div>'; |
| 193 | - else |
|
| 194 | - echo ' |
|
| 197 | + } else { |
|
| 198 | + echo ' |
|
| 195 | 199 | <div class="noticebox"> |
| 196 | 200 | ', $txt['agreement_disabled'], ' |
| 197 | 201 | </div>'; |
| 198 | -} |
|
| 202 | + } |
|
| 203 | + } |
|
| 199 | 204 | |
| 200 | 205 | ?> |
| 201 | 206 | \ No newline at end of file |
@@ -18,18 +18,20 @@ discard block |
||
| 18 | 18 | global $context, $settings, $options, $txt, $scripturl, $modSettings; |
| 19 | 19 | |
| 20 | 20 | // Let them know, if their report was a success! |
| 21 | - if ($context['report_sent']) |
|
| 22 | - echo ' |
|
| 21 | + if ($context['report_sent']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="infobox"> |
| 24 | 24 | ', $txt['report_sent'], ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // Let them know why their message became unapproved. |
| 28 | - if ($context['becomesUnapproved']) |
|
| 29 | - echo ' |
|
| 29 | + if ($context['becomesUnapproved']) { |
|
| 30 | + echo ' |
|
| 30 | 31 | <div class="noticebox"> |
| 31 | 32 | ', $txt['post_becomesUnapproved'], ' |
| 32 | 33 | </div>'; |
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | // Show new topic info here? |
| 35 | 37 | echo ' |
@@ -49,11 +51,13 @@ discard block |
||
| 49 | 51 | <p>'; |
| 50 | 52 | |
| 51 | 53 | // Show just numbers...? |
| 52 | - if ($settings['display_who_viewing'] == 1) |
|
| 53 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 54 | + if ($settings['display_who_viewing'] == 1) { |
|
| 55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 56 | + } |
|
| 54 | 57 | // Or show the actual people viewing the topic? |
| 55 | - else |
|
| 56 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 58 | + else { |
|
| 59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // Now show how many guests are here too. |
| 59 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -91,10 +95,11 @@ discard block |
||
| 91 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
| 92 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
| 93 | 97 | |
| 94 | - if ($context['allow_results_view']) |
|
| 95 | - echo ' |
|
| 98 | + if ($context['allow_results_view']) { |
|
| 99 | + echo ' |
|
| 96 | 100 | ', $option['bar_ndt'], ' |
| 97 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
| 102 | + } |
|
| 98 | 103 | |
| 99 | 104 | echo ' |
| 100 | 105 | </dd>'; |
@@ -103,9 +108,10 @@ discard block |
||
| 103 | 108 | echo ' |
| 104 | 109 | </dl>'; |
| 105 | 110 | |
| 106 | - if ($context['allow_results_view']) |
|
| 107 | - echo ' |
|
| 111 | + if ($context['allow_results_view']) { |
|
| 112 | + echo ' |
|
| 108 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
| 114 | + } |
|
| 109 | 115 | } |
| 110 | 116 | // They are allowed to vote! Go to it! |
| 111 | 117 | else |
@@ -114,17 +120,19 @@ discard block |
||
| 114 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 115 | 121 | |
| 116 | 122 | // Show a warning if they are allowed more than one option. |
| 117 | - if ($context['poll']['allowed_warning']) |
|
| 118 | - echo ' |
|
| 123 | + if ($context['poll']['allowed_warning']) { |
|
| 124 | + echo ' |
|
| 119 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
| 126 | + } |
|
| 120 | 127 | |
| 121 | 128 | echo ' |
| 122 | 129 | <ul class="options">'; |
| 123 | 130 | |
| 124 | 131 | // Show each option with its button - a radio likely. |
| 125 | - foreach ($context['poll']['options'] as $option) |
|
| 126 | - echo ' |
|
| 132 | + foreach ($context['poll']['options'] as $option) { |
|
| 133 | + echo ' |
|
| 127 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
| 135 | + } |
|
| 128 | 136 | |
| 129 | 137 | echo ' |
| 130 | 138 | </ul> |
@@ -136,9 +144,10 @@ discard block |
||
| 136 | 144 | } |
| 137 | 145 | |
| 138 | 146 | // Is the clock ticking? |
| 139 | - if (!empty($context['poll']['expire_time'])) |
|
| 140 | - echo ' |
|
| 147 | + if (!empty($context['poll']['expire_time'])) { |
|
| 148 | + echo ' |
|
| 141 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
| 150 | + } |
|
| 142 | 151 | |
| 143 | 152 | echo ' |
| 144 | 153 | </div><!-- #poll_options --> |
@@ -168,11 +177,13 @@ discard block |
||
| 168 | 177 | <li> |
| 169 | 178 | <strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>'; |
| 170 | 179 | |
| 171 | - if ($event['can_edit']) |
|
| 172 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 180 | + if ($event['can_edit']) { |
|
| 181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 182 | + } |
|
| 173 | 183 | |
| 174 | - if ($event['can_export']) |
|
| 175 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 184 | + if ($event['can_export']) { |
|
| 185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 186 | + } |
|
| 176 | 187 | |
| 177 | 188 | echo ' |
| 178 | 189 | <br>'; |
@@ -180,14 +191,14 @@ discard block |
||
| 180 | 191 | if (!empty($event['allday'])) |
| 181 | 192 | { |
| 182 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 183 | - } |
|
| 184 | - else |
|
| 194 | + } else |
|
| 185 | 195 | { |
| 186 | 196 | // Display event info relative to user's local timezone |
| 187 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 188 | 198 | |
| 189 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 190 | - echo trim($event['end_date_local']) . ', '; |
|
| 199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 200 | + echo trim($event['end_date_local']) . ', '; |
|
| 201 | + } |
|
| 191 | 202 | |
| 192 | 203 | echo trim($event['end_time_local']); |
| 193 | 204 | |
@@ -196,24 +207,28 @@ discard block |
||
| 196 | 207 | { |
| 197 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 198 | 209 | |
| 199 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 200 | - echo trim($event['start_date_orig']), ', '; |
|
| 210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 211 | + echo trim($event['start_date_orig']), ', '; |
|
| 212 | + } |
|
| 201 | 213 | |
| 202 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 203 | 215 | |
| 204 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 205 | - echo trim($event['end_date_orig']) . ', '; |
|
| 216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 217 | + echo trim($event['end_date_orig']) . ', '; |
|
| 218 | + } |
|
| 206 | 219 | |
| 207 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 208 | 221 | } |
| 209 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 210 | - else |
|
| 211 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 223 | + else { |
|
| 224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 225 | + } |
|
| 212 | 226 | } |
| 213 | 227 | |
| 214 | - if (!empty($event['location'])) |
|
| 215 | - echo ' |
|
| 228 | + if (!empty($event['location'])) { |
|
| 229 | + echo ' |
|
| 216 | 230 | <br>', $event['location']; |
| 231 | + } |
|
| 217 | 232 | |
| 218 | 233 | echo ' |
| 219 | 234 | </li>'; |
@@ -250,8 +265,9 @@ discard block |
||
| 250 | 265 | $context['removableMessageIDs'] = array(); |
| 251 | 266 | |
| 252 | 267 | // Get all the messages... |
| 253 | - while ($message = $context['get_message']()) |
|
| 254 | - template_single_post($message); |
|
| 268 | + while ($message = $context['get_message']()) { |
|
| 269 | + template_single_post($message); |
|
| 270 | + } |
|
| 255 | 271 | |
| 256 | 272 | echo ' |
| 257 | 273 | </form> |
@@ -289,8 +305,9 @@ discard block |
||
| 289 | 305 | <div id="display_jump_to"></div>'; |
| 290 | 306 | |
| 291 | 307 | // Show quickreply |
| 292 | - if ($context['can_reply']) |
|
| 293 | - template_quickreply(); |
|
| 308 | + if ($context['can_reply']) { |
|
| 309 | + template_quickreply(); |
|
| 310 | + } |
|
| 294 | 311 | |
| 295 | 312 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
| 296 | 313 | echo ' |
@@ -305,8 +322,8 @@ discard block |
||
| 305 | 322 | </div>'; |
| 306 | 323 | |
| 307 | 324 | // Show the moderation button & pop only if user can moderate |
| 308 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
| 309 | - echo ' |
|
| 325 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
| 326 | + echo ' |
|
| 310 | 327 | <div id="mobile_moderation" class="popup_container"> |
| 311 | 328 | <div class="popup_window description"> |
| 312 | 329 | <div class="popup_heading"> |
@@ -318,6 +335,7 @@ discard block |
||
| 318 | 335 | </div> |
| 319 | 336 | </div> |
| 320 | 337 | </div>'; |
| 338 | + } |
|
| 321 | 339 | |
| 322 | 340 | echo ' |
| 323 | 341 | <script>'; |
@@ -441,9 +459,10 @@ discard block |
||
| 441 | 459 | }); |
| 442 | 460 | }'; |
| 443 | 461 | |
| 444 | - if (!empty($context['ignoredMsgs'])) |
|
| 445 | - echo ' |
|
| 462 | + if (!empty($context['ignoredMsgs'])) { |
|
| 463 | + echo ' |
|
| 446 | 464 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
| 465 | + } |
|
| 447 | 466 | |
| 448 | 467 | echo ' |
| 449 | 468 | </script>'; |
@@ -460,8 +479,9 @@ discard block |
||
| 460 | 479 | |
| 461 | 480 | $ignoring = false; |
| 462 | 481 | |
| 463 | - if ($message['can_remove']) |
|
| 464 | - $context['removableMessageIDs'][] = $message['id']; |
|
| 482 | + if ($message['can_remove']) { |
|
| 483 | + $context['removableMessageIDs'][] = $message['id']; |
|
| 484 | + } |
|
| 465 | 485 | |
| 466 | 486 | // Are we ignoring this message? |
| 467 | 487 | if (!empty($message['is_ignored'])) |
@@ -488,9 +508,10 @@ discard block |
||
| 488 | 508 | <div class="custom_fields_above_member"> |
| 489 | 509 | <ul class="nolist">'; |
| 490 | 510 | |
| 491 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 492 | - echo ' |
|
| 511 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 512 | + echo ' |
|
| 493 | 513 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 514 | + } |
|
| 494 | 515 | |
| 495 | 516 | echo ' |
| 496 | 517 | </ul> |
@@ -501,25 +522,28 @@ discard block |
||
| 501 | 522 | <h4>'; |
| 502 | 523 | |
| 503 | 524 | // Show online and offline buttons? |
| 504 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 505 | - echo ' |
|
| 525 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 526 | + echo ' |
|
| 506 | 527 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
| 528 | + } |
|
| 507 | 529 | |
| 508 | 530 | // Custom fields BEFORE the username? |
| 509 | - if (!empty($message['custom_fields']['before_member'])) |
|
| 510 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 531 | + if (!empty($message['custom_fields']['before_member'])) { |
|
| 532 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 511 | 533 | echo ' |
| 512 | 534 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 535 | + } |
|
| 513 | 536 | |
| 514 | 537 | // Show a link to the member's profile. |
| 515 | 538 | echo ' |
| 516 | 539 | ', $message['member']['link']; |
| 517 | 540 | |
| 518 | 541 | // Custom fields AFTER the username? |
| 519 | - if (!empty($message['custom_fields']['after_member'])) |
|
| 520 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 542 | + if (!empty($message['custom_fields']['after_member'])) { |
|
| 543 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 521 | 544 | echo ' |
| 522 | 545 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 546 | + } |
|
| 523 | 547 | |
| 524 | 548 | // Begin display of user info |
| 525 | 549 | echo ' |
@@ -527,51 +551,59 @@ discard block |
||
| 527 | 551 | <ul class="user_info">'; |
| 528 | 552 | |
| 529 | 553 | // Show the user's avatar. |
| 530 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 531 | - echo ' |
|
| 554 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 555 | + echo ' |
|
| 532 | 556 | <li class="avatar"> |
| 533 | 557 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
| 534 | 558 | </li>'; |
| 559 | + } |
|
| 535 | 560 | |
| 536 | 561 | // Are there any custom fields below the avatar? |
| 537 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 538 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 562 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 563 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 539 | 564 | echo ' |
| 540 | 565 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 566 | + } |
|
| 541 | 567 | |
| 542 | 568 | // Show the post group icons, but not for guests. |
| 543 | - if (!$message['member']['is_guest']) |
|
| 544 | - echo ' |
|
| 569 | + if (!$message['member']['is_guest']) { |
|
| 570 | + echo ' |
|
| 545 | 571 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 572 | + } |
|
| 546 | 573 | |
| 547 | 574 | // Show the member's primary group (like 'Administrator') if they have one. |
| 548 | - if (!empty($message['member']['group'])) |
|
| 549 | - echo ' |
|
| 575 | + if (!empty($message['member']['group'])) { |
|
| 576 | + echo ' |
|
| 550 | 577 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 578 | + } |
|
| 551 | 579 | |
| 552 | 580 | // Show the member's custom title, if they have one. |
| 553 | - if (!empty($message['member']['title'])) |
|
| 554 | - echo ' |
|
| 581 | + if (!empty($message['member']['title'])) { |
|
| 582 | + echo ' |
|
| 555 | 583 | <li class="title">', $message['member']['title'], '</li>'; |
| 584 | + } |
|
| 556 | 585 | |
| 557 | 586 | // Don't show these things for guests. |
| 558 | 587 | if (!$message['member']['is_guest']) |
| 559 | 588 | { |
| 560 | 589 | |
| 561 | 590 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 562 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
| 563 | - echo ' |
|
| 591 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
| 592 | + echo ' |
|
| 564 | 593 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 594 | + } |
|
| 565 | 595 | |
| 566 | 596 | // Show how many posts they have made. |
| 567 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 568 | - echo ' |
|
| 597 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 598 | + echo ' |
|
| 569 | 599 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 600 | + } |
|
| 570 | 601 | |
| 571 | 602 | // Show their personal text? |
| 572 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
| 573 | - echo ' |
|
| 603 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
| 604 | + echo ' |
|
| 574 | 605 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 606 | + } |
|
| 575 | 607 | |
| 576 | 608 | // Any custom fields to show as icons? |
| 577 | 609 | if (!empty($message['custom_fields']['icons'])) |
@@ -580,9 +612,10 @@ discard block |
||
| 580 | 612 | <li class="im_icons"> |
| 581 | 613 | <ol>'; |
| 582 | 614 | |
| 583 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 584 | - echo ' |
|
| 615 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 616 | + echo ' |
|
| 585 | 617 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 618 | + } |
|
| 586 | 619 | |
| 587 | 620 | echo ' |
| 588 | 621 | </ol> |
@@ -597,19 +630,22 @@ discard block |
||
| 597 | 630 | <ol class="profile_icons">'; |
| 598 | 631 | |
| 599 | 632 | // Don't show an icon if they haven't specified a website. |
| 600 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
| 601 | - echo ' |
|
| 633 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
| 634 | + echo ' |
|
| 602 | 635 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 636 | + } |
|
| 603 | 637 | |
| 604 | 638 | // Since we know this person isn't a guest, you *can* message them. |
| 605 | - if ($context['can_send_pm']) |
|
| 606 | - echo ' |
|
| 639 | + if ($context['can_send_pm']) { |
|
| 640 | + echo ' |
|
| 607 | 641 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 642 | + } |
|
| 608 | 643 | |
| 609 | 644 | // Show the email if necessary |
| 610 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 611 | - echo ' |
|
| 645 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 646 | + echo ' |
|
| 612 | 647 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 648 | + } |
|
| 613 | 649 | |
| 614 | 650 | echo ' |
| 615 | 651 | </ol> |
@@ -617,58 +653,66 @@ discard block |
||
| 617 | 653 | } |
| 618 | 654 | |
| 619 | 655 | // Any custom fields for standard placement? |
| 620 | - if (!empty($message['custom_fields']['standard'])) |
|
| 621 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 656 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 657 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 622 | 658 | echo ' |
| 623 | 659 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 660 | + } |
|
| 624 | 661 | |
| 625 | 662 | } |
| 626 | 663 | // Otherwise, show the guest's email. |
| 627 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 628 | - echo ' |
|
| 664 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 665 | + echo ' |
|
| 629 | 666 | <li class="email"> |
| 630 | 667 | <a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a> |
| 631 | 668 | </li>'; |
| 669 | + } |
|
| 632 | 670 | |
| 633 | 671 | // Show the IP to this user for this post - because you can moderate? |
| 634 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 635 | - echo ' |
|
| 672 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 673 | + echo ' |
|
| 636 | 674 | <li class="poster_ip"> |
| 637 | 675 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
| 638 | 676 | </li>'; |
| 677 | + } |
|
| 639 | 678 | |
| 640 | 679 | // Or, should we show it because this is you? |
| 641 | - elseif ($message['can_see_ip']) |
|
| 642 | - echo ' |
|
| 680 | + elseif ($message['can_see_ip']) { |
|
| 681 | + echo ' |
|
| 643 | 682 | <li class="poster_ip"> |
| 644 | 683 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
| 645 | 684 | </li>'; |
| 685 | + } |
|
| 646 | 686 | |
| 647 | 687 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
| 648 | - elseif (!$context['user']['is_guest']) |
|
| 649 | - echo ' |
|
| 688 | + elseif (!$context['user']['is_guest']) { |
|
| 689 | + echo ' |
|
| 650 | 690 | <li class="poster_ip"> |
| 651 | 691 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
| 652 | 692 | </li>'; |
| 693 | + } |
|
| 653 | 694 | |
| 654 | 695 | // Otherwise, you see NOTHING! |
| 655 | - else |
|
| 656 | - echo ' |
|
| 696 | + else { |
|
| 697 | + echo ' |
|
| 657 | 698 | <li class="poster_ip">', $txt['logged'], '</li>'; |
| 699 | + } |
|
| 658 | 700 | |
| 659 | 701 | // Are we showing the warning status? |
| 660 | 702 | // Don't show these things for guests. |
| 661 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
| 662 | - echo ' |
|
| 703 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
| 704 | + echo ' |
|
| 663 | 705 | <li class="warning"> |
| 664 | 706 | ', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span> |
| 665 | 707 | </li>'; |
| 708 | + } |
|
| 666 | 709 | |
| 667 | 710 | // Are there any custom fields to show at the bottom of the poster info? |
| 668 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 669 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 711 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 712 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 670 | 713 | echo ' |
| 671 | 714 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 715 | + } |
|
| 672 | 716 | |
| 673 | 717 | // Poster info ends. |
| 674 | 718 | echo ' |
@@ -698,9 +742,10 @@ discard block |
||
| 698 | 742 | echo ' |
| 699 | 743 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
| 700 | 744 | |
| 701 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
| 702 | - echo |
|
| 745 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
| 746 | + echo |
|
| 703 | 747 | $message['modified']['last_edit_text']; |
| 748 | + } |
|
| 704 | 749 | |
| 705 | 750 | echo ' |
| 706 | 751 | </span> |
@@ -709,22 +754,24 @@ discard block |
||
| 709 | 754 | </div><!-- .keyinfo -->'; |
| 710 | 755 | |
| 711 | 756 | // Ignoring this user? Hide the post. |
| 712 | - if ($ignoring) |
|
| 713 | - echo ' |
|
| 757 | + if ($ignoring) { |
|
| 758 | + echo ' |
|
| 714 | 759 | <div id="msg_', $message['id'], '_ignored_prompt"> |
| 715 | 760 | ', $txt['ignoring_user'], ' |
| 716 | 761 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 717 | 762 | </div>'; |
| 763 | + } |
|
| 718 | 764 | |
| 719 | 765 | // Show the post itself, finally! |
| 720 | 766 | echo ' |
| 721 | 767 | <div class="post">'; |
| 722 | 768 | |
| 723 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
| 724 | - echo ' |
|
| 769 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
| 770 | + echo ' |
|
| 725 | 771 | <div class="approve_post"> |
| 726 | 772 | ', $txt['post_awaiting_approval'], ' |
| 727 | 773 | </div>'; |
| 774 | + } |
|
| 728 | 775 | echo ' |
| 729 | 776 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '> |
| 730 | 777 | ', $message['body'], ' |
@@ -743,9 +790,9 @@ discard block |
||
| 743 | 790 | foreach ($message['attachment'] as $attachment) |
| 744 | 791 | { |
| 745 | 792 | // Do we want this attachment to not be showed here? |
| 746 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
| 747 | - continue; |
|
| 748 | - elseif (!$div_output) |
|
| 793 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
| 794 | + continue; |
|
| 795 | + } elseif (!$div_output) |
|
| 749 | 796 | { |
| 750 | 797 | $div_output = true; |
| 751 | 798 | |
@@ -762,9 +809,10 @@ discard block |
||
| 762 | 809 | <legend> |
| 763 | 810 | ', $txt['attach_awaiting_approve']; |
| 764 | 811 | |
| 765 | - if ($context['can_approve']) |
|
| 766 | - echo ' |
|
| 812 | + if ($context['can_approve']) { |
|
| 813 | + echo ' |
|
| 767 | 814 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
| 815 | + } |
|
| 768 | 816 | |
| 769 | 817 | echo ' |
| 770 | 818 | </legend>'; |
@@ -778,12 +826,13 @@ discard block |
||
| 778 | 826 | echo ' |
| 779 | 827 | <div class="attachments_top">'; |
| 780 | 828 | |
| 781 | - if ($attachment['thumbnail']['has_thumb']) |
|
| 782 | - echo ' |
|
| 829 | + if ($attachment['thumbnail']['has_thumb']) { |
|
| 830 | + echo ' |
|
| 783 | 831 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
| 784 | - else |
|
| 785 | - echo ' |
|
| 832 | + } else { |
|
| 833 | + echo ' |
|
| 786 | 834 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
| 835 | + } |
|
| 787 | 836 | |
| 788 | 837 | echo ' |
| 789 | 838 | </div><!-- .attachments_top -->'; |
@@ -793,9 +842,10 @@ discard block |
||
| 793 | 842 | <div class="attachments_bot"> |
| 794 | 843 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
| 795 | 844 | |
| 796 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
| 797 | - echo ' |
|
| 845 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
| 846 | + echo ' |
|
| 798 | 847 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
| 848 | + } |
|
| 799 | 849 | echo ' |
| 800 | 850 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
| 801 | 851 | </div><!-- .attachments_bot -->'; |
@@ -804,35 +854,40 @@ discard block |
||
| 804 | 854 | </div><!-- .attached -->'; |
| 805 | 855 | |
| 806 | 856 | // Next attachment line ? |
| 807 | - if (++$i % $attachments_per_line === 0) |
|
| 808 | - echo ' |
|
| 857 | + if (++$i % $attachments_per_line === 0) { |
|
| 858 | + echo ' |
|
| 809 | 859 | <br>'; |
| 860 | + } |
|
| 810 | 861 | } |
| 811 | 862 | |
| 812 | 863 | // If we had unapproved attachments clean up. |
| 813 | - if ($last_approved_state == 0) |
|
| 814 | - echo ' |
|
| 864 | + if ($last_approved_state == 0) { |
|
| 865 | + echo ' |
|
| 815 | 866 | </fieldset>'; |
| 867 | + } |
|
| 816 | 868 | |
| 817 | 869 | // Only do this if we output a div above - otherwise it'll break things |
| 818 | - if ($div_output) |
|
| 819 | - echo ' |
|
| 870 | + if ($div_output) { |
|
| 871 | + echo ' |
|
| 820 | 872 | </div><!-- #msg_[id]_footer -->'; |
| 873 | + } |
|
| 821 | 874 | } |
| 822 | 875 | |
| 823 | 876 | // And stuff below the attachments. |
| 824 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 825 | - echo ' |
|
| 877 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 878 | + echo ' |
|
| 826 | 879 | <div class="under_message">'; |
| 880 | + } |
|
| 827 | 881 | |
| 828 | 882 | // Maybe they want to report this post to the moderator(s)? |
| 829 | - if ($context['can_report_moderator']) |
|
| 830 | - echo ' |
|
| 883 | + if ($context['can_report_moderator']) { |
|
| 884 | + echo ' |
|
| 831 | 885 | <ul class="floatright smalltext"> |
| 832 | 886 | <li class="report_link"> |
| 833 | 887 | <a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a> |
| 834 | 888 | </li> |
| 835 | 889 | </ul>'; |
| 890 | + } |
|
| 836 | 891 | |
| 837 | 892 | // What about likes? |
| 838 | 893 | if (!empty($modSettings['enable_likes'])) |
@@ -879,83 +934,95 @@ discard block |
||
| 879 | 934 | <ul class="quickbuttons">'; |
| 880 | 935 | |
| 881 | 936 | // Can they quote? if so they can select and quote as well! |
| 882 | - if ($context['can_quote']) |
|
| 883 | - echo ' |
|
| 937 | + if ($context['can_quote']) { |
|
| 938 | + echo ' |
|
| 884 | 939 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
| 885 | 940 | <li style="display:none;" id="quoteSelected_', $message['id'], '"> |
| 886 | 941 | <a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a> |
| 887 | 942 | </li>'; |
| 943 | + } |
|
| 888 | 944 | |
| 889 | 945 | // Can the user modify the contents of this post? Show the modify inline image. |
| 890 | - if ($message['can_modify']) |
|
| 891 | - echo ' |
|
| 946 | + if ($message['can_modify']) { |
|
| 947 | + echo ' |
|
| 892 | 948 | <li class="quick_edit"> |
| 893 | 949 | <a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a> |
| 894 | 950 | </li>'; |
| 951 | + } |
|
| 895 | 952 | |
| 896 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 897 | - echo ' |
|
| 953 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 954 | + echo ' |
|
| 898 | 955 | <li class="post_options">', $txt['post_options']; |
| 956 | + } |
|
| 899 | 957 | |
| 900 | 958 | echo ' |
| 901 | 959 | <ul>'; |
| 902 | 960 | |
| 903 | 961 | // Can the user modify the contents of this post? |
| 904 | - if ($message['can_modify']) |
|
| 905 | - echo ' |
|
| 962 | + if ($message['can_modify']) { |
|
| 963 | + echo ' |
|
| 906 | 964 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
| 965 | + } |
|
| 907 | 966 | |
| 908 | 967 | // How about... even... remove it entirely?! |
| 909 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
| 910 | - echo ' |
|
| 968 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
| 969 | + echo ' |
|
| 911 | 970 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
| 912 | - |
|
| 913 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
| 914 | - echo ' |
|
| 971 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
| 972 | + echo ' |
|
| 915 | 973 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 974 | + } |
|
| 916 | 975 | |
| 917 | 976 | // What about splitting it off the rest of the topic? |
| 918 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
| 919 | - echo ' |
|
| 977 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
| 978 | + echo ' |
|
| 920 | 979 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
| 980 | + } |
|
| 921 | 981 | |
| 922 | 982 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
| 923 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
| 924 | - echo ' |
|
| 983 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
| 984 | + echo ' |
|
| 925 | 985 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
| 986 | + } |
|
| 926 | 987 | |
| 927 | 988 | // Can we restore topics? |
| 928 | - if ($context['can_restore_msg']) |
|
| 929 | - echo ' |
|
| 989 | + if ($context['can_restore_msg']) { |
|
| 990 | + echo ' |
|
| 930 | 991 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
| 992 | + } |
|
| 931 | 993 | |
| 932 | 994 | // Maybe we can approve it, maybe we should? |
| 933 | - if ($message['can_approve']) |
|
| 934 | - echo ' |
|
| 995 | + if ($message['can_approve']) { |
|
| 996 | + echo ' |
|
| 935 | 997 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
| 998 | + } |
|
| 936 | 999 | |
| 937 | 1000 | // Maybe we can unapprove it? |
| 938 | - if ($message['can_unapprove']) |
|
| 939 | - echo ' |
|
| 1001 | + if ($message['can_unapprove']) { |
|
| 1002 | + echo ' |
|
| 940 | 1003 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
| 1004 | + } |
|
| 941 | 1005 | |
| 942 | 1006 | echo ' |
| 943 | 1007 | </ul> |
| 944 | 1008 | </li>'; |
| 945 | 1009 | |
| 946 | 1010 | // Show a checkbox for quick moderation? |
| 947 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
| 948 | - echo ' |
|
| 1011 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
| 1012 | + echo ' |
|
| 949 | 1013 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
| 1014 | + } |
|
| 950 | 1015 | |
| 951 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 952 | - echo ' |
|
| 1016 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 1017 | + echo ' |
|
| 953 | 1018 | </ul><!-- .quickbuttons -->'; |
| 1019 | + } |
|
| 954 | 1020 | } |
| 955 | 1021 | |
| 956 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 957 | - echo ' |
|
| 1022 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 1023 | + echo ' |
|
| 958 | 1024 | </div><!-- .under_message -->'; |
| 1025 | + } |
|
| 959 | 1026 | |
| 960 | 1027 | echo ' |
| 961 | 1028 | </div><!-- .postarea --> |
@@ -968,9 +1035,10 @@ discard block |
||
| 968 | 1035 | <div class="custom_fields_above_signature"> |
| 969 | 1036 | <ul class="nolist">'; |
| 970 | 1037 | |
| 971 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 972 | - echo ' |
|
| 1038 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 1039 | + echo ' |
|
| 973 | 1040 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1041 | + } |
|
| 974 | 1042 | |
| 975 | 1043 | echo ' |
| 976 | 1044 | </ul> |
@@ -978,11 +1046,12 @@ discard block |
||
| 978 | 1046 | } |
| 979 | 1047 | |
| 980 | 1048 | // Show the member's signature? |
| 981 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 982 | - echo ' |
|
| 1049 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 1050 | + echo ' |
|
| 983 | 1051 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '> |
| 984 | 1052 | ', $message['member']['signature'], ' |
| 985 | 1053 | </div>'; |
| 1054 | + } |
|
| 986 | 1055 | |
| 987 | 1056 | |
| 988 | 1057 | // Are there any custom profile fields for below the signature? |
@@ -992,9 +1061,10 @@ discard block |
||
| 992 | 1061 | <div class="custom_fields_below_signature"> |
| 993 | 1062 | <ul class="nolist">'; |
| 994 | 1063 | |
| 995 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 996 | - echo ' |
|
| 1064 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 1065 | + echo ' |
|
| 997 | 1066 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1067 | + } |
|
| 998 | 1068 | |
| 999 | 1069 | echo ' |
| 1000 | 1070 | </ul> |
@@ -1044,8 +1114,8 @@ discard block |
||
| 1044 | 1114 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
| 1045 | 1115 | |
| 1046 | 1116 | // Guests just need more. |
| 1047 | - if ($context['user']['is_guest']) |
|
| 1048 | - echo ' |
|
| 1117 | + if ($context['user']['is_guest']) { |
|
| 1118 | + echo ' |
|
| 1049 | 1119 | <dl id="post_header"> |
| 1050 | 1120 | <dt> |
| 1051 | 1121 | ', $txt['name'], ': |
@@ -1060,6 +1130,7 @@ discard block |
||
| 1060 | 1130 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required> |
| 1061 | 1131 | </dd> |
| 1062 | 1132 | </dl>'; |
| 1133 | + } |
|
| 1063 | 1134 | |
| 1064 | 1135 | echo ' |
| 1065 | 1136 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1084,12 +1155,13 @@ discard block |
||
| 1084 | 1155 | </script>'; |
| 1085 | 1156 | |
| 1086 | 1157 | // Is visual verification enabled? |
| 1087 | - if ($context['require_verification']) |
|
| 1088 | - echo ' |
|
| 1158 | + if ($context['require_verification']) { |
|
| 1159 | + echo ' |
|
| 1089 | 1160 | <div class="post_verification"> |
| 1090 | 1161 | <strong>', $txt['verification'], ':</strong> |
| 1091 | 1162 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 1092 | 1163 | </div>'; |
| 1164 | + } |
|
| 1093 | 1165 | |
| 1094 | 1166 | // Finally, the submit buttons. |
| 1095 | 1167 | echo ' |
@@ -1105,8 +1177,8 @@ discard block |
||
| 1105 | 1177 | <br class="clear">'; |
| 1106 | 1178 | |
| 1107 | 1179 | // Draft autosave available and the user has it enabled? |
| 1108 | - if (!empty($context['drafts_autosave'])) |
|
| 1109 | - echo ' |
|
| 1180 | + if (!empty($context['drafts_autosave'])) { |
|
| 1181 | + echo ' |
|
| 1110 | 1182 | <script> |
| 1111 | 1183 | var oDraftAutoSave = new smf_DraftAutoSave({ |
| 1112 | 1184 | sSelf: \'oDraftAutoSave\', |
@@ -1118,12 +1190,14 @@ discard block |
||
| 1118 | 1190 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
| 1119 | 1191 | }); |
| 1120 | 1192 | </script>'; |
| 1193 | + } |
|
| 1121 | 1194 | |
| 1122 | - if ($context['show_spellchecking']) |
|
| 1123 | - echo ' |
|
| 1195 | + if ($context['show_spellchecking']) { |
|
| 1196 | + echo ' |
|
| 1124 | 1197 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"> |
| 1125 | 1198 | <input type="hidden" name="spellstring" value=""> |
| 1126 | 1199 | </form>'; |
| 1200 | + } |
|
| 1127 | 1201 | |
| 1128 | 1202 | echo ' |
| 1129 | 1203 | <script> |
@@ -37,9 +37,10 @@ discard block |
||
| 37 | 37 | echo ' |
| 38 | 38 | <optgroup label="', $category['name'], '">'; |
| 39 | 39 | |
| 40 | - foreach ($category['boards'] as $board) |
|
| 41 | - echo ' |
|
| 40 | + foreach ($category['boards'] as $board) { |
|
| 41 | + echo ' |
|
| 42 | 42 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=> ' : '', $board['name'], '</option>'; |
| 43 | + } |
|
| 43 | 44 | echo ' |
| 44 | 45 | </optgroup>'; |
| 45 | 46 | } |
@@ -70,9 +71,10 @@ discard block |
||
| 70 | 71 | </div><!-- .move_topic --> |
| 71 | 72 | </div><!-- .windowbg -->'; |
| 72 | 73 | |
| 73 | - if ($context['back_to_topic']) |
|
| 74 | - echo ' |
|
| 74 | + if ($context['back_to_topic']) { |
|
| 75 | + echo ' |
|
| 75 | 76 | <input type="hidden" name="goback" value="1">'; |
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | echo ' |
| 78 | 80 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -125,10 +127,10 @@ discard block |
||
| 125 | 127 | <option value="86400">', $txt['two_months'], '</option> |
| 126 | 128 | </select> |
| 127 | 129 | </dd>'; |
| 128 | - } |
|
| 129 | - else |
|
| 130 | - echo ' |
|
| 130 | + } else { |
|
| 131 | + echo ' |
|
| 131 | 132 | <input type="hidden" name="redirect_expires" value="0">'; |
| 133 | + } |
|
| 132 | 134 | |
| 133 | 135 | echo ' |
| 134 | 136 | </dl> |
@@ -207,9 +209,10 @@ discard block |
||
| 207 | 209 | echo ' |
| 208 | 210 | <optgroup label="', $cat['name'], '">'; |
| 209 | 211 | |
| 210 | - foreach ($cat['boards'] as $board) |
|
| 211 | - echo ' |
|
| 212 | + foreach ($cat['boards'] as $board) { |
|
| 213 | + echo ' |
|
| 212 | 214 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
| 215 | + } |
|
| 213 | 216 | |
| 214 | 217 | echo ' |
| 215 | 218 | </optgroup>'; |
@@ -220,9 +223,9 @@ discard block |
||
| 220 | 223 | <input type="submit" value="', $txt['go'], '" class="button"> |
| 221 | 224 | </form>'; |
| 222 | 225 | |
| 226 | + } else { |
|
| 227 | + echo $txt['target_below']; |
|
| 223 | 228 | } |
| 224 | - else |
|
| 225 | - echo $txt['target_below']; |
|
| 226 | 229 | |
| 227 | 230 | echo ' </h4> |
| 228 | 231 | </div><!-- .title_bar -->'; |
@@ -240,12 +243,13 @@ discard block |
||
| 240 | 243 | |
| 241 | 244 | $merge_button = create_button('merge', 'merge', ''); |
| 242 | 245 | |
| 243 | - foreach ($context['topics'] as $topic) |
|
| 244 | - echo ' |
|
| 246 | + foreach ($context['topics'] as $topic) { |
|
| 247 | + echo ' |
|
| 245 | 248 | <li> |
| 246 | 249 | <a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a> |
| 247 | 250 | <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], ' |
| 248 | 251 | </li>'; |
| 252 | + } |
|
| 249 | 253 | |
| 250 | 254 | echo ' |
| 251 | 255 | </ul> |
@@ -256,9 +260,10 @@ discard block |
||
| 256 | 260 | </div>'; |
| 257 | 261 | } |
| 258 | 262 | // Just a nice "There aren't any topics" message |
| 259 | - else |
|
| 260 | - echo ' |
|
| 263 | + else { |
|
| 264 | + echo ' |
|
| 261 | 265 | <div class="windowbg2">', $txt['topic_alert_none'], '</div>'; |
| 266 | + } |
|
| 262 | 267 | |
| 263 | 268 | echo ' |
| 264 | 269 | <br> |
@@ -308,8 +313,8 @@ discard block |
||
| 308 | 313 | </thead> |
| 309 | 314 | <tbody>'; |
| 310 | 315 | |
| 311 | - foreach ($context['topics'] as $topic) |
|
| 312 | - echo ' |
|
| 316 | + foreach ($context['topics'] as $topic) { |
|
| 317 | + echo ' |
|
| 313 | 318 | <tr class="windowbg"> |
| 314 | 319 | <td> |
| 315 | 320 | <input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked> |
@@ -329,6 +334,7 @@ discard block |
||
| 329 | 334 | <input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked> |
| 330 | 335 | </td> |
| 331 | 336 | </tr>'; |
| 337 | + } |
|
| 332 | 338 | echo ' |
| 333 | 339 | </tbody> |
| 334 | 340 | </table> |
@@ -338,9 +344,10 @@ discard block |
||
| 338 | 344 | <legend>', $txt['merge_select_subject'], '</legend> |
| 339 | 345 | <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">'; |
| 340 | 346 | |
| 341 | - foreach ($context['topics'] as $topic) |
|
| 342 | - echo ' |
|
| 347 | + foreach ($context['topics'] as $topic) { |
|
| 348 | + echo ' |
|
| 343 | 349 | <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>'; |
| 350 | + } |
|
| 344 | 351 | echo ' |
| 345 | 352 | <option value="0">', $txt['merge_custom_subject'], ':</option> |
| 346 | 353 | </select> |
@@ -359,11 +366,12 @@ discard block |
||
| 359 | 366 | <legend>', $txt['merge_select_target_board'], '</legend> |
| 360 | 367 | <ul>'; |
| 361 | 368 | |
| 362 | - foreach ($context['boards'] as $board) |
|
| 363 | - echo ' |
|
| 369 | + foreach ($context['boards'] as $board) { |
|
| 370 | + echo ' |
|
| 364 | 371 | <li> |
| 365 | 372 | <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . ' |
| 366 | 373 | </li>'; |
| 374 | + } |
|
| 367 | 375 | echo ' |
| 368 | 376 | </ul> |
| 369 | 377 | </fieldset>'; |
@@ -375,11 +383,12 @@ discard block |
||
| 375 | 383 | <legend>' . $txt['merge_select_poll'] . '</legend> |
| 376 | 384 | <ul>'; |
| 377 | 385 | |
| 378 | - foreach ($context['polls'] as $poll) |
|
| 379 | - echo ' |
|
| 386 | + foreach ($context['polls'] as $poll) { |
|
| 387 | + echo ' |
|
| 380 | 388 | <li> |
| 381 | 389 | <input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>) |
| 382 | 390 | </li>'; |
| 391 | + } |
|
| 383 | 392 | echo ' |
| 384 | 393 | <li> |
| 385 | 394 | <input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ') |
@@ -27,9 +27,10 @@ discard block |
||
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
| 29 | 29 | |
| 30 | - if (!isset($context['old_search'])) |
|
| 31 | - echo ' |
|
| 30 | + if (!isset($context['old_search'])) { |
|
| 31 | + echo ' |
|
| 32 | 32 | <span class="floatright">', $context['letter_links'], '</span>'; |
| 33 | + } |
|
| 33 | 34 | echo ' |
| 34 | 35 | </h3> |
| 35 | 36 | </div>'; |
@@ -44,20 +45,23 @@ discard block |
||
| 44 | 45 | foreach ($context['columns'] as $key => $column) |
| 45 | 46 | { |
| 46 | 47 | // @TODO maybe find something nicer? |
| 47 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
| 48 | - continue; |
|
| 48 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
| 49 | + continue; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // This is a selected column, so underline it or some such. |
| 51 | - if ($column['selected']) |
|
| 52 | - echo ' |
|
| 53 | + if ($column['selected']) { |
|
| 54 | + echo ' |
|
| 53 | 55 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
| 54 | 56 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
| 57 | + } |
|
| 55 | 58 | |
| 56 | 59 | // This is just some column... show the link and be done with it. |
| 57 | - else |
|
| 58 | - echo ' |
|
| 60 | + else { |
|
| 61 | + echo ' |
|
| 59 | 62 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
| 60 | 63 | ', $column['link'], '</th>'; |
| 64 | + } |
|
| 61 | 65 | } |
| 62 | 66 | |
| 63 | 67 | echo ' |
@@ -77,9 +81,10 @@ discard block |
||
| 77 | 81 | </td> |
| 78 | 82 | <td class="lefttext">', $member['link'], '</td>'; |
| 79 | 83 | |
| 80 | - if (!isset($context['disabled_fields']['website'])) |
|
| 81 | - echo ' |
|
| 84 | + if (!isset($context['disabled_fields']['website'])) { |
|
| 85 | + echo ' |
|
| 82 | 86 | <td class="centertext website_url">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
| 87 | + } |
|
| 83 | 88 | |
| 84 | 89 | // Group and date. |
| 85 | 90 | echo ' |
@@ -92,32 +97,35 @@ discard block |
||
| 92 | 97 | <td class="centertext" style="white-space: nowrap; width: 15px">', $member['posts'], '</td> |
| 93 | 98 | <td class="centertext statsbar" style="width: 120px">'; |
| 94 | 99 | |
| 95 | - if (!empty($member['post_percent'])) |
|
| 96 | - echo ' |
|
| 100 | + if (!empty($member['post_percent'])) { |
|
| 101 | + echo ' |
|
| 97 | 102 | <div class="bar" style="width: ', $member['post_percent'] + 4, 'px;"> |
| 98 | 103 | <div style="width: ', $member['post_percent'], 'px;"></div> |
| 99 | 104 | </div>'; |
| 105 | + } |
|
| 100 | 106 | |
| 101 | 107 | echo ' |
| 102 | 108 | </td>'; |
| 103 | 109 | } |
| 104 | 110 | |
| 105 | 111 | // Show custom fields marked to be shown here |
| 106 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 107 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
| 112 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 113 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
| 108 | 114 | echo ' |
| 109 | 115 | <td class="righttext">', $member['options'][$key], '</td>'; |
| 116 | + } |
|
| 110 | 117 | |
| 111 | 118 | echo ' |
| 112 | 119 | </tr>'; |
| 113 | 120 | } |
| 114 | 121 | } |
| 115 | 122 | // No members? |
| 116 | - else |
|
| 117 | - echo ' |
|
| 123 | + else { |
|
| 124 | + echo ' |
|
| 118 | 125 | <tr> |
| 119 | 126 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
| 120 | 127 | </tr>'; |
| 128 | + } |
|
| 121 | 129 | |
| 122 | 130 | echo ' |
| 123 | 131 | </tbody> |
@@ -130,9 +138,10 @@ discard block |
||
| 130 | 138 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
| 131 | 139 | |
| 132 | 140 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
| 133 | - if (isset($context['old_search'])) |
|
| 134 | - echo ' |
|
| 141 | + if (isset($context['old_search'])) { |
|
| 142 | + echo ' |
|
| 135 | 143 | <a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>'; |
| 144 | + } |
|
| 136 | 145 | echo ' |
| 137 | 146 | </div> |
| 138 | 147 | </div><!-- #memberlist -->'; |
@@ -172,12 +181,13 @@ discard block |
||
| 172 | 181 | <dd> |
| 173 | 182 | <ul>'; |
| 174 | 183 | |
| 175 | - foreach ($context['search_fields'] as $id => $title) |
|
| 176 | - echo ' |
|
| 184 | + foreach ($context['search_fields'] as $id => $title) { |
|
| 185 | + echo ' |
|
| 177 | 186 | <li> |
| 178 | 187 | <input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '> |
| 179 | 188 | <label for="fields-', $id, '">', $title, '</label> |
| 180 | 189 | </li>'; |
| 190 | + } |
|
| 181 | 191 | |
| 182 | 192 | echo ' |
| 183 | 193 | </ul> |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | 'class' => 'centercol', |
| 394 | 394 | ), |
| 395 | 395 | 'data' => array( |
| 396 | - 'function' => function ($rowData) |
|
| 396 | + 'function' => function($rowData) |
|
| 397 | 397 | { |
| 398 | 398 | return $rowData['selected'] ? '<span class="generic_icons valid"></span>' : ''; |
| 399 | 399 | }, |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | 'class' => 'centercol', |
| 454 | 454 | ), |
| 455 | 455 | 'data' => array( |
| 456 | - 'function' => function ($rowData) |
|
| 456 | + 'function' => function($rowData) |
|
| 457 | 457 | { |
| 458 | 458 | return $rowData['selected'] ? '' : sprintf('<input type="checkbox" name="smiley_set[%1$d]">', $rowData['id']); |
| 459 | 459 | }, |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | 'value' => $txt['smileys_location'], |
| 998 | 998 | ), |
| 999 | 999 | 'data' => array( |
| 1000 | - 'function' => function ($rowData) use ($txt) |
|
| 1000 | + 'function' => function($rowData) use ($txt) |
|
| 1001 | 1001 | { |
| 1002 | 1002 | if (empty($rowData['hidden'])) |
| 1003 | 1003 | return $txt['smileys_location_form']; |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | }, |
| 1009 | 1009 | ), |
| 1010 | 1010 | 'sort' => array( |
| 1011 | - 'default' => $smcFunc['db_custom_order']('hidden', array_keys($smiley_locations)) , |
|
| 1011 | + 'default' => $smcFunc['db_custom_order']('hidden', array_keys($smiley_locations)), |
|
| 1012 | 1012 | 'reverse' => $smcFunc['db_custom_order']('hidden', array_keys($smiley_locations), true), |
| 1013 | 1013 | ), |
| 1014 | 1014 | ), |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | 'value' => $txt['smileys_description'], |
| 1018 | 1018 | ), |
| 1019 | 1019 | 'data' => array( |
| 1020 | - 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
| 1020 | + 'function' => function($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
| 1021 | 1021 | { |
| 1022 | 1022 | if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
| 1023 | 1023 | return $smcFunc['htmlspecialchars']($rowData['description']); |
@@ -1554,7 +1554,7 @@ discard block |
||
| 1554 | 1554 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 1555 | 1555 | ); |
| 1556 | 1556 | |
| 1557 | - $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
| 1557 | + $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
| 1558 | 1558 | if (isset($action['filename']) && (!file_exists($file) || !is_writable(dirname($action['destination'])))) |
| 1559 | 1559 | { |
| 1560 | 1560 | $context['has_failure'] = true; |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | { |
| 1600 | 1600 | updateSettings(array( |
| 1601 | 1601 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . basename($action['action']), |
| 1602 | - 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
| 1602 | + 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
| 1603 | 1603 | )); |
| 1604 | 1604 | } |
| 1605 | 1605 | |
@@ -1611,7 +1611,7 @@ discard block |
||
| 1611 | 1611 | '{db_prefix}log_packages', |
| 1612 | 1612 | array( |
| 1613 | 1613 | 'filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', |
| 1614 | - 'id_member_installed' => 'int', 'member_installed' => 'string','time_installed' => 'int', |
|
| 1614 | + 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', |
|
| 1615 | 1615 | 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', |
| 1616 | 1616 | 'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string', |
| 1617 | 1617 | ), |
@@ -1860,7 +1860,7 @@ discard block |
||
| 1860 | 1860 | 'columns' => array( |
| 1861 | 1861 | 'icon' => array( |
| 1862 | 1862 | 'data' => array( |
| 1863 | - 'function' => function ($rowData) use ($settings, $smcFunc) |
|
| 1863 | + 'function' => function($rowData) use ($settings, $smcFunc) |
|
| 1864 | 1864 | { |
| 1865 | 1865 | $images_url = $settings[file_exists(sprintf('%1$s/images/post/%2$s.png', $settings['theme_dir'], $rowData['filename'])) ? 'actual_images_url' : 'default_images_url']; |
| 1866 | 1866 | return sprintf('<img src="%1$s/post/%2$s.png" alt="%3$s">', $images_url, $rowData['filename'], $smcFunc['htmlspecialchars']($rowData['title'])); |
@@ -1894,7 +1894,7 @@ discard block |
||
| 1894 | 1894 | 'value' => $txt['icons_board'], |
| 1895 | 1895 | ), |
| 1896 | 1896 | 'data' => array( |
| 1897 | - 'function' => function ($rowData) use ($txt) |
|
| 1897 | + 'function' => function($rowData) use ($txt) |
|
| 1898 | 1898 | { |
| 1899 | 1899 | return empty($rowData['board_name']) ? $txt['icons_edit_icons_all_boards'] : $rowData['board_name']; |
| 1900 | 1900 | }, |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | { |
| 387 | 387 | $val = 'CASE '; |
| 388 | 388 | foreach ($members as $k => $v) |
| 389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 389 | + $val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 390 | 390 | $val = $val . ' END'; |
| 391 | 391 | $type = 'raw'; |
| 392 | 392 | } |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
| 818 | 818 | if (empty($unsupportedFormats)) |
| 819 | 819 | { |
| 820 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
| 820 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
| 821 | 821 | { |
| 822 | 822 | $value = @strftime('%' . $format); |
| 823 | 823 | |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
| 1183 | 1183 | ), |
| 1184 | 1184 | 'content' => '$1', |
| 1185 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1185 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1186 | 1186 | { |
| 1187 | 1187 | $returnContext = ''; |
| 1188 | 1188 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
| 1220 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1220 | + $returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>'; |
|
| 1221 | 1221 | else |
| 1222 | 1222 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
| 1223 | 1223 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | 'type' => 'unparsed_content', |
| 1247 | 1247 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
| 1248 | 1248 | // @todo Maybe this can be simplified? |
| 1249 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1249 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1250 | 1250 | { |
| 1251 | 1251 | if (!isset($disabled['code'])) |
| 1252 | 1252 | { |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | 'type' => 'unparsed_equals_content', |
| 1284 | 1284 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
| 1285 | 1285 | // @todo Maybe this can be simplified? |
| 1286 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1286 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1287 | 1287 | { |
| 1288 | 1288 | if (!isset($disabled['code'])) |
| 1289 | 1289 | { |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | 'type' => 'unparsed_content', |
| 1328 | 1328 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
| 1329 | 1329 | // @todo Should this respect guest_hideContacts? |
| 1330 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1330 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1331 | 1331 | { |
| 1332 | 1332 | $data = strtr($data, array('<br>' => '')); |
| 1333 | 1333 | }, |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | 'type' => 'unparsed_commas_content', |
| 1347 | 1347 | 'test' => '\d+,\d+\]', |
| 1348 | 1348 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1349 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1349 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1350 | 1350 | { |
| 1351 | 1351 | if (isset($disabled['url'])) |
| 1352 | 1352 | $tag['content'] = '$1'; |
@@ -1362,7 +1362,7 @@ discard block |
||
| 1362 | 1362 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
| 1363 | 1363 | 'before' => '<div $1>', |
| 1364 | 1364 | 'after' => '</div>', |
| 1365 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1365 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1366 | 1366 | { |
| 1367 | 1367 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1368 | 1368 | |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
| 1412 | 1412 | ), |
| 1413 | 1413 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
| 1414 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1414 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1415 | 1415 | { |
| 1416 | 1416 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1417 | 1417 | |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | 'tag' => 'img', |
| 1435 | 1435 | 'type' => 'unparsed_content', |
| 1436 | 1436 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
| 1437 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1437 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1438 | 1438 | { |
| 1439 | 1439 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1440 | 1440 | |
@@ -1457,7 +1457,7 @@ discard block |
||
| 1457 | 1457 | 'tag' => 'iurl', |
| 1458 | 1458 | 'type' => 'unparsed_content', |
| 1459 | 1459 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
| 1460 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1460 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1461 | 1461 | { |
| 1462 | 1462 | $data = strtr($data, array('<br>' => '')); |
| 1463 | 1463 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1471,7 +1471,7 @@ discard block |
||
| 1471 | 1471 | 'quoted' => 'optional', |
| 1472 | 1472 | 'before' => '<a href="$1" class="bbc_link">', |
| 1473 | 1473 | 'after' => '</a>', |
| 1474 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1474 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1475 | 1475 | { |
| 1476 | 1476 | if (substr($data, 0, 1) == '#') |
| 1477 | 1477 | $data = '#post_' . substr($data, 1); |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | 'tag' => 'php', |
| 1552 | 1552 | 'type' => 'unparsed_content', |
| 1553 | 1553 | 'content' => '<span class="phpcode">$1</span>', |
| 1554 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
| 1554 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
| 1555 | 1555 | { |
| 1556 | 1556 | if (!isset($disabled['php'])) |
| 1557 | 1557 | { |
@@ -1649,7 +1649,7 @@ discard block |
||
| 1649 | 1649 | 'test' => '[1-7]\]', |
| 1650 | 1650 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
| 1651 | 1651 | 'after' => '</span>', |
| 1652 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1652 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1653 | 1653 | { |
| 1654 | 1654 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
| 1655 | 1655 | $data = $sizes[$data] . 'em'; |
@@ -1687,7 +1687,7 @@ discard block |
||
| 1687 | 1687 | 'tag' => 'time', |
| 1688 | 1688 | 'type' => 'unparsed_content', |
| 1689 | 1689 | 'content' => '$1', |
| 1690 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1690 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1691 | 1691 | { |
| 1692 | 1692 | if (is_numeric($data)) |
| 1693 | 1693 | $data = timeformat($data); |
@@ -1715,7 +1715,7 @@ discard block |
||
| 1715 | 1715 | 'tag' => 'url', |
| 1716 | 1716 | 'type' => 'unparsed_content', |
| 1717 | 1717 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
| 1718 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1718 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1719 | 1719 | { |
| 1720 | 1720 | $data = strtr($data, array('<br>' => '')); |
| 1721 | 1721 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1729,7 +1729,7 @@ discard block |
||
| 1729 | 1729 | 'quoted' => 'optional', |
| 1730 | 1730 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
| 1731 | 1731 | 'after' => '</a>', |
| 1732 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1732 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1733 | 1733 | { |
| 1734 | 1734 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1735 | 1735 | if (empty($scheme)) |
@@ -1755,7 +1755,7 @@ discard block |
||
| 1755 | 1755 | { |
| 1756 | 1756 | if (isset($temp_bbc)) |
| 1757 | 1757 | $bbc_codes = $temp_bbc; |
| 1758 | - usort($codes, function ($a, $b) { |
|
| 1758 | + usort($codes, function($a, $b) { |
|
| 1759 | 1759 | return strcmp($a['tag'], $b['tag']); |
| 1760 | 1760 | }); |
| 1761 | 1761 | return $codes; |
@@ -1992,7 +1992,7 @@ discard block |
||
| 1992 | 1992 | # a run of Unicode domain name characters and a dot |
| 1993 | 1993 | [\p{L}\p{M}\p{N}\-.:@]+\. |
| 1994 | 1994 | # and then a TLD valid in the DNS or the reserved "local" TLD |
| 1995 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
| 1995 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
| 1996 | 1996 | ) |
| 1997 | 1997 | # followed by a non-domain character or end of line |
| 1998 | 1998 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2060,7 +2060,7 @@ discard block |
||
| 2060 | 2060 | )? |
| 2061 | 2061 | '; |
| 2062 | 2062 | |
| 2063 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
| 2063 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
| 2064 | 2064 | $url = array_shift($matches); |
| 2065 | 2065 | |
| 2066 | 2066 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2800,7 +2800,7 @@ discard block |
||
| 2800 | 2800 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
| 2801 | 2801 | { |
| 2802 | 2802 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
| 2803 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2803 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2804 | 2804 | |
| 2805 | 2805 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
| 2806 | 2806 | |
@@ -2817,7 +2817,7 @@ discard block |
||
| 2817 | 2817 | |
| 2818 | 2818 | // Replace away! |
| 2819 | 2819 | $message = preg_replace_callback($smileyPregSearch, |
| 2820 | - function ($matches) use ($smileyPregReplacements) |
|
| 2820 | + function($matches) use ($smileyPregReplacements) |
|
| 2821 | 2821 | { |
| 2822 | 2822 | return $smileyPregReplacements[$matches[1]]; |
| 2823 | 2823 | }, $message); |
@@ -2883,13 +2883,13 @@ discard block |
||
| 2883 | 2883 | { |
| 2884 | 2884 | if (defined('SID') && SID != '') |
| 2885 | 2885 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
| 2886 | - function ($m) use ($scripturl) |
|
| 2886 | + function($m) use ($scripturl) |
|
| 2887 | 2887 | { |
| 2888 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
| 2888 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
| 2889 | 2889 | }, $setLocation); |
| 2890 | 2890 | else |
| 2891 | 2891 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
| 2892 | - function ($m) use ($scripturl) |
|
| 2892 | + function($m) use ($scripturl) |
|
| 2893 | 2893 | { |
| 2894 | 2894 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 2895 | 2895 | }, $setLocation); |
@@ -3212,7 +3212,7 @@ discard block |
||
| 3212 | 3212 | |
| 3213 | 3213 | // Add a generic "Are you sure?" confirmation message. |
| 3214 | 3214 | addInlineJavaScript(' |
| 3215 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
| 3215 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
| 3216 | 3216 | |
| 3217 | 3217 | // Now add the capping code for avatars. |
| 3218 | 3218 | if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
@@ -3573,7 +3573,7 @@ discard block |
||
| 3573 | 3573 | |
| 3574 | 3574 | else |
| 3575 | 3575 | echo ' |
| 3576 | - <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
|
| 3576 | + <script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>'; |
|
| 3577 | 3577 | } |
| 3578 | 3578 | |
| 3579 | 3579 | // Inline JavaScript - Actually useful some times! |
@@ -3651,14 +3651,14 @@ discard block |
||
| 3651 | 3651 | |
| 3652 | 3652 | else |
| 3653 | 3653 | echo ' |
| 3654 | - <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
|
| 3654 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">'; |
|
| 3655 | 3655 | } |
| 3656 | 3656 | |
| 3657 | 3657 | // Print the rest after the minified files. |
| 3658 | 3658 | if (!empty($normal)) |
| 3659 | 3659 | foreach ($normal as $nf) |
| 3660 | 3660 | echo ' |
| 3661 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
| 3661 | + <link rel="stylesheet" href="', $nf, '">'; |
|
| 3662 | 3662 | |
| 3663 | 3663 | if ($db_show_debug === true) |
| 3664 | 3664 | { |
@@ -3674,7 +3674,7 @@ discard block |
||
| 3674 | 3674 | <style>'; |
| 3675 | 3675 | |
| 3676 | 3676 | foreach ($context['css_header'] as $css) |
| 3677 | - echo $css .' |
|
| 3677 | + echo $css . ' |
|
| 3678 | 3678 | '; |
| 3679 | 3679 | |
| 3680 | 3680 | echo' |
@@ -3703,27 +3703,27 @@ discard block |
||
| 3703 | 3703 | return false; |
| 3704 | 3704 | |
| 3705 | 3705 | // Did we already did this? |
| 3706 | - $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
|
| 3706 | + $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400); |
|
| 3707 | 3707 | |
| 3708 | 3708 | // Already done? |
| 3709 | 3709 | if (!empty($toCache)) |
| 3710 | 3710 | return true; |
| 3711 | 3711 | |
| 3712 | 3712 | // No namespaces, sorry! |
| 3713 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
| 3713 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
| 3714 | 3714 | |
| 3715 | 3715 | // Temp path. |
| 3716 | - $cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/'; |
|
| 3716 | + $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
|
| 3717 | 3717 | |
| 3718 | 3718 | // What kind of file are we going to create? |
| 3719 | - $toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type; |
|
| 3719 | + $toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type; |
|
| 3720 | 3720 | |
| 3721 | 3721 | // File has to exists, if it isn't try to create it. |
| 3722 | 3722 | if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate)) |
| 3723 | 3723 | { |
| 3724 | 3724 | loadLanguage('Errors'); |
| 3725 | 3725 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
| 3726 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
| 3726 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
| 3727 | 3727 | |
| 3728 | 3728 | // The process failed so roll back to print each individual file. |
| 3729 | 3729 | return $data; |
@@ -3758,14 +3758,14 @@ discard block |
||
| 3758 | 3758 | { |
| 3759 | 3759 | loadLanguage('Errors'); |
| 3760 | 3760 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
| 3761 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
| 3761 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
| 3762 | 3762 | |
| 3763 | 3763 | // The process failed so roll back to print each individual file. |
| 3764 | 3764 | return $data; |
| 3765 | 3765 | } |
| 3766 | 3766 | |
| 3767 | 3767 | // And create a long lived cache entry. |
| 3768 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400); |
|
| 3768 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400); |
|
| 3769 | 3769 | |
| 3770 | 3770 | return true; |
| 3771 | 3771 | } |
@@ -3825,7 +3825,7 @@ discard block |
||
| 3825 | 3825 | else |
| 3826 | 3826 | $path = $modSettings['attachmentUploadDir']; |
| 3827 | 3827 | |
| 3828 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
| 3828 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
| 3829 | 3829 | } |
| 3830 | 3830 | |
| 3831 | 3831 | /** |
@@ -3869,10 +3869,10 @@ discard block |
||
| 3869 | 3869 | $valid_low = isValidIP($ip_parts[0]); |
| 3870 | 3870 | $valid_high = isValidIP($ip_parts[1]); |
| 3871 | 3871 | $count = 0; |
| 3872 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
| 3872 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
| 3873 | 3873 | $max = ($mode == ':' ? 'ffff' : '255'); |
| 3874 | 3874 | $min = 0; |
| 3875 | - if(!$valid_low) |
|
| 3875 | + if (!$valid_low) |
|
| 3876 | 3876 | { |
| 3877 | 3877 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
| 3878 | 3878 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3886,7 +3886,7 @@ discard block |
||
| 3886 | 3886 | } |
| 3887 | 3887 | |
| 3888 | 3888 | $count = 0; |
| 3889 | - if(!$valid_high) |
|
| 3889 | + if (!$valid_high) |
|
| 3890 | 3890 | { |
| 3891 | 3891 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
| 3892 | 3892 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3899,7 +3899,7 @@ discard block |
||
| 3899 | 3899 | } |
| 3900 | 3900 | } |
| 3901 | 3901 | |
| 3902 | - if($valid_high && $valid_low) |
|
| 3902 | + if ($valid_high && $valid_low) |
|
| 3903 | 3903 | { |
| 3904 | 3904 | $ip_array['low'] = $ip_parts[0]; |
| 3905 | 3905 | $ip_array['high'] = $ip_parts[1]; |
@@ -4081,7 +4081,7 @@ discard block |
||
| 4081 | 4081 | addInlineJavaScript(' |
| 4082 | 4082 | var user_menus = new smc_PopupMenu(); |
| 4083 | 4083 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4084 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
| 4084 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
| 4085 | 4085 | if ($context['allow_pm']) |
| 4086 | 4086 | addInlineJavaScript(' |
| 4087 | 4087 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4701,7 +4701,7 @@ discard block |
||
| 4701 | 4701 | // No? try a fallback to $sourcedir |
| 4702 | 4702 | else |
| 4703 | 4703 | { |
| 4704 | - $absPath = $sourcedir .'/'. $file; |
|
| 4704 | + $absPath = $sourcedir . '/' . $file; |
|
| 4705 | 4705 | |
| 4706 | 4706 | if (file_exists($absPath)) |
| 4707 | 4707 | require_once($absPath); |
@@ -4782,15 +4782,15 @@ discard block |
||
| 4782 | 4782 | |
| 4783 | 4783 | // UTF-8 occurences of MS special characters |
| 4784 | 4784 | $findchars_utf8 = array( |
| 4785 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 4786 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 4787 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
| 4788 | - "\xe2\x80\x98", // left single curly quote |
|
| 4789 | - "\xe2\x80\x99", // right single curly quote |
|
| 4790 | - "\xe2\x80\x9c", // left double curly quote |
|
| 4791 | - "\xe2\x80\x9d", // right double curly quote |
|
| 4792 | - "\xe2\x80\x93", // en dash |
|
| 4793 | - "\xe2\x80\x94", // em dash |
|
| 4785 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 4786 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 4787 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
| 4788 | + "\xe2\x80\x98", // left single curly quote |
|
| 4789 | + "\xe2\x80\x99", // right single curly quote |
|
| 4790 | + "\xe2\x80\x9c", // left double curly quote |
|
| 4791 | + "\xe2\x80\x9d", // right double curly quote |
|
| 4792 | + "\xe2\x80\x93", // en dash |
|
| 4793 | + "\xe2\x80\x94", // em dash |
|
| 4794 | 4794 | ); |
| 4795 | 4795 | |
| 4796 | 4796 | // windows 1252 / iso equivalents |
@@ -4808,15 +4808,15 @@ discard block |
||
| 4808 | 4808 | |
| 4809 | 4809 | // safe replacements |
| 4810 | 4810 | $replacechars = array( |
| 4811 | - ',', // ‚ |
|
| 4812 | - ',,', // „ |
|
| 4813 | - '...', // … |
|
| 4814 | - "'", // ‘ |
|
| 4815 | - "'", // ’ |
|
| 4816 | - '"', // “ |
|
| 4817 | - '"', // ” |
|
| 4818 | - '-', // – |
|
| 4819 | - '--', // — |
|
| 4811 | + ',', // ‚ |
|
| 4812 | + ',,', // „ |
|
| 4813 | + '...', // … |
|
| 4814 | + "'", // ‘ |
|
| 4815 | + "'", // ’ |
|
| 4816 | + '"', // “ |
|
| 4817 | + '"', // ” |
|
| 4818 | + '-', // – |
|
| 4819 | + '--', // — |
|
| 4820 | 4820 | ); |
| 4821 | 4821 | |
| 4822 | 4822 | if ($context['utf8']) |
@@ -5234,7 +5234,7 @@ discard block |
||
| 5234 | 5234 | */ |
| 5235 | 5235 | function inet_dtop($bin) |
| 5236 | 5236 | { |
| 5237 | - if(empty($bin)) |
|
| 5237 | + if (empty($bin)) |
|
| 5238 | 5238 | return ''; |
| 5239 | 5239 | |
| 5240 | 5240 | global $db_type; |
@@ -5265,28 +5265,28 @@ discard block |
||
| 5265 | 5265 | */ |
| 5266 | 5266 | function _safe_serialize($value) |
| 5267 | 5267 | { |
| 5268 | - if(is_null($value)) |
|
| 5268 | + if (is_null($value)) |
|
| 5269 | 5269 | return 'N;'; |
| 5270 | 5270 | |
| 5271 | - if(is_bool($value)) |
|
| 5272 | - return 'b:'. (int) $value .';'; |
|
| 5271 | + if (is_bool($value)) |
|
| 5272 | + return 'b:' . (int) $value . ';'; |
|
| 5273 | 5273 | |
| 5274 | - if(is_int($value)) |
|
| 5275 | - return 'i:'. $value .';'; |
|
| 5274 | + if (is_int($value)) |
|
| 5275 | + return 'i:' . $value . ';'; |
|
| 5276 | 5276 | |
| 5277 | - if(is_float($value)) |
|
| 5278 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5277 | + if (is_float($value)) |
|
| 5278 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
| 5279 | 5279 | |
| 5280 | - if(is_string($value)) |
|
| 5281 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5280 | + if (is_string($value)) |
|
| 5281 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 5282 | 5282 | |
| 5283 | - if(is_array($value)) |
|
| 5283 | + if (is_array($value)) |
|
| 5284 | 5284 | { |
| 5285 | 5285 | $out = ''; |
| 5286 | - foreach($value as $k => $v) |
|
| 5286 | + foreach ($value as $k => $v) |
|
| 5287 | 5287 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 5288 | 5288 | |
| 5289 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
| 5289 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 5290 | 5290 | } |
| 5291 | 5291 | |
| 5292 | 5292 | // safe_serialize cannot serialize resources or objects. |
@@ -5328,7 +5328,7 @@ discard block |
||
| 5328 | 5328 | function _safe_unserialize($str) |
| 5329 | 5329 | { |
| 5330 | 5330 | // Input is not a string. |
| 5331 | - if(empty($str) || !is_string($str)) |
|
| 5331 | + if (empty($str) || !is_string($str)) |
|
| 5332 | 5332 | return false; |
| 5333 | 5333 | |
| 5334 | 5334 | $stack = array(); |
@@ -5342,40 +5342,40 @@ discard block |
||
| 5342 | 5342 | * 3 - in array, expecting value or another array |
| 5343 | 5343 | */ |
| 5344 | 5344 | $state = 0; |
| 5345 | - while($state != 1) |
|
| 5345 | + while ($state != 1) |
|
| 5346 | 5346 | { |
| 5347 | 5347 | $type = isset($str[0]) ? $str[0] : ''; |
| 5348 | - if($type == '}') |
|
| 5348 | + if ($type == '}') |
|
| 5349 | 5349 | $str = substr($str, 1); |
| 5350 | 5350 | |
| 5351 | - else if($type == 'N' && $str[1] == ';') |
|
| 5351 | + else if ($type == 'N' && $str[1] == ';') |
|
| 5352 | 5352 | { |
| 5353 | 5353 | $value = null; |
| 5354 | 5354 | $str = substr($str, 2); |
| 5355 | 5355 | } |
| 5356 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5356 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5357 | 5357 | { |
| 5358 | 5358 | $value = $matches[1] == '1' ? true : false; |
| 5359 | 5359 | $str = substr($str, 4); |
| 5360 | 5360 | } |
| 5361 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5361 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5362 | 5362 | { |
| 5363 | - $value = (int)$matches[1]; |
|
| 5363 | + $value = (int) $matches[1]; |
|
| 5364 | 5364 | $str = $matches[2]; |
| 5365 | 5365 | } |
| 5366 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5366 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5367 | 5367 | { |
| 5368 | - $value = (float)$matches[1]; |
|
| 5368 | + $value = (float) $matches[1]; |
|
| 5369 | 5369 | $str = $matches[3]; |
| 5370 | 5370 | } |
| 5371 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5371 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 5372 | 5372 | { |
| 5373 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 5374 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 5373 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 5374 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 5375 | 5375 | } |
| 5376 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5376 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5377 | 5377 | { |
| 5378 | - $expectedLength = (int)$matches[1]; |
|
| 5378 | + $expectedLength = (int) $matches[1]; |
|
| 5379 | 5379 | $str = $matches[2]; |
| 5380 | 5380 | } |
| 5381 | 5381 | |
@@ -5383,10 +5383,10 @@ discard block |
||
| 5383 | 5383 | else |
| 5384 | 5384 | return false; |
| 5385 | 5385 | |
| 5386 | - switch($state) |
|
| 5386 | + switch ($state) |
|
| 5387 | 5387 | { |
| 5388 | 5388 | case 3: // In array, expecting value or another array. |
| 5389 | - if($type == 'a') |
|
| 5389 | + if ($type == 'a') |
|
| 5390 | 5390 | { |
| 5391 | 5391 | $stack[] = &$list; |
| 5392 | 5392 | $list[$key] = array(); |
@@ -5395,7 +5395,7 @@ discard block |
||
| 5395 | 5395 | $state = 2; |
| 5396 | 5396 | break; |
| 5397 | 5397 | } |
| 5398 | - if($type != '}') |
|
| 5398 | + if ($type != '}') |
|
| 5399 | 5399 | { |
| 5400 | 5400 | $list[$key] = $value; |
| 5401 | 5401 | $state = 2; |
@@ -5406,29 +5406,29 @@ discard block |
||
| 5406 | 5406 | return false; |
| 5407 | 5407 | |
| 5408 | 5408 | case 2: // in array, expecting end of array or a key |
| 5409 | - if($type == '}') |
|
| 5409 | + if ($type == '}') |
|
| 5410 | 5410 | { |
| 5411 | 5411 | // Array size is less than expected. |
| 5412 | - if(count($list) < end($expected)) |
|
| 5412 | + if (count($list) < end($expected)) |
|
| 5413 | 5413 | return false; |
| 5414 | 5414 | |
| 5415 | 5415 | unset($list); |
| 5416 | - $list = &$stack[count($stack)-1]; |
|
| 5416 | + $list = &$stack[count($stack) - 1]; |
|
| 5417 | 5417 | array_pop($stack); |
| 5418 | 5418 | |
| 5419 | 5419 | // Go to terminal state if we're at the end of the root array. |
| 5420 | 5420 | array_pop($expected); |
| 5421 | 5421 | |
| 5422 | - if(count($expected) == 0) |
|
| 5422 | + if (count($expected) == 0) |
|
| 5423 | 5423 | $state = 1; |
| 5424 | 5424 | |
| 5425 | 5425 | break; |
| 5426 | 5426 | } |
| 5427 | 5427 | |
| 5428 | - if($type == 'i' || $type == 's') |
|
| 5428 | + if ($type == 'i' || $type == 's') |
|
| 5429 | 5429 | { |
| 5430 | 5430 | // Array size exceeds expected length. |
| 5431 | - if(count($list) >= end($expected)) |
|
| 5431 | + if (count($list) >= end($expected)) |
|
| 5432 | 5432 | return false; |
| 5433 | 5433 | |
| 5434 | 5434 | $key = $value; |
@@ -5441,7 +5441,7 @@ discard block |
||
| 5441 | 5441 | |
| 5442 | 5442 | // Expecting array or value. |
| 5443 | 5443 | case 0: |
| 5444 | - if($type == 'a') |
|
| 5444 | + if ($type == 'a') |
|
| 5445 | 5445 | { |
| 5446 | 5446 | $data = array(); |
| 5447 | 5447 | $list = &$data; |
@@ -5450,7 +5450,7 @@ discard block |
||
| 5450 | 5450 | break; |
| 5451 | 5451 | } |
| 5452 | 5452 | |
| 5453 | - if($type != '}') |
|
| 5453 | + if ($type != '}') |
|
| 5454 | 5454 | { |
| 5455 | 5455 | $data = $value; |
| 5456 | 5456 | $state = 1; |
@@ -5463,7 +5463,7 @@ discard block |
||
| 5463 | 5463 | } |
| 5464 | 5464 | |
| 5465 | 5465 | // Trailing data in input. |
| 5466 | - if(!empty($str)) |
|
| 5466 | + if (!empty($str)) |
|
| 5467 | 5467 | return false; |
| 5468 | 5468 | |
| 5469 | 5469 | return $data; |
@@ -5517,7 +5517,7 @@ discard block |
||
| 5517 | 5517 | // Set different modes. |
| 5518 | 5518 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
| 5519 | 5519 | |
| 5520 | - foreach($chmodValues as $val) |
|
| 5520 | + foreach ($chmodValues as $val) |
|
| 5521 | 5521 | { |
| 5522 | 5522 | // If it's writable, break out of the loop. |
| 5523 | 5523 | if (is_writable($file)) |
@@ -5552,13 +5552,13 @@ discard block |
||
| 5552 | 5552 | $returnArray = @json_decode($json, $returnAsArray); |
| 5553 | 5553 | |
| 5554 | 5554 | // PHP 5.3 so no json_last_error_msg() |
| 5555 | - switch(json_last_error()) |
|
| 5555 | + switch (json_last_error()) |
|
| 5556 | 5556 | { |
| 5557 | 5557 | case JSON_ERROR_NONE: |
| 5558 | 5558 | $jsonError = false; |
| 5559 | 5559 | break; |
| 5560 | 5560 | case JSON_ERROR_DEPTH: |
| 5561 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5561 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5562 | 5562 | break; |
| 5563 | 5563 | case JSON_ERROR_STATE_MISMATCH: |
| 5564 | 5564 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5586,10 +5586,10 @@ discard block |
||
| 5586 | 5586 | loadLanguage('Errors'); |
| 5587 | 5587 | |
| 5588 | 5588 | if (!empty($jsonDebug)) |
| 5589 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5589 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5590 | 5590 | |
| 5591 | 5591 | else |
| 5592 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5592 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
| 5593 | 5593 | |
| 5594 | 5594 | // Everyone expects an array. |
| 5595 | 5595 | return array(); |
@@ -5701,7 +5701,7 @@ discard block |
||
| 5701 | 5701 | }); |
| 5702 | 5702 | |
| 5703 | 5703 | // Convert Punycode to Unicode |
| 5704 | - $tlds = array_map(function ($input) { |
|
| 5704 | + $tlds = array_map(function($input) { |
|
| 5705 | 5705 | $prefix = 'xn--'; |
| 5706 | 5706 | $safe_char = 0xFFFC; |
| 5707 | 5707 | $base = 36; |
@@ -5717,7 +5717,7 @@ discard block |
||
| 5717 | 5717 | |
| 5718 | 5718 | foreach ($enco_parts as $encoded) |
| 5719 | 5719 | { |
| 5720 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
| 5720 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
| 5721 | 5721 | { |
| 5722 | 5722 | $output_parts[] = $encoded; |
| 5723 | 5723 | continue; |
@@ -5728,7 +5728,7 @@ discard block |
||
| 5728 | 5728 | $idx = 0; |
| 5729 | 5729 | $char = 0x80; |
| 5730 | 5730 | $decoded = array(); |
| 5731 | - $output=''; |
|
| 5731 | + $output = ''; |
|
| 5732 | 5732 | $delim_pos = strrpos($encoded, '-'); |
| 5733 | 5733 | |
| 5734 | 5734 | if ($delim_pos > strlen($prefix)) |
@@ -5744,7 +5744,7 @@ discard block |
||
| 5744 | 5744 | |
| 5745 | 5745 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
| 5746 | 5746 | { |
| 5747 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
| 5747 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
| 5748 | 5748 | { |
| 5749 | 5749 | $cp = ord($encoded{$enco_idx++}); |
| 5750 | 5750 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5785,15 +5785,15 @@ discard block |
||
| 5785 | 5785 | |
| 5786 | 5786 | // 2 bytes |
| 5787 | 5787 | elseif ($v < (1 << 11)) |
| 5788 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 5788 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
| 5789 | 5789 | |
| 5790 | 5790 | // 3 bytes |
| 5791 | 5791 | elseif ($v < (1 << 16)) |
| 5792 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5792 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 5793 | 5793 | |
| 5794 | 5794 | // 4 bytes |
| 5795 | 5795 | elseif ($v < (1 << 21)) |
| 5796 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5796 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 5797 | 5797 | |
| 5798 | 5798 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5799 | 5799 | else |
@@ -5898,7 +5898,7 @@ discard block |
||
| 5898 | 5898 | } |
| 5899 | 5899 | |
| 5900 | 5900 | // This recursive function creates the index array from the strings |
| 5901 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 5901 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 5902 | 5902 | { |
| 5903 | 5903 | static $depth = 0; |
| 5904 | 5904 | $depth++; |
@@ -5925,7 +5925,7 @@ discard block |
||
| 5925 | 5925 | }; |
| 5926 | 5926 | |
| 5927 | 5927 | // This recursive function turns the index array into a regular expression |
| 5928 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 5928 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 5929 | 5929 | { |
| 5930 | 5930 | static $depth = 0; |
| 5931 | 5931 | $depth++; |
@@ -5949,11 +5949,11 @@ discard block |
||
| 5949 | 5949 | |
| 5950 | 5950 | if (count(array_keys($value)) == 1) |
| 5951 | 5951 | { |
| 5952 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
| 5952 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
| 5953 | 5953 | $new_key .= $new_key_array[0]; |
| 5954 | 5954 | } |
| 5955 | 5955 | else |
| 5956 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5956 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
| 5957 | 5957 | } |
| 5958 | 5958 | |
| 5959 | 5959 | if ($depth > 1) |
@@ -5996,10 +5996,10 @@ discard block |
||
| 5996 | 5996 | { |
| 5997 | 5997 | $regex = array(); |
| 5998 | 5998 | while (!empty($index)) |
| 5999 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 5999 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6000 | 6000 | } |
| 6001 | 6001 | else |
| 6002 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6002 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6003 | 6003 | |
| 6004 | 6004 | // Restore PHP's internal character encoding to whatever it was originally |
| 6005 | 6005 | if (!empty($current_encoding)) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
| 122 | 123 | $smcFunc['db_free_result']($result); |
| 123 | 124 | |
| 124 | 125 | // Add this to the number of unapproved members |
| 125 | - if (!empty($changes['unapprovedMembers'])) |
|
| 126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 127 | - else |
|
| 128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 126 | + if (!empty($changes['unapprovedMembers'])) { |
|
| 127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 128 | + } else { |
|
| 129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 130 | + } |
|
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
| 133 | 135 | break; |
| 134 | 136 | |
| 135 | 137 | case 'message': |
| 136 | - if ($parameter1 === true && $parameter2 !== null) |
|
| 137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 138 | - else |
|
| 138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
| 139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
| 141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
| 175 | 177 | $parameter2 = text2words($parameter2); |
| 176 | 178 | |
| 177 | 179 | $inserts = array(); |
| 178 | - foreach ($parameter2 as $word) |
|
| 179 | - $inserts[] = array($word, $parameter1); |
|
| 180 | + foreach ($parameter2 as $word) { |
|
| 181 | + $inserts[] = array($word, $parameter1); |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | - if (!empty($inserts)) |
|
| 182 | - $smcFunc['db_insert']('ignore', |
|
| 184 | + if (!empty($inserts)) { |
|
| 185 | + $smcFunc['db_insert']('ignore', |
|
| 183 | 186 | '{db_prefix}log_search_subjects', |
| 184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
| 185 | 188 | $inserts, |
| 186 | 189 | array('word', 'id_topic') |
| 187 | 190 | ); |
| 191 | + } |
|
| 188 | 192 | } |
| 189 | 193 | break; |
| 190 | 194 | |
| 191 | 195 | case 'topic': |
| 192 | - if ($parameter1 === true) |
|
| 193 | - updateSettings(array('totalTopics' => true), true); |
|
| 194 | - else |
|
| 196 | + if ($parameter1 === true) { |
|
| 197 | + updateSettings(array('totalTopics' => true), true); |
|
| 198 | + } else |
|
| 195 | 199 | { |
| 196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
| 197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
| 212 | 216 | |
| 213 | 217 | case 'postgroups': |
| 214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
| 215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
| 216 | - return; |
|
| 219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 217 | 222 | |
| 218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
| 219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
| 228 | 233 | ) |
| 229 | 234 | ); |
| 230 | 235 | $postgroups = array(); |
| 231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 238 | + } |
|
| 233 | 239 | $smcFunc['db_free_result']($request); |
| 234 | 240 | |
| 235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // Oh great, they've screwed their post groups. |
| 242 | - if (empty($postgroups)) |
|
| 243 | - return; |
|
| 248 | + if (empty($postgroups)) { |
|
| 249 | + return; |
|
| 250 | + } |
|
| 244 | 251 | |
| 245 | 252 | // Set all membergroups from most posts to least posts. |
| 246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
| 298 | 305 | { |
| 299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
| 300 | 307 | $parameters['members'] = $members; |
| 301 | - } |
|
| 302 | - elseif ($members === null) |
|
| 303 | - $condition = '1=1'; |
|
| 304 | - else |
|
| 308 | + } elseif ($members === null) { |
|
| 309 | + $condition = '1=1'; |
|
| 310 | + } else |
|
| 305 | 311 | { |
| 306 | 312 | $condition = 'id_member = {int:member}'; |
| 307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
| 341 | 347 | if (count($vars_to_integrate) != 0) |
| 342 | 348 | { |
| 343 | 349 | // Fetch a list of member_names if necessary |
| 344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
| 345 | - $member_names = array($user_info['username']); |
|
| 346 | - else |
|
| 350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
| 351 | + $member_names = array($user_info['username']); |
|
| 352 | + } else |
|
| 347 | 353 | { |
| 348 | 354 | $member_names = array(); |
| 349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
| 352 | 358 | WHERE ' . $condition, |
| 353 | 359 | $parameters |
| 354 | 360 | ); |
| 355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 356 | - $member_names[] = $row['member_name']; |
|
| 361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 362 | + $member_names[] = $row['member_name']; |
|
| 363 | + } |
|
| 357 | 364 | $smcFunc['db_free_result']($request); |
| 358 | 365 | } |
| 359 | 366 | |
| 360 | - if (!empty($member_names)) |
|
| 361 | - foreach ($vars_to_integrate as $var) |
|
| 367 | + if (!empty($member_names)) { |
|
| 368 | + foreach ($vars_to_integrate as $var) |
|
| 362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
| 370 | + } |
|
| 363 | 371 | } |
| 364 | 372 | } |
| 365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
| 367 | 375 | foreach ($data as $var => $val) |
| 368 | 376 | { |
| 369 | 377 | $type = 'string'; |
| 370 | - if (in_array($var, $knownInts)) |
|
| 371 | - $type = 'int'; |
|
| 372 | - elseif (in_array($var, $knownFloats)) |
|
| 373 | - $type = 'float'; |
|
| 374 | - elseif ($var == 'birthdate') |
|
| 375 | - $type = 'date'; |
|
| 376 | - elseif ($var == 'member_ip') |
|
| 377 | - $type = 'inet'; |
|
| 378 | - elseif ($var == 'member_ip2') |
|
| 379 | - $type = 'inet'; |
|
| 378 | + if (in_array($var, $knownInts)) { |
|
| 379 | + $type = 'int'; |
|
| 380 | + } elseif (in_array($var, $knownFloats)) { |
|
| 381 | + $type = 'float'; |
|
| 382 | + } elseif ($var == 'birthdate') { |
|
| 383 | + $type = 'date'; |
|
| 384 | + } elseif ($var == 'member_ip') { |
|
| 385 | + $type = 'inet'; |
|
| 386 | + } elseif ($var == 'member_ip2') { |
|
| 387 | + $type = 'inet'; |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | // Doing an increment? |
| 382 | 391 | if ($var == 'alerts' && ($val === '+' || $val === '-')) |
@@ -385,18 +394,17 @@ discard block |
||
| 385 | 394 | if (is_array($members)) |
| 386 | 395 | { |
| 387 | 396 | $val = 'CASE '; |
| 388 | - foreach ($members as $k => $v) |
|
| 389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 397 | + foreach ($members as $k => $v) { |
|
| 398 | + $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 399 | + } |
|
| 390 | 400 | $val = $val . ' END'; |
| 391 | 401 | $type = 'raw'; |
| 392 | - } |
|
| 393 | - else |
|
| 402 | + } else |
|
| 394 | 403 | { |
| 395 | 404 | $blub = fetch_alerts($members, false, 0, array(), false); |
| 396 | 405 | $val = count($blub); |
| 397 | 406 | } |
| 398 | - } |
|
| 399 | - else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 407 | + } else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 400 | 408 | { |
| 401 | 409 | $val = $var . ' ' . $val . ' 1'; |
| 402 | 410 | $type = 'raw'; |
@@ -407,8 +415,9 @@ discard block |
||
| 407 | 415 | { |
| 408 | 416 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 409 | 417 | { |
| 410 | - if ($match[1] != '+ ') |
|
| 411 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 418 | + if ($match[1] != '+ ') { |
|
| 419 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 420 | + } |
|
| 412 | 421 | $type = 'raw'; |
| 413 | 422 | } |
| 414 | 423 | } |
@@ -429,8 +438,9 @@ discard block |
||
| 429 | 438 | // Clear any caching? |
| 430 | 439 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 431 | 440 | { |
| 432 | - if (!is_array($members)) |
|
| 433 | - $members = array($members); |
|
| 441 | + if (!is_array($members)) { |
|
| 442 | + $members = array($members); |
|
| 443 | + } |
|
| 434 | 444 | |
| 435 | 445 | foreach ($members as $member) |
| 436 | 446 | { |
@@ -463,29 +473,32 @@ discard block |
||
| 463 | 473 | { |
| 464 | 474 | global $modSettings, $smcFunc; |
| 465 | 475 | |
| 466 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 467 | - return; |
|
| 476 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 477 | + return; |
|
| 478 | + } |
|
| 468 | 479 | |
| 469 | 480 | $toRemove = array(); |
| 470 | 481 | |
| 471 | 482 | // Go check if there is any setting to be removed. |
| 472 | - foreach ($changeArray as $k => $v) |
|
| 473 | - if ($v === null) |
|
| 483 | + foreach ($changeArray as $k => $v) { |
|
| 484 | + if ($v === null) |
|
| 474 | 485 | { |
| 475 | 486 | // Found some, remove them from the original array and add them to ours. |
| 476 | 487 | unset($changeArray[$k]); |
| 488 | + } |
|
| 477 | 489 | $toRemove[] = $k; |
| 478 | 490 | } |
| 479 | 491 | |
| 480 | 492 | // Proceed with the deletion. |
| 481 | - if (!empty($toRemove)) |
|
| 482 | - $smcFunc['db_query']('', ' |
|
| 493 | + if (!empty($toRemove)) { |
|
| 494 | + $smcFunc['db_query']('', ' |
|
| 483 | 495 | DELETE FROM {db_prefix}settings |
| 484 | 496 | WHERE variable IN ({array_string:remove})', |
| 485 | 497 | array( |
| 486 | 498 | 'remove' => $toRemove, |
| 487 | 499 | ) |
| 488 | 500 | ); |
| 501 | + } |
|
| 489 | 502 | |
| 490 | 503 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 491 | 504 | if ($update) |
@@ -514,19 +527,22 @@ discard block |
||
| 514 | 527 | foreach ($changeArray as $variable => $value) |
| 515 | 528 | { |
| 516 | 529 | // Don't bother if it's already like that ;). |
| 517 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 518 | - continue; |
|
| 530 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 531 | + continue; |
|
| 532 | + } |
|
| 519 | 533 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 520 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 521 | - continue; |
|
| 534 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 535 | + continue; |
|
| 536 | + } |
|
| 522 | 537 | |
| 523 | 538 | $replaceArray[] = array($variable, $value); |
| 524 | 539 | |
| 525 | 540 | $modSettings[$variable] = $value; |
| 526 | 541 | } |
| 527 | 542 | |
| 528 | - if (empty($replaceArray)) |
|
| 529 | - return; |
|
| 543 | + if (empty($replaceArray)) { |
|
| 544 | + return; |
|
| 545 | + } |
|
| 530 | 546 | |
| 531 | 547 | $smcFunc['db_insert']('replace', |
| 532 | 548 | '{db_prefix}settings', |
@@ -572,14 +588,17 @@ discard block |
||
| 572 | 588 | $start_invalid = $start < 0; |
| 573 | 589 | |
| 574 | 590 | // Make sure $start is a proper variable - not less than 0. |
| 575 | - if ($start_invalid) |
|
| 576 | - $start = 0; |
|
| 591 | + if ($start_invalid) { |
|
| 592 | + $start = 0; |
|
| 593 | + } |
|
| 577 | 594 | // Not greater than the upper bound. |
| 578 | - elseif ($start >= $max_value) |
|
| 579 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 595 | + elseif ($start >= $max_value) { |
|
| 596 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 597 | + } |
|
| 580 | 598 | // And it has to be a multiple of $num_per_page! |
| 581 | - else |
|
| 582 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 599 | + else { |
|
| 600 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 601 | + } |
|
| 583 | 602 | |
| 584 | 603 | $context['current_page'] = $start / $num_per_page; |
| 585 | 604 | |
@@ -609,77 +628,87 @@ discard block |
||
| 609 | 628 | |
| 610 | 629 | // Show all the pages. |
| 611 | 630 | $display_page = 1; |
| 612 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 613 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 631 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 632 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 633 | + } |
|
| 614 | 634 | |
| 615 | 635 | // Show the right arrow. |
| 616 | 636 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 617 | - if ($start != $counter - $max_value && !$start_invalid) |
|
| 618 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 619 | - } |
|
| 620 | - else |
|
| 637 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
| 638 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 639 | + } |
|
| 640 | + } else |
|
| 621 | 641 | { |
| 622 | 642 | // If they didn't enter an odd value, pretend they did. |
| 623 | 643 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 624 | 644 | |
| 625 | 645 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 626 | - if (!empty($start) && $show_prevnext) |
|
| 627 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 628 | - else |
|
| 629 | - $pageindex .= ''; |
|
| 646 | + if (!empty($start) && $show_prevnext) { |
|
| 647 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 648 | + } else { |
|
| 649 | + $pageindex .= ''; |
|
| 650 | + } |
|
| 630 | 651 | |
| 631 | 652 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 632 | - if ($start > $num_per_page * $PageContiguous) |
|
| 633 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 653 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 654 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 655 | + } |
|
| 634 | 656 | |
| 635 | 657 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 636 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 637 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 658 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 659 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 638 | 660 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 639 | 661 | '{FIRST_PAGE}' => $num_per_page, |
| 640 | 662 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 641 | 663 | '{PER_PAGE}' => $num_per_page, |
| 642 | 664 | )); |
| 665 | + } |
|
| 643 | 666 | |
| 644 | 667 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 645 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 646 | - if ($start >= $num_per_page * $nCont) |
|
| 668 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 669 | + if ($start >= $num_per_page * $nCont) |
|
| 647 | 670 | { |
| 648 | 671 | $tmpStart = $start - $num_per_page * $nCont; |
| 672 | + } |
|
| 649 | 673 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 650 | 674 | } |
| 651 | 675 | |
| 652 | 676 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 653 | - if (!$start_invalid) |
|
| 654 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 655 | - else |
|
| 656 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 677 | + if (!$start_invalid) { |
|
| 678 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 679 | + } else { |
|
| 680 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 681 | + } |
|
| 657 | 682 | |
| 658 | 683 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 659 | 684 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 660 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 661 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 685 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 686 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 662 | 687 | { |
| 663 | 688 | $tmpStart = $start + $num_per_page * $nCont; |
| 689 | + } |
|
| 664 | 690 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 665 | 691 | } |
| 666 | 692 | |
| 667 | 693 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 668 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 669 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 694 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 695 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 670 | 696 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 671 | 697 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 672 | 698 | '{LAST_PAGE}' => $tmpMaxPages, |
| 673 | 699 | '{PER_PAGE}' => $num_per_page, |
| 674 | 700 | )); |
| 701 | + } |
|
| 675 | 702 | |
| 676 | 703 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 677 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 678 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 704 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 705 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 706 | + } |
|
| 679 | 707 | |
| 680 | 708 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 681 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 682 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 709 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 710 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 711 | + } |
|
| 683 | 712 | } |
| 684 | 713 | $pageindex .= $settings['page_index']['extra_after']; |
| 685 | 714 | |
@@ -705,8 +734,9 @@ discard block |
||
| 705 | 734 | if ($decimal_separator === null) |
| 706 | 735 | { |
| 707 | 736 | // Not set for whatever reason? |
| 708 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 709 | - return $number; |
|
| 737 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 738 | + return $number; |
|
| 739 | + } |
|
| 710 | 740 | |
| 711 | 741 | // Cache these each load... |
| 712 | 742 | $thousands_separator = $matches[1]; |
@@ -740,17 +770,20 @@ discard block |
||
| 740 | 770 | static $unsupportedFormats, $finalizedFormats; |
| 741 | 771 | |
| 742 | 772 | // Offset the time. |
| 743 | - if (!$offset_type) |
|
| 744 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 773 | + if (!$offset_type) { |
|
| 774 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 775 | + } |
|
| 745 | 776 | // Just the forum offset? |
| 746 | - elseif ($offset_type == 'forum') |
|
| 747 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 748 | - else |
|
| 749 | - $time = $log_time; |
|
| 777 | + elseif ($offset_type == 'forum') { |
|
| 778 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 779 | + } else { |
|
| 780 | + $time = $log_time; |
|
| 781 | + } |
|
| 750 | 782 | |
| 751 | 783 | // We can't have a negative date (on Windows, at least.) |
| 752 | - if ($log_time < 0) |
|
| 753 | - $log_time = 0; |
|
| 784 | + if ($log_time < 0) { |
|
| 785 | + $log_time = 0; |
|
| 786 | + } |
|
| 754 | 787 | |
| 755 | 788 | // Today and Yesterday? |
| 756 | 789 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -767,24 +800,27 @@ discard block |
||
| 767 | 800 | { |
| 768 | 801 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 769 | 802 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 803 | + } else { |
|
| 804 | + $today_fmt = '%H:%M' . $s; |
|
| 770 | 805 | } |
| 771 | - else |
|
| 772 | - $today_fmt = '%H:%M' . $s; |
|
| 773 | 806 | |
| 774 | 807 | // Same day of the year, same year.... Today! |
| 775 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 776 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 808 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 809 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 810 | + } |
|
| 777 | 811 | |
| 778 | 812 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
| 779 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
| 780 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 813 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
| 814 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 815 | + } |
|
| 781 | 816 | } |
| 782 | 817 | |
| 783 | 818 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 784 | 819 | |
| 785 | 820 | // Use the cached formats if available |
| 786 | - if (is_null($finalizedFormats)) |
|
| 787 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 821 | + if (is_null($finalizedFormats)) { |
|
| 822 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 823 | + } |
|
| 788 | 824 | |
| 789 | 825 | // Make a supported version for this format if we don't already have one |
| 790 | 826 | if (empty($finalizedFormats[$str])) |
@@ -813,8 +849,9 @@ discard block |
||
| 813 | 849 | ); |
| 814 | 850 | |
| 815 | 851 | // No need to do this part again if we already did it once |
| 816 | - if (is_null($unsupportedFormats)) |
|
| 817 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 852 | + if (is_null($unsupportedFormats)) { |
|
| 853 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 854 | + } |
|
| 818 | 855 | if (empty($unsupportedFormats)) |
| 819 | 856 | { |
| 820 | 857 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -823,20 +860,23 @@ discard block |
||
| 823 | 860 | |
| 824 | 861 | // Windows will return false for unsupported formats |
| 825 | 862 | // Other operating systems return the format string as a literal |
| 826 | - if ($value === false || $value === $format) |
|
| 827 | - $unsupportedFormats[] = $format; |
|
| 863 | + if ($value === false || $value === $format) { |
|
| 864 | + $unsupportedFormats[] = $format; |
|
| 865 | + } |
|
| 828 | 866 | } |
| 829 | 867 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
| 830 | 868 | } |
| 831 | 869 | |
| 832 | 870 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
| 833 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
| 834 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 871 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
| 872 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 873 | + } |
|
| 835 | 874 | |
| 836 | 875 | // Substitute unsupported formats with supported ones |
| 837 | - if (!empty($unsupportedFormats)) |
|
| 838 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 876 | + if (!empty($unsupportedFormats)) { |
|
| 877 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 839 | 878 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
| 879 | + } |
|
| 840 | 880 | |
| 841 | 881 | // Remember this so we don't need to do it again |
| 842 | 882 | $finalizedFormats[$str] = $timeformat; |
@@ -845,33 +885,39 @@ discard block |
||
| 845 | 885 | |
| 846 | 886 | $str = $finalizedFormats[$str]; |
| 847 | 887 | |
| 848 | - if (!isset($locale_cache)) |
|
| 849 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
| 888 | + if (!isset($locale_cache)) { |
|
| 889 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
| 890 | + } |
|
| 850 | 891 | |
| 851 | 892 | if ($locale_cache !== false) |
| 852 | 893 | { |
| 853 | 894 | // Check if another process changed the locale |
| 854 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
| 855 | - setlocale(LC_TIME, $txt['lang_locale']); |
|
| 895 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
| 896 | + setlocale(LC_TIME, $txt['lang_locale']); |
|
| 897 | + } |
|
| 856 | 898 | |
| 857 | - if (!isset($non_twelve_hour)) |
|
| 858 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 859 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 860 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 899 | + if (!isset($non_twelve_hour)) { |
|
| 900 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 901 | + } |
|
| 902 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 903 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 904 | + } |
|
| 861 | 905 | |
| 862 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 863 | - if (strpos($str, $token) !== false) |
|
| 906 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 907 | + if (strpos($str, $token) !== false) |
|
| 864 | 908 | $str = str_replace($token, strftime($token, $time), $str); |
| 865 | - } |
|
| 866 | - else |
|
| 909 | + } |
|
| 910 | + } else |
|
| 867 | 911 | { |
| 868 | 912 | // Do-it-yourself time localization. Fun. |
| 869 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 870 | - if (strpos($str, $token) !== false) |
|
| 913 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 914 | + if (strpos($str, $token) !== false) |
|
| 871 | 915 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 916 | + } |
|
| 872 | 917 | |
| 873 | - if (strpos($str, '%p') !== false) |
|
| 874 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 918 | + if (strpos($str, '%p') !== false) { |
|
| 919 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 920 | + } |
|
| 875 | 921 | } |
| 876 | 922 | |
| 877 | 923 | // Format the time and then restore any literal percent characters |
@@ -894,16 +940,19 @@ discard block |
||
| 894 | 940 | static $translation = array(); |
| 895 | 941 | |
| 896 | 942 | // Determine the character set... Default to UTF-8 |
| 897 | - if (empty($context['character_set'])) |
|
| 898 | - $charset = 'UTF-8'; |
|
| 943 | + if (empty($context['character_set'])) { |
|
| 944 | + $charset = 'UTF-8'; |
|
| 945 | + } |
|
| 899 | 946 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 900 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 901 | - $charset = 'ISO-8859-1'; |
|
| 902 | - else |
|
| 903 | - $charset = $context['character_set']; |
|
| 947 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 948 | + $charset = 'ISO-8859-1'; |
|
| 949 | + } else { |
|
| 950 | + $charset = $context['character_set']; |
|
| 951 | + } |
|
| 904 | 952 | |
| 905 | - if (empty($translation)) |
|
| 906 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 953 | + if (empty($translation)) { |
|
| 954 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 955 | + } |
|
| 907 | 956 | |
| 908 | 957 | return strtr($string, $translation); |
| 909 | 958 | } |
@@ -925,8 +974,9 @@ discard block |
||
| 925 | 974 | global $smcFunc; |
| 926 | 975 | |
| 927 | 976 | // It was already short enough! |
| 928 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 929 | - return $subject; |
|
| 977 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 978 | + return $subject; |
|
| 979 | + } |
|
| 930 | 980 | |
| 931 | 981 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 932 | 982 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -945,10 +995,11 @@ discard block |
||
| 945 | 995 | { |
| 946 | 996 | global $user_info, $modSettings; |
| 947 | 997 | |
| 948 | - if ($timestamp === null) |
|
| 949 | - $timestamp = time(); |
|
| 950 | - elseif ($timestamp == 0) |
|
| 951 | - return 0; |
|
| 998 | + if ($timestamp === null) { |
|
| 999 | + $timestamp = time(); |
|
| 1000 | + } elseif ($timestamp == 0) { |
|
| 1001 | + return 0; |
|
| 1002 | + } |
|
| 952 | 1003 | |
| 953 | 1004 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 954 | 1005 | } |
@@ -977,8 +1028,9 @@ discard block |
||
| 977 | 1028 | $array[$i] = $array[$j]; |
| 978 | 1029 | $array[$j] = $temp; |
| 979 | 1030 | |
| 980 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 981 | - $p[$i] = 1; |
|
| 1031 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 1032 | + $p[$i] = 1; |
|
| 1033 | + } |
|
| 982 | 1034 | |
| 983 | 1035 | $orders[] = $array; |
| 984 | 1036 | } |
@@ -1010,12 +1062,14 @@ discard block |
||
| 1010 | 1062 | static $disabled; |
| 1011 | 1063 | |
| 1012 | 1064 | // Don't waste cycles |
| 1013 | - if ($message === '') |
|
| 1014 | - return ''; |
|
| 1065 | + if ($message === '') { |
|
| 1066 | + return ''; |
|
| 1067 | + } |
|
| 1015 | 1068 | |
| 1016 | 1069 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 1017 | - if (!isset($context['utf8'])) |
|
| 1018 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1070 | + if (!isset($context['utf8'])) { |
|
| 1071 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1072 | + } |
|
| 1019 | 1073 | |
| 1020 | 1074 | // Clean up any cut/paste issues we may have |
| 1021 | 1075 | $message = sanitizeMSCutPaste($message); |
@@ -1027,13 +1081,15 @@ discard block |
||
| 1027 | 1081 | return $message; |
| 1028 | 1082 | } |
| 1029 | 1083 | |
| 1030 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 1031 | - $smileys = (bool) $smileys; |
|
| 1084 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 1085 | + $smileys = (bool) $smileys; |
|
| 1086 | + } |
|
| 1032 | 1087 | |
| 1033 | 1088 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 1034 | 1089 | { |
| 1035 | - if ($smileys === true) |
|
| 1036 | - parsesmileys($message); |
|
| 1090 | + if ($smileys === true) { |
|
| 1091 | + parsesmileys($message); |
|
| 1092 | + } |
|
| 1037 | 1093 | |
| 1038 | 1094 | return $message; |
| 1039 | 1095 | } |
@@ -1046,8 +1102,9 @@ discard block |
||
| 1046 | 1102 | } |
| 1047 | 1103 | |
| 1048 | 1104 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 1049 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 1050 | - set_tld_regex(); |
|
| 1105 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1106 | + set_tld_regex(); |
|
| 1107 | + } |
|
| 1051 | 1108 | |
| 1052 | 1109 | // Allow mods access before entering the main parse_bbc loop |
| 1053 | 1110 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1061,12 +1118,14 @@ discard block |
||
| 1061 | 1118 | |
| 1062 | 1119 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 1063 | 1120 | |
| 1064 | - foreach ($temp as $tag) |
|
| 1065 | - $disabled[trim($tag)] = true; |
|
| 1121 | + foreach ($temp as $tag) { |
|
| 1122 | + $disabled[trim($tag)] = true; |
|
| 1123 | + } |
|
| 1066 | 1124 | } |
| 1067 | 1125 | |
| 1068 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1069 | - $disabled['flash'] = true; |
|
| 1126 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1127 | + $disabled['flash'] = true; |
|
| 1128 | + } |
|
| 1070 | 1129 | |
| 1071 | 1130 | /* The following bbc are formatted as an array, with keys as follows: |
| 1072 | 1131 | |
@@ -1187,8 +1246,9 @@ discard block |
||
| 1187 | 1246 | $returnContext = ''; |
| 1188 | 1247 | |
| 1189 | 1248 | // BBC or the entire attachments feature is disabled |
| 1190 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1191 | - return $data; |
|
| 1249 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1250 | + return $data; |
|
| 1251 | + } |
|
| 1192 | 1252 | |
| 1193 | 1253 | // Save the attach ID. |
| 1194 | 1254 | $attachID = $data; |
@@ -1199,8 +1259,9 @@ discard block |
||
| 1199 | 1259 | $currentAttachment = parseAttachBBC($attachID); |
| 1200 | 1260 | |
| 1201 | 1261 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
| 1202 | - if (is_string($currentAttachment)) |
|
| 1203 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1262 | + if (is_string($currentAttachment)) { |
|
| 1263 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1264 | + } |
|
| 1204 | 1265 | |
| 1205 | 1266 | if (!empty($currentAttachment['is_image'])) |
| 1206 | 1267 | { |
@@ -1216,15 +1277,17 @@ discard block |
||
| 1216 | 1277 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1217 | 1278 | } |
| 1218 | 1279 | |
| 1219 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1220 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1221 | - else |
|
| 1222 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1280 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1281 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1282 | + } else { |
|
| 1283 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1284 | + } |
|
| 1223 | 1285 | } |
| 1224 | 1286 | |
| 1225 | 1287 | // No image. Show a link. |
| 1226 | - else |
|
| 1227 | - $returnContext .= $currentAttachment['link']; |
|
| 1288 | + else { |
|
| 1289 | + $returnContext .= $currentAttachment['link']; |
|
| 1290 | + } |
|
| 1228 | 1291 | |
| 1229 | 1292 | // Gotta append what we just did. |
| 1230 | 1293 | $data = $returnContext; |
@@ -1255,8 +1318,9 @@ discard block |
||
| 1255 | 1318 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1256 | 1319 | { |
| 1257 | 1320 | // Do PHP code coloring? |
| 1258 | - if ($php_parts[$php_i] != '<?php') |
|
| 1259 | - continue; |
|
| 1321 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1322 | + continue; |
|
| 1323 | + } |
|
| 1260 | 1324 | |
| 1261 | 1325 | $php_string = ''; |
| 1262 | 1326 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1272,8 +1336,9 @@ discard block |
||
| 1272 | 1336 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1273 | 1337 | |
| 1274 | 1338 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1275 | - if ($context['browser']['is_opera']) |
|
| 1276 | - $data .= ' '; |
|
| 1339 | + if ($context['browser']['is_opera']) { |
|
| 1340 | + $data .= ' '; |
|
| 1341 | + } |
|
| 1277 | 1342 | } |
| 1278 | 1343 | }, |
| 1279 | 1344 | 'block_level' => true, |
@@ -1292,8 +1357,9 @@ discard block |
||
| 1292 | 1357 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1293 | 1358 | { |
| 1294 | 1359 | // Do PHP code coloring? |
| 1295 | - if ($php_parts[$php_i] != '<?php') |
|
| 1296 | - continue; |
|
| 1360 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1361 | + continue; |
|
| 1362 | + } |
|
| 1297 | 1363 | |
| 1298 | 1364 | $php_string = ''; |
| 1299 | 1365 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1309,8 +1375,9 @@ discard block |
||
| 1309 | 1375 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1310 | 1376 | |
| 1311 | 1377 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1312 | - if ($context['browser']['is_opera']) |
|
| 1313 | - $data[0] .= ' '; |
|
| 1378 | + if ($context['browser']['is_opera']) { |
|
| 1379 | + $data[0] .= ' '; |
|
| 1380 | + } |
|
| 1314 | 1381 | } |
| 1315 | 1382 | }, |
| 1316 | 1383 | 'block_level' => true, |
@@ -1348,11 +1415,13 @@ discard block |
||
| 1348 | 1415 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1349 | 1416 | 'validate' => function (&$tag, &$data, $disabled) |
| 1350 | 1417 | { |
| 1351 | - if (isset($disabled['url'])) |
|
| 1352 | - $tag['content'] = '$1'; |
|
| 1418 | + if (isset($disabled['url'])) { |
|
| 1419 | + $tag['content'] = '$1'; |
|
| 1420 | + } |
|
| 1353 | 1421 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1354 | - if (empty($scheme)) |
|
| 1355 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1422 | + if (empty($scheme)) { |
|
| 1423 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1424 | + } |
|
| 1356 | 1425 | }, |
| 1357 | 1426 | 'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>', |
| 1358 | 1427 | ), |
@@ -1366,10 +1435,11 @@ discard block |
||
| 1366 | 1435 | { |
| 1367 | 1436 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1368 | 1437 | |
| 1369 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
| 1370 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1371 | - else |
|
| 1372 | - $css = ''; |
|
| 1438 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
| 1439 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1440 | + } else { |
|
| 1441 | + $css = ''; |
|
| 1442 | + } |
|
| 1373 | 1443 | |
| 1374 | 1444 | $data = $class . $css; |
| 1375 | 1445 | }, |
@@ -1419,14 +1489,16 @@ discard block |
||
| 1419 | 1489 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1420 | 1490 | if ($image_proxy_enabled) |
| 1421 | 1491 | { |
| 1422 | - if (empty($scheme)) |
|
| 1423 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1492 | + if (empty($scheme)) { |
|
| 1493 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1494 | + } |
|
| 1424 | 1495 | |
| 1425 | - if ($scheme != 'https') |
|
| 1426 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1496 | + if ($scheme != 'https') { |
|
| 1497 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1498 | + } |
|
| 1499 | + } elseif (empty($scheme)) { |
|
| 1500 | + $data = '//' . ltrim($data, ':/'); |
|
| 1427 | 1501 | } |
| 1428 | - elseif (empty($scheme)) |
|
| 1429 | - $data = '//' . ltrim($data, ':/'); |
|
| 1430 | 1502 | }, |
| 1431 | 1503 | 'disabled_content' => '($1)', |
| 1432 | 1504 | ), |
@@ -1442,14 +1514,16 @@ discard block |
||
| 1442 | 1514 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1443 | 1515 | if ($image_proxy_enabled) |
| 1444 | 1516 | { |
| 1445 | - if (empty($scheme)) |
|
| 1446 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1517 | + if (empty($scheme)) { |
|
| 1518 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1519 | + } |
|
| 1447 | 1520 | |
| 1448 | - if ($scheme != 'https') |
|
| 1449 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1521 | + if ($scheme != 'https') { |
|
| 1522 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1523 | + } |
|
| 1524 | + } elseif (empty($scheme)) { |
|
| 1525 | + $data = '//' . ltrim($data, ':/'); |
|
| 1450 | 1526 | } |
| 1451 | - elseif (empty($scheme)) |
|
| 1452 | - $data = '//' . ltrim($data, ':/'); |
|
| 1453 | 1527 | }, |
| 1454 | 1528 | 'disabled_content' => '($1)', |
| 1455 | 1529 | ), |
@@ -1461,8 +1535,9 @@ discard block |
||
| 1461 | 1535 | { |
| 1462 | 1536 | $data = strtr($data, array('<br>' => '')); |
| 1463 | 1537 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1464 | - if (empty($scheme)) |
|
| 1465 | - $data = '//' . ltrim($data, ':/'); |
|
| 1538 | + if (empty($scheme)) { |
|
| 1539 | + $data = '//' . ltrim($data, ':/'); |
|
| 1540 | + } |
|
| 1466 | 1541 | }, |
| 1467 | 1542 | ), |
| 1468 | 1543 | array( |
@@ -1473,13 +1548,14 @@ discard block |
||
| 1473 | 1548 | 'after' => '</a>', |
| 1474 | 1549 | 'validate' => function (&$tag, &$data, $disabled) |
| 1475 | 1550 | { |
| 1476 | - if (substr($data, 0, 1) == '#') |
|
| 1477 | - $data = '#post_' . substr($data, 1); |
|
| 1478 | - else |
|
| 1551 | + if (substr($data, 0, 1) == '#') { |
|
| 1552 | + $data = '#post_' . substr($data, 1); |
|
| 1553 | + } else |
|
| 1479 | 1554 | { |
| 1480 | 1555 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1481 | - if (empty($scheme)) |
|
| 1482 | - $data = '//' . ltrim($data, ':/'); |
|
| 1556 | + if (empty($scheme)) { |
|
| 1557 | + $data = '//' . ltrim($data, ':/'); |
|
| 1558 | + } |
|
| 1483 | 1559 | } |
| 1484 | 1560 | }, |
| 1485 | 1561 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1557,8 +1633,9 @@ discard block |
||
| 1557 | 1633 | { |
| 1558 | 1634 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1559 | 1635 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1560 | - if ($add_begin) |
|
| 1561 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1636 | + if ($add_begin) { |
|
| 1637 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1638 | + } |
|
| 1562 | 1639 | } |
| 1563 | 1640 | }, |
| 1564 | 1641 | 'block_level' => false, |
@@ -1689,10 +1766,11 @@ discard block |
||
| 1689 | 1766 | 'content' => '$1', |
| 1690 | 1767 | 'validate' => function (&$tag, &$data, $disabled) |
| 1691 | 1768 | { |
| 1692 | - if (is_numeric($data)) |
|
| 1693 | - $data = timeformat($data); |
|
| 1694 | - else |
|
| 1695 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1769 | + if (is_numeric($data)) { |
|
| 1770 | + $data = timeformat($data); |
|
| 1771 | + } else { |
|
| 1772 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1773 | + } |
|
| 1696 | 1774 | }, |
| 1697 | 1775 | ), |
| 1698 | 1776 | array( |
@@ -1719,8 +1797,9 @@ discard block |
||
| 1719 | 1797 | { |
| 1720 | 1798 | $data = strtr($data, array('<br>' => '')); |
| 1721 | 1799 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1722 | - if (empty($scheme)) |
|
| 1723 | - $data = '//' . ltrim($data, ':/'); |
|
| 1800 | + if (empty($scheme)) { |
|
| 1801 | + $data = '//' . ltrim($data, ':/'); |
|
| 1802 | + } |
|
| 1724 | 1803 | }, |
| 1725 | 1804 | ), |
| 1726 | 1805 | array( |
@@ -1732,8 +1811,9 @@ discard block |
||
| 1732 | 1811 | 'validate' => function (&$tag, &$data, $disabled) |
| 1733 | 1812 | { |
| 1734 | 1813 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1735 | - if (empty($scheme)) |
|
| 1736 | - $data = '//' . ltrim($data, ':/'); |
|
| 1814 | + if (empty($scheme)) { |
|
| 1815 | + $data = '//' . ltrim($data, ':/'); |
|
| 1816 | + } |
|
| 1737 | 1817 | }, |
| 1738 | 1818 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1739 | 1819 | 'disabled_after' => ' ($1)', |
@@ -1753,8 +1833,9 @@ discard block |
||
| 1753 | 1833 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1754 | 1834 | if ($message === false) |
| 1755 | 1835 | { |
| 1756 | - if (isset($temp_bbc)) |
|
| 1757 | - $bbc_codes = $temp_bbc; |
|
| 1836 | + if (isset($temp_bbc)) { |
|
| 1837 | + $bbc_codes = $temp_bbc; |
|
| 1838 | + } |
|
| 1758 | 1839 | usort($codes, function ($a, $b) { |
| 1759 | 1840 | return strcmp($a['tag'], $b['tag']); |
| 1760 | 1841 | }); |
@@ -1774,8 +1855,9 @@ discard block |
||
| 1774 | 1855 | ); |
| 1775 | 1856 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1776 | 1857 | { |
| 1777 | - foreach ($itemcodes as $c => $dummy) |
|
| 1778 | - $bbc_codes[$c] = array(); |
|
| 1858 | + foreach ($itemcodes as $c => $dummy) { |
|
| 1859 | + $bbc_codes[$c] = array(); |
|
| 1860 | + } |
|
| 1779 | 1861 | } |
| 1780 | 1862 | |
| 1781 | 1863 | // Shhhh! |
@@ -1796,12 +1878,14 @@ discard block |
||
| 1796 | 1878 | foreach ($codes as $code) |
| 1797 | 1879 | { |
| 1798 | 1880 | // Make it easier to process parameters later |
| 1799 | - if (!empty($code['parameters'])) |
|
| 1800 | - ksort($code['parameters'], SORT_STRING); |
|
| 1881 | + if (!empty($code['parameters'])) { |
|
| 1882 | + ksort($code['parameters'], SORT_STRING); |
|
| 1883 | + } |
|
| 1801 | 1884 | |
| 1802 | 1885 | // If we are not doing every tag only do ones we are interested in. |
| 1803 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1804 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1886 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 1887 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1888 | + } |
|
| 1805 | 1889 | } |
| 1806 | 1890 | $codes = null; |
| 1807 | 1891 | } |
@@ -1812,8 +1896,9 @@ discard block |
||
| 1812 | 1896 | // It's likely this will change if the message is modified. |
| 1813 | 1897 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
| 1814 | 1898 | |
| 1815 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1816 | - return $temp; |
|
| 1899 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 1900 | + return $temp; |
|
| 1901 | + } |
|
| 1817 | 1902 | |
| 1818 | 1903 | $cache_t = microtime(); |
| 1819 | 1904 | } |
@@ -1845,8 +1930,9 @@ discard block |
||
| 1845 | 1930 | $disabled['flash'] = true; |
| 1846 | 1931 | |
| 1847 | 1932 | // @todo Change maybe? |
| 1848 | - if (!isset($_GET['images'])) |
|
| 1849 | - $disabled['img'] = true; |
|
| 1933 | + if (!isset($_GET['images'])) { |
|
| 1934 | + $disabled['img'] = true; |
|
| 1935 | + } |
|
| 1850 | 1936 | |
| 1851 | 1937 | // @todo Interface/setting to add more? |
| 1852 | 1938 | } |
@@ -1870,8 +1956,9 @@ discard block |
||
| 1870 | 1956 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 1871 | 1957 | |
| 1872 | 1958 | // Failsafe. |
| 1873 | - if ($pos === false || $last_pos > $pos) |
|
| 1874 | - $pos = strlen($message) + 1; |
|
| 1959 | + if ($pos === false || $last_pos > $pos) { |
|
| 1960 | + $pos = strlen($message) + 1; |
|
| 1961 | + } |
|
| 1875 | 1962 | |
| 1876 | 1963 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 1877 | 1964 | if ($last_pos < $pos - 1) |
@@ -1889,8 +1976,9 @@ discard block |
||
| 1889 | 1976 | |
| 1890 | 1977 | // <br> should be empty. |
| 1891 | 1978 | $empty_tags = array('br', 'hr'); |
| 1892 | - foreach ($empty_tags as $tag) |
|
| 1893 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 1979 | + foreach ($empty_tags as $tag) { |
|
| 1980 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 1981 | + } |
|
| 1894 | 1982 | |
| 1895 | 1983 | // b, u, i, s, pre... basic tags. |
| 1896 | 1984 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1899,8 +1987,9 @@ discard block |
||
| 1899 | 1987 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 1900 | 1988 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 1901 | 1989 | |
| 1902 | - if ($diff > 0) |
|
| 1903 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1990 | + if ($diff > 0) { |
|
| 1991 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1992 | + } |
|
| 1904 | 1993 | } |
| 1905 | 1994 | |
| 1906 | 1995 | // Do <img ...> - with security... action= -> action-. |
@@ -1913,8 +2002,9 @@ discard block |
||
| 1913 | 2002 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 1914 | 2003 | |
| 1915 | 2004 | // Remove action= from the URL - no funny business, now. |
| 1916 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 1917 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2005 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 2006 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2007 | + } |
|
| 1918 | 2008 | |
| 1919 | 2009 | // Check if the image is larger than allowed. |
| 1920 | 2010 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1935,9 +2025,9 @@ discard block |
||
| 1935 | 2025 | |
| 1936 | 2026 | // Set the new image tag. |
| 1937 | 2027 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
| 2028 | + } else { |
|
| 2029 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1938 | 2030 | } |
| 1939 | - else |
|
| 1940 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1941 | 2031 | } |
| 1942 | 2032 | |
| 1943 | 2033 | $data = strtr($data, $replaces); |
@@ -1950,16 +2040,18 @@ discard block |
||
| 1950 | 2040 | $no_autolink_area = false; |
| 1951 | 2041 | if (!empty($open_tags)) |
| 1952 | 2042 | { |
| 1953 | - foreach ($open_tags as $open_tag) |
|
| 1954 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2043 | + foreach ($open_tags as $open_tag) { |
|
| 2044 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1955 | 2045 | $no_autolink_area = true; |
| 2046 | + } |
|
| 1956 | 2047 | } |
| 1957 | 2048 | |
| 1958 | 2049 | // Don't go backwards. |
| 1959 | 2050 | // @todo Don't think is the real solution.... |
| 1960 | 2051 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 1961 | - if ($pos < $lastAutoPos) |
|
| 1962 | - $no_autolink_area = true; |
|
| 2052 | + if ($pos < $lastAutoPos) { |
|
| 2053 | + $no_autolink_area = true; |
|
| 2054 | + } |
|
| 1963 | 2055 | $lastAutoPos = $pos; |
| 1964 | 2056 | |
| 1965 | 2057 | if (!$no_autolink_area) |
@@ -2068,17 +2160,19 @@ discard block |
||
| 2068 | 2160 | if ($scheme == 'mailto') |
| 2069 | 2161 | { |
| 2070 | 2162 | $email_address = str_replace('mailto:', '', $url); |
| 2071 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 2072 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2073 | - else |
|
| 2074 | - return $url; |
|
| 2163 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2164 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2165 | + } else { |
|
| 2166 | + return $url; |
|
| 2167 | + } |
|
| 2075 | 2168 | } |
| 2076 | 2169 | |
| 2077 | 2170 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 2078 | - if (empty($scheme)) |
|
| 2079 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2080 | - else |
|
| 2081 | - $fullUrl = $url; |
|
| 2171 | + if (empty($scheme)) { |
|
| 2172 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2173 | + } else { |
|
| 2174 | + $fullUrl = $url; |
|
| 2175 | + } |
|
| 2082 | 2176 | |
| 2083 | 2177 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 2084 | 2178 | }, $data); |
@@ -2127,16 +2221,18 @@ discard block |
||
| 2127 | 2221 | } |
| 2128 | 2222 | |
| 2129 | 2223 | // Are we there yet? Are we there yet? |
| 2130 | - if ($pos >= strlen($message) - 1) |
|
| 2131 | - break; |
|
| 2224 | + if ($pos >= strlen($message) - 1) { |
|
| 2225 | + break; |
|
| 2226 | + } |
|
| 2132 | 2227 | |
| 2133 | 2228 | $tags = strtolower($message[$pos + 1]); |
| 2134 | 2229 | |
| 2135 | 2230 | if ($tags == '/' && !empty($open_tags)) |
| 2136 | 2231 | { |
| 2137 | 2232 | $pos2 = strpos($message, ']', $pos + 1); |
| 2138 | - if ($pos2 == $pos + 2) |
|
| 2139 | - continue; |
|
| 2233 | + if ($pos2 == $pos + 2) { |
|
| 2234 | + continue; |
|
| 2235 | + } |
|
| 2140 | 2236 | |
| 2141 | 2237 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2142 | 2238 | |
@@ -2146,8 +2242,9 @@ discard block |
||
| 2146 | 2242 | do |
| 2147 | 2243 | { |
| 2148 | 2244 | $tag = array_pop($open_tags); |
| 2149 | - if (!$tag) |
|
| 2150 | - break; |
|
| 2245 | + if (!$tag) { |
|
| 2246 | + break; |
|
| 2247 | + } |
|
| 2151 | 2248 | |
| 2152 | 2249 | if (!empty($tag['block_level'])) |
| 2153 | 2250 | { |
@@ -2161,10 +2258,11 @@ discard block |
||
| 2161 | 2258 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2162 | 2259 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2163 | 2260 | { |
| 2164 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2165 | - if ($temp['tag'] == $look_for) |
|
| 2261 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2262 | + if ($temp['tag'] == $look_for) |
|
| 2166 | 2263 | { |
| 2167 | 2264 | $block_level = !empty($temp['block_level']); |
| 2265 | + } |
|
| 2168 | 2266 | break; |
| 2169 | 2267 | } |
| 2170 | 2268 | } |
@@ -2186,15 +2284,15 @@ discard block |
||
| 2186 | 2284 | { |
| 2187 | 2285 | $open_tags = $to_close; |
| 2188 | 2286 | continue; |
| 2189 | - } |
|
| 2190 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2287 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2191 | 2288 | { |
| 2192 | 2289 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2193 | 2290 | { |
| 2194 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2195 | - if ($temp['tag'] == $look_for) |
|
| 2291 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2292 | + if ($temp['tag'] == $look_for) |
|
| 2196 | 2293 | { |
| 2197 | 2294 | $block_level = !empty($temp['block_level']); |
| 2295 | + } |
|
| 2198 | 2296 | break; |
| 2199 | 2297 | } |
| 2200 | 2298 | } |
@@ -2202,8 +2300,9 @@ discard block |
||
| 2202 | 2300 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2203 | 2301 | if (!$block_level) |
| 2204 | 2302 | { |
| 2205 | - foreach ($to_close as $tag) |
|
| 2206 | - array_push($open_tags, $tag); |
|
| 2303 | + foreach ($to_close as $tag) { |
|
| 2304 | + array_push($open_tags, $tag); |
|
| 2305 | + } |
|
| 2207 | 2306 | continue; |
| 2208 | 2307 | } |
| 2209 | 2308 | } |
@@ -2216,14 +2315,17 @@ discard block |
||
| 2216 | 2315 | |
| 2217 | 2316 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2218 | 2317 | $whitespace_regex = ''; |
| 2219 | - if (!empty($tag['block_level'])) |
|
| 2220 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2318 | + if (!empty($tag['block_level'])) { |
|
| 2319 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2320 | + } |
|
| 2221 | 2321 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
| 2222 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2223 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2322 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2323 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2324 | + } |
|
| 2224 | 2325 | |
| 2225 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2226 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2326 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2327 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2328 | + } |
|
| 2227 | 2329 | } |
| 2228 | 2330 | |
| 2229 | 2331 | if (!empty($to_close)) |
@@ -2236,8 +2338,9 @@ discard block |
||
| 2236 | 2338 | } |
| 2237 | 2339 | |
| 2238 | 2340 | // No tags for this character, so just keep going (fastest possible course.) |
| 2239 | - if (!isset($bbc_codes[$tags])) |
|
| 2240 | - continue; |
|
| 2341 | + if (!isset($bbc_codes[$tags])) { |
|
| 2342 | + continue; |
|
| 2343 | + } |
|
| 2241 | 2344 | |
| 2242 | 2345 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2243 | 2346 | $tag = null; |
@@ -2246,44 +2349,52 @@ discard block |
||
| 2246 | 2349 | $pt_strlen = strlen($possible['tag']); |
| 2247 | 2350 | |
| 2248 | 2351 | // Not a match? |
| 2249 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2250 | - continue; |
|
| 2352 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2353 | + continue; |
|
| 2354 | + } |
|
| 2251 | 2355 | |
| 2252 | 2356 | $next_c = $message[$pos + 1 + $pt_strlen]; |
| 2253 | 2357 | |
| 2254 | 2358 | // A test validation? |
| 2255 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2256 | - continue; |
|
| 2359 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2360 | + continue; |
|
| 2361 | + } |
|
| 2257 | 2362 | // Do we want parameters? |
| 2258 | 2363 | elseif (!empty($possible['parameters'])) |
| 2259 | 2364 | { |
| 2260 | - if ($next_c != ' ') |
|
| 2261 | - continue; |
|
| 2262 | - } |
|
| 2263 | - elseif (isset($possible['type'])) |
|
| 2365 | + if ($next_c != ' ') { |
|
| 2366 | + continue; |
|
| 2367 | + } |
|
| 2368 | + } elseif (isset($possible['type'])) |
|
| 2264 | 2369 | { |
| 2265 | 2370 | // Do we need an equal sign? |
| 2266 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2267 | - continue; |
|
| 2371 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2372 | + continue; |
|
| 2373 | + } |
|
| 2268 | 2374 | // Maybe we just want a /... |
| 2269 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2270 | - continue; |
|
| 2375 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2376 | + continue; |
|
| 2377 | + } |
|
| 2271 | 2378 | // An immediate ]? |
| 2272 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2273 | - continue; |
|
| 2379 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2380 | + continue; |
|
| 2381 | + } |
|
| 2274 | 2382 | } |
| 2275 | 2383 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2276 | - elseif ($next_c != ']') |
|
| 2277 | - continue; |
|
| 2384 | + elseif ($next_c != ']') { |
|
| 2385 | + continue; |
|
| 2386 | + } |
|
| 2278 | 2387 | |
| 2279 | 2388 | // Check allowed tree? |
| 2280 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2281 | - continue; |
|
| 2282 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2283 | - continue; |
|
| 2389 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2390 | + continue; |
|
| 2391 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2392 | + continue; |
|
| 2393 | + } |
|
| 2284 | 2394 | // If this is in the list of disallowed child tags, don't parse it. |
| 2285 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2286 | - continue; |
|
| 2395 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2396 | + continue; |
|
| 2397 | + } |
|
| 2287 | 2398 | |
| 2288 | 2399 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2289 | 2400 | |
@@ -2295,8 +2406,9 @@ discard block |
||
| 2295 | 2406 | foreach ($open_tags as $open_quote) |
| 2296 | 2407 | { |
| 2297 | 2408 | // Every parent quote this quote has flips the styling |
| 2298 | - if ($open_quote['tag'] == 'quote') |
|
| 2299 | - $quote_alt = !$quote_alt; |
|
| 2409 | + if ($open_quote['tag'] == 'quote') { |
|
| 2410 | + $quote_alt = !$quote_alt; |
|
| 2411 | + } |
|
| 2300 | 2412 | } |
| 2301 | 2413 | // Add a class to the quote to style alternating blockquotes |
| 2302 | 2414 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2307,8 +2419,9 @@ discard block |
||
| 2307 | 2419 | { |
| 2308 | 2420 | // Build a regular expression for each parameter for the current tag. |
| 2309 | 2421 | $preg = array(); |
| 2310 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2311 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2422 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2423 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2424 | + } |
|
| 2312 | 2425 | |
| 2313 | 2426 | // Extract the string that potentially holds our parameters. |
| 2314 | 2427 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2328,24 +2441,27 @@ discard block |
||
| 2328 | 2441 | |
| 2329 | 2442 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2330 | 2443 | |
| 2331 | - if ($match) |
|
| 2332 | - $blob_counter = count($blobs) + 1; |
|
| 2444 | + if ($match) { |
|
| 2445 | + $blob_counter = count($blobs) + 1; |
|
| 2446 | + } |
|
| 2333 | 2447 | } |
| 2334 | 2448 | |
| 2335 | 2449 | // Didn't match our parameter list, try the next possible. |
| 2336 | - if (!$match) |
|
| 2337 | - continue; |
|
| 2450 | + if (!$match) { |
|
| 2451 | + continue; |
|
| 2452 | + } |
|
| 2338 | 2453 | |
| 2339 | 2454 | $params = array(); |
| 2340 | 2455 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2341 | 2456 | { |
| 2342 | 2457 | $key = strtok(ltrim($matches[$i]), '='); |
| 2343 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2344 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2345 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2346 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2347 | - else |
|
| 2348 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2458 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2459 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2460 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2461 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2462 | + } else { |
|
| 2463 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2464 | + } |
|
| 2349 | 2465 | |
| 2350 | 2466 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2351 | 2467 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2353,23 +2469,26 @@ discard block |
||
| 2353 | 2469 | |
| 2354 | 2470 | foreach ($possible['parameters'] as $p => $info) |
| 2355 | 2471 | { |
| 2356 | - if (!isset($params['{' . $p . '}'])) |
|
| 2357 | - $params['{' . $p . '}'] = ''; |
|
| 2472 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2473 | + $params['{' . $p . '}'] = ''; |
|
| 2474 | + } |
|
| 2358 | 2475 | } |
| 2359 | 2476 | |
| 2360 | 2477 | $tag = $possible; |
| 2361 | 2478 | |
| 2362 | 2479 | // Put the parameters into the string. |
| 2363 | - if (isset($tag['before'])) |
|
| 2364 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2365 | - if (isset($tag['after'])) |
|
| 2366 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2367 | - if (isset($tag['content'])) |
|
| 2368 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2480 | + if (isset($tag['before'])) { |
|
| 2481 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2482 | + } |
|
| 2483 | + if (isset($tag['after'])) { |
|
| 2484 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2485 | + } |
|
| 2486 | + if (isset($tag['content'])) { |
|
| 2487 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2488 | + } |
|
| 2369 | 2489 | |
| 2370 | 2490 | $pos1 += strlen($given_param_string); |
| 2371 | - } |
|
| 2372 | - else |
|
| 2491 | + } else |
|
| 2373 | 2492 | { |
| 2374 | 2493 | $tag = $possible; |
| 2375 | 2494 | $params = array(); |
@@ -2380,8 +2499,9 @@ discard block |
||
| 2380 | 2499 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2381 | 2500 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2382 | 2501 | { |
| 2383 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2384 | - continue; |
|
| 2502 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2503 | + continue; |
|
| 2504 | + } |
|
| 2385 | 2505 | |
| 2386 | 2506 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2387 | 2507 | |
@@ -2402,9 +2522,9 @@ discard block |
||
| 2402 | 2522 | { |
| 2403 | 2523 | array_pop($open_tags); |
| 2404 | 2524 | $code = '</li>'; |
| 2525 | + } else { |
|
| 2526 | + $code = ''; |
|
| 2405 | 2527 | } |
| 2406 | - else |
|
| 2407 | - $code = ''; |
|
| 2408 | 2528 | |
| 2409 | 2529 | // Now we open a new tag. |
| 2410 | 2530 | $open_tags[] = array( |
@@ -2451,12 +2571,14 @@ discard block |
||
| 2451 | 2571 | } |
| 2452 | 2572 | |
| 2453 | 2573 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2454 | - if ($tag === null) |
|
| 2455 | - continue; |
|
| 2574 | + if ($tag === null) { |
|
| 2575 | + continue; |
|
| 2576 | + } |
|
| 2456 | 2577 | |
| 2457 | 2578 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2458 | - if (isset($inside['disallow_children'])) |
|
| 2459 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2579 | + if (isset($inside['disallow_children'])) { |
|
| 2580 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2581 | + } |
|
| 2460 | 2582 | |
| 2461 | 2583 | // Is this tag disabled? |
| 2462 | 2584 | if (isset($disabled[$tag['tag']])) |
@@ -2466,14 +2588,13 @@ discard block |
||
| 2466 | 2588 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2467 | 2589 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2468 | 2590 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2469 | - } |
|
| 2470 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2591 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2471 | 2592 | { |
| 2472 | 2593 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2473 | 2594 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2595 | + } else { |
|
| 2596 | + $tag['content'] = $tag['disabled_content']; |
|
| 2474 | 2597 | } |
| 2475 | - else |
|
| 2476 | - $tag['content'] = $tag['disabled_content']; |
|
| 2477 | 2598 | } |
| 2478 | 2599 | |
| 2479 | 2600 | // we use this a lot |
@@ -2483,8 +2604,9 @@ discard block |
||
| 2483 | 2604 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2484 | 2605 | { |
| 2485 | 2606 | $n = count($open_tags) - 1; |
| 2486 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2487 | - $n--; |
|
| 2607 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2608 | + $n--; |
|
| 2609 | + } |
|
| 2488 | 2610 | |
| 2489 | 2611 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2490 | 2612 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2496,12 +2618,15 @@ discard block |
||
| 2496 | 2618 | |
| 2497 | 2619 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2498 | 2620 | $whitespace_regex = ''; |
| 2499 | - if (!empty($tag['block_level'])) |
|
| 2500 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2501 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2502 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2503 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2504 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2621 | + if (!empty($tag['block_level'])) { |
|
| 2622 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2623 | + } |
|
| 2624 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2625 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2626 | + } |
|
| 2627 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2628 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2629 | + } |
|
| 2505 | 2630 | |
| 2506 | 2631 | array_pop($open_tags); |
| 2507 | 2632 | } |
@@ -2522,16 +2647,19 @@ discard block |
||
| 2522 | 2647 | elseif ($tag['type'] == 'unparsed_content') |
| 2523 | 2648 | { |
| 2524 | 2649 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2525 | - if ($pos2 === false) |
|
| 2526 | - continue; |
|
| 2650 | + if ($pos2 === false) { |
|
| 2651 | + continue; |
|
| 2652 | + } |
|
| 2527 | 2653 | |
| 2528 | 2654 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2529 | 2655 | |
| 2530 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2531 | - $data = substr($data, 4); |
|
| 2656 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2657 | + $data = substr($data, 4); |
|
| 2658 | + } |
|
| 2532 | 2659 | |
| 2533 | - if (isset($tag['validate'])) |
|
| 2534 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2660 | + if (isset($tag['validate'])) { |
|
| 2661 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2662 | + } |
|
| 2535 | 2663 | |
| 2536 | 2664 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2537 | 2665 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2547,34 +2675,40 @@ discard block |
||
| 2547 | 2675 | if (isset($tag['quoted'])) |
| 2548 | 2676 | { |
| 2549 | 2677 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2550 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2551 | - continue; |
|
| 2678 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2679 | + continue; |
|
| 2680 | + } |
|
| 2552 | 2681 | |
| 2553 | - if ($quoted) |
|
| 2554 | - $pos1 += 6; |
|
| 2682 | + if ($quoted) { |
|
| 2683 | + $pos1 += 6; |
|
| 2684 | + } |
|
| 2685 | + } else { |
|
| 2686 | + $quoted = false; |
|
| 2555 | 2687 | } |
| 2556 | - else |
|
| 2557 | - $quoted = false; |
|
| 2558 | 2688 | |
| 2559 | 2689 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2560 | - if ($pos2 === false) |
|
| 2561 | - continue; |
|
| 2690 | + if ($pos2 === false) { |
|
| 2691 | + continue; |
|
| 2692 | + } |
|
| 2562 | 2693 | |
| 2563 | 2694 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2564 | - if ($pos3 === false) |
|
| 2565 | - continue; |
|
| 2695 | + if ($pos3 === false) { |
|
| 2696 | + continue; |
|
| 2697 | + } |
|
| 2566 | 2698 | |
| 2567 | 2699 | $data = array( |
| 2568 | 2700 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2569 | 2701 | substr($message, $pos1, $pos2 - $pos1) |
| 2570 | 2702 | ); |
| 2571 | 2703 | |
| 2572 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2573 | - $data[0] = substr($data[0], 4); |
|
| 2704 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2705 | + $data[0] = substr($data[0], 4); |
|
| 2706 | + } |
|
| 2574 | 2707 | |
| 2575 | 2708 | // Validation for my parking, please! |
| 2576 | - if (isset($tag['validate'])) |
|
| 2577 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2709 | + if (isset($tag['validate'])) { |
|
| 2710 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2711 | + } |
|
| 2578 | 2712 | |
| 2579 | 2713 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2580 | 2714 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2591,23 +2725,27 @@ discard block |
||
| 2591 | 2725 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2592 | 2726 | { |
| 2593 | 2727 | $pos2 = strpos($message, ']', $pos1); |
| 2594 | - if ($pos2 === false) |
|
| 2595 | - continue; |
|
| 2728 | + if ($pos2 === false) { |
|
| 2729 | + continue; |
|
| 2730 | + } |
|
| 2596 | 2731 | |
| 2597 | 2732 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2598 | - if ($pos3 === false) |
|
| 2599 | - continue; |
|
| 2733 | + if ($pos3 === false) { |
|
| 2734 | + continue; |
|
| 2735 | + } |
|
| 2600 | 2736 | |
| 2601 | 2737 | // We want $1 to be the content, and the rest to be csv. |
| 2602 | 2738 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2603 | 2739 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2604 | 2740 | |
| 2605 | - if (isset($tag['validate'])) |
|
| 2606 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2741 | + if (isset($tag['validate'])) { |
|
| 2742 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2743 | + } |
|
| 2607 | 2744 | |
| 2608 | 2745 | $code = $tag['content']; |
| 2609 | - foreach ($data as $k => $d) |
|
| 2610 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2746 | + foreach ($data as $k => $d) { |
|
| 2747 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2748 | + } |
|
| 2611 | 2749 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2612 | 2750 | $pos += strlen($code) - 1 + 2; |
| 2613 | 2751 | } |
@@ -2615,24 +2753,28 @@ discard block |
||
| 2615 | 2753 | elseif ($tag['type'] == 'unparsed_commas') |
| 2616 | 2754 | { |
| 2617 | 2755 | $pos2 = strpos($message, ']', $pos1); |
| 2618 | - if ($pos2 === false) |
|
| 2619 | - continue; |
|
| 2756 | + if ($pos2 === false) { |
|
| 2757 | + continue; |
|
| 2758 | + } |
|
| 2620 | 2759 | |
| 2621 | 2760 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2622 | 2761 | |
| 2623 | - if (isset($tag['validate'])) |
|
| 2624 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2762 | + if (isset($tag['validate'])) { |
|
| 2763 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2764 | + } |
|
| 2625 | 2765 | |
| 2626 | 2766 | // Fix after, for disabled code mainly. |
| 2627 | - foreach ($data as $k => $d) |
|
| 2628 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2767 | + foreach ($data as $k => $d) { |
|
| 2768 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2769 | + } |
|
| 2629 | 2770 | |
| 2630 | 2771 | $open_tags[] = $tag; |
| 2631 | 2772 | |
| 2632 | 2773 | // Replace them out, $1, $2, $3, $4, etc. |
| 2633 | 2774 | $code = $tag['before']; |
| 2634 | - foreach ($data as $k => $d) |
|
| 2635 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2775 | + foreach ($data as $k => $d) { |
|
| 2776 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2777 | + } |
|
| 2636 | 2778 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2637 | 2779 | $pos += strlen($code) - 1 + 2; |
| 2638 | 2780 | } |
@@ -2643,28 +2785,33 @@ discard block |
||
| 2643 | 2785 | if (isset($tag['quoted'])) |
| 2644 | 2786 | { |
| 2645 | 2787 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2646 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2647 | - continue; |
|
| 2788 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2789 | + continue; |
|
| 2790 | + } |
|
| 2648 | 2791 | |
| 2649 | - if ($quoted) |
|
| 2650 | - $pos1 += 6; |
|
| 2792 | + if ($quoted) { |
|
| 2793 | + $pos1 += 6; |
|
| 2794 | + } |
|
| 2795 | + } else { |
|
| 2796 | + $quoted = false; |
|
| 2651 | 2797 | } |
| 2652 | - else |
|
| 2653 | - $quoted = false; |
|
| 2654 | 2798 | |
| 2655 | 2799 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2656 | - if ($pos2 === false) |
|
| 2657 | - continue; |
|
| 2800 | + if ($pos2 === false) { |
|
| 2801 | + continue; |
|
| 2802 | + } |
|
| 2658 | 2803 | |
| 2659 | 2804 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2660 | 2805 | |
| 2661 | 2806 | // Validation for my parking, please! |
| 2662 | - if (isset($tag['validate'])) |
|
| 2663 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2807 | + if (isset($tag['validate'])) { |
|
| 2808 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2809 | + } |
|
| 2664 | 2810 | |
| 2665 | 2811 | // For parsed content, we must recurse to avoid security problems. |
| 2666 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2667 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2812 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2813 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2814 | + } |
|
| 2668 | 2815 | |
| 2669 | 2816 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2670 | 2817 | |
@@ -2676,34 +2823,40 @@ discard block |
||
| 2676 | 2823 | } |
| 2677 | 2824 | |
| 2678 | 2825 | // If this is block level, eat any breaks after it. |
| 2679 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2680 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2826 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2827 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2828 | + } |
|
| 2681 | 2829 | |
| 2682 | 2830 | // Are we trimming outside this tag? |
| 2683 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2684 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2831 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 2832 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2833 | + } |
|
| 2685 | 2834 | } |
| 2686 | 2835 | |
| 2687 | 2836 | // Close any remaining tags. |
| 2688 | - while ($tag = array_pop($open_tags)) |
|
| 2689 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 2837 | + while ($tag = array_pop($open_tags)) { |
|
| 2838 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 2839 | + } |
|
| 2690 | 2840 | |
| 2691 | 2841 | // Parse the smileys within the parts where it can be done safely. |
| 2692 | 2842 | if ($smileys === true) |
| 2693 | 2843 | { |
| 2694 | 2844 | $message_parts = explode("\n", $message); |
| 2695 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2696 | - parsesmileys($message_parts[$i]); |
|
| 2845 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 2846 | + parsesmileys($message_parts[$i]); |
|
| 2847 | + } |
|
| 2697 | 2848 | |
| 2698 | 2849 | $message = implode('', $message_parts); |
| 2699 | 2850 | } |
| 2700 | 2851 | |
| 2701 | 2852 | // No smileys, just get rid of the markers. |
| 2702 | - else |
|
| 2703 | - $message = strtr($message, array("\n" => '')); |
|
| 2853 | + else { |
|
| 2854 | + $message = strtr($message, array("\n" => '')); |
|
| 2855 | + } |
|
| 2704 | 2856 | |
| 2705 | - if ($message !== '' && $message[0] === ' ') |
|
| 2706 | - $message = ' ' . substr($message, 1); |
|
| 2857 | + if ($message !== '' && $message[0] === ' ') { |
|
| 2858 | + $message = ' ' . substr($message, 1); |
|
| 2859 | + } |
|
| 2707 | 2860 | |
| 2708 | 2861 | // Cleanup whitespace. |
| 2709 | 2862 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2712,15 +2865,16 @@ discard block |
||
| 2712 | 2865 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2713 | 2866 | |
| 2714 | 2867 | // Cache the output if it took some time... |
| 2715 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2716 | - cache_put_data($cache_key, $message, 240); |
|
| 2868 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 2869 | + cache_put_data($cache_key, $message, 240); |
|
| 2870 | + } |
|
| 2717 | 2871 | |
| 2718 | 2872 | // If this was a force parse revert if needed. |
| 2719 | 2873 | if (!empty($parse_tags)) |
| 2720 | 2874 | { |
| 2721 | - if (empty($temp_bbc)) |
|
| 2722 | - $bbc_codes = array(); |
|
| 2723 | - else |
|
| 2875 | + if (empty($temp_bbc)) { |
|
| 2876 | + $bbc_codes = array(); |
|
| 2877 | + } else |
|
| 2724 | 2878 | { |
| 2725 | 2879 | $bbc_codes = $temp_bbc; |
| 2726 | 2880 | unset($temp_bbc); |
@@ -2747,8 +2901,9 @@ discard block |
||
| 2747 | 2901 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2748 | 2902 | |
| 2749 | 2903 | // No smiley set at all?! |
| 2750 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2751 | - return; |
|
| 2904 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 2905 | + return; |
|
| 2906 | + } |
|
| 2752 | 2907 | |
| 2753 | 2908 | // If smileyPregSearch hasn't been set, do it now. |
| 2754 | 2909 | if (empty($smileyPregSearch)) |
@@ -2759,8 +2914,7 @@ discard block |
||
| 2759 | 2914 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
| 2760 | 2915 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
| 2761 | 2916 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
| 2762 | - } |
|
| 2763 | - else |
|
| 2917 | + } else |
|
| 2764 | 2918 | { |
| 2765 | 2919 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2766 | 2920 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2784,9 +2938,9 @@ discard block |
||
| 2784 | 2938 | $smcFunc['db_free_result']($result); |
| 2785 | 2939 | |
| 2786 | 2940 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 2941 | + } else { |
|
| 2942 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2787 | 2943 | } |
| 2788 | - else |
|
| 2789 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2790 | 2944 | } |
| 2791 | 2945 | |
| 2792 | 2946 | // The non-breaking-space is a complex thing... |
@@ -2863,35 +3017,41 @@ discard block |
||
| 2863 | 3017 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 2864 | 3018 | |
| 2865 | 3019 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 2866 | - if (!empty($context['flush_mail'])) |
|
| 2867 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3020 | + if (!empty($context['flush_mail'])) { |
|
| 3021 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2868 | 3022 | AddMailQueue(true); |
| 3023 | + } |
|
| 2869 | 3024 | |
| 2870 | 3025 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 2871 | 3026 | |
| 2872 | - if ($add) |
|
| 2873 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3027 | + if ($add) { |
|
| 3028 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3029 | + } |
|
| 2874 | 3030 | |
| 2875 | 3031 | // Put the session ID in. |
| 2876 | - if (defined('SID') && SID != '') |
|
| 2877 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3032 | + if (defined('SID') && SID != '') { |
|
| 3033 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3034 | + } |
|
| 2878 | 3035 | // Keep that debug in their for template debugging! |
| 2879 | - elseif (isset($_GET['debug'])) |
|
| 2880 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3036 | + elseif (isset($_GET['debug'])) { |
|
| 3037 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3038 | + } |
|
| 2881 | 3039 | |
| 2882 | 3040 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
| 2883 | 3041 | { |
| 2884 | - if (defined('SID') && SID != '') |
|
| 2885 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3042 | + if (defined('SID') && SID != '') { |
|
| 3043 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2886 | 3044 | function ($m) use ($scripturl) |
| 2887 | 3045 | { |
| 2888 | 3046 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 3047 | + } |
|
| 2889 | 3048 | }, $setLocation); |
| 2890 | - else |
|
| 2891 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3049 | + else { |
|
| 3050 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2892 | 3051 | function ($m) use ($scripturl) |
| 2893 | 3052 | { |
| 2894 | 3053 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3054 | + } |
|
| 2895 | 3055 | }, $setLocation); |
| 2896 | 3056 | } |
| 2897 | 3057 | |
@@ -2902,8 +3062,9 @@ discard block |
||
| 2902 | 3062 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 2903 | 3063 | |
| 2904 | 3064 | // Debugging. |
| 2905 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 2906 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 3065 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3066 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 3067 | + } |
|
| 2907 | 3068 | |
| 2908 | 3069 | obExit(false); |
| 2909 | 3070 | } |
@@ -2922,51 +3083,60 @@ discard block |
||
| 2922 | 3083 | |
| 2923 | 3084 | // Attempt to prevent a recursive loop. |
| 2924 | 3085 | ++$level; |
| 2925 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 2926 | - exit; |
|
| 2927 | - if ($from_fatal_error) |
|
| 2928 | - $has_fatal_error = true; |
|
| 3086 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 3087 | + exit; |
|
| 3088 | + } |
|
| 3089 | + if ($from_fatal_error) { |
|
| 3090 | + $has_fatal_error = true; |
|
| 3091 | + } |
|
| 2929 | 3092 | |
| 2930 | 3093 | // Clear out the stat cache. |
| 2931 | 3094 | trackStats(); |
| 2932 | 3095 | |
| 2933 | 3096 | // If we have mail to send, send it. |
| 2934 | - if (!empty($context['flush_mail'])) |
|
| 2935 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3097 | + if (!empty($context['flush_mail'])) { |
|
| 3098 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2936 | 3099 | AddMailQueue(true); |
| 3100 | + } |
|
| 2937 | 3101 | |
| 2938 | 3102 | $do_header = $header === null ? !$header_done : $header; |
| 2939 | - if ($do_footer === null) |
|
| 2940 | - $do_footer = $do_header; |
|
| 3103 | + if ($do_footer === null) { |
|
| 3104 | + $do_footer = $do_header; |
|
| 3105 | + } |
|
| 2941 | 3106 | |
| 2942 | 3107 | // Has the template/header been done yet? |
| 2943 | 3108 | if ($do_header) |
| 2944 | 3109 | { |
| 2945 | 3110 | // Was the page title set last minute? Also update the HTML safe one. |
| 2946 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 2947 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3111 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 3112 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3113 | + } |
|
| 2948 | 3114 | |
| 2949 | 3115 | // Start up the session URL fixer. |
| 2950 | 3116 | ob_start('ob_sessrewrite'); |
| 2951 | 3117 | |
| 2952 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 2953 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 2954 | - elseif (!empty($settings['output_buffers'])) |
|
| 2955 | - $buffers = $settings['output_buffers']; |
|
| 2956 | - else |
|
| 2957 | - $buffers = array(); |
|
| 3118 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 3119 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 3120 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3121 | + $buffers = $settings['output_buffers']; |
|
| 3122 | + } else { |
|
| 3123 | + $buffers = array(); |
|
| 3124 | + } |
|
| 2958 | 3125 | |
| 2959 | - if (isset($modSettings['integrate_buffer'])) |
|
| 2960 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3126 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3127 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3128 | + } |
|
| 2961 | 3129 | |
| 2962 | - if (!empty($buffers)) |
|
| 2963 | - foreach ($buffers as $function) |
|
| 3130 | + if (!empty($buffers)) { |
|
| 3131 | + foreach ($buffers as $function) |
|
| 2964 | 3132 | { |
| 2965 | 3133 | $call = call_helper($function, true); |
| 3134 | + } |
|
| 2966 | 3135 | |
| 2967 | 3136 | // Is it valid? |
| 2968 | - if (!empty($call)) |
|
| 2969 | - ob_start($call); |
|
| 3137 | + if (!empty($call)) { |
|
| 3138 | + ob_start($call); |
|
| 3139 | + } |
|
| 2970 | 3140 | } |
| 2971 | 3141 | |
| 2972 | 3142 | // Display the screen in the logical order. |
@@ -2978,8 +3148,9 @@ discard block |
||
| 2978 | 3148 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 2979 | 3149 | |
| 2980 | 3150 | // Anything special to put out? |
| 2981 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 2982 | - echo $context['insert_after_template']; |
|
| 3151 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3152 | + echo $context['insert_after_template']; |
|
| 3153 | + } |
|
| 2983 | 3154 | |
| 2984 | 3155 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 2985 | 3156 | if (!$footer_done) |
@@ -2988,14 +3159,16 @@ discard block |
||
| 2988 | 3159 | template_footer(); |
| 2989 | 3160 | |
| 2990 | 3161 | // (since this is just debugging... it's okay that it's after </html>.) |
| 2991 | - if (!isset($_REQUEST['xml'])) |
|
| 2992 | - displayDebug(); |
|
| 3162 | + if (!isset($_REQUEST['xml'])) { |
|
| 3163 | + displayDebug(); |
|
| 3164 | + } |
|
| 2993 | 3165 | } |
| 2994 | 3166 | } |
| 2995 | 3167 | |
| 2996 | 3168 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 2997 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 2998 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3169 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3170 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3171 | + } |
|
| 2999 | 3172 | |
| 3000 | 3173 | // For session check verification.... don't switch browsers... |
| 3001 | 3174 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3004,9 +3177,10 @@ discard block |
||
| 3004 | 3177 | call_integration_hook('integrate_exit', array($do_footer)); |
| 3005 | 3178 | |
| 3006 | 3179 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 3007 | - if (!$from_index) |
|
| 3008 | - exit; |
|
| 3009 | -} |
|
| 3180 | + if (!$from_index) { |
|
| 3181 | + exit; |
|
| 3182 | + } |
|
| 3183 | + } |
|
| 3010 | 3184 | |
| 3011 | 3185 | /** |
| 3012 | 3186 | * Get the size of a specified image with better error handling. |
@@ -3025,8 +3199,9 @@ discard block |
||
| 3025 | 3199 | $url = str_replace(' ', '%20', $url); |
| 3026 | 3200 | |
| 3027 | 3201 | // Can we pull this from the cache... please please? |
| 3028 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 3029 | - return $temp; |
|
| 3202 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3203 | + return $temp; |
|
| 3204 | + } |
|
| 3030 | 3205 | $t = microtime(); |
| 3031 | 3206 | |
| 3032 | 3207 | // Get the host to pester... |
@@ -3036,12 +3211,10 @@ discard block |
||
| 3036 | 3211 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 3037 | 3212 | { |
| 3038 | 3213 | return false; |
| 3039 | - } |
|
| 3040 | - elseif (!isset($match[1])) |
|
| 3214 | + } elseif (!isset($match[1])) |
|
| 3041 | 3215 | { |
| 3042 | 3216 | $size = @getimagesize($url); |
| 3043 | - } |
|
| 3044 | - else |
|
| 3217 | + } else |
|
| 3045 | 3218 | { |
| 3046 | 3219 | // Try to connect to the server... give it half a second. |
| 3047 | 3220 | $temp = 0; |
@@ -3080,12 +3253,14 @@ discard block |
||
| 3080 | 3253 | } |
| 3081 | 3254 | |
| 3082 | 3255 | // If we didn't get it, we failed. |
| 3083 | - if (!isset($size)) |
|
| 3084 | - $size = false; |
|
| 3256 | + if (!isset($size)) { |
|
| 3257 | + $size = false; |
|
| 3258 | + } |
|
| 3085 | 3259 | |
| 3086 | 3260 | // If this took a long time, we may never have to do it again, but then again we might... |
| 3087 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 3088 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3261 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3262 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3263 | + } |
|
| 3089 | 3264 | |
| 3090 | 3265 | // Didn't work. |
| 3091 | 3266 | return $size; |
@@ -3103,8 +3278,9 @@ discard block |
||
| 3103 | 3278 | |
| 3104 | 3279 | // Under SSI this function can be called more then once. That can cause some problems. |
| 3105 | 3280 | // So only run the function once unless we are forced to run it again. |
| 3106 | - if ($loaded && !$forceload) |
|
| 3107 | - return; |
|
| 3281 | + if ($loaded && !$forceload) { |
|
| 3282 | + return; |
|
| 3283 | + } |
|
| 3108 | 3284 | |
| 3109 | 3285 | $loaded = true; |
| 3110 | 3286 | |
@@ -3116,14 +3292,16 @@ discard block |
||
| 3116 | 3292 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3117 | 3293 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3118 | 3294 | { |
| 3119 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3120 | - continue; |
|
| 3295 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3296 | + continue; |
|
| 3297 | + } |
|
| 3121 | 3298 | |
| 3122 | 3299 | // Clean it up for presentation ;). |
| 3123 | 3300 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3124 | 3301 | } |
| 3125 | - if (!empty($context['news_lines'])) |
|
| 3126 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3302 | + if (!empty($context['news_lines'])) { |
|
| 3303 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3304 | + } |
|
| 3127 | 3305 | |
| 3128 | 3306 | if (!$user_info['is_guest']) |
| 3129 | 3307 | { |
@@ -3132,40 +3310,48 @@ discard block |
||
| 3132 | 3310 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3133 | 3311 | |
| 3134 | 3312 | // Personal message popup... |
| 3135 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3136 | - $context['user']['popup_messages'] = true; |
|
| 3137 | - else |
|
| 3138 | - $context['user']['popup_messages'] = false; |
|
| 3313 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3314 | + $context['user']['popup_messages'] = true; |
|
| 3315 | + } else { |
|
| 3316 | + $context['user']['popup_messages'] = false; |
|
| 3317 | + } |
|
| 3139 | 3318 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3140 | 3319 | |
| 3141 | - if (allowedTo('moderate_forum')) |
|
| 3142 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3320 | + if (allowedTo('moderate_forum')) { |
|
| 3321 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3322 | + } |
|
| 3143 | 3323 | |
| 3144 | 3324 | $context['user']['avatar'] = array(); |
| 3145 | 3325 | |
| 3146 | 3326 | // Check for gravatar first since we might be forcing them... |
| 3147 | 3327 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3148 | 3328 | { |
| 3149 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3150 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3151 | - else |
|
| 3152 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3329 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3330 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3331 | + } else { |
|
| 3332 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3333 | + } |
|
| 3153 | 3334 | } |
| 3154 | 3335 | // Uploaded? |
| 3155 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3156 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3336 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3337 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3338 | + } |
|
| 3157 | 3339 | // Full URL? |
| 3158 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3159 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3340 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3341 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3342 | + } |
|
| 3160 | 3343 | // Otherwise we assume it's server stored. |
| 3161 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3162 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3344 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3345 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3346 | + } |
|
| 3163 | 3347 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3164 | - else |
|
| 3165 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3348 | + else { |
|
| 3349 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3350 | + } |
|
| 3166 | 3351 | |
| 3167 | - if (!empty($context['user']['avatar'])) |
|
| 3168 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3352 | + if (!empty($context['user']['avatar'])) { |
|
| 3353 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3354 | + } |
|
| 3169 | 3355 | |
| 3170 | 3356 | // Figure out how long they've been logged in. |
| 3171 | 3357 | $context['user']['total_time_logged_in'] = array( |
@@ -3173,8 +3359,7 @@ discard block |
||
| 3173 | 3359 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3174 | 3360 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3175 | 3361 | ); |
| 3176 | - } |
|
| 3177 | - else |
|
| 3362 | + } else |
|
| 3178 | 3363 | { |
| 3179 | 3364 | $context['user']['messages'] = 0; |
| 3180 | 3365 | $context['user']['unread_messages'] = 0; |
@@ -3182,12 +3367,14 @@ discard block |
||
| 3182 | 3367 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3183 | 3368 | $context['user']['popup_messages'] = false; |
| 3184 | 3369 | |
| 3185 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3186 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3370 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3371 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3372 | + } |
|
| 3187 | 3373 | |
| 3188 | 3374 | // If we've upgraded recently, go easy on the passwords. |
| 3189 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3190 | - $context['disable_login_hashing'] = true; |
|
| 3375 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3376 | + $context['disable_login_hashing'] = true; |
|
| 3377 | + } |
|
| 3191 | 3378 | } |
| 3192 | 3379 | |
| 3193 | 3380 | // Setup the main menu items. |
@@ -3200,8 +3387,8 @@ discard block |
||
| 3200 | 3387 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3201 | 3388 | |
| 3202 | 3389 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3203 | - if ($context['show_pm_popup']) |
|
| 3204 | - addInlineJavaScript(' |
|
| 3390 | + if ($context['show_pm_popup']) { |
|
| 3391 | + addInlineJavaScript(' |
|
| 3205 | 3392 | jQuery(document).ready(function($) { |
| 3206 | 3393 | new smc_Popup({ |
| 3207 | 3394 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3209,15 +3396,17 @@ discard block |
||
| 3209 | 3396 | icon_class: \'generic_icons mail_new\' |
| 3210 | 3397 | }); |
| 3211 | 3398 | });'); |
| 3399 | + } |
|
| 3212 | 3400 | |
| 3213 | 3401 | // Add a generic "Are you sure?" confirmation message. |
| 3214 | 3402 | addInlineJavaScript(' |
| 3215 | 3403 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3216 | 3404 | |
| 3217 | 3405 | // Now add the capping code for avatars. |
| 3218 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
| 3219 | - addInlineCss(' |
|
| 3406 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
| 3407 | + addInlineCss(' |
|
| 3220 | 3408 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3409 | + } |
|
| 3221 | 3410 | |
| 3222 | 3411 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3223 | 3412 | $context['common_stats']['latest_member'] = array( |
@@ -3234,11 +3423,13 @@ discard block |
||
| 3234 | 3423 | ); |
| 3235 | 3424 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
| 3236 | 3425 | |
| 3237 | - if (empty($settings['theme_version'])) |
|
| 3238 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3426 | + if (empty($settings['theme_version'])) { |
|
| 3427 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3428 | + } |
|
| 3239 | 3429 | |
| 3240 | - if (!isset($context['page_title'])) |
|
| 3241 | - $context['page_title'] = ''; |
|
| 3430 | + if (!isset($context['page_title'])) { |
|
| 3431 | + $context['page_title'] = ''; |
|
| 3432 | + } |
|
| 3242 | 3433 | |
| 3243 | 3434 | // Set some specific vars. |
| 3244 | 3435 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3248,21 +3439,23 @@ discard block |
||
| 3248 | 3439 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3249 | 3440 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3250 | 3441 | |
| 3251 | - if (!empty($context['meta_keywords'])) |
|
| 3252 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3442 | + if (!empty($context['meta_keywords'])) { |
|
| 3443 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3444 | + } |
|
| 3253 | 3445 | |
| 3254 | - if (!empty($context['canonical_url'])) |
|
| 3255 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3446 | + if (!empty($context['canonical_url'])) { |
|
| 3447 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3448 | + } |
|
| 3256 | 3449 | |
| 3257 | - if (!empty($settings['og_image'])) |
|
| 3258 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3450 | + if (!empty($settings['og_image'])) { |
|
| 3451 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3452 | + } |
|
| 3259 | 3453 | |
| 3260 | 3454 | if (!empty($context['meta_description'])) |
| 3261 | 3455 | { |
| 3262 | 3456 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3263 | 3457 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3264 | - } |
|
| 3265 | - else |
|
| 3458 | + } else |
|
| 3266 | 3459 | { |
| 3267 | 3460 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3268 | 3461 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3287,8 +3480,9 @@ discard block |
||
| 3287 | 3480 | $memory_needed = memoryReturnBytes($needed); |
| 3288 | 3481 | |
| 3289 | 3482 | // should we account for how much is currently being used? |
| 3290 | - if ($in_use) |
|
| 3291 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3483 | + if ($in_use) { |
|
| 3484 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3485 | + } |
|
| 3292 | 3486 | |
| 3293 | 3487 | // if more is needed, request it |
| 3294 | 3488 | if ($memory_current < $memory_needed) |
@@ -3311,8 +3505,9 @@ discard block |
||
| 3311 | 3505 | */ |
| 3312 | 3506 | function memoryReturnBytes($val) |
| 3313 | 3507 | { |
| 3314 | - if (is_integer($val)) |
|
| 3315 | - return $val; |
|
| 3508 | + if (is_integer($val)) { |
|
| 3509 | + return $val; |
|
| 3510 | + } |
|
| 3316 | 3511 | |
| 3317 | 3512 | // Separate the number from the designator |
| 3318 | 3513 | $val = trim($val); |
@@ -3348,10 +3543,11 @@ discard block |
||
| 3348 | 3543 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3349 | 3544 | |
| 3350 | 3545 | // Are we debugging the template/html content? |
| 3351 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3352 | - header('Content-Type: application/xhtml+xml'); |
|
| 3353 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3354 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3546 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3547 | + header('Content-Type: application/xhtml+xml'); |
|
| 3548 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3549 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3550 | + } |
|
| 3355 | 3551 | } |
| 3356 | 3552 | |
| 3357 | 3553 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3360,8 +3556,9 @@ discard block |
||
| 3360 | 3556 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3361 | 3557 | { |
| 3362 | 3558 | $position = array_search('body', $context['template_layers']); |
| 3363 | - if ($position === false) |
|
| 3364 | - $position = array_search('main', $context['template_layers']); |
|
| 3559 | + if ($position === false) { |
|
| 3560 | + $position = array_search('main', $context['template_layers']); |
|
| 3561 | + } |
|
| 3365 | 3562 | |
| 3366 | 3563 | if ($position !== false) |
| 3367 | 3564 | { |
@@ -3389,23 +3586,25 @@ discard block |
||
| 3389 | 3586 | |
| 3390 | 3587 | foreach ($securityFiles as $i => $securityFile) |
| 3391 | 3588 | { |
| 3392 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3393 | - unset($securityFiles[$i]); |
|
| 3589 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3590 | + unset($securityFiles[$i]); |
|
| 3591 | + } |
|
| 3394 | 3592 | } |
| 3395 | 3593 | |
| 3396 | 3594 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3397 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3398 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3399 | - |
|
| 3400 | - else |
|
| 3401 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3595 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3596 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3597 | + } else { |
|
| 3598 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3599 | + } |
|
| 3402 | 3600 | |
| 3403 | 3601 | secureDirectory($path, true); |
| 3404 | 3602 | secureDirectory($cachedir); |
| 3405 | 3603 | |
| 3406 | 3604 | // If agreement is enabled, at least the english version shall exists |
| 3407 | - if ($modSettings['requireAgreement']) |
|
| 3408 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3605 | + if ($modSettings['requireAgreement']) { |
|
| 3606 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3607 | + } |
|
| 3409 | 3608 | |
| 3410 | 3609 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3411 | 3610 | { |
@@ -3420,18 +3619,21 @@ discard block |
||
| 3420 | 3619 | echo ' |
| 3421 | 3620 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3422 | 3621 | |
| 3423 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3424 | - echo ' |
|
| 3622 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3623 | + echo ' |
|
| 3425 | 3624 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3625 | + } |
|
| 3426 | 3626 | } |
| 3427 | 3627 | |
| 3428 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3429 | - echo ' |
|
| 3628 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3629 | + echo ' |
|
| 3430 | 3630 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3631 | + } |
|
| 3431 | 3632 | |
| 3432 | - if (!empty($agreement)) |
|
| 3433 | - echo ' |
|
| 3633 | + if (!empty($agreement)) { |
|
| 3634 | + echo ' |
|
| 3434 | 3635 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3636 | + } |
|
| 3435 | 3637 | |
| 3436 | 3638 | echo ' |
| 3437 | 3639 | </p> |
@@ -3446,16 +3648,18 @@ discard block |
||
| 3446 | 3648 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3447 | 3649 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3448 | 3650 | |
| 3449 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3450 | - echo ' |
|
| 3651 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3652 | + echo ' |
|
| 3451 | 3653 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3654 | + } |
|
| 3452 | 3655 | |
| 3453 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3454 | - echo ' |
|
| 3656 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3657 | + echo ' |
|
| 3455 | 3658 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3456 | - else |
|
| 3457 | - echo ' |
|
| 3659 | + } else { |
|
| 3660 | + echo ' |
|
| 3458 | 3661 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3662 | + } |
|
| 3459 | 3663 | |
| 3460 | 3664 | echo ' |
| 3461 | 3665 | </div>'; |
@@ -3471,8 +3675,9 @@ discard block |
||
| 3471 | 3675 | global $forum_copyright, $software_year, $forum_version; |
| 3472 | 3676 | |
| 3473 | 3677 | // Don't display copyright for things like SSI. |
| 3474 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3475 | - return; |
|
| 3678 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3679 | + return; |
|
| 3680 | + } |
|
| 3476 | 3681 | |
| 3477 | 3682 | // Put in the version... |
| 3478 | 3683 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3490,9 +3695,10 @@ discard block |
||
| 3490 | 3695 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
| 3491 | 3696 | $context['load_queries'] = $db_count; |
| 3492 | 3697 | |
| 3493 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3494 | - loadSubTemplate($layer . '_below', true); |
|
| 3495 | -} |
|
| 3698 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3699 | + loadSubTemplate($layer . '_below', true); |
|
| 3700 | + } |
|
| 3701 | + } |
|
| 3496 | 3702 | |
| 3497 | 3703 | /** |
| 3498 | 3704 | * Output the Javascript files |
@@ -3523,8 +3729,7 @@ discard block |
||
| 3523 | 3729 | { |
| 3524 | 3730 | echo ' |
| 3525 | 3731 | var ', $key, ';'; |
| 3526 | - } |
|
| 3527 | - else |
|
| 3732 | + } else |
|
| 3528 | 3733 | { |
| 3529 | 3734 | echo ' |
| 3530 | 3735 | var ', $key, ' = ', $value, ';'; |
@@ -3539,26 +3744,27 @@ discard block |
||
| 3539 | 3744 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3540 | 3745 | { |
| 3541 | 3746 | // Last minute call! allow theme authors to disable single files. |
| 3542 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3543 | - continue; |
|
| 3747 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3748 | + continue; |
|
| 3749 | + } |
|
| 3544 | 3750 | |
| 3545 | 3751 | // By default all files don't get minimized unless the file explicitly says so! |
| 3546 | 3752 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3547 | 3753 | { |
| 3548 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
| 3549 | - $toMinifyDefer[] = $js_file; |
|
| 3550 | - |
|
| 3551 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
| 3552 | - $toMinify[] = $js_file; |
|
| 3754 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
| 3755 | + $toMinifyDefer[] = $js_file; |
|
| 3756 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
| 3757 | + $toMinify[] = $js_file; |
|
| 3758 | + } |
|
| 3553 | 3759 | |
| 3554 | 3760 | // Grab a random seed. |
| 3555 | - if (!isset($minSeed)) |
|
| 3556 | - $minSeed = $js_file['options']['seed']; |
|
| 3557 | - } |
|
| 3558 | - |
|
| 3559 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
| 3560 | - echo ' |
|
| 3761 | + if (!isset($minSeed)) { |
|
| 3762 | + $minSeed = $js_file['options']['seed']; |
|
| 3763 | + } |
|
| 3764 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
| 3765 | + echo ' |
|
| 3561 | 3766 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3767 | + } |
|
| 3562 | 3768 | } |
| 3563 | 3769 | |
| 3564 | 3770 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3566,14 +3772,14 @@ discard block |
||
| 3566 | 3772 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
| 3567 | 3773 | |
| 3568 | 3774 | // Minify process couldn't work, print each individual files. |
| 3569 | - if (!empty($result) && is_array($result)) |
|
| 3570 | - foreach ($result as $minFailedFile) |
|
| 3775 | + if (!empty($result) && is_array($result)) { |
|
| 3776 | + foreach ($result as $minFailedFile) |
|
| 3571 | 3777 | echo ' |
| 3572 | 3778 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3573 | - |
|
| 3574 | - else |
|
| 3575 | - echo ' |
|
| 3779 | + } else { |
|
| 3780 | + echo ' |
|
| 3576 | 3781 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
| 3782 | + } |
|
| 3577 | 3783 | } |
| 3578 | 3784 | |
| 3579 | 3785 | // Inline JavaScript - Actually useful some times! |
@@ -3584,8 +3790,9 @@ discard block |
||
| 3584 | 3790 | echo ' |
| 3585 | 3791 | <script>'; |
| 3586 | 3792 | |
| 3587 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3588 | - echo $js_code; |
|
| 3793 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 3794 | + echo $js_code; |
|
| 3795 | + } |
|
| 3589 | 3796 | |
| 3590 | 3797 | echo ' |
| 3591 | 3798 | </script>'; |
@@ -3596,8 +3803,9 @@ discard block |
||
| 3596 | 3803 | echo ' |
| 3597 | 3804 | <script>'; |
| 3598 | 3805 | |
| 3599 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3600 | - echo $js_code; |
|
| 3806 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 3807 | + echo $js_code; |
|
| 3808 | + } |
|
| 3601 | 3809 | |
| 3602 | 3810 | echo ' |
| 3603 | 3811 | </script>'; |
@@ -3622,8 +3830,9 @@ discard block |
||
| 3622 | 3830 | foreach ($context['css_files'] as $id => $file) |
| 3623 | 3831 | { |
| 3624 | 3832 | // Last minute call! allow theme authors to disable single files. |
| 3625 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3626 | - continue; |
|
| 3833 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3834 | + continue; |
|
| 3835 | + } |
|
| 3627 | 3836 | |
| 3628 | 3837 | // By default all files don't get minimized unless the file explicitly says so! |
| 3629 | 3838 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3631,12 +3840,12 @@ discard block |
||
| 3631 | 3840 | $toMinify[] = $file; |
| 3632 | 3841 | |
| 3633 | 3842 | // Grab a random seed. |
| 3634 | - if (!isset($minSeed)) |
|
| 3635 | - $minSeed = $file['options']['seed']; |
|
| 3843 | + if (!isset($minSeed)) { |
|
| 3844 | + $minSeed = $file['options']['seed']; |
|
| 3845 | + } |
|
| 3846 | + } else { |
|
| 3847 | + $normal[] = $file['fileUrl']; |
|
| 3636 | 3848 | } |
| 3637 | - |
|
| 3638 | - else |
|
| 3639 | - $normal[] = $file['fileUrl']; |
|
| 3640 | 3849 | } |
| 3641 | 3850 | |
| 3642 | 3851 | if (!empty($toMinify)) |
@@ -3644,28 +3853,30 @@ discard block |
||
| 3644 | 3853 | $result = custMinify($toMinify, 'css'); |
| 3645 | 3854 | |
| 3646 | 3855 | // Minify process couldn't work, print each individual files. |
| 3647 | - if (!empty($result) && is_array($result)) |
|
| 3648 | - foreach ($result as $minFailedFile) |
|
| 3856 | + if (!empty($result) && is_array($result)) { |
|
| 3857 | + foreach ($result as $minFailedFile) |
|
| 3649 | 3858 | echo ' |
| 3650 | 3859 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
| 3651 | - |
|
| 3652 | - else |
|
| 3653 | - echo ' |
|
| 3860 | + } else { |
|
| 3861 | + echo ' |
|
| 3654 | 3862 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
| 3863 | + } |
|
| 3655 | 3864 | } |
| 3656 | 3865 | |
| 3657 | 3866 | // Print the rest after the minified files. |
| 3658 | - if (!empty($normal)) |
|
| 3659 | - foreach ($normal as $nf) |
|
| 3867 | + if (!empty($normal)) { |
|
| 3868 | + foreach ($normal as $nf) |
|
| 3660 | 3869 | echo ' |
| 3661 | 3870 | <link rel="stylesheet" href="', $nf ,'">'; |
| 3871 | + } |
|
| 3662 | 3872 | |
| 3663 | 3873 | if ($db_show_debug === true) |
| 3664 | 3874 | { |
| 3665 | 3875 | // Try to keep only what's useful. |
| 3666 | 3876 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3667 | - foreach ($context['css_files'] as $file) |
|
| 3668 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3877 | + foreach ($context['css_files'] as $file) { |
|
| 3878 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3879 | + } |
|
| 3669 | 3880 | } |
| 3670 | 3881 | |
| 3671 | 3882 | if (!empty($context['css_header'])) |
@@ -3673,9 +3884,10 @@ discard block |
||
| 3673 | 3884 | echo ' |
| 3674 | 3885 | <style>'; |
| 3675 | 3886 | |
| 3676 | - foreach ($context['css_header'] as $css) |
|
| 3677 | - echo $css .' |
|
| 3887 | + foreach ($context['css_header'] as $css) { |
|
| 3888 | + echo $css .' |
|
| 3678 | 3889 | '; |
| 3890 | + } |
|
| 3679 | 3891 | |
| 3680 | 3892 | echo' |
| 3681 | 3893 | </style>'; |
@@ -3699,15 +3911,17 @@ discard block |
||
| 3699 | 3911 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3700 | 3912 | $data = !empty($data) ? $data : false; |
| 3701 | 3913 | |
| 3702 | - if (empty($type) || empty($data)) |
|
| 3703 | - return false; |
|
| 3914 | + if (empty($type) || empty($data)) { |
|
| 3915 | + return false; |
|
| 3916 | + } |
|
| 3704 | 3917 | |
| 3705 | 3918 | // Did we already did this? |
| 3706 | 3919 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
| 3707 | 3920 | |
| 3708 | 3921 | // Already done? |
| 3709 | - if (!empty($toCache)) |
|
| 3710 | - return true; |
|
| 3922 | + if (!empty($toCache)) { |
|
| 3923 | + return true; |
|
| 3924 | + } |
|
| 3711 | 3925 | |
| 3712 | 3926 | // No namespaces, sorry! |
| 3713 | 3927 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3789,8 +4003,9 @@ discard block |
||
| 3789 | 4003 | global $modSettings, $smcFunc; |
| 3790 | 4004 | |
| 3791 | 4005 | // Just make up a nice hash... |
| 3792 | - if ($new) |
|
| 3793 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 4006 | + if ($new) { |
|
| 4007 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 4008 | + } |
|
| 3794 | 4009 | |
| 3795 | 4010 | // Just make sure that attachment id is only a int |
| 3796 | 4011 | $attachment_id = (int) $attachment_id; |
@@ -3807,23 +4022,25 @@ discard block |
||
| 3807 | 4022 | 'id_attach' => $attachment_id, |
| 3808 | 4023 | )); |
| 3809 | 4024 | |
| 3810 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 3811 | - return false; |
|
| 4025 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 4026 | + return false; |
|
| 4027 | + } |
|
| 3812 | 4028 | |
| 3813 | 4029 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 3814 | 4030 | $smcFunc['db_free_result']($request); |
| 3815 | 4031 | } |
| 3816 | 4032 | |
| 3817 | 4033 | // Still no hash? mmm... |
| 3818 | - if (empty($file_hash)) |
|
| 3819 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4034 | + if (empty($file_hash)) { |
|
| 4035 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4036 | + } |
|
| 3820 | 4037 | |
| 3821 | 4038 | // Are we using multiple directories? |
| 3822 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
| 3823 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3824 | - |
|
| 3825 | - else |
|
| 3826 | - $path = $modSettings['attachmentUploadDir']; |
|
| 4039 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
| 4040 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4041 | + } else { |
|
| 4042 | + $path = $modSettings['attachmentUploadDir']; |
|
| 4043 | + } |
|
| 3827 | 4044 | |
| 3828 | 4045 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 3829 | 4046 | } |
@@ -3838,8 +4055,9 @@ discard block |
||
| 3838 | 4055 | function ip2range($fullip) |
| 3839 | 4056 | { |
| 3840 | 4057 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 3841 | - if ($fullip == 'unknown') |
|
| 3842 | - $fullip = '255.255.255.255'; |
|
| 4058 | + if ($fullip == 'unknown') { |
|
| 4059 | + $fullip = '255.255.255.255'; |
|
| 4060 | + } |
|
| 3843 | 4061 | |
| 3844 | 4062 | $ip_parts = explode('-', $fullip); |
| 3845 | 4063 | $ip_array = array(); |
@@ -3863,10 +4081,11 @@ discard block |
||
| 3863 | 4081 | $ip_array['low'] = $ip_parts[0]; |
| 3864 | 4082 | $ip_array['high'] = $ip_parts[1]; |
| 3865 | 4083 | return $ip_array; |
| 3866 | - } |
|
| 3867 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 4084 | + } elseif (count($ip_parts) == 2) { |
|
| 4085 | + // if ip 22.22.*-22.22.* |
|
| 3868 | 4086 | { |
| 3869 | 4087 | $valid_low = isValidIP($ip_parts[0]); |
| 4088 | + } |
|
| 3870 | 4089 | $valid_high = isValidIP($ip_parts[1]); |
| 3871 | 4090 | $count = 0; |
| 3872 | 4091 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3881,7 +4100,9 @@ discard block |
||
| 3881 | 4100 | $ip_parts[0] .= $mode . $min; |
| 3882 | 4101 | $valid_low = isValidIP($ip_parts[0]); |
| 3883 | 4102 | $count++; |
| 3884 | - if ($count > 9) break; |
|
| 4103 | + if ($count > 9) { |
|
| 4104 | + break; |
|
| 4105 | + } |
|
| 3885 | 4106 | } |
| 3886 | 4107 | } |
| 3887 | 4108 | |
@@ -3895,7 +4116,9 @@ discard block |
||
| 3895 | 4116 | $ip_parts[1] .= $mode . $max; |
| 3896 | 4117 | $valid_high = isValidIP($ip_parts[1]); |
| 3897 | 4118 | $count++; |
| 3898 | - if ($count > 9) break; |
|
| 4119 | + if ($count > 9) { |
|
| 4120 | + break; |
|
| 4121 | + } |
|
| 3899 | 4122 | } |
| 3900 | 4123 | } |
| 3901 | 4124 | |
@@ -3920,46 +4143,54 @@ discard block |
||
| 3920 | 4143 | { |
| 3921 | 4144 | global $modSettings; |
| 3922 | 4145 | |
| 3923 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 3924 | - return $host; |
|
| 4146 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4147 | + return $host; |
|
| 4148 | + } |
|
| 3925 | 4149 | $t = microtime(); |
| 3926 | 4150 | |
| 3927 | 4151 | // Try the Linux host command, perhaps? |
| 3928 | 4152 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 3929 | 4153 | { |
| 3930 | - if (!isset($modSettings['host_to_dis'])) |
|
| 3931 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 3932 | - else |
|
| 3933 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4154 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4155 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4156 | + } else { |
|
| 4157 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4158 | + } |
|
| 3934 | 4159 | |
| 3935 | 4160 | // Did host say it didn't find anything? |
| 3936 | - if (strpos($test, 'not found') !== false) |
|
| 3937 | - $host = ''; |
|
| 4161 | + if (strpos($test, 'not found') !== false) { |
|
| 4162 | + $host = ''; |
|
| 4163 | + } |
|
| 3938 | 4164 | // Invalid server option? |
| 3939 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 3940 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4165 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4166 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4167 | + } |
|
| 3941 | 4168 | // Maybe it found something, after all? |
| 3942 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 3943 | - $host = $match[1]; |
|
| 4169 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4170 | + $host = $match[1]; |
|
| 4171 | + } |
|
| 3944 | 4172 | } |
| 3945 | 4173 | |
| 3946 | 4174 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 3947 | 4175 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 3948 | 4176 | { |
| 3949 | 4177 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 3950 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 3951 | - $host = ''; |
|
| 3952 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 3953 | - $host = $match[1]; |
|
| 4178 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4179 | + $host = ''; |
|
| 4180 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4181 | + $host = $match[1]; |
|
| 4182 | + } |
|
| 3954 | 4183 | } |
| 3955 | 4184 | |
| 3956 | 4185 | // This is the last try :/. |
| 3957 | - if (!isset($host) || $host === false) |
|
| 3958 | - $host = @gethostbyaddr($ip); |
|
| 4186 | + if (!isset($host) || $host === false) { |
|
| 4187 | + $host = @gethostbyaddr($ip); |
|
| 4188 | + } |
|
| 3959 | 4189 | |
| 3960 | 4190 | // It took a long time, so let's cache it! |
| 3961 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 3962 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4191 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4192 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4193 | + } |
|
| 3963 | 4194 | |
| 3964 | 4195 | return $host; |
| 3965 | 4196 | } |
@@ -3995,20 +4226,21 @@ discard block |
||
| 3995 | 4226 | { |
| 3996 | 4227 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 3997 | 4228 | $total = 0; |
| 3998 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 3999 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4229 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4230 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4231 | + } |
|
| 4000 | 4232 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 4001 | 4233 | } |
| 4002 | 4234 | } |
| 4003 | 4235 | return array_unique($returned_ints); |
| 4004 | - } |
|
| 4005 | - else |
|
| 4236 | + } else |
|
| 4006 | 4237 | { |
| 4007 | 4238 | // Trim characters before and after and add slashes for database insertion. |
| 4008 | 4239 | $returned_words = array(); |
| 4009 | - foreach ($words as $word) |
|
| 4010 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4240 | + foreach ($words as $word) { |
|
| 4241 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 4011 | 4242 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4243 | + } |
|
| 4012 | 4244 | |
| 4013 | 4245 | // Filter out all words that occur more than once. |
| 4014 | 4246 | return array_unique($returned_words); |
@@ -4030,16 +4262,18 @@ discard block |
||
| 4030 | 4262 | global $settings, $txt; |
| 4031 | 4263 | |
| 4032 | 4264 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 4033 | - if (function_exists('template_create_button') && !$force_use) |
|
| 4034 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4265 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4266 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4267 | + } |
|
| 4035 | 4268 | |
| 4036 | - if (!$settings['use_image_buttons']) |
|
| 4037 | - return $txt[$alt]; |
|
| 4038 | - elseif (!empty($settings['use_buttons'])) |
|
| 4039 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4040 | - else |
|
| 4041 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4042 | -} |
|
| 4269 | + if (!$settings['use_image_buttons']) { |
|
| 4270 | + return $txt[$alt]; |
|
| 4271 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4272 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4273 | + } else { |
|
| 4274 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4275 | + } |
|
| 4276 | + } |
|
| 4043 | 4277 | |
| 4044 | 4278 | /** |
| 4045 | 4279 | * Sets up all of the top menu buttons |
@@ -4082,9 +4316,10 @@ discard block |
||
| 4082 | 4316 | var user_menus = new smc_PopupMenu(); |
| 4083 | 4317 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4084 | 4318 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 4085 | - if ($context['allow_pm']) |
|
| 4086 | - addInlineJavaScript(' |
|
| 4319 | + if ($context['allow_pm']) { |
|
| 4320 | + addInlineJavaScript(' |
|
| 4087 | 4321 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4322 | + } |
|
| 4088 | 4323 | |
| 4089 | 4324 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 4090 | 4325 | { |
@@ -4244,88 +4479,96 @@ discard block |
||
| 4244 | 4479 | |
| 4245 | 4480 | // Now we put the buttons in the context so the theme can use them. |
| 4246 | 4481 | $menu_buttons = array(); |
| 4247 | - foreach ($buttons as $act => $button) |
|
| 4248 | - if (!empty($button['show'])) |
|
| 4482 | + foreach ($buttons as $act => $button) { |
|
| 4483 | + if (!empty($button['show'])) |
|
| 4249 | 4484 | { |
| 4250 | 4485 | $button['active_button'] = false; |
| 4486 | + } |
|
| 4251 | 4487 | |
| 4252 | 4488 | // This button needs some action. |
| 4253 | - if (isset($button['action_hook'])) |
|
| 4254 | - $needs_action_hook = true; |
|
| 4489 | + if (isset($button['action_hook'])) { |
|
| 4490 | + $needs_action_hook = true; |
|
| 4491 | + } |
|
| 4255 | 4492 | |
| 4256 | 4493 | // Make sure the last button truly is the last button. |
| 4257 | 4494 | if (!empty($button['is_last'])) |
| 4258 | 4495 | { |
| 4259 | - if (isset($last_button)) |
|
| 4260 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4496 | + if (isset($last_button)) { |
|
| 4497 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4498 | + } |
|
| 4261 | 4499 | $last_button = $act; |
| 4262 | 4500 | } |
| 4263 | 4501 | |
| 4264 | 4502 | // Go through the sub buttons if there are any. |
| 4265 | - if (!empty($button['sub_buttons'])) |
|
| 4266 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4503 | + if (!empty($button['sub_buttons'])) { |
|
| 4504 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4267 | 4505 | { |
| 4268 | 4506 | if (empty($subbutton['show'])) |
| 4269 | 4507 | unset($button['sub_buttons'][$key]); |
| 4508 | + } |
|
| 4270 | 4509 | |
| 4271 | 4510 | // 2nd level sub buttons next... |
| 4272 | 4511 | if (!empty($subbutton['sub_buttons'])) |
| 4273 | 4512 | { |
| 4274 | 4513 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4275 | 4514 | { |
| 4276 | - if (empty($sub_button2['show'])) |
|
| 4277 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4515 | + if (empty($sub_button2['show'])) { |
|
| 4516 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4517 | + } |
|
| 4278 | 4518 | } |
| 4279 | 4519 | } |
| 4280 | 4520 | } |
| 4281 | 4521 | |
| 4282 | 4522 | // Does this button have its own icon? |
| 4283 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4284 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4285 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4286 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4287 | - elseif (isset($button['icon'])) |
|
| 4288 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4289 | - else |
|
| 4290 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4523 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4524 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4525 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4526 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4527 | + } elseif (isset($button['icon'])) { |
|
| 4528 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4529 | + } else { |
|
| 4530 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4531 | + } |
|
| 4291 | 4532 | |
| 4292 | 4533 | $menu_buttons[$act] = $button; |
| 4293 | 4534 | } |
| 4294 | 4535 | |
| 4295 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4296 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4536 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4537 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4538 | + } |
|
| 4297 | 4539 | } |
| 4298 | 4540 | |
| 4299 | 4541 | $context['menu_buttons'] = $menu_buttons; |
| 4300 | 4542 | |
| 4301 | 4543 | // Logging out requires the session id in the url. |
| 4302 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4303 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4544 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4545 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4546 | + } |
|
| 4304 | 4547 | |
| 4305 | 4548 | // Figure out which action we are doing so we can set the active tab. |
| 4306 | 4549 | // Default to home. |
| 4307 | 4550 | $current_action = 'home'; |
| 4308 | 4551 | |
| 4309 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4310 | - $current_action = $context['current_action']; |
|
| 4311 | - elseif ($context['current_action'] == 'search2') |
|
| 4312 | - $current_action = 'search'; |
|
| 4313 | - elseif ($context['current_action'] == 'theme') |
|
| 4314 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4315 | - elseif ($context['current_action'] == 'register2') |
|
| 4316 | - $current_action = 'register'; |
|
| 4317 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4318 | - $current_action = 'login'; |
|
| 4319 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4320 | - $current_action = 'moderate'; |
|
| 4552 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4553 | + $current_action = $context['current_action']; |
|
| 4554 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4555 | + $current_action = 'search'; |
|
| 4556 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4557 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4558 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4559 | + $current_action = 'register'; |
|
| 4560 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4561 | + $current_action = 'login'; |
|
| 4562 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4563 | + $current_action = 'moderate'; |
|
| 4564 | + } |
|
| 4321 | 4565 | |
| 4322 | 4566 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4323 | 4567 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4324 | 4568 | { |
| 4325 | 4569 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4326 | 4570 | $context[$current_action] = true; |
| 4327 | - } |
|
| 4328 | - elseif ($context['current_action'] == 'pm') |
|
| 4571 | + } elseif ($context['current_action'] == 'pm') |
|
| 4329 | 4572 | { |
| 4330 | 4573 | $current_action = 'self_pm'; |
| 4331 | 4574 | $context['self_pm'] = true; |
@@ -4366,12 +4609,14 @@ discard block |
||
| 4366 | 4609 | } |
| 4367 | 4610 | |
| 4368 | 4611 | // Not all actions are simple. |
| 4369 | - if (!empty($needs_action_hook)) |
|
| 4370 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4612 | + if (!empty($needs_action_hook)) { |
|
| 4613 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4614 | + } |
|
| 4371 | 4615 | |
| 4372 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4373 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4374 | -} |
|
| 4616 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4617 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4618 | + } |
|
| 4619 | + } |
|
| 4375 | 4620 | |
| 4376 | 4621 | /** |
| 4377 | 4622 | * Generate a random seed and ensure it's stored in settings. |
@@ -4395,30 +4640,35 @@ discard block |
||
| 4395 | 4640 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4396 | 4641 | global $context, $txt; |
| 4397 | 4642 | |
| 4398 | - if ($db_show_debug === true) |
|
| 4399 | - $context['debug']['hooks'][] = $hook; |
|
| 4643 | + if ($db_show_debug === true) { |
|
| 4644 | + $context['debug']['hooks'][] = $hook; |
|
| 4645 | + } |
|
| 4400 | 4646 | |
| 4401 | 4647 | // Need to have some control. |
| 4402 | - if (!isset($context['instances'])) |
|
| 4403 | - $context['instances'] = array(); |
|
| 4648 | + if (!isset($context['instances'])) { |
|
| 4649 | + $context['instances'] = array(); |
|
| 4650 | + } |
|
| 4404 | 4651 | |
| 4405 | 4652 | $results = array(); |
| 4406 | - if (empty($modSettings[$hook])) |
|
| 4407 | - return $results; |
|
| 4653 | + if (empty($modSettings[$hook])) { |
|
| 4654 | + return $results; |
|
| 4655 | + } |
|
| 4408 | 4656 | |
| 4409 | 4657 | $functions = explode(',', $modSettings[$hook]); |
| 4410 | 4658 | // Loop through each function. |
| 4411 | 4659 | foreach ($functions as $function) |
| 4412 | 4660 | { |
| 4413 | 4661 | // Hook has been marked as "disabled". Skip it! |
| 4414 | - if (strpos($function, '!') !== false) |
|
| 4415 | - continue; |
|
| 4662 | + if (strpos($function, '!') !== false) { |
|
| 4663 | + continue; |
|
| 4664 | + } |
|
| 4416 | 4665 | |
| 4417 | 4666 | $call = call_helper($function, true); |
| 4418 | 4667 | |
| 4419 | 4668 | // Is it valid? |
| 4420 | - if (!empty($call)) |
|
| 4421 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 4669 | + if (!empty($call)) { |
|
| 4670 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 4671 | + } |
|
| 4422 | 4672 | |
| 4423 | 4673 | // Whatever it was suppose to call, it failed :( |
| 4424 | 4674 | elseif (!empty($function)) |
@@ -4434,8 +4684,9 @@ discard block |
||
| 4434 | 4684 | } |
| 4435 | 4685 | |
| 4436 | 4686 | // "Assume" the file resides on $boarddir somewhere... |
| 4437 | - else |
|
| 4438 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4687 | + else { |
|
| 4688 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4689 | + } |
|
| 4439 | 4690 | } |
| 4440 | 4691 | } |
| 4441 | 4692 | |
@@ -4457,12 +4708,14 @@ discard block |
||
| 4457 | 4708 | global $smcFunc, $modSettings; |
| 4458 | 4709 | |
| 4459 | 4710 | // Any objects? |
| 4460 | - if ($object) |
|
| 4461 | - $function = $function . '#'; |
|
| 4711 | + if ($object) { |
|
| 4712 | + $function = $function . '#'; |
|
| 4713 | + } |
|
| 4462 | 4714 | |
| 4463 | 4715 | // Any files to load? |
| 4464 | - if (!empty($file) && is_string($file)) |
|
| 4465 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4716 | + if (!empty($file) && is_string($file)) { |
|
| 4717 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4718 | + } |
|
| 4466 | 4719 | |
| 4467 | 4720 | // Get the correct string. |
| 4468 | 4721 | $integration_call = $function; |
@@ -4484,13 +4737,14 @@ discard block |
||
| 4484 | 4737 | if (!empty($current_functions)) |
| 4485 | 4738 | { |
| 4486 | 4739 | $current_functions = explode(',', $current_functions); |
| 4487 | - if (in_array($integration_call, $current_functions)) |
|
| 4488 | - return; |
|
| 4740 | + if (in_array($integration_call, $current_functions)) { |
|
| 4741 | + return; |
|
| 4742 | + } |
|
| 4489 | 4743 | |
| 4490 | 4744 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 4745 | + } else { |
|
| 4746 | + $permanent_functions = array($integration_call); |
|
| 4491 | 4747 | } |
| 4492 | - else |
|
| 4493 | - $permanent_functions = array($integration_call); |
|
| 4494 | 4748 | |
| 4495 | 4749 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4496 | 4750 | } |
@@ -4499,8 +4753,9 @@ discard block |
||
| 4499 | 4753 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4500 | 4754 | |
| 4501 | 4755 | // Do nothing, if it's already there. |
| 4502 | - if (in_array($integration_call, $functions)) |
|
| 4503 | - return; |
|
| 4756 | + if (in_array($integration_call, $functions)) { |
|
| 4757 | + return; |
|
| 4758 | + } |
|
| 4504 | 4759 | |
| 4505 | 4760 | $functions[] = $integration_call; |
| 4506 | 4761 | $modSettings[$hook] = implode(',', $functions); |
@@ -4523,12 +4778,14 @@ discard block |
||
| 4523 | 4778 | global $smcFunc, $modSettings; |
| 4524 | 4779 | |
| 4525 | 4780 | // Any objects? |
| 4526 | - if ($object) |
|
| 4527 | - $function = $function . '#'; |
|
| 4781 | + if ($object) { |
|
| 4782 | + $function = $function . '#'; |
|
| 4783 | + } |
|
| 4528 | 4784 | |
| 4529 | 4785 | // Any files to load? |
| 4530 | - if (!empty($file) && is_string($file)) |
|
| 4531 | - $function = $file . '|' . $function; |
|
| 4786 | + if (!empty($file) && is_string($file)) { |
|
| 4787 | + $function = $file . '|' . $function; |
|
| 4788 | + } |
|
| 4532 | 4789 | |
| 4533 | 4790 | // Get the correct string. |
| 4534 | 4791 | $integration_call = $function; |
@@ -4549,16 +4806,18 @@ discard block |
||
| 4549 | 4806 | { |
| 4550 | 4807 | $current_functions = explode(',', $current_functions); |
| 4551 | 4808 | |
| 4552 | - if (in_array($integration_call, $current_functions)) |
|
| 4553 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4809 | + if (in_array($integration_call, $current_functions)) { |
|
| 4810 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4811 | + } |
|
| 4554 | 4812 | } |
| 4555 | 4813 | |
| 4556 | 4814 | // Turn the function list into something usable. |
| 4557 | 4815 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4558 | 4816 | |
| 4559 | 4817 | // You can only remove it if it's available. |
| 4560 | - if (!in_array($integration_call, $functions)) |
|
| 4561 | - return; |
|
| 4818 | + if (!in_array($integration_call, $functions)) { |
|
| 4819 | + return; |
|
| 4820 | + } |
|
| 4562 | 4821 | |
| 4563 | 4822 | $functions = array_diff($functions, array($integration_call)); |
| 4564 | 4823 | $modSettings[$hook] = implode(',', $functions); |
@@ -4579,17 +4838,20 @@ discard block |
||
| 4579 | 4838 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4580 | 4839 | |
| 4581 | 4840 | // Really? |
| 4582 | - if (empty($string)) |
|
| 4583 | - return false; |
|
| 4841 | + if (empty($string)) { |
|
| 4842 | + return false; |
|
| 4843 | + } |
|
| 4584 | 4844 | |
| 4585 | 4845 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4586 | 4846 | // A closure? should be a callable one. |
| 4587 | - if (is_array($string) || $string instanceof Closure) |
|
| 4588 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4847 | + if (is_array($string) || $string instanceof Closure) { |
|
| 4848 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4849 | + } |
|
| 4589 | 4850 | |
| 4590 | 4851 | // No full objects, sorry! pass a method or a property instead! |
| 4591 | - if (is_object($string)) |
|
| 4592 | - return false; |
|
| 4852 | + if (is_object($string)) { |
|
| 4853 | + return false; |
|
| 4854 | + } |
|
| 4593 | 4855 | |
| 4594 | 4856 | // Stay vitaminized my friends... |
| 4595 | 4857 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4598,8 +4860,9 @@ discard block |
||
| 4598 | 4860 | $string = load_file($string); |
| 4599 | 4861 | |
| 4600 | 4862 | // Loaded file failed |
| 4601 | - if (empty($string)) |
|
| 4602 | - return false; |
|
| 4863 | + if (empty($string)) { |
|
| 4864 | + return false; |
|
| 4865 | + } |
|
| 4603 | 4866 | |
| 4604 | 4867 | // Found a method. |
| 4605 | 4868 | if (strpos($string, '::') !== false) |
@@ -4620,8 +4883,9 @@ discard block |
||
| 4620 | 4883 | // Add another one to the list. |
| 4621 | 4884 | if ($db_show_debug === true) |
| 4622 | 4885 | { |
| 4623 | - if (!isset($context['debug']['instances'])) |
|
| 4624 | - $context['debug']['instances'] = array(); |
|
| 4886 | + if (!isset($context['debug']['instances'])) { |
|
| 4887 | + $context['debug']['instances'] = array(); |
|
| 4888 | + } |
|
| 4625 | 4889 | |
| 4626 | 4890 | $context['debug']['instances'][$class] = $class; |
| 4627 | 4891 | } |
@@ -4631,13 +4895,15 @@ discard block |
||
| 4631 | 4895 | } |
| 4632 | 4896 | |
| 4633 | 4897 | // Right then. This is a call to a static method. |
| 4634 | - else |
|
| 4635 | - $func = array($class, $method); |
|
| 4898 | + else { |
|
| 4899 | + $func = array($class, $method); |
|
| 4900 | + } |
|
| 4636 | 4901 | } |
| 4637 | 4902 | |
| 4638 | 4903 | // Nope! just a plain regular function. |
| 4639 | - else |
|
| 4640 | - $func = $string; |
|
| 4904 | + else { |
|
| 4905 | + $func = $string; |
|
| 4906 | + } |
|
| 4641 | 4907 | |
| 4642 | 4908 | // Right, we got what we need, time to do some checks. |
| 4643 | 4909 | if (!is_callable($func, false, $callable_name)) |
@@ -4653,17 +4919,18 @@ discard block |
||
| 4653 | 4919 | else |
| 4654 | 4920 | { |
| 4655 | 4921 | // What are we gonna do about it? |
| 4656 | - if ($return) |
|
| 4657 | - return $func; |
|
| 4922 | + if ($return) { |
|
| 4923 | + return $func; |
|
| 4924 | + } |
|
| 4658 | 4925 | |
| 4659 | 4926 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4660 | 4927 | else |
| 4661 | 4928 | { |
| 4662 | - if (is_array($func)) |
|
| 4663 | - call_user_func($func); |
|
| 4664 | - |
|
| 4665 | - else |
|
| 4666 | - $func(); |
|
| 4929 | + if (is_array($func)) { |
|
| 4930 | + call_user_func($func); |
|
| 4931 | + } else { |
|
| 4932 | + $func(); |
|
| 4933 | + } |
|
| 4667 | 4934 | } |
| 4668 | 4935 | } |
| 4669 | 4936 | } |
@@ -4680,31 +4947,34 @@ discard block |
||
| 4680 | 4947 | { |
| 4681 | 4948 | global $sourcedir, $txt, $boarddir, $settings; |
| 4682 | 4949 | |
| 4683 | - if (empty($string)) |
|
| 4684 | - return false; |
|
| 4950 | + if (empty($string)) { |
|
| 4951 | + return false; |
|
| 4952 | + } |
|
| 4685 | 4953 | |
| 4686 | 4954 | if (strpos($string, '|') !== false) |
| 4687 | 4955 | { |
| 4688 | 4956 | list ($file, $string) = explode('|', $string); |
| 4689 | 4957 | |
| 4690 | 4958 | // Match the wildcards to their regular vars. |
| 4691 | - if (empty($settings['theme_dir'])) |
|
| 4692 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4693 | - |
|
| 4694 | - else |
|
| 4695 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4959 | + if (empty($settings['theme_dir'])) { |
|
| 4960 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4961 | + } else { |
|
| 4962 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4963 | + } |
|
| 4696 | 4964 | |
| 4697 | 4965 | // Load the file if it can be loaded. |
| 4698 | - if (file_exists($absPath)) |
|
| 4699 | - require_once($absPath); |
|
| 4966 | + if (file_exists($absPath)) { |
|
| 4967 | + require_once($absPath); |
|
| 4968 | + } |
|
| 4700 | 4969 | |
| 4701 | 4970 | // No? try a fallback to $sourcedir |
| 4702 | 4971 | else |
| 4703 | 4972 | { |
| 4704 | 4973 | $absPath = $sourcedir .'/'. $file; |
| 4705 | 4974 | |
| 4706 | - if (file_exists($absPath)) |
|
| 4707 | - require_once($absPath); |
|
| 4975 | + if (file_exists($absPath)) { |
|
| 4976 | + require_once($absPath); |
|
| 4977 | + } |
|
| 4708 | 4978 | |
| 4709 | 4979 | // Sorry, can't do much for you at this point. |
| 4710 | 4980 | else |
@@ -4731,8 +5001,9 @@ discard block |
||
| 4731 | 5001 | global $user_info, $smcFunc; |
| 4732 | 5002 | |
| 4733 | 5003 | // Make sure we have something to work with. |
| 4734 | - if (empty($topic)) |
|
| 4735 | - return array(); |
|
| 5004 | + if (empty($topic)) { |
|
| 5005 | + return array(); |
|
| 5006 | + } |
|
| 4736 | 5007 | |
| 4737 | 5008 | |
| 4738 | 5009 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4755,8 +5026,9 @@ discard block |
||
| 4755 | 5026 | 'topic' => $topic, |
| 4756 | 5027 | ) |
| 4757 | 5028 | ); |
| 4758 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4759 | - $temp[] = (int) $row['content_id']; |
|
| 5029 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5030 | + $temp[] = (int) $row['content_id']; |
|
| 5031 | + } |
|
| 4760 | 5032 | |
| 4761 | 5033 | cache_put_data($cache_key, $temp, $ttl); |
| 4762 | 5034 | } |
@@ -4777,8 +5049,9 @@ discard block |
||
| 4777 | 5049 | { |
| 4778 | 5050 | global $context; |
| 4779 | 5051 | |
| 4780 | - if (empty($string)) |
|
| 4781 | - return $string; |
|
| 5052 | + if (empty($string)) { |
|
| 5053 | + return $string; |
|
| 5054 | + } |
|
| 4782 | 5055 | |
| 4783 | 5056 | // UTF-8 occurences of MS special characters |
| 4784 | 5057 | $findchars_utf8 = array( |
@@ -4819,10 +5092,11 @@ discard block |
||
| 4819 | 5092 | '--', // — |
| 4820 | 5093 | ); |
| 4821 | 5094 | |
| 4822 | - if ($context['utf8']) |
|
| 4823 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4824 | - else |
|
| 4825 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5095 | + if ($context['utf8']) { |
|
| 5096 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5097 | + } else { |
|
| 5098 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5099 | + } |
|
| 4826 | 5100 | |
| 4827 | 5101 | return $string; |
| 4828 | 5102 | } |
@@ -4841,49 +5115,59 @@ discard block |
||
| 4841 | 5115 | { |
| 4842 | 5116 | global $context; |
| 4843 | 5117 | |
| 4844 | - if (!isset($matches[2])) |
|
| 4845 | - return ''; |
|
| 5118 | + if (!isset($matches[2])) { |
|
| 5119 | + return ''; |
|
| 5120 | + } |
|
| 4846 | 5121 | |
| 4847 | 5122 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4848 | 5123 | |
| 4849 | 5124 | // remove left to right / right to left overrides |
| 4850 | - if ($num === 0x202D || $num === 0x202E) |
|
| 4851 | - return ''; |
|
| 5125 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5126 | + return ''; |
|
| 5127 | + } |
|
| 4852 | 5128 | |
| 4853 | 5129 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 4854 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 4855 | - return '&#' . $num . ';'; |
|
| 5130 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5131 | + return '&#' . $num . ';'; |
|
| 5132 | + } |
|
| 4856 | 5133 | |
| 4857 | 5134 | if (empty($context['utf8'])) |
| 4858 | 5135 | { |
| 4859 | 5136 | // no control characters |
| 4860 | - if ($num < 0x20) |
|
| 4861 | - return ''; |
|
| 5137 | + if ($num < 0x20) { |
|
| 5138 | + return ''; |
|
| 5139 | + } |
|
| 4862 | 5140 | // text is text |
| 4863 | - elseif ($num < 0x80) |
|
| 4864 | - return chr($num); |
|
| 5141 | + elseif ($num < 0x80) { |
|
| 5142 | + return chr($num); |
|
| 5143 | + } |
|
| 4865 | 5144 | // all others get html-ised |
| 4866 | - else |
|
| 4867 | - return '&#' . $matches[2] . ';'; |
|
| 4868 | - } |
|
| 4869 | - else |
|
| 5145 | + else { |
|
| 5146 | + return '&#' . $matches[2] . ';'; |
|
| 5147 | + } |
|
| 5148 | + } else |
|
| 4870 | 5149 | { |
| 4871 | 5150 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 4872 | 5151 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 4873 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 4874 | - return ''; |
|
| 5152 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5153 | + return ''; |
|
| 5154 | + } |
|
| 4875 | 5155 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4876 | - elseif ($num < 0x80) |
|
| 4877 | - return chr($num); |
|
| 5156 | + elseif ($num < 0x80) { |
|
| 5157 | + return chr($num); |
|
| 5158 | + } |
|
| 4878 | 5159 | // <0x800 (2048) |
| 4879 | - elseif ($num < 0x800) |
|
| 4880 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5160 | + elseif ($num < 0x800) { |
|
| 5161 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5162 | + } |
|
| 4881 | 5163 | // < 0x10000 (65536) |
| 4882 | - elseif ($num < 0x10000) |
|
| 4883 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5164 | + elseif ($num < 0x10000) { |
|
| 5165 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5166 | + } |
|
| 4884 | 5167 | // <= 0x10FFFF (1114111) |
| 4885 | - else |
|
| 4886 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5168 | + else { |
|
| 5169 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5170 | + } |
|
| 4887 | 5171 | } |
| 4888 | 5172 | } |
| 4889 | 5173 | |
@@ -4899,28 +5183,34 @@ discard block |
||
| 4899 | 5183 | */ |
| 4900 | 5184 | function fixchar__callback($matches) |
| 4901 | 5185 | { |
| 4902 | - if (!isset($matches[1])) |
|
| 4903 | - return ''; |
|
| 5186 | + if (!isset($matches[1])) { |
|
| 5187 | + return ''; |
|
| 5188 | + } |
|
| 4904 | 5189 | |
| 4905 | 5190 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 4906 | 5191 | |
| 4907 | 5192 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 4908 | 5193 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 4909 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 4910 | - return ''; |
|
| 5194 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5195 | + return ''; |
|
| 5196 | + } |
|
| 4911 | 5197 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4912 | - elseif ($num < 0x80) |
|
| 4913 | - return chr($num); |
|
| 5198 | + elseif ($num < 0x80) { |
|
| 5199 | + return chr($num); |
|
| 5200 | + } |
|
| 4914 | 5201 | // <0x800 (2048) |
| 4915 | - elseif ($num < 0x800) |
|
| 4916 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5202 | + elseif ($num < 0x800) { |
|
| 5203 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5204 | + } |
|
| 4917 | 5205 | // < 0x10000 (65536) |
| 4918 | - elseif ($num < 0x10000) |
|
| 4919 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5206 | + elseif ($num < 0x10000) { |
|
| 5207 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5208 | + } |
|
| 4920 | 5209 | // <= 0x10FFFF (1114111) |
| 4921 | - else |
|
| 4922 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 4923 | -} |
|
| 5210 | + else { |
|
| 5211 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5212 | + } |
|
| 5213 | + } |
|
| 4924 | 5214 | |
| 4925 | 5215 | /** |
| 4926 | 5216 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4933,17 +5223,19 @@ discard block |
||
| 4933 | 5223 | */ |
| 4934 | 5224 | function entity_fix__callback($matches) |
| 4935 | 5225 | { |
| 4936 | - if (!isset($matches[2])) |
|
| 4937 | - return ''; |
|
| 5226 | + if (!isset($matches[2])) { |
|
| 5227 | + return ''; |
|
| 5228 | + } |
|
| 4938 | 5229 | |
| 4939 | 5230 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4940 | 5231 | |
| 4941 | 5232 | // we don't allow control characters, characters out of range, byte markers, etc |
| 4942 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 4943 | - return ''; |
|
| 4944 | - else |
|
| 4945 | - return '&#' . $num . ';'; |
|
| 4946 | -} |
|
| 5233 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5234 | + return ''; |
|
| 5235 | + } else { |
|
| 5236 | + return '&#' . $num . ';'; |
|
| 5237 | + } |
|
| 5238 | + } |
|
| 4947 | 5239 | |
| 4948 | 5240 | /** |
| 4949 | 5241 | * Return a Gravatar URL based on |
@@ -4967,18 +5259,23 @@ discard block |
||
| 4967 | 5259 | $ratings = array('G', 'PG', 'R', 'X'); |
| 4968 | 5260 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 4969 | 5261 | $url_params = array(); |
| 4970 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 4971 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 4972 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 4973 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 4974 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 4975 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 4976 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 4977 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5262 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5263 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5264 | + } |
|
| 5265 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5266 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5267 | + } |
|
| 5268 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5269 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5270 | + } |
|
| 5271 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5272 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 4978 | 5273 | $size_string = $modSettings['avatar_max_height_external']; |
| 5274 | + } |
|
| 4979 | 5275 | |
| 4980 | - if (!empty($size_string)) |
|
| 4981 | - $url_params[] = 's=' . $size_string; |
|
| 5276 | + if (!empty($size_string)) { |
|
| 5277 | + $url_params[] = 's=' . $size_string; |
|
| 5278 | + } |
|
| 4982 | 5279 | } |
| 4983 | 5280 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
| 4984 | 5281 | |
@@ -4997,22 +5294,26 @@ discard block |
||
| 4997 | 5294 | static $timezones = null, $lastwhen = null; |
| 4998 | 5295 | |
| 4999 | 5296 | // No point doing this over if we already did it once |
| 5000 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 5001 | - return $timezones; |
|
| 5002 | - else |
|
| 5003 | - $lastwhen = $when; |
|
| 5297 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5298 | + return $timezones; |
|
| 5299 | + } else { |
|
| 5300 | + $lastwhen = $when; |
|
| 5301 | + } |
|
| 5004 | 5302 | |
| 5005 | 5303 | // Parseable datetime string? |
| 5006 | - if (is_int($timestamp = strtotime($when))) |
|
| 5007 | - $when = $timestamp; |
|
| 5304 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5305 | + $when = $timestamp; |
|
| 5306 | + } |
|
| 5008 | 5307 | |
| 5009 | 5308 | // A Unix timestamp? |
| 5010 | - elseif (is_numeric($when)) |
|
| 5011 | - $when = intval($when); |
|
| 5309 | + elseif (is_numeric($when)) { |
|
| 5310 | + $when = intval($when); |
|
| 5311 | + } |
|
| 5012 | 5312 | |
| 5013 | 5313 | // Invalid value? Just get current Unix timestamp. |
| 5014 | - else |
|
| 5015 | - $when = time(); |
|
| 5314 | + else { |
|
| 5315 | + $when = time(); |
|
| 5316 | + } |
|
| 5016 | 5317 | |
| 5017 | 5318 | // We'll need these too |
| 5018 | 5319 | $date_when = date_create('@' . $when); |
@@ -5076,8 +5377,9 @@ discard block |
||
| 5076 | 5377 | foreach ($priority_countries as $country) |
| 5077 | 5378 | { |
| 5078 | 5379 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 5079 | - if (!empty($country_tzids)) |
|
| 5080 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5380 | + if (!empty($country_tzids)) { |
|
| 5381 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5382 | + } |
|
| 5081 | 5383 | } |
| 5082 | 5384 | |
| 5083 | 5385 | // Process the preferred timezones first, then the rest. |
@@ -5087,8 +5389,9 @@ discard block |
||
| 5087 | 5389 | foreach ($tzids as $tzid) |
| 5088 | 5390 | { |
| 5089 | 5391 | // We don't want UTC right now |
| 5090 | - if ($tzid == 'UTC') |
|
| 5091 | - continue; |
|
| 5392 | + if ($tzid == 'UTC') { |
|
| 5393 | + continue; |
|
| 5394 | + } |
|
| 5092 | 5395 | |
| 5093 | 5396 | $tz = timezone_open($tzid); |
| 5094 | 5397 | |
@@ -5109,8 +5412,9 @@ discard block |
||
| 5109 | 5412 | } |
| 5110 | 5413 | |
| 5111 | 5414 | // A time zone from a prioritized country? |
| 5112 | - if (in_array($tzid, $priority_tzids)) |
|
| 5113 | - $priority_zones[$tzkey] = true; |
|
| 5415 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5416 | + $priority_zones[$tzkey] = true; |
|
| 5417 | + } |
|
| 5114 | 5418 | |
| 5115 | 5419 | // Keep track of the location and offset for this tzid |
| 5116 | 5420 | $tzid_parts = explode('/', $tzid); |
@@ -5129,15 +5433,17 @@ discard block |
||
| 5129 | 5433 | { |
| 5130 | 5434 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
| 5131 | 5435 | |
| 5132 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
| 5133 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5134 | - else |
|
| 5135 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5436 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
| 5437 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5438 | + } else { |
|
| 5439 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5440 | + } |
|
| 5136 | 5441 | |
| 5137 | - if (isset($priority_zones[$tzkey])) |
|
| 5138 | - $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5139 | - else |
|
| 5140 | - $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5442 | + if (isset($priority_zones[$tzkey])) { |
|
| 5443 | + $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5444 | + } else { |
|
| 5445 | + $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5446 | + } |
|
| 5141 | 5447 | } |
| 5142 | 5448 | |
| 5143 | 5449 | $timezones = array_merge( |
@@ -5191,9 +5497,9 @@ discard block |
||
| 5191 | 5497 | 'Indian/Kerguelen' => 'TFT', |
| 5192 | 5498 | ); |
| 5193 | 5499 | |
| 5194 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
| 5195 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5196 | - else |
|
| 5500 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
| 5501 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5502 | + } else |
|
| 5197 | 5503 | { |
| 5198 | 5504 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
| 5199 | 5505 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5221,8 +5527,9 @@ discard block |
||
| 5221 | 5527 | */ |
| 5222 | 5528 | function inet_ptod($ip_address) |
| 5223 | 5529 | { |
| 5224 | - if (!isValidIP($ip_address)) |
|
| 5225 | - return $ip_address; |
|
| 5530 | + if (!isValidIP($ip_address)) { |
|
| 5531 | + return $ip_address; |
|
| 5532 | + } |
|
| 5226 | 5533 | |
| 5227 | 5534 | $bin = inet_pton($ip_address); |
| 5228 | 5535 | return $bin; |
@@ -5234,13 +5541,15 @@ discard block |
||
| 5234 | 5541 | */ |
| 5235 | 5542 | function inet_dtop($bin) |
| 5236 | 5543 | { |
| 5237 | - if(empty($bin)) |
|
| 5238 | - return ''; |
|
| 5544 | + if(empty($bin)) { |
|
| 5545 | + return ''; |
|
| 5546 | + } |
|
| 5239 | 5547 | |
| 5240 | 5548 | global $db_type; |
| 5241 | 5549 | |
| 5242 | - if ($db_type == 'postgresql') |
|
| 5243 | - return $bin; |
|
| 5550 | + if ($db_type == 'postgresql') { |
|
| 5551 | + return $bin; |
|
| 5552 | + } |
|
| 5244 | 5553 | |
| 5245 | 5554 | $ip_address = inet_ntop($bin); |
| 5246 | 5555 | |
@@ -5265,26 +5574,32 @@ discard block |
||
| 5265 | 5574 | */ |
| 5266 | 5575 | function _safe_serialize($value) |
| 5267 | 5576 | { |
| 5268 | - if(is_null($value)) |
|
| 5269 | - return 'N;'; |
|
| 5577 | + if(is_null($value)) { |
|
| 5578 | + return 'N;'; |
|
| 5579 | + } |
|
| 5270 | 5580 | |
| 5271 | - if(is_bool($value)) |
|
| 5272 | - return 'b:'. (int) $value .';'; |
|
| 5581 | + if(is_bool($value)) { |
|
| 5582 | + return 'b:'. (int) $value .';'; |
|
| 5583 | + } |
|
| 5273 | 5584 | |
| 5274 | - if(is_int($value)) |
|
| 5275 | - return 'i:'. $value .';'; |
|
| 5585 | + if(is_int($value)) { |
|
| 5586 | + return 'i:'. $value .';'; |
|
| 5587 | + } |
|
| 5276 | 5588 | |
| 5277 | - if(is_float($value)) |
|
| 5278 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5589 | + if(is_float($value)) { |
|
| 5590 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5591 | + } |
|
| 5279 | 5592 | |
| 5280 | - if(is_string($value)) |
|
| 5281 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5593 | + if(is_string($value)) { |
|
| 5594 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5595 | + } |
|
| 5282 | 5596 | |
| 5283 | 5597 | if(is_array($value)) |
| 5284 | 5598 | { |
| 5285 | 5599 | $out = ''; |
| 5286 | - foreach($value as $k => $v) |
|
| 5287 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5600 | + foreach($value as $k => $v) { |
|
| 5601 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5602 | + } |
|
| 5288 | 5603 | |
| 5289 | 5604 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5290 | 5605 | } |
@@ -5310,8 +5625,9 @@ discard block |
||
| 5310 | 5625 | |
| 5311 | 5626 | $out = _safe_serialize($value); |
| 5312 | 5627 | |
| 5313 | - if (isset($mbIntEnc)) |
|
| 5314 | - mb_internal_encoding($mbIntEnc); |
|
| 5628 | + if (isset($mbIntEnc)) { |
|
| 5629 | + mb_internal_encoding($mbIntEnc); |
|
| 5630 | + } |
|
| 5315 | 5631 | |
| 5316 | 5632 | return $out; |
| 5317 | 5633 | } |
@@ -5328,8 +5644,9 @@ discard block |
||
| 5328 | 5644 | function _safe_unserialize($str) |
| 5329 | 5645 | { |
| 5330 | 5646 | // Input is not a string. |
| 5331 | - if(empty($str) || !is_string($str)) |
|
| 5332 | - return false; |
|
| 5647 | + if(empty($str) || !is_string($str)) { |
|
| 5648 | + return false; |
|
| 5649 | + } |
|
| 5333 | 5650 | |
| 5334 | 5651 | $stack = array(); |
| 5335 | 5652 | $expected = array(); |
@@ -5345,43 +5662,38 @@ discard block |
||
| 5345 | 5662 | while($state != 1) |
| 5346 | 5663 | { |
| 5347 | 5664 | $type = isset($str[0]) ? $str[0] : ''; |
| 5348 | - if($type == '}') |
|
| 5349 | - $str = substr($str, 1); |
|
| 5350 | - |
|
| 5351 | - else if($type == 'N' && $str[1] == ';') |
|
| 5665 | + if($type == '}') { |
|
| 5666 | + $str = substr($str, 1); |
|
| 5667 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5352 | 5668 | { |
| 5353 | 5669 | $value = null; |
| 5354 | 5670 | $str = substr($str, 2); |
| 5355 | - } |
|
| 5356 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5671 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5357 | 5672 | { |
| 5358 | 5673 | $value = $matches[1] == '1' ? true : false; |
| 5359 | 5674 | $str = substr($str, 4); |
| 5360 | - } |
|
| 5361 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5675 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5362 | 5676 | { |
| 5363 | 5677 | $value = (int)$matches[1]; |
| 5364 | 5678 | $str = $matches[2]; |
| 5365 | - } |
|
| 5366 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5679 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5367 | 5680 | { |
| 5368 | 5681 | $value = (float)$matches[1]; |
| 5369 | 5682 | $str = $matches[3]; |
| 5370 | - } |
|
| 5371 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5683 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5372 | 5684 | { |
| 5373 | 5685 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5374 | 5686 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5375 | - } |
|
| 5376 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5687 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5377 | 5688 | { |
| 5378 | 5689 | $expectedLength = (int)$matches[1]; |
| 5379 | 5690 | $str = $matches[2]; |
| 5380 | 5691 | } |
| 5381 | 5692 | |
| 5382 | 5693 | // Object or unknown/malformed type. |
| 5383 | - else |
|
| 5384 | - return false; |
|
| 5694 | + else { |
|
| 5695 | + return false; |
|
| 5696 | + } |
|
| 5385 | 5697 | |
| 5386 | 5698 | switch($state) |
| 5387 | 5699 | { |
@@ -5409,8 +5721,9 @@ discard block |
||
| 5409 | 5721 | if($type == '}') |
| 5410 | 5722 | { |
| 5411 | 5723 | // Array size is less than expected. |
| 5412 | - if(count($list) < end($expected)) |
|
| 5413 | - return false; |
|
| 5724 | + if(count($list) < end($expected)) { |
|
| 5725 | + return false; |
|
| 5726 | + } |
|
| 5414 | 5727 | |
| 5415 | 5728 | unset($list); |
| 5416 | 5729 | $list = &$stack[count($stack)-1]; |
@@ -5419,8 +5732,9 @@ discard block |
||
| 5419 | 5732 | // Go to terminal state if we're at the end of the root array. |
| 5420 | 5733 | array_pop($expected); |
| 5421 | 5734 | |
| 5422 | - if(count($expected) == 0) |
|
| 5423 | - $state = 1; |
|
| 5735 | + if(count($expected) == 0) { |
|
| 5736 | + $state = 1; |
|
| 5737 | + } |
|
| 5424 | 5738 | |
| 5425 | 5739 | break; |
| 5426 | 5740 | } |
@@ -5428,8 +5742,9 @@ discard block |
||
| 5428 | 5742 | if($type == 'i' || $type == 's') |
| 5429 | 5743 | { |
| 5430 | 5744 | // Array size exceeds expected length. |
| 5431 | - if(count($list) >= end($expected)) |
|
| 5432 | - return false; |
|
| 5745 | + if(count($list) >= end($expected)) { |
|
| 5746 | + return false; |
|
| 5747 | + } |
|
| 5433 | 5748 | |
| 5434 | 5749 | $key = $value; |
| 5435 | 5750 | $state = 3; |
@@ -5463,8 +5778,9 @@ discard block |
||
| 5463 | 5778 | } |
| 5464 | 5779 | |
| 5465 | 5780 | // Trailing data in input. |
| 5466 | - if(!empty($str)) |
|
| 5467 | - return false; |
|
| 5781 | + if(!empty($str)) { |
|
| 5782 | + return false; |
|
| 5783 | + } |
|
| 5468 | 5784 | |
| 5469 | 5785 | return $data; |
| 5470 | 5786 | } |
@@ -5487,8 +5803,9 @@ discard block |
||
| 5487 | 5803 | |
| 5488 | 5804 | $out = _safe_unserialize($str); |
| 5489 | 5805 | |
| 5490 | - if (isset($mbIntEnc)) |
|
| 5491 | - mb_internal_encoding($mbIntEnc); |
|
| 5806 | + if (isset($mbIntEnc)) { |
|
| 5807 | + mb_internal_encoding($mbIntEnc); |
|
| 5808 | + } |
|
| 5492 | 5809 | |
| 5493 | 5810 | return $out; |
| 5494 | 5811 | } |
@@ -5503,12 +5820,14 @@ discard block |
||
| 5503 | 5820 | function smf_chmod($file, $value = 0) |
| 5504 | 5821 | { |
| 5505 | 5822 | // No file? no checks! |
| 5506 | - if (empty($file)) |
|
| 5507 | - return false; |
|
| 5823 | + if (empty($file)) { |
|
| 5824 | + return false; |
|
| 5825 | + } |
|
| 5508 | 5826 | |
| 5509 | 5827 | // Already writable? |
| 5510 | - if (is_writable($file)) |
|
| 5511 | - return true; |
|
| 5828 | + if (is_writable($file)) { |
|
| 5829 | + return true; |
|
| 5830 | + } |
|
| 5512 | 5831 | |
| 5513 | 5832 | // Do we have a file or a dir? |
| 5514 | 5833 | $isDir = is_dir($file); |
@@ -5524,10 +5843,9 @@ discard block |
||
| 5524 | 5843 | { |
| 5525 | 5844 | $isWritable = true; |
| 5526 | 5845 | break; |
| 5846 | + } else { |
|
| 5847 | + @chmod($file, $val); |
|
| 5527 | 5848 | } |
| 5528 | - |
|
| 5529 | - else |
|
| 5530 | - @chmod($file, $val); |
|
| 5531 | 5849 | } |
| 5532 | 5850 | |
| 5533 | 5851 | return $isWritable; |
@@ -5546,8 +5864,9 @@ discard block |
||
| 5546 | 5864 | global $txt; |
| 5547 | 5865 | |
| 5548 | 5866 | // Come on... |
| 5549 | - if (empty($json) || !is_string($json)) |
|
| 5550 | - return array(); |
|
| 5867 | + if (empty($json) || !is_string($json)) { |
|
| 5868 | + return array(); |
|
| 5869 | + } |
|
| 5551 | 5870 | |
| 5552 | 5871 | $returnArray = @json_decode($json, $returnAsArray); |
| 5553 | 5872 | |
@@ -5585,11 +5904,11 @@ discard block |
||
| 5585 | 5904 | $jsonDebug = $jsonDebug[0]; |
| 5586 | 5905 | loadLanguage('Errors'); |
| 5587 | 5906 | |
| 5588 | - if (!empty($jsonDebug)) |
|
| 5589 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5590 | - |
|
| 5591 | - else |
|
| 5592 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5907 | + if (!empty($jsonDebug)) { |
|
| 5908 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5909 | + } else { |
|
| 5910 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5911 | + } |
|
| 5593 | 5912 | |
| 5594 | 5913 | // Everyone expects an array. |
| 5595 | 5914 | return array(); |
@@ -5623,8 +5942,9 @@ discard block |
||
| 5623 | 5942 | global $db_show_debug, $modSettings; |
| 5624 | 5943 | |
| 5625 | 5944 | // Defensive programming anyone? |
| 5626 | - if (empty($data)) |
|
| 5627 | - return false; |
|
| 5945 | + if (empty($data)) { |
|
| 5946 | + return false; |
|
| 5947 | + } |
|
| 5628 | 5948 | |
| 5629 | 5949 | // Don't need extra stuff... |
| 5630 | 5950 | $db_show_debug = false; |
@@ -5632,11 +5952,11 @@ discard block |
||
| 5632 | 5952 | // Kill anything else. |
| 5633 | 5953 | ob_end_clean(); |
| 5634 | 5954 | |
| 5635 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 5636 | - @ob_start('ob_gzhandler'); |
|
| 5637 | - |
|
| 5638 | - else |
|
| 5639 | - ob_start(); |
|
| 5955 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 5956 | + @ob_start('ob_gzhandler'); |
|
| 5957 | + } else { |
|
| 5958 | + ob_start(); |
|
| 5959 | + } |
|
| 5640 | 5960 | |
| 5641 | 5961 | // Set the header. |
| 5642 | 5962 | header($type); |
@@ -5668,8 +5988,9 @@ discard block |
||
| 5668 | 5988 | static $done = false; |
| 5669 | 5989 | |
| 5670 | 5990 | // If we don't need to do anything, don't |
| 5671 | - if (!$update && $done) |
|
| 5672 | - return; |
|
| 5991 | + if (!$update && $done) { |
|
| 5992 | + return; |
|
| 5993 | + } |
|
| 5673 | 5994 | |
| 5674 | 5995 | // Should we get a new copy of the official list of TLDs? |
| 5675 | 5996 | if ($update) |
@@ -5678,8 +5999,9 @@ discard block |
||
| 5678 | 5999 | $tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt'); |
| 5679 | 6000 | |
| 5680 | 6001 | // If the Internet Assigned Numbers Authority can't be reached, the Internet is gone. We're probably running on a server hidden in a bunker deep underground to protect it from marauding bandits roaming on the surface. We don't want to waste precious electricity on pointlessly repeating background tasks, so we'll wait until the next regularly scheduled update to see if civilization has been restored. |
| 5681 | - if ($tlds === false) |
|
| 5682 | - $postapocalypticNightmare = true; |
|
| 6002 | + if ($tlds === false) { |
|
| 6003 | + $postapocalypticNightmare = true; |
|
| 6004 | + } |
|
| 5683 | 6005 | } |
| 5684 | 6006 | // If we aren't updating and the regex is valid, we're done |
| 5685 | 6007 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5694,10 +6016,11 @@ discard block |
||
| 5694 | 6016 | // Clean $tlds and convert it to an array |
| 5695 | 6017 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 5696 | 6018 | $line = trim($line); |
| 5697 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 5698 | - return false; |
|
| 5699 | - else |
|
| 5700 | - return true; |
|
| 6019 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 6020 | + return false; |
|
| 6021 | + } else { |
|
| 6022 | + return true; |
|
| 6023 | + } |
|
| 5701 | 6024 | }); |
| 5702 | 6025 | |
| 5703 | 6026 | // Convert Punycode to Unicode |
@@ -5751,8 +6074,9 @@ discard block |
||
| 5751 | 6074 | $idx += $digit * $w; |
| 5752 | 6075 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
| 5753 | 6076 | |
| 5754 | - if ($digit < $t) |
|
| 5755 | - break; |
|
| 6077 | + if ($digit < $t) { |
|
| 6078 | + break; |
|
| 6079 | + } |
|
| 5756 | 6080 | |
| 5757 | 6081 | $w = (int) ($w * ($base - $t)); |
| 5758 | 6082 | } |
@@ -5761,8 +6085,9 @@ discard block |
||
| 5761 | 6085 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
| 5762 | 6086 | $delta += intval($delta / ($deco_len + 1)); |
| 5763 | 6087 | |
| 5764 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
| 5765 | - $delta = intval($delta / ($base - $tmin)); |
|
| 6088 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
| 6089 | + $delta = intval($delta / ($base - $tmin)); |
|
| 6090 | + } |
|
| 5766 | 6091 | |
| 5767 | 6092 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
| 5768 | 6093 | $is_first = false; |
@@ -5771,8 +6096,9 @@ discard block |
||
| 5771 | 6096 | |
| 5772 | 6097 | if ($deco_len > 0) |
| 5773 | 6098 | { |
| 5774 | - for ($i = $deco_len; $i > $idx; $i--) |
|
| 5775 | - $decoded[$i] = $decoded[($i - 1)]; |
|
| 6099 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
| 6100 | + $decoded[$i] = $decoded[($i - 1)]; |
|
| 6101 | + } |
|
| 5776 | 6102 | } |
| 5777 | 6103 | $decoded[$idx++] = $char; |
| 5778 | 6104 | } |
@@ -5780,24 +6106,29 @@ discard block |
||
| 5780 | 6106 | foreach ($decoded as $k => $v) |
| 5781 | 6107 | { |
| 5782 | 6108 | // 7bit are transferred literally |
| 5783 | - if ($v < 128) |
|
| 5784 | - $output .= chr($v); |
|
| 6109 | + if ($v < 128) { |
|
| 6110 | + $output .= chr($v); |
|
| 6111 | + } |
|
| 5785 | 6112 | |
| 5786 | 6113 | // 2 bytes |
| 5787 | - elseif ($v < (1 << 11)) |
|
| 5788 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6114 | + elseif ($v < (1 << 11)) { |
|
| 6115 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6116 | + } |
|
| 5789 | 6117 | |
| 5790 | 6118 | // 3 bytes |
| 5791 | - elseif ($v < (1 << 16)) |
|
| 5792 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6119 | + elseif ($v < (1 << 16)) { |
|
| 6120 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6121 | + } |
|
| 5793 | 6122 | |
| 5794 | 6123 | // 4 bytes |
| 5795 | - elseif ($v < (1 << 21)) |
|
| 5796 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6124 | + elseif ($v < (1 << 21)) { |
|
| 6125 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6126 | + } |
|
| 5797 | 6127 | |
| 5798 | 6128 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5799 | - else |
|
| 5800 | - $output .= $safe_char; |
|
| 6129 | + else { |
|
| 6130 | + $output .= $safe_char; |
|
| 6131 | + } |
|
| 5801 | 6132 | } |
| 5802 | 6133 | |
| 5803 | 6134 | $output_parts[] = $output; |
@@ -5890,8 +6221,7 @@ discard block |
||
| 5890 | 6221 | |
| 5891 | 6222 | $strlen = 'mb_strlen'; |
| 5892 | 6223 | $substr = 'mb_substr'; |
| 5893 | - } |
|
| 5894 | - else |
|
| 6224 | + } else |
|
| 5895 | 6225 | { |
| 5896 | 6226 | $strlen = $smcFunc['strlen']; |
| 5897 | 6227 | $substr = $smcFunc['substr']; |
@@ -5905,20 +6235,21 @@ discard block |
||
| 5905 | 6235 | |
| 5906 | 6236 | $first = $substr($string, 0, 1); |
| 5907 | 6237 | |
| 5908 | - if (empty($index[$first])) |
|
| 5909 | - $index[$first] = array(); |
|
| 6238 | + if (empty($index[$first])) { |
|
| 6239 | + $index[$first] = array(); |
|
| 6240 | + } |
|
| 5910 | 6241 | |
| 5911 | 6242 | if ($strlen($string) > 1) |
| 5912 | 6243 | { |
| 5913 | 6244 | // Sanity check on recursion |
| 5914 | - if ($depth > 99) |
|
| 5915 | - $index[$first][$substr($string, 1)] = ''; |
|
| 5916 | - |
|
| 5917 | - else |
|
| 5918 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6245 | + if ($depth > 99) { |
|
| 6246 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6247 | + } else { |
|
| 6248 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6249 | + } |
|
| 6250 | + } else { |
|
| 6251 | + $index[$first][''] = ''; |
|
| 5919 | 6252 | } |
| 5920 | - else |
|
| 5921 | - $index[$first][''] = ''; |
|
| 5922 | 6253 | |
| 5923 | 6254 | $depth--; |
| 5924 | 6255 | return $index; |
@@ -5941,9 +6272,9 @@ discard block |
||
| 5941 | 6272 | $key_regex = preg_quote($key, $delim); |
| 5942 | 6273 | $new_key = $key; |
| 5943 | 6274 | |
| 5944 | - if (empty($value)) |
|
| 5945 | - $sub_regex = ''; |
|
| 5946 | - else |
|
| 6275 | + if (empty($value)) { |
|
| 6276 | + $sub_regex = ''; |
|
| 6277 | + } else |
|
| 5947 | 6278 | { |
| 5948 | 6279 | $sub_regex = $index_to_regex($value, $delim); |
| 5949 | 6280 | |
@@ -5951,22 +6282,22 @@ discard block |
||
| 5951 | 6282 | { |
| 5952 | 6283 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 5953 | 6284 | $new_key .= $new_key_array[0]; |
| 6285 | + } else { |
|
| 6286 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5954 | 6287 | } |
| 5955 | - else |
|
| 5956 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5957 | 6288 | } |
| 5958 | 6289 | |
| 5959 | - if ($depth > 1) |
|
| 5960 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 5961 | - else |
|
| 6290 | + if ($depth > 1) { |
|
| 6291 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6292 | + } else |
|
| 5962 | 6293 | { |
| 5963 | 6294 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 5964 | 6295 | { |
| 5965 | 6296 | $regex[$new_key] = $key_regex . $sub_regex; |
| 5966 | 6297 | unset($index[$key]); |
| 6298 | + } else { |
|
| 6299 | + break; |
|
| 5967 | 6300 | } |
| 5968 | - else |
|
| 5969 | - break; |
|
| 5970 | 6301 | } |
| 5971 | 6302 | } |
| 5972 | 6303 | |
@@ -5975,10 +6306,11 @@ discard block |
||
| 5975 | 6306 | $l1 = $strlen($k1); |
| 5976 | 6307 | $l2 = $strlen($k2); |
| 5977 | 6308 | |
| 5978 | - if ($l1 == $l2) |
|
| 5979 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 5980 | - else |
|
| 5981 | - return $l1 > $l2 ? -1 : 1; |
|
| 6309 | + if ($l1 == $l2) { |
|
| 6310 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6311 | + } else { |
|
| 6312 | + return $l1 > $l2 ? -1 : 1; |
|
| 6313 | + } |
|
| 5982 | 6314 | }); |
| 5983 | 6315 | |
| 5984 | 6316 | $depth--; |
@@ -5989,21 +6321,24 @@ discard block |
||
| 5989 | 6321 | $index = array(); |
| 5990 | 6322 | $regex = ''; |
| 5991 | 6323 | |
| 5992 | - foreach ($strings as $string) |
|
| 5993 | - $index = $add_string_to_index($string, $index); |
|
| 6324 | + foreach ($strings as $string) { |
|
| 6325 | + $index = $add_string_to_index($string, $index); |
|
| 6326 | + } |
|
| 5994 | 6327 | |
| 5995 | 6328 | if ($returnArray === true) |
| 5996 | 6329 | { |
| 5997 | 6330 | $regex = array(); |
| 5998 | - while (!empty($index)) |
|
| 5999 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6331 | + while (!empty($index)) { |
|
| 6332 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6333 | + } |
|
| 6334 | + } else { |
|
| 6335 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6000 | 6336 | } |
| 6001 | - else |
|
| 6002 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6003 | 6337 | |
| 6004 | 6338 | // Restore PHP's internal character encoding to whatever it was originally |
| 6005 | - if (!empty($current_encoding)) |
|
| 6006 | - mb_internal_encoding($current_encoding); |
|
| 6339 | + if (!empty($current_encoding)) { |
|
| 6340 | + mb_internal_encoding($current_encoding); |
|
| 6341 | + } |
|
| 6007 | 6342 | |
| 6008 | 6343 | return $regex; |
| 6009 | 6344 | } |
@@ -6046,13 +6381,15 @@ discard block |
||
| 6046 | 6381 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
| 6047 | 6382 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
| 6048 | 6383 | $headers = @get_headers($url); |
| 6049 | - if ($headers === false) |
|
| 6050 | - return false; |
|
| 6384 | + if ($headers === false) { |
|
| 6385 | + return false; |
|
| 6386 | + } |
|
| 6051 | 6387 | |
| 6052 | 6388 | // Now to see if it came back https... |
| 6053 | 6389 | // First check for a redirect status code in first row (301, 302, 307) |
| 6054 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
| 6055 | - return false; |
|
| 6390 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
| 6391 | + return false; |
|
| 6392 | + } |
|
| 6056 | 6393 | |
| 6057 | 6394 | // Search for the location entry to confirm https |
| 6058 | 6395 | $result = false; |
@@ -6088,8 +6425,7 @@ discard block |
||
| 6088 | 6425 | $is_admin = $user_info['is_admin']; |
| 6089 | 6426 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
| 6090 | 6427 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
| 6091 | - } |
|
| 6092 | - else |
|
| 6428 | + } else |
|
| 6093 | 6429 | { |
| 6094 | 6430 | $request = $smcFunc['db_query']('', ' |
| 6095 | 6431 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6103,17 +6439,19 @@ discard block |
||
| 6103 | 6439 | |
| 6104 | 6440 | $row = $smcFunc['db_fetch_assoc']($request); |
| 6105 | 6441 | |
| 6106 | - if (empty($row['additional_groups'])) |
|
| 6107 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6108 | - else |
|
| 6109 | - $groups = array_merge( |
|
| 6442 | + if (empty($row['additional_groups'])) { |
|
| 6443 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6444 | + } else { |
|
| 6445 | + $groups = array_merge( |
|
| 6110 | 6446 | array($row['id_group'], $row['id_post_group']), |
| 6111 | 6447 | explode(',', $row['additional_groups']) |
| 6112 | 6448 | ); |
| 6449 | + } |
|
| 6113 | 6450 | |
| 6114 | 6451 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 6115 | - foreach ($groups as $k => $v) |
|
| 6116 | - $groups[$k] = (int) $v; |
|
| 6452 | + foreach ($groups as $k => $v) { |
|
| 6453 | + $groups[$k] = (int) $v; |
|
| 6454 | + } |
|
| 6117 | 6455 | |
| 6118 | 6456 | $is_admin = in_array(1, $groups); |
| 6119 | 6457 | |
@@ -6130,8 +6468,9 @@ discard block |
||
| 6130 | 6468 | 'current_member' => $userid, |
| 6131 | 6469 | ) |
| 6132 | 6470 | ); |
| 6133 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6134 | - $boards_mod[] = $row['id_board']; |
|
| 6471 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6472 | + $boards_mod[] = $row['id_board']; |
|
| 6473 | + } |
|
| 6135 | 6474 | $smcFunc['db_free_result']($request); |
| 6136 | 6475 | |
| 6137 | 6476 | // Can any of the groups they're in moderate any of the boards? |
@@ -6143,8 +6482,9 @@ discard block |
||
| 6143 | 6482 | 'groups' => $groups, |
| 6144 | 6483 | ) |
| 6145 | 6484 | ); |
| 6146 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6147 | - $boards_mod[] = $row['id_board']; |
|
| 6485 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6486 | + $boards_mod[] = $row['id_board']; |
|
| 6487 | + } |
|
| 6148 | 6488 | $smcFunc['db_free_result']($request); |
| 6149 | 6489 | |
| 6150 | 6490 | // Just in case we've got duplicates here... |
@@ -6154,21 +6494,25 @@ discard block |
||
| 6154 | 6494 | } |
| 6155 | 6495 | |
| 6156 | 6496 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 6157 | - if ($is_admin) |
|
| 6158 | - $query_part['query_see_board'] = '1=1'; |
|
| 6497 | + if ($is_admin) { |
|
| 6498 | + $query_part['query_see_board'] = '1=1'; |
|
| 6499 | + } |
|
| 6159 | 6500 | // Otherwise just the groups in $user_info['groups']. |
| 6160 | - else |
|
| 6161 | - $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6501 | + else { |
|
| 6502 | + $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6503 | + } |
|
| 6162 | 6504 | |
| 6163 | 6505 | // Build the list of boards they WANT to see. |
| 6164 | 6506 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 6165 | 6507 | |
| 6166 | 6508 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 6167 | - if (empty($ignoreboards)) |
|
| 6168 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6509 | + if (empty($ignoreboards)) { |
|
| 6510 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6511 | + } |
|
| 6169 | 6512 | // Ok I guess they don't want to see all the boards |
| 6170 | - else |
|
| 6171 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6513 | + else { |
|
| 6514 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6515 | + } |
|
| 6172 | 6516 | |
| 6173 | 6517 | return $query_part; |
| 6174 | 6518 | } |