@@ -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 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
107 | 108 | // Perhaps the search method wants to add some settings? |
108 | 109 | require_once($sourcedir . '/Search.php'); |
109 | 110 | $searchAPI = findSearchAPI(); |
110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
113 | + } |
|
112 | 114 | |
113 | - if ($return_config) |
|
114 | - return $config_vars; |
|
115 | + if ($return_config) { |
|
116 | + return $config_vars; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | |
127 | 130 | call_integration_hook('integrate_save_search_settings'); |
128 | 131 | |
129 | - if (empty($_POST['search_results_per_page'])) |
|
130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
132 | + if (empty($_POST['search_results_per_page'])) { |
|
133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
134 | + } |
|
131 | 135 | saveDBSettings($config_vars); |
132 | 136 | $_SESSION['adm-save'] = true; |
133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
177 | 181 | call_integration_hook('integrate_save_search_weights'); |
178 | 182 | |
179 | 183 | $changes = array(); |
180 | - foreach ($factors as $factor) |
|
181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
184 | + foreach ($factors as $factor) { |
|
185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
186 | + } |
|
182 | 187 | updateSettings($changes); |
183 | 188 | } |
184 | 189 | |
185 | 190 | $context['relative_weights'] = array('total' => 0); |
186 | - foreach ($factors as $factor) |
|
187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
191 | + foreach ($factors as $factor) { |
|
192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
193 | + } |
|
188 | 194 | |
189 | - foreach ($factors as $factor) |
|
190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
195 | + foreach ($factors as $factor) { |
|
196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
197 | + } |
|
191 | 198 | |
192 | 199 | createToken('admin-msw'); |
193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
216 | 223 | |
217 | 224 | // Detect whether a fulltext index is set. |
218 | - if ($context['supports_fulltext']) |
|
219 | - detectFulltextIndex(); |
|
225 | + if ($context['supports_fulltext']) { |
|
226 | + detectFulltextIndex(); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
240 | 248 | 'language' => $language_ftx |
241 | 249 | ) |
242 | 250 | ); |
243 | - } |
|
244 | - else |
|
251 | + } else |
|
245 | 252 | { |
246 | 253 | // Make sure it's gone before creating it. |
247 | 254 | $smcFunc['db_query']('', ' |
@@ -259,8 +266,7 @@ discard block |
||
259 | 266 | ) |
260 | 267 | ); |
261 | 268 | } |
262 | - } |
|
263 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
269 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
264 | 270 | { |
265 | 271 | checkSession('get'); |
266 | 272 | validateToken('admin-msm', 'get'); |
@@ -277,12 +283,12 @@ discard block |
||
277 | 283 | $context['fulltext_index'] = array(); |
278 | 284 | |
279 | 285 | // Go back to the default search method. |
280 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
281 | - updateSettings(array( |
|
286 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
287 | + updateSettings(array( |
|
282 | 288 | 'search_index' => '', |
283 | 289 | )); |
284 | - } |
|
285 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
290 | + } |
|
291 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
286 | 292 | { |
287 | 293 | checkSession('get'); |
288 | 294 | validateToken('admin-msm', 'get'); |
@@ -304,12 +310,12 @@ discard block |
||
304 | 310 | )); |
305 | 311 | |
306 | 312 | // Go back to the default search method. |
307 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
308 | - updateSettings(array( |
|
313 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
314 | + updateSettings(array( |
|
309 | 315 | 'search_index' => '', |
310 | 316 | )); |
311 | - } |
|
312 | - elseif (isset($_POST['save'])) |
|
317 | + } |
|
318 | + } elseif (isset($_POST['save'])) |
|
313 | 319 | { |
314 | 320 | checkSession(); |
315 | 321 | validateToken('admin-msmpost'); |
@@ -331,8 +337,8 @@ discard block |
||
331 | 337 | // Get some info about the messages table, to show its size and index size. |
332 | 338 | if ($db_type == 'mysql') |
333 | 339 | { |
334 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
335 | - $request = $smcFunc['db_query']('', ' |
|
340 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
341 | + $request = $smcFunc['db_query']('', ' |
|
336 | 342 | SHOW TABLE STATUS |
337 | 343 | FROM {string:database_name} |
338 | 344 | LIKE {string:table_name}', |
@@ -341,14 +347,15 @@ discard block |
||
341 | 347 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
342 | 348 | ) |
343 | 349 | ); |
344 | - else |
|
345 | - $request = $smcFunc['db_query']('', ' |
|
350 | + } else { |
|
351 | + $request = $smcFunc['db_query']('', ' |
|
346 | 352 | SHOW TABLE STATUS |
347 | 353 | LIKE {string:table_name}', |
348 | 354 | array( |
349 | 355 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
350 | 356 | ) |
351 | 357 | ); |
358 | + } |
|
352 | 359 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
353 | 360 | { |
354 | 361 | // Only do this if the user has permission to execute this query. |
@@ -360,8 +367,8 @@ discard block |
||
360 | 367 | } |
361 | 368 | |
362 | 369 | // Now check the custom index table, if it exists at all. |
363 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
364 | - $request = $smcFunc['db_query']('', ' |
|
370 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
371 | + $request = $smcFunc['db_query']('', ' |
|
365 | 372 | SHOW TABLE STATUS |
366 | 373 | FROM {string:database_name} |
367 | 374 | LIKE {string:table_name}', |
@@ -370,14 +377,15 @@ discard block |
||
370 | 377 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
371 | 378 | ) |
372 | 379 | ); |
373 | - else |
|
374 | - $request = $smcFunc['db_query']('', ' |
|
380 | + } else { |
|
381 | + $request = $smcFunc['db_query']('', ' |
|
375 | 382 | SHOW TABLE STATUS |
376 | 383 | LIKE {string:table_name}', |
377 | 384 | array( |
378 | 385 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
379 | 386 | ) |
380 | 387 | ); |
388 | + } |
|
381 | 389 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
382 | 390 | { |
383 | 391 | // Only do this if the user has permission to execute this query. |
@@ -386,8 +394,7 @@ discard block |
||
386 | 394 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
387 | 395 | $smcFunc['db_free_result']($request); |
388 | 396 | } |
389 | - } |
|
390 | - elseif ($db_type == 'postgresql') |
|
397 | + } elseif ($db_type == 'postgresql') |
|
391 | 398 | { |
392 | 399 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
393 | 400 | //db_extend(); |
@@ -429,38 +436,38 @@ discard block |
||
429 | 436 | $context['table_info']['data_length'] = (int) $row['table_size']; |
430 | 437 | $context['table_info']['index_length'] = (int) $row['index_size']; |
431 | 438 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
432 | - } |
|
433 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
439 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
434 | 440 | { |
435 | 441 | $context['table_info']['index_length'] = (int) $row['index_size']; |
436 | 442 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
437 | 443 | } |
438 | 444 | } |
439 | 445 | $smcFunc['db_free_result']($request); |
440 | - } |
|
441 | - else |
|
442 | - // Didn't work for some reason... |
|
446 | + } else { |
|
447 | + // Didn't work for some reason... |
|
443 | 448 | $context['table_info'] = array( |
444 | 449 | 'data_length' => $txt['not_applicable'], |
445 | 450 | 'index_length' => $txt['not_applicable'], |
446 | 451 | 'fulltext_length' => $txt['not_applicable'], |
447 | 452 | 'custom_index_length' => $txt['not_applicable'], |
448 | 453 | ); |
449 | - } |
|
450 | - else |
|
451 | - $context['table_info'] = array( |
|
454 | + } |
|
455 | + } else { |
|
456 | + $context['table_info'] = array( |
|
452 | 457 | 'data_length' => $txt['not_applicable'], |
453 | 458 | 'index_length' => $txt['not_applicable'], |
454 | 459 | 'fulltext_length' => $txt['not_applicable'], |
455 | 460 | 'custom_index_length' => $txt['not_applicable'], |
456 | 461 | ); |
462 | + } |
|
457 | 463 | |
458 | 464 | // Format the data and index length in kilobytes. |
459 | 465 | foreach ($context['table_info'] as $type => $size) |
460 | 466 | { |
461 | 467 | // If it's not numeric then just break. This database engine doesn't support size. |
462 | - if (!is_numeric($size)) |
|
463 | - break; |
|
468 | + if (!is_numeric($size)) { |
|
469 | + break; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
466 | 473 | } |
@@ -489,8 +496,9 @@ discard block |
||
489 | 496 | |
490 | 497 | // Scotty, we need more time... |
491 | 498 | @set_time_limit(600); |
492 | - if (function_exists('apache_reset_timeout')) |
|
493 | - @apache_reset_timeout(); |
|
499 | + if (function_exists('apache_reset_timeout')) { |
|
500 | + @apache_reset_timeout(); |
|
501 | + } |
|
494 | 502 | |
495 | 503 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
496 | 504 | $context['page_title'] = $txt['search_index_custom']; |
@@ -520,8 +528,7 @@ discard block |
||
520 | 528 | $context['start'] = (int) $context['index_settings']['resume_at']; |
521 | 529 | unset($context['index_settings']['resume_at']); |
522 | 530 | $context['step'] = 1; |
523 | - } |
|
524 | - else |
|
531 | + } else |
|
525 | 532 | { |
526 | 533 | $context['index_settings'] = array( |
527 | 534 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -530,12 +537,14 @@ discard block |
||
530 | 537 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
531 | 538 | |
532 | 539 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
533 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
534 | - $_SESSION['admin_time'] = time(); |
|
540 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
541 | + $_SESSION['admin_time'] = time(); |
|
542 | + } |
|
535 | 543 | } |
536 | 544 | |
537 | - if ($context['step'] !== 0) |
|
538 | - checkSession('request'); |
|
545 | + if ($context['step'] !== 0) { |
|
546 | + checkSession('request'); |
|
547 | + } |
|
539 | 548 | |
540 | 549 | // Step 0: let the user determine how they like their index. |
541 | 550 | if ($context['step'] === 0) |
@@ -564,12 +573,14 @@ discard block |
||
564 | 573 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
565 | 574 | |
566 | 575 | // Temporarily switch back to not using a search index. |
567 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
568 | - updateSettings(array('search_index' => '')); |
|
576 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
577 | + updateSettings(array('search_index' => '')); |
|
578 | + } |
|
569 | 579 | |
570 | 580 | // Don't let simultanious processes be updating the search index. |
571 | - if (!empty($modSettings['search_custom_index_config'])) |
|
572 | - updateSettings(array('search_custom_index_config' => '')); |
|
581 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
582 | + updateSettings(array('search_custom_index_config' => '')); |
|
583 | + } |
|
573 | 584 | } |
574 | 585 | |
575 | 586 | $num_messages = array( |
@@ -585,16 +596,16 @@ discard block |
||
585 | 596 | 'starting_id' => $context['start'], |
586 | 597 | ) |
587 | 598 | ); |
588 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
589 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
600 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
601 | + } |
|
590 | 602 | |
591 | 603 | if (empty($num_messages['todo'])) |
592 | 604 | { |
593 | 605 | $context['step'] = 2; |
594 | 606 | $context['percentage'] = 80; |
595 | 607 | $context['start'] = 0; |
596 | - } |
|
597 | - else |
|
608 | + } else |
|
598 | 609 | { |
599 | 610 | // Number of seconds before the next step. |
600 | 611 | $stop = time() + 3; |
@@ -635,21 +646,22 @@ discard block |
||
635 | 646 | |
636 | 647 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
637 | 648 | |
638 | - if (!empty($inserts)) |
|
639 | - $smcFunc['db_insert']('ignore', |
|
649 | + if (!empty($inserts)) { |
|
650 | + $smcFunc['db_insert']('ignore', |
|
640 | 651 | '{db_prefix}log_search_words', |
641 | 652 | array('id_word' => 'int', 'id_msg' => 'int'), |
642 | 653 | $inserts, |
643 | 654 | array('id_word', 'id_msg') |
644 | 655 | ); |
656 | + } |
|
645 | 657 | if ($num_messages['todo'] === 0) |
646 | 658 | { |
647 | 659 | $context['step'] = 2; |
648 | 660 | $context['start'] = 0; |
649 | 661 | break; |
662 | + } else { |
|
663 | + updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
650 | 664 | } |
651 | - else |
|
652 | - updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
653 | 665 | } |
654 | 666 | |
655 | 667 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -660,9 +672,9 @@ discard block |
||
660 | 672 | // Step 2: removing the words that occur too often and are of no use. |
661 | 673 | elseif ($context['step'] === 2) |
662 | 674 | { |
663 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
664 | - $context['step'] = 3; |
|
665 | - else |
|
675 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
676 | + $context['step'] = 3; |
|
677 | + } else |
|
666 | 678 | { |
667 | 679 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
668 | 680 | $stop = time() + 3; |
@@ -683,20 +695,22 @@ discard block |
||
683 | 695 | 'minimum_messages' => $max_messages, |
684 | 696 | ) |
685 | 697 | ); |
686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
687 | - $stop_words[] = $row['id_word']; |
|
698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
699 | + $stop_words[] = $row['id_word']; |
|
700 | + } |
|
688 | 701 | $smcFunc['db_free_result']($request); |
689 | 702 | |
690 | 703 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
691 | 704 | |
692 | - if (!empty($stop_words)) |
|
693 | - $smcFunc['db_query']('', ' |
|
705 | + if (!empty($stop_words)) { |
|
706 | + $smcFunc['db_query']('', ' |
|
694 | 707 | DELETE FROM {db_prefix}log_search_words |
695 | 708 | WHERE id_word in ({array_int:stop_words})', |
696 | 709 | array( |
697 | 710 | 'stop_words' => $stop_words, |
698 | 711 | ) |
699 | 712 | ); |
713 | + } |
|
700 | 714 | |
701 | 715 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
702 | 716 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -757,8 +771,9 @@ discard block |
||
757 | 771 | $searchAPI = new $search_class_name(); |
758 | 772 | |
759 | 773 | // No Support? NEXT! |
760 | - if (!$searchAPI->is_supported) |
|
761 | - continue; |
|
774 | + if (!$searchAPI->is_supported) { |
|
775 | + continue; |
|
776 | + } |
|
762 | 777 | |
763 | 778 | $apis[$index_name] = array( |
764 | 779 | 'filename' => $file, |
@@ -805,10 +820,10 @@ discard block |
||
805 | 820 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
806 | 821 | ) |
807 | 822 | ); |
808 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
809 | - $context['fulltext_index'][] = $row['indexname']; |
|
810 | - } |
|
811 | - else |
|
823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
824 | + $context['fulltext_index'][] = $row['indexname']; |
|
825 | + } |
|
826 | + } else |
|
812 | 827 | { |
813 | 828 | $request = $smcFunc['db_query']('', ' |
814 | 829 | SHOW INDEX |
@@ -819,17 +834,19 @@ discard block |
||
819 | 834 | $context['fulltext_index'] = array(); |
820 | 835 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
821 | 836 | { |
822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
823 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
838 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
824 | 839 | $context['fulltext_index'][] = $row['Key_name']; |
840 | + } |
|
825 | 841 | $smcFunc['db_free_result']($request); |
826 | 842 | |
827 | - if (is_array($context['fulltext_index'])) |
|
828 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
843 | + if (is_array($context['fulltext_index'])) { |
|
844 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
845 | + } |
|
829 | 846 | } |
830 | 847 | |
831 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
832 | - $request = $smcFunc['db_query']('', ' |
|
848 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
849 | + $request = $smcFunc['db_query']('', ' |
|
833 | 850 | SHOW TABLE STATUS |
834 | 851 | FROM {string:database_name} |
835 | 852 | LIKE {string:table_name}', |
@@ -838,20 +855,22 @@ discard block |
||
838 | 855 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
839 | 856 | ) |
840 | 857 | ); |
841 | - else |
|
842 | - $request = $smcFunc['db_query']('', ' |
|
858 | + } else { |
|
859 | + $request = $smcFunc['db_query']('', ' |
|
843 | 860 | SHOW TABLE STATUS |
844 | 861 | LIKE {string:table_name}', |
845 | 862 | array( |
846 | 863 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
847 | 864 | ) |
848 | 865 | ); |
866 | + } |
|
849 | 867 | |
850 | 868 | if ($request !== false) |
851 | 869 | { |
852 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
853 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
870 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
871 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
854 | 872 | $context['cannot_create_fulltext'] = true; |
873 | + } |
|
855 | 874 | $smcFunc['db_free_result']($request); |
856 | 875 | } |
857 | 876 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | |
57 | 58 | $context['name'] = $board_info['name']; |
58 | 59 | $context['description'] = $board_info['description']; |
59 | - if (!empty($board_info['description'])) |
|
60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
60 | + if (!empty($board_info['description'])) { |
|
61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // How many topics do we have in total? |
63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
73 | 75 | $session_name = session_name(); |
74 | 76 | foreach ($_GET as $k => $v) |
75 | 77 | { |
76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
77 | - $context['robot_no_index'] = true; |
|
78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
79 | + $context['robot_no_index'] = true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
81 | - $context['robot_no_index'] = true; |
|
83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
84 | + $context['robot_no_index'] = true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // If we can view unapproved messages and there are some build up a list. |
84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
89 | 93 | } |
90 | 94 | |
91 | 95 | // We only know these. |
92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
93 | - $_REQUEST['sort'] = 'last_post'; |
|
96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
97 | + $_REQUEST['sort'] = 'last_post'; |
|
98 | + } |
|
94 | 99 | |
95 | 100 | // Make sure the starting place makes sense and construct the page index. |
96 | - if (isset($_REQUEST['sort'])) |
|
97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
98 | - else |
|
99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
101 | + if (isset($_REQUEST['sort'])) { |
|
102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
103 | + } else { |
|
104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
105 | + } |
|
100 | 106 | $context['start'] = &$_REQUEST['start']; |
101 | 107 | |
102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
132 | 138 | $context['link_moderators'] = array(); |
133 | 139 | if (!empty($board_info['moderators'])) |
134 | 140 | { |
135 | - foreach ($board_info['moderators'] as $mod) |
|
136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
141 | + foreach ($board_info['moderators'] as $mod) { |
|
142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
143 | + } |
|
137 | 144 | } |
138 | 145 | if (!empty($board_info['moderator_groups'])) |
139 | 146 | { |
140 | 147 | // By default just tack the moderator groups onto the end of the members |
141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | |
145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | ); |
192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
193 | 201 | { |
194 | - if (empty($row['id_member'])) |
|
195 | - continue; |
|
202 | + if (empty($row['id_member'])) { |
|
203 | + continue; |
|
204 | + } |
|
196 | 205 | |
197 | - if (!empty($row['online_color'])) |
|
198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
199 | - else |
|
200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
206 | + if (!empty($row['online_color'])) { |
|
207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
208 | + } else { |
|
209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
210 | + } |
|
201 | 211 | |
202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
203 | - if ($is_buddy) |
|
204 | - $link = '<strong>' . $link . '</strong>'; |
|
213 | + if ($is_buddy) { |
|
214 | + $link = '<strong>' . $link . '</strong>'; |
|
215 | + } |
|
205 | 216 | |
206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
219 | + } |
|
208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | 'hidden' => empty($row['show_online']), |
218 | 230 | ); |
219 | 231 | |
220 | - if (empty($row['show_online'])) |
|
221 | - $context['view_num_hidden']++; |
|
232 | + if (empty($row['show_online'])) { |
|
233 | + $context['view_num_hidden']++; |
|
234 | + } |
|
222 | 235 | } |
223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
260 | 273 | // Bring in any changes we want to make before the query. |
261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
262 | 275 | |
263 | - foreach ($sort_methods as $key => $val) |
|
264 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
276 | + foreach ($sort_methods as $key => $val) { |
|
277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | // Calculate the fastest way to get the topics. |
267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
271 | 285 | $fake_ascending = true; |
272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
288 | + } else { |
|
289 | + $fake_ascending = false; |
|
274 | 290 | } |
275 | - else |
|
276 | - $fake_ascending = false; |
|
277 | 291 | |
278 | 292 | // Setup the default topic icons... |
279 | 293 | $context['icon_sources'] = array(); |
280 | - foreach ($context['stable_icons'] as $icon) |
|
281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
294 | + foreach ($context['stable_icons'] as $icon) { |
|
295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
296 | + } |
|
282 | 297 | |
283 | 298 | $topic_ids = array(); |
284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
316 | 331 | $message_pre_index_parameters |
317 | 332 | ); |
318 | 333 | $topic_ids = array(); |
319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
320 | - $topic_ids[] = $row['id_topic']; |
|
334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
335 | + $topic_ids[] = $row['id_topic']; |
|
336 | + } |
|
321 | 337 | } |
322 | 338 | |
323 | 339 | // Grab the appropriate topic information... |
@@ -340,10 +356,11 @@ discard block |
||
340 | 356 | $message_index_wheres = array(); |
341 | 357 | call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids)); |
342 | 358 | |
343 | - if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
|
344 | - $enableParticipation = true; |
|
345 | - else |
|
346 | - $enableParticipation = false; |
|
359 | + if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) { |
|
360 | + $enableParticipation = true; |
|
361 | + } else { |
|
362 | + $enableParticipation = false; |
|
363 | + } |
|
347 | 364 | |
348 | 365 | $result = $smcFunc['db_query']('substring', ' |
349 | 366 | SELECT |
@@ -382,11 +399,13 @@ discard block |
||
382 | 399 | // Begin 'printing' the message index for current board. |
383 | 400 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
384 | 401 | { |
385 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
386 | - continue; |
|
402 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
403 | + continue; |
|
404 | + } |
|
387 | 405 | |
388 | - if (!$pre_query) |
|
389 | - $topic_ids[] = $row['id_topic']; |
|
406 | + if (!$pre_query) { |
|
407 | + $topic_ids[] = $row['id_topic']; |
|
408 | + } |
|
390 | 409 | |
391 | 410 | // Reference the main color class. |
392 | 411 | $colorClass = 'windowbg'; |
@@ -396,8 +415,9 @@ discard block |
||
396 | 415 | { |
397 | 416 | // Limit them to $modSettings['preview_characters'] characters |
398 | 417 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
399 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
400 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
418 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
419 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
420 | + } |
|
401 | 421 | |
402 | 422 | // Censor the subject and message preview. |
403 | 423 | censorText($row['first_subject']); |
@@ -408,27 +428,27 @@ discard block |
||
408 | 428 | { |
409 | 429 | $row['last_subject'] = $row['first_subject']; |
410 | 430 | $row['last_body'] = $row['first_body']; |
411 | - } |
|
412 | - else |
|
431 | + } else |
|
413 | 432 | { |
414 | 433 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
415 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
416 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
434 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
435 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
436 | + } |
|
417 | 437 | |
418 | 438 | censorText($row['last_subject']); |
419 | 439 | censorText($row['last_body']); |
420 | 440 | } |
421 | - } |
|
422 | - else |
|
441 | + } else |
|
423 | 442 | { |
424 | 443 | $row['first_body'] = ''; |
425 | 444 | $row['last_body'] = ''; |
426 | 445 | censorText($row['first_subject']); |
427 | 446 | |
428 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
429 | - $row['last_subject'] = $row['first_subject']; |
|
430 | - else |
|
431 | - censorText($row['last_subject']); |
|
447 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
448 | + $row['last_subject'] = $row['first_subject']; |
|
449 | + } else { |
|
450 | + censorText($row['last_subject']); |
|
451 | + } |
|
432 | 452 | } |
433 | 453 | |
434 | 454 | // Decide how many pages the topic should have. |
@@ -439,42 +459,50 @@ discard block |
||
439 | 459 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
440 | 460 | |
441 | 461 | // If we can use all, show all. |
442 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
443 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
462 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
463 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
464 | + } |
|
465 | + } else { |
|
466 | + $pages = ''; |
|
444 | 467 | } |
445 | - else |
|
446 | - $pages = ''; |
|
447 | 468 | |
448 | 469 | // We need to check the topic icons exist... |
449 | 470 | if (!empty($modSettings['messageIconChecks_enable'])) |
450 | 471 | { |
451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
452 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
454 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
455 | - } |
|
456 | - else |
|
472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
473 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
474 | + } |
|
475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
476 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
477 | + } |
|
478 | + } else |
|
457 | 479 | { |
458 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
459 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
460 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
461 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
480 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
481 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
482 | + } |
|
483 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
484 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
485 | + } |
|
462 | 486 | } |
463 | 487 | |
464 | - if (!empty($board_info['recycle'])) |
|
465 | - $row['first_icon'] = 'recycled'; |
|
488 | + if (!empty($board_info['recycle'])) { |
|
489 | + $row['first_icon'] = 'recycled'; |
|
490 | + } |
|
466 | 491 | |
467 | 492 | // Is this topic pending approval, or does it have any posts pending approval? |
468 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
469 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
493 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
494 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
495 | + } |
|
470 | 496 | |
471 | 497 | // Sticky topics should get a different color, too. |
472 | - if ($row['is_sticky']) |
|
473 | - $colorClass .= ' sticky'; |
|
498 | + if ($row['is_sticky']) { |
|
499 | + $colorClass .= ' sticky'; |
|
500 | + } |
|
474 | 501 | |
475 | 502 | // Locked topics get special treatment as well. |
476 | - if ($row['locked']) |
|
477 | - $colorClass .= ' locked'; |
|
503 | + if ($row['locked']) { |
|
504 | + $colorClass .= ' locked'; |
|
505 | + } |
|
478 | 506 | |
479 | 507 | // 'Print' the topic info. |
480 | 508 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -555,8 +583,9 @@ discard block |
||
555 | 583 | $smcFunc['db_free_result']($result); |
556 | 584 | |
557 | 585 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
558 | - if ($fake_ascending) |
|
559 | - $context['topics'] = array_reverse($context['topics'], true); |
|
586 | + if ($fake_ascending) { |
|
587 | + $context['topics'] = array_reverse($context['topics'], true); |
|
588 | + } |
|
560 | 589 | } |
561 | 590 | |
562 | 591 | $context['jump_to'] = array( |
@@ -579,9 +608,9 @@ discard block |
||
579 | 608 | // Can we restore topics? |
580 | 609 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
581 | 610 | |
582 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
583 | - $context['can_move_any'] = true; |
|
584 | - else |
|
611 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
612 | + $context['can_move_any'] = true; |
|
613 | + } else |
|
585 | 614 | { |
586 | 615 | // We'll use this in a minute |
587 | 616 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -608,11 +637,13 @@ discard block |
||
608 | 637 | } |
609 | 638 | |
610 | 639 | // Can we use quick moderation checkboxes? |
611 | - if ($options['display_quick_mod'] == 1) |
|
612 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
640 | + if ($options['display_quick_mod'] == 1) { |
|
641 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
642 | + } |
|
613 | 643 | // Or the icons? |
614 | - else |
|
615 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
644 | + else { |
|
645 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
646 | + } |
|
616 | 647 | } |
617 | 648 | |
618 | 649 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -646,13 +677,15 @@ discard block |
||
646 | 677 | ); |
647 | 678 | |
648 | 679 | // We've seen all these boards now! |
649 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
650 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
680 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
681 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
651 | 682 | unset($_SESSION['topicseen_cache'][$k]); |
683 | + } |
|
652 | 684 | } |
653 | 685 | |
654 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
655 | - unset($_SESSION['topicseen_cache'][$board]); |
|
686 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
687 | + unset($_SESSION['topicseen_cache'][$board]); |
|
688 | + } |
|
656 | 689 | |
657 | 690 | $request = $smcFunc['db_query']('', ' |
658 | 691 | SELECT id_topic, id_board, sent |
@@ -673,8 +706,9 @@ discard block |
||
673 | 706 | $context['is_marked_notify'] = true; |
674 | 707 | $board_sent = $row['sent']; |
675 | 708 | } |
676 | - if (!empty($row['id_topic'])) |
|
677 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
709 | + if (!empty($row['id_topic'])) { |
|
710 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
711 | + } |
|
678 | 712 | } |
679 | 713 | $smcFunc['db_free_result']($request); |
680 | 714 | |
@@ -698,8 +732,7 @@ discard block |
||
698 | 732 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
699 | 733 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
700 | 734 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
701 | - } |
|
702 | - else |
|
735 | + } else |
|
703 | 736 | { |
704 | 737 | $context['is_marked_notify'] = false; |
705 | 738 | $context['board_notification_mode'] = 1; |
@@ -712,23 +745,27 @@ discard block |
||
712 | 745 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
713 | 746 | |
714 | 747 | // Don't want to show this forever... |
715 | - if ($context['becomesUnapproved']) |
|
716 | - unset($_SESSION['becomesUnapproved']); |
|
748 | + if ($context['becomesUnapproved']) { |
|
749 | + unset($_SESSION['becomesUnapproved']); |
|
750 | + } |
|
717 | 751 | |
718 | 752 | // Build the message index button array. |
719 | 753 | $context['normal_buttons'] = array(); |
720 | 754 | |
721 | - if ($context['can_post_new']) |
|
722 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
755 | + if ($context['can_post_new']) { |
|
756 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
757 | + } |
|
723 | 758 | |
724 | - if ($context['can_post_poll']) |
|
725 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
759 | + if ($context['can_post_poll']) { |
|
760 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
761 | + } |
|
726 | 762 | |
727 | - if (!$context['user']['is_logged']) |
|
728 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
763 | + if (!$context['user']['is_logged']) { |
|
764 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
765 | + } |
|
729 | 766 | |
730 | - if ($context['can_mark_notify']) |
|
731 | - $context['normal_buttons']['notify'] = array( |
|
767 | + if ($context['can_mark_notify']) { |
|
768 | + $context['normal_buttons']['notify'] = array( |
|
732 | 769 | 'lang' => true, |
733 | 770 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
734 | 771 | 'sub_buttons' => array( |
@@ -746,6 +783,7 @@ discard block |
||
746 | 783 | ), |
747 | 784 | ), |
748 | 785 | ); |
786 | + } |
|
749 | 787 | |
750 | 788 | // Javascript for inline editing. |
751 | 789 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -767,18 +805,21 @@ discard block |
||
767 | 805 | checkSession('request'); |
768 | 806 | |
769 | 807 | // Lets go straight to the restore area. |
770 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
771 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
808 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
809 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
810 | + } |
|
772 | 811 | |
773 | - if (isset($_SESSION['topicseen_cache'])) |
|
774 | - $_SESSION['topicseen_cache'] = array(); |
|
812 | + if (isset($_SESSION['topicseen_cache'])) { |
|
813 | + $_SESSION['topicseen_cache'] = array(); |
|
814 | + } |
|
775 | 815 | |
776 | 816 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
777 | 817 | require_once($sourcedir . '/Subs-Post.php'); |
778 | 818 | |
779 | 819 | // Remember the last board they moved things to. |
780 | - if (isset($_REQUEST['move_to'])) |
|
781 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
820 | + if (isset($_REQUEST['move_to'])) { |
|
821 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
822 | + } |
|
782 | 823 | |
783 | 824 | // Only a few possible actions. |
784 | 825 | $possibleActions = array(); |
@@ -798,8 +839,7 @@ discard block |
||
798 | 839 | ); |
799 | 840 | |
800 | 841 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
801 | - } |
|
802 | - else |
|
842 | + } else |
|
803 | 843 | { |
804 | 844 | /** |
805 | 845 | * @todo Ugly. There's no getting around this, is there? |
@@ -817,8 +857,7 @@ discard block |
||
817 | 857 | if (!empty($board)) |
818 | 858 | { |
819 | 859 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
820 | - } |
|
821 | - else |
|
860 | + } else |
|
822 | 861 | { |
823 | 862 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
824 | 863 | } |
@@ -829,55 +868,67 @@ discard block |
||
829 | 868 | } |
830 | 869 | } |
831 | 870 | |
832 | - if (!$user_info['is_guest']) |
|
833 | - $possibleActions[] = 'markread'; |
|
834 | - if (!empty($boards_can['make_sticky'])) |
|
835 | - $possibleActions[] = 'sticky'; |
|
836 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
837 | - $possibleActions[] = 'move'; |
|
838 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
839 | - $possibleActions[] = 'remove'; |
|
840 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
841 | - $possibleActions[] = 'lock'; |
|
842 | - if (!empty($boards_can['merge_any'])) |
|
843 | - $possibleActions[] = 'merge'; |
|
844 | - if (!empty($boards_can['approve_posts'])) |
|
845 | - $possibleActions[] = 'approve'; |
|
871 | + if (!$user_info['is_guest']) { |
|
872 | + $possibleActions[] = 'markread'; |
|
873 | + } |
|
874 | + if (!empty($boards_can['make_sticky'])) { |
|
875 | + $possibleActions[] = 'sticky'; |
|
876 | + } |
|
877 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
878 | + $possibleActions[] = 'move'; |
|
879 | + } |
|
880 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
881 | + $possibleActions[] = 'remove'; |
|
882 | + } |
|
883 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
884 | + $possibleActions[] = 'lock'; |
|
885 | + } |
|
886 | + if (!empty($boards_can['merge_any'])) { |
|
887 | + $possibleActions[] = 'merge'; |
|
888 | + } |
|
889 | + if (!empty($boards_can['approve_posts'])) { |
|
890 | + $possibleActions[] = 'approve'; |
|
891 | + } |
|
846 | 892 | |
847 | 893 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
848 | 894 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
849 | 895 | if (!empty($_REQUEST['topics'])) |
850 | 896 | { |
851 | 897 | // If the action isn't valid, just quit now. |
852 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
853 | - redirectexit($redirect_url); |
|
898 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
899 | + redirectexit($redirect_url); |
|
900 | + } |
|
854 | 901 | |
855 | 902 | // Merge requires all topics as one parameter and can be done at once. |
856 | 903 | if ($_REQUEST['qaction'] == 'merge') |
857 | 904 | { |
858 | 905 | // Merge requires at least two topics. |
859 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
860 | - redirectexit($redirect_url); |
|
906 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
907 | + redirectexit($redirect_url); |
|
908 | + } |
|
861 | 909 | |
862 | 910 | require_once($sourcedir . '/SplitTopics.php'); |
863 | 911 | return MergeExecute($_REQUEST['topics']); |
864 | 912 | } |
865 | 913 | |
866 | 914 | // Just convert to the other method, to make it easier. |
867 | - foreach ($_REQUEST['topics'] as $topic) |
|
868 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
915 | + foreach ($_REQUEST['topics'] as $topic) { |
|
916 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
917 | + } |
|
869 | 918 | } |
870 | 919 | |
871 | 920 | // Weird... how'd you get here? |
872 | - if (empty($_REQUEST['actions'])) |
|
873 | - redirectexit($redirect_url); |
|
921 | + if (empty($_REQUEST['actions'])) { |
|
922 | + redirectexit($redirect_url); |
|
923 | + } |
|
874 | 924 | |
875 | 925 | // Validate each action. |
876 | 926 | $temp = array(); |
877 | 927 | foreach ($_REQUEST['actions'] as $topic => $action) |
878 | 928 | { |
879 | - if (in_array($action, $possibleActions)) |
|
880 | - $temp[(int) $topic] = $action; |
|
929 | + if (in_array($action, $possibleActions)) { |
|
930 | + $temp[(int) $topic] = $action; |
|
931 | + } |
|
881 | 932 | } |
882 | 933 | $_REQUEST['actions'] = $temp; |
883 | 934 | |
@@ -898,27 +949,31 @@ discard block |
||
898 | 949 | { |
899 | 950 | if (!empty($board)) |
900 | 951 | { |
901 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
902 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
903 | - } |
|
904 | - else |
|
952 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
953 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
954 | + } |
|
955 | + } else |
|
905 | 956 | { |
906 | 957 | // Don't allow them to act on unapproved posts they can't see... |
907 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
908 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
958 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
959 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
960 | + } |
|
909 | 961 | // Goodness, this is fun. We need to validate the action. |
910 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
911 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
962 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
963 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
964 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
968 | + } |
|
916 | 969 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
917 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
918 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
970 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
971 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
972 | + } |
|
919 | 973 | // If the topic is approved then you need permission to approve the posts within. |
920 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
974 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
975 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
976 | + } |
|
922 | 977 | } |
923 | 978 | } |
924 | 979 | $smcFunc['db_free_result']($request); |
@@ -936,11 +991,11 @@ discard block |
||
936 | 991 | { |
937 | 992 | $topic = (int) $topic; |
938 | 993 | |
939 | - if ($action == 'markread') |
|
940 | - $markCache[] = $topic; |
|
941 | - elseif ($action == 'sticky') |
|
942 | - $stickyCache[] = $topic; |
|
943 | - elseif ($action == 'move') |
|
994 | + if ($action == 'markread') { |
|
995 | + $markCache[] = $topic; |
|
996 | + } elseif ($action == 'sticky') { |
|
997 | + $stickyCache[] = $topic; |
|
998 | + } elseif ($action == 'move') |
|
944 | 999 | { |
945 | 1000 | require_once($sourcedir . '/MoveTopic.php'); |
946 | 1001 | moveTopicConcurrence(); |
@@ -948,23 +1003,25 @@ discard block |
||
948 | 1003 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
949 | 1004 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
950 | 1005 | |
951 | - if (empty($moveCache[1][$topic])) |
|
952 | - continue; |
|
1006 | + if (empty($moveCache[1][$topic])) { |
|
1007 | + continue; |
|
1008 | + } |
|
953 | 1009 | |
954 | 1010 | $moveCache[0][] = $topic; |
1011 | + } elseif ($action == 'remove') { |
|
1012 | + $removeCache[] = $topic; |
|
1013 | + } elseif ($action == 'lock') { |
|
1014 | + $lockCache[] = $topic; |
|
1015 | + } elseif ($action == 'approve') { |
|
1016 | + $approveCache[] = $topic; |
|
955 | 1017 | } |
956 | - elseif ($action == 'remove') |
|
957 | - $removeCache[] = $topic; |
|
958 | - elseif ($action == 'lock') |
|
959 | - $lockCache[] = $topic; |
|
960 | - elseif ($action == 'approve') |
|
961 | - $approveCache[] = $topic; |
|
962 | 1018 | } |
963 | 1019 | |
964 | - if (empty($board)) |
|
965 | - $affectedBoards = array(); |
|
966 | - else |
|
967 | - $affectedBoards = array($board => array(0, 0)); |
|
1020 | + if (empty($board)) { |
|
1021 | + $affectedBoards = array(); |
|
1022 | + } else { |
|
1023 | + $affectedBoards = array($board => array(0, 0)); |
|
1024 | + } |
|
968 | 1025 | |
969 | 1026 | // Do all the stickies... |
970 | 1027 | if (!empty($stickyCache)) |
@@ -1024,14 +1081,16 @@ discard block |
||
1024 | 1081 | { |
1025 | 1082 | $to = $moveCache[1][$row['id_topic']]; |
1026 | 1083 | |
1027 | - if (empty($to)) |
|
1028 | - continue; |
|
1084 | + if (empty($to)) { |
|
1085 | + continue; |
|
1086 | + } |
|
1029 | 1087 | |
1030 | 1088 | // Does this topic's board count the posts or not? |
1031 | 1089 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
1032 | 1090 | |
1033 | - if (!isset($moveTos[$to])) |
|
1034 | - $moveTos[$to] = array(); |
|
1091 | + if (!isset($moveTos[$to])) { |
|
1092 | + $moveTos[$to] = array(); |
|
1093 | + } |
|
1035 | 1094 | |
1036 | 1095 | $moveTos[$to][] = $row['id_topic']; |
1037 | 1096 | |
@@ -1045,8 +1104,9 @@ discard block |
||
1045 | 1104 | require_once($sourcedir . '/MoveTopic.php'); |
1046 | 1105 | |
1047 | 1106 | // Do the actual moves... |
1048 | - foreach ($moveTos as $to => $topics) |
|
1049 | - moveTopics($topics, $to); |
|
1107 | + foreach ($moveTos as $to => $topics) { |
|
1108 | + moveTopics($topics, $to); |
|
1109 | + } |
|
1050 | 1110 | |
1051 | 1111 | // Does the post counts need to be updated? |
1052 | 1112 | if (!empty($moveTos)) |
@@ -1095,20 +1155,23 @@ discard block |
||
1095 | 1155 | |
1096 | 1156 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1097 | 1157 | { |
1098 | - if (!isset($members[$row['id_member']])) |
|
1099 | - $members[$row['id_member']] = 0; |
|
1158 | + if (!isset($members[$row['id_member']])) { |
|
1159 | + $members[$row['id_member']] = 0; |
|
1160 | + } |
|
1100 | 1161 | |
1101 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
1102 | - $members[$row['id_member']] += 1; |
|
1103 | - else |
|
1104 | - $members[$row['id_member']] -= 1; |
|
1162 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
1163 | + $members[$row['id_member']] += 1; |
|
1164 | + } else { |
|
1165 | + $members[$row['id_member']] -= 1; |
|
1166 | + } |
|
1105 | 1167 | } |
1106 | 1168 | |
1107 | 1169 | $smcFunc['db_free_result']($request); |
1108 | 1170 | |
1109 | 1171 | // And now update them member's post counts |
1110 | - foreach ($members as $id_member => $post_adj) |
|
1111 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1172 | + foreach ($members as $id_member => $post_adj) { |
|
1173 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1174 | + } |
|
1112 | 1175 | |
1113 | 1176 | } |
1114 | 1177 | } |
@@ -1188,8 +1251,9 @@ discard block |
||
1188 | 1251 | approveTopics($approveCache); |
1189 | 1252 | |
1190 | 1253 | // Time for some logging! |
1191 | - foreach ($approveCache as $topic) |
|
1192 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1254 | + foreach ($approveCache as $topic) { |
|
1255 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1256 | + } |
|
1193 | 1257 | } |
1194 | 1258 | } |
1195 | 1259 | |
@@ -1224,8 +1288,7 @@ discard block |
||
1224 | 1288 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
1225 | 1289 | } |
1226 | 1290 | $smcFunc['db_free_result']($result); |
1227 | - } |
|
1228 | - else |
|
1291 | + } else |
|
1229 | 1292 | { |
1230 | 1293 | $result = $smcFunc['db_query']('', ' |
1231 | 1294 | SELECT id_topic, locked, id_board |
@@ -1275,13 +1338,15 @@ discard block |
||
1275 | 1338 | ) |
1276 | 1339 | ); |
1277 | 1340 | $logged_topics = array(); |
1278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1279 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1341 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1342 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1343 | + } |
|
1280 | 1344 | $smcFunc['db_free_result']($request); |
1281 | 1345 | |
1282 | 1346 | $markArray = array(); |
1283 | - foreach ($markCache as $topic) |
|
1284 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1347 | + foreach ($markCache as $topic) { |
|
1348 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1349 | + } |
|
1285 | 1350 | |
1286 | 1351 | $smcFunc['db_insert']('replace', |
1287 | 1352 | '{db_prefix}log_topics', |
@@ -1294,8 +1359,9 @@ discard block |
||
1294 | 1359 | foreach ($moveCache as $topic) |
1295 | 1360 | { |
1296 | 1361 | // Didn't actually move anything! |
1297 | - if (!isset($topic[0])) |
|
1298 | - break; |
|
1362 | + if (!isset($topic[0])) { |
|
1363 | + break; |
|
1364 | + } |
|
1299 | 1365 | |
1300 | 1366 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
1301 | 1367 | sendNotifications($topic[0], 'move'); |
@@ -1317,8 +1383,9 @@ discard block |
||
1317 | 1383 | 'calendar_updated' => time(), |
1318 | 1384 | )); |
1319 | 1385 | |
1320 | - if (!empty($affectedBoards)) |
|
1321 | - updateLastMessages(array_keys($affectedBoards)); |
|
1386 | + if (!empty($affectedBoards)) { |
|
1387 | + updateLastMessages(array_keys($affectedBoards)); |
|
1388 | + } |
|
1322 | 1389 | |
1323 | 1390 | redirectexit($redirect_url); |
1324 | 1391 | } |
@@ -349,7 +349,7 @@ |
||
349 | 349 | SELECT |
350 | 350 | t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, |
351 | 351 | ' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, COALESCE(lmr.id_msg, -1)) + 1') . ' AS new_from, |
352 | - ' . ( $enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
352 | + ' . ($enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
353 | 353 | ' : '') . ' |
354 | 354 | t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time, t.id_redirect_topic, |
355 | 355 | ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -155,12 +158,13 @@ discard block |
||
155 | 158 | 'data' => array( |
156 | 159 | 'function' => function($news) |
157 | 160 | { |
158 | - if (is_numeric($news['id'])) |
|
159 | - return ' |
|
161 | + if (is_numeric($news['id'])) { |
|
162 | + return ' |
|
160 | 163 | <textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
161 | 164 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
162 | - else |
|
163 | - return $news['unparsed']; |
|
165 | + } else { |
|
166 | + return $news['unparsed']; |
|
167 | + } |
|
164 | 168 | }, |
165 | 169 | 'class' => 'half_table', |
166 | 170 | ), |
@@ -186,10 +190,11 @@ discard block |
||
186 | 190 | 'data' => array( |
187 | 191 | 'function' => function($news) |
188 | 192 | { |
189 | - if (is_numeric($news['id'])) |
|
190 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
191 | - else |
|
192 | - return ''; |
|
193 | + if (is_numeric($news['id'])) { |
|
194 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
195 | + } else { |
|
196 | + return ''; |
|
197 | + } |
|
193 | 198 | }, |
194 | 199 | 'class' => 'centercol icon', |
195 | 200 | ), |
@@ -283,12 +288,13 @@ discard block |
||
283 | 288 | |
284 | 289 | $admin_current_news = array(); |
285 | 290 | // Ready the current news. |
286 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
287 | - $admin_current_news[$id] = array( |
|
291 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
292 | + $admin_current_news[$id] = array( |
|
288 | 293 | 'id' => $id, |
289 | 294 | 'unparsed' => un_preparsecode($line), |
290 | 295 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
291 | 296 | ); |
297 | + } |
|
292 | 298 | |
293 | 299 | $admin_current_news['last'] = array( |
294 | 300 | 'id' => 'last', |
@@ -355,10 +361,11 @@ discard block |
||
355 | 361 | 'member_count' => 0, |
356 | 362 | ); |
357 | 363 | |
358 | - if ($row['min_posts'] == -1) |
|
359 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
360 | - else |
|
361 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
364 | + if ($row['min_posts'] == -1) { |
|
365 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
366 | + } else { |
|
367 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
368 | + } |
|
362 | 369 | } |
363 | 370 | $smcFunc['db_free_result']($request); |
364 | 371 | |
@@ -374,8 +381,9 @@ discard block |
||
374 | 381 | 'post_group_list' => $postGroups, |
375 | 382 | ) |
376 | 383 | ); |
377 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
378 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
384 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
385 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
386 | + } |
|
379 | 387 | $smcFunc['db_free_result']($query); |
380 | 388 | } |
381 | 389 | |
@@ -391,8 +399,9 @@ discard block |
||
391 | 399 | 'normal_group_list' => $normalGroups, |
392 | 400 | ) |
393 | 401 | ); |
394 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
395 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
403 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
404 | + } |
|
396 | 405 | $smcFunc['db_free_result']($query); |
397 | 406 | |
398 | 407 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -409,8 +418,9 @@ discard block |
||
409 | 418 | 'blank_string' => '', |
410 | 419 | ) |
411 | 420 | ); |
412 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
413 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
421 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
422 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
423 | + } |
|
414 | 424 | $smcFunc['db_free_result']($query); |
415 | 425 | } |
416 | 426 | |
@@ -461,10 +471,11 @@ discard block |
||
461 | 471 | { |
462 | 472 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
463 | 473 | |
464 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
465 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
466 | - elseif (!empty($_REQUEST['xml'])) |
|
467 | - continue; |
|
474 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
475 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
476 | + } elseif (!empty($_REQUEST['xml'])) { |
|
477 | + continue; |
|
478 | + } |
|
468 | 479 | |
469 | 480 | preparsecode($context[$key]); |
470 | 481 | if ($html) |
@@ -543,10 +554,12 @@ discard block |
||
543 | 554 | |
544 | 555 | // Start by finding any members! |
545 | 556 | $toClean = array(); |
546 | - if (!empty($_POST['members'])) |
|
547 | - $toClean[] = 'members'; |
|
548 | - if (!empty($_POST['exclude_members'])) |
|
549 | - $toClean[] = 'exclude_members'; |
|
557 | + if (!empty($_POST['members'])) { |
|
558 | + $toClean[] = 'members'; |
|
559 | + } |
|
560 | + if (!empty($_POST['exclude_members'])) { |
|
561 | + $toClean[] = 'exclude_members'; |
|
562 | + } |
|
550 | 563 | if (!empty($toClean)) |
551 | 564 | { |
552 | 565 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -558,11 +571,13 @@ discard block |
||
558 | 571 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
559 | 572 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
560 | 573 | |
561 | - foreach ($_POST[$type] as $index => $member) |
|
562 | - if (strlen(trim($member)) > 0) |
|
574 | + foreach ($_POST[$type] as $index => $member) { |
|
575 | + if (strlen(trim($member)) > 0) |
|
563 | 576 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
564 | - else |
|
565 | - unset($_POST[$type][$index]); |
|
577 | + } |
|
578 | + else { |
|
579 | + unset($_POST[$type][$index]); |
|
580 | + } |
|
566 | 581 | |
567 | 582 | // Find the members |
568 | 583 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -572,16 +587,18 @@ discard block |
||
572 | 587 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
573 | 588 | { |
574 | 589 | $members = array(); |
575 | - foreach ($_POST['member_list'] as $member_id) |
|
576 | - $members[] = (int) $member_id; |
|
590 | + foreach ($_POST['member_list'] as $member_id) { |
|
591 | + $members[] = (int) $member_id; |
|
592 | + } |
|
577 | 593 | $_POST['members'] = implode(',', $members); |
578 | 594 | } |
579 | 595 | |
580 | 596 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
581 | 597 | { |
582 | 598 | $members = array(); |
583 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
584 | - $members[] = (int) $member_id; |
|
599 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
600 | + $members[] = (int) $member_id; |
|
601 | + } |
|
585 | 602 | $_POST['exclude_members'] = implode(',', $members); |
586 | 603 | } |
587 | 604 | |
@@ -605,8 +622,9 @@ discard block |
||
605 | 622 | 'current_time' => time(), |
606 | 623 | ) |
607 | 624 | ); |
608 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
609 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
625 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
626 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
627 | + } |
|
610 | 628 | $smcFunc['db_free_result']($request); |
611 | 629 | |
612 | 630 | $request = $smcFunc['db_query']('', ' |
@@ -641,8 +659,9 @@ discard block |
||
641 | 659 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
642 | 660 | $condition_array_params |
643 | 661 | ); |
644 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
645 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
662 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
663 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
664 | + } |
|
646 | 665 | $smcFunc['db_free_result']($request); |
647 | 666 | } |
648 | 667 | |
@@ -660,10 +679,11 @@ discard block |
||
660 | 679 | ); |
661 | 680 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
662 | 681 | { |
663 | - if (in_array(3, $context['recipients'])) |
|
664 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
665 | - else |
|
666 | - $context['recipients']['members'][] = $row['identifier']; |
|
682 | + if (in_array(3, $context['recipients'])) { |
|
683 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
684 | + } else { |
|
685 | + $context['recipients']['members'][] = $row['identifier']; |
|
686 | + } |
|
667 | 687 | } |
668 | 688 | $smcFunc['db_free_result']($request); |
669 | 689 | } |
@@ -710,8 +730,9 @@ discard block |
||
710 | 730 | $num_at_once = 1000; |
711 | 731 | |
712 | 732 | // If by PM's I suggest we half the above number. |
713 | - if (!empty($_POST['send_pm'])) |
|
714 | - $num_at_once /= 2; |
|
733 | + if (!empty($_POST['send_pm'])) { |
|
734 | + $num_at_once /= 2; |
|
735 | + } |
|
715 | 736 | |
716 | 737 | checkSession(); |
717 | 738 | |
@@ -734,8 +755,7 @@ discard block |
||
734 | 755 | ); |
735 | 756 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
736 | 757 | $smcFunc['db_free_result']($request); |
737 | - } |
|
738 | - else |
|
758 | + } else |
|
739 | 759 | { |
740 | 760 | $context['total_members'] = (int) $_REQUEST['total_members']; |
741 | 761 | } |
@@ -753,32 +773,35 @@ discard block |
||
753 | 773 | if (!empty($_POST['exclude_members'])) |
754 | 774 | { |
755 | 775 | $members = explode(',', $_POST['exclude_members']); |
756 | - foreach ($members as $member) |
|
757 | - if ($member >= $context['start']) |
|
776 | + foreach ($members as $member) { |
|
777 | + if ($member >= $context['start']) |
|
758 | 778 | $context['recipients']['exclude_members'][] = (int) $member; |
779 | + } |
|
759 | 780 | } |
760 | 781 | |
761 | 782 | // What about members we *must* do? |
762 | 783 | if (!empty($_POST['members'])) |
763 | 784 | { |
764 | 785 | $members = explode(',', $_POST['members']); |
765 | - foreach ($members as $member) |
|
766 | - if ($member >= $context['start']) |
|
786 | + foreach ($members as $member) { |
|
787 | + if ($member >= $context['start']) |
|
767 | 788 | $context['recipients']['members'][] = (int) $member; |
789 | + } |
|
768 | 790 | } |
769 | 791 | // Cleaning groups is simple - although deal with both checkbox and commas. |
770 | 792 | if (isset($_POST['groups'])) |
771 | 793 | { |
772 | 794 | if (is_array($_POST['groups'])) |
773 | 795 | { |
774 | - foreach ($_POST['groups'] as $group => $dummy) |
|
775 | - $context['recipients']['groups'][] = (int) $group; |
|
776 | - } |
|
777 | - else |
|
796 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
797 | + $context['recipients']['groups'][] = (int) $group; |
|
798 | + } |
|
799 | + } else |
|
778 | 800 | { |
779 | 801 | $groups = explode(',', $_POST['groups']); |
780 | - foreach ($groups as $group) |
|
781 | - $context['recipients']['groups'][] = (int) $group; |
|
802 | + foreach ($groups as $group) { |
|
803 | + $context['recipients']['groups'][] = (int) $group; |
|
804 | + } |
|
782 | 805 | } |
783 | 806 | } |
784 | 807 | // Same for excluded groups |
@@ -786,15 +809,17 @@ discard block |
||
786 | 809 | { |
787 | 810 | if (is_array($_POST['exclude_groups'])) |
788 | 811 | { |
789 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
790 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
812 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
813 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
814 | + } |
|
791 | 815 | } |
792 | 816 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
793 | 817 | elseif ($_POST['exclude_groups'] != '') |
794 | 818 | { |
795 | 819 | $groups = explode(',', $_POST['exclude_groups']); |
796 | - foreach ($groups as $group) |
|
797 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
820 | + foreach ($groups as $group) { |
|
821 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
822 | + } |
|
798 | 823 | } |
799 | 824 | } |
800 | 825 | // Finally - emails! |
@@ -804,14 +829,16 @@ discard block |
||
804 | 829 | foreach ($addressed as $curmem) |
805 | 830 | { |
806 | 831 | $curmem = trim($curmem); |
807 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
808 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
832 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
833 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
834 | + } |
|
809 | 835 | } |
810 | 836 | } |
811 | 837 | |
812 | 838 | // If we're only cleaning drop out here. |
813 | - if ($clean_only) |
|
814 | - return; |
|
839 | + if ($clean_only) { |
|
840 | + return; |
|
841 | + } |
|
815 | 842 | |
816 | 843 | require_once($sourcedir . '/Subs-Post.php'); |
817 | 844 | |
@@ -827,16 +854,18 @@ discard block |
||
827 | 854 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
828 | 855 | { |
829 | 856 | // Prepare the message for HTML. |
830 | - if (!empty($_POST['parse_html'])) |
|
831 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
857 | + if (!empty($_POST['parse_html'])) { |
|
858 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
859 | + } |
|
832 | 860 | |
833 | 861 | // This is here to prevent spam filters from tagging this as spam. |
834 | 862 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
835 | 863 | { |
836 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
837 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
838 | - else |
|
839 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
864 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
865 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
866 | + } else { |
|
867 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
868 | + } |
|
840 | 869 | } |
841 | 870 | } |
842 | 871 | |
@@ -890,15 +919,17 @@ discard block |
||
890 | 919 | foreach ($context['recipients']['emails'] as $k => $email) |
891 | 920 | { |
892 | 921 | // Done as many as we can? |
893 | - if ($i >= $num_at_once) |
|
894 | - break; |
|
922 | + if ($i >= $num_at_once) { |
|
923 | + break; |
|
924 | + } |
|
895 | 925 | |
896 | 926 | // Don't sent it twice! |
897 | 927 | unset($context['recipients']['emails'][$k]); |
898 | 928 | |
899 | 929 | // Dammit - can't PM emails! |
900 | - if ($context['send_pm']) |
|
901 | - continue; |
|
930 | + if ($context['send_pm']) { |
|
931 | + continue; |
|
932 | + } |
|
902 | 933 | |
903 | 934 | $to_member = array( |
904 | 935 | $email, |
@@ -932,8 +963,9 @@ discard block |
||
932 | 963 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
933 | 964 | } |
934 | 965 | } |
935 | - if (!empty($queryBuild)) |
|
936 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
966 | + if (!empty($queryBuild)) { |
|
967 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
968 | + } |
|
937 | 969 | } |
938 | 970 | if (!empty($context['recipients']['members'])) |
939 | 971 | { |
@@ -952,8 +984,9 @@ discard block |
||
952 | 984 | } |
953 | 985 | |
954 | 986 | // Anything to exclude? |
955 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
956 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
987 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
988 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
989 | + } |
|
957 | 990 | if (!empty($context['recipients']['exclude_members'])) |
958 | 991 | { |
959 | 992 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -989,21 +1022,24 @@ discard block |
||
989 | 1022 | foreach ($rows as $row) |
990 | 1023 | { |
991 | 1024 | // Force them to have it? |
992 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
993 | - continue; |
|
1025 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
1026 | + continue; |
|
1027 | + } |
|
994 | 1028 | |
995 | 1029 | // What groups are we looking at here? |
996 | - if (empty($row['additional_groups'])) |
|
997 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
998 | - else |
|
999 | - $groups = array_merge( |
|
1030 | + if (empty($row['additional_groups'])) { |
|
1031 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1032 | + } else { |
|
1033 | + $groups = array_merge( |
|
1000 | 1034 | array($row['id_group'], $row['id_post_group']), |
1001 | 1035 | explode(',', $row['additional_groups']) |
1002 | 1036 | ); |
1037 | + } |
|
1003 | 1038 | |
1004 | 1039 | // Excluded groups? |
1005 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1006 | - continue; |
|
1040 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1041 | + continue; |
|
1042 | + } |
|
1007 | 1043 | |
1008 | 1044 | // We might need this |
1009 | 1045 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1026,10 +1062,11 @@ discard block |
||
1026 | 1062 | ), $_POST['subject']); |
1027 | 1063 | |
1028 | 1064 | // Send the actual email - or a PM! |
1029 | - if (!$context['send_pm']) |
|
1030 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1031 | - else |
|
1032 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1065 | + if (!$context['send_pm']) { |
|
1066 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1067 | + } else { |
|
1068 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1069 | + } |
|
1033 | 1070 | } |
1034 | 1071 | } |
1035 | 1072 | |
@@ -1079,8 +1116,9 @@ discard block |
||
1079 | 1116 | |
1080 | 1117 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1081 | 1118 | |
1082 | - if ($return_config) |
|
1083 | - return $config_vars; |
|
1119 | + if ($return_config) { |
|
1120 | + return $config_vars; |
|
1121 | + } |
|
1084 | 1122 | |
1085 | 1123 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1086 | 1124 | $context['sub_template'] = 'show_settings'; |
@@ -5495,7 +5495,6 @@ discard block |
||
5495 | 5495 | |
5496 | 5496 | /** |
5497 | 5497 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
5498 | - |
|
5499 | 5498 | * @param string $file The file/dir full path. |
5500 | 5499 | * @param int $value Not needed, added for legacy reasons. |
5501 | 5500 | * @return boolean true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable. |
@@ -5535,7 +5534,6 @@ discard block |
||
5535 | 5534 | |
5536 | 5535 | /** |
5537 | 5536 | * Wrapper function for json_decode() with error handling. |
5538 | - |
|
5539 | 5537 | * @param string $json The string to decode. |
5540 | 5538 | * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default. |
5541 | 5539 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -6029,7 +6027,7 @@ discard block |
||
6029 | 6027 | $params = stream_context_get_params($stream); |
6030 | 6028 | $result = isset($params["options"]["ssl"]["peer_certificate"]) ? true : false; |
6031 | 6029 | } |
6032 | - return $result; |
|
6030 | + return $result; |
|
6033 | 6031 | } |
6034 | 6032 | |
6035 | 6033 | /** |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * - caches the formatting data from the setting for optimization. |
694 | 694 | * |
695 | 695 | * @param float $number A number |
696 | - * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
696 | + * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
697 | 697 | * @return string A formatted number |
698 | 698 | */ |
699 | 699 | function comma_format($number, $override_decimal_count = false) |
@@ -5646,7 +5646,7 @@ discard block |
||
5646 | 5646 | * It assumes the data is already a string. |
5647 | 5647 | * @param string $data The data to print |
5648 | 5648 | * @param string $type The content type. Defaults to Json. |
5649 | - * @return void |
|
5649 | + * @return false|null |
|
5650 | 5650 | */ |
5651 | 5651 | function smf_serverResponse($data = '', $type = 'content-type: application/json') |
5652 | 5652 | { |
@@ -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, $user_info; |
1417 | 1417 | |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | 'tag' => 'img', |
1438 | 1438 | 'type' => 'unparsed_content', |
1439 | 1439 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
1440 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1440 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1441 | 1441 | { |
1442 | 1442 | global $image_proxy_enabled, $user_info; |
1443 | 1443 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | 'tag' => 'iurl', |
1464 | 1464 | 'type' => 'unparsed_content', |
1465 | 1465 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
1466 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1466 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1467 | 1467 | { |
1468 | 1468 | $data = strtr($data, array('<br>' => '')); |
1469 | 1469 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | 'quoted' => 'optional', |
1478 | 1478 | 'before' => '<a href="$1" class="bbc_link">', |
1479 | 1479 | 'after' => '</a>', |
1480 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1480 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1481 | 1481 | { |
1482 | 1482 | if (substr($data, 0, 1) == '#') |
1483 | 1483 | $data = '#post_' . substr($data, 1); |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | 'tag' => 'php', |
1558 | 1558 | 'type' => 'unparsed_content', |
1559 | 1559 | 'content' => '<span class="phpcode">$1</span>', |
1560 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
1560 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
1561 | 1561 | { |
1562 | 1562 | if (!isset($disabled['php'])) |
1563 | 1563 | { |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | 'test' => '[1-7]\]', |
1656 | 1656 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
1657 | 1657 | 'after' => '</span>', |
1658 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1658 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1659 | 1659 | { |
1660 | 1660 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
1661 | 1661 | $data = $sizes[$data] . 'em'; |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | 'tag' => 'time', |
1694 | 1694 | 'type' => 'unparsed_content', |
1695 | 1695 | 'content' => '$1', |
1696 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1696 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1697 | 1697 | { |
1698 | 1698 | if (is_numeric($data)) |
1699 | 1699 | $data = timeformat($data); |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | 'tag' => 'url', |
1722 | 1722 | 'type' => 'unparsed_content', |
1723 | 1723 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
1724 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1724 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1725 | 1725 | { |
1726 | 1726 | $data = strtr($data, array('<br>' => '')); |
1727 | 1727 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | 'quoted' => 'optional', |
1736 | 1736 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
1737 | 1737 | 'after' => '</a>', |
1738 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1738 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1739 | 1739 | { |
1740 | 1740 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1741 | 1741 | if (empty($scheme)) |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | { |
1762 | 1762 | if (isset($temp_bbc)) |
1763 | 1763 | $bbc_codes = $temp_bbc; |
1764 | - usort($codes, function ($a, $b) { |
|
1764 | + usort($codes, function($a, $b) { |
|
1765 | 1765 | return strcmp($a['tag'], $b['tag']); |
1766 | 1766 | }); |
1767 | 1767 | return $codes; |
@@ -1998,7 +1998,7 @@ discard block |
||
1998 | 1998 | # a run of Unicode domain name characters and a dot |
1999 | 1999 | [\p{L}\p{M}\p{N}\-.:@]+\. |
2000 | 2000 | # and then a TLD valid in the DNS or the reserved "local" TLD |
2001 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
2001 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
2002 | 2002 | ) |
2003 | 2003 | # followed by a non-domain character or end of line |
2004 | 2004 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2066,7 +2066,7 @@ discard block |
||
2066 | 2066 | )? |
2067 | 2067 | '; |
2068 | 2068 | |
2069 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
2069 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
2070 | 2070 | $url = array_shift($matches); |
2071 | 2071 | |
2072 | 2072 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2147,7 +2147,7 @@ discard block |
||
2147 | 2147 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2148 | 2148 | |
2149 | 2149 | // A closing tag that doesn't match any open tags? Skip it. |
2150 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2150 | + if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags))) |
|
2151 | 2151 | continue; |
2152 | 2152 | |
2153 | 2153 | $to_close = array(); |
@@ -2814,7 +2814,7 @@ discard block |
||
2814 | 2814 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
2815 | 2815 | { |
2816 | 2816 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
2817 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2817 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2818 | 2818 | |
2819 | 2819 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
2820 | 2820 | |
@@ -2831,7 +2831,7 @@ discard block |
||
2831 | 2831 | |
2832 | 2832 | // Replace away! |
2833 | 2833 | $message = preg_replace_callback($smileyPregSearch, |
2834 | - function ($matches) use ($smileyPregReplacements) |
|
2834 | + function($matches) use ($smileyPregReplacements) |
|
2835 | 2835 | { |
2836 | 2836 | return $smileyPregReplacements[$matches[1]]; |
2837 | 2837 | }, $message); |
@@ -2915,13 +2915,13 @@ discard block |
||
2915 | 2915 | { |
2916 | 2916 | if (defined('SID') && SID != '') |
2917 | 2917 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
2918 | - function ($m) use ($scripturl) |
|
2918 | + function($m) use ($scripturl) |
|
2919 | 2919 | { |
2920 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
2920 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
2921 | 2921 | }, $setLocation); |
2922 | 2922 | else |
2923 | 2923 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
2924 | - function ($m) use ($scripturl) |
|
2924 | + function($m) use ($scripturl) |
|
2925 | 2925 | { |
2926 | 2926 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2927 | 2927 | }, $setLocation); |
@@ -3244,7 +3244,7 @@ discard block |
||
3244 | 3244 | |
3245 | 3245 | // Add a generic "Are you sure?" confirmation message. |
3246 | 3246 | addInlineJavaScript(' |
3247 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
3247 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
3248 | 3248 | |
3249 | 3249 | // Now add the capping code for avatars. |
3250 | 3250 | 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') |
@@ -3688,7 +3688,7 @@ discard block |
||
3688 | 3688 | if (!empty($normal)) |
3689 | 3689 | foreach ($normal as $nf) |
3690 | 3690 | echo ' |
3691 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
3691 | + <link rel="stylesheet" href="', $nf, '">'; |
|
3692 | 3692 | |
3693 | 3693 | if ($db_show_debug === true) |
3694 | 3694 | { |
@@ -3704,7 +3704,7 @@ discard block |
||
3704 | 3704 | <style>'; |
3705 | 3705 | |
3706 | 3706 | foreach ($context['css_header'] as $css) |
3707 | - echo $css .' |
|
3707 | + echo $css . ' |
|
3708 | 3708 | '; |
3709 | 3709 | |
3710 | 3710 | echo' |
@@ -3743,7 +3743,7 @@ discard block |
||
3743 | 3743 | return true; |
3744 | 3744 | |
3745 | 3745 | // No namespaces, sorry! |
3746 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
3746 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
3747 | 3747 | |
3748 | 3748 | // Temp path. |
3749 | 3749 | $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
@@ -3869,7 +3869,7 @@ discard block |
||
3869 | 3869 | else |
3870 | 3870 | $path = $modSettings['attachmentUploadDir']; |
3871 | 3871 | |
3872 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
3872 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
3873 | 3873 | } |
3874 | 3874 | |
3875 | 3875 | /** |
@@ -3913,10 +3913,10 @@ discard block |
||
3913 | 3913 | $valid_low = isValidIP($ip_parts[0]); |
3914 | 3914 | $valid_high = isValidIP($ip_parts[1]); |
3915 | 3915 | $count = 0; |
3916 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
3916 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
3917 | 3917 | $max = ($mode == ':' ? 'ffff' : '255'); |
3918 | 3918 | $min = 0; |
3919 | - if(!$valid_low) |
|
3919 | + if (!$valid_low) |
|
3920 | 3920 | { |
3921 | 3921 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
3922 | 3922 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3930,7 +3930,7 @@ discard block |
||
3930 | 3930 | } |
3931 | 3931 | |
3932 | 3932 | $count = 0; |
3933 | - if(!$valid_high) |
|
3933 | + if (!$valid_high) |
|
3934 | 3934 | { |
3935 | 3935 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
3936 | 3936 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3943,7 +3943,7 @@ discard block |
||
3943 | 3943 | } |
3944 | 3944 | } |
3945 | 3945 | |
3946 | - if($valid_high && $valid_low) |
|
3946 | + if ($valid_high && $valid_low) |
|
3947 | 3947 | { |
3948 | 3948 | $ip_array['low'] = $ip_parts[0]; |
3949 | 3949 | $ip_array['high'] = $ip_parts[1]; |
@@ -4125,7 +4125,7 @@ discard block |
||
4125 | 4125 | addInlineJavaScript(' |
4126 | 4126 | var user_menus = new smc_PopupMenu(); |
4127 | 4127 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4128 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
4128 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
4129 | 4129 | if ($context['allow_pm']) |
4130 | 4130 | addInlineJavaScript(' |
4131 | 4131 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4761,7 +4761,7 @@ discard block |
||
4761 | 4761 | // No? try a fallback to $sourcedir |
4762 | 4762 | else |
4763 | 4763 | { |
4764 | - $absPath = $sourcedir .'/'. $file; |
|
4764 | + $absPath = $sourcedir . '/' . $file; |
|
4765 | 4765 | |
4766 | 4766 | if (file_exists($absPath)) |
4767 | 4767 | require_once($absPath); |
@@ -4842,15 +4842,15 @@ discard block |
||
4842 | 4842 | |
4843 | 4843 | // UTF-8 occurences of MS special characters |
4844 | 4844 | $findchars_utf8 = array( |
4845 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
4846 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
4847 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
4848 | - "\xe2\x80\x98", // left single curly quote |
|
4849 | - "\xe2\x80\x99", // right single curly quote |
|
4850 | - "\xe2\x80\x9c", // left double curly quote |
|
4851 | - "\xe2\x80\x9d", // right double curly quote |
|
4852 | - "\xe2\x80\x93", // en dash |
|
4853 | - "\xe2\x80\x94", // em dash |
|
4845 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
4846 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
4847 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
4848 | + "\xe2\x80\x98", // left single curly quote |
|
4849 | + "\xe2\x80\x99", // right single curly quote |
|
4850 | + "\xe2\x80\x9c", // left double curly quote |
|
4851 | + "\xe2\x80\x9d", // right double curly quote |
|
4852 | + "\xe2\x80\x93", // en dash |
|
4853 | + "\xe2\x80\x94", // em dash |
|
4854 | 4854 | ); |
4855 | 4855 | |
4856 | 4856 | // windows 1252 / iso equivalents |
@@ -4868,15 +4868,15 @@ discard block |
||
4868 | 4868 | |
4869 | 4869 | // safe replacements |
4870 | 4870 | $replacechars = array( |
4871 | - ',', // ‚ |
|
4872 | - ',,', // „ |
|
4873 | - '...', // … |
|
4874 | - "'", // ‘ |
|
4875 | - "'", // ’ |
|
4876 | - '"', // “ |
|
4877 | - '"', // ” |
|
4878 | - '-', // – |
|
4879 | - '--', // — |
|
4871 | + ',', // ‚ |
|
4872 | + ',,', // „ |
|
4873 | + '...', // … |
|
4874 | + "'", // ‘ |
|
4875 | + "'", // ’ |
|
4876 | + '"', // “ |
|
4877 | + '"', // ” |
|
4878 | + '-', // – |
|
4879 | + '--', // — |
|
4880 | 4880 | ); |
4881 | 4881 | |
4882 | 4882 | if ($context['utf8']) |
@@ -5294,7 +5294,7 @@ discard block |
||
5294 | 5294 | */ |
5295 | 5295 | function inet_dtop($bin) |
5296 | 5296 | { |
5297 | - if(empty($bin)) |
|
5297 | + if (empty($bin)) |
|
5298 | 5298 | return ''; |
5299 | 5299 | |
5300 | 5300 | global $db_type; |
@@ -5325,28 +5325,28 @@ discard block |
||
5325 | 5325 | */ |
5326 | 5326 | function _safe_serialize($value) |
5327 | 5327 | { |
5328 | - if(is_null($value)) |
|
5328 | + if (is_null($value)) |
|
5329 | 5329 | return 'N;'; |
5330 | 5330 | |
5331 | - if(is_bool($value)) |
|
5332 | - return 'b:'. (int) $value .';'; |
|
5331 | + if (is_bool($value)) |
|
5332 | + return 'b:' . (int) $value . ';'; |
|
5333 | 5333 | |
5334 | - if(is_int($value)) |
|
5335 | - return 'i:'. $value .';'; |
|
5334 | + if (is_int($value)) |
|
5335 | + return 'i:' . $value . ';'; |
|
5336 | 5336 | |
5337 | - if(is_float($value)) |
|
5338 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5337 | + if (is_float($value)) |
|
5338 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
5339 | 5339 | |
5340 | - if(is_string($value)) |
|
5341 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5340 | + if (is_string($value)) |
|
5341 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
5342 | 5342 | |
5343 | - if(is_array($value)) |
|
5343 | + if (is_array($value)) |
|
5344 | 5344 | { |
5345 | 5345 | $out = ''; |
5346 | - foreach($value as $k => $v) |
|
5346 | + foreach ($value as $k => $v) |
|
5347 | 5347 | $out .= _safe_serialize($k) . _safe_serialize($v); |
5348 | 5348 | |
5349 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
5349 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
5350 | 5350 | } |
5351 | 5351 | |
5352 | 5352 | // safe_serialize cannot serialize resources or objects. |
@@ -5388,7 +5388,7 @@ discard block |
||
5388 | 5388 | function _safe_unserialize($str) |
5389 | 5389 | { |
5390 | 5390 | // Input is not a string. |
5391 | - if(empty($str) || !is_string($str)) |
|
5391 | + if (empty($str) || !is_string($str)) |
|
5392 | 5392 | return false; |
5393 | 5393 | |
5394 | 5394 | $stack = array(); |
@@ -5402,40 +5402,40 @@ discard block |
||
5402 | 5402 | * 3 - in array, expecting value or another array |
5403 | 5403 | */ |
5404 | 5404 | $state = 0; |
5405 | - while($state != 1) |
|
5405 | + while ($state != 1) |
|
5406 | 5406 | { |
5407 | 5407 | $type = isset($str[0]) ? $str[0] : ''; |
5408 | - if($type == '}') |
|
5408 | + if ($type == '}') |
|
5409 | 5409 | $str = substr($str, 1); |
5410 | 5410 | |
5411 | - else if($type == 'N' && $str[1] == ';') |
|
5411 | + else if ($type == 'N' && $str[1] == ';') |
|
5412 | 5412 | { |
5413 | 5413 | $value = null; |
5414 | 5414 | $str = substr($str, 2); |
5415 | 5415 | } |
5416 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5416 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5417 | 5417 | { |
5418 | 5418 | $value = $matches[1] == '1' ? true : false; |
5419 | 5419 | $str = substr($str, 4); |
5420 | 5420 | } |
5421 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5421 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5422 | 5422 | { |
5423 | - $value = (int)$matches[1]; |
|
5423 | + $value = (int) $matches[1]; |
|
5424 | 5424 | $str = $matches[2]; |
5425 | 5425 | } |
5426 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5426 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5427 | 5427 | { |
5428 | - $value = (float)$matches[1]; |
|
5428 | + $value = (float) $matches[1]; |
|
5429 | 5429 | $str = $matches[3]; |
5430 | 5430 | } |
5431 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5431 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
5432 | 5432 | { |
5433 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
5434 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
5433 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
5434 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
5435 | 5435 | } |
5436 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5436 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5437 | 5437 | { |
5438 | - $expectedLength = (int)$matches[1]; |
|
5438 | + $expectedLength = (int) $matches[1]; |
|
5439 | 5439 | $str = $matches[2]; |
5440 | 5440 | } |
5441 | 5441 | |
@@ -5443,10 +5443,10 @@ discard block |
||
5443 | 5443 | else |
5444 | 5444 | return false; |
5445 | 5445 | |
5446 | - switch($state) |
|
5446 | + switch ($state) |
|
5447 | 5447 | { |
5448 | 5448 | case 3: // In array, expecting value or another array. |
5449 | - if($type == 'a') |
|
5449 | + if ($type == 'a') |
|
5450 | 5450 | { |
5451 | 5451 | $stack[] = &$list; |
5452 | 5452 | $list[$key] = array(); |
@@ -5455,7 +5455,7 @@ discard block |
||
5455 | 5455 | $state = 2; |
5456 | 5456 | break; |
5457 | 5457 | } |
5458 | - if($type != '}') |
|
5458 | + if ($type != '}') |
|
5459 | 5459 | { |
5460 | 5460 | $list[$key] = $value; |
5461 | 5461 | $state = 2; |
@@ -5466,29 +5466,29 @@ discard block |
||
5466 | 5466 | return false; |
5467 | 5467 | |
5468 | 5468 | case 2: // in array, expecting end of array or a key |
5469 | - if($type == '}') |
|
5469 | + if ($type == '}') |
|
5470 | 5470 | { |
5471 | 5471 | // Array size is less than expected. |
5472 | - if(count($list) < end($expected)) |
|
5472 | + if (count($list) < end($expected)) |
|
5473 | 5473 | return false; |
5474 | 5474 | |
5475 | 5475 | unset($list); |
5476 | - $list = &$stack[count($stack)-1]; |
|
5476 | + $list = &$stack[count($stack) - 1]; |
|
5477 | 5477 | array_pop($stack); |
5478 | 5478 | |
5479 | 5479 | // Go to terminal state if we're at the end of the root array. |
5480 | 5480 | array_pop($expected); |
5481 | 5481 | |
5482 | - if(count($expected) == 0) |
|
5482 | + if (count($expected) == 0) |
|
5483 | 5483 | $state = 1; |
5484 | 5484 | |
5485 | 5485 | break; |
5486 | 5486 | } |
5487 | 5487 | |
5488 | - if($type == 'i' || $type == 's') |
|
5488 | + if ($type == 'i' || $type == 's') |
|
5489 | 5489 | { |
5490 | 5490 | // Array size exceeds expected length. |
5491 | - if(count($list) >= end($expected)) |
|
5491 | + if (count($list) >= end($expected)) |
|
5492 | 5492 | return false; |
5493 | 5493 | |
5494 | 5494 | $key = $value; |
@@ -5501,7 +5501,7 @@ discard block |
||
5501 | 5501 | |
5502 | 5502 | // Expecting array or value. |
5503 | 5503 | case 0: |
5504 | - if($type == 'a') |
|
5504 | + if ($type == 'a') |
|
5505 | 5505 | { |
5506 | 5506 | $data = array(); |
5507 | 5507 | $list = &$data; |
@@ -5510,7 +5510,7 @@ discard block |
||
5510 | 5510 | break; |
5511 | 5511 | } |
5512 | 5512 | |
5513 | - if($type != '}') |
|
5513 | + if ($type != '}') |
|
5514 | 5514 | { |
5515 | 5515 | $data = $value; |
5516 | 5516 | $state = 1; |
@@ -5523,7 +5523,7 @@ discard block |
||
5523 | 5523 | } |
5524 | 5524 | |
5525 | 5525 | // Trailing data in input. |
5526 | - if(!empty($str)) |
|
5526 | + if (!empty($str)) |
|
5527 | 5527 | return false; |
5528 | 5528 | |
5529 | 5529 | return $data; |
@@ -5577,7 +5577,7 @@ discard block |
||
5577 | 5577 | // Set different modes. |
5578 | 5578 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
5579 | 5579 | |
5580 | - foreach($chmodValues as $val) |
|
5580 | + foreach ($chmodValues as $val) |
|
5581 | 5581 | { |
5582 | 5582 | // If it's writable, break out of the loop. |
5583 | 5583 | if (is_writable($file)) |
@@ -5612,13 +5612,13 @@ discard block |
||
5612 | 5612 | $returnArray = @json_decode($json, $returnAsArray); |
5613 | 5613 | |
5614 | 5614 | // PHP 5.3 so no json_last_error_msg() |
5615 | - switch(json_last_error()) |
|
5615 | + switch (json_last_error()) |
|
5616 | 5616 | { |
5617 | 5617 | case JSON_ERROR_NONE: |
5618 | 5618 | $jsonError = false; |
5619 | 5619 | break; |
5620 | 5620 | case JSON_ERROR_DEPTH: |
5621 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
5621 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
5622 | 5622 | break; |
5623 | 5623 | case JSON_ERROR_STATE_MISMATCH: |
5624 | 5624 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5646,10 +5646,10 @@ discard block |
||
5646 | 5646 | loadLanguage('Errors'); |
5647 | 5647 | |
5648 | 5648 | if (!empty($jsonDebug)) |
5649 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5649 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5650 | 5650 | |
5651 | 5651 | else |
5652 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5652 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
5653 | 5653 | |
5654 | 5654 | // Everyone expects an array. |
5655 | 5655 | return array(); |
@@ -5761,7 +5761,7 @@ discard block |
||
5761 | 5761 | }); |
5762 | 5762 | |
5763 | 5763 | // Convert Punycode to Unicode |
5764 | - $tlds = array_map(function ($input) { |
|
5764 | + $tlds = array_map(function($input) { |
|
5765 | 5765 | $prefix = 'xn--'; |
5766 | 5766 | $safe_char = 0xFFFC; |
5767 | 5767 | $base = 36; |
@@ -5777,7 +5777,7 @@ discard block |
||
5777 | 5777 | |
5778 | 5778 | foreach ($enco_parts as $encoded) |
5779 | 5779 | { |
5780 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
5780 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
5781 | 5781 | { |
5782 | 5782 | $output_parts[] = $encoded; |
5783 | 5783 | continue; |
@@ -5788,7 +5788,7 @@ discard block |
||
5788 | 5788 | $idx = 0; |
5789 | 5789 | $char = 0x80; |
5790 | 5790 | $decoded = array(); |
5791 | - $output=''; |
|
5791 | + $output = ''; |
|
5792 | 5792 | $delim_pos = strrpos($encoded, '-'); |
5793 | 5793 | |
5794 | 5794 | if ($delim_pos > strlen($prefix)) |
@@ -5804,7 +5804,7 @@ discard block |
||
5804 | 5804 | |
5805 | 5805 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
5806 | 5806 | { |
5807 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
5807 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
5808 | 5808 | { |
5809 | 5809 | $cp = ord($encoded{$enco_idx++}); |
5810 | 5810 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5845,15 +5845,15 @@ discard block |
||
5845 | 5845 | |
5846 | 5846 | // 2 bytes |
5847 | 5847 | elseif ($v < (1 << 11)) |
5848 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
5848 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
5849 | 5849 | |
5850 | 5850 | // 3 bytes |
5851 | 5851 | elseif ($v < (1 << 16)) |
5852 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5852 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5853 | 5853 | |
5854 | 5854 | // 4 bytes |
5855 | 5855 | elseif ($v < (1 << 21)) |
5856 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5856 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5857 | 5857 | |
5858 | 5858 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5859 | 5859 | else |
@@ -5958,7 +5958,7 @@ discard block |
||
5958 | 5958 | } |
5959 | 5959 | |
5960 | 5960 | // This recursive function creates the index array from the strings |
5961 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5961 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5962 | 5962 | { |
5963 | 5963 | static $depth = 0; |
5964 | 5964 | $depth++; |
@@ -5985,7 +5985,7 @@ discard block |
||
5985 | 5985 | }; |
5986 | 5986 | |
5987 | 5987 | // This recursive function turns the index array into a regular expression |
5988 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5988 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5989 | 5989 | { |
5990 | 5990 | static $depth = 0; |
5991 | 5991 | $depth++; |
@@ -6009,11 +6009,11 @@ discard block |
||
6009 | 6009 | |
6010 | 6010 | if (count(array_keys($value)) == 1) |
6011 | 6011 | { |
6012 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
6012 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
6013 | 6013 | $new_key .= $new_key_array[0]; |
6014 | 6014 | } |
6015 | 6015 | else |
6016 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6016 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
6017 | 6017 | } |
6018 | 6018 | |
6019 | 6019 | if ($depth > 1) |
@@ -6056,10 +6056,10 @@ discard block |
||
6056 | 6056 | { |
6057 | 6057 | $regex = array(); |
6058 | 6058 | while (!empty($index)) |
6059 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6059 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6060 | 6060 | } |
6061 | 6061 | else |
6062 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6062 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6063 | 6063 | |
6064 | 6064 | // Restore PHP's internal character encoding to whatever it was originally |
6065 | 6065 | 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,17 +1489,20 @@ discard block |
||
1419 | 1489 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1420 | 1490 | if ($image_proxy_enabled) |
1421 | 1491 | { |
1422 | - if (!empty($user_info['possibly_robot'])) |
|
1423 | - return; |
|
1492 | + if (!empty($user_info['possibly_robot'])) { |
|
1493 | + return; |
|
1494 | + } |
|
1424 | 1495 | |
1425 | - if (empty($scheme)) |
|
1426 | - $data = 'http://' . ltrim($data, ':/'); |
|
1496 | + if (empty($scheme)) { |
|
1497 | + $data = 'http://' . ltrim($data, ':/'); |
|
1498 | + } |
|
1427 | 1499 | |
1428 | - if ($scheme != 'https') |
|
1429 | - $data = get_proxied_url($data); |
|
1500 | + if ($scheme != 'https') { |
|
1501 | + $data = get_proxied_url($data); |
|
1502 | + } |
|
1503 | + } elseif (empty($scheme)) { |
|
1504 | + $data = '//' . ltrim($data, ':/'); |
|
1430 | 1505 | } |
1431 | - elseif (empty($scheme)) |
|
1432 | - $data = '//' . ltrim($data, ':/'); |
|
1433 | 1506 | }, |
1434 | 1507 | 'disabled_content' => '($1)', |
1435 | 1508 | ), |
@@ -1445,17 +1518,20 @@ discard block |
||
1445 | 1518 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1446 | 1519 | if ($image_proxy_enabled) |
1447 | 1520 | { |
1448 | - if (!empty($user_info['possibly_robot'])) |
|
1449 | - return; |
|
1521 | + if (!empty($user_info['possibly_robot'])) { |
|
1522 | + return; |
|
1523 | + } |
|
1450 | 1524 | |
1451 | - if (empty($scheme)) |
|
1452 | - $data = 'http://' . ltrim($data, ':/'); |
|
1525 | + if (empty($scheme)) { |
|
1526 | + $data = 'http://' . ltrim($data, ':/'); |
|
1527 | + } |
|
1453 | 1528 | |
1454 | - if ($scheme != 'https') |
|
1455 | - $data = get_proxied_url($data); |
|
1529 | + if ($scheme != 'https') { |
|
1530 | + $data = get_proxied_url($data); |
|
1531 | + } |
|
1532 | + } elseif (empty($scheme)) { |
|
1533 | + $data = '//' . ltrim($data, ':/'); |
|
1456 | 1534 | } |
1457 | - elseif (empty($scheme)) |
|
1458 | - $data = '//' . ltrim($data, ':/'); |
|
1459 | 1535 | }, |
1460 | 1536 | 'disabled_content' => '($1)', |
1461 | 1537 | ), |
@@ -1467,8 +1543,9 @@ discard block |
||
1467 | 1543 | { |
1468 | 1544 | $data = strtr($data, array('<br>' => '')); |
1469 | 1545 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1470 | - if (empty($scheme)) |
|
1471 | - $data = '//' . ltrim($data, ':/'); |
|
1546 | + if (empty($scheme)) { |
|
1547 | + $data = '//' . ltrim($data, ':/'); |
|
1548 | + } |
|
1472 | 1549 | }, |
1473 | 1550 | ), |
1474 | 1551 | array( |
@@ -1479,13 +1556,14 @@ discard block |
||
1479 | 1556 | 'after' => '</a>', |
1480 | 1557 | 'validate' => function (&$tag, &$data, $disabled) |
1481 | 1558 | { |
1482 | - if (substr($data, 0, 1) == '#') |
|
1483 | - $data = '#post_' . substr($data, 1); |
|
1484 | - else |
|
1559 | + if (substr($data, 0, 1) == '#') { |
|
1560 | + $data = '#post_' . substr($data, 1); |
|
1561 | + } else |
|
1485 | 1562 | { |
1486 | 1563 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1487 | - if (empty($scheme)) |
|
1488 | - $data = '//' . ltrim($data, ':/'); |
|
1564 | + if (empty($scheme)) { |
|
1565 | + $data = '//' . ltrim($data, ':/'); |
|
1566 | + } |
|
1489 | 1567 | } |
1490 | 1568 | }, |
1491 | 1569 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1563,8 +1641,9 @@ discard block |
||
1563 | 1641 | { |
1564 | 1642 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1565 | 1643 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1566 | - if ($add_begin) |
|
1567 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1644 | + if ($add_begin) { |
|
1645 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1646 | + } |
|
1568 | 1647 | } |
1569 | 1648 | }, |
1570 | 1649 | 'block_level' => false, |
@@ -1695,10 +1774,11 @@ discard block |
||
1695 | 1774 | 'content' => '$1', |
1696 | 1775 | 'validate' => function (&$tag, &$data, $disabled) |
1697 | 1776 | { |
1698 | - if (is_numeric($data)) |
|
1699 | - $data = timeformat($data); |
|
1700 | - else |
|
1701 | - $tag['content'] = '[time]$1[/time]'; |
|
1777 | + if (is_numeric($data)) { |
|
1778 | + $data = timeformat($data); |
|
1779 | + } else { |
|
1780 | + $tag['content'] = '[time]$1[/time]'; |
|
1781 | + } |
|
1702 | 1782 | }, |
1703 | 1783 | ), |
1704 | 1784 | array( |
@@ -1725,8 +1805,9 @@ discard block |
||
1725 | 1805 | { |
1726 | 1806 | $data = strtr($data, array('<br>' => '')); |
1727 | 1807 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1728 | - if (empty($scheme)) |
|
1729 | - $data = '//' . ltrim($data, ':/'); |
|
1808 | + if (empty($scheme)) { |
|
1809 | + $data = '//' . ltrim($data, ':/'); |
|
1810 | + } |
|
1730 | 1811 | }, |
1731 | 1812 | ), |
1732 | 1813 | array( |
@@ -1738,8 +1819,9 @@ discard block |
||
1738 | 1819 | 'validate' => function (&$tag, &$data, $disabled) |
1739 | 1820 | { |
1740 | 1821 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1741 | - if (empty($scheme)) |
|
1742 | - $data = '//' . ltrim($data, ':/'); |
|
1822 | + if (empty($scheme)) { |
|
1823 | + $data = '//' . ltrim($data, ':/'); |
|
1824 | + } |
|
1743 | 1825 | }, |
1744 | 1826 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1745 | 1827 | 'disabled_after' => ' ($1)', |
@@ -1759,8 +1841,9 @@ discard block |
||
1759 | 1841 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1760 | 1842 | if ($message === false) |
1761 | 1843 | { |
1762 | - if (isset($temp_bbc)) |
|
1763 | - $bbc_codes = $temp_bbc; |
|
1844 | + if (isset($temp_bbc)) { |
|
1845 | + $bbc_codes = $temp_bbc; |
|
1846 | + } |
|
1764 | 1847 | usort($codes, function ($a, $b) { |
1765 | 1848 | return strcmp($a['tag'], $b['tag']); |
1766 | 1849 | }); |
@@ -1780,8 +1863,9 @@ discard block |
||
1780 | 1863 | ); |
1781 | 1864 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1782 | 1865 | { |
1783 | - foreach ($itemcodes as $c => $dummy) |
|
1784 | - $bbc_codes[$c] = array(); |
|
1866 | + foreach ($itemcodes as $c => $dummy) { |
|
1867 | + $bbc_codes[$c] = array(); |
|
1868 | + } |
|
1785 | 1869 | } |
1786 | 1870 | |
1787 | 1871 | // Shhhh! |
@@ -1802,12 +1886,14 @@ discard block |
||
1802 | 1886 | foreach ($codes as $code) |
1803 | 1887 | { |
1804 | 1888 | // Make it easier to process parameters later |
1805 | - if (!empty($code['parameters'])) |
|
1806 | - ksort($code['parameters'], SORT_STRING); |
|
1889 | + if (!empty($code['parameters'])) { |
|
1890 | + ksort($code['parameters'], SORT_STRING); |
|
1891 | + } |
|
1807 | 1892 | |
1808 | 1893 | // If we are not doing every tag only do ones we are interested in. |
1809 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1810 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1894 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1895 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1896 | + } |
|
1811 | 1897 | } |
1812 | 1898 | $codes = null; |
1813 | 1899 | } |
@@ -1818,8 +1904,9 @@ discard block |
||
1818 | 1904 | // It's likely this will change if the message is modified. |
1819 | 1905 | $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']); |
1820 | 1906 | |
1821 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1822 | - return $temp; |
|
1907 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1908 | + return $temp; |
|
1909 | + } |
|
1823 | 1910 | |
1824 | 1911 | $cache_t = microtime(); |
1825 | 1912 | } |
@@ -1851,8 +1938,9 @@ discard block |
||
1851 | 1938 | $disabled['flash'] = true; |
1852 | 1939 | |
1853 | 1940 | // @todo Change maybe? |
1854 | - if (!isset($_GET['images'])) |
|
1855 | - $disabled['img'] = true; |
|
1941 | + if (!isset($_GET['images'])) { |
|
1942 | + $disabled['img'] = true; |
|
1943 | + } |
|
1856 | 1944 | |
1857 | 1945 | // @todo Interface/setting to add more? |
1858 | 1946 | } |
@@ -1876,8 +1964,9 @@ discard block |
||
1876 | 1964 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1877 | 1965 | |
1878 | 1966 | // Failsafe. |
1879 | - if ($pos === false || $last_pos > $pos) |
|
1880 | - $pos = strlen($message) + 1; |
|
1967 | + if ($pos === false || $last_pos > $pos) { |
|
1968 | + $pos = strlen($message) + 1; |
|
1969 | + } |
|
1881 | 1970 | |
1882 | 1971 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1883 | 1972 | if ($last_pos < $pos - 1) |
@@ -1895,8 +1984,9 @@ discard block |
||
1895 | 1984 | |
1896 | 1985 | // <br> should be empty. |
1897 | 1986 | $empty_tags = array('br', 'hr'); |
1898 | - foreach ($empty_tags as $tag) |
|
1899 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1987 | + foreach ($empty_tags as $tag) { |
|
1988 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1989 | + } |
|
1900 | 1990 | |
1901 | 1991 | // b, u, i, s, pre... basic tags. |
1902 | 1992 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1905,8 +1995,9 @@ discard block |
||
1905 | 1995 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1906 | 1996 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1907 | 1997 | |
1908 | - if ($diff > 0) |
|
1909 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1998 | + if ($diff > 0) { |
|
1999 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
2000 | + } |
|
1910 | 2001 | } |
1911 | 2002 | |
1912 | 2003 | // Do <img ...> - with security... action= -> action-. |
@@ -1919,8 +2010,9 @@ discard block |
||
1919 | 2010 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1920 | 2011 | |
1921 | 2012 | // Remove action= from the URL - no funny business, now. |
1922 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1923 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2013 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
2014 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2015 | + } |
|
1924 | 2016 | |
1925 | 2017 | $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
1926 | 2018 | } |
@@ -1935,16 +2027,18 @@ discard block |
||
1935 | 2027 | $no_autolink_area = false; |
1936 | 2028 | if (!empty($open_tags)) |
1937 | 2029 | { |
1938 | - foreach ($open_tags as $open_tag) |
|
1939 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
2030 | + foreach ($open_tags as $open_tag) { |
|
2031 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1940 | 2032 | $no_autolink_area = true; |
2033 | + } |
|
1941 | 2034 | } |
1942 | 2035 | |
1943 | 2036 | // Don't go backwards. |
1944 | 2037 | // @todo Don't think is the real solution.... |
1945 | 2038 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1946 | - if ($pos < $lastAutoPos) |
|
1947 | - $no_autolink_area = true; |
|
2039 | + if ($pos < $lastAutoPos) { |
|
2040 | + $no_autolink_area = true; |
|
2041 | + } |
|
1948 | 2042 | $lastAutoPos = $pos; |
1949 | 2043 | |
1950 | 2044 | if (!$no_autolink_area) |
@@ -2053,17 +2147,19 @@ discard block |
||
2053 | 2147 | if ($scheme == 'mailto') |
2054 | 2148 | { |
2055 | 2149 | $email_address = str_replace('mailto:', '', $url); |
2056 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2057 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2058 | - else |
|
2059 | - return $url; |
|
2150 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2151 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2152 | + } else { |
|
2153 | + return $url; |
|
2154 | + } |
|
2060 | 2155 | } |
2061 | 2156 | |
2062 | 2157 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2063 | - if (empty($scheme)) |
|
2064 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2065 | - else |
|
2066 | - $fullUrl = $url; |
|
2158 | + if (empty($scheme)) { |
|
2159 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2160 | + } else { |
|
2161 | + $fullUrl = $url; |
|
2162 | + } |
|
2067 | 2163 | |
2068 | 2164 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2069 | 2165 | }, $data); |
@@ -2112,22 +2208,25 @@ discard block |
||
2112 | 2208 | } |
2113 | 2209 | |
2114 | 2210 | // Are we there yet? Are we there yet? |
2115 | - if ($pos >= strlen($message) - 1) |
|
2116 | - break; |
|
2211 | + if ($pos >= strlen($message) - 1) { |
|
2212 | + break; |
|
2213 | + } |
|
2117 | 2214 | |
2118 | 2215 | $tags = strtolower($message[$pos + 1]); |
2119 | 2216 | |
2120 | 2217 | if ($tags == '/' && !empty($open_tags)) |
2121 | 2218 | { |
2122 | 2219 | $pos2 = strpos($message, ']', $pos + 1); |
2123 | - if ($pos2 == $pos + 2) |
|
2124 | - continue; |
|
2220 | + if ($pos2 == $pos + 2) { |
|
2221 | + continue; |
|
2222 | + } |
|
2125 | 2223 | |
2126 | 2224 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2127 | 2225 | |
2128 | 2226 | // A closing tag that doesn't match any open tags? Skip it. |
2129 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2130 | - continue; |
|
2227 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
2228 | + continue; |
|
2229 | + } |
|
2131 | 2230 | |
2132 | 2231 | $to_close = array(); |
2133 | 2232 | $block_level = null; |
@@ -2135,8 +2234,9 @@ discard block |
||
2135 | 2234 | do |
2136 | 2235 | { |
2137 | 2236 | $tag = array_pop($open_tags); |
2138 | - if (!$tag) |
|
2139 | - break; |
|
2237 | + if (!$tag) { |
|
2238 | + break; |
|
2239 | + } |
|
2140 | 2240 | |
2141 | 2241 | if (!empty($tag['block_level'])) |
2142 | 2242 | { |
@@ -2150,10 +2250,11 @@ discard block |
||
2150 | 2250 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2151 | 2251 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2152 | 2252 | { |
2153 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2154 | - if ($temp['tag'] == $look_for) |
|
2253 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2254 | + if ($temp['tag'] == $look_for) |
|
2155 | 2255 | { |
2156 | 2256 | $block_level = !empty($temp['block_level']); |
2257 | + } |
|
2157 | 2258 | break; |
2158 | 2259 | } |
2159 | 2260 | } |
@@ -2175,15 +2276,15 @@ discard block |
||
2175 | 2276 | { |
2176 | 2277 | $open_tags = $to_close; |
2177 | 2278 | continue; |
2178 | - } |
|
2179 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2279 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2180 | 2280 | { |
2181 | 2281 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2182 | 2282 | { |
2183 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2184 | - if ($temp['tag'] == $look_for) |
|
2283 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2284 | + if ($temp['tag'] == $look_for) |
|
2185 | 2285 | { |
2186 | 2286 | $block_level = !empty($temp['block_level']); |
2287 | + } |
|
2187 | 2288 | break; |
2188 | 2289 | } |
2189 | 2290 | } |
@@ -2191,8 +2292,9 @@ discard block |
||
2191 | 2292 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2192 | 2293 | if (!$block_level) |
2193 | 2294 | { |
2194 | - foreach ($to_close as $tag) |
|
2195 | - array_push($open_tags, $tag); |
|
2295 | + foreach ($to_close as $tag) { |
|
2296 | + array_push($open_tags, $tag); |
|
2297 | + } |
|
2196 | 2298 | continue; |
2197 | 2299 | } |
2198 | 2300 | } |
@@ -2205,14 +2307,17 @@ discard block |
||
2205 | 2307 | |
2206 | 2308 | // See the comment at the end of the big loop - just eating whitespace ;). |
2207 | 2309 | $whitespace_regex = ''; |
2208 | - if (!empty($tag['block_level'])) |
|
2209 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2310 | + if (!empty($tag['block_level'])) { |
|
2311 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2312 | + } |
|
2210 | 2313 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2211 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2212 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2314 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2315 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2316 | + } |
|
2213 | 2317 | |
2214 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2215 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2318 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2319 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2320 | + } |
|
2216 | 2321 | } |
2217 | 2322 | |
2218 | 2323 | if (!empty($to_close)) |
@@ -2225,8 +2330,9 @@ discard block |
||
2225 | 2330 | } |
2226 | 2331 | |
2227 | 2332 | // No tags for this character, so just keep going (fastest possible course.) |
2228 | - if (!isset($bbc_codes[$tags])) |
|
2229 | - continue; |
|
2333 | + if (!isset($bbc_codes[$tags])) { |
|
2334 | + continue; |
|
2335 | + } |
|
2230 | 2336 | |
2231 | 2337 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2232 | 2338 | $tag = null; |
@@ -2235,48 +2341,57 @@ discard block |
||
2235 | 2341 | $pt_strlen = strlen($possible['tag']); |
2236 | 2342 | |
2237 | 2343 | // Not a match? |
2238 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2239 | - continue; |
|
2344 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2345 | + continue; |
|
2346 | + } |
|
2240 | 2347 | |
2241 | 2348 | $next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : ''; |
2242 | 2349 | |
2243 | 2350 | // A tag is the last char maybe |
2244 | - if ($next_c == '') |
|
2245 | - break; |
|
2351 | + if ($next_c == '') { |
|
2352 | + break; |
|
2353 | + } |
|
2246 | 2354 | |
2247 | 2355 | // A test validation? |
2248 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2249 | - continue; |
|
2356 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2357 | + continue; |
|
2358 | + } |
|
2250 | 2359 | // Do we want parameters? |
2251 | 2360 | elseif (!empty($possible['parameters'])) |
2252 | 2361 | { |
2253 | - if ($next_c != ' ') |
|
2254 | - continue; |
|
2255 | - } |
|
2256 | - elseif (isset($possible['type'])) |
|
2362 | + if ($next_c != ' ') { |
|
2363 | + continue; |
|
2364 | + } |
|
2365 | + } elseif (isset($possible['type'])) |
|
2257 | 2366 | { |
2258 | 2367 | // Do we need an equal sign? |
2259 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2260 | - continue; |
|
2368 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2369 | + continue; |
|
2370 | + } |
|
2261 | 2371 | // Maybe we just want a /... |
2262 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2263 | - continue; |
|
2372 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2373 | + continue; |
|
2374 | + } |
|
2264 | 2375 | // An immediate ]? |
2265 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2266 | - continue; |
|
2376 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2377 | + continue; |
|
2378 | + } |
|
2267 | 2379 | } |
2268 | 2380 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2269 | - elseif ($next_c != ']') |
|
2270 | - continue; |
|
2381 | + elseif ($next_c != ']') { |
|
2382 | + continue; |
|
2383 | + } |
|
2271 | 2384 | |
2272 | 2385 | // Check allowed tree? |
2273 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2274 | - continue; |
|
2275 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2276 | - continue; |
|
2386 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2387 | + continue; |
|
2388 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2389 | + continue; |
|
2390 | + } |
|
2277 | 2391 | // If this is in the list of disallowed child tags, don't parse it. |
2278 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2279 | - continue; |
|
2392 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2393 | + continue; |
|
2394 | + } |
|
2280 | 2395 | |
2281 | 2396 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2282 | 2397 | |
@@ -2288,8 +2403,9 @@ discard block |
||
2288 | 2403 | foreach ($open_tags as $open_quote) |
2289 | 2404 | { |
2290 | 2405 | // Every parent quote this quote has flips the styling |
2291 | - if ($open_quote['tag'] == 'quote') |
|
2292 | - $quote_alt = !$quote_alt; |
|
2406 | + if ($open_quote['tag'] == 'quote') { |
|
2407 | + $quote_alt = !$quote_alt; |
|
2408 | + } |
|
2293 | 2409 | } |
2294 | 2410 | // Add a class to the quote to style alternating blockquotes |
2295 | 2411 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2300,8 +2416,9 @@ discard block |
||
2300 | 2416 | { |
2301 | 2417 | // Build a regular expression for each parameter for the current tag. |
2302 | 2418 | $preg = array(); |
2303 | - foreach ($possible['parameters'] as $p => $info) |
|
2304 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2419 | + foreach ($possible['parameters'] as $p => $info) { |
|
2420 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2421 | + } |
|
2305 | 2422 | |
2306 | 2423 | // Extract the string that potentially holds our parameters. |
2307 | 2424 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2321,24 +2438,27 @@ discard block |
||
2321 | 2438 | |
2322 | 2439 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2323 | 2440 | |
2324 | - if ($match) |
|
2325 | - $blob_counter = count($blobs) + 1; |
|
2441 | + if ($match) { |
|
2442 | + $blob_counter = count($blobs) + 1; |
|
2443 | + } |
|
2326 | 2444 | } |
2327 | 2445 | |
2328 | 2446 | // Didn't match our parameter list, try the next possible. |
2329 | - if (!$match) |
|
2330 | - continue; |
|
2447 | + if (!$match) { |
|
2448 | + continue; |
|
2449 | + } |
|
2331 | 2450 | |
2332 | 2451 | $params = array(); |
2333 | 2452 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2334 | 2453 | { |
2335 | 2454 | $key = strtok(ltrim($matches[$i]), '='); |
2336 | - if (isset($possible['parameters'][$key]['value'])) |
|
2337 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2338 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2339 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2340 | - else |
|
2341 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2455 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2456 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2457 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2458 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2459 | + } else { |
|
2460 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2461 | + } |
|
2342 | 2462 | |
2343 | 2463 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2344 | 2464 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2346,23 +2466,26 @@ discard block |
||
2346 | 2466 | |
2347 | 2467 | foreach ($possible['parameters'] as $p => $info) |
2348 | 2468 | { |
2349 | - if (!isset($params['{' . $p . '}'])) |
|
2350 | - $params['{' . $p . '}'] = ''; |
|
2469 | + if (!isset($params['{' . $p . '}'])) { |
|
2470 | + $params['{' . $p . '}'] = ''; |
|
2471 | + } |
|
2351 | 2472 | } |
2352 | 2473 | |
2353 | 2474 | $tag = $possible; |
2354 | 2475 | |
2355 | 2476 | // Put the parameters into the string. |
2356 | - if (isset($tag['before'])) |
|
2357 | - $tag['before'] = strtr($tag['before'], $params); |
|
2358 | - if (isset($tag['after'])) |
|
2359 | - $tag['after'] = strtr($tag['after'], $params); |
|
2360 | - if (isset($tag['content'])) |
|
2361 | - $tag['content'] = strtr($tag['content'], $params); |
|
2477 | + if (isset($tag['before'])) { |
|
2478 | + $tag['before'] = strtr($tag['before'], $params); |
|
2479 | + } |
|
2480 | + if (isset($tag['after'])) { |
|
2481 | + $tag['after'] = strtr($tag['after'], $params); |
|
2482 | + } |
|
2483 | + if (isset($tag['content'])) { |
|
2484 | + $tag['content'] = strtr($tag['content'], $params); |
|
2485 | + } |
|
2362 | 2486 | |
2363 | 2487 | $pos1 += strlen($given_param_string); |
2364 | - } |
|
2365 | - else |
|
2488 | + } else |
|
2366 | 2489 | { |
2367 | 2490 | $tag = $possible; |
2368 | 2491 | $params = array(); |
@@ -2373,8 +2496,9 @@ discard block |
||
2373 | 2496 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2374 | 2497 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2375 | 2498 | { |
2376 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2377 | - continue; |
|
2499 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2500 | + continue; |
|
2501 | + } |
|
2378 | 2502 | |
2379 | 2503 | $tag = $itemcodes[$message[$pos + 1]]; |
2380 | 2504 | |
@@ -2395,9 +2519,9 @@ discard block |
||
2395 | 2519 | { |
2396 | 2520 | array_pop($open_tags); |
2397 | 2521 | $code = '</li>'; |
2522 | + } else { |
|
2523 | + $code = ''; |
|
2398 | 2524 | } |
2399 | - else |
|
2400 | - $code = ''; |
|
2401 | 2525 | |
2402 | 2526 | // Now we open a new tag. |
2403 | 2527 | $open_tags[] = array( |
@@ -2444,12 +2568,14 @@ discard block |
||
2444 | 2568 | } |
2445 | 2569 | |
2446 | 2570 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2447 | - if ($tag === null) |
|
2448 | - continue; |
|
2571 | + if ($tag === null) { |
|
2572 | + continue; |
|
2573 | + } |
|
2449 | 2574 | |
2450 | 2575 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2451 | - if (isset($inside['disallow_children'])) |
|
2452 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2576 | + if (isset($inside['disallow_children'])) { |
|
2577 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2578 | + } |
|
2453 | 2579 | |
2454 | 2580 | // Is this tag disabled? |
2455 | 2581 | if (isset($disabled[$tag['tag']])) |
@@ -2459,14 +2585,13 @@ discard block |
||
2459 | 2585 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2460 | 2586 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2461 | 2587 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2462 | - } |
|
2463 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2588 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2464 | 2589 | { |
2465 | 2590 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2466 | 2591 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2592 | + } else { |
|
2593 | + $tag['content'] = $tag['disabled_content']; |
|
2467 | 2594 | } |
2468 | - else |
|
2469 | - $tag['content'] = $tag['disabled_content']; |
|
2470 | 2595 | } |
2471 | 2596 | |
2472 | 2597 | // we use this a lot |
@@ -2476,8 +2601,9 @@ discard block |
||
2476 | 2601 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2477 | 2602 | { |
2478 | 2603 | $n = count($open_tags) - 1; |
2479 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2480 | - $n--; |
|
2604 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2605 | + $n--; |
|
2606 | + } |
|
2481 | 2607 | |
2482 | 2608 | // Close all the non block level tags so this tag isn't surrounded by them. |
2483 | 2609 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2489,12 +2615,15 @@ discard block |
||
2489 | 2615 | |
2490 | 2616 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2491 | 2617 | $whitespace_regex = ''; |
2492 | - if (!empty($tag['block_level'])) |
|
2493 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2494 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2495 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2496 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2497 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2618 | + if (!empty($tag['block_level'])) { |
|
2619 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2620 | + } |
|
2621 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2622 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2623 | + } |
|
2624 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2625 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2626 | + } |
|
2498 | 2627 | |
2499 | 2628 | array_pop($open_tags); |
2500 | 2629 | } |
@@ -2515,16 +2644,19 @@ discard block |
||
2515 | 2644 | elseif ($tag['type'] == 'unparsed_content') |
2516 | 2645 | { |
2517 | 2646 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2518 | - if ($pos2 === false) |
|
2519 | - continue; |
|
2647 | + if ($pos2 === false) { |
|
2648 | + continue; |
|
2649 | + } |
|
2520 | 2650 | |
2521 | 2651 | $data = substr($message, $pos1, $pos2 - $pos1); |
2522 | 2652 | |
2523 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2524 | - $data = substr($data, 4); |
|
2653 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2654 | + $data = substr($data, 4); |
|
2655 | + } |
|
2525 | 2656 | |
2526 | - if (isset($tag['validate'])) |
|
2527 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2657 | + if (isset($tag['validate'])) { |
|
2658 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2659 | + } |
|
2528 | 2660 | |
2529 | 2661 | $code = strtr($tag['content'], array('$1' => $data)); |
2530 | 2662 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2540,34 +2672,40 @@ discard block |
||
2540 | 2672 | if (isset($tag['quoted'])) |
2541 | 2673 | { |
2542 | 2674 | $quoted = substr($message, $pos1, 6) == '"'; |
2543 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2544 | - continue; |
|
2675 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2676 | + continue; |
|
2677 | + } |
|
2545 | 2678 | |
2546 | - if ($quoted) |
|
2547 | - $pos1 += 6; |
|
2679 | + if ($quoted) { |
|
2680 | + $pos1 += 6; |
|
2681 | + } |
|
2682 | + } else { |
|
2683 | + $quoted = false; |
|
2548 | 2684 | } |
2549 | - else |
|
2550 | - $quoted = false; |
|
2551 | 2685 | |
2552 | 2686 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2553 | - if ($pos2 === false) |
|
2554 | - continue; |
|
2687 | + if ($pos2 === false) { |
|
2688 | + continue; |
|
2689 | + } |
|
2555 | 2690 | |
2556 | 2691 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2557 | - if ($pos3 === false) |
|
2558 | - continue; |
|
2692 | + if ($pos3 === false) { |
|
2693 | + continue; |
|
2694 | + } |
|
2559 | 2695 | |
2560 | 2696 | $data = array( |
2561 | 2697 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2562 | 2698 | substr($message, $pos1, $pos2 - $pos1) |
2563 | 2699 | ); |
2564 | 2700 | |
2565 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2566 | - $data[0] = substr($data[0], 4); |
|
2701 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
2702 | + $data[0] = substr($data[0], 4); |
|
2703 | + } |
|
2567 | 2704 | |
2568 | 2705 | // Validation for my parking, please! |
2569 | - if (isset($tag['validate'])) |
|
2570 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2706 | + if (isset($tag['validate'])) { |
|
2707 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2708 | + } |
|
2571 | 2709 | |
2572 | 2710 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2573 | 2711 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2584,23 +2722,27 @@ discard block |
||
2584 | 2722 | elseif ($tag['type'] == 'unparsed_commas_content') |
2585 | 2723 | { |
2586 | 2724 | $pos2 = strpos($message, ']', $pos1); |
2587 | - if ($pos2 === false) |
|
2588 | - continue; |
|
2725 | + if ($pos2 === false) { |
|
2726 | + continue; |
|
2727 | + } |
|
2589 | 2728 | |
2590 | 2729 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2591 | - if ($pos3 === false) |
|
2592 | - continue; |
|
2730 | + if ($pos3 === false) { |
|
2731 | + continue; |
|
2732 | + } |
|
2593 | 2733 | |
2594 | 2734 | // We want $1 to be the content, and the rest to be csv. |
2595 | 2735 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2596 | 2736 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2597 | 2737 | |
2598 | - if (isset($tag['validate'])) |
|
2599 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2738 | + if (isset($tag['validate'])) { |
|
2739 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2740 | + } |
|
2600 | 2741 | |
2601 | 2742 | $code = $tag['content']; |
2602 | - foreach ($data as $k => $d) |
|
2603 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2743 | + foreach ($data as $k => $d) { |
|
2744 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2745 | + } |
|
2604 | 2746 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2605 | 2747 | $pos += strlen($code) - 1 + 2; |
2606 | 2748 | } |
@@ -2608,24 +2750,28 @@ discard block |
||
2608 | 2750 | elseif ($tag['type'] == 'unparsed_commas') |
2609 | 2751 | { |
2610 | 2752 | $pos2 = strpos($message, ']', $pos1); |
2611 | - if ($pos2 === false) |
|
2612 | - continue; |
|
2753 | + if ($pos2 === false) { |
|
2754 | + continue; |
|
2755 | + } |
|
2613 | 2756 | |
2614 | 2757 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2615 | 2758 | |
2616 | - if (isset($tag['validate'])) |
|
2617 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2759 | + if (isset($tag['validate'])) { |
|
2760 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2761 | + } |
|
2618 | 2762 | |
2619 | 2763 | // Fix after, for disabled code mainly. |
2620 | - foreach ($data as $k => $d) |
|
2621 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2764 | + foreach ($data as $k => $d) { |
|
2765 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2766 | + } |
|
2622 | 2767 | |
2623 | 2768 | $open_tags[] = $tag; |
2624 | 2769 | |
2625 | 2770 | // Replace them out, $1, $2, $3, $4, etc. |
2626 | 2771 | $code = $tag['before']; |
2627 | - foreach ($data as $k => $d) |
|
2628 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2772 | + foreach ($data as $k => $d) { |
|
2773 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2774 | + } |
|
2629 | 2775 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2630 | 2776 | $pos += strlen($code) - 1 + 2; |
2631 | 2777 | } |
@@ -2636,28 +2782,33 @@ discard block |
||
2636 | 2782 | if (isset($tag['quoted'])) |
2637 | 2783 | { |
2638 | 2784 | $quoted = substr($message, $pos1, 6) == '"'; |
2639 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2640 | - continue; |
|
2785 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2786 | + continue; |
|
2787 | + } |
|
2641 | 2788 | |
2642 | - if ($quoted) |
|
2643 | - $pos1 += 6; |
|
2789 | + if ($quoted) { |
|
2790 | + $pos1 += 6; |
|
2791 | + } |
|
2792 | + } else { |
|
2793 | + $quoted = false; |
|
2644 | 2794 | } |
2645 | - else |
|
2646 | - $quoted = false; |
|
2647 | 2795 | |
2648 | 2796 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2649 | - if ($pos2 === false) |
|
2650 | - continue; |
|
2797 | + if ($pos2 === false) { |
|
2798 | + continue; |
|
2799 | + } |
|
2651 | 2800 | |
2652 | 2801 | $data = substr($message, $pos1, $pos2 - $pos1); |
2653 | 2802 | |
2654 | 2803 | // Validation for my parking, please! |
2655 | - if (isset($tag['validate'])) |
|
2656 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2804 | + if (isset($tag['validate'])) { |
|
2805 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2806 | + } |
|
2657 | 2807 | |
2658 | 2808 | // For parsed content, we must recurse to avoid security problems. |
2659 | - if ($tag['type'] != 'unparsed_equals') |
|
2660 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2809 | + if ($tag['type'] != 'unparsed_equals') { |
|
2810 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2811 | + } |
|
2661 | 2812 | |
2662 | 2813 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2663 | 2814 | |
@@ -2669,34 +2820,40 @@ discard block |
||
2669 | 2820 | } |
2670 | 2821 | |
2671 | 2822 | // If this is block level, eat any breaks after it. |
2672 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2673 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2823 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
2824 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2825 | + } |
|
2674 | 2826 | |
2675 | 2827 | // Are we trimming outside this tag? |
2676 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2677 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2828 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
2829 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2830 | + } |
|
2678 | 2831 | } |
2679 | 2832 | |
2680 | 2833 | // Close any remaining tags. |
2681 | - while ($tag = array_pop($open_tags)) |
|
2682 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2834 | + while ($tag = array_pop($open_tags)) { |
|
2835 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2836 | + } |
|
2683 | 2837 | |
2684 | 2838 | // Parse the smileys within the parts where it can be done safely. |
2685 | 2839 | if ($smileys === true) |
2686 | 2840 | { |
2687 | 2841 | $message_parts = explode("\n", $message); |
2688 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2689 | - parsesmileys($message_parts[$i]); |
|
2842 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2843 | + parsesmileys($message_parts[$i]); |
|
2844 | + } |
|
2690 | 2845 | |
2691 | 2846 | $message = implode('', $message_parts); |
2692 | 2847 | } |
2693 | 2848 | |
2694 | 2849 | // No smileys, just get rid of the markers. |
2695 | - else |
|
2696 | - $message = strtr($message, array("\n" => '')); |
|
2850 | + else { |
|
2851 | + $message = strtr($message, array("\n" => '')); |
|
2852 | + } |
|
2697 | 2853 | |
2698 | - if ($message !== '' && $message[0] === ' ') |
|
2699 | - $message = ' ' . substr($message, 1); |
|
2854 | + if ($message !== '' && $message[0] === ' ') { |
|
2855 | + $message = ' ' . substr($message, 1); |
|
2856 | + } |
|
2700 | 2857 | |
2701 | 2858 | // Cleanup whitespace. |
2702 | 2859 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2705,15 +2862,16 @@ discard block |
||
2705 | 2862 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2706 | 2863 | |
2707 | 2864 | // Cache the output if it took some time... |
2708 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2709 | - cache_put_data($cache_key, $message, 240); |
|
2865 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
2866 | + cache_put_data($cache_key, $message, 240); |
|
2867 | + } |
|
2710 | 2868 | |
2711 | 2869 | // If this was a force parse revert if needed. |
2712 | 2870 | if (!empty($parse_tags)) |
2713 | 2871 | { |
2714 | - if (empty($temp_bbc)) |
|
2715 | - $bbc_codes = array(); |
|
2716 | - else |
|
2872 | + if (empty($temp_bbc)) { |
|
2873 | + $bbc_codes = array(); |
|
2874 | + } else |
|
2717 | 2875 | { |
2718 | 2876 | $bbc_codes = $temp_bbc; |
2719 | 2877 | unset($temp_bbc); |
@@ -2740,8 +2898,9 @@ discard block |
||
2740 | 2898 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2741 | 2899 | |
2742 | 2900 | // No smiley set at all?! |
2743 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2744 | - return; |
|
2901 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2902 | + return; |
|
2903 | + } |
|
2745 | 2904 | |
2746 | 2905 | // If smileyPregSearch hasn't been set, do it now. |
2747 | 2906 | if (empty($smileyPregSearch)) |
@@ -2752,8 +2911,7 @@ discard block |
||
2752 | 2911 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2753 | 2912 | $smileysto = array('evil.png', 'cheesy.png', 'rolleyes.png', 'angry.png', 'laugh.png', 'smiley.png', 'wink.png', 'grin.png', 'sad.png', 'shocked.png', 'cool.png', 'tongue.png', 'huh.png', 'embarrassed.png', 'lipsrsealed.png', 'kiss.png', 'cry.png', 'undecided.png', 'azn.png', 'afro.png', 'police.png', 'angel.png'); |
2754 | 2913 | $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'], '', '', '', ''); |
2755 | - } |
|
2756 | - else |
|
2914 | + } else |
|
2757 | 2915 | { |
2758 | 2916 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2759 | 2917 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2777,9 +2935,9 @@ discard block |
||
2777 | 2935 | $smcFunc['db_free_result']($result); |
2778 | 2936 | |
2779 | 2937 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2938 | + } else { |
|
2939 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2780 | 2940 | } |
2781 | - else |
|
2782 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2783 | 2941 | } |
2784 | 2942 | |
2785 | 2943 | // The non-breaking-space is a complex thing... |
@@ -2857,12 +3015,14 @@ discard block |
||
2857 | 3015 | global $boardurl, $image_proxy_enabled, $image_proxy_secret; |
2858 | 3016 | |
2859 | 3017 | // Only use the proxy if enabled and necessary |
2860 | - if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') |
|
2861 | - return $url; |
|
3018 | + if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') { |
|
3019 | + return $url; |
|
3020 | + } |
|
2862 | 3021 | |
2863 | 3022 | // We don't need to proxy our own resources |
2864 | - if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) |
|
2865 | - return strtr($url, array('http://' => 'https://')); |
|
3023 | + if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) { |
|
3024 | + return strtr($url, array('http://' => 'https://')); |
|
3025 | + } |
|
2866 | 3026 | |
2867 | 3027 | // By default, use SMF's own image proxy script |
2868 | 3028 | $proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret); |
@@ -2887,35 +3047,41 @@ discard block |
||
2887 | 3047 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2888 | 3048 | |
2889 | 3049 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2890 | - if (!empty($context['flush_mail'])) |
|
2891 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3050 | + if (!empty($context['flush_mail'])) { |
|
3051 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2892 | 3052 | AddMailQueue(true); |
3053 | + } |
|
2893 | 3054 | |
2894 | 3055 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2895 | 3056 | |
2896 | - if ($add) |
|
2897 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3057 | + if ($add) { |
|
3058 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3059 | + } |
|
2898 | 3060 | |
2899 | 3061 | // Put the session ID in. |
2900 | - if (defined('SID') && SID != '') |
|
2901 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3062 | + if (defined('SID') && SID != '') { |
|
3063 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3064 | + } |
|
2902 | 3065 | // Keep that debug in their for template debugging! |
2903 | - elseif (isset($_GET['debug'])) |
|
2904 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3066 | + elseif (isset($_GET['debug'])) { |
|
3067 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3068 | + } |
|
2905 | 3069 | |
2906 | 3070 | 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']))) |
2907 | 3071 | { |
2908 | - if (defined('SID') && SID != '') |
|
2909 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
3072 | + if (defined('SID') && SID != '') { |
|
3073 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2910 | 3074 | function ($m) use ($scripturl) |
2911 | 3075 | { |
2912 | 3076 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
3077 | + } |
|
2913 | 3078 | }, $setLocation); |
2914 | - else |
|
2915 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
3079 | + else { |
|
3080 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2916 | 3081 | function ($m) use ($scripturl) |
2917 | 3082 | { |
2918 | 3083 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
3084 | + } |
|
2919 | 3085 | }, $setLocation); |
2920 | 3086 | } |
2921 | 3087 | |
@@ -2926,8 +3092,9 @@ discard block |
||
2926 | 3092 | header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2927 | 3093 | |
2928 | 3094 | // Debugging. |
2929 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2930 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3095 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3096 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3097 | + } |
|
2931 | 3098 | |
2932 | 3099 | obExit(false); |
2933 | 3100 | } |
@@ -2946,51 +3113,60 @@ discard block |
||
2946 | 3113 | |
2947 | 3114 | // Attempt to prevent a recursive loop. |
2948 | 3115 | ++$level; |
2949 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2950 | - exit; |
|
2951 | - if ($from_fatal_error) |
|
2952 | - $has_fatal_error = true; |
|
3116 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3117 | + exit; |
|
3118 | + } |
|
3119 | + if ($from_fatal_error) { |
|
3120 | + $has_fatal_error = true; |
|
3121 | + } |
|
2953 | 3122 | |
2954 | 3123 | // Clear out the stat cache. |
2955 | 3124 | trackStats(); |
2956 | 3125 | |
2957 | 3126 | // If we have mail to send, send it. |
2958 | - if (!empty($context['flush_mail'])) |
|
2959 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3127 | + if (!empty($context['flush_mail'])) { |
|
3128 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2960 | 3129 | AddMailQueue(true); |
3130 | + } |
|
2961 | 3131 | |
2962 | 3132 | $do_header = $header === null ? !$header_done : $header; |
2963 | - if ($do_footer === null) |
|
2964 | - $do_footer = $do_header; |
|
3133 | + if ($do_footer === null) { |
|
3134 | + $do_footer = $do_header; |
|
3135 | + } |
|
2965 | 3136 | |
2966 | 3137 | // Has the template/header been done yet? |
2967 | 3138 | if ($do_header) |
2968 | 3139 | { |
2969 | 3140 | // Was the page title set last minute? Also update the HTML safe one. |
2970 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2971 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3141 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3142 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3143 | + } |
|
2972 | 3144 | |
2973 | 3145 | // Start up the session URL fixer. |
2974 | 3146 | ob_start('ob_sessrewrite'); |
2975 | 3147 | |
2976 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2977 | - $buffers = explode(',', $settings['output_buffers']); |
|
2978 | - elseif (!empty($settings['output_buffers'])) |
|
2979 | - $buffers = $settings['output_buffers']; |
|
2980 | - else |
|
2981 | - $buffers = array(); |
|
3148 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3149 | + $buffers = explode(',', $settings['output_buffers']); |
|
3150 | + } elseif (!empty($settings['output_buffers'])) { |
|
3151 | + $buffers = $settings['output_buffers']; |
|
3152 | + } else { |
|
3153 | + $buffers = array(); |
|
3154 | + } |
|
2982 | 3155 | |
2983 | - if (isset($modSettings['integrate_buffer'])) |
|
2984 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3156 | + if (isset($modSettings['integrate_buffer'])) { |
|
3157 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3158 | + } |
|
2985 | 3159 | |
2986 | - if (!empty($buffers)) |
|
2987 | - foreach ($buffers as $function) |
|
3160 | + if (!empty($buffers)) { |
|
3161 | + foreach ($buffers as $function) |
|
2988 | 3162 | { |
2989 | 3163 | $call = call_helper($function, true); |
3164 | + } |
|
2990 | 3165 | |
2991 | 3166 | // Is it valid? |
2992 | - if (!empty($call)) |
|
2993 | - ob_start($call); |
|
3167 | + if (!empty($call)) { |
|
3168 | + ob_start($call); |
|
3169 | + } |
|
2994 | 3170 | } |
2995 | 3171 | |
2996 | 3172 | // Display the screen in the logical order. |
@@ -3002,8 +3178,9 @@ discard block |
||
3002 | 3178 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
3003 | 3179 | |
3004 | 3180 | // Anything special to put out? |
3005 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
3006 | - echo $context['insert_after_template']; |
|
3181 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3182 | + echo $context['insert_after_template']; |
|
3183 | + } |
|
3007 | 3184 | |
3008 | 3185 | // Just so we don't get caught in an endless loop of errors from the footer... |
3009 | 3186 | if (!$footer_done) |
@@ -3012,14 +3189,16 @@ discard block |
||
3012 | 3189 | template_footer(); |
3013 | 3190 | |
3014 | 3191 | // (since this is just debugging... it's okay that it's after </html>.) |
3015 | - if (!isset($_REQUEST['xml'])) |
|
3016 | - displayDebug(); |
|
3192 | + if (!isset($_REQUEST['xml'])) { |
|
3193 | + displayDebug(); |
|
3194 | + } |
|
3017 | 3195 | } |
3018 | 3196 | } |
3019 | 3197 | |
3020 | 3198 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
3021 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
3022 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3199 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3200 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3201 | + } |
|
3023 | 3202 | |
3024 | 3203 | // For session check verification.... don't switch browsers... |
3025 | 3204 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3028,9 +3207,10 @@ discard block |
||
3028 | 3207 | call_integration_hook('integrate_exit', array($do_footer)); |
3029 | 3208 | |
3030 | 3209 | // Don't exit if we're coming from index.php; that will pass through normally. |
3031 | - if (!$from_index) |
|
3032 | - exit; |
|
3033 | -} |
|
3210 | + if (!$from_index) { |
|
3211 | + exit; |
|
3212 | + } |
|
3213 | + } |
|
3034 | 3214 | |
3035 | 3215 | /** |
3036 | 3216 | * Get the size of a specified image with better error handling. |
@@ -3049,8 +3229,9 @@ discard block |
||
3049 | 3229 | $url = str_replace(' ', '%20', $url); |
3050 | 3230 | |
3051 | 3231 | // Can we pull this from the cache... please please? |
3052 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
3053 | - return $temp; |
|
3232 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3233 | + return $temp; |
|
3234 | + } |
|
3054 | 3235 | $t = microtime(); |
3055 | 3236 | |
3056 | 3237 | // Get the host to pester... |
@@ -3060,12 +3241,10 @@ discard block |
||
3060 | 3241 | if ($url == '' || $url == 'http://' || $url == 'https://') |
3061 | 3242 | { |
3062 | 3243 | return false; |
3063 | - } |
|
3064 | - elseif (!isset($match[1])) |
|
3244 | + } elseif (!isset($match[1])) |
|
3065 | 3245 | { |
3066 | 3246 | $size = @getimagesize($url); |
3067 | - } |
|
3068 | - else |
|
3247 | + } else |
|
3069 | 3248 | { |
3070 | 3249 | // Try to connect to the server... give it half a second. |
3071 | 3250 | $temp = 0; |
@@ -3102,12 +3281,14 @@ discard block |
||
3102 | 3281 | } |
3103 | 3282 | |
3104 | 3283 | // If we didn't get it, we failed. |
3105 | - if (!isset($size)) |
|
3106 | - $size = false; |
|
3284 | + if (!isset($size)) { |
|
3285 | + $size = false; |
|
3286 | + } |
|
3107 | 3287 | |
3108 | 3288 | // If this took a long time, we may never have to do it again, but then again we might... |
3109 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3110 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3289 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3290 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3291 | + } |
|
3111 | 3292 | |
3112 | 3293 | // Didn't work. |
3113 | 3294 | return $size; |
@@ -3125,8 +3306,9 @@ discard block |
||
3125 | 3306 | |
3126 | 3307 | // Under SSI this function can be called more then once. That can cause some problems. |
3127 | 3308 | // So only run the function once unless we are forced to run it again. |
3128 | - if ($loaded && !$forceload) |
|
3129 | - return; |
|
3309 | + if ($loaded && !$forceload) { |
|
3310 | + return; |
|
3311 | + } |
|
3130 | 3312 | |
3131 | 3313 | $loaded = true; |
3132 | 3314 | |
@@ -3138,14 +3320,16 @@ discard block |
||
3138 | 3320 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3139 | 3321 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3140 | 3322 | { |
3141 | - if (trim($context['news_lines'][$i]) == '') |
|
3142 | - continue; |
|
3323 | + if (trim($context['news_lines'][$i]) == '') { |
|
3324 | + continue; |
|
3325 | + } |
|
3143 | 3326 | |
3144 | 3327 | // Clean it up for presentation ;). |
3145 | 3328 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3146 | 3329 | } |
3147 | - if (!empty($context['news_lines'])) |
|
3148 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3330 | + if (!empty($context['news_lines'])) { |
|
3331 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3332 | + } |
|
3149 | 3333 | |
3150 | 3334 | if (!$user_info['is_guest']) |
3151 | 3335 | { |
@@ -3154,40 +3338,48 @@ discard block |
||
3154 | 3338 | $context['user']['alerts'] = &$user_info['alerts']; |
3155 | 3339 | |
3156 | 3340 | // Personal message popup... |
3157 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3158 | - $context['user']['popup_messages'] = true; |
|
3159 | - else |
|
3160 | - $context['user']['popup_messages'] = false; |
|
3341 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3342 | + $context['user']['popup_messages'] = true; |
|
3343 | + } else { |
|
3344 | + $context['user']['popup_messages'] = false; |
|
3345 | + } |
|
3161 | 3346 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3162 | 3347 | |
3163 | - if (allowedTo('moderate_forum')) |
|
3164 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3348 | + if (allowedTo('moderate_forum')) { |
|
3349 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3350 | + } |
|
3165 | 3351 | |
3166 | 3352 | $context['user']['avatar'] = array(); |
3167 | 3353 | |
3168 | 3354 | // Check for gravatar first since we might be forcing them... |
3169 | 3355 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3170 | 3356 | { |
3171 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3172 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3173 | - else |
|
3174 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3357 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3358 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3359 | + } else { |
|
3360 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3361 | + } |
|
3175 | 3362 | } |
3176 | 3363 | // Uploaded? |
3177 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3178 | - $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'; |
|
3364 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3365 | + $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'; |
|
3366 | + } |
|
3179 | 3367 | // Full URL? |
3180 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3181 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3368 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3369 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3370 | + } |
|
3182 | 3371 | // Otherwise we assume it's server stored. |
3183 | - elseif ($user_info['avatar']['url'] != '') |
|
3184 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3372 | + elseif ($user_info['avatar']['url'] != '') { |
|
3373 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3374 | + } |
|
3185 | 3375 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3186 | - else |
|
3187 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3376 | + else { |
|
3377 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3378 | + } |
|
3188 | 3379 | |
3189 | - if (!empty($context['user']['avatar'])) |
|
3190 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3380 | + if (!empty($context['user']['avatar'])) { |
|
3381 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3382 | + } |
|
3191 | 3383 | |
3192 | 3384 | // Figure out how long they've been logged in. |
3193 | 3385 | $context['user']['total_time_logged_in'] = array( |
@@ -3195,8 +3387,7 @@ discard block |
||
3195 | 3387 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3196 | 3388 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3197 | 3389 | ); |
3198 | - } |
|
3199 | - else |
|
3390 | + } else |
|
3200 | 3391 | { |
3201 | 3392 | $context['user']['messages'] = 0; |
3202 | 3393 | $context['user']['unread_messages'] = 0; |
@@ -3204,12 +3395,14 @@ discard block |
||
3204 | 3395 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3205 | 3396 | $context['user']['popup_messages'] = false; |
3206 | 3397 | |
3207 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3208 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3398 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3399 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3400 | + } |
|
3209 | 3401 | |
3210 | 3402 | // If we've upgraded recently, go easy on the passwords. |
3211 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3212 | - $context['disable_login_hashing'] = true; |
|
3403 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3404 | + $context['disable_login_hashing'] = true; |
|
3405 | + } |
|
3213 | 3406 | } |
3214 | 3407 | |
3215 | 3408 | // Setup the main menu items. |
@@ -3222,8 +3415,8 @@ discard block |
||
3222 | 3415 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3223 | 3416 | |
3224 | 3417 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3225 | - if ($context['show_pm_popup']) |
|
3226 | - addInlineJavaScript(' |
|
3418 | + if ($context['show_pm_popup']) { |
|
3419 | + addInlineJavaScript(' |
|
3227 | 3420 | jQuery(document).ready(function($) { |
3228 | 3421 | new smc_Popup({ |
3229 | 3422 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3231,24 +3424,28 @@ discard block |
||
3231 | 3424 | icon_class: \'generic_icons mail_new\' |
3232 | 3425 | }); |
3233 | 3426 | });'); |
3427 | + } |
|
3234 | 3428 | |
3235 | 3429 | // Add a generic "Are you sure?" confirmation message. |
3236 | 3430 | addInlineJavaScript(' |
3237 | 3431 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3238 | 3432 | |
3239 | 3433 | // Now add the capping code for avatars. |
3240 | - 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') |
|
3241 | - addInlineCss(' |
|
3434 | + 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') { |
|
3435 | + addInlineCss(' |
|
3242 | 3436 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3437 | + } |
|
3243 | 3438 | |
3244 | 3439 | // Add max image limits |
3245 | - if (!empty($modSettings['max_image_width'])) |
|
3246 | - addInlineCss(' |
|
3440 | + if (!empty($modSettings['max_image_width'])) { |
|
3441 | + addInlineCss(' |
|
3247 | 3442 | .postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }'); |
3443 | + } |
|
3248 | 3444 | |
3249 | - if (!empty($modSettings['max_image_height'])) |
|
3250 | - addInlineCss(' |
|
3445 | + if (!empty($modSettings['max_image_height'])) { |
|
3446 | + addInlineCss(' |
|
3251 | 3447 | .postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }'); |
3448 | + } |
|
3252 | 3449 | |
3253 | 3450 | // This looks weird, but it's because BoardIndex.php references the variable. |
3254 | 3451 | $context['common_stats']['latest_member'] = array( |
@@ -3265,11 +3462,13 @@ discard block |
||
3265 | 3462 | ); |
3266 | 3463 | $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']); |
3267 | 3464 | |
3268 | - if (empty($settings['theme_version'])) |
|
3269 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3465 | + if (empty($settings['theme_version'])) { |
|
3466 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3467 | + } |
|
3270 | 3468 | |
3271 | - if (!isset($context['page_title'])) |
|
3272 | - $context['page_title'] = ''; |
|
3469 | + if (!isset($context['page_title'])) { |
|
3470 | + $context['page_title'] = ''; |
|
3471 | + } |
|
3273 | 3472 | |
3274 | 3473 | // Set some specific vars. |
3275 | 3474 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3279,21 +3478,23 @@ discard block |
||
3279 | 3478 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3280 | 3479 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3281 | 3480 | |
3282 | - if (!empty($context['meta_keywords'])) |
|
3283 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3481 | + if (!empty($context['meta_keywords'])) { |
|
3482 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3483 | + } |
|
3284 | 3484 | |
3285 | - if (!empty($context['canonical_url'])) |
|
3286 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3485 | + if (!empty($context['canonical_url'])) { |
|
3486 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3487 | + } |
|
3287 | 3488 | |
3288 | - if (!empty($settings['og_image'])) |
|
3289 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3489 | + if (!empty($settings['og_image'])) { |
|
3490 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3491 | + } |
|
3290 | 3492 | |
3291 | 3493 | if (!empty($context['meta_description'])) |
3292 | 3494 | { |
3293 | 3495 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3294 | 3496 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3295 | - } |
|
3296 | - else |
|
3497 | + } else |
|
3297 | 3498 | { |
3298 | 3499 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3299 | 3500 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3318,8 +3519,9 @@ discard block |
||
3318 | 3519 | $memory_needed = memoryReturnBytes($needed); |
3319 | 3520 | |
3320 | 3521 | // should we account for how much is currently being used? |
3321 | - if ($in_use) |
|
3322 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3522 | + if ($in_use) { |
|
3523 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3524 | + } |
|
3323 | 3525 | |
3324 | 3526 | // if more is needed, request it |
3325 | 3527 | if ($memory_current < $memory_needed) |
@@ -3342,8 +3544,9 @@ discard block |
||
3342 | 3544 | */ |
3343 | 3545 | function memoryReturnBytes($val) |
3344 | 3546 | { |
3345 | - if (is_integer($val)) |
|
3346 | - return $val; |
|
3547 | + if (is_integer($val)) { |
|
3548 | + return $val; |
|
3549 | + } |
|
3347 | 3550 | |
3348 | 3551 | // Separate the number from the designator |
3349 | 3552 | $val = trim($val); |
@@ -3379,10 +3582,11 @@ discard block |
||
3379 | 3582 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3380 | 3583 | |
3381 | 3584 | // Are we debugging the template/html content? |
3382 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3383 | - header('content-type: application/xhtml+xml'); |
|
3384 | - elseif (!isset($_REQUEST['xml'])) |
|
3385 | - header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3585 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3586 | + header('content-type: application/xhtml+xml'); |
|
3587 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3588 | + header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3589 | + } |
|
3386 | 3590 | } |
3387 | 3591 | |
3388 | 3592 | header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3391,8 +3595,9 @@ discard block |
||
3391 | 3595 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3392 | 3596 | { |
3393 | 3597 | $position = array_search('body', $context['template_layers']); |
3394 | - if ($position === false) |
|
3395 | - $position = array_search('main', $context['template_layers']); |
|
3598 | + if ($position === false) { |
|
3599 | + $position = array_search('main', $context['template_layers']); |
|
3600 | + } |
|
3396 | 3601 | |
3397 | 3602 | if ($position !== false) |
3398 | 3603 | { |
@@ -3420,23 +3625,25 @@ discard block |
||
3420 | 3625 | |
3421 | 3626 | foreach ($securityFiles as $i => $securityFile) |
3422 | 3627 | { |
3423 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3424 | - unset($securityFiles[$i]); |
|
3628 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3629 | + unset($securityFiles[$i]); |
|
3630 | + } |
|
3425 | 3631 | } |
3426 | 3632 | |
3427 | 3633 | // We are already checking so many files...just few more doesn't make any difference! :P |
3428 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3429 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3430 | - |
|
3431 | - else |
|
3432 | - $path = $modSettings['attachmentUploadDir']; |
|
3634 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3635 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3636 | + } else { |
|
3637 | + $path = $modSettings['attachmentUploadDir']; |
|
3638 | + } |
|
3433 | 3639 | |
3434 | 3640 | secureDirectory($path, true); |
3435 | 3641 | secureDirectory($cachedir); |
3436 | 3642 | |
3437 | 3643 | // If agreement is enabled, at least the english version shall exists |
3438 | - if ($modSettings['requireAgreement']) |
|
3439 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3644 | + if ($modSettings['requireAgreement']) { |
|
3645 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3646 | + } |
|
3440 | 3647 | |
3441 | 3648 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3442 | 3649 | { |
@@ -3451,18 +3658,21 @@ discard block |
||
3451 | 3658 | echo ' |
3452 | 3659 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3453 | 3660 | |
3454 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3455 | - echo ' |
|
3661 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3662 | + echo ' |
|
3456 | 3663 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3664 | + } |
|
3457 | 3665 | } |
3458 | 3666 | |
3459 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3460 | - echo ' |
|
3667 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3668 | + echo ' |
|
3461 | 3669 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3670 | + } |
|
3462 | 3671 | |
3463 | - if (!empty($agreement)) |
|
3464 | - echo ' |
|
3672 | + if (!empty($agreement)) { |
|
3673 | + echo ' |
|
3465 | 3674 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3675 | + } |
|
3466 | 3676 | |
3467 | 3677 | echo ' |
3468 | 3678 | </p> |
@@ -3477,16 +3687,18 @@ discard block |
||
3477 | 3687 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3478 | 3688 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3479 | 3689 | |
3480 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3481 | - echo ' |
|
3690 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3691 | + echo ' |
|
3482 | 3692 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3693 | + } |
|
3483 | 3694 | |
3484 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3485 | - echo ' |
|
3695 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3696 | + echo ' |
|
3486 | 3697 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3487 | - else |
|
3488 | - echo ' |
|
3698 | + } else { |
|
3699 | + echo ' |
|
3489 | 3700 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3701 | + } |
|
3490 | 3702 | |
3491 | 3703 | echo ' |
3492 | 3704 | </div>'; |
@@ -3502,8 +3714,9 @@ discard block |
||
3502 | 3714 | global $forum_copyright, $software_year, $forum_version; |
3503 | 3715 | |
3504 | 3716 | // Don't display copyright for things like SSI. |
3505 | - if (!isset($forum_version) || !isset($software_year)) |
|
3506 | - return; |
|
3717 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3718 | + return; |
|
3719 | + } |
|
3507 | 3720 | |
3508 | 3721 | // Put in the version... |
3509 | 3722 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3521,9 +3734,10 @@ discard block |
||
3521 | 3734 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
3522 | 3735 | $context['load_queries'] = $db_count; |
3523 | 3736 | |
3524 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3525 | - loadSubTemplate($layer . '_below', true); |
|
3526 | -} |
|
3737 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3738 | + loadSubTemplate($layer . '_below', true); |
|
3739 | + } |
|
3740 | + } |
|
3527 | 3741 | |
3528 | 3742 | /** |
3529 | 3743 | * Output the Javascript files |
@@ -3554,8 +3768,7 @@ discard block |
||
3554 | 3768 | { |
3555 | 3769 | echo ' |
3556 | 3770 | var ', $key, ';'; |
3557 | - } |
|
3558 | - else |
|
3771 | + } else |
|
3559 | 3772 | { |
3560 | 3773 | echo ' |
3561 | 3774 | var ', $key, ' = ', $value, ';'; |
@@ -3570,26 +3783,27 @@ discard block |
||
3570 | 3783 | foreach ($context['javascript_files'] as $id => $js_file) |
3571 | 3784 | { |
3572 | 3785 | // Last minute call! allow theme authors to disable single files. |
3573 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3574 | - continue; |
|
3786 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3787 | + continue; |
|
3788 | + } |
|
3575 | 3789 | |
3576 | 3790 | // By default all files don't get minimized unless the file explicitly says so! |
3577 | 3791 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3578 | 3792 | { |
3579 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
3580 | - $toMinifyDefer[] = $js_file; |
|
3581 | - |
|
3582 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
3583 | - $toMinify[] = $js_file; |
|
3793 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
3794 | + $toMinifyDefer[] = $js_file; |
|
3795 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
3796 | + $toMinify[] = $js_file; |
|
3797 | + } |
|
3584 | 3798 | |
3585 | 3799 | // Grab a random seed. |
3586 | - if (!isset($minSeed) && isset($js_file['options']['seed'])) |
|
3587 | - $minSeed = $js_file['options']['seed']; |
|
3588 | - } |
|
3589 | - |
|
3590 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
3591 | - echo ' |
|
3800 | + if (!isset($minSeed) && isset($js_file['options']['seed'])) { |
|
3801 | + $minSeed = $js_file['options']['seed']; |
|
3802 | + } |
|
3803 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
3804 | + echo ' |
|
3592 | 3805 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
3806 | + } |
|
3593 | 3807 | } |
3594 | 3808 | |
3595 | 3809 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3598,9 +3812,10 @@ discard block |
||
3598 | 3812 | |
3599 | 3813 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3600 | 3814 | |
3601 | - foreach ($result as $minFile) |
|
3602 | - echo ' |
|
3815 | + foreach ($result as $minFile) { |
|
3816 | + echo ' |
|
3603 | 3817 | <script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async="async"' : '', '></script>'; |
3818 | + } |
|
3604 | 3819 | |
3605 | 3820 | } |
3606 | 3821 | |
@@ -3612,8 +3827,9 @@ discard block |
||
3612 | 3827 | echo ' |
3613 | 3828 | <script>'; |
3614 | 3829 | |
3615 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3616 | - echo $js_code; |
|
3830 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3831 | + echo $js_code; |
|
3832 | + } |
|
3617 | 3833 | |
3618 | 3834 | echo ' |
3619 | 3835 | </script>'; |
@@ -3624,8 +3840,9 @@ discard block |
||
3624 | 3840 | echo ' |
3625 | 3841 | <script>'; |
3626 | 3842 | |
3627 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3628 | - echo $js_code; |
|
3843 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3844 | + echo $js_code; |
|
3845 | + } |
|
3629 | 3846 | |
3630 | 3847 | echo ' |
3631 | 3848 | </script>'; |
@@ -3653,23 +3870,26 @@ discard block |
||
3653 | 3870 | foreach ($context['css_files'] as $id => $file) |
3654 | 3871 | { |
3655 | 3872 | // Last minute call! allow theme authors to disable single files. |
3656 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3657 | - continue; |
|
3873 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3874 | + continue; |
|
3875 | + } |
|
3658 | 3876 | |
3659 | 3877 | // Files are minimized unless they explicitly opt out. |
3660 | - if (!isset($file['options']['minimize'])) |
|
3661 | - $file['options']['minimize'] = true; |
|
3878 | + if (!isset($file['options']['minimize'])) { |
|
3879 | + $file['options']['minimize'] = true; |
|
3880 | + } |
|
3662 | 3881 | |
3663 | 3882 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3664 | 3883 | { |
3665 | 3884 | $toMinify[] = $file; |
3666 | 3885 | |
3667 | 3886 | // Grab a random seed. |
3668 | - if (!isset($minSeed) && isset($file['options']['seed'])) |
|
3669 | - $minSeed = $file['options']['seed']; |
|
3887 | + if (!isset($minSeed) && isset($file['options']['seed'])) { |
|
3888 | + $minSeed = $file['options']['seed']; |
|
3889 | + } |
|
3890 | + } else { |
|
3891 | + $normal[] = $file['fileUrl']; |
|
3670 | 3892 | } |
3671 | - else |
|
3672 | - $normal[] = $file['fileUrl']; |
|
3673 | 3893 | } |
3674 | 3894 | |
3675 | 3895 | if (!empty($toMinify)) |
@@ -3678,23 +3898,26 @@ discard block |
||
3678 | 3898 | |
3679 | 3899 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3680 | 3900 | |
3681 | - foreach ($result as $minFile) |
|
3682 | - echo ' |
|
3901 | + foreach ($result as $minFile) { |
|
3902 | + echo ' |
|
3683 | 3903 | <link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">'; |
3904 | + } |
|
3684 | 3905 | } |
3685 | 3906 | |
3686 | 3907 | // Print the rest after the minified files. |
3687 | - if (!empty($normal)) |
|
3688 | - foreach ($normal as $nf) |
|
3908 | + if (!empty($normal)) { |
|
3909 | + foreach ($normal as $nf) |
|
3689 | 3910 | echo ' |
3690 | 3911 | <link rel="stylesheet" href="', $nf ,'">'; |
3912 | + } |
|
3691 | 3913 | |
3692 | 3914 | if ($db_show_debug === true) |
3693 | 3915 | { |
3694 | 3916 | // Try to keep only what's useful. |
3695 | 3917 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3696 | - foreach ($context['css_files'] as $file) |
|
3697 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3918 | + foreach ($context['css_files'] as $file) { |
|
3919 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3920 | + } |
|
3698 | 3921 | } |
3699 | 3922 | |
3700 | 3923 | if (!empty($context['css_header'])) |
@@ -3702,9 +3925,10 @@ discard block |
||
3702 | 3925 | echo ' |
3703 | 3926 | <style>'; |
3704 | 3927 | |
3705 | - foreach ($context['css_header'] as $css) |
|
3706 | - echo $css .' |
|
3928 | + foreach ($context['css_header'] as $css) { |
|
3929 | + echo $css .' |
|
3707 | 3930 | '; |
3931 | + } |
|
3708 | 3932 | |
3709 | 3933 | echo' |
3710 | 3934 | </style>'; |
@@ -3728,8 +3952,9 @@ discard block |
||
3728 | 3952 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3729 | 3953 | $data = !empty($data) ? $data : false; |
3730 | 3954 | |
3731 | - if (empty($type) || empty($data)) |
|
3732 | - return false; |
|
3955 | + if (empty($type) || empty($data)) { |
|
3956 | + return false; |
|
3957 | + } |
|
3733 | 3958 | |
3734 | 3959 | // Different pages include different files, so we use a hash to label the different combinations |
3735 | 3960 | $hash = md5(implode(' ', array_keys($data))); |
@@ -3738,8 +3963,9 @@ discard block |
||
3738 | 3963 | $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400); |
3739 | 3964 | |
3740 | 3965 | // Already done? |
3741 | - if (!empty($toCache)) |
|
3742 | - return true; |
|
3966 | + if (!empty($toCache)) { |
|
3967 | + return true; |
|
3968 | + } |
|
3743 | 3969 | |
3744 | 3970 | // No namespaces, sorry! |
3745 | 3971 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3771,8 +3997,9 @@ discard block |
||
3771 | 3997 | $toAdd = file_exists($tempFile) ? $tempFile : false; |
3772 | 3998 | |
3773 | 3999 | // A minified script should only be loaded asynchronously if all its components wanted to be. |
3774 | - if (empty($file['options']['async'])) |
|
3775 | - $async = false; |
|
4000 | + if (empty($file['options']['async'])) { |
|
4001 | + $async = false; |
|
4002 | + } |
|
3776 | 4003 | |
3777 | 4004 | // The file couldn't be located so it won't be added. Log this error. |
3778 | 4005 | if (empty($toAdd)) |
@@ -3832,8 +4059,9 @@ discard block |
||
3832 | 4059 | global $modSettings, $smcFunc; |
3833 | 4060 | |
3834 | 4061 | // Just make up a nice hash... |
3835 | - if ($new) |
|
3836 | - return sha1(md5($filename . time()) . mt_rand()); |
|
4062 | + if ($new) { |
|
4063 | + return sha1(md5($filename . time()) . mt_rand()); |
|
4064 | + } |
|
3837 | 4065 | |
3838 | 4066 | // Just make sure that attachment id is only a int |
3839 | 4067 | $attachment_id = (int) $attachment_id; |
@@ -3850,23 +4078,25 @@ discard block |
||
3850 | 4078 | 'id_attach' => $attachment_id, |
3851 | 4079 | )); |
3852 | 4080 | |
3853 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3854 | - return false; |
|
4081 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
4082 | + return false; |
|
4083 | + } |
|
3855 | 4084 | |
3856 | 4085 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3857 | 4086 | $smcFunc['db_free_result']($request); |
3858 | 4087 | } |
3859 | 4088 | |
3860 | 4089 | // Still no hash? mmm... |
3861 | - if (empty($file_hash)) |
|
3862 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4090 | + if (empty($file_hash)) { |
|
4091 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4092 | + } |
|
3863 | 4093 | |
3864 | 4094 | // Are we using multiple directories? |
3865 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3866 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3867 | - |
|
3868 | - else |
|
3869 | - $path = $modSettings['attachmentUploadDir']; |
|
4095 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
4096 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
4097 | + } else { |
|
4098 | + $path = $modSettings['attachmentUploadDir']; |
|
4099 | + } |
|
3870 | 4100 | |
3871 | 4101 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3872 | 4102 | } |
@@ -3881,8 +4111,9 @@ discard block |
||
3881 | 4111 | function ip2range($fullip) |
3882 | 4112 | { |
3883 | 4113 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3884 | - if ($fullip == 'unknown') |
|
3885 | - $fullip = '255.255.255.255'; |
|
4114 | + if ($fullip == 'unknown') { |
|
4115 | + $fullip = '255.255.255.255'; |
|
4116 | + } |
|
3886 | 4117 | |
3887 | 4118 | $ip_parts = explode('-', $fullip); |
3888 | 4119 | $ip_array = array(); |
@@ -3906,10 +4137,11 @@ discard block |
||
3906 | 4137 | $ip_array['low'] = $ip_parts[0]; |
3907 | 4138 | $ip_array['high'] = $ip_parts[1]; |
3908 | 4139 | return $ip_array; |
3909 | - } |
|
3910 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4140 | + } elseif (count($ip_parts) == 2) { |
|
4141 | + // if ip 22.22.*-22.22.* |
|
3911 | 4142 | { |
3912 | 4143 | $valid_low = isValidIP($ip_parts[0]); |
4144 | + } |
|
3913 | 4145 | $valid_high = isValidIP($ip_parts[1]); |
3914 | 4146 | $count = 0; |
3915 | 4147 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3924,7 +4156,9 @@ discard block |
||
3924 | 4156 | $ip_parts[0] .= $mode . $min; |
3925 | 4157 | $valid_low = isValidIP($ip_parts[0]); |
3926 | 4158 | $count++; |
3927 | - if ($count > 9) break; |
|
4159 | + if ($count > 9) { |
|
4160 | + break; |
|
4161 | + } |
|
3928 | 4162 | } |
3929 | 4163 | } |
3930 | 4164 | |
@@ -3938,7 +4172,9 @@ discard block |
||
3938 | 4172 | $ip_parts[1] .= $mode . $max; |
3939 | 4173 | $valid_high = isValidIP($ip_parts[1]); |
3940 | 4174 | $count++; |
3941 | - if ($count > 9) break; |
|
4175 | + if ($count > 9) { |
|
4176 | + break; |
|
4177 | + } |
|
3942 | 4178 | } |
3943 | 4179 | } |
3944 | 4180 | |
@@ -3963,46 +4199,54 @@ discard block |
||
3963 | 4199 | { |
3964 | 4200 | global $modSettings; |
3965 | 4201 | |
3966 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
3967 | - return $host; |
|
4202 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4203 | + return $host; |
|
4204 | + } |
|
3968 | 4205 | $t = microtime(); |
3969 | 4206 | |
3970 | 4207 | // Try the Linux host command, perhaps? |
3971 | 4208 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
3972 | 4209 | { |
3973 | - if (!isset($modSettings['host_to_dis'])) |
|
3974 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
3975 | - else |
|
3976 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4210 | + if (!isset($modSettings['host_to_dis'])) { |
|
4211 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4212 | + } else { |
|
4213 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4214 | + } |
|
3977 | 4215 | |
3978 | 4216 | // Did host say it didn't find anything? |
3979 | - if (strpos($test, 'not found') !== false) |
|
3980 | - $host = ''; |
|
4217 | + if (strpos($test, 'not found') !== false) { |
|
4218 | + $host = ''; |
|
4219 | + } |
|
3981 | 4220 | // Invalid server option? |
3982 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
3983 | - updateSettings(array('host_to_dis' => 1)); |
|
4221 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4222 | + updateSettings(array('host_to_dis' => 1)); |
|
4223 | + } |
|
3984 | 4224 | // Maybe it found something, after all? |
3985 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
3986 | - $host = $match[1]; |
|
4225 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4226 | + $host = $match[1]; |
|
4227 | + } |
|
3987 | 4228 | } |
3988 | 4229 | |
3989 | 4230 | // This is nslookup; usually only Windows, but possibly some Unix? |
3990 | 4231 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
3991 | 4232 | { |
3992 | 4233 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
3993 | - if (strpos($test, 'Non-existent domain') !== false) |
|
3994 | - $host = ''; |
|
3995 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
3996 | - $host = $match[1]; |
|
4234 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4235 | + $host = ''; |
|
4236 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4237 | + $host = $match[1]; |
|
4238 | + } |
|
3997 | 4239 | } |
3998 | 4240 | |
3999 | 4241 | // This is the last try :/. |
4000 | - if (!isset($host) || $host === false) |
|
4001 | - $host = @gethostbyaddr($ip); |
|
4242 | + if (!isset($host) || $host === false) { |
|
4243 | + $host = @gethostbyaddr($ip); |
|
4244 | + } |
|
4002 | 4245 | |
4003 | 4246 | // It took a long time, so let's cache it! |
4004 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
4005 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4247 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4248 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4249 | + } |
|
4006 | 4250 | |
4007 | 4251 | return $host; |
4008 | 4252 | } |
@@ -4038,20 +4282,21 @@ discard block |
||
4038 | 4282 | { |
4039 | 4283 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
4040 | 4284 | $total = 0; |
4041 | - for ($i = 0; $i < $max_chars; $i++) |
|
4042 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4285 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4286 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4287 | + } |
|
4043 | 4288 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
4044 | 4289 | } |
4045 | 4290 | } |
4046 | 4291 | return array_unique($returned_ints); |
4047 | - } |
|
4048 | - else |
|
4292 | + } else |
|
4049 | 4293 | { |
4050 | 4294 | // Trim characters before and after and add slashes for database insertion. |
4051 | 4295 | $returned_words = array(); |
4052 | - foreach ($words as $word) |
|
4053 | - if (($word = trim($word, '-_\'')) !== '') |
|
4296 | + foreach ($words as $word) { |
|
4297 | + if (($word = trim($word, '-_\'')) !== '') |
|
4054 | 4298 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4299 | + } |
|
4055 | 4300 | |
4056 | 4301 | // Filter out all words that occur more than once. |
4057 | 4302 | return array_unique($returned_words); |
@@ -4073,16 +4318,18 @@ discard block |
||
4073 | 4318 | global $settings, $txt; |
4074 | 4319 | |
4075 | 4320 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
4076 | - if (function_exists('template_create_button') && !$force_use) |
|
4077 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4321 | + if (function_exists('template_create_button') && !$force_use) { |
|
4322 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4323 | + } |
|
4078 | 4324 | |
4079 | - if (!$settings['use_image_buttons']) |
|
4080 | - return $txt[$alt]; |
|
4081 | - elseif (!empty($settings['use_buttons'])) |
|
4082 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4083 | - else |
|
4084 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4085 | -} |
|
4325 | + if (!$settings['use_image_buttons']) { |
|
4326 | + return $txt[$alt]; |
|
4327 | + } elseif (!empty($settings['use_buttons'])) { |
|
4328 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4329 | + } else { |
|
4330 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4331 | + } |
|
4332 | + } |
|
4086 | 4333 | |
4087 | 4334 | /** |
4088 | 4335 | * Sets up all of the top menu buttons |
@@ -4125,9 +4372,10 @@ discard block |
||
4125 | 4372 | var user_menus = new smc_PopupMenu(); |
4126 | 4373 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4127 | 4374 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4128 | - if ($context['allow_pm']) |
|
4129 | - addInlineJavaScript(' |
|
4375 | + if ($context['allow_pm']) { |
|
4376 | + addInlineJavaScript(' |
|
4130 | 4377 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4378 | + } |
|
4131 | 4379 | |
4132 | 4380 | if (!empty($modSettings['enable_ajax_alerts'])) |
4133 | 4381 | { |
@@ -4287,88 +4535,96 @@ discard block |
||
4287 | 4535 | |
4288 | 4536 | // Now we put the buttons in the context so the theme can use them. |
4289 | 4537 | $menu_buttons = array(); |
4290 | - foreach ($buttons as $act => $button) |
|
4291 | - if (!empty($button['show'])) |
|
4538 | + foreach ($buttons as $act => $button) { |
|
4539 | + if (!empty($button['show'])) |
|
4292 | 4540 | { |
4293 | 4541 | $button['active_button'] = false; |
4542 | + } |
|
4294 | 4543 | |
4295 | 4544 | // This button needs some action. |
4296 | - if (isset($button['action_hook'])) |
|
4297 | - $needs_action_hook = true; |
|
4545 | + if (isset($button['action_hook'])) { |
|
4546 | + $needs_action_hook = true; |
|
4547 | + } |
|
4298 | 4548 | |
4299 | 4549 | // Make sure the last button truly is the last button. |
4300 | 4550 | if (!empty($button['is_last'])) |
4301 | 4551 | { |
4302 | - if (isset($last_button)) |
|
4303 | - unset($menu_buttons[$last_button]['is_last']); |
|
4552 | + if (isset($last_button)) { |
|
4553 | + unset($menu_buttons[$last_button]['is_last']); |
|
4554 | + } |
|
4304 | 4555 | $last_button = $act; |
4305 | 4556 | } |
4306 | 4557 | |
4307 | 4558 | // Go through the sub buttons if there are any. |
4308 | - if (!empty($button['sub_buttons'])) |
|
4309 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4559 | + if (!empty($button['sub_buttons'])) { |
|
4560 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4310 | 4561 | { |
4311 | 4562 | if (empty($subbutton['show'])) |
4312 | 4563 | unset($button['sub_buttons'][$key]); |
4564 | + } |
|
4313 | 4565 | |
4314 | 4566 | // 2nd level sub buttons next... |
4315 | 4567 | if (!empty($subbutton['sub_buttons'])) |
4316 | 4568 | { |
4317 | 4569 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4318 | 4570 | { |
4319 | - if (empty($sub_button2['show'])) |
|
4320 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4571 | + if (empty($sub_button2['show'])) { |
|
4572 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4573 | + } |
|
4321 | 4574 | } |
4322 | 4575 | } |
4323 | 4576 | } |
4324 | 4577 | |
4325 | 4578 | // Does this button have its own icon? |
4326 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4327 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4328 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4329 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4330 | - elseif (isset($button['icon'])) |
|
4331 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4332 | - else |
|
4333 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4579 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4580 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4581 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4582 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4583 | + } elseif (isset($button['icon'])) { |
|
4584 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4585 | + } else { |
|
4586 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4587 | + } |
|
4334 | 4588 | |
4335 | 4589 | $menu_buttons[$act] = $button; |
4336 | 4590 | } |
4337 | 4591 | |
4338 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4339 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4592 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4593 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4594 | + } |
|
4340 | 4595 | } |
4341 | 4596 | |
4342 | 4597 | $context['menu_buttons'] = $menu_buttons; |
4343 | 4598 | |
4344 | 4599 | // Logging out requires the session id in the url. |
4345 | - if (isset($context['menu_buttons']['logout'])) |
|
4346 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4600 | + if (isset($context['menu_buttons']['logout'])) { |
|
4601 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4602 | + } |
|
4347 | 4603 | |
4348 | 4604 | // Figure out which action we are doing so we can set the active tab. |
4349 | 4605 | // Default to home. |
4350 | 4606 | $current_action = 'home'; |
4351 | 4607 | |
4352 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4353 | - $current_action = $context['current_action']; |
|
4354 | - elseif ($context['current_action'] == 'search2') |
|
4355 | - $current_action = 'search'; |
|
4356 | - elseif ($context['current_action'] == 'theme') |
|
4357 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4358 | - elseif ($context['current_action'] == 'register2') |
|
4359 | - $current_action = 'register'; |
|
4360 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4361 | - $current_action = 'login'; |
|
4362 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4363 | - $current_action = 'moderate'; |
|
4608 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4609 | + $current_action = $context['current_action']; |
|
4610 | + } elseif ($context['current_action'] == 'search2') { |
|
4611 | + $current_action = 'search'; |
|
4612 | + } elseif ($context['current_action'] == 'theme') { |
|
4613 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4614 | + } elseif ($context['current_action'] == 'register2') { |
|
4615 | + $current_action = 'register'; |
|
4616 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4617 | + $current_action = 'login'; |
|
4618 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4619 | + $current_action = 'moderate'; |
|
4620 | + } |
|
4364 | 4621 | |
4365 | 4622 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4366 | 4623 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4367 | 4624 | { |
4368 | 4625 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4369 | 4626 | $context[$current_action] = true; |
4370 | - } |
|
4371 | - elseif ($context['current_action'] == 'pm') |
|
4627 | + } elseif ($context['current_action'] == 'pm') |
|
4372 | 4628 | { |
4373 | 4629 | $current_action = 'self_pm'; |
4374 | 4630 | $context['self_pm'] = true; |
@@ -4425,12 +4681,14 @@ discard block |
||
4425 | 4681 | } |
4426 | 4682 | |
4427 | 4683 | // Not all actions are simple. |
4428 | - if (!empty($needs_action_hook)) |
|
4429 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4684 | + if (!empty($needs_action_hook)) { |
|
4685 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4686 | + } |
|
4430 | 4687 | |
4431 | - if (isset($context['menu_buttons'][$current_action])) |
|
4432 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4433 | -} |
|
4688 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4689 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4690 | + } |
|
4691 | + } |
|
4434 | 4692 | |
4435 | 4693 | /** |
4436 | 4694 | * Generate a random seed and ensure it's stored in settings. |
@@ -4454,30 +4712,35 @@ discard block |
||
4454 | 4712 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4455 | 4713 | global $context, $txt; |
4456 | 4714 | |
4457 | - if ($db_show_debug === true) |
|
4458 | - $context['debug']['hooks'][] = $hook; |
|
4715 | + if ($db_show_debug === true) { |
|
4716 | + $context['debug']['hooks'][] = $hook; |
|
4717 | + } |
|
4459 | 4718 | |
4460 | 4719 | // Need to have some control. |
4461 | - if (!isset($context['instances'])) |
|
4462 | - $context['instances'] = array(); |
|
4720 | + if (!isset($context['instances'])) { |
|
4721 | + $context['instances'] = array(); |
|
4722 | + } |
|
4463 | 4723 | |
4464 | 4724 | $results = array(); |
4465 | - if (empty($modSettings[$hook])) |
|
4466 | - return $results; |
|
4725 | + if (empty($modSettings[$hook])) { |
|
4726 | + return $results; |
|
4727 | + } |
|
4467 | 4728 | |
4468 | 4729 | $functions = explode(',', $modSettings[$hook]); |
4469 | 4730 | // Loop through each function. |
4470 | 4731 | foreach ($functions as $function) |
4471 | 4732 | { |
4472 | 4733 | // Hook has been marked as "disabled". Skip it! |
4473 | - if (strpos($function, '!') !== false) |
|
4474 | - continue; |
|
4734 | + if (strpos($function, '!') !== false) { |
|
4735 | + continue; |
|
4736 | + } |
|
4475 | 4737 | |
4476 | 4738 | $call = call_helper($function, true); |
4477 | 4739 | |
4478 | 4740 | // Is it valid? |
4479 | - if (!empty($call)) |
|
4480 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4741 | + if (!empty($call)) { |
|
4742 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4743 | + } |
|
4481 | 4744 | |
4482 | 4745 | // Whatever it was suppose to call, it failed :( |
4483 | 4746 | elseif (!empty($function)) |
@@ -4493,8 +4756,9 @@ discard block |
||
4493 | 4756 | } |
4494 | 4757 | |
4495 | 4758 | // "Assume" the file resides on $boarddir somewhere... |
4496 | - else |
|
4497 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4759 | + else { |
|
4760 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4761 | + } |
|
4498 | 4762 | } |
4499 | 4763 | } |
4500 | 4764 | |
@@ -4516,12 +4780,14 @@ discard block |
||
4516 | 4780 | global $smcFunc, $modSettings; |
4517 | 4781 | |
4518 | 4782 | // Any objects? |
4519 | - if ($object) |
|
4520 | - $function = $function . '#'; |
|
4783 | + if ($object) { |
|
4784 | + $function = $function . '#'; |
|
4785 | + } |
|
4521 | 4786 | |
4522 | 4787 | // Any files to load? |
4523 | - if (!empty($file) && is_string($file)) |
|
4524 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4788 | + if (!empty($file) && is_string($file)) { |
|
4789 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4790 | + } |
|
4525 | 4791 | |
4526 | 4792 | // Get the correct string. |
4527 | 4793 | $integration_call = $function; |
@@ -4543,13 +4809,14 @@ discard block |
||
4543 | 4809 | if (!empty($current_functions)) |
4544 | 4810 | { |
4545 | 4811 | $current_functions = explode(',', $current_functions); |
4546 | - if (in_array($integration_call, $current_functions)) |
|
4547 | - return; |
|
4812 | + if (in_array($integration_call, $current_functions)) { |
|
4813 | + return; |
|
4814 | + } |
|
4548 | 4815 | |
4549 | 4816 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4817 | + } else { |
|
4818 | + $permanent_functions = array($integration_call); |
|
4550 | 4819 | } |
4551 | - else |
|
4552 | - $permanent_functions = array($integration_call); |
|
4553 | 4820 | |
4554 | 4821 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4555 | 4822 | } |
@@ -4558,8 +4825,9 @@ discard block |
||
4558 | 4825 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4559 | 4826 | |
4560 | 4827 | // Do nothing, if it's already there. |
4561 | - if (in_array($integration_call, $functions)) |
|
4562 | - return; |
|
4828 | + if (in_array($integration_call, $functions)) { |
|
4829 | + return; |
|
4830 | + } |
|
4563 | 4831 | |
4564 | 4832 | $functions[] = $integration_call; |
4565 | 4833 | $modSettings[$hook] = implode(',', $functions); |
@@ -4582,12 +4850,14 @@ discard block |
||
4582 | 4850 | global $smcFunc, $modSettings; |
4583 | 4851 | |
4584 | 4852 | // Any objects? |
4585 | - if ($object) |
|
4586 | - $function = $function . '#'; |
|
4853 | + if ($object) { |
|
4854 | + $function = $function . '#'; |
|
4855 | + } |
|
4587 | 4856 | |
4588 | 4857 | // Any files to load? |
4589 | - if (!empty($file) && is_string($file)) |
|
4590 | - $function = $file . '|' . $function; |
|
4858 | + if (!empty($file) && is_string($file)) { |
|
4859 | + $function = $file . '|' . $function; |
|
4860 | + } |
|
4591 | 4861 | |
4592 | 4862 | // Get the correct string. |
4593 | 4863 | $integration_call = $function; |
@@ -4608,16 +4878,18 @@ discard block |
||
4608 | 4878 | { |
4609 | 4879 | $current_functions = explode(',', $current_functions); |
4610 | 4880 | |
4611 | - if (in_array($integration_call, $current_functions)) |
|
4612 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4881 | + if (in_array($integration_call, $current_functions)) { |
|
4882 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4883 | + } |
|
4613 | 4884 | } |
4614 | 4885 | |
4615 | 4886 | // Turn the function list into something usable. |
4616 | 4887 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4617 | 4888 | |
4618 | 4889 | // You can only remove it if it's available. |
4619 | - if (!in_array($integration_call, $functions)) |
|
4620 | - return; |
|
4890 | + if (!in_array($integration_call, $functions)) { |
|
4891 | + return; |
|
4892 | + } |
|
4621 | 4893 | |
4622 | 4894 | $functions = array_diff($functions, array($integration_call)); |
4623 | 4895 | $modSettings[$hook] = implode(',', $functions); |
@@ -4638,17 +4910,20 @@ discard block |
||
4638 | 4910 | global $context, $smcFunc, $txt, $db_show_debug; |
4639 | 4911 | |
4640 | 4912 | // Really? |
4641 | - if (empty($string)) |
|
4642 | - return false; |
|
4913 | + if (empty($string)) { |
|
4914 | + return false; |
|
4915 | + } |
|
4643 | 4916 | |
4644 | 4917 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4645 | 4918 | // A closure? should be a callable one. |
4646 | - if (is_array($string) || $string instanceof Closure) |
|
4647 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4919 | + if (is_array($string) || $string instanceof Closure) { |
|
4920 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4921 | + } |
|
4648 | 4922 | |
4649 | 4923 | // No full objects, sorry! pass a method or a property instead! |
4650 | - if (is_object($string)) |
|
4651 | - return false; |
|
4924 | + if (is_object($string)) { |
|
4925 | + return false; |
|
4926 | + } |
|
4652 | 4927 | |
4653 | 4928 | // Stay vitaminized my friends... |
4654 | 4929 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4657,8 +4932,9 @@ discard block |
||
4657 | 4932 | $string = load_file($string); |
4658 | 4933 | |
4659 | 4934 | // Loaded file failed |
4660 | - if (empty($string)) |
|
4661 | - return false; |
|
4935 | + if (empty($string)) { |
|
4936 | + return false; |
|
4937 | + } |
|
4662 | 4938 | |
4663 | 4939 | // Found a method. |
4664 | 4940 | if (strpos($string, '::') !== false) |
@@ -4679,8 +4955,9 @@ discard block |
||
4679 | 4955 | // Add another one to the list. |
4680 | 4956 | if ($db_show_debug === true) |
4681 | 4957 | { |
4682 | - if (!isset($context['debug']['instances'])) |
|
4683 | - $context['debug']['instances'] = array(); |
|
4958 | + if (!isset($context['debug']['instances'])) { |
|
4959 | + $context['debug']['instances'] = array(); |
|
4960 | + } |
|
4684 | 4961 | |
4685 | 4962 | $context['debug']['instances'][$class] = $class; |
4686 | 4963 | } |
@@ -4690,13 +4967,15 @@ discard block |
||
4690 | 4967 | } |
4691 | 4968 | |
4692 | 4969 | // Right then. This is a call to a static method. |
4693 | - else |
|
4694 | - $func = array($class, $method); |
|
4970 | + else { |
|
4971 | + $func = array($class, $method); |
|
4972 | + } |
|
4695 | 4973 | } |
4696 | 4974 | |
4697 | 4975 | // Nope! just a plain regular function. |
4698 | - else |
|
4699 | - $func = $string; |
|
4976 | + else { |
|
4977 | + $func = $string; |
|
4978 | + } |
|
4700 | 4979 | |
4701 | 4980 | // Right, we got what we need, time to do some checks. |
4702 | 4981 | if (!is_callable($func, false, $callable_name)) |
@@ -4712,17 +4991,18 @@ discard block |
||
4712 | 4991 | else |
4713 | 4992 | { |
4714 | 4993 | // What are we gonna do about it? |
4715 | - if ($return) |
|
4716 | - return $func; |
|
4994 | + if ($return) { |
|
4995 | + return $func; |
|
4996 | + } |
|
4717 | 4997 | |
4718 | 4998 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4719 | 4999 | else |
4720 | 5000 | { |
4721 | - if (is_array($func)) |
|
4722 | - call_user_func($func); |
|
4723 | - |
|
4724 | - else |
|
4725 | - $func(); |
|
5001 | + if (is_array($func)) { |
|
5002 | + call_user_func($func); |
|
5003 | + } else { |
|
5004 | + $func(); |
|
5005 | + } |
|
4726 | 5006 | } |
4727 | 5007 | } |
4728 | 5008 | } |
@@ -4739,31 +5019,34 @@ discard block |
||
4739 | 5019 | { |
4740 | 5020 | global $sourcedir, $txt, $boarddir, $settings; |
4741 | 5021 | |
4742 | - if (empty($string)) |
|
4743 | - return false; |
|
5022 | + if (empty($string)) { |
|
5023 | + return false; |
|
5024 | + } |
|
4744 | 5025 | |
4745 | 5026 | if (strpos($string, '|') !== false) |
4746 | 5027 | { |
4747 | 5028 | list ($file, $string) = explode('|', $string); |
4748 | 5029 | |
4749 | 5030 | // Match the wildcards to their regular vars. |
4750 | - if (empty($settings['theme_dir'])) |
|
4751 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4752 | - |
|
4753 | - else |
|
4754 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5031 | + if (empty($settings['theme_dir'])) { |
|
5032 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
5033 | + } else { |
|
5034 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5035 | + } |
|
4755 | 5036 | |
4756 | 5037 | // Load the file if it can be loaded. |
4757 | - if (file_exists($absPath)) |
|
4758 | - require_once($absPath); |
|
5038 | + if (file_exists($absPath)) { |
|
5039 | + require_once($absPath); |
|
5040 | + } |
|
4759 | 5041 | |
4760 | 5042 | // No? try a fallback to $sourcedir |
4761 | 5043 | else |
4762 | 5044 | { |
4763 | 5045 | $absPath = $sourcedir .'/'. $file; |
4764 | 5046 | |
4765 | - if (file_exists($absPath)) |
|
4766 | - require_once($absPath); |
|
5047 | + if (file_exists($absPath)) { |
|
5048 | + require_once($absPath); |
|
5049 | + } |
|
4767 | 5050 | |
4768 | 5051 | // Sorry, can't do much for you at this point. |
4769 | 5052 | else |
@@ -4802,8 +5085,9 @@ discard block |
||
4802 | 5085 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
4803 | 5086 | |
4804 | 5087 | // No scheme? No data for you! |
4805 | - if (empty($match[1])) |
|
4806 | - return false; |
|
5088 | + if (empty($match[1])) { |
|
5089 | + return false; |
|
5090 | + } |
|
4807 | 5091 | |
4808 | 5092 | // An FTP url. We should try connecting and RETRieving it... |
4809 | 5093 | elseif ($match[1] == 'ftp') |
@@ -4813,23 +5097,26 @@ discard block |
||
4813 | 5097 | |
4814 | 5098 | // Establish a connection and attempt to enable passive mode. |
4815 | 5099 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
4816 | - if ($ftp->error !== false || !$ftp->passive()) |
|
4817 | - return false; |
|
5100 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
5101 | + return false; |
|
5102 | + } |
|
4818 | 5103 | |
4819 | 5104 | // I want that one *points*! |
4820 | 5105 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
4821 | 5106 | |
4822 | 5107 | // Since passive mode worked (or we would have returned already!) open the connection. |
4823 | 5108 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
4824 | - if (!$fp) |
|
4825 | - return false; |
|
5109 | + if (!$fp) { |
|
5110 | + return false; |
|
5111 | + } |
|
4826 | 5112 | |
4827 | 5113 | // The server should now say something in acknowledgement. |
4828 | 5114 | $ftp->check_response(150); |
4829 | 5115 | |
4830 | 5116 | $data = ''; |
4831 | - while (!feof($fp)) |
|
4832 | - $data .= fread($fp, 4096); |
|
5117 | + while (!feof($fp)) { |
|
5118 | + $data .= fread($fp, 4096); |
|
5119 | + } |
|
4833 | 5120 | fclose($fp); |
4834 | 5121 | |
4835 | 5122 | // All done, right? Good. |
@@ -4841,8 +5128,9 @@ discard block |
||
4841 | 5128 | elseif (isset($match[1]) && $match[1] == 'http') |
4842 | 5129 | { |
4843 | 5130 | // First try to use fsockopen, because it is fastest. |
4844 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
4845 | - $fp = $keep_alive_fp; |
|
5131 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
5132 | + $fp = $keep_alive_fp; |
|
5133 | + } |
|
4846 | 5134 | if (empty($fp)) |
4847 | 5135 | { |
4848 | 5136 | // Open the socket on the port we want... |
@@ -4862,20 +5150,21 @@ discard block |
||
4862 | 5150 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
4863 | 5151 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
4864 | 5152 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
4865 | - if ($keep_alive) |
|
4866 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
4867 | - else |
|
4868 | - fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
4869 | - } |
|
4870 | - else |
|
5153 | + if ($keep_alive) { |
|
5154 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
5155 | + } else { |
|
5156 | + fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
5157 | + } |
|
5158 | + } else |
|
4871 | 5159 | { |
4872 | 5160 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
4873 | 5161 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
4874 | 5162 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
4875 | - if ($keep_alive) |
|
4876 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
4877 | - else |
|
4878 | - fwrite($fp, 'connection: close' . "\r\n"); |
|
5163 | + if ($keep_alive) { |
|
5164 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
5165 | + } else { |
|
5166 | + fwrite($fp, 'connection: close' . "\r\n"); |
|
5167 | + } |
|
4879 | 5168 | fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n"); |
4880 | 5169 | fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n"); |
4881 | 5170 | fwrite($fp, $post_data); |
@@ -4888,30 +5177,33 @@ discard block |
||
4888 | 5177 | { |
4889 | 5178 | $header = ''; |
4890 | 5179 | $location = ''; |
4891 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
4892 | - if (strpos($header, 'location:') !== false) |
|
5180 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
5181 | + if (strpos($header, 'location:') !== false) |
|
4893 | 5182 | $location = trim(substr($header, strpos($header, ':') + 1)); |
5183 | + } |
|
4894 | 5184 | |
4895 | - if (empty($location)) |
|
4896 | - return false; |
|
4897 | - else |
|
5185 | + if (empty($location)) { |
|
5186 | + return false; |
|
5187 | + } else |
|
4898 | 5188 | { |
4899 | - if (!$keep_alive) |
|
4900 | - fclose($fp); |
|
5189 | + if (!$keep_alive) { |
|
5190 | + fclose($fp); |
|
5191 | + } |
|
4901 | 5192 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
4902 | 5193 | } |
4903 | 5194 | } |
4904 | 5195 | |
4905 | 5196 | // Make sure we get a 200 OK. |
4906 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
4907 | - return false; |
|
5197 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
5198 | + return false; |
|
5199 | + } |
|
4908 | 5200 | |
4909 | 5201 | // Skip the headers... |
4910 | 5202 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
4911 | 5203 | { |
4912 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
4913 | - $content_length = $match[1]; |
|
4914 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
5204 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
5205 | + $content_length = $match[1]; |
|
5206 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
4915 | 5207 | { |
4916 | 5208 | $keep_alive_dom = null; |
4917 | 5209 | $keep_alive = false; |
@@ -4923,17 +5215,19 @@ discard block |
||
4923 | 5215 | $data = ''; |
4924 | 5216 | if (isset($content_length)) |
4925 | 5217 | { |
4926 | - while (!feof($fp) && strlen($data) < $content_length) |
|
4927 | - $data .= fread($fp, $content_length - strlen($data)); |
|
4928 | - } |
|
4929 | - else |
|
5218 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
5219 | + $data .= fread($fp, $content_length - strlen($data)); |
|
5220 | + } |
|
5221 | + } else |
|
4930 | 5222 | { |
4931 | - while (!feof($fp)) |
|
4932 | - $data .= fread($fp, 4096); |
|
5223 | + while (!feof($fp)) { |
|
5224 | + $data .= fread($fp, 4096); |
|
5225 | + } |
|
4933 | 5226 | } |
4934 | 5227 | |
4935 | - if (!$keep_alive) |
|
4936 | - fclose($fp); |
|
5228 | + if (!$keep_alive) { |
|
5229 | + fclose($fp); |
|
5230 | + } |
|
4937 | 5231 | } |
4938 | 5232 | |
4939 | 5233 | // If using fsockopen didn't work, try to use cURL if available. |
@@ -4946,17 +5240,18 @@ discard block |
||
4946 | 5240 | $fetch_data->get_url_data($url, $post_data); |
4947 | 5241 | |
4948 | 5242 | // no errors and a 200 result, then we have a good dataset, well we at least have data. ;) |
4949 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
4950 | - $data = $fetch_data->result('body'); |
|
4951 | - else |
|
4952 | - return false; |
|
5243 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
5244 | + $data = $fetch_data->result('body'); |
|
5245 | + } else { |
|
5246 | + return false; |
|
5247 | + } |
|
4953 | 5248 | } |
4954 | 5249 | |
4955 | 5250 | // Neither fsockopen nor curl are available. Well, phooey. |
4956 | - else |
|
4957 | - return false; |
|
4958 | - } |
|
4959 | - else |
|
5251 | + else { |
|
5252 | + return false; |
|
5253 | + } |
|
5254 | + } else |
|
4960 | 5255 | { |
4961 | 5256 | // Umm, this shouldn't happen? |
4962 | 5257 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -4976,8 +5271,9 @@ discard block |
||
4976 | 5271 | global $user_info, $smcFunc; |
4977 | 5272 | |
4978 | 5273 | // Make sure we have something to work with. |
4979 | - if (empty($topic)) |
|
4980 | - return array(); |
|
5274 | + if (empty($topic)) { |
|
5275 | + return array(); |
|
5276 | + } |
|
4981 | 5277 | |
4982 | 5278 | |
4983 | 5279 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -5000,8 +5296,9 @@ discard block |
||
5000 | 5296 | 'topic' => $topic, |
5001 | 5297 | ) |
5002 | 5298 | ); |
5003 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
5004 | - $temp[] = (int) $row['content_id']; |
|
5299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5300 | + $temp[] = (int) $row['content_id']; |
|
5301 | + } |
|
5005 | 5302 | |
5006 | 5303 | cache_put_data($cache_key, $temp, $ttl); |
5007 | 5304 | } |
@@ -5022,8 +5319,9 @@ discard block |
||
5022 | 5319 | { |
5023 | 5320 | global $context; |
5024 | 5321 | |
5025 | - if (empty($string)) |
|
5026 | - return $string; |
|
5322 | + if (empty($string)) { |
|
5323 | + return $string; |
|
5324 | + } |
|
5027 | 5325 | |
5028 | 5326 | // UTF-8 occurences of MS special characters |
5029 | 5327 | $findchars_utf8 = array( |
@@ -5064,10 +5362,11 @@ discard block |
||
5064 | 5362 | '--', // — |
5065 | 5363 | ); |
5066 | 5364 | |
5067 | - if ($context['utf8']) |
|
5068 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5069 | - else |
|
5070 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5365 | + if ($context['utf8']) { |
|
5366 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5367 | + } else { |
|
5368 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5369 | + } |
|
5071 | 5370 | |
5072 | 5371 | return $string; |
5073 | 5372 | } |
@@ -5086,49 +5385,59 @@ discard block |
||
5086 | 5385 | { |
5087 | 5386 | global $context; |
5088 | 5387 | |
5089 | - if (!isset($matches[2])) |
|
5090 | - return ''; |
|
5388 | + if (!isset($matches[2])) { |
|
5389 | + return ''; |
|
5390 | + } |
|
5091 | 5391 | |
5092 | 5392 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
5093 | 5393 | |
5094 | 5394 | // remove left to right / right to left overrides |
5095 | - if ($num === 0x202D || $num === 0x202E) |
|
5096 | - return ''; |
|
5395 | + if ($num === 0x202D || $num === 0x202E) { |
|
5396 | + return ''; |
|
5397 | + } |
|
5097 | 5398 | |
5098 | 5399 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
5099 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
5100 | - return '&#' . $num . ';'; |
|
5400 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5401 | + return '&#' . $num . ';'; |
|
5402 | + } |
|
5101 | 5403 | |
5102 | 5404 | if (empty($context['utf8'])) |
5103 | 5405 | { |
5104 | 5406 | // no control characters |
5105 | - if ($num < 0x20) |
|
5106 | - return ''; |
|
5407 | + if ($num < 0x20) { |
|
5408 | + return ''; |
|
5409 | + } |
|
5107 | 5410 | // text is text |
5108 | - elseif ($num < 0x80) |
|
5109 | - return chr($num); |
|
5411 | + elseif ($num < 0x80) { |
|
5412 | + return chr($num); |
|
5413 | + } |
|
5110 | 5414 | // all others get html-ised |
5111 | - else |
|
5112 | - return '&#' . $matches[2] . ';'; |
|
5113 | - } |
|
5114 | - else |
|
5415 | + else { |
|
5416 | + return '&#' . $matches[2] . ';'; |
|
5417 | + } |
|
5418 | + } else |
|
5115 | 5419 | { |
5116 | 5420 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
5117 | 5421 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
5118 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
5119 | - return ''; |
|
5422 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5423 | + return ''; |
|
5424 | + } |
|
5120 | 5425 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
5121 | - elseif ($num < 0x80) |
|
5122 | - return chr($num); |
|
5426 | + elseif ($num < 0x80) { |
|
5427 | + return chr($num); |
|
5428 | + } |
|
5123 | 5429 | // <0x800 (2048) |
5124 | - elseif ($num < 0x800) |
|
5125 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5430 | + elseif ($num < 0x800) { |
|
5431 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5432 | + } |
|
5126 | 5433 | // < 0x10000 (65536) |
5127 | - elseif ($num < 0x10000) |
|
5128 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5434 | + elseif ($num < 0x10000) { |
|
5435 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5436 | + } |
|
5129 | 5437 | // <= 0x10FFFF (1114111) |
5130 | - else |
|
5131 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5438 | + else { |
|
5439 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5440 | + } |
|
5132 | 5441 | } |
5133 | 5442 | } |
5134 | 5443 | |
@@ -5144,28 +5453,34 @@ discard block |
||
5144 | 5453 | */ |
5145 | 5454 | function fixchar__callback($matches) |
5146 | 5455 | { |
5147 | - if (!isset($matches[1])) |
|
5148 | - return ''; |
|
5456 | + if (!isset($matches[1])) { |
|
5457 | + return ''; |
|
5458 | + } |
|
5149 | 5459 | |
5150 | 5460 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
5151 | 5461 | |
5152 | 5462 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
5153 | 5463 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
5154 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
5155 | - return ''; |
|
5464 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5465 | + return ''; |
|
5466 | + } |
|
5156 | 5467 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
5157 | - elseif ($num < 0x80) |
|
5158 | - return chr($num); |
|
5468 | + elseif ($num < 0x80) { |
|
5469 | + return chr($num); |
|
5470 | + } |
|
5159 | 5471 | // <0x800 (2048) |
5160 | - elseif ($num < 0x800) |
|
5161 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5472 | + elseif ($num < 0x800) { |
|
5473 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5474 | + } |
|
5162 | 5475 | // < 0x10000 (65536) |
5163 | - elseif ($num < 0x10000) |
|
5164 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5476 | + elseif ($num < 0x10000) { |
|
5477 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5478 | + } |
|
5165 | 5479 | // <= 0x10FFFF (1114111) |
5166 | - else |
|
5167 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5168 | -} |
|
5480 | + else { |
|
5481 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5482 | + } |
|
5483 | + } |
|
5169 | 5484 | |
5170 | 5485 | /** |
5171 | 5486 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -5178,17 +5493,19 @@ discard block |
||
5178 | 5493 | */ |
5179 | 5494 | function entity_fix__callback($matches) |
5180 | 5495 | { |
5181 | - if (!isset($matches[2])) |
|
5182 | - return ''; |
|
5496 | + if (!isset($matches[2])) { |
|
5497 | + return ''; |
|
5498 | + } |
|
5183 | 5499 | |
5184 | 5500 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
5185 | 5501 | |
5186 | 5502 | // we don't allow control characters, characters out of range, byte markers, etc |
5187 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
5188 | - return ''; |
|
5189 | - else |
|
5190 | - return '&#' . $num . ';'; |
|
5191 | -} |
|
5503 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5504 | + return ''; |
|
5505 | + } else { |
|
5506 | + return '&#' . $num . ';'; |
|
5507 | + } |
|
5508 | + } |
|
5192 | 5509 | |
5193 | 5510 | /** |
5194 | 5511 | * Return a Gravatar URL based on |
@@ -5212,18 +5529,23 @@ discard block |
||
5212 | 5529 | $ratings = array('G', 'PG', 'R', 'X'); |
5213 | 5530 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
5214 | 5531 | $url_params = array(); |
5215 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
5216 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5217 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
5218 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5219 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
5220 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5221 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
5222 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5532 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5533 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5534 | + } |
|
5535 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5536 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5537 | + } |
|
5538 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5539 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5540 | + } |
|
5541 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5542 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5223 | 5543 | $size_string = $modSettings['avatar_max_height_external']; |
5544 | + } |
|
5224 | 5545 | |
5225 | - if (!empty($size_string)) |
|
5226 | - $url_params[] = 's=' . $size_string; |
|
5546 | + if (!empty($size_string)) { |
|
5547 | + $url_params[] = 's=' . $size_string; |
|
5548 | + } |
|
5227 | 5549 | } |
5228 | 5550 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
5229 | 5551 | |
@@ -5242,22 +5564,26 @@ discard block |
||
5242 | 5564 | static $timezones = null, $lastwhen = null; |
5243 | 5565 | |
5244 | 5566 | // No point doing this over if we already did it once |
5245 | - if (!empty($timezones) && $when == $lastwhen) |
|
5246 | - return $timezones; |
|
5247 | - else |
|
5248 | - $lastwhen = $when; |
|
5567 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5568 | + return $timezones; |
|
5569 | + } else { |
|
5570 | + $lastwhen = $when; |
|
5571 | + } |
|
5249 | 5572 | |
5250 | 5573 | // Parseable datetime string? |
5251 | - if (is_int($timestamp = strtotime($when))) |
|
5252 | - $when = $timestamp; |
|
5574 | + if (is_int($timestamp = strtotime($when))) { |
|
5575 | + $when = $timestamp; |
|
5576 | + } |
|
5253 | 5577 | |
5254 | 5578 | // A Unix timestamp? |
5255 | - elseif (is_numeric($when)) |
|
5256 | - $when = intval($when); |
|
5579 | + elseif (is_numeric($when)) { |
|
5580 | + $when = intval($when); |
|
5581 | + } |
|
5257 | 5582 | |
5258 | 5583 | // Invalid value? Just get current Unix timestamp. |
5259 | - else |
|
5260 | - $when = time(); |
|
5584 | + else { |
|
5585 | + $when = time(); |
|
5586 | + } |
|
5261 | 5587 | |
5262 | 5588 | // We'll need these too |
5263 | 5589 | $date_when = date_create('@' . $when); |
@@ -5321,8 +5647,9 @@ discard block |
||
5321 | 5647 | foreach ($priority_countries as $country) |
5322 | 5648 | { |
5323 | 5649 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5324 | - if (!empty($country_tzids)) |
|
5325 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5650 | + if (!empty($country_tzids)) { |
|
5651 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5652 | + } |
|
5326 | 5653 | } |
5327 | 5654 | |
5328 | 5655 | // Process the preferred timezones first, then the rest. |
@@ -5332,8 +5659,9 @@ discard block |
||
5332 | 5659 | foreach ($tzids as $tzid) |
5333 | 5660 | { |
5334 | 5661 | // We don't want UTC right now |
5335 | - if ($tzid == 'UTC') |
|
5336 | - continue; |
|
5662 | + if ($tzid == 'UTC') { |
|
5663 | + continue; |
|
5664 | + } |
|
5337 | 5665 | |
5338 | 5666 | $tz = timezone_open($tzid); |
5339 | 5667 | |
@@ -5354,8 +5682,9 @@ discard block |
||
5354 | 5682 | } |
5355 | 5683 | |
5356 | 5684 | // A time zone from a prioritized country? |
5357 | - if (in_array($tzid, $priority_tzids)) |
|
5358 | - $priority_zones[$tzkey] = true; |
|
5685 | + if (in_array($tzid, $priority_tzids)) { |
|
5686 | + $priority_zones[$tzkey] = true; |
|
5687 | + } |
|
5359 | 5688 | |
5360 | 5689 | // Keep track of the location and offset for this tzid |
5361 | 5690 | $tzid_parts = explode('/', $tzid); |
@@ -5374,15 +5703,17 @@ discard block |
||
5374 | 5703 | { |
5375 | 5704 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5376 | 5705 | |
5377 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
5378 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5379 | - else |
|
5380 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5706 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
5707 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5708 | + } else { |
|
5709 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5710 | + } |
|
5381 | 5711 | |
5382 | - if (isset($priority_zones[$tzkey])) |
|
5383 | - $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5384 | - else |
|
5385 | - $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5712 | + if (isset($priority_zones[$tzkey])) { |
|
5713 | + $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5714 | + } else { |
|
5715 | + $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5716 | + } |
|
5386 | 5717 | } |
5387 | 5718 | |
5388 | 5719 | $timezones = array_merge( |
@@ -5436,9 +5767,9 @@ discard block |
||
5436 | 5767 | 'Indian/Kerguelen' => 'TFT', |
5437 | 5768 | ); |
5438 | 5769 | |
5439 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
5440 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5441 | - else |
|
5770 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
5771 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5772 | + } else |
|
5442 | 5773 | { |
5443 | 5774 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
5444 | 5775 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5466,8 +5797,9 @@ discard block |
||
5466 | 5797 | */ |
5467 | 5798 | function inet_ptod($ip_address) |
5468 | 5799 | { |
5469 | - if (!isValidIP($ip_address)) |
|
5470 | - return $ip_address; |
|
5800 | + if (!isValidIP($ip_address)) { |
|
5801 | + return $ip_address; |
|
5802 | + } |
|
5471 | 5803 | |
5472 | 5804 | $bin = inet_pton($ip_address); |
5473 | 5805 | return $bin; |
@@ -5479,13 +5811,15 @@ discard block |
||
5479 | 5811 | */ |
5480 | 5812 | function inet_dtop($bin) |
5481 | 5813 | { |
5482 | - if(empty($bin)) |
|
5483 | - return ''; |
|
5814 | + if(empty($bin)) { |
|
5815 | + return ''; |
|
5816 | + } |
|
5484 | 5817 | |
5485 | 5818 | global $db_type; |
5486 | 5819 | |
5487 | - if ($db_type == 'postgresql') |
|
5488 | - return $bin; |
|
5820 | + if ($db_type == 'postgresql') { |
|
5821 | + return $bin; |
|
5822 | + } |
|
5489 | 5823 | |
5490 | 5824 | $ip_address = inet_ntop($bin); |
5491 | 5825 | |
@@ -5510,26 +5844,32 @@ discard block |
||
5510 | 5844 | */ |
5511 | 5845 | function _safe_serialize($value) |
5512 | 5846 | { |
5513 | - if(is_null($value)) |
|
5514 | - return 'N;'; |
|
5847 | + if(is_null($value)) { |
|
5848 | + return 'N;'; |
|
5849 | + } |
|
5515 | 5850 | |
5516 | - if(is_bool($value)) |
|
5517 | - return 'b:'. (int) $value .';'; |
|
5851 | + if(is_bool($value)) { |
|
5852 | + return 'b:'. (int) $value .';'; |
|
5853 | + } |
|
5518 | 5854 | |
5519 | - if(is_int($value)) |
|
5520 | - return 'i:'. $value .';'; |
|
5855 | + if(is_int($value)) { |
|
5856 | + return 'i:'. $value .';'; |
|
5857 | + } |
|
5521 | 5858 | |
5522 | - if(is_float($value)) |
|
5523 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5859 | + if(is_float($value)) { |
|
5860 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5861 | + } |
|
5524 | 5862 | |
5525 | - if(is_string($value)) |
|
5526 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5863 | + if(is_string($value)) { |
|
5864 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5865 | + } |
|
5527 | 5866 | |
5528 | 5867 | if(is_array($value)) |
5529 | 5868 | { |
5530 | 5869 | $out = ''; |
5531 | - foreach($value as $k => $v) |
|
5532 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5870 | + foreach($value as $k => $v) { |
|
5871 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5872 | + } |
|
5533 | 5873 | |
5534 | 5874 | return 'a:'. count($value) .':{'. $out .'}'; |
5535 | 5875 | } |
@@ -5555,8 +5895,9 @@ discard block |
||
5555 | 5895 | |
5556 | 5896 | $out = _safe_serialize($value); |
5557 | 5897 | |
5558 | - if (isset($mbIntEnc)) |
|
5559 | - mb_internal_encoding($mbIntEnc); |
|
5898 | + if (isset($mbIntEnc)) { |
|
5899 | + mb_internal_encoding($mbIntEnc); |
|
5900 | + } |
|
5560 | 5901 | |
5561 | 5902 | return $out; |
5562 | 5903 | } |
@@ -5573,8 +5914,9 @@ discard block |
||
5573 | 5914 | function _safe_unserialize($str) |
5574 | 5915 | { |
5575 | 5916 | // Input is not a string. |
5576 | - if(empty($str) || !is_string($str)) |
|
5577 | - return false; |
|
5917 | + if(empty($str) || !is_string($str)) { |
|
5918 | + return false; |
|
5919 | + } |
|
5578 | 5920 | |
5579 | 5921 | $stack = array(); |
5580 | 5922 | $expected = array(); |
@@ -5590,43 +5932,38 @@ discard block |
||
5590 | 5932 | while($state != 1) |
5591 | 5933 | { |
5592 | 5934 | $type = isset($str[0]) ? $str[0] : ''; |
5593 | - if($type == '}') |
|
5594 | - $str = substr($str, 1); |
|
5595 | - |
|
5596 | - else if($type == 'N' && $str[1] == ';') |
|
5935 | + if($type == '}') { |
|
5936 | + $str = substr($str, 1); |
|
5937 | + } else if($type == 'N' && $str[1] == ';') |
|
5597 | 5938 | { |
5598 | 5939 | $value = null; |
5599 | 5940 | $str = substr($str, 2); |
5600 | - } |
|
5601 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5941 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5602 | 5942 | { |
5603 | 5943 | $value = $matches[1] == '1' ? true : false; |
5604 | 5944 | $str = substr($str, 4); |
5605 | - } |
|
5606 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5945 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5607 | 5946 | { |
5608 | 5947 | $value = (int)$matches[1]; |
5609 | 5948 | $str = $matches[2]; |
5610 | - } |
|
5611 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5949 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5612 | 5950 | { |
5613 | 5951 | $value = (float)$matches[1]; |
5614 | 5952 | $str = $matches[3]; |
5615 | - } |
|
5616 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5953 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5617 | 5954 | { |
5618 | 5955 | $value = substr($matches[2], 0, (int)$matches[1]); |
5619 | 5956 | $str = substr($matches[2], (int)$matches[1] + 2); |
5620 | - } |
|
5621 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5957 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5622 | 5958 | { |
5623 | 5959 | $expectedLength = (int)$matches[1]; |
5624 | 5960 | $str = $matches[2]; |
5625 | 5961 | } |
5626 | 5962 | |
5627 | 5963 | // Object or unknown/malformed type. |
5628 | - else |
|
5629 | - return false; |
|
5964 | + else { |
|
5965 | + return false; |
|
5966 | + } |
|
5630 | 5967 | |
5631 | 5968 | switch($state) |
5632 | 5969 | { |
@@ -5654,8 +5991,9 @@ discard block |
||
5654 | 5991 | if($type == '}') |
5655 | 5992 | { |
5656 | 5993 | // Array size is less than expected. |
5657 | - if(count($list) < end($expected)) |
|
5658 | - return false; |
|
5994 | + if(count($list) < end($expected)) { |
|
5995 | + return false; |
|
5996 | + } |
|
5659 | 5997 | |
5660 | 5998 | unset($list); |
5661 | 5999 | $list = &$stack[count($stack)-1]; |
@@ -5664,8 +6002,9 @@ discard block |
||
5664 | 6002 | // Go to terminal state if we're at the end of the root array. |
5665 | 6003 | array_pop($expected); |
5666 | 6004 | |
5667 | - if(count($expected) == 0) |
|
5668 | - $state = 1; |
|
6005 | + if(count($expected) == 0) { |
|
6006 | + $state = 1; |
|
6007 | + } |
|
5669 | 6008 | |
5670 | 6009 | break; |
5671 | 6010 | } |
@@ -5673,8 +6012,9 @@ discard block |
||
5673 | 6012 | if($type == 'i' || $type == 's') |
5674 | 6013 | { |
5675 | 6014 | // Array size exceeds expected length. |
5676 | - if(count($list) >= end($expected)) |
|
5677 | - return false; |
|
6015 | + if(count($list) >= end($expected)) { |
|
6016 | + return false; |
|
6017 | + } |
|
5678 | 6018 | |
5679 | 6019 | $key = $value; |
5680 | 6020 | $state = 3; |
@@ -5708,8 +6048,9 @@ discard block |
||
5708 | 6048 | } |
5709 | 6049 | |
5710 | 6050 | // Trailing data in input. |
5711 | - if(!empty($str)) |
|
5712 | - return false; |
|
6051 | + if(!empty($str)) { |
|
6052 | + return false; |
|
6053 | + } |
|
5713 | 6054 | |
5714 | 6055 | return $data; |
5715 | 6056 | } |
@@ -5732,8 +6073,9 @@ discard block |
||
5732 | 6073 | |
5733 | 6074 | $out = _safe_unserialize($str); |
5734 | 6075 | |
5735 | - if (isset($mbIntEnc)) |
|
5736 | - mb_internal_encoding($mbIntEnc); |
|
6076 | + if (isset($mbIntEnc)) { |
|
6077 | + mb_internal_encoding($mbIntEnc); |
|
6078 | + } |
|
5737 | 6079 | |
5738 | 6080 | return $out; |
5739 | 6081 | } |
@@ -5748,12 +6090,14 @@ discard block |
||
5748 | 6090 | function smf_chmod($file, $value = 0) |
5749 | 6091 | { |
5750 | 6092 | // No file? no checks! |
5751 | - if (empty($file)) |
|
5752 | - return false; |
|
6093 | + if (empty($file)) { |
|
6094 | + return false; |
|
6095 | + } |
|
5753 | 6096 | |
5754 | 6097 | // Already writable? |
5755 | - if (is_writable($file)) |
|
5756 | - return true; |
|
6098 | + if (is_writable($file)) { |
|
6099 | + return true; |
|
6100 | + } |
|
5757 | 6101 | |
5758 | 6102 | // Do we have a file or a dir? |
5759 | 6103 | $isDir = is_dir($file); |
@@ -5769,10 +6113,9 @@ discard block |
||
5769 | 6113 | { |
5770 | 6114 | $isWritable = true; |
5771 | 6115 | break; |
6116 | + } else { |
|
6117 | + @chmod($file, $val); |
|
5772 | 6118 | } |
5773 | - |
|
5774 | - else |
|
5775 | - @chmod($file, $val); |
|
5776 | 6119 | } |
5777 | 6120 | |
5778 | 6121 | return $isWritable; |
@@ -5791,8 +6134,9 @@ discard block |
||
5791 | 6134 | global $txt; |
5792 | 6135 | |
5793 | 6136 | // Come on... |
5794 | - if (empty($json) || !is_string($json)) |
|
5795 | - return array(); |
|
6137 | + if (empty($json) || !is_string($json)) { |
|
6138 | + return array(); |
|
6139 | + } |
|
5796 | 6140 | |
5797 | 6141 | $returnArray = @json_decode($json, $returnAsArray); |
5798 | 6142 | |
@@ -5830,11 +6174,11 @@ discard block |
||
5830 | 6174 | $jsonDebug = $jsonDebug[0]; |
5831 | 6175 | loadLanguage('Errors'); |
5832 | 6176 | |
5833 | - if (!empty($jsonDebug)) |
|
5834 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5835 | - |
|
5836 | - else |
|
5837 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
6177 | + if (!empty($jsonDebug)) { |
|
6178 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
6179 | + } else { |
|
6180 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
6181 | + } |
|
5838 | 6182 | |
5839 | 6183 | // Everyone expects an array. |
5840 | 6184 | return array(); |
@@ -5868,8 +6212,9 @@ discard block |
||
5868 | 6212 | global $db_show_debug, $modSettings; |
5869 | 6213 | |
5870 | 6214 | // Defensive programming anyone? |
5871 | - if (empty($data)) |
|
5872 | - return false; |
|
6215 | + if (empty($data)) { |
|
6216 | + return false; |
|
6217 | + } |
|
5873 | 6218 | |
5874 | 6219 | // Don't need extra stuff... |
5875 | 6220 | $db_show_debug = false; |
@@ -5877,11 +6222,11 @@ discard block |
||
5877 | 6222 | // Kill anything else. |
5878 | 6223 | ob_end_clean(); |
5879 | 6224 | |
5880 | - if (!empty($modSettings['CompressedOutput'])) |
|
5881 | - @ob_start('ob_gzhandler'); |
|
5882 | - |
|
5883 | - else |
|
5884 | - ob_start(); |
|
6225 | + if (!empty($modSettings['CompressedOutput'])) { |
|
6226 | + @ob_start('ob_gzhandler'); |
|
6227 | + } else { |
|
6228 | + ob_start(); |
|
6229 | + } |
|
5885 | 6230 | |
5886 | 6231 | // Set the header. |
5887 | 6232 | header($type); |
@@ -5913,8 +6258,9 @@ discard block |
||
5913 | 6258 | static $done = false; |
5914 | 6259 | |
5915 | 6260 | // If we don't need to do anything, don't |
5916 | - if (!$update && $done) |
|
5917 | - return; |
|
6261 | + if (!$update && $done) { |
|
6262 | + return; |
|
6263 | + } |
|
5918 | 6264 | |
5919 | 6265 | // Should we get a new copy of the official list of TLDs? |
5920 | 6266 | if ($update) |
@@ -5922,8 +6268,9 @@ discard block |
||
5922 | 6268 | $tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt'); |
5923 | 6269 | |
5924 | 6270 | // 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. |
5925 | - if ($tlds === false) |
|
5926 | - $postapocalypticNightmare = true; |
|
6271 | + if ($tlds === false) { |
|
6272 | + $postapocalypticNightmare = true; |
|
6273 | + } |
|
5927 | 6274 | } |
5928 | 6275 | // If we aren't updating and the regex is valid, we're done |
5929 | 6276 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5938,10 +6285,11 @@ discard block |
||
5938 | 6285 | // Clean $tlds and convert it to an array |
5939 | 6286 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
5940 | 6287 | $line = trim($line); |
5941 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
5942 | - return false; |
|
5943 | - else |
|
5944 | - return true; |
|
6288 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
6289 | + return false; |
|
6290 | + } else { |
|
6291 | + return true; |
|
6292 | + } |
|
5945 | 6293 | }); |
5946 | 6294 | |
5947 | 6295 | // Convert Punycode to Unicode |
@@ -5995,8 +6343,9 @@ discard block |
||
5995 | 6343 | $idx += $digit * $w; |
5996 | 6344 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
5997 | 6345 | |
5998 | - if ($digit < $t) |
|
5999 | - break; |
|
6346 | + if ($digit < $t) { |
|
6347 | + break; |
|
6348 | + } |
|
6000 | 6349 | |
6001 | 6350 | $w = (int) ($w * ($base - $t)); |
6002 | 6351 | } |
@@ -6005,8 +6354,9 @@ discard block |
||
6005 | 6354 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
6006 | 6355 | $delta += intval($delta / ($deco_len + 1)); |
6007 | 6356 | |
6008 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
6009 | - $delta = intval($delta / ($base - $tmin)); |
|
6357 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
6358 | + $delta = intval($delta / ($base - $tmin)); |
|
6359 | + } |
|
6010 | 6360 | |
6011 | 6361 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
6012 | 6362 | $is_first = false; |
@@ -6015,8 +6365,9 @@ discard block |
||
6015 | 6365 | |
6016 | 6366 | if ($deco_len > 0) |
6017 | 6367 | { |
6018 | - for ($i = $deco_len; $i > $idx; $i--) |
|
6019 | - $decoded[$i] = $decoded[($i - 1)]; |
|
6368 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
6369 | + $decoded[$i] = $decoded[($i - 1)]; |
|
6370 | + } |
|
6020 | 6371 | } |
6021 | 6372 | $decoded[$idx++] = $char; |
6022 | 6373 | } |
@@ -6024,24 +6375,29 @@ discard block |
||
6024 | 6375 | foreach ($decoded as $k => $v) |
6025 | 6376 | { |
6026 | 6377 | // 7bit are transferred literally |
6027 | - if ($v < 128) |
|
6028 | - $output .= chr($v); |
|
6378 | + if ($v < 128) { |
|
6379 | + $output .= chr($v); |
|
6380 | + } |
|
6029 | 6381 | |
6030 | 6382 | // 2 bytes |
6031 | - elseif ($v < (1 << 11)) |
|
6032 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6383 | + elseif ($v < (1 << 11)) { |
|
6384 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6385 | + } |
|
6033 | 6386 | |
6034 | 6387 | // 3 bytes |
6035 | - elseif ($v < (1 << 16)) |
|
6036 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6388 | + elseif ($v < (1 << 16)) { |
|
6389 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6390 | + } |
|
6037 | 6391 | |
6038 | 6392 | // 4 bytes |
6039 | - elseif ($v < (1 << 21)) |
|
6040 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6393 | + elseif ($v < (1 << 21)) { |
|
6394 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6395 | + } |
|
6041 | 6396 | |
6042 | 6397 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
6043 | - else |
|
6044 | - $output .= $safe_char; |
|
6398 | + else { |
|
6399 | + $output .= $safe_char; |
|
6400 | + } |
|
6045 | 6401 | } |
6046 | 6402 | |
6047 | 6403 | $output_parts[] = $output; |
@@ -6134,8 +6490,7 @@ discard block |
||
6134 | 6490 | |
6135 | 6491 | $strlen = 'mb_strlen'; |
6136 | 6492 | $substr = 'mb_substr'; |
6137 | - } |
|
6138 | - else |
|
6493 | + } else |
|
6139 | 6494 | { |
6140 | 6495 | $strlen = $smcFunc['strlen']; |
6141 | 6496 | $substr = $smcFunc['substr']; |
@@ -6149,20 +6504,21 @@ discard block |
||
6149 | 6504 | |
6150 | 6505 | $first = $substr($string, 0, 1); |
6151 | 6506 | |
6152 | - if (empty($index[$first])) |
|
6153 | - $index[$first] = array(); |
|
6507 | + if (empty($index[$first])) { |
|
6508 | + $index[$first] = array(); |
|
6509 | + } |
|
6154 | 6510 | |
6155 | 6511 | if ($strlen($string) > 1) |
6156 | 6512 | { |
6157 | 6513 | // Sanity check on recursion |
6158 | - if ($depth > 99) |
|
6159 | - $index[$first][$substr($string, 1)] = ''; |
|
6160 | - |
|
6161 | - else |
|
6162 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6514 | + if ($depth > 99) { |
|
6515 | + $index[$first][$substr($string, 1)] = ''; |
|
6516 | + } else { |
|
6517 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6518 | + } |
|
6519 | + } else { |
|
6520 | + $index[$first][''] = ''; |
|
6163 | 6521 | } |
6164 | - else |
|
6165 | - $index[$first][''] = ''; |
|
6166 | 6522 | |
6167 | 6523 | $depth--; |
6168 | 6524 | return $index; |
@@ -6185,9 +6541,9 @@ discard block |
||
6185 | 6541 | $key_regex = preg_quote($key, $delim); |
6186 | 6542 | $new_key = $key; |
6187 | 6543 | |
6188 | - if (empty($value)) |
|
6189 | - $sub_regex = ''; |
|
6190 | - else |
|
6544 | + if (empty($value)) { |
|
6545 | + $sub_regex = ''; |
|
6546 | + } else |
|
6191 | 6547 | { |
6192 | 6548 | $sub_regex = $index_to_regex($value, $delim); |
6193 | 6549 | |
@@ -6195,22 +6551,22 @@ discard block |
||
6195 | 6551 | { |
6196 | 6552 | $new_key_array = explode('(?'.'>', $sub_regex); |
6197 | 6553 | $new_key .= $new_key_array[0]; |
6554 | + } else { |
|
6555 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6198 | 6556 | } |
6199 | - else |
|
6200 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6201 | 6557 | } |
6202 | 6558 | |
6203 | - if ($depth > 1) |
|
6204 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
6205 | - else |
|
6559 | + if ($depth > 1) { |
|
6560 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6561 | + } else |
|
6206 | 6562 | { |
6207 | 6563 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
6208 | 6564 | { |
6209 | 6565 | $regex[$new_key] = $key_regex . $sub_regex; |
6210 | 6566 | unset($index[$key]); |
6567 | + } else { |
|
6568 | + break; |
|
6211 | 6569 | } |
6212 | - else |
|
6213 | - break; |
|
6214 | 6570 | } |
6215 | 6571 | } |
6216 | 6572 | |
@@ -6219,10 +6575,11 @@ discard block |
||
6219 | 6575 | $l1 = $strlen($k1); |
6220 | 6576 | $l2 = $strlen($k2); |
6221 | 6577 | |
6222 | - if ($l1 == $l2) |
|
6223 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6224 | - else |
|
6225 | - return $l1 > $l2 ? -1 : 1; |
|
6578 | + if ($l1 == $l2) { |
|
6579 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6580 | + } else { |
|
6581 | + return $l1 > $l2 ? -1 : 1; |
|
6582 | + } |
|
6226 | 6583 | }); |
6227 | 6584 | |
6228 | 6585 | $depth--; |
@@ -6233,21 +6590,24 @@ discard block |
||
6233 | 6590 | $index = array(); |
6234 | 6591 | $regex = ''; |
6235 | 6592 | |
6236 | - foreach ($strings as $string) |
|
6237 | - $index = $add_string_to_index($string, $index); |
|
6593 | + foreach ($strings as $string) { |
|
6594 | + $index = $add_string_to_index($string, $index); |
|
6595 | + } |
|
6238 | 6596 | |
6239 | 6597 | if ($returnArray === true) |
6240 | 6598 | { |
6241 | 6599 | $regex = array(); |
6242 | - while (!empty($index)) |
|
6243 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6600 | + while (!empty($index)) { |
|
6601 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6602 | + } |
|
6603 | + } else { |
|
6604 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6244 | 6605 | } |
6245 | - else |
|
6246 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6247 | 6606 | |
6248 | 6607 | // Restore PHP's internal character encoding to whatever it was originally |
6249 | - if (!empty($current_encoding)) |
|
6250 | - mb_internal_encoding($current_encoding); |
|
6608 | + if (!empty($current_encoding)) { |
|
6609 | + mb_internal_encoding($current_encoding); |
|
6610 | + } |
|
6251 | 6611 | |
6252 | 6612 | return $regex; |
6253 | 6613 | } |
@@ -6290,13 +6650,15 @@ discard block |
||
6290 | 6650 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
6291 | 6651 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
6292 | 6652 | $headers = @get_headers($url); |
6293 | - if ($headers === false) |
|
6294 | - return false; |
|
6653 | + if ($headers === false) { |
|
6654 | + return false; |
|
6655 | + } |
|
6295 | 6656 | |
6296 | 6657 | // Now to see if it came back https... |
6297 | 6658 | // First check for a redirect status code in first row (301, 302, 307) |
6298 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
6299 | - return false; |
|
6659 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
6660 | + return false; |
|
6661 | + } |
|
6300 | 6662 | |
6301 | 6663 | // Search for the location entry to confirm https |
6302 | 6664 | $result = false; |
@@ -6332,8 +6694,7 @@ discard block |
||
6332 | 6694 | $is_admin = $user_info['is_admin']; |
6333 | 6695 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
6334 | 6696 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
6335 | - } |
|
6336 | - else |
|
6697 | + } else |
|
6337 | 6698 | { |
6338 | 6699 | $request = $smcFunc['db_query']('', ' |
6339 | 6700 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6347,17 +6708,19 @@ discard block |
||
6347 | 6708 | |
6348 | 6709 | $row = $smcFunc['db_fetch_assoc']($request); |
6349 | 6710 | |
6350 | - if (empty($row['additional_groups'])) |
|
6351 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
6352 | - else |
|
6353 | - $groups = array_merge( |
|
6711 | + if (empty($row['additional_groups'])) { |
|
6712 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
6713 | + } else { |
|
6714 | + $groups = array_merge( |
|
6354 | 6715 | array($row['id_group'], $row['id_post_group']), |
6355 | 6716 | explode(',', $row['additional_groups']) |
6356 | 6717 | ); |
6718 | + } |
|
6357 | 6719 | |
6358 | 6720 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
6359 | - foreach ($groups as $k => $v) |
|
6360 | - $groups[$k] = (int) $v; |
|
6721 | + foreach ($groups as $k => $v) { |
|
6722 | + $groups[$k] = (int) $v; |
|
6723 | + } |
|
6361 | 6724 | |
6362 | 6725 | $is_admin = in_array(1, $groups); |
6363 | 6726 | |
@@ -6374,8 +6737,9 @@ discard block |
||
6374 | 6737 | 'current_member' => $userid, |
6375 | 6738 | ) |
6376 | 6739 | ); |
6377 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6378 | - $boards_mod[] = $row['id_board']; |
|
6740 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6741 | + $boards_mod[] = $row['id_board']; |
|
6742 | + } |
|
6379 | 6743 | $smcFunc['db_free_result']($request); |
6380 | 6744 | |
6381 | 6745 | // Can any of the groups they're in moderate any of the boards? |
@@ -6387,8 +6751,9 @@ discard block |
||
6387 | 6751 | 'groups' => $groups, |
6388 | 6752 | ) |
6389 | 6753 | ); |
6390 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6391 | - $boards_mod[] = $row['id_board']; |
|
6754 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6755 | + $boards_mod[] = $row['id_board']; |
|
6756 | + } |
|
6392 | 6757 | $smcFunc['db_free_result']($request); |
6393 | 6758 | |
6394 | 6759 | // Just in case we've got duplicates here... |
@@ -6398,21 +6763,25 @@ discard block |
||
6398 | 6763 | } |
6399 | 6764 | |
6400 | 6765 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
6401 | - if ($is_admin) |
|
6402 | - $query_part['query_see_board'] = '1=1'; |
|
6766 | + if ($is_admin) { |
|
6767 | + $query_part['query_see_board'] = '1=1'; |
|
6768 | + } |
|
6403 | 6769 | // Otherwise just the groups in $user_info['groups']. |
6404 | - else |
|
6405 | - $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'] : '') . ')'; |
|
6770 | + else { |
|
6771 | + $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'] : '') . ')'; |
|
6772 | + } |
|
6406 | 6773 | |
6407 | 6774 | // Build the list of boards they WANT to see. |
6408 | 6775 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
6409 | 6776 | |
6410 | 6777 | // If they aren't ignoring any boards then they want to see all the boards they can see |
6411 | - if (empty($ignoreboards)) |
|
6412 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6778 | + if (empty($ignoreboards)) { |
|
6779 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6780 | + } |
|
6413 | 6781 | // Ok I guess they don't want to see all the boards |
6414 | - else |
|
6415 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6782 | + else { |
|
6783 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6784 | + } |
|
6416 | 6785 | |
6417 | 6786 | return $query_part; |
6418 | 6787 | } |
@@ -6426,10 +6795,11 @@ discard block |
||
6426 | 6795 | { |
6427 | 6796 | $secure = false; |
6428 | 6797 | |
6429 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
6430 | - $secure = true; |
|
6431 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
6432 | - $secure = true; |
|
6798 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
6799 | + $secure = true; |
|
6800 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
6801 | + $secure = true; |
|
6802 | + } |
|
6433 | 6803 | |
6434 | 6804 | return $secure; |
6435 | 6805 | } |
@@ -28,14 +28,15 @@ discard block |
||
28 | 28 | <div id="confirm_buttons">'; |
29 | 29 | |
30 | 30 | // Age restriction in effect? |
31 | - if ($context['show_coppa']) |
|
32 | - echo ' |
|
31 | + if ($context['show_coppa']) { |
|
32 | + echo ' |
|
33 | 33 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
34 | 34 | <br> |
35 | 35 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
36 | - else |
|
37 | - echo ' |
|
36 | + } else { |
|
37 | + echo ' |
|
38 | 38 | <input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">'; |
39 | + } |
|
39 | 40 | |
40 | 41 | echo ' |
41 | 42 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -78,9 +79,10 @@ discard block |
||
78 | 79 | <ul>'; |
79 | 80 | |
80 | 81 | // Cycle through each error and display an error message. |
81 | - foreach ($context['registration_errors'] as $error) |
|
82 | - echo ' |
|
82 | + foreach ($context['registration_errors'] as $error) { |
|
83 | + echo ' |
|
83 | 84 | <li>', $error, '</li>'; |
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </ul> |
@@ -149,14 +151,15 @@ discard block |
||
149 | 151 | echo ' |
150 | 152 | <dl class="register_form">'; |
151 | 153 | |
152 | - foreach ($context['custom_fields'] as $field) |
|
153 | - if ($field['show_reg'] > 1) |
|
154 | + foreach ($context['custom_fields'] as $field) { |
|
155 | + if ($field['show_reg'] > 1) |
|
154 | 156 | echo ' |
155 | 157 | <dt> |
156 | 158 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
157 | 159 | <span class="smalltext">', $field['desc'], '</span> |
158 | 160 | </dt> |
159 | 161 | <dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>'; |
162 | + } |
|
160 | 163 | |
161 | 164 | echo ' |
162 | 165 | </dl>'; |
@@ -167,14 +170,15 @@ discard block |
||
167 | 170 | </div><!-- .roundframe -->'; |
168 | 171 | |
169 | 172 | // If we have either of these, show the extra group. |
170 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
171 | - echo ' |
|
173 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
174 | + echo ' |
|
172 | 175 | <div class="title_bar title_top"> |
173 | 176 | <h3 class="titlebg">', $txt['additional_information'], '</h3> |
174 | 177 | </div> |
175 | 178 | <div class="roundframe noup"> |
176 | 179 | <fieldset> |
177 | 180 | <dl class="register_form" id="custom_group">'; |
181 | + } |
|
178 | 182 | |
179 | 183 | if (!empty($context['profile_fields'])) |
180 | 184 | { |
@@ -188,41 +192,45 @@ discard block |
||
188 | 192 | $callback_func = 'template_profile_' . $field['callback_func']; |
189 | 193 | $callback_func(); |
190 | 194 | } |
191 | - } |
|
192 | - else |
|
195 | + } else |
|
193 | 196 | { |
194 | 197 | echo ' |
195 | 198 | <dt> |
196 | 199 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>'; |
197 | 200 | |
198 | 201 | // Does it have any subtext to show? |
199 | - if (!empty($field['subtext'])) |
|
200 | - echo ' |
|
202 | + if (!empty($field['subtext'])) { |
|
203 | + echo ' |
|
201 | 204 | <span class="smalltext">', $field['subtext'], '</span>'; |
205 | + } |
|
202 | 206 | |
203 | 207 | echo ' |
204 | 208 | </dt> |
205 | 209 | <dd>'; |
206 | 210 | |
207 | 211 | // Want to put something infront of the box? |
208 | - if (!empty($field['preinput'])) |
|
209 | - echo ' |
|
212 | + if (!empty($field['preinput'])) { |
|
213 | + echo ' |
|
210 | 214 | ', $field['preinput']; |
215 | + } |
|
211 | 216 | |
212 | 217 | // What type of data are we showing? |
213 | - if ($field['type'] == 'label') |
|
214 | - echo ' |
|
218 | + if ($field['type'] == 'label') { |
|
219 | + echo ' |
|
215 | 220 | ', $field['value']; |
221 | + } |
|
216 | 222 | |
217 | 223 | // Maybe it's a text box - very likely! |
218 | - elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) |
|
219 | - echo ' |
|
224 | + elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) { |
|
225 | + echo ' |
|
220 | 226 | <input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
227 | + } |
|
221 | 228 | |
222 | 229 | // You "checking" me out? ;) |
223 | - elseif ($field['type'] == 'check') |
|
224 | - echo ' |
|
230 | + elseif ($field['type'] == 'check') { |
|
231 | + echo ' |
|
225 | 232 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
233 | + } |
|
226 | 234 | |
227 | 235 | // Always fun - select boxes! |
228 | 236 | elseif ($field['type'] == 'select') |
@@ -233,14 +241,16 @@ discard block |
||
233 | 241 | if (isset($field['options'])) |
234 | 242 | { |
235 | 243 | // Is this some code to generate the options? |
236 | - if (!is_array($field['options'])) |
|
237 | - $field['options'] = eval($field['options']); |
|
244 | + if (!is_array($field['options'])) { |
|
245 | + $field['options'] = eval($field['options']); |
|
246 | + } |
|
238 | 247 | |
239 | 248 | // Assuming we now have some! |
240 | - if (is_array($field['options'])) |
|
241 | - foreach ($field['options'] as $value => $name) |
|
249 | + if (is_array($field['options'])) { |
|
250 | + foreach ($field['options'] as $value => $name) |
|
242 | 251 | echo ' |
243 | 252 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
253 | + } |
|
244 | 254 | } |
245 | 255 | |
246 | 256 | echo ' |
@@ -248,9 +258,10 @@ discard block |
||
248 | 258 | } |
249 | 259 | |
250 | 260 | // Something to end with? |
251 | - if (!empty($field['postinput'])) |
|
252 | - echo ' |
|
261 | + if (!empty($field['postinput'])) { |
|
262 | + echo ' |
|
253 | 263 | ', $field['postinput']; |
264 | + } |
|
254 | 265 | |
255 | 266 | echo ' |
256 | 267 | </dd>'; |
@@ -261,25 +272,27 @@ discard block |
||
261 | 272 | // Are there any custom fields? |
262 | 273 | if (!empty($context['custom_fields'])) |
263 | 274 | { |
264 | - foreach ($context['custom_fields'] as $field) |
|
265 | - if ($field['show_reg'] < 2) |
|
275 | + foreach ($context['custom_fields'] as $field) { |
|
276 | + if ($field['show_reg'] < 2) |
|
266 | 277 | echo ' |
267 | 278 | <dt> |
268 | 279 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
269 | 280 | <span class="smalltext">', $field['desc'], '</span> |
270 | 281 | </dt> |
271 | 282 | <dd>', $field['input_html'], '</dd>'; |
283 | + } |
|
272 | 284 | } |
273 | 285 | |
274 | 286 | // If we have either of these, close the list like a proper gent. |
275 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
276 | - echo ' |
|
287 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
288 | + echo ' |
|
277 | 289 | </dl> |
278 | 290 | </fieldset> |
279 | 291 | </div><!-- .roundframe -->'; |
292 | + } |
|
280 | 293 | |
281 | - if ($context['visual_verification']) |
|
282 | - echo ' |
|
294 | + if ($context['visual_verification']) { |
|
295 | + echo ' |
|
283 | 296 | <div class="title_bar title_top"> |
284 | 297 | <h3 class="titlebg">', $txt['verification'], '</h3> |
285 | 298 | </div> |
@@ -288,19 +301,21 @@ discard block |
||
288 | 301 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
289 | 302 | </fieldset> |
290 | 303 | </div>'; |
304 | + } |
|
291 | 305 | |
292 | 306 | echo ' |
293 | 307 | <div id="confirm_buttons" class="flow_auto">'; |
294 | 308 | |
295 | 309 | // Age restriction in effect? |
296 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
297 | - echo ' |
|
310 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
311 | + echo ' |
|
298 | 312 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
299 | 313 | <br> |
300 | 314 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
301 | - else |
|
302 | - echo ' |
|
315 | + } else { |
|
316 | + echo ' |
|
303 | 317 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
318 | + } |
|
304 | 319 | |
305 | 320 | echo ' |
306 | 321 | </div> |
@@ -362,25 +377,28 @@ discard block |
||
362 | 377 | <p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>'; |
363 | 378 | |
364 | 379 | // Can they send by post? |
365 | - if (!empty($context['coppa']['post'])) |
|
366 | - echo ' |
|
380 | + if (!empty($context['coppa']['post'])) { |
|
381 | + echo ' |
|
367 | 382 | <h4>1) ', $txt['coppa_send_by_post'], '</h4> |
368 | 383 | <div class="coppa_contact"> |
369 | 384 | ', $context['coppa']['post'], ' |
370 | 385 | </div>'; |
386 | + } |
|
371 | 387 | |
372 | 388 | // Can they send by fax?? |
373 | - if (!empty($context['coppa']['fax'])) |
|
374 | - echo ' |
|
389 | + if (!empty($context['coppa']['fax'])) { |
|
390 | + echo ' |
|
375 | 391 | <h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4> |
376 | 392 | <div class="coppa_contact"> |
377 | 393 | ', $context['coppa']['fax'], ' |
378 | 394 | </div>'; |
395 | + } |
|
379 | 396 | |
380 | 397 | // Offer an alternative Phone Number? |
381 | - if ($context['coppa']['phone']) |
|
382 | - echo ' |
|
398 | + if ($context['coppa']['phone']) { |
|
399 | + echo ' |
|
383 | 400 | <p>', $context['coppa']['phone'], '</p>'; |
401 | + } |
|
384 | 402 | |
385 | 403 | echo ' |
386 | 404 | </div><!-- #coppa -->'; |
@@ -445,19 +463,20 @@ discard block |
||
445 | 463 | <body style="margin: 1ex;"> |
446 | 464 | <div class="windowbg description" style="text-align: center;">'; |
447 | 465 | |
448 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
449 | - echo ' |
|
466 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
467 | + echo ' |
|
450 | 468 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
451 | 469 | <param name="AutoStart" value="1"> |
452 | 470 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
453 | 471 | </object>'; |
454 | - else |
|
455 | - echo ' |
|
472 | + } else { |
|
473 | + echo ' |
|
456 | 474 | <audio src="', $context['verification_sound_href'], '" controls> |
457 | 475 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
458 | 476 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
459 | 477 | </object> |
460 | 478 | </audio>'; |
479 | + } |
|
461 | 480 | |
462 | 481 | echo ' |
463 | 482 | <br> |
@@ -485,11 +504,12 @@ discard block |
||
485 | 504 | </div> |
486 | 505 | <div id="register_screen" class="windowbg2 noup">'; |
487 | 506 | |
488 | - if (!empty($context['registration_done'])) |
|
489 | - echo ' |
|
507 | + if (!empty($context['registration_done'])) { |
|
508 | + echo ' |
|
490 | 509 | <div class="infobox"> |
491 | 510 | ', $context['registration_done'], ' |
492 | 511 | </div>'; |
512 | + } |
|
493 | 513 | |
494 | 514 | echo ' |
495 | 515 | <dl class="register_form" id="admin_register_form"> |
@@ -525,9 +545,10 @@ discard block |
||
525 | 545 | <dd> |
526 | 546 | <select name="group" id="group_select" tabindex="', $context['tabindex']++, '">'; |
527 | 547 | |
528 | - foreach ($context['member_groups'] as $id => $name) |
|
529 | - echo ' |
|
548 | + foreach ($context['member_groups'] as $id => $name) { |
|
549 | + echo ' |
|
530 | 550 | <option value="', $id, '">', $name, '</option>'; |
551 | + } |
|
531 | 552 | |
532 | 553 | echo ' |
533 | 554 | </select> |
@@ -535,8 +556,8 @@ discard block |
||
535 | 556 | } |
536 | 557 | |
537 | 558 | // If there is any field marked as required, show it here! |
538 | - if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) |
|
539 | - foreach ($context['custom_fields'] as $field) |
|
559 | + if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) { |
|
560 | + foreach ($context['custom_fields'] as $field) |
|
540 | 561 | if ($field['show_reg'] > 1) |
541 | 562 | echo ' |
542 | 563 | <dt> |
@@ -546,6 +567,7 @@ discard block |
||
546 | 567 | <dd> |
547 | 568 | ', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), ' |
548 | 569 | </dd>'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | <dt> |
@@ -582,13 +604,13 @@ discard block |
||
582 | 604 | { |
583 | 605 | global $context, $scripturl, $txt; |
584 | 606 | |
585 | - if (!empty($context['saved_successful'])) |
|
586 | - echo ' |
|
607 | + if (!empty($context['saved_successful'])) { |
|
608 | + echo ' |
|
587 | 609 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
588 | - |
|
589 | - elseif (!empty($context['could_not_save'])) |
|
590 | - echo ' |
|
610 | + } elseif (!empty($context['could_not_save'])) { |
|
611 | + echo ' |
|
591 | 612 | <div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>'; |
613 | + } |
|
592 | 614 | |
593 | 615 | // Just a big box to edit the text file ;) |
594 | 616 | echo ' |
@@ -598,9 +620,10 @@ discard block |
||
598 | 620 | </div>'; |
599 | 621 | |
600 | 622 | // Warning for if the file isn't writable. |
601 | - if (!empty($context['warning'])) |
|
602 | - echo ' |
|
623 | + if (!empty($context['warning'])) { |
|
624 | + echo ' |
|
603 | 625 | <p class="error">', $context['warning'], '</p>'; |
626 | + } |
|
604 | 627 | |
605 | 628 | echo ' |
606 | 629 | <div class="windowbg2 noup" id="registration_agreement">'; |
@@ -617,9 +640,10 @@ discard block |
||
617 | 640 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
618 | 641 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
619 | 642 | |
620 | - foreach ($context['editable_agreements'] as $file => $name) |
|
621 | - echo ' |
|
643 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
644 | + echo ' |
|
622 | 645 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
646 | + } |
|
623 | 647 | |
624 | 648 | echo ' |
625 | 649 | </select> |
@@ -659,9 +683,10 @@ discard block |
||
659 | 683 | { |
660 | 684 | global $context, $scripturl, $txt; |
661 | 685 | |
662 | - if (!empty($context['saved_successful'])) |
|
663 | - echo ' |
|
686 | + if (!empty($context['saved_successful'])) { |
|
687 | + echo ' |
|
664 | 688 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
689 | + } |
|
665 | 690 | |
666 | 691 | echo ' |
667 | 692 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -20,17 +20,19 @@ discard block |
||
20 | 20 | echo ' |
21 | 21 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">'; |
22 | 22 | |
23 | - if (!empty($context['search_errors'])) |
|
24 | - echo ' |
|
23 | + if (!empty($context['search_errors'])) { |
|
24 | + echo ' |
|
25 | 25 | <div class="errorbox"> |
26 | 26 | ', implode('<br>', $context['search_errors']['messages']), ' |
27 | 27 | </div>'; |
28 | + } |
|
28 | 29 | |
29 | - if (!empty($context['search_ignored'])) |
|
30 | - echo ' |
|
30 | + if (!empty($context['search_ignored'])) { |
|
31 | + echo ' |
|
31 | 32 | <div class="noticebox"> |
32 | 33 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
33 | 34 | </div>'; |
35 | + } |
|
34 | 36 | |
35 | 37 | echo ' |
36 | 38 | <div class="cat_bar"> |
@@ -48,9 +50,10 @@ discard block |
||
48 | 50 | <dd> |
49 | 51 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
50 | 52 | |
51 | - if (empty($modSettings['search_simple_fulltext'])) |
|
52 | - echo ' |
|
53 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
54 | + echo ' |
|
53 | 55 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
56 | + } |
|
54 | 57 | |
55 | 58 | echo ' |
56 | 59 | </dd> |
@@ -114,21 +117,23 @@ discard block |
||
114 | 117 | <input type="hidden" name="advanced" value="1">'; |
115 | 118 | |
116 | 119 | // Require an image to be typed to save spamming? |
117 | - if ($context['require_verification']) |
|
118 | - echo ' |
|
120 | + if ($context['require_verification']) { |
|
121 | + echo ' |
|
119 | 122 | <p> |
120 | 123 | <strong>', $txt['verification'], ':</strong> |
121 | 124 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
122 | 125 | </p>'; |
126 | + } |
|
123 | 127 | |
124 | 128 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
125 | - if (!empty($context['search_params']['topic'])) |
|
126 | - echo ' |
|
129 | + if (!empty($context['search_params']['topic'])) { |
|
130 | + echo ' |
|
127 | 131 | <p> |
128 | 132 | ', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '". |
129 | 133 | </p> |
130 | 134 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
131 | 135 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
136 | + } |
|
132 | 137 | |
133 | 138 | echo ' |
134 | 139 | </div>'; |
@@ -158,14 +163,15 @@ discard block |
||
158 | 163 | |
159 | 164 | foreach ($category['boards'] as $board) |
160 | 165 | { |
161 | - if ($i == $limit) |
|
162 | - echo ' |
|
166 | + if ($i == $limit) { |
|
167 | + echo ' |
|
163 | 168 | </ul> |
164 | 169 | </li> |
165 | 170 | </ul> |
166 | 171 | <ul class="ignoreboards floatright"> |
167 | 172 | <li class="category"> |
168 | 173 | <ul>'; |
174 | + } |
|
169 | 175 | |
170 | 176 | echo ' |
171 | 177 | <li class="board"> |
@@ -253,17 +259,19 @@ discard block |
||
253 | 259 | <div class="roundframe noup">'; |
254 | 260 | |
255 | 261 | // Did they make any typos or mistakes, perhaps? |
256 | - if (isset($context['did_you_mean'])) |
|
257 | - echo ' |
|
262 | + if (isset($context['did_you_mean'])) { |
|
263 | + echo ' |
|
258 | 264 | <p> |
259 | 265 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
260 | 266 | </p>'; |
267 | + } |
|
261 | 268 | |
262 | - if (!empty($context['search_ignored'])) |
|
263 | - echo ' |
|
269 | + if (!empty($context['search_ignored'])) { |
|
270 | + echo ' |
|
264 | 271 | <p> |
265 | 272 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
266 | 273 | </p>'; |
274 | + } |
|
267 | 275 | |
268 | 276 | echo ' |
269 | 277 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -286,10 +294,11 @@ discard block |
||
286 | 294 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
287 | 295 | </div>'; |
288 | 296 | |
289 | - if (!empty($context['search_params']['brd'])) |
|
290 | - foreach ($context['search_params']['brd'] as $board_id) |
|
297 | + if (!empty($context['search_params']['brd'])) { |
|
298 | + foreach ($context['search_params']['brd'] as $board_id) |
|
291 | 299 | echo ' |
292 | 300 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
301 | + } |
|
293 | 302 | |
294 | 303 | echo ' |
295 | 304 | </form> |
@@ -300,18 +309,20 @@ discard block |
||
300 | 309 | if ($context['compact']) |
301 | 310 | { |
302 | 311 | // Quick moderation set to checkboxes? Oh, how fun :/ |
303 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
304 | - echo ' |
|
312 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
313 | + echo ' |
|
305 | 314 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
315 | + } |
|
306 | 316 | |
307 | 317 | echo ' |
308 | 318 | <div class="cat_bar"> |
309 | 319 | <h3 class="catbg"> |
310 | 320 | <span class="floatright">'; |
311 | 321 | |
312 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
313 | - echo ' |
|
322 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
323 | + echo ' |
|
314 | 324 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
325 | + } |
|
315 | 326 | echo ' |
316 | 327 | </span> |
317 | 328 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -319,15 +330,15 @@ discard block |
||
319 | 330 | </div>'; |
320 | 331 | |
321 | 332 | // Was anything even found? |
322 | - if (!empty($context['topics'])) |
|
323 | - echo ' |
|
333 | + if (!empty($context['topics'])) { |
|
334 | + echo ' |
|
324 | 335 | <div class="pagesection"> |
325 | 336 | <span>', $context['page_index'], '</span> |
326 | 337 | </div>'; |
327 | - |
|
328 | - else |
|
329 | - echo ' |
|
338 | + } else { |
|
339 | + echo ' |
|
330 | 340 | <div class="roundframe noup">', $txt['find_no_results'], '</div>'; |
341 | + } |
|
331 | 342 | |
332 | 343 | // While we have results to show ... |
333 | 344 | while ($topic = $context['get_topics']()) |
@@ -350,31 +361,35 @@ discard block |
||
350 | 361 | echo ' |
351 | 362 | <span class="floatright">'; |
352 | 363 | |
353 | - if ($options['display_quick_mod'] == 1) |
|
354 | - echo ' |
|
364 | + if ($options['display_quick_mod'] == 1) { |
|
365 | + echo ' |
|
355 | 366 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
356 | - |
|
357 | - else |
|
367 | + } else |
|
358 | 368 | { |
359 | - if ($topic['quick_mod']['remove']) |
|
360 | - echo ' |
|
369 | + if ($topic['quick_mod']['remove']) { |
|
370 | + echo ' |
|
361 | 371 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
372 | + } |
|
362 | 373 | |
363 | - if ($topic['quick_mod']['lock']) |
|
364 | - echo ' |
|
374 | + if ($topic['quick_mod']['lock']) { |
|
375 | + echo ' |
|
365 | 376 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
377 | + } |
|
366 | 378 | |
367 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
368 | - echo ' |
|
379 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
380 | + echo ' |
|
369 | 381 | <br>'; |
382 | + } |
|
370 | 383 | |
371 | - if ($topic['quick_mod']['sticky']) |
|
372 | - echo ' |
|
384 | + if ($topic['quick_mod']['sticky']) { |
|
385 | + echo ' |
|
373 | 386 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
387 | + } |
|
374 | 388 | |
375 | - if ($topic['quick_mod']['move']) |
|
376 | - echo ' |
|
389 | + if ($topic['quick_mod']['move']) { |
|
390 | + echo ' |
|
377 | 391 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
392 | + } |
|
378 | 393 | } |
379 | 394 | |
380 | 395 | echo ' |
@@ -384,20 +399,22 @@ discard block |
||
384 | 399 | echo ' |
385 | 400 | </div><!-- .block -->'; |
386 | 401 | |
387 | - if ($message['body_highlighted'] != '') |
|
388 | - echo ' |
|
402 | + if ($message['body_highlighted'] != '') { |
|
403 | + echo ' |
|
389 | 404 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
405 | + } |
|
390 | 406 | } |
391 | 407 | |
392 | 408 | echo ' |
393 | 409 | </div><!-- $topic[css_class] -->'; |
394 | 410 | |
395 | 411 | } |
396 | - if (!empty($context['topics'])) |
|
397 | - echo ' |
|
412 | + if (!empty($context['topics'])) { |
|
413 | + echo ' |
|
398 | 414 | <div class="pagesection"> |
399 | 415 | <span>', $context['page_index'], '</span> |
400 | 416 | </div>'; |
417 | + } |
|
401 | 418 | |
402 | 419 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
403 | 420 | { |
@@ -406,17 +423,19 @@ discard block |
||
406 | 423 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
407 | 424 | <option value="">--------</option>'; |
408 | 425 | |
409 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
410 | - if ($context['can_' . $qmod_action]) |
|
426 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
427 | + if ($context['can_' . $qmod_action]) |
|
411 | 428 | echo ' |
412 | 429 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
430 | + } |
|
413 | 431 | |
414 | 432 | echo ' |
415 | 433 | </select>'; |
416 | 434 | |
417 | - if ($context['can_move']) |
|
418 | - echo ' |
|
435 | + if ($context['can_move']) { |
|
436 | + echo ' |
|
419 | 437 | <span id="quick_mod_jump_to"></span>'; |
438 | + } |
|
420 | 439 | |
421 | 440 | echo ' |
422 | 441 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -425,13 +444,13 @@ discard block |
||
425 | 444 | } |
426 | 445 | |
427 | 446 | |
428 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
429 | - echo ' |
|
447 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
448 | + echo ' |
|
430 | 449 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
431 | 450 | </form>'; |
451 | + } |
|
432 | 452 | |
433 | - } |
|
434 | - else |
|
453 | + } else |
|
435 | 454 | { |
436 | 455 | echo ' |
437 | 456 | <div class="cat_bar"> |
@@ -443,9 +462,10 @@ discard block |
||
443 | 462 | <span>', $context['page_index'], '</span> |
444 | 463 | </div>'; |
445 | 464 | |
446 | - if (empty($context['topics'])) |
|
447 | - echo ' |
|
465 | + if (empty($context['topics'])) { |
|
466 | + echo ' |
|
448 | 467 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
468 | + } |
|
449 | 469 | |
450 | 470 | while ($topic = $context['get_topics']()) |
451 | 471 | { |
@@ -462,23 +482,27 @@ discard block |
||
462 | 482 | </div> |
463 | 483 | <div class="list_posts">', $message['body_highlighted'], '</div>'; |
464 | 484 | |
465 | - if ($topic['can_reply']) |
|
466 | - echo ' |
|
485 | + if ($topic['can_reply']) { |
|
486 | + echo ' |
|
467 | 487 | <ul class="quickbuttons">'; |
488 | + } |
|
468 | 489 | |
469 | 490 | // If they *can* reply? |
470 | - if ($topic['can_reply']) |
|
471 | - echo ' |
|
491 | + if ($topic['can_reply']) { |
|
492 | + echo ' |
|
472 | 493 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
494 | + } |
|
473 | 495 | |
474 | 496 | // If they *can* quote? |
475 | - if ($topic['can_quote']) |
|
476 | - echo ' |
|
497 | + if ($topic['can_quote']) { |
|
498 | + echo ' |
|
477 | 499 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
500 | + } |
|
478 | 501 | |
479 | - if ($topic['can_reply']) |
|
480 | - echo ' |
|
502 | + if ($topic['can_reply']) { |
|
503 | + echo ' |
|
481 | 504 | </ul>'; |
505 | + } |
|
482 | 506 | echo ' |
483 | 507 | <br class="clear"> |
484 | 508 | </div><!-- $topic[css_class] -->'; |
@@ -497,8 +521,8 @@ discard block |
||
497 | 521 | <div class="smalltext righttext" id="search_jump_to"></div> |
498 | 522 | <script>'; |
499 | 523 | |
500 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
501 | - echo ' |
|
524 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
525 | + echo ' |
|
502 | 526 | if (typeof(window.XMLHttpRequest) != "undefined") |
503 | 527 | aJumpTo[aJumpTo.length] = new JumpTo({ |
504 | 528 | sContainerId: "quick_mod_jump_to", |
@@ -513,6 +537,7 @@ discard block |
||
513 | 537 | bDisabled: true, |
514 | 538 | sCustomName: "move_to" |
515 | 539 | });'; |
540 | + } |
|
516 | 541 | |
517 | 542 | echo ' |
518 | 543 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -54,18 +54,20 @@ discard block |
||
54 | 54 | <div class="windowbg2 noup" id="group_requests_panel"> |
55 | 55 | <ul>'; |
56 | 56 | |
57 | - foreach ($context['group_requests'] as $request) |
|
58 | - echo ' |
|
57 | + foreach ($context['group_requests'] as $request) { |
|
58 | + echo ' |
|
59 | 59 | <li class="smalltext"> |
60 | 60 | <a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], ' |
61 | 61 | </li>'; |
62 | + } |
|
62 | 63 | |
63 | 64 | // Don't have any watched users right now? |
64 | - if (empty($context['group_requests'])) |
|
65 | - echo ' |
|
65 | + if (empty($context['group_requests'])) { |
|
66 | + echo ' |
|
66 | 67 | <li> |
67 | 68 | <strong class="smalltext">', $txt['mc_group_requests_none'], '</strong> |
68 | 69 | </li>'; |
70 | + } |
|
69 | 71 | |
70 | 72 | echo ' |
71 | 73 | </ul> |
@@ -121,18 +123,20 @@ discard block |
||
121 | 123 | <div class="windowbg2 noup" id="watched_users_panel"> |
122 | 124 | <ul>'; |
123 | 125 | |
124 | - foreach ($context['watched_users'] as $user) |
|
125 | - echo ' |
|
126 | + foreach ($context['watched_users'] as $user) { |
|
127 | + echo ' |
|
126 | 128 | <li> |
127 | 129 | <span class="smalltext">', sprintf(!empty($user['last_login']) ? $txt['mc_seen'] : $txt['mc_seen_never'], $user['link'], $user['last_login']), '</span> |
128 | 130 | </li>'; |
131 | + } |
|
129 | 132 | |
130 | 133 | // Don't have any watched users right now? |
131 | - if (empty($context['watched_users'])) |
|
132 | - echo ' |
|
134 | + if (empty($context['watched_users'])) { |
|
135 | + echo ' |
|
133 | 136 | <li> |
134 | 137 | <strong class="smalltext">', $txt['mc_watched_users_none'], '</strong> |
135 | 138 | </li>'; |
139 | + } |
|
136 | 140 | |
137 | 141 | echo ' |
138 | 142 | </ul> |
@@ -188,18 +192,20 @@ discard block |
||
188 | 192 | <div class="windowbg2 noup" id="reported_posts_panel"> |
189 | 193 | <ul>'; |
190 | 194 | |
191 | - foreach ($context['reported_posts'] as $post) |
|
192 | - echo ' |
|
195 | + foreach ($context['reported_posts'] as $post) { |
|
196 | + echo ' |
|
193 | 197 | <li> |
194 | 198 | <span class="smalltext">', sprintf($txt['mc_post_report'], $post['report_link'], $post['author']['link']), '</span> |
195 | 199 | </li>'; |
200 | + } |
|
196 | 201 | |
197 | 202 | // Don't have any watched users right now? |
198 | - if (empty($context['reported_posts'])) |
|
199 | - echo ' |
|
203 | + if (empty($context['reported_posts'])) { |
|
204 | + echo ' |
|
200 | 205 | <li> |
201 | 206 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
202 | 207 | </li>'; |
208 | + } |
|
203 | 209 | |
204 | 210 | echo ' |
205 | 211 | </ul> |
@@ -255,18 +261,20 @@ discard block |
||
255 | 261 | <div class="windowbg2 noup" id="reported_users_panel"> |
256 | 262 | <ul>'; |
257 | 263 | |
258 | - foreach ($context['reported_users'] as $user) |
|
259 | - echo ' |
|
264 | + foreach ($context['reported_users'] as $user) { |
|
265 | + echo ' |
|
260 | 266 | <li> |
261 | 267 | <span class="smalltext">', $user['user']['link'], '</span> |
262 | 268 | </li>'; |
269 | + } |
|
263 | 270 | |
264 | 271 | // Don't have any watched users right now? |
265 | - if (empty($context['reported_users'])) |
|
266 | - echo ' |
|
272 | + if (empty($context['reported_users'])) { |
|
273 | + echo ' |
|
267 | 274 | <li> |
268 | 275 | <strong class="smalltext">', $txt['mc_reported_users_none'], '</strong> |
269 | 276 | </li>'; |
277 | + } |
|
270 | 278 | |
271 | 279 | echo ' |
272 | 280 | </ul> |
@@ -313,11 +321,12 @@ discard block |
||
313 | 321 | global $context, $txt, $scripturl; |
314 | 322 | |
315 | 323 | // Let them know the action was a success. |
316 | - if (!empty($context['report_post_action'])) |
|
317 | - echo ' |
|
324 | + if (!empty($context['report_post_action'])) { |
|
325 | + echo ' |
|
318 | 326 | <div class="infobox"> |
319 | 327 | ', $txt['report_action_' . $context['report_post_action']], ' |
320 | 328 | </div>'; |
329 | + } |
|
321 | 330 | |
322 | 331 | echo ' |
323 | 332 | <div id="modnotes"> |
@@ -333,11 +342,12 @@ discard block |
||
333 | 342 | <ul class="moderation_notes">'; |
334 | 343 | |
335 | 344 | // Cycle through the notes. |
336 | - foreach ($context['notes'] as $note) |
|
337 | - echo ' |
|
345 | + foreach ($context['notes'] as $note) { |
|
346 | + echo ' |
|
338 | 347 | <li class="smalltext"> |
339 | 348 | ', ($note['can_delete'] ? '<a href="' . $note['delete_href'] . ';' . $context['mod-modnote-del_token_var'] . '=' . $context['mod-modnote-del_token'] . '" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '" class="you_sure"><span class="generic_icons delete"></span></a>' : ''), $note['time'], ' <strong>', $note['author']['link'], ':</strong> ', $note['text'], ' |
340 | 349 | </li>'; |
350 | + } |
|
341 | 351 | |
342 | 352 | echo ' |
343 | 353 | </ul> |
@@ -378,18 +388,19 @@ discard block |
||
378 | 388 | $remove_button = create_button('delete', 'remove_message', 'remove'); |
379 | 389 | |
380 | 390 | // No posts? |
381 | - if (empty($context['unapproved_items'])) |
|
382 | - echo ' |
|
391 | + if (empty($context['unapproved_items'])) { |
|
392 | + echo ' |
|
383 | 393 | <div class="windowbg2"> |
384 | 394 | <p class="centertext"> |
385 | 395 | ', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], ' |
386 | 396 | </p> |
387 | 397 | </div>'; |
388 | - else |
|
389 | - echo ' |
|
398 | + } else { |
|
399 | + echo ' |
|
390 | 400 | <div class="pagesection floatleft"> |
391 | 401 | ', $context['page_index'], ' |
392 | 402 | </div>'; |
403 | + } |
|
393 | 404 | |
394 | 405 | foreach ($context['unapproved_items'] as $item) |
395 | 406 | { |
@@ -408,14 +419,16 @@ discard block |
||
408 | 419 | <span class="floatright"> |
409 | 420 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>'; |
410 | 421 | |
411 | - if ($item['can_delete']) |
|
412 | - echo ' |
|
422 | + if ($item['can_delete']) { |
|
423 | + echo ' |
|
413 | 424 | ', $context['menu_separator'], ' |
414 | 425 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>'; |
426 | + } |
|
415 | 427 | |
416 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
417 | - echo ' |
|
428 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
429 | + echo ' |
|
418 | 430 | <input type="checkbox" name="item[]" value="', $item['id'], '" checked> '; |
431 | + } |
|
419 | 432 | |
420 | 433 | echo ' |
421 | 434 | </span> |
@@ -425,8 +438,8 @@ discard block |
||
425 | 438 | echo ' |
426 | 439 | <div class="pagesection">'; |
427 | 440 | |
428 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
429 | - echo ' |
|
441 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
442 | + echo ' |
|
430 | 443 | <div class="floatright"> |
431 | 444 | <select name="do" onchange="if (this.value != 0 && confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();"> |
432 | 445 | <option value="0">', $txt['with_selected'], ':</option> |
@@ -438,12 +451,14 @@ discard block |
||
438 | 451 | <input type="submit" name="mc_go" value="', $txt['go'], '" class="button"> |
439 | 452 | </noscript> |
440 | 453 | </div>'; |
454 | + } |
|
441 | 455 | |
442 | - if (!empty($context['unapproved_items'])) |
|
443 | - echo ' |
|
456 | + if (!empty($context['unapproved_items'])) { |
|
457 | + echo ' |
|
444 | 458 | <div class="floatleft"> |
445 | 459 | <div class="pagelinks">', $context['page_index'], '</div> |
446 | 460 | </div>'; |
461 | + } |
|
447 | 462 | |
448 | 463 | echo ' |
449 | 464 | </div><!-- .pagesection --> |
@@ -464,8 +479,9 @@ discard block |
||
464 | 479 | |
465 | 480 | // We'll have a delete please bob. |
466 | 481 | // @todo Discuss this with the team and rewrite if required. |
467 | - if (empty($delete_button)) |
|
468 | - $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
482 | + if (empty($delete_button)) { |
|
483 | + $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
484 | + } |
|
469 | 485 | |
470 | 486 | $output_html = ' |
471 | 487 | <div> |
@@ -474,10 +490,11 @@ discard block |
||
474 | 490 | </div> |
475 | 491 | <div class="floatright">'; |
476 | 492 | |
477 | - if ($post['can_delete']) |
|
478 | - $output_html .= ' |
|
493 | + if ($post['can_delete']) { |
|
494 | + $output_html .= ' |
|
479 | 495 | <a href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['mc_watched_users_delete_post'] . '" class="you_sure">' . $delete_button . '</a> |
480 | 496 | <input type="checkbox" name="delete[]" value="' . $post['id'] . '">'; |
497 | + } |
|
481 | 498 | |
482 | 499 | $output_html .= ' |
483 | 500 | </div> |
@@ -521,12 +538,12 @@ discard block |
||
521 | 538 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
522 | 539 | </div> |
523 | 540 | </form>'; |
524 | - } |
|
525 | - else |
|
526 | - echo ' |
|
541 | + } else { |
|
542 | + echo ' |
|
527 | 543 | <div class="windowbg"> |
528 | 544 | <div class="centertext">', $txt['mc_no_settings'], '</div> |
529 | 545 | </div>'; |
546 | + } |
|
530 | 547 | |
531 | 548 | echo ' |
532 | 549 | </div><!-- #modcenter -->'; |
@@ -622,13 +639,14 @@ discard block |
||
622 | 639 | </dd> |
623 | 640 | </dl>'; |
624 | 641 | |
625 | - if ($context['template_data']['can_edit_personal']) |
|
626 | - echo ' |
|
642 | + if ($context['template_data']['can_edit_personal']) { |
|
643 | + echo ' |
|
627 | 644 | <input type="checkbox" name="make_personal" id="make_personal"', $context['template_data']['personal'] ? ' checked' : '', '> |
628 | 645 | <label for="make_personal"> |
629 | 646 | <strong>', $txt['mc_warning_template_personal'], '</strong> |
630 | 647 | </label> |
631 | 648 | <p class="smalltext">', $txt['mc_warning_template_personal_desc'], '</p>'; |
649 | + } |
|
632 | 650 | |
633 | 651 | echo ' |
634 | 652 | <input type="submit" name="preview" id="preview_button" value="', $txt['preview'], '" class="button"> |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | |
50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
51 | 52 | |
52 | - if (pg_affected_rows($result) === 0) |
|
53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
53 | + if (pg_affected_rows($result) === 0) { |
|
54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | |
56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
60 | 62 | { |
61 | 63 | global $smcFunc, $db_connection; |
62 | 64 | |
63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
64 | - return false; |
|
65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
66 | + return false; |
|
67 | + } |
|
65 | 68 | |
66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
67 | 70 | $res = pg_fetch_assoc($result); |
68 | 71 | |
69 | - if ($res['server_version_num'] < 90500) |
|
70 | - return false; |
|
72 | + if ($res['server_version_num'] < 90500) { |
|
73 | + return false; |
|
74 | + } |
|
71 | 75 | |
72 | 76 | return $test ? true : parent::isSupported(); |
73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
81 | 85 | |
82 | 86 | $ttl = time() - $ttl; |
83 | 87 | |
84 | - if (empty($this->pg_get_data_prep)) |
|
85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
88 | + if (empty($this->pg_get_data_prep)) { |
|
89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
88 | 93 | |
89 | - if (pg_affected_rows($result) === 0) |
|
90 | - return null; |
|
94 | + if (pg_affected_rows($result) === 0) { |
|
95 | + return null; |
|
96 | + } |
|
91 | 97 | |
92 | 98 | $res = pg_fetch_assoc($result); |
93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
101 | 107 | { |
102 | 108 | global $db_prefix, $db_connection; |
103 | 109 | |
104 | - if (!isset($value)) |
|
105 | - $value = ''; |
|
110 | + if (!isset($value)) { |
|
111 | + $value = ''; |
|
112 | + } |
|
106 | 113 | |
107 | 114 | $ttl = time() + $ttl; |
108 | 115 | |
109 | - if (empty($this->pg_put_data_prep)) |
|
110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
116 | + if (empty($this->pg_put_data_prep)) { |
|
117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
113 | 120 | ); |
121 | + } |
|
114 | 122 | |
115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
116 | 124 | |
117 | - if (pg_affected_rows($result) > 0) |
|
118 | - return true; |
|
119 | - else |
|
120 | - return false; |
|
125 | + if (pg_affected_rows($result) > 0) { |
|
126 | + return true; |
|
127 | + } else { |
|
128 | + return false; |
|
129 | + } |
|
121 | 130 | } |
122 | 131 | |
123 | 132 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | global $db_connection, $db_prefix; |
167 | 167 | |
168 | - pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time() ); |
|
168 | + pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | global $db_connection, $db_prefix; |
191 | 191 | |
192 | - pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM '. $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING'); |
|
192 | + pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM ' . $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING'); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 |
@@ -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 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |