@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
53 | 55 | |
54 | 56 | // An extended key is needed to counteract a bug in APC. |
55 | - if ($value === null) |
|
56 | - return apcu_delete($key . 'smf'); |
|
57 | - else |
|
58 | - return apcu_store($key . 'smf', $value, $ttl); |
|
57 | + if ($value === null) { |
|
58 | + return apcu_delete($key . 'smf'); |
|
59 | + } else { |
|
60 | + return apcu_store($key . 'smf', $value, $ttl); |
|
61 | + } |
|
59 | 62 | } |
60 | 63 | |
61 | 64 | /** |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $currentServers = $this->memcached->getServerList(); |
55 | 55 | foreach ($servers as $server) |
56 | 56 | { |
57 | - if (strpos($server,'/') !== false) |
|
57 | + if (strpos($server, '/') !== false) |
|
58 | 58 | $tempServer = array($server, 0); |
59 | 59 | else |
60 | 60 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcached'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -54,9 +56,9 @@ discard block |
||
54 | 56 | $currentServers = $this->memcached->getServerList(); |
55 | 57 | foreach ($servers as $server) |
56 | 58 | { |
57 | - if (strpos($server,'/') !== false) |
|
58 | - $tempServer = array($server, 0); |
|
59 | - else |
|
59 | + if (strpos($server,'/') !== false) { |
|
60 | + $tempServer = array($server, 0); |
|
61 | + } else |
|
60 | 62 | { |
61 | 63 | $server = explode(':', $server); |
62 | 64 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | } |
75 | 77 | |
76 | 78 | // Found it? |
77 | - if (empty($foundServer)) |
|
78 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
79 | + if (empty($foundServer)) { |
|
80 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // Best guess is this worked. |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | $value = $this->memcached->get($key); |
93 | 96 | |
94 | 97 | // $value should return either data or false (from failure, key not found or empty array). |
95 | - if ($value === false) |
|
96 | - return null; |
|
98 | + if ($value === false) { |
|
99 | + return null; |
|
100 | + } |
|
97 | 101 | return $value; |
98 | 102 | } |
99 | 103 | |
@@ -136,8 +140,9 @@ discard block |
||
136 | 140 | $config_vars[] = $txt['cache_memcache_settings']; |
137 | 141 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
138 | 142 | |
139 | - if (!isset($context['settings_post_javascript'])) |
|
140 | - $context['settings_post_javascript'] = ''; |
|
143 | + if (!isset($context['settings_post_javascript'])) { |
|
144 | + $context['settings_post_javascript'] = ''; |
|
145 | + } |
|
141 | 146 | |
142 | 147 | $context['settings_post_javascript'] .= ' |
143 | 148 | $("#cache_accelerator").change(function (e) { |
@@ -555,7 +555,7 @@ |
||
555 | 555 | 'subject' => $row_liked_message['subject'], |
556 | 556 | 'num' => $row_liked_message['likes'], |
557 | 557 | 'href' => $scripturl . '?msg=' . $row_liked_message['id_msg'], |
558 | - 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
|
558 | + 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] . '">' . $row_liked_message['subject'] . '</a>' |
|
559 | 559 | ); |
560 | 560 | |
561 | 561 | if ($max_liked_message < $row_liked_message['likes']) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Display some useful/interesting board statistics. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | |
31 | 32 | isAllowedTo('view_stats'); |
32 | 33 | // Page disabled - redirect them out |
33 | - if (empty($modSettings['trackStats'])) |
|
34 | - fatal_lang_error('feature_disabled', true); |
|
34 | + if (empty($modSettings['trackStats'])) { |
|
35 | + fatal_lang_error('feature_disabled', true); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | if (!empty($_REQUEST['expand'])) |
37 | 39 | { |
@@ -39,31 +41,34 @@ discard block |
||
39 | 41 | |
40 | 42 | $month = (int) substr($_REQUEST['expand'], 4); |
41 | 43 | $year = (int) substr($_REQUEST['expand'], 0, 4); |
42 | - if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) |
|
43 | - $_SESSION['expanded_stats'][$year][] = $month; |
|
44 | - } |
|
45 | - elseif (!empty($_REQUEST['collapse'])) |
|
44 | + if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) { |
|
45 | + $_SESSION['expanded_stats'][$year][] = $month; |
|
46 | + } |
|
47 | + } elseif (!empty($_REQUEST['collapse'])) |
|
46 | 48 | { |
47 | 49 | $context['robot_no_index'] = true; |
48 | 50 | |
49 | 51 | $month = (int) substr($_REQUEST['collapse'], 4); |
50 | 52 | $year = (int) substr($_REQUEST['collapse'], 0, 4); |
51 | - if (!empty($_SESSION['expanded_stats'][$year])) |
|
52 | - $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
53 | + if (!empty($_SESSION['expanded_stats'][$year])) { |
|
54 | + $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | |
55 | 58 | // Handle the XMLHttpRequest. |
56 | 59 | if (isset($_REQUEST['xml'])) |
57 | 60 | { |
58 | 61 | // Collapsing stats only needs adjustments of the session variables. |
59 | - if (!empty($_REQUEST['collapse'])) |
|
60 | - obExit(false); |
|
62 | + if (!empty($_REQUEST['collapse'])) { |
|
63 | + obExit(false); |
|
64 | + } |
|
61 | 65 | |
62 | 66 | $context['sub_template'] = 'stats'; |
63 | 67 | $context['yearly'] = array(); |
64 | 68 | |
65 | - if (empty($month) || empty($year)) |
|
66 | - return; |
|
69 | + if (empty($month) || empty($year)) { |
|
70 | + return; |
|
71 | + } |
|
67 | 72 | |
68 | 73 | getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month)); |
69 | 74 | $context['yearly'][$year]['months'][$month]['date'] = array( |
@@ -220,8 +225,9 @@ discard block |
||
220 | 225 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
221 | 226 | ); |
222 | 227 | |
223 | - if ($max_num_posts < $row_members['posts']) |
|
224 | - $max_num_posts = $row_members['posts']; |
|
228 | + if ($max_num_posts < $row_members['posts']) { |
|
229 | + $max_num_posts = $row_members['posts']; |
|
230 | + } |
|
225 | 231 | } |
226 | 232 | $smcFunc['db_free_result']($members_result); |
227 | 233 | |
@@ -257,8 +263,9 @@ discard block |
||
257 | 263 | 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>' |
258 | 264 | ); |
259 | 265 | |
260 | - if ($max_num_posts < $row_board['num_posts']) |
|
261 | - $max_num_posts = $row_board['num_posts']; |
|
266 | + if ($max_num_posts < $row_board['num_posts']) { |
|
267 | + $max_num_posts = $row_board['num_posts']; |
|
268 | + } |
|
262 | 269 | } |
263 | 270 | $smcFunc['db_free_result']($boards_result); |
264 | 271 | |
@@ -284,12 +291,13 @@ discard block |
||
284 | 291 | ) |
285 | 292 | ); |
286 | 293 | $topic_ids = array(); |
287 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
288 | - $topic_ids[] = $row['id_topic']; |
|
294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
295 | + $topic_ids[] = $row['id_topic']; |
|
296 | + } |
|
289 | 297 | $smcFunc['db_free_result']($request); |
298 | + } else { |
|
299 | + $topic_ids = array(); |
|
290 | 300 | } |
291 | - else |
|
292 | - $topic_ids = array(); |
|
293 | 301 | |
294 | 302 | // Topic replies top 10. |
295 | 303 | $topic_reply_result = $smcFunc['db_query']('', ' |
@@ -329,8 +337,9 @@ discard block |
||
329 | 337 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>' |
330 | 338 | ); |
331 | 339 | |
332 | - if ($max_num_replies < $row_topic_reply['num_replies']) |
|
333 | - $max_num_replies = $row_topic_reply['num_replies']; |
|
340 | + if ($max_num_replies < $row_topic_reply['num_replies']) { |
|
341 | + $max_num_replies = $row_topic_reply['num_replies']; |
|
342 | + } |
|
334 | 343 | } |
335 | 344 | $smcFunc['db_free_result']($topic_reply_result); |
336 | 345 | |
@@ -354,12 +363,13 @@ discard block |
||
354 | 363 | ) |
355 | 364 | ); |
356 | 365 | $topic_ids = array(); |
357 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
358 | - $topic_ids[] = $row['id_topic']; |
|
366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
367 | + $topic_ids[] = $row['id_topic']; |
|
368 | + } |
|
359 | 369 | $smcFunc['db_free_result']($request); |
370 | + } else { |
|
371 | + $topic_ids = array(); |
|
360 | 372 | } |
361 | - else |
|
362 | - $topic_ids = array(); |
|
363 | 373 | |
364 | 374 | // Topic views top 10. |
365 | 375 | $topic_view_result = $smcFunc['db_query']('', ' |
@@ -399,8 +409,9 @@ discard block |
||
399 | 409 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>' |
400 | 410 | ); |
401 | 411 | |
402 | - if ($max_num < $row_topic_views['num_views']) |
|
403 | - $max_num = $row_topic_views['num_views']; |
|
412 | + if ($max_num < $row_topic_views['num_views']) { |
|
413 | + $max_num = $row_topic_views['num_views']; |
|
414 | + } |
|
404 | 415 | } |
405 | 416 | $smcFunc['db_free_result']($topic_view_result); |
406 | 417 | |
@@ -425,15 +436,17 @@ discard block |
||
425 | 436 | ) |
426 | 437 | ); |
427 | 438 | $members = array(); |
428 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
429 | - $members[$row['id_member_started']] = $row['hits']; |
|
439 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
440 | + $members[$row['id_member_started']] = $row['hits']; |
|
441 | + } |
|
430 | 442 | $smcFunc['db_free_result']($request); |
431 | 443 | |
432 | 444 | cache_put_data('stats_top_starters', $members, 360); |
433 | 445 | } |
434 | 446 | |
435 | - if (empty($members)) |
|
436 | - $members = array(0 => 0); |
|
447 | + if (empty($members)) { |
|
448 | + $members = array(0 => 0); |
|
449 | + } |
|
437 | 450 | |
438 | 451 | // Topic poster top 10. |
439 | 452 | $members_result = $smcFunc['db_query']('', ' |
@@ -458,8 +471,9 @@ discard block |
||
458 | 471 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
459 | 472 | ); |
460 | 473 | |
461 | - if ($max_num < $members[$row_members['id_member']]) |
|
462 | - $max_num = $members[$row_members['id_member']]; |
|
474 | + if ($max_num < $members[$row_members['id_member']]) { |
|
475 | + $max_num = $members[$row_members['id_member']]; |
|
476 | + } |
|
463 | 477 | } |
464 | 478 | ksort($context['stats_blocks']['starters']); |
465 | 479 | $smcFunc['db_free_result']($members_result); |
@@ -488,8 +502,9 @@ discard block |
||
488 | 502 | while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) |
489 | 503 | { |
490 | 504 | $temp2[] = (int) $row_members['id_member']; |
491 | - if (count($context['stats_blocks']['time_online']) >= 10) |
|
492 | - continue; |
|
505 | + if (count($context['stats_blocks']['time_online']) >= 10) { |
|
506 | + continue; |
|
507 | + } |
|
493 | 508 | |
494 | 509 | // Figure out the days, hours and minutes. |
495 | 510 | $timeDays = floor($row_members['total_time_logged_in'] / 86400); |
@@ -497,10 +512,12 @@ discard block |
||
497 | 512 | |
498 | 513 | // Figure out which things to show... (days, hours, minutes, etc.) |
499 | 514 | $timelogged = ''; |
500 | - if ($timeDays > 0) |
|
501 | - $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
502 | - if ($timeHours > 0) |
|
503 | - $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
515 | + if ($timeDays > 0) { |
|
516 | + $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
517 | + } |
|
518 | + if ($timeHours > 0) { |
|
519 | + $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
520 | + } |
|
504 | 521 | $timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7']; |
505 | 522 | |
506 | 523 | $context['stats_blocks']['time_online'][] = array( |
@@ -512,17 +529,20 @@ discard block |
||
512 | 529 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
513 | 530 | ); |
514 | 531 | |
515 | - if ($max_time_online < $row_members['total_time_logged_in']) |
|
516 | - $max_time_online = $row_members['total_time_logged_in']; |
|
532 | + if ($max_time_online < $row_members['total_time_logged_in']) { |
|
533 | + $max_time_online = $row_members['total_time_logged_in']; |
|
534 | + } |
|
517 | 535 | } |
518 | 536 | $smcFunc['db_free_result']($members_result); |
519 | 537 | |
520 | - foreach ($context['stats_blocks']['time_online'] as $i => $member) |
|
521 | - $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
538 | + foreach ($context['stats_blocks']['time_online'] as $i => $member) { |
|
539 | + $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
540 | + } |
|
522 | 541 | |
523 | 542 | // Cache the ones we found for a bit, just so we don't have to look again. |
524 | - if ($temp !== $temp2) |
|
525 | - cache_put_data('stats_total_time_members', $temp2, 480); |
|
543 | + if ($temp !== $temp2) { |
|
544 | + cache_put_data('stats_total_time_members', $temp2, 480); |
|
545 | + } |
|
526 | 546 | |
527 | 547 | // Likes. |
528 | 548 | if (!empty($modSettings['enable_likes'])) |
@@ -558,13 +578,15 @@ discard block |
||
558 | 578 | 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
559 | 579 | ); |
560 | 580 | |
561 | - if ($max_liked_message < $row_liked_message['likes']) |
|
562 | - $max_liked_message = $row_liked_message['likes']; |
|
581 | + if ($max_liked_message < $row_liked_message['likes']) { |
|
582 | + $max_liked_message = $row_liked_message['likes']; |
|
583 | + } |
|
563 | 584 | } |
564 | 585 | $smcFunc['db_free_result']($liked_messages); |
565 | 586 | |
566 | - foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) |
|
567 | - $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
587 | + foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) { |
|
588 | + $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
589 | + } |
|
568 | 590 | |
569 | 591 | // Liked users top 10. |
570 | 592 | $context['stats_blocks']['liked_users'] = array(); |
@@ -595,14 +617,16 @@ discard block |
||
595 | 617 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>', |
596 | 618 | ); |
597 | 619 | |
598 | - if ($max_liked_users < $row_liked_users['count']) |
|
599 | - $max_liked_users = $row_liked_users['count']; |
|
620 | + if ($max_liked_users < $row_liked_users['count']) { |
|
621 | + $max_liked_users = $row_liked_users['count']; |
|
622 | + } |
|
600 | 623 | } |
601 | 624 | |
602 | 625 | $smcFunc['db_free_result']($liked_users); |
603 | 626 | |
604 | - foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) |
|
605 | - $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
627 | + foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) { |
|
628 | + $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
629 | + } |
|
606 | 630 | } |
607 | 631 | |
608 | 632 | // Activity by month. |
@@ -620,8 +644,8 @@ discard block |
||
620 | 644 | $ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']); |
621 | 645 | $expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]); |
622 | 646 | |
623 | - if (!isset($context['yearly'][$row_months['stats_year']])) |
|
624 | - $context['yearly'][$row_months['stats_year']] = array( |
|
647 | + if (!isset($context['yearly'][$row_months['stats_year']])) { |
|
648 | + $context['yearly'][$row_months['stats_year']] = array( |
|
625 | 649 | 'year' => $row_months['stats_year'], |
626 | 650 | 'new_topics' => 0, |
627 | 651 | 'new_posts' => 0, |
@@ -633,6 +657,7 @@ discard block |
||
633 | 657 | 'expanded' => false, |
634 | 658 | 'current_year' => $row_months['stats_year'] == date('Y'), |
635 | 659 | ); |
660 | + } |
|
636 | 661 | |
637 | 662 | $context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array( |
638 | 663 | 'id' => $ID_MONTH, |
@@ -678,26 +703,30 @@ discard block |
||
678 | 703 | $context['yearly'][$year]['hits'] = comma_format($data['hits']); |
679 | 704 | |
680 | 705 | // Keep a list of collapsed years. |
681 | - if (!$data['expanded'] && !$data['current_year']) |
|
682 | - $context['collapsed_years'][] = $year; |
|
706 | + if (!$data['expanded'] && !$data['current_year']) { |
|
707 | + $context['collapsed_years'][] = $year; |
|
708 | + } |
|
683 | 709 | } |
684 | 710 | |
685 | - if (empty($_SESSION['expanded_stats'])) |
|
686 | - return; |
|
711 | + if (empty($_SESSION['expanded_stats'])) { |
|
712 | + return; |
|
713 | + } |
|
687 | 714 | |
688 | 715 | $condition_text = array(); |
689 | 716 | $condition_params = array(); |
690 | - foreach ($_SESSION['expanded_stats'] as $year => $months) |
|
691 | - if (!empty($months)) |
|
717 | + foreach ($_SESSION['expanded_stats'] as $year => $months) { |
|
718 | + if (!empty($months)) |
|
692 | 719 | { |
693 | 720 | $condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})'; |
721 | + } |
|
694 | 722 | $condition_params['year_' . $year] = $year; |
695 | 723 | $condition_params['months_' . $year] = $months; |
696 | 724 | } |
697 | 725 | |
698 | 726 | // No daily stats to even look at? |
699 | - if (empty($condition_text)) |
|
700 | - return; |
|
727 | + if (empty($condition_text)) { |
|
728 | + return; |
|
729 | + } |
|
701 | 730 | |
702 | 731 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
703 | 732 | |
@@ -723,8 +752,8 @@ discard block |
||
723 | 752 | ORDER BY stats_day ASC', |
724 | 753 | $condition_parameters |
725 | 754 | ); |
726 | - while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) |
|
727 | - $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
755 | + while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) { |
|
756 | + $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
728 | 757 | 'day' => sprintf('%02d', $row_days['stats_day']), |
729 | 758 | 'month' => sprintf('%02d', $row_days['stats_month']), |
730 | 759 | 'year' => $row_days['stats_year'], |
@@ -734,6 +763,7 @@ discard block |
||
734 | 763 | 'most_members_online' => comma_format($row_days['most_on']), |
735 | 764 | 'hits' => comma_format($row_days['hits']) |
736 | 765 | ); |
766 | + } |
|
737 | 767 | $smcFunc['db_free_result']($days_result); |
738 | 768 | } |
739 | 769 | |
@@ -752,16 +782,19 @@ discard block |
||
752 | 782 | global $modSettings, $user_info, $forum_version, $sourcedir; |
753 | 783 | |
754 | 784 | // First, is it disabled? |
755 | - if (empty($modSettings['allow_sm_stats'])) |
|
756 | - die(); |
|
785 | + if (empty($modSettings['allow_sm_stats'])) { |
|
786 | + die(); |
|
787 | + } |
|
757 | 788 | |
758 | 789 | // Are we saying who we are, and are we right? (OR an admin) |
759 | - if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) |
|
760 | - die(); |
|
790 | + if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) { |
|
791 | + die(); |
|
792 | + } |
|
761 | 793 | |
762 | 794 | // Verify the referer... |
763 | - if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) |
|
764 | - die(); |
|
795 | + if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) { |
|
796 | + die(); |
|
797 | + } |
|
765 | 798 | |
766 | 799 | // Get some server versions. |
767 | 800 | require_once($sourcedir . '/Subs-Admin.php'); |
@@ -787,16 +820,17 @@ discard block |
||
787 | 820 | ); |
788 | 821 | |
789 | 822 | // Encode all the data, for security. |
790 | - foreach ($stats_to_send as $k => $v) |
|
791 | - $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
823 | + foreach ($stats_to_send as $k => $v) { |
|
824 | + $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
825 | + } |
|
792 | 826 | |
793 | 827 | // Turn this into the query string! |
794 | 828 | $stats_to_send = implode('&', $stats_to_send); |
795 | 829 | |
796 | 830 | // If we're an admin, just plonk them out. |
797 | - if ($user_info['is_admin']) |
|
798 | - echo $stats_to_send; |
|
799 | - else |
|
831 | + if ($user_info['is_admin']) { |
|
832 | + echo $stats_to_send; |
|
833 | + } else |
|
800 | 834 | { |
801 | 835 | // Connect to the collection script. |
802 | 836 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
@@ -1799,9 +1799,9 @@ |
||
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | /** |
1802 | - * Callback for createList(). |
|
1803 | - * @return int The total number of warning templates |
|
1804 | - */ |
|
1802 | + * Callback for createList(). |
|
1803 | + * @return int The total number of warning templates |
|
1804 | + */ |
|
1805 | 1805 | function list_getWarningTemplateCount() |
1806 | 1806 | { |
1807 | 1807 | global $smcFunc, $user_info; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if (empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if (empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5(json_encode($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5(json_encode((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
691 | 710 | isAllowedTo('moderate_forum'); |
692 | 711 | |
693 | 712 | // Are they wanting to view a particular report? |
694 | - if (!empty($_REQUEST['report'])) |
|
695 | - return MemberReport(); |
|
713 | + if (!empty($_REQUEST['report'])) { |
|
714 | + return MemberReport(); |
|
715 | + } |
|
696 | 716 | |
697 | 717 | // Set up the comforting bits... |
698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
746 | 766 | // Time to update. |
747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
748 | 768 | recountOpenReports('members'); |
749 | - } |
|
750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
751 | 770 | { |
752 | 771 | checkSession(); |
753 | 772 | |
754 | 773 | // All the ones to update... |
755 | 774 | $toClose = array(); |
756 | - foreach ($_POST['close'] as $rid) |
|
757 | - $toClose[] = (int) $rid; |
|
775 | + foreach ($_POST['close'] as $rid) { |
|
776 | + $toClose[] = (int) $rid; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | if (!empty($toClose)) |
760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
907 | 927 | global $context, $user_info; |
908 | 928 | |
909 | 929 | // You need to be allowed to moderate groups... |
910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
911 | - isAllowedTo('manage_membergroups'); |
|
930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
931 | + isAllowedTo('manage_membergroups'); |
|
932 | + } |
|
912 | 933 | |
913 | 934 | // Load the group templates. |
914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
919 | 940 | 'view' => 'ViewGroups', |
920 | 941 | ); |
921 | 942 | |
922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
923 | - $_GET['sa'] = 'view'; |
|
943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
944 | + $_GET['sa'] = 'view'; |
|
945 | + } |
|
924 | 946 | $context['sub_action'] = $_GET['sa']; |
925 | 947 | |
926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
950 | 972 | 'id_notice' => $id_notice, |
951 | 973 | ) |
952 | 974 | ); |
953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
954 | - fatal_lang_error('no_access', false); |
|
975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
976 | + fatal_lang_error('no_access', false); |
|
977 | + } |
|
955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
956 | 979 | $smcFunc['db_free_result']($request); |
957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
989 | 1012 | |
990 | 1013 | $toDelete = array(); |
991 | - if (!is_array($_REQUEST['delete'])) |
|
992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
993 | - else |
|
994 | - foreach ($_REQUEST['delete'] as $did) |
|
1014 | + if (!is_array($_REQUEST['delete'])) { |
|
1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1016 | + } else { |
|
1017 | + foreach ($_REQUEST['delete'] as $did) |
|
995 | 1018 | $toDelete[] = (int) $did; |
1019 | + } |
|
996 | 1020 | |
997 | 1021 | if (!empty($toDelete)) |
998 | 1022 | { |
999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
1001 | - foreach ($toDelete as $did) |
|
1002 | - removeMessage($did); |
|
1025 | + foreach ($toDelete as $did) { |
|
1026 | + removeMessage($did); |
|
1027 | + } |
|
1003 | 1028 | } |
1004 | 1029 | } |
1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
1008 | 1033 | { |
1009 | 1034 | $approve_query = ''; |
1010 | 1035 | $delete_boards = array(); |
1011 | - } |
|
1012 | - else |
|
1036 | + } else |
|
1013 | 1037 | { |
1014 | 1038 | // Still obey permissions! |
1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
1017 | 1041 | |
1018 | - if ($approve_boards == array(0)) |
|
1019 | - $approve_query = ''; |
|
1020 | - elseif (!empty($approve_boards)) |
|
1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1042 | + if ($approve_boards == array(0)) { |
|
1043 | + $approve_query = ''; |
|
1044 | + } elseif (!empty($approve_boards)) { |
|
1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1046 | + } |
|
1022 | 1047 | // Nada, zip, etc... |
1023 | - else |
|
1024 | - $approve_query = ' AND 1=0'; |
|
1048 | + else { |
|
1049 | + $approve_query = ' AND 1=0'; |
|
1050 | + } |
|
1025 | 1051 | } |
1026 | 1052 | |
1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
1120 | 1146 | 'data' => array( |
1121 | 1147 | 'function' => function($member) use ($scripturl) |
1122 | 1148 | { |
1123 | - if ($member['last_post_id']) |
|
1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1125 | - else |
|
1126 | - return $member['last_post']; |
|
1149 | + if ($member['last_post_id']) { |
|
1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1151 | + } else { |
|
1152 | + return $member['last_post']; |
|
1153 | + } |
|
1127 | 1154 | }, |
1128 | 1155 | ), |
1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
1251 | 1278 | ) |
1252 | 1279 | ); |
1253 | 1280 | $latest_posts = array(); |
1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1283 | + } |
|
1256 | 1284 | |
1257 | 1285 | if (!empty($latest_posts)) |
1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
1443 | 1471 | // Setup the direction stuff... |
1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1445 | 1473 | |
1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1448 | - else |
|
1449 | - $search_params_string = $search_params['string']; |
|
1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1476 | + } else { |
|
1477 | + $search_params_string = $search_params['string']; |
|
1478 | + } |
|
1450 | 1479 | |
1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1453 | - else |
|
1454 | - $search_params_type = $search_params['type']; |
|
1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1482 | + } else { |
|
1483 | + $search_params_type = $search_params['type']; |
|
1484 | + } |
|
1455 | 1485 | |
1456 | 1486 | $search_params = array( |
1457 | 1487 | 'string' => $search_params_string, |
@@ -1534,9 +1564,10 @@ discard block |
||
1534 | 1564 | ' . $rowData['reason'] . ' |
1535 | 1565 | </div>'; |
1536 | 1566 | |
1537 | - if (!empty($rowData['id_notice'])) |
|
1538 | - $output .= ' |
|
1567 | + if (!empty($rowData['id_notice'])) { |
|
1568 | + $output .= ' |
|
1539 | 1569 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1570 | + } |
|
1540 | 1571 | return $output; |
1541 | 1572 | }, |
1542 | 1573 | ), |
@@ -1654,9 +1685,9 @@ discard block |
||
1654 | 1685 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1655 | 1686 | |
1656 | 1687 | // Submitting a new one? |
1657 | - if (isset($_POST['add'])) |
|
1658 | - return ModifyWarningTemplate(); |
|
1659 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1688 | + if (isset($_POST['add'])) { |
|
1689 | + return ModifyWarningTemplate(); |
|
1690 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1660 | 1691 | { |
1661 | 1692 | checkSession(); |
1662 | 1693 | validateToken('mod-wt'); |
@@ -1675,8 +1706,9 @@ discard block |
||
1675 | 1706 | 'current_member' => $user_info['id'], |
1676 | 1707 | ) |
1677 | 1708 | ); |
1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1679 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1710 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1711 | + } |
|
1680 | 1712 | $smcFunc['db_free_result']($request); |
1681 | 1713 | |
1682 | 1714 | // Do the deletes. |
@@ -1967,16 +1999,18 @@ discard block |
||
1967 | 1999 | ); |
1968 | 2000 | |
1969 | 2001 | // If it wasn't visible and now is they've effectively added it. |
1970 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1971 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2002 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
2003 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2004 | + } |
|
1972 | 2005 | // Conversely if they made it personal it's a delete. |
1973 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1974 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2006 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2007 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2008 | + } |
|
1975 | 2009 | // Otherwise just an edit. |
1976 | - else |
|
1977 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1978 | - } |
|
1979 | - else |
|
2010 | + else { |
|
2011 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2012 | + } |
|
2013 | + } else |
|
1980 | 2014 | { |
1981 | 2015 | $smcFunc['db_insert']('', |
1982 | 2016 | '{db_prefix}log_comments', |
@@ -1996,17 +2030,18 @@ discard block |
||
1996 | 2030 | |
1997 | 2031 | // Get out of town... |
1998 | 2032 | redirectexit('action=moderate;area=warnings;sa=templates'); |
1999 | - } |
|
2000 | - else |
|
2033 | + } else |
|
2001 | 2034 | { |
2002 | 2035 | $context['warning_errors'] = array(); |
2003 | 2036 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2004 | 2037 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2005 | 2038 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2006 | - if (empty($_POST['template_title'])) |
|
2007 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2008 | - if (empty($_POST['template_body'])) |
|
2009 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2039 | + if (empty($_POST['template_title'])) { |
|
2040 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2041 | + } |
|
2042 | + if (empty($_POST['template_body'])) { |
|
2043 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2044 | + } |
|
2010 | 2045 | } |
2011 | 2046 | } |
2012 | 2047 | |
@@ -2051,8 +2086,9 @@ discard block |
||
2051 | 2086 | // Now check other options! |
2052 | 2087 | $pref_binary = 0; |
2053 | 2088 | |
2054 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2055 | - $pref_binary |= 4; |
|
2089 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2090 | + $pref_binary |= 4; |
|
2091 | + } |
|
2056 | 2092 | |
2057 | 2093 | // Put it all together. |
2058 | 2094 | $mod_prefs = '0||' . $pref_binary; |
@@ -2076,9 +2112,10 @@ discard block |
||
2076 | 2112 | unset($_SESSION['moderate_time']); |
2077 | 2113 | |
2078 | 2114 | // Clean any moderator tokens as well. |
2079 | - foreach ($_SESSION['token'] as $key => $token) |
|
2080 | - if (strpos($key, '-mod') !== false) |
|
2115 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2116 | + if (strpos($key, '-mod') !== false) |
|
2081 | 2117 | unset($_SESSION['token'][$key]); |
2118 | + } |
|
2082 | 2119 | |
2083 | 2120 | redirectexit(); |
2084 | 2121 | } |
@@ -273,7 +273,6 @@ |
||
273 | 273 | * Modify any setting related to topics. |
274 | 274 | * Requires the admin_forum permission. |
275 | 275 | * Accessed from ?action=admin;area=postsettings;sa=topics. |
276 | - |
|
277 | 276 | * @param bool $return_config Whether or not to return the config_vars array (used for admin search) |
278 | 277 | * @return void|array Returns nothing or returns $config_vars if $return_config is true |
279 | 278 | * @uses Admin template, edit_topic_settings sub-template. |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
98 | 99 | { |
99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
100 | 101 | |
101 | - foreach ($_POST['censortext'] as $c) |
|
102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
103 | - } |
|
104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
102 | + foreach ($_POST['censortext'] as $c) { |
|
103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
104 | + } |
|
105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
105 | 106 | { |
106 | 107 | if (is_array($_POST['censor_vulgar'])) |
107 | 108 | { |
108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
109 | 110 | { |
110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | |
114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
115 | 117 | $censored_proper = $_POST['censor_proper']; |
116 | - } |
|
117 | - else |
|
118 | + } else |
|
118 | 119 | { |
119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
151 | 152 | $context['censored_words'] = array(); |
152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
153 | 154 | { |
154 | - if (empty($censor_vulgar[$i])) |
|
155 | - continue; |
|
155 | + if (empty($censor_vulgar[$i])) { |
|
156 | + continue; |
|
157 | + } |
|
156 | 158 | |
157 | 159 | // Skip it, it's either spaces or stars only. |
158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
159 | - continue; |
|
160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
161 | + continue; |
|
162 | + } |
|
160 | 163 | |
161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
187 | 190 | |
188 | 191 | // Make an inline conditional a little shorter... |
189 | 192 | $can_spell_check = false; |
190 | - if (function_exists('pspell_new')) |
|
191 | - $can_spell_check = true; |
|
192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
193 | - $can_spell_check = true; |
|
193 | + if (function_exists('pspell_new')) { |
|
194 | + $can_spell_check = true; |
|
195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
196 | + $can_spell_check = true; |
|
197 | + } |
|
194 | 198 | |
195 | 199 | // All the settings... |
196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
221 | 225 | |
222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
223 | 227 | |
224 | - if ($return_config) |
|
225 | - return $config_vars; |
|
228 | + if ($return_config) { |
|
229 | + return $config_vars; |
|
230 | + } |
|
226 | 231 | |
227 | 232 | // We'll want this for our easy save. |
228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
242 | 247 | db_extend('packages'); |
243 | 248 | |
244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
245 | - foreach ($colData as $column) |
|
246 | - if ($column['name'] == 'body') |
|
250 | + foreach ($colData as $column) { |
|
251 | + if ($column['name'] == 'body') |
|
247 | 252 | $body_type = $column['type']; |
253 | + } |
|
248 | 254 | |
249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
257 | + } |
|
251 | 258 | } |
252 | 259 | |
253 | 260 | // If we're changing the post preview length let's check its valid |
254 | - if (!empty($_POST['preview_characters'])) |
|
255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
261 | + if (!empty($_POST['preview_characters'])) { |
|
262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
263 | + } |
|
256 | 264 | |
257 | 265 | call_integration_hook('integrate_save_post_settings'); |
258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
313 | 321 | |
314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
315 | 323 | |
316 | - if ($return_config) |
|
317 | - return $config_vars; |
|
324 | + if ($return_config) { |
|
325 | + return $config_vars; |
|
326 | + } |
|
318 | 327 | |
319 | 328 | // Get the settings template ready. |
320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
368 | 377 | ); |
369 | 378 | |
370 | - if ($return_config) |
|
371 | - return $config_vars; |
|
379 | + if ($return_config) { |
|
380 | + return $config_vars; |
|
381 | + } |
|
372 | 382 | |
373 | 383 | // Get the settings template ready. |
374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => true, |
32 | 33 | ); |
33 | -} |
|
34 | + } |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /** |
36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
54 | 56 | { |
55 | 57 | global $smcFunc; |
56 | 58 | |
57 | - if ($size == 'small') |
|
58 | - $size = 'smallint(5)'; |
|
59 | - elseif ($size == 'medium') |
|
60 | - $size = 'mediumint(8)'; |
|
61 | - else |
|
62 | - $size = 'int(10)'; |
|
59 | + if ($size == 'small') { |
|
60 | + $size = 'smallint(5)'; |
|
61 | + } elseif ($size == 'medium') { |
|
62 | + $size = 'mediumint(8)'; |
|
63 | + } else { |
|
64 | + $size = 'int(10)'; |
|
65 | + } |
|
63 | 66 | |
64 | 67 | $smcFunc['db_query']('', ' |
65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
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 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | is_not_guest(); |
35 | 36 | |
36 | 37 | // You have to specify a board to turn notifications on! |
37 | - if (empty($board)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($board)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // No subaction: find out what to do. |
41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
50 | 52 | |
51 | - if ($mode > 1) |
|
52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | + if ($mode > 1) { |
|
54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | 55 | $smcFunc['db_insert']('ignore', |
54 | 56 | '{db_prefix}log_notify', |
55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
56 | 58 | array($user_info['id'], $board), |
57 | 59 | array('id_member', 'id_board') |
58 | 60 | ); |
59 | - else |
|
60 | - $smcFunc['db_query']('', ' |
|
61 | + } else { |
|
62 | + $smcFunc['db_query']('', ' |
|
61 | 63 | DELETE FROM {db_prefix}log_notify |
62 | 64 | WHERE id_member = {int:current_member} |
63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
66 | 68 | 'current_member' => $user_info['id'], |
67 | 69 | ) |
68 | 70 | ); |
71 | + } |
|
69 | 72 | |
70 | 73 | } |
71 | 74 | |
@@ -81,10 +84,10 @@ discard block |
||
81 | 84 | ), |
82 | 85 | ); |
83 | 86 | $context['sub_template'] = 'generic_xml'; |
87 | + } else { |
|
88 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
89 | + } |
|
84 | 90 | } |
85 | - else |
|
86 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
87 | -} |
|
88 | 91 | |
89 | 92 | /** |
90 | 93 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -108,8 +111,9 @@ discard block |
||
108 | 111 | $mode = (int) $_GET['mode']; |
109 | 112 | $alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3); |
110 | 113 | |
111 | - if (empty($mode)) |
|
112 | - $mode = 1; |
|
114 | + if (empty($mode)) { |
|
115 | + $mode = 1; |
|
116 | + } |
|
113 | 117 | |
114 | 118 | $request = $smcFunc['db_query']('', ' |
115 | 119 | SELECT id_member, id_topic, id_msg, unwatched |
@@ -132,8 +136,7 @@ discard block |
||
132 | 136 | 'id_msg' => 0, |
133 | 137 | 'unwatched' => empty($mode) ? 1 : 0, |
134 | 138 | ); |
135 | - } |
|
136 | - else |
|
139 | + } else |
|
137 | 140 | { |
138 | 141 | $insert = false; |
139 | 142 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -160,9 +163,8 @@ discard block |
||
160 | 163 | array($user_info['id'], $log['id_topic']), |
161 | 164 | array('id_member', 'id_board') |
162 | 165 | ); |
163 | - } |
|
164 | - else |
|
165 | - $smcFunc['db_query']('', ' |
|
166 | + } else { |
|
167 | + $smcFunc['db_query']('', ' |
|
166 | 168 | DELETE FROM {db_prefix}log_notify |
167 | 169 | WHERE id_topic = {int:topic} |
168 | 170 | AND id_member = {int:member}', |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | 'topic' => $log['id_topic'], |
171 | 173 | 'member' => $user_info['id'], |
172 | 174 | )); |
175 | + } |
|
173 | 176 | |
174 | 177 | } |
175 | 178 | } |
@@ -186,9 +189,9 @@ discard block |
||
186 | 189 | ), |
187 | 190 | ); |
188 | 191 | $context['sub_template'] = 'generic_xml'; |
192 | + } else { |
|
193 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
194 | + } |
|
189 | 195 | } |
190 | - else |
|
191 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
192 | -} |
|
193 | 196 | |
194 | 197 | ?> |
195 | 198 | \ No newline at end of file |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | // Just send a generic message. |
77 | 77 | else |
78 | 78 | $this->setResponse(array( |
79 | - 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
79 | + 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
|
80 | 80 | 'type' => 'error', |
81 | 81 | 'data' => false, |
82 | 82 | )); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | // Gotta urlencode the filename. |
405 | 405 | if ($this->_attachResults) |
406 | 406 | foreach ($this->_attachResults as $k => $v) |
407 | - $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
407 | + $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
408 | 408 | |
409 | 409 | $this->_response = array( |
410 | 410 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | ob_start(); |
432 | 432 | |
433 | 433 | // Set the header. |
434 | - header('Content-Type: application/json; charset='. $context['character_set'] .''); |
|
434 | + header('Content-Type: application/json; charset=' . $context['character_set'] . ''); |
|
435 | 435 | |
436 | 436 | echo json_encode($this->_response ? $this->_response : array()); |
437 | 437 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | class Attachments |
20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
70 | 71 | |
71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
72 | 73 | |
73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
74 | - $this->{$this->_sa}(); |
|
74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
75 | + $this->{$this->_sa}(); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | // Just send a generic message. |
77 | - else |
|
78 | - $this->setResponse(array( |
|
79 | + else { |
|
80 | + $this->setResponse(array( |
|
79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
80 | 82 | 'type' => 'error', |
81 | 83 | 'data' => false, |
82 | 84 | )); |
85 | + } |
|
83 | 86 | |
84 | 87 | // Back to the future, oh, to the browser! |
85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
96 | 99 | |
97 | 100 | // Need something to work with. |
98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
99 | - return $this->setResponse(array( |
|
101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
102 | + return $this->setResponse(array( |
|
100 | 103 | 'text' => 'attached_file_deleted_error', |
101 | 104 | 'type' => 'error', |
102 | 105 | 'data' => false, |
103 | 106 | )); |
107 | + } |
|
104 | 108 | |
105 | 109 | // Lets pass some params and see what happens :P |
106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -119,19 +123,21 @@ discard block |
||
119 | 123 | public function add() |
120 | 124 | { |
121 | 125 | // You gotta be able to post attachments. |
122 | - if (!$this->_canPostAttachment) |
|
123 | - return $this->setResponse(array( |
|
126 | + if (!$this->_canPostAttachment) { |
|
127 | + return $this->setResponse(array( |
|
124 | 128 | 'text' => 'attached_file_cannot', |
125 | 129 | 'type' => 'error', |
126 | 130 | 'data' => false, |
127 | 131 | )); |
132 | + } |
|
128 | 133 | |
129 | 134 | // Process them at once! |
130 | 135 | $this->processAttachments(); |
131 | 136 | |
132 | 137 | // The attachments was created and moved the the right folder, time to update the DB. |
133 | - if (!empty($_SESSION['temp_attachments'])) |
|
134 | - $this->createAtttach(); |
|
138 | + if (!empty($_SESSION['temp_attachments'])) { |
|
139 | + $this->createAtttach(); |
|
140 | + } |
|
135 | 141 | |
136 | 142 | // Set the response. |
137 | 143 | $this->setResponse(); |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | { |
145 | 151 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
146 | 152 | |
147 | - if (!isset($_FILES['attachment']['name'])) |
|
148 | - $_FILES['attachment']['tmp_name'] = array(); |
|
153 | + if (!isset($_FILES['attachment']['name'])) { |
|
154 | + $_FILES['attachment']['tmp_name'] = array(); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // If there are attachments, calculate the total size and how many. |
151 | 158 | $context['attachments']['total_size'] = 0; |
@@ -155,25 +162,30 @@ discard block |
||
155 | 162 | if (isset($_REQUEST['msg'])) |
156 | 163 | { |
157 | 164 | $context['attachments']['quantity'] = count($context['current_attachments']); |
158 | - foreach ($context['current_attachments'] as $attachment) |
|
159 | - $context['attachments']['total_size'] += $attachment['size']; |
|
165 | + foreach ($context['current_attachments'] as $attachment) { |
|
166 | + $context['attachments']['total_size'] += $attachment['size']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | // A bit of house keeping first. |
163 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
164 | - unset($_SESSION['temp_attachments']); |
|
171 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
172 | + unset($_SESSION['temp_attachments']); |
|
173 | + } |
|
165 | 174 | |
166 | 175 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
167 | - if (!isset($_SESSION['temp_attachments'])) |
|
168 | - $_SESSION['temp_attachments'] = array(); |
|
176 | + if (!isset($_SESSION['temp_attachments'])) { |
|
177 | + $_SESSION['temp_attachments'] = array(); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Make sure we're uploading to the right place. |
171 | - if (!empty($modSettings['automanage_attachments'])) |
|
172 | - automanage_attachments_check_directory(); |
|
181 | + if (!empty($modSettings['automanage_attachments'])) { |
|
182 | + automanage_attachments_check_directory(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | // Is the attachments folder actually there? |
175 | - if (!empty($context['dir_creation_error'])) |
|
176 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
186 | + if (!empty($context['dir_creation_error'])) { |
|
187 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
188 | + } |
|
177 | 189 | |
178 | 190 | // The current attach folder ha some issues... |
179 | 191 | elseif (!is_dir($this->_attchDir)) |
@@ -198,13 +210,12 @@ discard block |
||
198 | 210 | ); |
199 | 211 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
200 | 212 | $smcFunc['db_free_result']($request); |
201 | - } |
|
202 | - |
|
203 | - else |
|
204 | - $context['attachments'] = array( |
|
213 | + } else { |
|
214 | + $context['attachments'] = array( |
|
205 | 215 | 'quantity' => 0, |
206 | 216 | 'total_size' => 0, |
207 | 217 | ); |
218 | + } |
|
208 | 219 | |
209 | 220 | // Check for other general errors here. |
210 | 221 | |
@@ -212,9 +223,10 @@ discard block |
||
212 | 223 | if (!empty($this->_generalErrors)) |
213 | 224 | { |
214 | 225 | // And delete the files 'cos they ain't going nowhere. |
215 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
216 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
226 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
227 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
217 | 228 | unlink($_FILES['attachment']['tmp_name'][$n]); |
229 | + } |
|
218 | 230 | |
219 | 231 | $_FILES['attachment']['tmp_name'] = array(); |
220 | 232 | |
@@ -225,26 +237,29 @@ discard block |
||
225 | 237 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
226 | 238 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
227 | 239 | { |
228 | - if ($_FILES['attachment']['name'][$n] == '') |
|
229 | - continue; |
|
240 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
241 | + continue; |
|
242 | + } |
|
230 | 243 | |
231 | 244 | // First, let's first check for PHP upload errors. |
232 | 245 | $errors = array(); |
233 | 246 | if (!empty($_FILES['attachment']['error'][$n])) |
234 | 247 | { |
235 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
236 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
237 | - |
|
238 | - else |
|
239 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
248 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
249 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
250 | + } else { |
|
251 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
252 | + } |
|
240 | 253 | |
241 | 254 | // Log this one, because... |
242 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
243 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
255 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
256 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
257 | + } |
|
244 | 258 | |
245 | 259 | // Weird, no errors were cached, still fill out a generic one. |
246 | - if (empty($errors)) |
|
247 | - $errors[] = 'attach_php_error'; |
|
260 | + if (empty($errors)) { |
|
261 | + $errors[] = 'attach_php_error'; |
|
262 | + } |
|
248 | 263 | } |
249 | 264 | |
250 | 265 | // Try to move and rename the file before doing any more checks on it. |
@@ -256,8 +271,9 @@ discard block |
||
256 | 271 | { |
257 | 272 | // The reported MIME type of the attachment might not be reliable. |
258 | 273 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
259 | - if (function_exists('mime_content_type')) |
|
260 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
274 | + if (function_exists('mime_content_type')) { |
|
275 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
276 | + } |
|
261 | 277 | |
262 | 278 | $_SESSION['temp_attachments'][$attachID] = array( |
263 | 279 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -269,16 +285,18 @@ discard block |
||
269 | 285 | ); |
270 | 286 | |
271 | 287 | // Move the file to the attachments folder with a temp name for now. |
272 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
273 | - smf_chmod($destName, 0644); |
|
288 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
289 | + smf_chmod($destName, 0644); |
|
290 | + } |
|
274 | 291 | |
275 | 292 | // This is madness!! |
276 | 293 | else |
277 | 294 | { |
278 | 295 | // File couldn't be moved. |
279 | 296 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
280 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
281 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
297 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
298 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
299 | + } |
|
282 | 300 | } |
283 | 301 | } |
284 | 302 | |
@@ -291,13 +309,15 @@ discard block |
||
291 | 309 | 'errors' => $errors, |
292 | 310 | ); |
293 | 311 | |
294 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
295 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
312 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
313 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
314 | + } |
|
296 | 315 | } |
297 | 316 | |
298 | 317 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
299 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
300 | - attachmentChecks($attachID); |
|
318 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
319 | + attachmentChecks($attachID); |
|
320 | + } |
|
301 | 321 | } |
302 | 322 | |
303 | 323 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -344,14 +364,15 @@ discard block |
||
344 | 364 | |
345 | 365 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
346 | 366 | |
347 | - if (!empty($attachmentOptions['thumb'])) |
|
348 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
367 | + if (!empty($attachmentOptions['thumb'])) { |
|
368 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
369 | + } |
|
349 | 370 | |
350 | - if ($this->_msg) |
|
351 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
371 | + if ($this->_msg) { |
|
372 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
373 | + } |
|
352 | 374 | } |
353 | - } |
|
354 | - else |
|
375 | + } else |
|
355 | 376 | { |
356 | 377 | // Sort out the errors for display and delete any associated files. |
357 | 378 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -363,14 +384,16 @@ discard block |
||
363 | 384 | if (!is_array($error)) |
364 | 385 | { |
365 | 386 | $attachmentOptions['errors'][] = $txt[$error]; |
366 | - if (in_array($error, $log_these)) |
|
367 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
387 | + if (in_array($error, $log_these)) { |
|
388 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
389 | + } |
|
390 | + } else { |
|
391 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
368 | 392 | } |
369 | - else |
|
370 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
371 | 393 | } |
372 | - if (file_exists($attachment['tmp_name'])) |
|
373 | - unlink($attachment['tmp_name']); |
|
394 | + if (file_exists($attachment['tmp_name'])) { |
|
395 | + unlink($attachment['tmp_name']); |
|
396 | + } |
|
374 | 397 | } |
375 | 398 | |
376 | 399 | // Regardless of errors, pass the results. |
@@ -378,8 +401,9 @@ discard block |
||
378 | 401 | } |
379 | 402 | |
380 | 403 | // Temp save this on the db. |
381 | - if (!empty($_SESSION['already_attached'])) |
|
382 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
404 | + if (!empty($_SESSION['already_attached'])) { |
|
405 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
406 | + } |
|
383 | 407 | |
384 | 408 | unset($_SESSION['temp_attachments']); |
385 | 409 | } |
@@ -399,14 +423,16 @@ discard block |
||
399 | 423 | if ($this->_sa == 'add') |
400 | 424 | { |
401 | 425 | // Is there any generic errors? made some sense out of them! |
402 | - if ($this->_generalErrors) |
|
403 | - foreach ($this->_generalErrors as $k => $v) |
|
426 | + if ($this->_generalErrors) { |
|
427 | + foreach ($this->_generalErrors as $k => $v) |
|
404 | 428 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
429 | + } |
|
405 | 430 | |
406 | 431 | // Gotta urlencode the filename. |
407 | - if ($this->_attachResults) |
|
408 | - foreach ($this->_attachResults as $k => $v) |
|
432 | + if ($this->_attachResults) { |
|
433 | + foreach ($this->_attachResults as $k => $v) |
|
409 | 434 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
435 | + } |
|
410 | 436 | |
411 | 437 | $this->_response = array( |
412 | 438 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -415,9 +441,10 @@ discard block |
||
415 | 441 | } |
416 | 442 | |
417 | 443 | // Rest of us mere mortals gets no special treatment... |
418 | - elseif (!empty($data)) |
|
419 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
444 | + elseif (!empty($data)) { |
|
445 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
420 | 446 | $this->_response['text'] = $txt[$data['text']]; |
447 | + } |
|
421 | 448 | } |
422 | 449 | |
423 | 450 | protected function sendResponse() |
@@ -426,11 +453,11 @@ discard block |
||
426 | 453 | |
427 | 454 | ob_end_clean(); |
428 | 455 | |
429 | - if (!empty($modSettings['CompressedOutput'])) |
|
430 | - @ob_start('ob_gzhandler'); |
|
431 | - |
|
432 | - else |
|
433 | - ob_start(); |
|
456 | + if (!empty($modSettings['CompressedOutput'])) { |
|
457 | + @ob_start('ob_gzhandler'); |
|
458 | + } else { |
|
459 | + ob_start(); |
|
460 | + } |
|
434 | 461 | |
435 | 462 | // Set the header. |
436 | 463 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -42,10 +44,11 @@ discard block |
||
42 | 44 | $key = $this->prefix . strtr($key, ':/', '-_'); |
43 | 45 | |
44 | 46 | // Zend's pricey stuff. |
45 | - if (function_exists('zend_shm_cache_fetch')) |
|
46 | - return zend_shm_cache_fetch('SMF::' . $key); |
|
47 | - elseif (function_exists('output_cache_get')) |
|
48 | - return output_cache_get($key, $ttl); |
|
47 | + if (function_exists('zend_shm_cache_fetch')) { |
|
48 | + return zend_shm_cache_fetch('SMF::' . $key); |
|
49 | + } elseif (function_exists('output_cache_get')) { |
|
50 | + return output_cache_get($key, $ttl); |
|
51 | + } |
|
49 | 52 | } |
50 | 53 | |
51 | 54 | /** |
@@ -55,10 +58,11 @@ discard block |
||
55 | 58 | { |
56 | 59 | $key = $this->prefix . strtr($key, ':/', '-_'); |
57 | 60 | |
58 | - if (function_exists('zend_shm_cache_store')) |
|
59 | - return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
60 | - elseif (function_exists('output_cache_put')) |
|
61 | - return output_cache_put($key, $value); |
|
61 | + if (function_exists('zend_shm_cache_store')) { |
|
62 | + return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
63 | + } elseif (function_exists('output_cache_put')) { |
|
64 | + return output_cache_put($key, $value); |
|
65 | + } |
|
62 | 66 | } |
63 | 67 | |
64 | 68 | /** |