@@ -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 | * This function shows the board index. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | $context['canonical_url'] = $scripturl; |
35 | 36 | |
36 | 37 | // Do not let search engines index anything if there is a random thing in $_GET. |
37 | - if (!empty($_GET)) |
|
38 | - $context['robot_no_index'] = true; |
|
38 | + if (!empty($_GET)) { |
|
39 | + $context['robot_no_index'] = true; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Retrieve the categories and boards. |
41 | 43 | require_once($sourcedir . '/Subs-BoardIndex.php'); |
@@ -62,11 +64,12 @@ discard block |
||
62 | 64 | $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); |
63 | 65 | } |
64 | 66 | |
65 | - if (!empty($context['latest_posts']) || !empty($context['latest_post'])) |
|
66 | - $context['info_center'][] = array( |
|
67 | + if (!empty($context['latest_posts']) || !empty($context['latest_post'])) { |
|
68 | + $context['info_center'][] = array( |
|
67 | 69 | 'tpl' => 'recent', |
68 | 70 | 'txt' => 'recent_posts', |
69 | 71 | ); |
72 | + } |
|
70 | 73 | } |
71 | 74 | |
72 | 75 | // Load the calendar? |
@@ -87,20 +90,22 @@ discard block |
||
87 | 90 | // This is used to show the "how-do-I-edit" help. |
88 | 91 | $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); |
89 | 92 | |
90 | - if (!empty($context['show_calendar'])) |
|
91 | - $context['info_center'][] = array( |
|
93 | + if (!empty($context['show_calendar'])) { |
|
94 | + $context['info_center'][] = array( |
|
92 | 95 | 'tpl' => 'calendar', |
93 | 96 | 'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming', |
94 | 97 | ); |
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | // And stats. |
98 | 102 | $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); |
99 | - if ($settings['show_stats_index']) |
|
100 | - $context['info_center'][] = array( |
|
103 | + if ($settings['show_stats_index']) { |
|
104 | + $context['info_center'][] = array( |
|
101 | 105 | 'tpl' => 'stats', |
102 | 106 | 'txt' => 'forum_stats', |
103 | 107 | ); |
108 | + } |
|
104 | 109 | |
105 | 110 | // Now the online stuff |
106 | 111 | require_once($sourcedir . '/Subs-MembersOnline.php'); |
@@ -118,12 +123,14 @@ discard block |
||
118 | 123 | ); |
119 | 124 | |
120 | 125 | // Track most online statistics? (Subs-MembersOnline.php) |
121 | - if (!empty($modSettings['trackStats'])) |
|
122 | - trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
126 | + if (!empty($modSettings['trackStats'])) { |
|
127 | + trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
128 | + } |
|
123 | 129 | |
124 | 130 | // Are we showing all membergroups on the board index? |
125 | - if (!empty($settings['show_group_key'])) |
|
126 | - $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
131 | + if (!empty($settings['show_group_key'])) { |
|
132 | + $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
133 | + } |
|
127 | 134 | |
128 | 135 | // And back to normality. |
129 | 136 | $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); |
@@ -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 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
43 | 44 | |
44 | 45 | // Is the security option off? |
45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
46 | - return; |
|
46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
50 | - return; |
|
51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
52 | + return; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
55 | 58 | if (isset($_POST[$type . '_pass'])) |
56 | 59 | { |
57 | 60 | // Check to ensure we're forcing SSL for authentication |
58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
59 | - fatal_lang_error('login_ssl_required'); |
|
61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
62 | + fatal_lang_error('login_ssl_required'); |
|
63 | + } |
|
60 | 64 | |
61 | 65 | checkSession(); |
62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
72 | 76 | } |
73 | 77 | |
74 | 78 | // Better be sure to remember the real referer |
75 | - if (empty($_SESSION['request_referer'])) |
|
76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
77 | - elseif (empty($_POST)) |
|
78 | - unset($_SESSION['request_referer']); |
|
79 | + if (empty($_SESSION['request_referer'])) { |
|
80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
81 | + } elseif (empty($_POST)) { |
|
82 | + unset($_SESSION['request_referer']); |
|
83 | + } |
|
79 | 84 | |
80 | 85 | // Need to type in a password for that, man. |
81 | - if (!isset($_GET['xml'])) |
|
82 | - adminLogin($type); |
|
83 | - else |
|
84 | - return 'session_verify_fail'; |
|
85 | -} |
|
86 | + if (!isset($_GET['xml'])) { |
|
87 | + adminLogin($type); |
|
88 | + } else { |
|
89 | + return 'session_verify_fail'; |
|
90 | + } |
|
91 | + } |
|
86 | 92 | |
87 | 93 | /** |
88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
97 | 103 | |
98 | 104 | // Luckily, this person isn't a guest. |
99 | - if (!$user_info['is_guest']) |
|
100 | - return; |
|
105 | + if (!$user_info['is_guest']) { |
|
106 | + return; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | // Log what they were trying to do didn't work) |
103 | - if (!empty($modSettings['who_enabled'])) |
|
104 | - $_GET['error'] = 'guest_login'; |
|
110 | + if (!empty($modSettings['who_enabled'])) { |
|
111 | + $_GET['error'] = 'guest_login'; |
|
112 | + } |
|
105 | 113 | writeLog(true); |
106 | 114 | |
107 | 115 | // Just die. |
108 | - if (isset($_REQUEST['xml'])) |
|
109 | - obExit(false); |
|
116 | + if (isset($_REQUEST['xml'])) { |
|
117 | + obExit(false); |
|
118 | + } |
|
110 | 119 | |
111 | 120 | // Attempt to detect if they came from dlattach. |
112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
113 | - loadTheme(); |
|
121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
122 | + loadTheme(); |
|
123 | + } |
|
114 | 124 | |
115 | 125 | // Never redirect to an attachment |
116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
128 | + } |
|
118 | 129 | |
119 | 130 | // Load the Login template and language file. |
120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
124 | 135 | { |
125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
126 | 137 | redirectexit('action=login'); |
127 | - } |
|
128 | - else |
|
138 | + } else |
|
129 | 139 | { |
130 | 140 | loadTemplate('Login'); |
131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
156 | 166 | |
157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
158 | - if ($user_info['is_admin']) |
|
159 | - return; |
|
168 | + if ($user_info['is_admin']) { |
|
169 | + return; |
|
170 | + } |
|
160 | 171 | |
161 | 172 | // Only check the ban every so often. (to reduce load.) |
162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
177 | 188 | // Check both IP addresses. |
178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
179 | 190 | { |
180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
181 | - continue; |
|
191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
192 | + continue; |
|
193 | + } |
|
182 | 194 | $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
228 | 240 | // Store every type of ban that applies to you in your session. |
229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
230 | 242 | { |
231 | - foreach ($restrictions as $restriction) |
|
232 | - if (!empty($row[$restriction])) |
|
243 | + foreach ($restrictions as $restriction) { |
|
244 | + if (!empty($row[$restriction])) |
|
233 | 245 | { |
234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
247 | + } |
|
235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
251 | + } |
|
238 | 252 | |
239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
240 | - $flag_is_activated = true; |
|
253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
254 | + $flag_is_activated = true; |
|
255 | + } |
|
241 | 256 | } |
242 | 257 | } |
243 | 258 | $smcFunc['db_free_result']($request); |
244 | 259 | } |
245 | 260 | |
246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
264 | + } |
|
249 | 265 | |
250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
261 | 277 | { |
262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
263 | - foreach ($bans as $key => $value) |
|
264 | - $bans[$key] = (int) $value; |
|
279 | + foreach ($bans as $key => $value) { |
|
280 | + $bans[$key] = (int) $value; |
|
281 | + } |
|
265 | 282 | $request = $smcFunc['db_query']('', ' |
266 | 283 | SELECT bi.id_ban, bg.reason, COALESCE(bg.expire_time, 0) AS expire_time |
267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -298,14 +315,15 @@ discard block |
||
298 | 315 | if (isset($_SESSION['ban']['cannot_access'])) |
299 | 316 | { |
300 | 317 | // We don't wanna see you! |
301 | - if (!$user_info['is_guest']) |
|
302 | - $smcFunc['db_query']('', ' |
|
318 | + if (!$user_info['is_guest']) { |
|
319 | + $smcFunc['db_query']('', ' |
|
303 | 320 | DELETE FROM {db_prefix}log_online |
304 | 321 | WHERE id_member = {int:current_member}', |
305 | 322 | array( |
306 | 323 | 'current_member' => $user_info['id'], |
307 | 324 | ) |
308 | 325 | ); |
326 | + } |
|
309 | 327 | |
310 | 328 | // 'Log' the user out. Can't have any funny business... (save the name!) |
311 | 329 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -391,9 +409,10 @@ discard block |
||
391 | 409 | } |
392 | 410 | |
393 | 411 | // Fix up the banning permissions. |
394 | - if (isset($user_info['permissions'])) |
|
395 | - banPermissions(); |
|
396 | -} |
|
412 | + if (isset($user_info['permissions'])) { |
|
413 | + banPermissions(); |
|
414 | + } |
|
415 | + } |
|
397 | 416 | |
398 | 417 | /** |
399 | 418 | * Fix permissions according to ban status. |
@@ -404,8 +423,9 @@ discard block |
||
404 | 423 | global $user_info, $sourcedir, $modSettings, $context; |
405 | 424 | |
406 | 425 | // Somehow they got here, at least take away all permissions... |
407 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
408 | - $user_info['permissions'] = array(); |
|
426 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
427 | + $user_info['permissions'] = array(); |
|
428 | + } |
|
409 | 429 | // Okay, well, you can watch, but don't touch a thing. |
410 | 430 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
411 | 431 | { |
@@ -447,19 +467,20 @@ discard block |
||
447 | 467 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
448 | 468 | foreach ($permission_change as $old => $new) |
449 | 469 | { |
450 | - if (!in_array($old, $user_info['permissions'])) |
|
451 | - unset($permission_change[$old]); |
|
452 | - else |
|
453 | - $user_info['permissions'][] = $new; |
|
470 | + if (!in_array($old, $user_info['permissions'])) { |
|
471 | + unset($permission_change[$old]); |
|
472 | + } else { |
|
473 | + $user_info['permissions'][] = $new; |
|
474 | + } |
|
454 | 475 | } |
455 | 476 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
456 | 477 | } |
457 | 478 | |
458 | 479 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
459 | 480 | // Finally, some bits we cache in the session because it saves queries. |
460 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
461 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
462 | - else |
|
481 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
482 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
483 | + } else |
|
463 | 484 | { |
464 | 485 | require_once($sourcedir . '/Subs-Auth.php'); |
465 | 486 | rebuildModCache(); |
@@ -470,14 +491,12 @@ discard block |
||
470 | 491 | { |
471 | 492 | $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
472 | 493 | $context['open_member_reports'] = $_SESSION['rc']['member_reports']; |
473 | - } |
|
474 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
494 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
475 | 495 | { |
476 | 496 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
477 | 497 | $context['open_mod_reports'] = recountOpenReports('posts'); |
478 | 498 | $context['open_member_reports'] = recountOpenReports('members'); |
479 | - } |
|
480 | - else |
|
499 | + } else |
|
481 | 500 | { |
482 | 501 | $context['open_mod_reports'] = 0; |
483 | 502 | $context['open_member_reports'] = 0; |
@@ -497,8 +516,9 @@ discard block |
||
497 | 516 | global $user_info, $smcFunc; |
498 | 517 | |
499 | 518 | // Don't log web accelerators, it's very confusing... |
500 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
501 | - return; |
|
519 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
520 | + return; |
|
521 | + } |
|
502 | 522 | |
503 | 523 | $smcFunc['db_insert']('', |
504 | 524 | '{db_prefix}log_banned', |
@@ -508,8 +528,8 @@ discard block |
||
508 | 528 | ); |
509 | 529 | |
510 | 530 | // One extra point for these bans. |
511 | - if (!empty($ban_ids)) |
|
512 | - $smcFunc['db_query']('', ' |
|
531 | + if (!empty($ban_ids)) { |
|
532 | + $smcFunc['db_query']('', ' |
|
513 | 533 | UPDATE {db_prefix}ban_items |
514 | 534 | SET hits = hits + 1 |
515 | 535 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -517,7 +537,8 @@ discard block |
||
517 | 537 | 'ban_ids' => $ban_ids, |
518 | 538 | ) |
519 | 539 | ); |
520 | -} |
|
540 | + } |
|
541 | + } |
|
521 | 542 | |
522 | 543 | /** |
523 | 544 | * Checks if a given email address might be banned. |
@@ -533,8 +554,9 @@ discard block |
||
533 | 554 | global $txt, $smcFunc; |
534 | 555 | |
535 | 556 | // Can't ban an empty email |
536 | - if (empty($email) || trim($email) == '') |
|
537 | - return; |
|
557 | + if (empty($email) || trim($email) == '') { |
|
558 | + return; |
|
559 | + } |
|
538 | 560 | |
539 | 561 | // Let's start with the bans based on your IP/hostname/memberID... |
540 | 562 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -607,16 +629,18 @@ discard block |
||
607 | 629 | if ($type == 'post') |
608 | 630 | { |
609 | 631 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
610 | - if ($check !== $sc) |
|
611 | - $error = 'session_timeout'; |
|
632 | + if ($check !== $sc) { |
|
633 | + $error = 'session_timeout'; |
|
634 | + } |
|
612 | 635 | } |
613 | 636 | |
614 | 637 | // How about $_GET['sesc']? |
615 | 638 | elseif ($type == 'get') |
616 | 639 | { |
617 | 640 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
618 | - if ($check !== $sc) |
|
619 | - $error = 'session_verify_fail'; |
|
641 | + if ($check !== $sc) { |
|
642 | + $error = 'session_verify_fail'; |
|
643 | + } |
|
620 | 644 | } |
621 | 645 | |
622 | 646 | // Or can it be in either? |
@@ -624,13 +648,15 @@ discard block |
||
624 | 648 | { |
625 | 649 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
626 | 650 | |
627 | - if ($check !== $sc) |
|
628 | - $error = 'session_verify_fail'; |
|
651 | + if ($check !== $sc) { |
|
652 | + $error = 'session_verify_fail'; |
|
653 | + } |
|
629 | 654 | } |
630 | 655 | |
631 | 656 | // Verify that they aren't changing user agents on us - that could be bad. |
632 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
633 | - $error = 'session_verify_fail'; |
|
657 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
658 | + $error = 'session_verify_fail'; |
|
659 | + } |
|
634 | 660 | |
635 | 661 | // Make sure a page with session check requirement is not being prefetched. |
636 | 662 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -641,30 +667,35 @@ discard block |
||
641 | 667 | } |
642 | 668 | |
643 | 669 | // Check the referring site - it should be the same server at least! |
644 | - if (isset($_SESSION['request_referer'])) |
|
645 | - $referrer = $_SESSION['request_referer']; |
|
646 | - else |
|
647 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
670 | + if (isset($_SESSION['request_referer'])) { |
|
671 | + $referrer = $_SESSION['request_referer']; |
|
672 | + } else { |
|
673 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
674 | + } |
|
648 | 675 | if (!empty($referrer['host'])) |
649 | 676 | { |
650 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
651 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
652 | - else |
|
653 | - $real_host = $_SERVER['HTTP_HOST']; |
|
677 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
678 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
679 | + } else { |
|
680 | + $real_host = $_SERVER['HTTP_HOST']; |
|
681 | + } |
|
654 | 682 | |
655 | 683 | $parsed_url = parse_url($boardurl); |
656 | 684 | |
657 | 685 | // Are global cookies on? If so, let's check them ;). |
658 | 686 | if (!empty($modSettings['globalCookies'])) |
659 | 687 | { |
660 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
661 | - $parsed_url['host'] = $parts[1]; |
|
688 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
689 | + $parsed_url['host'] = $parts[1]; |
|
690 | + } |
|
662 | 691 | |
663 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
664 | - $referrer['host'] = $parts[1]; |
|
692 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
693 | + $referrer['host'] = $parts[1]; |
|
694 | + } |
|
665 | 695 | |
666 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
667 | - $real_host = $parts[1]; |
|
696 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
697 | + $real_host = $parts[1]; |
|
698 | + } |
|
668 | 699 | } |
669 | 700 | |
670 | 701 | // Okay: referrer must either match parsed_url or real_host. |
@@ -682,12 +713,14 @@ discard block |
||
682 | 713 | $log_error = true; |
683 | 714 | } |
684 | 715 | |
685 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
686 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
716 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
717 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
718 | + } |
|
687 | 719 | |
688 | 720 | // Everything is ok, return an empty string. |
689 | - if (!isset($error)) |
|
690 | - return ''; |
|
721 | + if (!isset($error)) { |
|
722 | + return ''; |
|
723 | + } |
|
691 | 724 | // A session error occurred, show the error. |
692 | 725 | elseif ($is_fatal) |
693 | 726 | { |
@@ -696,13 +729,14 @@ discard block |
||
696 | 729 | ob_end_clean(); |
697 | 730 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
698 | 731 | die; |
732 | + } else { |
|
733 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
699 | 734 | } |
700 | - else |
|
701 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
702 | 735 | } |
703 | 736 | // A session error occurred, return the error to the calling function. |
704 | - else |
|
705 | - return $error; |
|
737 | + else { |
|
738 | + return $error; |
|
739 | + } |
|
706 | 740 | |
707 | 741 | // We really should never fall through here, for very important reasons. Let's make sure. |
708 | 742 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -718,10 +752,9 @@ discard block |
||
718 | 752 | { |
719 | 753 | global $modSettings; |
720 | 754 | |
721 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
722 | - return true; |
|
723 | - |
|
724 | - else |
|
755 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
756 | + return true; |
|
757 | + } else |
|
725 | 758 | { |
726 | 759 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
727 | 760 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -772,9 +805,9 @@ discard block |
||
772 | 805 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
773 | 806 | unset($_SESSION['token'][$type . '-' . $action]); |
774 | 807 | return $return; |
808 | + } else { |
|
809 | + return ''; |
|
775 | 810 | } |
776 | - else |
|
777 | - return ''; |
|
778 | 811 | } |
779 | 812 | |
780 | 813 | // This nasty piece of code validates a token. |
@@ -805,12 +838,14 @@ discard block |
||
805 | 838 | fatal_lang_error('token_verify_fail', false); |
806 | 839 | } |
807 | 840 | // Remove this token as its useless |
808 | - else |
|
809 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
841 | + else { |
|
842 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
843 | + } |
|
810 | 844 | |
811 | 845 | // Randomly check if we should remove some older tokens. |
812 | - if (mt_rand(0, 138) == 23) |
|
813 | - cleanTokens(); |
|
846 | + if (mt_rand(0, 138) == 23) { |
|
847 | + cleanTokens(); |
|
848 | + } |
|
814 | 849 | |
815 | 850 | return false; |
816 | 851 | } |
@@ -825,14 +860,16 @@ discard block |
||
825 | 860 | function cleanTokens($complete = false) |
826 | 861 | { |
827 | 862 | // We appreciate cleaning up after yourselves. |
828 | - if (!isset($_SESSION['token'])) |
|
829 | - return; |
|
863 | + if (!isset($_SESSION['token'])) { |
|
864 | + return; |
|
865 | + } |
|
830 | 866 | |
831 | 867 | // Clean up tokens, trying to give enough time still. |
832 | - foreach ($_SESSION['token'] as $key => $data) |
|
833 | - if ($data[2] + 10800 < time() || $complete) |
|
868 | + foreach ($_SESSION['token'] as $key => $data) { |
|
869 | + if ($data[2] + 10800 < time() || $complete) |
|
834 | 870 | unset($_SESSION['token'][$key]); |
835 | -} |
|
871 | + } |
|
872 | + } |
|
836 | 873 | |
837 | 874 | /** |
838 | 875 | * Check whether a form has been submitted twice. |
@@ -850,37 +887,40 @@ discard block |
||
850 | 887 | { |
851 | 888 | global $context; |
852 | 889 | |
853 | - if (!isset($_SESSION['forms'])) |
|
854 | - $_SESSION['forms'] = array(); |
|
890 | + if (!isset($_SESSION['forms'])) { |
|
891 | + $_SESSION['forms'] = array(); |
|
892 | + } |
|
855 | 893 | |
856 | 894 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
857 | 895 | if ($action == 'register') |
858 | 896 | { |
859 | 897 | $context['form_sequence_number'] = 0; |
860 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
861 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
898 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
899 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
900 | + } |
|
862 | 901 | } |
863 | 902 | // Check whether the submitted number can be found in the session. |
864 | 903 | elseif ($action == 'check') |
865 | 904 | { |
866 | - if (!isset($_REQUEST['seqnum'])) |
|
867 | - return true; |
|
868 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
905 | + if (!isset($_REQUEST['seqnum'])) { |
|
906 | + return true; |
|
907 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
869 | 908 | { |
870 | 909 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
871 | 910 | return true; |
911 | + } elseif ($is_fatal) { |
|
912 | + fatal_lang_error('error_form_already_submitted', false); |
|
913 | + } else { |
|
914 | + return false; |
|
872 | 915 | } |
873 | - elseif ($is_fatal) |
|
874 | - fatal_lang_error('error_form_already_submitted', false); |
|
875 | - else |
|
876 | - return false; |
|
877 | 916 | } |
878 | 917 | // Don't check, just free the stack number. |
879 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
880 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
881 | - elseif ($action != 'free') |
|
882 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
883 | -} |
|
918 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
919 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
920 | + } elseif ($action != 'free') { |
|
921 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
922 | + } |
|
923 | + } |
|
884 | 924 | |
885 | 925 | /** |
886 | 926 | * Check the user's permissions. |
@@ -899,16 +939,19 @@ discard block |
||
899 | 939 | global $user_info, $smcFunc; |
900 | 940 | |
901 | 941 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
902 | - if (empty($permission)) |
|
903 | - return true; |
|
942 | + if (empty($permission)) { |
|
943 | + return true; |
|
944 | + } |
|
904 | 945 | |
905 | 946 | // You're never allowed to do something if your data hasn't been loaded yet! |
906 | - if (empty($user_info)) |
|
907 | - return false; |
|
947 | + if (empty($user_info)) { |
|
948 | + return false; |
|
949 | + } |
|
908 | 950 | |
909 | 951 | // Administrators are supermen :P. |
910 | - if ($user_info['is_admin']) |
|
911 | - return true; |
|
952 | + if ($user_info['is_admin']) { |
|
953 | + return true; |
|
954 | + } |
|
912 | 955 | |
913 | 956 | // Let's ensure this is an array. |
914 | 957 | $permission = (array) $permission; |
@@ -916,14 +959,16 @@ discard block |
||
916 | 959 | // Are we checking the _current_ board, or some other boards? |
917 | 960 | if ($boards === null) |
918 | 961 | { |
919 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
920 | - return true; |
|
962 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
963 | + return true; |
|
964 | + } |
|
921 | 965 | // You aren't allowed, by default. |
922 | - else |
|
923 | - return false; |
|
966 | + else { |
|
967 | + return false; |
|
968 | + } |
|
969 | + } elseif (!is_array($boards)) { |
|
970 | + $boards = array($boards); |
|
924 | 971 | } |
925 | - elseif (!is_array($boards)) |
|
926 | - $boards = array($boards); |
|
927 | 972 | |
928 | 973 | $request = $smcFunc['db_query']('', ' |
929 | 974 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -951,20 +996,23 @@ discard block |
||
951 | 996 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
952 | 997 | { |
953 | 998 | $result = !empty($row['add_deny']); |
954 | - if ($result == true) |
|
955 | - break; |
|
999 | + if ($result == true) { |
|
1000 | + break; |
|
1001 | + } |
|
956 | 1002 | } |
957 | 1003 | $smcFunc['db_free_result']($request); |
958 | 1004 | return $result; |
959 | 1005 | } |
960 | 1006 | |
961 | 1007 | // Make sure they can do it on all of the boards. |
962 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
963 | - return false; |
|
1008 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
1009 | + return false; |
|
1010 | + } |
|
964 | 1011 | |
965 | 1012 | $result = true; |
966 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
967 | - $result &= !empty($row['add_deny']); |
|
1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1014 | + $result &= !empty($row['add_deny']); |
|
1015 | + } |
|
968 | 1016 | $smcFunc['db_free_result']($request); |
969 | 1017 | |
970 | 1018 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1031,9 +1079,10 @@ discard block |
||
1031 | 1079 | |
1032 | 1080 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
1033 | 1081 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
1034 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
1035 | - validateSession(); |
|
1036 | -} |
|
1082 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
1083 | + validateSession(); |
|
1084 | + } |
|
1085 | + } |
|
1037 | 1086 | |
1038 | 1087 | /** |
1039 | 1088 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1064,13 +1113,14 @@ discard block |
||
1064 | 1113 | // Administrators are all powerful, sorry. |
1065 | 1114 | if ($user_info['is_admin']) |
1066 | 1115 | { |
1067 | - if ($simple) |
|
1068 | - return array(0); |
|
1069 | - else |
|
1116 | + if ($simple) { |
|
1117 | + return array(0); |
|
1118 | + } else |
|
1070 | 1119 | { |
1071 | 1120 | $boards = array(); |
1072 | - foreach ($permissions as $permission) |
|
1073 | - $boards[$permission] = array(0); |
|
1121 | + foreach ($permissions as $permission) { |
|
1122 | + $boards[$permission] = array(0); |
|
1123 | + } |
|
1074 | 1124 | |
1075 | 1125 | return $boards; |
1076 | 1126 | } |
@@ -1102,31 +1152,32 @@ discard block |
||
1102 | 1152 | { |
1103 | 1153 | if ($simple) |
1104 | 1154 | { |
1105 | - if (empty($row['add_deny'])) |
|
1106 | - $deny_boards[] = $row['id_board']; |
|
1107 | - else |
|
1108 | - $boards[] = $row['id_board']; |
|
1109 | - } |
|
1110 | - else |
|
1155 | + if (empty($row['add_deny'])) { |
|
1156 | + $deny_boards[] = $row['id_board']; |
|
1157 | + } else { |
|
1158 | + $boards[] = $row['id_board']; |
|
1159 | + } |
|
1160 | + } else |
|
1111 | 1161 | { |
1112 | - if (empty($row['add_deny'])) |
|
1113 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
1114 | - else |
|
1115 | - $boards[$row['permission']][] = $row['id_board']; |
|
1162 | + if (empty($row['add_deny'])) { |
|
1163 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
1164 | + } else { |
|
1165 | + $boards[$row['permission']][] = $row['id_board']; |
|
1166 | + } |
|
1116 | 1167 | } |
1117 | 1168 | } |
1118 | 1169 | $smcFunc['db_free_result']($request); |
1119 | 1170 | |
1120 | - if ($simple) |
|
1121 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1122 | - else |
|
1171 | + if ($simple) { |
|
1172 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1173 | + } else |
|
1123 | 1174 | { |
1124 | 1175 | foreach ($permissions as $permission) |
1125 | 1176 | { |
1126 | 1177 | // never had it to start with |
1127 | - if (empty($boards[$permission])) |
|
1128 | - $boards[$permission] = array(); |
|
1129 | - else |
|
1178 | + if (empty($boards[$permission])) { |
|
1179 | + $boards[$permission] = array(); |
|
1180 | + } else |
|
1130 | 1181 | { |
1131 | 1182 | // Or it may have been removed |
1132 | 1183 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1162,10 +1213,11 @@ discard block |
||
1162 | 1213 | |
1163 | 1214 | |
1164 | 1215 | // Moderators are free... |
1165 | - if (!allowedTo('moderate_board')) |
|
1166 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1167 | - else |
|
1168 | - $timeLimit = 2; |
|
1216 | + if (!allowedTo('moderate_board')) { |
|
1217 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1218 | + } else { |
|
1219 | + $timeLimit = 2; |
|
1220 | + } |
|
1169 | 1221 | |
1170 | 1222 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
1171 | 1223 | |
@@ -1192,8 +1244,9 @@ discard block |
||
1192 | 1244 | if ($smcFunc['db_affected_rows']() != 1) |
1193 | 1245 | { |
1194 | 1246 | // Spammer! You only have to wait a *few* seconds! |
1195 | - if (!$only_return_result) |
|
1196 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1247 | + if (!$only_return_result) { |
|
1248 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
1249 | + } |
|
1197 | 1250 | |
1198 | 1251 | return true; |
1199 | 1252 | } |
@@ -1211,11 +1264,13 @@ discard block |
||
1211 | 1264 | */ |
1212 | 1265 | function secureDirectory($path, $attachments = false) |
1213 | 1266 | { |
1214 | - if (empty($path)) |
|
1215 | - return 'empty_path'; |
|
1267 | + if (empty($path)) { |
|
1268 | + return 'empty_path'; |
|
1269 | + } |
|
1216 | 1270 | |
1217 | - if (!is_writable($path)) |
|
1218 | - return 'path_not_writable'; |
|
1271 | + if (!is_writable($path)) { |
|
1272 | + return 'path_not_writable'; |
|
1273 | + } |
|
1219 | 1274 | |
1220 | 1275 | $directoryname = basename($path); |
1221 | 1276 | |
@@ -1227,9 +1282,9 @@ discard block |
||
1227 | 1282 | |
1228 | 1283 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
1229 | 1284 | |
1230 | - if (file_exists($path . '/.htaccess')) |
|
1231 | - $errors[] = 'htaccess_exists'; |
|
1232 | - else |
|
1285 | + if (file_exists($path . '/.htaccess')) { |
|
1286 | + $errors[] = 'htaccess_exists'; |
|
1287 | + } else |
|
1233 | 1288 | { |
1234 | 1289 | $fh = @fopen($path . '/.htaccess', 'w'); |
1235 | 1290 | if ($fh) |
@@ -1242,9 +1297,9 @@ discard block |
||
1242 | 1297 | $errors[] = 'htaccess_cannot_create_file'; |
1243 | 1298 | } |
1244 | 1299 | |
1245 | - if (file_exists($path . '/index.php')) |
|
1246 | - $errors[] = 'index-php_exists'; |
|
1247 | - else |
|
1300 | + if (file_exists($path . '/index.php')) { |
|
1301 | + $errors[] = 'index-php_exists'; |
|
1302 | + } else |
|
1248 | 1303 | { |
1249 | 1304 | $fh = @fopen($path . '/index.php', 'w'); |
1250 | 1305 | if ($fh) |
@@ -1272,11 +1327,12 @@ discard block |
||
1272 | 1327 | $errors[] = 'index-php_cannot_create_file'; |
1273 | 1328 | } |
1274 | 1329 | |
1275 | - if (!empty($errors)) |
|
1276 | - return $errors; |
|
1277 | - else |
|
1278 | - return true; |
|
1279 | -} |
|
1330 | + if (!empty($errors)) { |
|
1331 | + return $errors; |
|
1332 | + } else { |
|
1333 | + return true; |
|
1334 | + } |
|
1335 | + } |
|
1280 | 1336 | |
1281 | 1337 | /** |
1282 | 1338 | * This sets the X-Frame-Options header. |
@@ -1289,14 +1345,16 @@ discard block |
||
1289 | 1345 | global $modSettings; |
1290 | 1346 | |
1291 | 1347 | $option = 'SAMEORIGIN'; |
1292 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
1293 | - $option = $modSettings['frame_security']; |
|
1294 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
1295 | - $option = $override; |
|
1348 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
1349 | + $option = $modSettings['frame_security']; |
|
1350 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
1351 | + $option = $override; |
|
1352 | + } |
|
1296 | 1353 | |
1297 | 1354 | // Don't bother setting the header if we have disabled it. |
1298 | - if ($option == 'DISABLE') |
|
1299 | - return; |
|
1355 | + if ($option == 'DISABLE') { |
|
1356 | + return; |
|
1357 | + } |
|
1300 | 1358 | |
1301 | 1359 | // Finally set it. |
1302 | 1360 | header('x-frame-options: ' . $option); |
@@ -328,7 +328,7 @@ |
||
328 | 328 | foreach ($context['error_info']['backtrace'] as $key => $value) |
329 | 329 | { |
330 | 330 | //Check for existing |
331 | - if (!property_exists($value,'file') || empty($value->file)) |
|
331 | + if (!property_exists($value, 'file') || empty($value->file)) |
|
332 | 332 | $value->file = $txt['unknown']; |
333 | 333 | if (!property_exists($value, 'line') || empty($value->line)) |
334 | 334 | $value->line = -1; |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $context, $txt; |
25 | 25 | |
26 | - if (!empty($context['simple_action'])) |
|
27 | - echo ' |
|
26 | + if (!empty($context['simple_action'])) { |
|
27 | + echo ' |
|
28 | 28 | <strong> |
29 | 29 | ', $context['error_title'], ' |
30 | 30 | </strong><br> |
31 | 31 | <div ', $context['error_code'], 'class="padding"> |
32 | 32 | ', $context['error_message'], ' |
33 | 33 | </div>'; |
34 | - else |
|
34 | + } else |
|
35 | 35 | { |
36 | 36 | echo ' |
37 | 37 | <div id="fatal_error"> |
@@ -85,21 +85,23 @@ discard block |
||
85 | 85 | |
86 | 86 | $error_types = array(); |
87 | 87 | |
88 | - foreach ($context['error_types'] as $type => $details) |
|
89 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
88 | + foreach ($context['error_types'] as $type => $details) { |
|
89 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
90 | + } |
|
90 | 91 | |
91 | 92 | echo ' |
92 | 93 | ', implode(' | ', $error_types), ' |
93 | 94 | </td> |
94 | 95 | </tr>'; |
95 | 96 | |
96 | - if ($context['has_filter']) |
|
97 | - echo ' |
|
97 | + if ($context['has_filter']) { |
|
98 | + echo ' |
|
98 | 99 | <tr> |
99 | 100 | <td colspan="3" class="windowbg"> |
100 | 101 | <strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
101 | 102 | </td> |
102 | 103 | </tr>'; |
104 | + } |
|
103 | 105 | |
104 | 106 | echo ' |
105 | 107 | <tr> |
@@ -110,11 +112,12 @@ discard block |
||
110 | 112 | </tr>'; |
111 | 113 | |
112 | 114 | // No errors, then show a message |
113 | - if (count($context['errors']) == 0) |
|
114 | - echo ' |
|
115 | + if (count($context['errors']) == 0) { |
|
116 | + echo ' |
|
115 | 117 | <tr class="windowbg"> |
116 | 118 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
117 | 119 | </tr>'; |
120 | + } |
|
118 | 121 | |
119 | 122 | // We have some errors, must be some mods installed :P |
120 | 123 | foreach ($context['errors'] as $error) |
@@ -128,16 +131,18 @@ discard block |
||
128 | 131 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
129 | 132 | ', $error['time'], '<br>'; |
130 | 133 | |
131 | - if (!empty($error['member']['ip'])) |
|
132 | - echo ' |
|
134 | + if (!empty($error['member']['ip'])) { |
|
135 | + echo ' |
|
133 | 136 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
134 | 137 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>'; |
138 | + } |
|
135 | 139 | |
136 | - if ($error['member']['session'] != '') |
|
137 | - echo ' |
|
140 | + if ($error['member']['session'] != '') { |
|
141 | + echo ' |
|
138 | 142 | <br> |
139 | 143 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
140 | 144 | ', $error['member']['session'], '<br>'; |
145 | + } |
|
141 | 146 | |
142 | 147 | echo ' |
143 | 148 | </div> |
@@ -152,12 +157,13 @@ discard block |
||
152 | 157 | <a href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
153 | 158 | '; |
154 | 159 | |
155 | - if (!empty($error['file'])) |
|
156 | - echo ' |
|
160 | + if (!empty($error['file'])) { |
|
161 | + echo ' |
|
157 | 162 | <div> |
158 | 163 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '">' |
159 | 164 | . ' <span class="generic_icons filter"></span></a> ', $error['file']['link'], ' (', $txt['line'], ' ', $error['file']['line'], ') |
160 | 165 | </div>'; |
166 | + } |
|
161 | 167 | |
162 | 168 | echo ' |
163 | 169 | </div> |
@@ -186,9 +192,10 @@ discard block |
||
186 | 192 | </div> |
187 | 193 | </div>'; |
188 | 194 | |
189 | - if ($context['sort_direction'] == 'down') |
|
190 | - echo ' |
|
195 | + if ($context['sort_direction'] == 'down') { |
|
196 | + echo ' |
|
191 | 197 | <input type="hidden" name="desc" value="1">'; |
198 | + } |
|
192 | 199 | |
193 | 200 | echo ' |
194 | 201 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -249,9 +256,10 @@ discard block |
||
249 | 256 | $context['error_message'], ' |
250 | 257 | </div>'; |
251 | 258 | |
252 | - if (!empty($context['back_link'])) |
|
253 | - echo ' |
|
259 | + if (!empty($context['back_link'])) { |
|
260 | + echo ' |
|
254 | 261 | <a class="button" href="', $scripturl, $context['back_link'], '">', $txt['back'], '</a>'; |
262 | + } |
|
255 | 263 | |
256 | 264 | echo ' |
257 | 265 | <span style="float: right; margin:.5em;"></span> |
@@ -288,25 +296,30 @@ discard block |
||
288 | 296 | <div class="windowbg"> |
289 | 297 | <ul class="padding">'; |
290 | 298 | |
291 | - if (!empty($context['error_info']['error_type'])) |
|
292 | - echo ' |
|
299 | + if (!empty($context['error_info']['error_type'])) { |
|
300 | + echo ' |
|
293 | 301 | <li>', $txt['error_type'], ': ', ucfirst($context['error_info']['error_type']), '</li>'; |
302 | + } |
|
294 | 303 | |
295 | - if (!empty($context['error_info']['message'])) |
|
296 | - echo ' |
|
304 | + if (!empty($context['error_info']['message'])) { |
|
305 | + echo ' |
|
297 | 306 | <li>', $txt['error_message'], ': ', $context['error_info']['message'], '</li>'; |
307 | + } |
|
298 | 308 | |
299 | - if (!empty($context['error_info']['file'])) |
|
300 | - echo ' |
|
309 | + if (!empty($context['error_info']['file'])) { |
|
310 | + echo ' |
|
301 | 311 | <li>', $txt['error_file'], ': ', $context['error_info']['file'], '</li>'; |
312 | + } |
|
302 | 313 | |
303 | - if (!empty($context['error_info']['line'])) |
|
304 | - echo ' |
|
314 | + if (!empty($context['error_info']['line'])) { |
|
315 | + echo ' |
|
305 | 316 | <li>', $txt['error_line'], ': ', $context['error_info']['line'], '</li>'; |
317 | + } |
|
306 | 318 | |
307 | - if (!empty($context['error_info']['url'])) |
|
308 | - echo ' |
|
319 | + if (!empty($context['error_info']['url'])) { |
|
320 | + echo ' |
|
309 | 321 | <li>', $txt['error_url'], ': ', $context['error_info']['url'], '</li>'; |
322 | + } |
|
310 | 323 | |
311 | 324 | |
312 | 325 | echo ' |
@@ -328,10 +341,12 @@ discard block |
||
328 | 341 | foreach ($context['error_info']['backtrace'] as $key => $value) |
329 | 342 | { |
330 | 343 | //Check for existing |
331 | - if (!property_exists($value,'file') || empty($value->file)) |
|
332 | - $value->file = $txt['unknown']; |
|
333 | - if (!property_exists($value, 'line') || empty($value->line)) |
|
334 | - $value->line = -1; |
|
344 | + if (!property_exists($value,'file') || empty($value->file)) { |
|
345 | + $value->file = $txt['unknown']; |
|
346 | + } |
|
347 | + if (!property_exists($value, 'line') || empty($value->line)) { |
|
348 | + $value->line = -1; |
|
349 | + } |
|
335 | 350 | |
336 | 351 | echo ' |
337 | 352 | <li class="backtrace">', sprintf($txt['backtrace_info'], $key, $value->function, $value->file, $value->line, base64_encode($value->file)), '</li>'; |
@@ -26,9 +26,10 @@ discard block |
||
26 | 26 | </div> |
27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
28 | 28 | |
29 | - if (empty($context['posts'])) |
|
30 | - echo ' |
|
29 | + if (empty($context['posts'])) { |
|
30 | + echo ' |
|
31 | 31 | <div class="windowbg">', $txt['no_messages'], '</div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | foreach ($context['posts'] as $post) |
34 | 35 | { |
@@ -41,28 +42,33 @@ discard block |
||
41 | 42 | </div> |
42 | 43 | <div class="list_posts">', $post['message'], '</div>'; |
43 | 44 | |
44 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
45 | - echo ' |
|
45 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
46 | + echo ' |
|
46 | 47 | <ul class="quickbuttons">'; |
48 | + } |
|
47 | 49 | |
48 | 50 | // If they *can* reply? |
49 | - if ($post['can_reply']) |
|
50 | - echo ' |
|
51 | + if ($post['can_reply']) { |
|
52 | + echo ' |
|
51 | 53 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
54 | + } |
|
52 | 55 | |
53 | 56 | // If they *can* quote? |
54 | - if ($post['can_quote']) |
|
55 | - echo ' |
|
57 | + if ($post['can_quote']) { |
|
58 | + echo ' |
|
56 | 59 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
60 | + } |
|
57 | 61 | |
58 | 62 | // How about... even... remove it entirely?! |
59 | - if ($post['can_delete']) |
|
60 | - echo ' |
|
63 | + if ($post['can_delete']) { |
|
64 | + echo ' |
|
61 | 65 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
66 | + } |
|
62 | 67 | |
63 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
64 | - echo ' |
|
68 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
69 | + echo ' |
|
65 | 70 | </ul>'; |
71 | + } |
|
66 | 72 | |
67 | 73 | echo ' |
68 | 74 | </div><!-- $post[css_class] -->'; |
@@ -83,12 +89,13 @@ discard block |
||
83 | 89 | echo ' |
84 | 90 | <div id="recent" class="main_content">'; |
85 | 91 | |
86 | - if ($context['showCheckboxes']) |
|
87 | - echo ' |
|
92 | + if ($context['showCheckboxes']) { |
|
93 | + echo ' |
|
88 | 94 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
89 | 95 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
90 | 96 | <input type="hidden" name="qaction" value="markread"> |
91 | 97 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
98 | + } |
|
92 | 99 | |
93 | 100 | if (!empty($context['topics'])) |
94 | 101 | { |
@@ -117,11 +124,12 @@ discard block |
||
117 | 124 | </div>'; |
118 | 125 | |
119 | 126 | // Show a "select all" box for quick moderation? |
120 | - if ($context['showCheckboxes']) |
|
121 | - echo ' |
|
127 | + if ($context['showCheckboxes']) { |
|
128 | + echo ' |
|
122 | 129 | <div class="moderation"> |
123 | 130 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
124 | 131 | </div>'; |
132 | + } |
|
125 | 133 | |
126 | 134 | echo ' |
127 | 135 | </div><!-- #topic_header --> |
@@ -141,17 +149,20 @@ discard block |
||
141 | 149 | echo ' |
142 | 150 | <div class="icons floatright">'; |
143 | 151 | |
144 | - if ($topic['is_locked']) |
|
145 | - echo ' |
|
152 | + if ($topic['is_locked']) { |
|
153 | + echo ' |
|
146 | 154 | <span class="generic_icons lock"></span>'; |
155 | + } |
|
147 | 156 | |
148 | - if ($topic['is_sticky']) |
|
149 | - echo ' |
|
157 | + if ($topic['is_sticky']) { |
|
158 | + echo ' |
|
150 | 159 | <span class="generic_icons sticky"></span>'; |
160 | + } |
|
151 | 161 | |
152 | - if ($topic['is_poll']) |
|
153 | - echo ' |
|
162 | + if ($topic['is_poll']) { |
|
163 | + echo ' |
|
154 | 164 | <span class="generic_icons poll"></span>'; |
165 | + } |
|
155 | 166 | |
156 | 167 | echo ' |
157 | 168 | </div>'; |
@@ -177,19 +188,21 @@ discard block |
||
177 | 188 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
178 | 189 | </div>'; |
179 | 190 | |
180 | - if ($context['showCheckboxes']) |
|
181 | - echo ' |
|
191 | + if ($context['showCheckboxes']) { |
|
192 | + echo ' |
|
182 | 193 | <div class="moderation"> |
183 | 194 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
184 | 195 | </div>'; |
196 | + } |
|
185 | 197 | |
186 | 198 | echo ' |
187 | 199 | </div><!-- $topic[css_class] -->'; |
188 | 200 | } |
189 | 201 | |
190 | - if (empty($context['topics'])) |
|
191 | - echo ' |
|
202 | + if (empty($context['topics'])) { |
|
203 | + echo ' |
|
192 | 204 | <div style="display: none;"></div>'; |
205 | + } |
|
193 | 206 | |
194 | 207 | echo ' |
195 | 208 | </div><!-- #topic_container --> |
@@ -204,25 +217,27 @@ discard block |
||
204 | 217 | ', $context['page_index'], ' |
205 | 218 | </div> |
206 | 219 | </div>'; |
207 | - } |
|
208 | - else |
|
209 | - echo ' |
|
220 | + } else { |
|
221 | + echo ' |
|
210 | 222 | <div class="cat_bar"> |
211 | 223 | <h3 class="catbg centertext"> |
212 | 224 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
213 | 225 | </h3> |
214 | 226 | </div>'; |
227 | + } |
|
215 | 228 | |
216 | - if ($context['showCheckboxes']) |
|
217 | - echo ' |
|
229 | + if ($context['showCheckboxes']) { |
|
230 | + echo ' |
|
218 | 231 | </form>'; |
232 | + } |
|
219 | 233 | |
220 | 234 | echo ' |
221 | 235 | </div><!-- #recent -->'; |
222 | 236 | |
223 | - if (empty($context['no_topic_listing'])) |
|
224 | - template_topic_legend(); |
|
225 | -} |
|
237 | + if (empty($context['no_topic_listing'])) { |
|
238 | + template_topic_legend(); |
|
239 | + } |
|
240 | + } |
|
226 | 241 | |
227 | 242 | /** |
228 | 243 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -234,12 +249,13 @@ discard block |
||
234 | 249 | echo ' |
235 | 250 | <div id="recent">'; |
236 | 251 | |
237 | - if ($context['showCheckboxes']) |
|
238 | - echo ' |
|
252 | + if ($context['showCheckboxes']) { |
|
253 | + echo ' |
|
239 | 254 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm"> |
240 | 255 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
241 | 256 | <input type="hidden" name="qaction" value="markread"> |
242 | 257 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
258 | + } |
|
243 | 259 | |
244 | 260 | if (!empty($context['topics'])) |
245 | 261 | { |
@@ -268,11 +284,12 @@ discard block |
||
268 | 284 | </div>'; |
269 | 285 | |
270 | 286 | // Show a "select all" box for quick moderation? |
271 | - if ($context['showCheckboxes']) |
|
272 | - echo ' |
|
287 | + if ($context['showCheckboxes']) { |
|
288 | + echo ' |
|
273 | 289 | <div class="moderation"> |
274 | 290 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
275 | 291 | </div>'; |
292 | + } |
|
276 | 293 | |
277 | 294 | echo ' |
278 | 295 | </div><!-- #topic_header --> |
@@ -292,17 +309,20 @@ discard block |
||
292 | 309 | echo ' |
293 | 310 | <div class="icons floatright">'; |
294 | 311 | |
295 | - if ($topic['is_locked']) |
|
296 | - echo ' |
|
312 | + if ($topic['is_locked']) { |
|
313 | + echo ' |
|
297 | 314 | <span class="generic_icons lock"></span>'; |
315 | + } |
|
298 | 316 | |
299 | - if ($topic['is_sticky']) |
|
300 | - echo ' |
|
317 | + if ($topic['is_sticky']) { |
|
318 | + echo ' |
|
301 | 319 | <span class="generic_icons sticky"></span>'; |
320 | + } |
|
302 | 321 | |
303 | - if ($topic['is_poll']) |
|
304 | - echo ' |
|
322 | + if ($topic['is_poll']) { |
|
323 | + echo ' |
|
305 | 324 | <span class="generic_icons poll"></span>'; |
325 | + } |
|
306 | 326 | |
307 | 327 | echo ' |
308 | 328 | </div>'; |
@@ -328,11 +348,12 @@ discard block |
||
328 | 348 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
329 | 349 | </div>'; |
330 | 350 | |
331 | - if ($context['showCheckboxes']) |
|
332 | - echo ' |
|
351 | + if ($context['showCheckboxes']) { |
|
352 | + echo ' |
|
333 | 353 | <div class="moderation"> |
334 | 354 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
335 | 355 | </div>'; |
356 | + } |
|
336 | 357 | |
337 | 358 | echo ' |
338 | 359 | </div><!-- $topic[css_class] -->'; |
@@ -349,24 +370,26 @@ discard block |
||
349 | 370 | ', $context['page_index'], ' |
350 | 371 | </div> |
351 | 372 | </div>'; |
352 | - } |
|
353 | - else |
|
354 | - echo ' |
|
373 | + } else { |
|
374 | + echo ' |
|
355 | 375 | <div class="cat_bar"> |
356 | 376 | <h3 class="catbg centertext"> |
357 | 377 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['updated_topics_visit_none'], ' |
358 | 378 | </h3> |
359 | 379 | </div>'; |
380 | + } |
|
360 | 381 | |
361 | - if ($context['showCheckboxes']) |
|
362 | - echo ' |
|
382 | + if ($context['showCheckboxes']) { |
|
383 | + echo ' |
|
363 | 384 | </form>'; |
385 | + } |
|
364 | 386 | |
365 | 387 | echo ' |
366 | 388 | </div><!-- #recent -->'; |
367 | 389 | |
368 | - if (empty($context['no_topic_listing'])) |
|
369 | - template_topic_legend(); |
|
370 | -} |
|
390 | + if (empty($context['no_topic_listing'])) { |
|
391 | + template_topic_legend(); |
|
392 | + } |
|
393 | + } |
|
371 | 394 | |
372 | 395 | ?> |
373 | 396 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | <div id="recent" class="main_section"> |
22 | 22 | <div class="cat_bar"> |
23 | 23 | <h3 class="catbg"> |
24 | - <span class="xx"></span>',$txt['recent_posts'],' |
|
24 | + <span class="xx"></span>',$txt['recent_posts'], ' |
|
25 | 25 | </h3> |
26 | 26 | </div> |
27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | <p class="floatleft"> |
165 | 165 | ', $topic['first_post']['started_by'], ' |
166 | 166 | </p> |
167 | - ', !empty($topic['pages']) ? '<span id="pages'.$topic['first_post']['id'].'" class="topic_pages">'.$topic['pages'].'</span>' : '', ' |
|
167 | + ', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', ' |
|
168 | 168 | </div><!-- .info --> |
169 | 169 | <div class="board_stats centertext"> |
170 | 170 | <p> |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | <p class="floatleft"> |
316 | 316 | ', $topic['first_post']['started_by'], ' |
317 | 317 | </p> |
318 | - ', !empty($topic['pages']) ? '<span id="pages'.$topic['first_post']['id'].'" class="topic_pages">'.$topic['pages'].'</span>' : '', ' |
|
318 | + ', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', ' |
|
319 | 319 | </div><!-- .info --> |
320 | 320 | <div class="board_stats centertext"> |
321 | 321 | <p> |
@@ -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 | * Check if the current directory is still valid or not. |
@@ -28,22 +29,24 @@ discard block |
||
28 | 29 | global $smcFunc, $boarddir, $modSettings, $context; |
29 | 30 | |
30 | 31 | // Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found. |
31 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') |
|
32 | - $doit = true; |
|
33 | - elseif (empty($modSettings['automanage_attachments'])) |
|
34 | - return; |
|
35 | - elseif (!isset($_FILES)) |
|
36 | - return; |
|
37 | - elseif (isset($_FILES['attachment'])) |
|
38 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
32 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') { |
|
33 | + $doit = true; |
|
34 | + } elseif (empty($modSettings['automanage_attachments'])) { |
|
35 | + return; |
|
36 | + } elseif (!isset($_FILES)) { |
|
37 | + return; |
|
38 | + } elseif (isset($_FILES['attachment'])) { |
|
39 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
39 | 40 | if (!empty($dummy)) |
40 | 41 | { |
41 | 42 | $doit = true; |
43 | + } |
|
42 | 44 | break; |
43 | 45 | } |
44 | 46 | |
45 | - if (!isset($doit)) |
|
46 | - return; |
|
47 | + if (!isset($doit)) { |
|
48 | + return; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | $year = date('Y'); |
49 | 52 | $month = date('m'); |
@@ -54,21 +57,25 @@ discard block |
||
54 | 57 | |
55 | 58 | if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments'])) |
56 | 59 | { |
57 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
58 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
60 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
61 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
62 | + } |
|
59 | 63 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
64 | + } else { |
|
65 | + $base_dir = 0; |
|
60 | 66 | } |
61 | - else |
|
62 | - $base_dir = 0; |
|
63 | 67 | |
64 | 68 | if ($modSettings['automanage_attachments'] == 1) |
65 | 69 | { |
66 | - if (!isset($modSettings['last_attachments_directory'])) |
|
67 | - $modSettings['last_attachments_directory'] = array(); |
|
68 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
69 | - $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
70 | - if (!isset($modSettings['last_attachments_directory'][$base_dir])) |
|
71 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
70 | + if (!isset($modSettings['last_attachments_directory'])) { |
|
71 | + $modSettings['last_attachments_directory'] = array(); |
|
72 | + } |
|
73 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
74 | + $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
75 | + } |
|
76 | + if (!isset($modSettings['last_attachments_directory'][$base_dir])) { |
|
77 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
78 | + } |
|
72 | 79 | } |
73 | 80 | |
74 | 81 | $basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
@@ -97,12 +104,14 @@ discard block |
||
97 | 104 | $updir = ''; |
98 | 105 | } |
99 | 106 | |
100 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
101 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
102 | - if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) |
|
103 | - $outputCreation = automanage_attachments_create_directory($updir); |
|
104 | - elseif (in_array($updir, $modSettings['attachmentUploadDir'])) |
|
105 | - $outputCreation = true; |
|
107 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
108 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
109 | + } |
|
110 | + if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) { |
|
111 | + $outputCreation = automanage_attachments_create_directory($updir); |
|
112 | + } elseif (in_array($updir, $modSettings['attachmentUploadDir'])) { |
|
113 | + $outputCreation = true; |
|
114 | + } |
|
106 | 115 | |
107 | 116 | if ($outputCreation) |
108 | 117 | { |
@@ -139,8 +148,9 @@ discard block |
||
139 | 148 | $count = count($tree); |
140 | 149 | |
141 | 150 | $directory = attachments_init_dir($tree, $count); |
142 | - if ($directory === false) |
|
143 | - return false; |
|
151 | + if ($directory === false) { |
|
152 | + return false; |
|
153 | + } |
|
144 | 154 | } |
145 | 155 | |
146 | 156 | $directory .= DIRECTORY_SEPARATOR . array_shift($tree); |
@@ -168,8 +178,9 @@ discard block |
||
168 | 178 | } |
169 | 179 | |
170 | 180 | // Everything seems fine...let's create the .htaccess |
171 | - if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) |
|
172 | - secureDirectory($updir, true); |
|
181 | + if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) { |
|
182 | + secureDirectory($updir, true); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | $sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR; |
175 | 186 | $updir = rtrim($updir, $sep); |
@@ -201,8 +212,9 @@ discard block |
||
201 | 212 | { |
202 | 213 | global $smcFunc, $modSettings, $boarddir; |
203 | 214 | |
204 | - if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) |
|
205 | - return; |
|
215 | + if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) { |
|
216 | + return; |
|
217 | + } |
|
206 | 218 | |
207 | 219 | $basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir; |
208 | 220 | // Just to be sure: I don't want directory separators at the end |
@@ -214,13 +226,14 @@ discard block |
||
214 | 226 | { |
215 | 227 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
216 | 228 | $base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0; |
229 | + } else { |
|
230 | + $base_dir = 0; |
|
217 | 231 | } |
218 | - else |
|
219 | - $base_dir = 0; |
|
220 | 232 | |
221 | 233 | // Get the last attachment directory for that base directory |
222 | - if (empty($modSettings['last_attachments_directory'][$base_dir])) |
|
223 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
234 | + if (empty($modSettings['last_attachments_directory'][$base_dir])) { |
|
235 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
236 | + } |
|
224 | 237 | // And increment it. |
225 | 238 | $modSettings['last_attachments_directory'][$base_dir]++; |
226 | 239 | |
@@ -235,10 +248,10 @@ discard block |
||
235 | 248 | $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
236 | 249 | |
237 | 250 | return true; |
251 | + } else { |
|
252 | + return false; |
|
253 | + } |
|
238 | 254 | } |
239 | - else |
|
240 | - return false; |
|
241 | -} |
|
242 | 255 | |
243 | 256 | /** |
244 | 257 | * Split a path into a list of all directories and subdirectories |
@@ -256,12 +269,13 @@ discard block |
||
256 | 269 | * in Windows we need to explode for both \ and / |
257 | 270 | * while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR) |
258 | 271 | */ |
259 | - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') |
|
260 | - $tree = preg_split('#[\\\/]#', $directory); |
|
261 | - else |
|
272 | + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
273 | + $tree = preg_split('#[\\\/]#', $directory); |
|
274 | + } else |
|
262 | 275 | { |
263 | - if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) |
|
264 | - return false; |
|
276 | + if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) { |
|
277 | + return false; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | $tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR)); |
267 | 281 | } |
@@ -285,10 +299,11 @@ discard block |
||
285 | 299 | //Better be sure that the first part of the path is actually a drive letter... |
286 | 300 | //...even if, I should check this in the admin page...isn't it? |
287 | 301 | //...NHAAA Let's leave space for users' complains! :P |
288 | - if (preg_match('/^[a-z]:$/i', $tree[0])) |
|
289 | - $directory = array_shift($tree); |
|
290 | - else |
|
291 | - return false; |
|
302 | + if (preg_match('/^[a-z]:$/i', $tree[0])) { |
|
303 | + $directory = array_shift($tree); |
|
304 | + } else { |
|
305 | + return false; |
|
306 | + } |
|
292 | 307 | |
293 | 308 | $count--; |
294 | 309 | } |
@@ -303,18 +318,20 @@ discard block |
||
303 | 318 | global $context, $modSettings, $smcFunc, $txt, $user_info; |
304 | 319 | |
305 | 320 | // Make sure we're uploading to the right place. |
306 | - if (!empty($modSettings['automanage_attachments'])) |
|
307 | - automanage_attachments_check_directory(); |
|
321 | + if (!empty($modSettings['automanage_attachments'])) { |
|
322 | + automanage_attachments_check_directory(); |
|
323 | + } |
|
308 | 324 | |
309 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
310 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
325 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
326 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
327 | + } |
|
311 | 328 | |
312 | 329 | $context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
313 | 330 | |
314 | 331 | // Is the attachments folder actualy there? |
315 | - if (!empty($context['dir_creation_error'])) |
|
316 | - $initial_error = $context['dir_creation_error']; |
|
317 | - elseif (!is_dir($context['attach_dir'])) |
|
332 | + if (!empty($context['dir_creation_error'])) { |
|
333 | + $initial_error = $context['dir_creation_error']; |
|
334 | + } elseif (!is_dir($context['attach_dir'])) |
|
318 | 335 | { |
319 | 336 | $initial_error = 'attach_folder_warning'; |
320 | 337 | log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical'); |
@@ -337,12 +354,12 @@ discard block |
||
337 | 354 | ); |
338 | 355 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
339 | 356 | $smcFunc['db_free_result']($request); |
340 | - } |
|
341 | - else |
|
342 | - $context['attachments'] = array( |
|
357 | + } else { |
|
358 | + $context['attachments'] = array( |
|
343 | 359 | 'quantity' => 0, |
344 | 360 | 'total_size' => 0, |
345 | 361 | ); |
362 | + } |
|
346 | 363 | } |
347 | 364 | |
348 | 365 | // Hmm. There are still files in session. |
@@ -352,39 +369,44 @@ discard block |
||
352 | 369 | // Let's try to keep them. But... |
353 | 370 | $ignore_temp = true; |
354 | 371 | // If new files are being added. We can't ignore those |
355 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
356 | - if (!empty($dummy)) |
|
372 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) { |
|
373 | + if (!empty($dummy)) |
|
357 | 374 | { |
358 | 375 | $ignore_temp = false; |
376 | + } |
|
359 | 377 | break; |
360 | 378 | } |
361 | 379 | |
362 | 380 | // Need to make space for the new files. So, bye bye. |
363 | 381 | if (!$ignore_temp) |
364 | 382 | { |
365 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
366 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
383 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
384 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
367 | 385 | unlink($attachment['tmp_name']); |
386 | + } |
|
368 | 387 | |
369 | 388 | $context['we_are_history'] = $txt['error_temp_attachments_flushed']; |
370 | 389 | $_SESSION['temp_attachments'] = array(); |
371 | 390 | } |
372 | 391 | } |
373 | 392 | |
374 | - if (!isset($_FILES['attachment']['name'])) |
|
375 | - $_FILES['attachment']['tmp_name'] = array(); |
|
393 | + if (!isset($_FILES['attachment']['name'])) { |
|
394 | + $_FILES['attachment']['tmp_name'] = array(); |
|
395 | + } |
|
376 | 396 | |
377 | - if (!isset($_SESSION['temp_attachments'])) |
|
378 | - $_SESSION['temp_attachments'] = array(); |
|
397 | + if (!isset($_SESSION['temp_attachments'])) { |
|
398 | + $_SESSION['temp_attachments'] = array(); |
|
399 | + } |
|
379 | 400 | |
380 | 401 | // Remember where we are at. If it's anywhere at all. |
381 | - if (!$ignore_temp) |
|
382 | - $_SESSION['temp_attachments']['post'] = array( |
|
402 | + if (!$ignore_temp) { |
|
403 | + $_SESSION['temp_attachments']['post'] = array( |
|
383 | 404 | 'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0, |
384 | 405 | 'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0, |
385 | 406 | 'topic' => !empty($topic) ? $topic : 0, |
386 | 407 | 'board' => !empty($board) ? $board : 0, |
387 | 408 | ); |
409 | + } |
|
388 | 410 | |
389 | 411 | // If we have an initial error, lets just display it. |
390 | 412 | if (!empty($initial_error)) |
@@ -392,9 +414,10 @@ discard block |
||
392 | 414 | $_SESSION['temp_attachments']['initial_error'] = $initial_error; |
393 | 415 | |
394 | 416 | // And delete the files 'cos they ain't going nowhere. |
395 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
396 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
417 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
418 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
397 | 419 | unlink($_FILES['attachment']['tmp_name'][$n]); |
420 | + } |
|
398 | 421 | |
399 | 422 | $_FILES['attachment']['tmp_name'] = array(); |
400 | 423 | } |
@@ -402,21 +425,24 @@ discard block |
||
402 | 425 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
403 | 426 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
404 | 427 | { |
405 | - if ($_FILES['attachment']['name'][$n] == '') |
|
406 | - continue; |
|
428 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
429 | + continue; |
|
430 | + } |
|
407 | 431 | |
408 | 432 | // First, let's first check for PHP upload errors. |
409 | 433 | $errors = array(); |
410 | 434 | if (!empty($_FILES['attachment']['error'][$n])) |
411 | 435 | { |
412 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
413 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
414 | - elseif ($_FILES['attachment']['error'][$n] == 6) |
|
415 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
416 | - else |
|
417 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
418 | - if (empty($errors)) |
|
419 | - $errors[] = 'attach_php_error'; |
|
436 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
437 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
438 | + } elseif ($_FILES['attachment']['error'][$n] == 6) { |
|
439 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
440 | + } else { |
|
441 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
442 | + } |
|
443 | + if (empty($errors)) { |
|
444 | + $errors[] = 'attach_php_error'; |
|
445 | + } |
|
420 | 446 | } |
421 | 447 | |
422 | 448 | // Try to move and rename the file before doing any more checks on it. |
@@ -426,8 +452,9 @@ discard block |
||
426 | 452 | { |
427 | 453 | // The reported MIME type of the attachment might not be reliable. |
428 | 454 | // Fortunately, PHP 5.3+ lets us easily verify the real MIME type. |
429 | - if (function_exists('mime_content_type')) |
|
430 | - $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
455 | + if (function_exists('mime_content_type')) { |
|
456 | + $_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]); |
|
457 | + } |
|
431 | 458 | |
432 | 459 | $_SESSION['temp_attachments'][$attachID] = array( |
433 | 460 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -439,16 +466,16 @@ discard block |
||
439 | 466 | ); |
440 | 467 | |
441 | 468 | // Move the file to the attachments folder with a temp name for now. |
442 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
443 | - smf_chmod($destName, 0644); |
|
444 | - else |
|
469 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
470 | + smf_chmod($destName, 0644); |
|
471 | + } else |
|
445 | 472 | { |
446 | 473 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
447 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
448 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
474 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
475 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
476 | + } |
|
449 | 477 | } |
450 | - } |
|
451 | - else |
|
478 | + } else |
|
452 | 479 | { |
453 | 480 | $_SESSION['temp_attachments'][$attachID] = array( |
454 | 481 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -456,12 +483,14 @@ discard block |
||
456 | 483 | 'errors' => $errors, |
457 | 484 | ); |
458 | 485 | |
459 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
460 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
486 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
487 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
488 | + } |
|
461 | 489 | } |
462 | 490 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
463 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
464 | - attachmentChecks($attachID); |
|
491 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
492 | + attachmentChecks($attachID); |
|
493 | + } |
|
465 | 494 | } |
466 | 495 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
467 | 496 | // Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand()) |
@@ -488,21 +517,20 @@ discard block |
||
488 | 517 | global $modSettings, $context, $sourcedir, $smcFunc; |
489 | 518 | |
490 | 519 | // No data or missing data .... Not necessarily needed, but in case a mod author missed something. |
491 | - if (empty($_SESSION['temp_attachments'][$attachID])) |
|
492 | - $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
493 | - |
|
494 | - elseif (empty($attachID)) |
|
495 | - $error = '$attachID'; |
|
496 | - |
|
497 | - elseif (empty($context['attachments'])) |
|
498 | - $error = '$context[\'attachments\']'; |
|
499 | - |
|
500 | - elseif (empty($context['attach_dir'])) |
|
501 | - $error = '$context[\'attach_dir\']'; |
|
520 | + if (empty($_SESSION['temp_attachments'][$attachID])) { |
|
521 | + $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
522 | + } elseif (empty($attachID)) { |
|
523 | + $error = '$attachID'; |
|
524 | + } elseif (empty($context['attachments'])) { |
|
525 | + $error = '$context[\'attachments\']'; |
|
526 | + } elseif (empty($context['attach_dir'])) { |
|
527 | + $error = '$context[\'attach_dir\']'; |
|
528 | + } |
|
502 | 529 | |
503 | 530 | // Let's get their attention. |
504 | - if (!empty($error)) |
|
505 | - fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
531 | + if (!empty($error)) { |
|
532 | + fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
533 | + } |
|
506 | 534 | |
507 | 535 | // Just in case this slipped by the first checks, we stop it here and now |
508 | 536 | if ($_SESSION['temp_attachments'][$attachID]['size'] == 0) |
@@ -531,8 +559,9 @@ discard block |
||
531 | 559 | $size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']); |
532 | 560 | if (!(empty($size)) && ($size[2] != $old_format)) |
533 | 561 | { |
534 | - if (isset($context['valid_image_types'][$size[2]])) |
|
535 | - $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
562 | + if (isset($context['valid_image_types'][$size[2]])) { |
|
563 | + $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
564 | + } |
|
536 | 565 | } |
537 | 566 | } |
538 | 567 | } |
@@ -586,42 +615,48 @@ discard block |
||
586 | 615 | // Or, let the user know that it ain't gonna happen. |
587 | 616 | else |
588 | 617 | { |
589 | - if (isset($context['dir_creation_error'])) |
|
590 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
591 | - else |
|
592 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
618 | + if (isset($context['dir_creation_error'])) { |
|
619 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
620 | + } else { |
|
621 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
622 | + } |
|
593 | 623 | } |
624 | + } else { |
|
625 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
594 | 626 | } |
595 | - else |
|
596 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
597 | 627 | } |
598 | 628 | } |
599 | 629 | |
600 | 630 | // Is the file too big? |
601 | 631 | $context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size']; |
602 | - if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) |
|
603 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
632 | + if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) { |
|
633 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
634 | + } |
|
604 | 635 | |
605 | 636 | // Check the total upload size for this post... |
606 | - if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) |
|
607 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
637 | + if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) { |
|
638 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
639 | + } |
|
608 | 640 | |
609 | 641 | // Have we reached the maximum number of files we are allowed? |
610 | 642 | $context['attachments']['quantity']++; |
611 | 643 | |
612 | 644 | // Set a max limit if none exists |
613 | - if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) |
|
614 | - $modSettings['attachmentNumPerPostLimit'] = 50; |
|
645 | + if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) { |
|
646 | + $modSettings['attachmentNumPerPostLimit'] = 50; |
|
647 | + } |
|
615 | 648 | |
616 | - if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) |
|
617 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
649 | + if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) { |
|
650 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
651 | + } |
|
618 | 652 | |
619 | 653 | // File extension check |
620 | 654 | if (!empty($modSettings['attachmentCheckExtensions'])) |
621 | 655 | { |
622 | 656 | $allowed = explode(',', strtolower($modSettings['attachmentExtensions'])); |
623 | - foreach ($allowed as $k => $dummy) |
|
624 | - $allowed[$k] = trim($dummy); |
|
657 | + foreach ($allowed as $k => $dummy) { |
|
658 | + $allowed[$k] = trim($dummy); |
|
659 | + } |
|
625 | 660 | |
626 | 661 | if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed)) |
627 | 662 | { |
@@ -633,10 +668,12 @@ discard block |
||
633 | 668 | // Undo the math if there's an error |
634 | 669 | if (!empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
635 | 670 | { |
636 | - if (isset($context['dir_size'])) |
|
637 | - $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
638 | - if (isset($context['dir_files'])) |
|
639 | - $context['dir_files']--; |
|
671 | + if (isset($context['dir_size'])) { |
|
672 | + $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
673 | + } |
|
674 | + if (isset($context['dir_files'])) { |
|
675 | + $context['dir_files']--; |
|
676 | + } |
|
640 | 677 | $context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
641 | 678 | $context['attachments']['quantity']--; |
642 | 679 | return false; |
@@ -668,12 +705,14 @@ discard block |
||
668 | 705 | if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width']) |
669 | 706 | { |
670 | 707 | // Got a proper mime type? |
671 | - if (!empty($size['mime'])) |
|
672 | - $attachmentOptions['mime_type'] = $size['mime']; |
|
708 | + if (!empty($size['mime'])) { |
|
709 | + $attachmentOptions['mime_type'] = $size['mime']; |
|
710 | + } |
|
673 | 711 | |
674 | 712 | // Otherwise a valid one? |
675 | - elseif (isset($context['valid_image_types'][$size[2]])) |
|
676 | - $attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
713 | + elseif (isset($context['valid_image_types'][$size[2]])) { |
|
714 | + $attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]]; |
|
715 | + } |
|
677 | 716 | } |
678 | 717 | |
679 | 718 | // It is possible we might have a MIME type that isn't actually an image but still have a size. |
@@ -685,15 +724,17 @@ discard block |
||
685 | 724 | } |
686 | 725 | |
687 | 726 | // Get the hash if no hash has been given yet. |
688 | - if (empty($attachmentOptions['file_hash'])) |
|
689 | - $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
727 | + if (empty($attachmentOptions['file_hash'])) { |
|
728 | + $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
729 | + } |
|
690 | 730 | |
691 | 731 | // Assuming no-one set the extension let's take a look at it. |
692 | 732 | if (empty($attachmentOptions['fileext'])) |
693 | 733 | { |
694 | 734 | $attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : ''); |
695 | - if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) |
|
696 | - $attachmentOptions['fileext'] = ''; |
|
735 | + if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) { |
|
736 | + $attachmentOptions['fileext'] = ''; |
|
737 | + } |
|
697 | 738 | } |
698 | 739 | |
699 | 740 | // Last chance to change stuff! |
@@ -702,8 +743,9 @@ discard block |
||
702 | 743 | // Make sure the folder is valid... |
703 | 744 | $tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
704 | 745 | $folders = array_keys($tmp); |
705 | - if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) |
|
706 | - $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
746 | + if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) { |
|
747 | + $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
748 | + } |
|
707 | 749 | |
708 | 750 | $attachmentOptions['id'] = $smcFunc['db_insert']('', |
709 | 751 | '{db_prefix}attachments', |
@@ -734,8 +776,8 @@ discard block |
||
734 | 776 | rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']); |
735 | 777 | |
736 | 778 | // If it's not approved then add to the approval queue. |
737 | - if (!$attachmentOptions['approved']) |
|
738 | - $smcFunc['db_insert']('', |
|
779 | + if (!$attachmentOptions['approved']) { |
|
780 | + $smcFunc['db_insert']('', |
|
739 | 781 | '{db_prefix}approval_queue', |
740 | 782 | array( |
741 | 783 | 'id_attach' => 'int', 'id_msg' => 'int', |
@@ -745,9 +787,11 @@ discard block |
||
745 | 787 | ), |
746 | 788 | array() |
747 | 789 | ); |
790 | + } |
|
748 | 791 | |
749 | - if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) |
|
750 | - return true; |
|
792 | + if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) { |
|
793 | + return true; |
|
794 | + } |
|
751 | 795 | |
752 | 796 | // Like thumbnails, do we? |
753 | 797 | if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight'])) |
@@ -758,13 +802,15 @@ discard block |
||
758 | 802 | $size = @getimagesize($attachmentOptions['destination'] . '_thumb'); |
759 | 803 | list ($thumb_width, $thumb_height) = $size; |
760 | 804 | |
761 | - if (!empty($size['mime'])) |
|
762 | - $thumb_mime = $size['mime']; |
|
763 | - elseif (isset($context['valid_image_types'][$size[2]])) |
|
764 | - $thumb_mime = 'image/' . $context['valid_image_types'][$size[2]]; |
|
805 | + if (!empty($size['mime'])) { |
|
806 | + $thumb_mime = $size['mime']; |
|
807 | + } elseif (isset($context['valid_image_types'][$size[2]])) { |
|
808 | + $thumb_mime = 'image/' . $context['valid_image_types'][$size[2]]; |
|
809 | + } |
|
765 | 810 | // Lord only knows how this happened... |
766 | - else |
|
767 | - $thumb_mime = ''; |
|
811 | + else { |
|
812 | + $thumb_mime = ''; |
|
813 | + } |
|
768 | 814 | |
769 | 815 | $thumb_filename = $attachmentOptions['name'] . '_thumb'; |
770 | 816 | $thumb_size = filesize($attachmentOptions['destination'] . '_thumb'); |
@@ -844,15 +890,17 @@ discard block |
||
844 | 890 | global $smcFunc; |
845 | 891 | |
846 | 892 | // Oh, come on! |
847 | - if (empty($attachIDs) || empty($msgID)) |
|
848 | - return false; |
|
893 | + if (empty($attachIDs) || empty($msgID)) { |
|
894 | + return false; |
|
895 | + } |
|
849 | 896 | |
850 | 897 | // "I see what is right and approve, but I do what is wrong." |
851 | 898 | call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID)); |
852 | 899 | |
853 | 900 | // One last check |
854 | - if (empty($attachIDs)) |
|
855 | - return false; |
|
901 | + if (empty($attachIDs)) { |
|
902 | + return false; |
|
903 | + } |
|
856 | 904 | |
857 | 905 | // Perform. |
858 | 906 | $smcFunc['db_query']('', ' |
@@ -880,8 +928,9 @@ discard block |
||
880 | 928 | global $board, $modSettings, $context, $scripturl, $smcFunc; |
881 | 929 | |
882 | 930 | // Meh... |
883 | - if (empty($attachID)) |
|
884 | - return 'attachments_no_data_loaded'; |
|
931 | + if (empty($attachID)) { |
|
932 | + return 'attachments_no_data_loaded'; |
|
933 | + } |
|
885 | 934 | |
886 | 935 | // Make it easy. |
887 | 936 | $msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0; |
@@ -890,20 +939,23 @@ discard block |
||
890 | 939 | $externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID)); |
891 | 940 | |
892 | 941 | // "I am innocent of the blood of this just person: see ye to it." |
893 | - if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) |
|
894 | - return $externalParse; |
|
942 | + if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) { |
|
943 | + return $externalParse; |
|
944 | + } |
|
895 | 945 | |
896 | 946 | //Are attachments enable? |
897 | - if (empty($modSettings['attachmentEnable'])) |
|
898 | - return 'attachments_not_enable'; |
|
947 | + if (empty($modSettings['attachmentEnable'])) { |
|
948 | + return 'attachments_not_enable'; |
|
949 | + } |
|
899 | 950 | |
900 | 951 | // Previewing much? no msg ID has been set yet. |
901 | 952 | if (!empty($context['preview_message'])) |
902 | 953 | { |
903 | 954 | $allAttachments = getAttachsByMsg(0); |
904 | 955 | |
905 | - if (empty($allAttachments[0][$attachID])) |
|
906 | - return 'attachments_no_data_loaded'; |
|
956 | + if (empty($allAttachments[0][$attachID])) { |
|
957 | + return 'attachments_no_data_loaded'; |
|
958 | + } |
|
907 | 959 | |
908 | 960 | $attachLoaded = loadAttachmentContext(0, $allAttachments); |
909 | 961 | |
@@ -915,57 +967,66 @@ discard block |
||
915 | 967 | $attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>'; |
916 | 968 | |
917 | 969 | // Fix the thumbnail too, if the image has one. |
918 | - if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) |
|
919 | - $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
970 | + if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) { |
|
971 | + $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
972 | + } |
|
920 | 973 | |
921 | 974 | return $attachContext; |
922 | 975 | } |
923 | 976 | |
924 | 977 | // There is always the chance someone else has already done our dirty work... |
925 | 978 | // If so, all pertinent checks were already done. Hopefully... |
926 | - if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) |
|
927 | - return $context['current_attachments'][$attachID]; |
|
979 | + if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) { |
|
980 | + return $context['current_attachments'][$attachID]; |
|
981 | + } |
|
928 | 982 | |
929 | 983 | // If we are lucky enough to be in $board's scope then check it! |
930 | - if (!empty($board) && !allowedTo('view_attachments', $board)) |
|
931 | - return 'attachments_not_allowed_to_see'; |
|
984 | + if (!empty($board) && !allowedTo('view_attachments', $board)) { |
|
985 | + return 'attachments_not_allowed_to_see'; |
|
986 | + } |
|
932 | 987 | |
933 | 988 | // Get the message info associated with this particular attach ID. |
934 | 989 | $attachInfo = getAttachMsgInfo($attachID); |
935 | 990 | |
936 | 991 | // There is always the chance this attachment no longer exists or isn't associated to a message anymore... |
937 | - if (empty($attachInfo) || empty($attachInfo['msg'])) |
|
938 | - return 'attachments_no_msg_associated'; |
|
992 | + if (empty($attachInfo) || empty($attachInfo['msg'])) { |
|
993 | + return 'attachments_no_msg_associated'; |
|
994 | + } |
|
939 | 995 | |
940 | 996 | // Hold it! got the info now check if you can see this attachment. |
941 | - if (!allowedTo('view_attachments', $attachInfo['board'])) |
|
942 | - return 'attachments_not_allowed_to_see'; |
|
997 | + if (!allowedTo('view_attachments', $attachInfo['board'])) { |
|
998 | + return 'attachments_not_allowed_to_see'; |
|
999 | + } |
|
943 | 1000 | |
944 | 1001 | $allAttachments = getAttachsByMsg($attachInfo['msg']); |
945 | 1002 | $attachContext = $allAttachments[$attachInfo['msg']][$attachID]; |
946 | 1003 | |
947 | 1004 | // No point in keep going further. |
948 | - if (!allowedTo('view_attachments', $attachContext['board'])) |
|
949 | - return 'attachments_not_allowed_to_see'; |
|
1005 | + if (!allowedTo('view_attachments', $attachContext['board'])) { |
|
1006 | + return 'attachments_not_allowed_to_see'; |
|
1007 | + } |
|
950 | 1008 | |
951 | 1009 | // Load this particular attach's context. |
952 | - if (!empty($attachContext)) |
|
953 | - $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1010 | + if (!empty($attachContext)) { |
|
1011 | + $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1012 | + } |
|
954 | 1013 | |
955 | 1014 | // One last check, you know, gotta be paranoid... |
956 | - else |
|
957 | - return 'attachments_no_data_loaded'; |
|
1015 | + else { |
|
1016 | + return 'attachments_no_data_loaded'; |
|
1017 | + } |
|
958 | 1018 | |
959 | 1019 | // This is the last "if" I promise! |
960 | - if (empty($attachLoaded)) |
|
961 | - return 'attachments_no_data_loaded'; |
|
962 | - |
|
963 | - else |
|
964 | - $attachContext = $attachLoaded[$attachID]; |
|
1020 | + if (empty($attachLoaded)) { |
|
1021 | + return 'attachments_no_data_loaded'; |
|
1022 | + } else { |
|
1023 | + $attachContext = $attachLoaded[$attachID]; |
|
1024 | + } |
|
965 | 1025 | |
966 | 1026 | // You may or may not want to show this under the post. |
967 | - if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) |
|
968 | - $context['show_attach_under_post'][$attachID] = $attachID; |
|
1027 | + if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) { |
|
1028 | + $context['show_attach_under_post'][$attachID] = $attachID; |
|
1029 | + } |
|
969 | 1030 | |
970 | 1031 | // Last minute changes? |
971 | 1032 | call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext)); |
@@ -985,8 +1046,9 @@ discard block |
||
985 | 1046 | { |
986 | 1047 | global $smcFunc, $modSettings; |
987 | 1048 | |
988 | - if (empty($attachIDs)) |
|
989 | - return array(); |
|
1049 | + if (empty($attachIDs)) { |
|
1050 | + return array(); |
|
1051 | + } |
|
990 | 1052 | |
991 | 1053 | $return = array(); |
992 | 1054 | |
@@ -1002,11 +1064,12 @@ discard block |
||
1002 | 1064 | ) |
1003 | 1065 | ); |
1004 | 1066 | |
1005 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1006 | - return array(); |
|
1067 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1068 | + return array(); |
|
1069 | + } |
|
1007 | 1070 | |
1008 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1009 | - $return[$row['id_attach']] = array( |
|
1071 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1072 | + $return[$row['id_attach']] = array( |
|
1010 | 1073 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
1011 | 1074 | 'size' => $row['size'], |
1012 | 1075 | 'attachID' => $row['id_attach'], |
@@ -1015,6 +1078,7 @@ discard block |
||
1015 | 1078 | 'mime_type' => $row['mime_type'], |
1016 | 1079 | 'thumb' => $row['id_thumb'], |
1017 | 1080 | ); |
1081 | + } |
|
1018 | 1082 | $smcFunc['db_free_result']($request); |
1019 | 1083 | |
1020 | 1084 | return $return; |
@@ -1031,8 +1095,9 @@ discard block |
||
1031 | 1095 | { |
1032 | 1096 | global $smcFunc; |
1033 | 1097 | |
1034 | - if (empty($attachID)) |
|
1035 | - return array(); |
|
1098 | + if (empty($attachID)) { |
|
1099 | + return array(); |
|
1100 | + } |
|
1036 | 1101 | |
1037 | 1102 | $request = $smcFunc['db_query']('', ' |
1038 | 1103 | SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board |
@@ -1045,8 +1110,9 @@ discard block |
||
1045 | 1110 | ) |
1046 | 1111 | ); |
1047 | 1112 | |
1048 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1049 | - return array(); |
|
1113 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1114 | + return array(); |
|
1115 | + } |
|
1050 | 1116 | |
1051 | 1117 | $row = $smcFunc['db_fetch_assoc']($request); |
1052 | 1118 | $smcFunc['db_free_result']($request); |
@@ -1087,8 +1153,9 @@ discard block |
||
1087 | 1153 | $temp = array(); |
1088 | 1154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1089 | 1155 | { |
1090 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1091 | - continue; |
|
1156 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1157 | + continue; |
|
1158 | + } |
|
1092 | 1159 | |
1093 | 1160 | $temp[$row['id_attach']] = $row; |
1094 | 1161 | } |
@@ -1117,8 +1184,9 @@ discard block |
||
1117 | 1184 | { |
1118 | 1185 | global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc; |
1119 | 1186 | |
1120 | - if (empty($attachments) || empty($attachments[$id_msg])) |
|
1121 | - return array(); |
|
1187 | + if (empty($attachments) || empty($attachments[$id_msg])) { |
|
1188 | + return array(); |
|
1189 | + } |
|
1122 | 1190 | |
1123 | 1191 | // Set up the attachment info - based on code by Meriadoc. |
1124 | 1192 | $attachmentData = array(); |
@@ -1142,11 +1210,13 @@ discard block |
||
1142 | 1210 | ); |
1143 | 1211 | |
1144 | 1212 | // If something is unapproved we'll note it so we can sort them. |
1145 | - if (!$attachment['approved']) |
|
1146 | - $have_unapproved = true; |
|
1213 | + if (!$attachment['approved']) { |
|
1214 | + $have_unapproved = true; |
|
1215 | + } |
|
1147 | 1216 | |
1148 | - if (!$attachmentData[$i]['is_image']) |
|
1149 | - continue; |
|
1217 | + if (!$attachmentData[$i]['is_image']) { |
|
1218 | + continue; |
|
1219 | + } |
|
1150 | 1220 | |
1151 | 1221 | $attachmentData[$i]['real_width'] = $attachment['width']; |
1152 | 1222 | $attachmentData[$i]['width'] = $attachment['width']; |
@@ -1167,11 +1237,11 @@ discard block |
||
1167 | 1237 | // So what folder are we putting this image in? |
1168 | 1238 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1169 | 1239 | { |
1170 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1171 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1240 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1241 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1242 | + } |
|
1172 | 1243 | $id_folder_thumb = $modSettings['currentAttachmentUploadDir']; |
1173 | - } |
|
1174 | - else |
|
1244 | + } else |
|
1175 | 1245 | { |
1176 | 1246 | $id_folder_thumb = 1; |
1177 | 1247 | } |
@@ -1185,10 +1255,11 @@ discard block |
||
1185 | 1255 | $thumb_ext = isset($context['valid_image_types'][$size[2]]) ? $context['valid_image_types'][$size[2]] : ''; |
1186 | 1256 | |
1187 | 1257 | // Figure out the mime type. |
1188 | - if (!empty($size['mime'])) |
|
1189 | - $thumb_mime = $size['mime']; |
|
1190 | - else |
|
1191 | - $thumb_mime = 'image/' . $thumb_ext; |
|
1258 | + if (!empty($size['mime'])) { |
|
1259 | + $thumb_mime = $size['mime']; |
|
1260 | + } else { |
|
1261 | + $thumb_mime = 'image/' . $thumb_ext; |
|
1262 | + } |
|
1192 | 1263 | |
1193 | 1264 | $thumb_filename = $attachment['filename'] . '_thumb'; |
1194 | 1265 | $thumb_hash = getAttachmentFilename($thumb_filename, false, null, true); |
@@ -1236,11 +1307,12 @@ discard block |
||
1236 | 1307 | } |
1237 | 1308 | } |
1238 | 1309 | |
1239 | - if (!empty($attachment['id_thumb'])) |
|
1240 | - $attachmentData[$i]['thumbnail'] = array( |
|
1310 | + if (!empty($attachment['id_thumb'])) { |
|
1311 | + $attachmentData[$i]['thumbnail'] = array( |
|
1241 | 1312 | 'id' => $attachment['id_thumb'], |
1242 | 1313 | 'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image', |
1243 | 1314 | ); |
1315 | + } |
|
1244 | 1316 | $attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']); |
1245 | 1317 | |
1246 | 1318 | // If thumbnails are disabled, check the maximum size of the image. |
@@ -1250,30 +1322,31 @@ discard block |
||
1250 | 1322 | { |
1251 | 1323 | $attachmentData[$i]['width'] = $modSettings['max_image_width']; |
1252 | 1324 | $attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']); |
1253 | - } |
|
1254 | - elseif (!empty($modSettings['max_image_width'])) |
|
1325 | + } elseif (!empty($modSettings['max_image_width'])) |
|
1255 | 1326 | { |
1256 | 1327 | $attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']); |
1257 | 1328 | $attachmentData[$i]['height'] = $modSettings['max_image_height']; |
1258 | 1329 | } |
1259 | - } |
|
1260 | - elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1330 | + } elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1261 | 1331 | { |
1262 | 1332 | // If the image is too large to show inline, make it a popup. |
1263 | - if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) |
|
1264 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1265 | - else |
|
1266 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1333 | + if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) { |
|
1334 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1335 | + } else { |
|
1336 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1337 | + } |
|
1267 | 1338 | } |
1268 | 1339 | |
1269 | - if (!$attachmentData[$i]['thumbnail']['has_thumb']) |
|
1270 | - $attachmentData[$i]['downloads']++; |
|
1340 | + if (!$attachmentData[$i]['thumbnail']['has_thumb']) { |
|
1341 | + $attachmentData[$i]['downloads']++; |
|
1342 | + } |
|
1271 | 1343 | } |
1272 | 1344 | } |
1273 | 1345 | |
1274 | 1346 | // Do we need to instigate a sort? |
1275 | - if ($have_unapproved) |
|
1276 | - usort($attachmentData, 'approved_attach_sort'); |
|
1347 | + if ($have_unapproved) { |
|
1348 | + usort($attachmentData, 'approved_attach_sort'); |
|
1349 | + } |
|
1277 | 1350 | |
1278 | 1351 | return $attachmentData; |
1279 | 1352 | } |
@@ -21,9 +21,10 @@ discard block |
||
21 | 21 | <div id="admincenter"> |
22 | 22 | <form action="', $scripturl, '?action=admin;area=paidsubscribe;sa=modify;sid=', $context['sub_id'], '" method="post">'; |
23 | 23 | |
24 | - if (!empty($context['disable_groups'])) |
|
25 | - echo ' |
|
24 | + if (!empty($context['disable_groups'])) { |
|
25 | + echo ' |
|
26 | 26 | <div class="noticebox">', $txt['paid_mod_edit_note'], '</div>'; |
27 | + } |
|
27 | 28 | |
28 | 29 | echo ' |
29 | 30 | <div class="cat_bar"> |
@@ -67,9 +68,10 @@ discard block |
||
67 | 68 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
68 | 69 | |
69 | 70 | // Put each group into the box. |
70 | - foreach ($context['groups'] as $id => $name) |
|
71 | - echo ' |
|
71 | + foreach ($context['groups'] as $id => $name) { |
|
72 | + echo ' |
|
72 | 73 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
74 | + } |
|
73 | 75 | |
74 | 76 | echo ' |
75 | 77 | </select> |
@@ -81,12 +83,13 @@ discard block |
||
81 | 83 | <dd>'; |
82 | 84 | |
83 | 85 | // Put a checkbox in for each group |
84 | - foreach ($context['groups'] as $id => $name) |
|
85 | - echo ' |
|
86 | + foreach ($context['groups'] as $id => $name) { |
|
87 | + echo ' |
|
86 | 88 | <label for="addgroup_', $id, '"> |
87 | 89 | <input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '> |
88 | 90 | <span class="smalltext">', $name, '</span> |
89 | 91 | </label><br>'; |
92 | + } |
|
90 | 93 | |
91 | 94 | echo ' |
92 | 95 | </dd> |
@@ -236,8 +239,8 @@ discard block |
||
236 | 239 | <dl class="settings">'; |
237 | 240 | |
238 | 241 | // Do we need a username? |
239 | - if ($context['action_type'] == 'add') |
|
240 | - echo ' |
|
242 | + if ($context['action_type'] == 'add') { |
|
243 | + echo ' |
|
241 | 244 | <dt> |
242 | 245 | <strong>', $txt['paid_username'], ':</strong><br> |
243 | 246 | <span class="smalltext">', $txt['one_username'], '</span> |
@@ -245,6 +248,7 @@ discard block |
||
245 | 248 | <dd> |
246 | 249 | <input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30"> |
247 | 250 | </dd>'; |
251 | + } |
|
248 | 252 | |
249 | 253 | echo ' |
250 | 254 | <dt> |
@@ -262,9 +266,10 @@ discard block |
||
262 | 266 | <select name="year" id="year" onchange="generateDays();">'; |
263 | 267 | |
264 | 268 | // Show a list of all the years we allow... |
265 | - for ($year = 2005; $year <= 2030; $year++) |
|
266 | - echo ' |
|
269 | + for ($year = 2005; $year <= 2030; $year++) { |
|
270 | + echo ' |
|
267 | 271 | <option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>'; |
272 | + } |
|
268 | 273 | |
269 | 274 | echo ' |
270 | 275 | </select> |
@@ -272,9 +277,10 @@ discard block |
||
272 | 277 | <select name="month" id="month" onchange="generateDays();">'; |
273 | 278 | |
274 | 279 | // There are 12 months per year - ensure that they all get listed. |
275 | - for ($month = 1; $month <= 12; $month++) |
|
276 | - echo ' |
|
280 | + for ($month = 1; $month <= 12; $month++) { |
|
281 | + echo ' |
|
277 | 282 | <option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
283 | + } |
|
278 | 284 | |
279 | 285 | echo ' |
280 | 286 | </select> |
@@ -282,9 +288,10 @@ discard block |
||
282 | 288 | <select name="day" id="day">'; |
283 | 289 | |
284 | 290 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
285 | - for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) |
|
286 | - echo ' |
|
291 | + for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) { |
|
292 | + echo ' |
|
287 | 293 | <option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>'; |
294 | + } |
|
288 | 295 | |
289 | 296 | echo ' |
290 | 297 | </select> |
@@ -296,9 +303,10 @@ discard block |
||
296 | 303 | <select name="yearend" id="yearend" onchange="generateDays(\'end\');">'; |
297 | 304 | |
298 | 305 | // Show a list of all the years we allow... |
299 | - for ($year = 2005; $year <= 2030; $year++) |
|
300 | - echo ' |
|
306 | + for ($year = 2005; $year <= 2030; $year++) { |
|
307 | + echo ' |
|
301 | 308 | <option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>'; |
309 | + } |
|
302 | 310 | |
303 | 311 | echo ' |
304 | 312 | </select> |
@@ -306,9 +314,10 @@ discard block |
||
306 | 314 | <select name="monthend" id="monthend" onchange="generateDays(\'end\');">'; |
307 | 315 | |
308 | 316 | // There are 12 months per year - ensure that they all get listed. |
309 | - for ($month = 1; $month <= 12; $month++) |
|
310 | - echo ' |
|
317 | + for ($month = 1; $month <= 12; $month++) { |
|
318 | + echo ' |
|
311 | 319 | <option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
320 | + } |
|
312 | 321 | |
313 | 322 | echo ' |
314 | 323 | </select> |
@@ -316,9 +325,10 @@ discard block |
||
316 | 325 | <select name="dayend" id="dayend">'; |
317 | 326 | |
318 | 327 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
319 | - for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) |
|
320 | - echo ' |
|
328 | + for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) { |
|
329 | + echo ' |
|
321 | 330 | <option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>'; |
331 | + } |
|
322 | 332 | |
323 | 333 | echo ' |
324 | 334 | </select> |
@@ -357,8 +367,8 @@ discard block |
||
357 | 367 | <div class="windowbg"> |
358 | 368 | <ul>'; |
359 | 369 | |
360 | - foreach ($context['pending_payments'] as $id => $payment) |
|
361 | - echo ' |
|
370 | + foreach ($context['pending_payments'] as $id => $payment) { |
|
371 | + echo ' |
|
362 | 372 | <li> |
363 | 373 | ', $payment['desc'], ' |
364 | 374 | <span class="floatleft"> |
@@ -368,6 +378,7 @@ discard block |
||
368 | 378 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a> |
369 | 379 | </span> |
370 | 380 | </li>'; |
381 | + } |
|
371 | 382 | |
372 | 383 | echo ' |
373 | 384 | </ul> |
@@ -392,12 +403,12 @@ discard block |
||
392 | 403 | <h3 class="catbg">', $txt['subscriptions'], '</h3> |
393 | 404 | </div>'; |
394 | 405 | |
395 | - if (empty($context['subscriptions'])) |
|
396 | - echo ' |
|
406 | + if (empty($context['subscriptions'])) { |
|
407 | + echo ' |
|
397 | 408 | <div class="information"> |
398 | 409 | ', $txt['paid_subs_none'], ' |
399 | 410 | </div>'; |
400 | - else |
|
411 | + } else |
|
401 | 412 | { |
402 | 413 | echo ' |
403 | 414 | <div class="information"> |
@@ -408,8 +419,9 @@ discard block |
||
408 | 419 | foreach ($context['subscriptions'] as $id => $subscription) |
409 | 420 | { |
410 | 421 | // Ignore the inactive ones... |
411 | - if (empty($subscription['active'])) |
|
412 | - continue; |
|
422 | + if (empty($subscription['active'])) { |
|
423 | + continue; |
|
424 | + } |
|
413 | 425 | |
414 | 426 | echo ' |
415 | 427 | <div class="cat_bar"> |
@@ -419,9 +431,10 @@ discard block |
||
419 | 431 | <p><strong>', $subscription['name'], '</strong></p> |
420 | 432 | <p class="smalltext">', $subscription['desc'], '</p>'; |
421 | 433 | |
422 | - if (!$subscription['flexible']) |
|
423 | - echo ' |
|
434 | + if (!$subscription['flexible']) { |
|
435 | + echo ' |
|
424 | 436 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
437 | + } |
|
425 | 438 | |
426 | 439 | if ($context['user']['is_owner']) |
427 | 440 | { |
@@ -434,24 +447,25 @@ discard block |
||
434 | 447 | <select name="cur[', $subscription['id'], ']">'; |
435 | 448 | |
436 | 449 | // Print out the costs for this one. |
437 | - foreach ($subscription['costs'] as $duration => $value) |
|
438 | - echo ' |
|
450 | + foreach ($subscription['costs'] as $duration => $value) { |
|
451 | + echo ' |
|
439 | 452 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
453 | + } |
|
440 | 454 | |
441 | 455 | echo ' |
442 | 456 | </select>'; |
443 | - } |
|
444 | - else |
|
445 | - echo ' |
|
457 | + } else { |
|
458 | + echo ' |
|
446 | 459 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
460 | + } |
|
447 | 461 | |
448 | 462 | echo ' |
449 | 463 | <hr> |
450 | 464 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">'; |
451 | - } |
|
452 | - else |
|
453 | - echo ' |
|
465 | + } else { |
|
466 | + echo ' |
|
454 | 467 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>'; |
468 | + } |
|
455 | 469 | |
456 | 470 | echo ' |
457 | 471 | </div><!-- .windowbg -->'; |
@@ -478,18 +492,19 @@ discard block |
||
478 | 492 | </thead> |
479 | 493 | <tbody>'; |
480 | 494 | |
481 | - if (empty($context['current'])) |
|
482 | - echo ' |
|
495 | + if (empty($context['current'])) { |
|
496 | + echo ' |
|
483 | 497 | <tr class="windowbg"> |
484 | 498 | <td colspan="4"> |
485 | 499 | ', $txt['paid_none_yet'], ' |
486 | 500 | </td> |
487 | 501 | </tr>'; |
502 | + } |
|
488 | 503 | |
489 | 504 | foreach ($context['current'] as $sub) |
490 | 505 | { |
491 | - if (!$sub['hide']) |
|
492 | - echo ' |
|
506 | + if (!$sub['hide']) { |
|
507 | + echo ' |
|
493 | 508 | <tr class="windowbg"> |
494 | 509 | <td> |
495 | 510 | ', ($context['user']['is_admin'] ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -500,6 +515,7 @@ discard block |
||
500 | 515 | <td>', $sub['start'], '</td> |
501 | 516 | <td>', $sub['end'], '</td> |
502 | 517 | </tr>'; |
518 | + } |
|
503 | 519 | } |
504 | 520 | |
505 | 521 | echo ' |
@@ -551,15 +567,17 @@ discard block |
||
551 | 567 | ', $gateway['desc'], '<br> |
552 | 568 | <form action="', $gateway['form'], '" method="post">'; |
553 | 569 | |
554 | - if (!empty($gateway['javascript'])) |
|
555 | - echo ' |
|
570 | + if (!empty($gateway['javascript'])) { |
|
571 | + echo ' |
|
556 | 572 | <script> |
557 | 573 | ', $gateway['javascript'], ' |
558 | 574 | </script>'; |
575 | + } |
|
559 | 576 | |
560 | - foreach ($gateway['hidden'] as $name => $value) |
|
561 | - echo ' |
|
577 | + foreach ($gateway['hidden'] as $name => $value) { |
|
578 | + echo ' |
|
562 | 579 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
580 | + } |
|
563 | 581 | |
564 | 582 | echo ' |
565 | 583 | <br> |
@@ -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>'; |
@@ -238,17 +243,19 @@ discard block |
||
238 | 243 | <div class="roundframe">'; |
239 | 244 | |
240 | 245 | // Did they make any typos or mistakes, perhaps? |
241 | - if (isset($context['did_you_mean'])) |
|
242 | - echo ' |
|
246 | + if (isset($context['did_you_mean'])) { |
|
247 | + echo ' |
|
243 | 248 | <p> |
244 | 249 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
245 | 250 | </p>'; |
251 | + } |
|
246 | 252 | |
247 | - if (!empty($context['search_ignored'])) |
|
248 | - echo ' |
|
253 | + if (!empty($context['search_ignored'])) { |
|
254 | + echo ' |
|
249 | 255 | <p> |
250 | 256 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
251 | 257 | </p>'; |
258 | + } |
|
252 | 259 | |
253 | 260 | echo ' |
254 | 261 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -271,10 +278,11 @@ discard block |
||
271 | 278 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
272 | 279 | </div>'; |
273 | 280 | |
274 | - if (!empty($context['search_params']['brd'])) |
|
275 | - foreach ($context['search_params']['brd'] as $board_id) |
|
281 | + if (!empty($context['search_params']['brd'])) { |
|
282 | + foreach ($context['search_params']['brd'] as $board_id) |
|
276 | 283 | echo ' |
277 | 284 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
285 | + } |
|
278 | 286 | |
279 | 287 | echo ' |
280 | 288 | </form> |
@@ -285,18 +293,20 @@ discard block |
||
285 | 293 | if ($context['compact']) |
286 | 294 | { |
287 | 295 | // Quick moderation set to checkboxes? Oh, how fun :/ |
288 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
289 | - echo ' |
|
296 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
297 | + echo ' |
|
290 | 298 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
299 | + } |
|
291 | 300 | |
292 | 301 | echo ' |
293 | 302 | <div class="cat_bar"> |
294 | 303 | <h3 class="catbg"> |
295 | 304 | <span class="floatright">'; |
296 | 305 | |
297 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
298 | - echo ' |
|
306 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
307 | + echo ' |
|
299 | 308 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
309 | + } |
|
300 | 310 | echo ' |
301 | 311 | </span> |
302 | 312 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -304,15 +314,15 @@ discard block |
||
304 | 314 | </div>'; |
305 | 315 | |
306 | 316 | // Was anything even found? |
307 | - if (!empty($context['topics'])) |
|
308 | - echo ' |
|
317 | + if (!empty($context['topics'])) { |
|
318 | + echo ' |
|
309 | 319 | <div class="pagesection"> |
310 | 320 | <span>', $context['page_index'], '</span> |
311 | 321 | </div>'; |
312 | - |
|
313 | - else |
|
314 | - echo ' |
|
322 | + } else { |
|
323 | + echo ' |
|
315 | 324 | <div class="roundframe noup">', $txt['find_no_results'], '</div>'; |
325 | + } |
|
316 | 326 | |
317 | 327 | // While we have results to show ... |
318 | 328 | while ($topic = $context['get_topics']()) |
@@ -335,31 +345,35 @@ discard block |
||
335 | 345 | echo ' |
336 | 346 | <span class="floatright">'; |
337 | 347 | |
338 | - if ($options['display_quick_mod'] == 1) |
|
339 | - echo ' |
|
348 | + if ($options['display_quick_mod'] == 1) { |
|
349 | + echo ' |
|
340 | 350 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
341 | - |
|
342 | - else |
|
351 | + } else |
|
343 | 352 | { |
344 | - if ($topic['quick_mod']['remove']) |
|
345 | - echo ' |
|
353 | + if ($topic['quick_mod']['remove']) { |
|
354 | + echo ' |
|
346 | 355 | <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>'; |
356 | + } |
|
347 | 357 | |
348 | - if ($topic['quick_mod']['lock']) |
|
349 | - echo ' |
|
358 | + if ($topic['quick_mod']['lock']) { |
|
359 | + echo ' |
|
350 | 360 | <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>'; |
361 | + } |
|
351 | 362 | |
352 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
353 | - echo ' |
|
363 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
364 | + echo ' |
|
354 | 365 | <br>'; |
366 | + } |
|
355 | 367 | |
356 | - if ($topic['quick_mod']['sticky']) |
|
357 | - echo ' |
|
368 | + if ($topic['quick_mod']['sticky']) { |
|
369 | + echo ' |
|
358 | 370 | <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>'; |
371 | + } |
|
359 | 372 | |
360 | - if ($topic['quick_mod']['move']) |
|
361 | - echo ' |
|
373 | + if ($topic['quick_mod']['move']) { |
|
374 | + echo ' |
|
362 | 375 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
376 | + } |
|
363 | 377 | } |
364 | 378 | |
365 | 379 | echo ' |
@@ -369,20 +383,22 @@ discard block |
||
369 | 383 | echo ' |
370 | 384 | </div><!-- .block -->'; |
371 | 385 | |
372 | - if ($message['body_highlighted'] != '') |
|
373 | - echo ' |
|
386 | + if ($message['body_highlighted'] != '') { |
|
387 | + echo ' |
|
374 | 388 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
389 | + } |
|
375 | 390 | } |
376 | 391 | |
377 | 392 | echo ' |
378 | 393 | </div><!-- $topic[css_class] -->'; |
379 | 394 | } |
380 | 395 | |
381 | - if (!empty($context['topics'])) |
|
382 | - echo ' |
|
396 | + if (!empty($context['topics'])) { |
|
397 | + echo ' |
|
383 | 398 | <div class="pagesection"> |
384 | 399 | <span>', $context['page_index'], '</span> |
385 | 400 | </div>'; |
401 | + } |
|
386 | 402 | |
387 | 403 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
388 | 404 | { |
@@ -391,17 +407,19 @@ discard block |
||
391 | 407 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
392 | 408 | <option value="">--------</option>'; |
393 | 409 | |
394 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
395 | - if ($context['can_' . $qmod_action]) |
|
410 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
411 | + if ($context['can_' . $qmod_action]) |
|
396 | 412 | echo ' |
397 | 413 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
414 | + } |
|
398 | 415 | |
399 | 416 | echo ' |
400 | 417 | </select>'; |
401 | 418 | |
402 | - if ($context['can_move']) |
|
403 | - echo ' |
|
419 | + if ($context['can_move']) { |
|
420 | + echo ' |
|
404 | 421 | <span id="quick_mod_jump_to"></span>'; |
422 | + } |
|
405 | 423 | |
406 | 424 | echo ' |
407 | 425 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -410,12 +428,12 @@ discard block |
||
410 | 428 | } |
411 | 429 | |
412 | 430 | |
413 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
414 | - echo ' |
|
431 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
432 | + echo ' |
|
415 | 433 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
416 | 434 | </form>'; |
417 | - } |
|
418 | - else |
|
435 | + } |
|
436 | + } else |
|
419 | 437 | { |
420 | 438 | echo ' |
421 | 439 | <div class="cat_bar"> |
@@ -427,9 +445,10 @@ discard block |
||
427 | 445 | <span>', $context['page_index'], '</span> |
428 | 446 | </div>'; |
429 | 447 | |
430 | - if (empty($context['topics'])) |
|
431 | - echo ' |
|
448 | + if (empty($context['topics'])) { |
|
449 | + echo ' |
|
432 | 450 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
451 | + } |
|
433 | 452 | |
434 | 453 | while ($topic = $context['get_topics']()) |
435 | 454 | { |
@@ -464,8 +483,8 @@ discard block |
||
464 | 483 | <div class="smalltext righttext" id="search_jump_to"></div> |
465 | 484 | <script>'; |
466 | 485 | |
467 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
468 | - echo ' |
|
486 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
487 | + echo ' |
|
469 | 488 | if (typeof(window.XMLHttpRequest) != "undefined") |
470 | 489 | aJumpTo[aJumpTo.length] = new JumpTo({ |
471 | 490 | sContainerId: "quick_mod_jump_to", |
@@ -480,6 +499,7 @@ discard block |
||
480 | 499 | bDisabled: true, |
481 | 500 | sCustomName: "move_to" |
482 | 501 | });'; |
502 | + } |
|
483 | 503 | |
484 | 504 | echo ' |
485 | 505 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 4 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -581,13 +593,13 @@ discard block |
||
581 | 593 | ) |
582 | 594 | ); |
583 | 595 | $context['theme_options'] = array(); |
584 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
585 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
597 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
598 | + } |
|
586 | 599 | $smcFunc['db_free_result']($request); |
587 | 600 | |
588 | 601 | $context['theme_options_reset'] = false; |
589 | - } |
|
590 | - else |
|
602 | + } else |
|
591 | 603 | { |
592 | 604 | $context['theme_options'] = array(); |
593 | 605 | $context['theme_options_reset'] = true; |
@@ -596,8 +608,9 @@ discard block |
||
596 | 608 | foreach ($context['options'] as $i => $setting) |
597 | 609 | { |
598 | 610 | // Just skip separators |
599 | - if (!is_array($setting)) |
|
600 | - continue; |
|
611 | + if (!is_array($setting)) { |
|
612 | + continue; |
|
613 | + } |
|
601 | 614 | |
602 | 615 | // Is this disabled? |
603 | 616 | if (isset($setting['enabled']) && $setting['enabled'] === false) |
@@ -606,15 +619,17 @@ discard block |
||
606 | 619 | continue; |
607 | 620 | } |
608 | 621 | |
609 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
610 | - $context['options'][$i]['type'] = 'checkbox'; |
|
611 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
612 | - $context['options'][$i]['type'] = 'number'; |
|
613 | - elseif ($setting['type'] == 'string') |
|
614 | - $context['options'][$i]['type'] = 'text'; |
|
622 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
623 | + $context['options'][$i]['type'] = 'checkbox'; |
|
624 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
625 | + $context['options'][$i]['type'] = 'number'; |
|
626 | + } elseif ($setting['type'] == 'string') { |
|
627 | + $context['options'][$i]['type'] = 'text'; |
|
628 | + } |
|
615 | 629 | |
616 | - if (isset($setting['options'])) |
|
617 | - $context['options'][$i]['type'] = 'list'; |
|
630 | + if (isset($setting['options'])) { |
|
631 | + $context['options'][$i]['type'] = 'list'; |
|
632 | + } |
|
618 | 633 | |
619 | 634 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
620 | 635 | } |
@@ -639,8 +654,9 @@ discard block |
||
639 | 654 | { |
640 | 655 | global $txt, $context, $settings, $modSettings, $smcFunc; |
641 | 656 | |
642 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
643 | - return ThemeAdmin(); |
|
657 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
658 | + return ThemeAdmin(); |
|
659 | + } |
|
644 | 660 | |
645 | 661 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
646 | 662 | |
@@ -651,8 +667,9 @@ discard block |
||
651 | 667 | isAllowedTo('admin_forum'); |
652 | 668 | |
653 | 669 | // Validate inputs/user. |
654 | - if (empty($_GET['th'])) |
|
655 | - fatal_lang_error('no_theme', false); |
|
670 | + if (empty($_GET['th'])) { |
|
671 | + fatal_lang_error('no_theme', false); |
|
672 | + } |
|
656 | 673 | |
657 | 674 | // Fetch the smiley sets... |
658 | 675 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -660,8 +677,9 @@ discard block |
||
660 | 677 | $context['smiley_sets'] = array( |
661 | 678 | '' => $txt['smileys_no_default'] |
662 | 679 | ); |
663 | - foreach ($sets as $i => $set) |
|
664 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
680 | + foreach ($sets as $i => $set) { |
|
681 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
682 | + } |
|
665 | 683 | |
666 | 684 | $old_id = $settings['theme_id']; |
667 | 685 | $old_settings = $settings; |
@@ -686,8 +704,9 @@ discard block |
||
686 | 704 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
687 | 705 | { |
688 | 706 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
689 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
690 | - eval('global $settings;' . $matches[0]); |
|
707 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
708 | + eval('global $settings;' . $matches[0]); |
|
709 | + } |
|
691 | 710 | } |
692 | 711 | |
693 | 712 | // Let mods hook into the theme settings. |
@@ -699,37 +718,45 @@ discard block |
||
699 | 718 | checkSession(); |
700 | 719 | validateToken('admin-sts'); |
701 | 720 | |
702 | - if (empty($_POST['options'])) |
|
703 | - $_POST['options'] = array(); |
|
704 | - if (empty($_POST['default_options'])) |
|
705 | - $_POST['default_options'] = array(); |
|
721 | + if (empty($_POST['options'])) { |
|
722 | + $_POST['options'] = array(); |
|
723 | + } |
|
724 | + if (empty($_POST['default_options'])) { |
|
725 | + $_POST['default_options'] = array(); |
|
726 | + } |
|
706 | 727 | |
707 | 728 | // Make sure items are cast correctly. |
708 | 729 | foreach ($context['theme_settings'] as $item) |
709 | 730 | { |
710 | 731 | // Disregard this item if this is just a separator. |
711 | - if (!is_array($item)) |
|
712 | - continue; |
|
732 | + if (!is_array($item)) { |
|
733 | + continue; |
|
734 | + } |
|
713 | 735 | |
714 | 736 | foreach (array('options', 'default_options') as $option) |
715 | 737 | { |
716 | - if (!isset($_POST[$option][$item['id']])) |
|
717 | - continue; |
|
738 | + if (!isset($_POST[$option][$item['id']])) { |
|
739 | + continue; |
|
740 | + } |
|
718 | 741 | // Checkbox. |
719 | - elseif (empty($item['type'])) |
|
720 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
742 | + elseif (empty($item['type'])) { |
|
743 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
744 | + } |
|
721 | 745 | // Number |
722 | - elseif ($item['type'] == 'number') |
|
723 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
746 | + elseif ($item['type'] == 'number') { |
|
747 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
748 | + } |
|
724 | 749 | } |
725 | 750 | } |
726 | 751 | |
727 | 752 | // Set up the sql query. |
728 | 753 | $inserts = array(); |
729 | - foreach ($_POST['options'] as $opt => $val) |
|
730 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
731 | - foreach ($_POST['default_options'] as $opt => $val) |
|
732 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
754 | + foreach ($_POST['options'] as $opt => $val) { |
|
755 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
756 | + } |
|
757 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
758 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
759 | + } |
|
733 | 760 | // If we're actually inserting something.. |
734 | 761 | if (!empty($inserts)) |
735 | 762 | { |
@@ -755,8 +782,9 @@ discard block |
||
755 | 782 | |
756 | 783 | foreach ($settings as $setting => $dummy) |
757 | 784 | { |
758 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
759 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
785 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
786 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
787 | + } |
|
760 | 788 | } |
761 | 789 | |
762 | 790 | $context['settings'] = $context['theme_settings']; |
@@ -765,18 +793,21 @@ discard block |
||
765 | 793 | foreach ($context['settings'] as $i => $setting) |
766 | 794 | { |
767 | 795 | // Separators are dummies, so leave them alone. |
768 | - if (!is_array($setting)) |
|
769 | - continue; |
|
796 | + if (!is_array($setting)) { |
|
797 | + continue; |
|
798 | + } |
|
770 | 799 | |
771 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
772 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
773 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
774 | - $context['settings'][$i]['type'] = 'number'; |
|
775 | - elseif ($setting['type'] == 'string') |
|
776 | - $context['settings'][$i]['type'] = 'text'; |
|
800 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
801 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
802 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
803 | + $context['settings'][$i]['type'] = 'number'; |
|
804 | + } elseif ($setting['type'] == 'string') { |
|
805 | + $context['settings'][$i]['type'] = 'text'; |
|
806 | + } |
|
777 | 807 | |
778 | - if (isset($setting['options'])) |
|
779 | - $context['settings'][$i]['type'] = 'list'; |
|
808 | + if (isset($setting['options'])) { |
|
809 | + $context['settings'][$i]['type'] = 'list'; |
|
810 | + } |
|
780 | 811 | |
781 | 812 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
782 | 813 | } |
@@ -829,8 +860,9 @@ discard block |
||
829 | 860 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
830 | 861 | |
831 | 862 | // You can't delete the default theme! |
832 | - if ($themeID == 1) |
|
833 | - fatal_lang_error('no_access', false); |
|
863 | + if ($themeID == 1) { |
|
864 | + fatal_lang_error('no_access', false); |
|
865 | + } |
|
834 | 866 | |
835 | 867 | $theme_info = get_single_theme($themeID); |
836 | 868 | |
@@ -838,8 +870,9 @@ discard block |
||
838 | 870 | remove_theme($themeID); |
839 | 871 | |
840 | 872 | // And remove all its files and folders too. |
841 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
842 | - remove_dir($theme_info['theme_dir']); |
|
873 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
874 | + remove_dir($theme_info['theme_dir']); |
|
875 | + } |
|
843 | 876 | |
844 | 877 | // Go back to the list page. |
845 | 878 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -864,12 +897,14 @@ discard block |
||
864 | 897 | $enableThemes = explode(',', $modSettings['enableThemes']); |
865 | 898 | |
866 | 899 | // Are we disabling it? |
867 | - if (isset($_GET['disabled'])) |
|
868 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
900 | + if (isset($_GET['disabled'])) { |
|
901 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
902 | + } |
|
869 | 903 | |
870 | 904 | // Nope? then enable it! |
871 | - else |
|
872 | - $enableThemes[] = (string) $themeID; |
|
905 | + else { |
|
906 | + $enableThemes[] = (string) $themeID; |
|
907 | + } |
|
873 | 908 | |
874 | 909 | // Update the setting. |
875 | 910 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -904,18 +939,21 @@ discard block |
||
904 | 939 | |
905 | 940 | $_SESSION['id_theme'] = 0; |
906 | 941 | |
907 | - if (isset($_GET['id'])) |
|
908 | - $_GET['th'] = $_GET['id']; |
|
942 | + if (isset($_GET['id'])) { |
|
943 | + $_GET['th'] = $_GET['id']; |
|
944 | + } |
|
909 | 945 | |
910 | 946 | // Saving a variant cause JS doesn't work - pretend it did ;) |
911 | 947 | if (isset($_POST['save'])) |
912 | 948 | { |
913 | 949 | // Which theme? |
914 | - foreach ($_POST['save'] as $k => $v) |
|
915 | - $_GET['th'] = (int) $k; |
|
950 | + foreach ($_POST['save'] as $k => $v) { |
|
951 | + $_GET['th'] = (int) $k; |
|
952 | + } |
|
916 | 953 | |
917 | - if (isset($_POST['vrt'][$k])) |
|
918 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
954 | + if (isset($_POST['vrt'][$k])) { |
|
955 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
956 | + } |
|
919 | 957 | } |
920 | 958 | |
921 | 959 | // Have we made a decision, or are we just browsing? |
@@ -1004,10 +1042,10 @@ discard block |
||
1004 | 1042 | ); |
1005 | 1043 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1006 | 1044 | |
1007 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1008 | - $_SESSION['id_variant'] = 0; |
|
1009 | - } |
|
1010 | - elseif ($_GET['th'] == 0) |
|
1045 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1046 | + $_SESSION['id_variant'] = 0; |
|
1047 | + } |
|
1048 | + } elseif ($_GET['th'] == 0) |
|
1011 | 1049 | { |
1012 | 1050 | // Remove any custom variants. |
1013 | 1051 | $smcFunc['db_query']('', ' |
@@ -1088,12 +1126,13 @@ discard block |
||
1088 | 1126 | ); |
1089 | 1127 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1090 | 1128 | { |
1091 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1092 | - $context['available_themes'][$row['id_theme']] = array( |
|
1129 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1130 | + $context['available_themes'][$row['id_theme']] = array( |
|
1093 | 1131 | 'id' => $row['id_theme'], |
1094 | 1132 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1095 | 1133 | 'num_users' => 0 |
1096 | 1134 | ); |
1135 | + } |
|
1097 | 1136 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1098 | 1137 | } |
1099 | 1138 | $smcFunc['db_free_result']($request); |
@@ -1106,9 +1145,9 @@ discard block |
||
1106 | 1145 | 'num_users' => 0 |
1107 | 1146 | ); |
1108 | 1147 | $guest_theme = 0; |
1148 | + } else { |
|
1149 | + $guest_theme = $modSettings['theme_guests']; |
|
1109 | 1150 | } |
1110 | - else |
|
1111 | - $guest_theme = $modSettings['theme_guests']; |
|
1112 | 1151 | |
1113 | 1152 | $request = $smcFunc['db_query']('', ' |
1114 | 1153 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1121,15 +1160,17 @@ discard block |
||
1121 | 1160 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1122 | 1161 | { |
1123 | 1162 | // Figure out which theme it is they are REALLY using. |
1124 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1125 | - $row['id_theme'] = $guest_theme; |
|
1126 | - elseif (empty($modSettings['theme_allow'])) |
|
1127 | - $row['id_theme'] = $guest_theme; |
|
1163 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1164 | + $row['id_theme'] = $guest_theme; |
|
1165 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1166 | + $row['id_theme'] = $guest_theme; |
|
1167 | + } |
|
1128 | 1168 | |
1129 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1130 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1131 | - else |
|
1132 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1169 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1170 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1171 | + } else { |
|
1172 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1173 | + } |
|
1133 | 1174 | } |
1134 | 1175 | $smcFunc['db_free_result']($request); |
1135 | 1176 | |
@@ -1148,8 +1189,9 @@ discard block |
||
1148 | 1189 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1149 | 1190 | ) |
1150 | 1191 | ); |
1151 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1152 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1192 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1193 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1194 | + } |
|
1153 | 1195 | $smcFunc['db_free_result']($request); |
1154 | 1196 | } |
1155 | 1197 | |
@@ -1160,17 +1202,18 @@ discard block |
||
1160 | 1202 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1161 | 1203 | { |
1162 | 1204 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1163 | - if ($id_theme == 0) |
|
1164 | - continue; |
|
1205 | + if ($id_theme == 0) { |
|
1206 | + continue; |
|
1207 | + } |
|
1165 | 1208 | |
1166 | 1209 | // The thumbnail needs the correct path. |
1167 | 1210 | $settings['images_url'] = &$theme_data['images_url']; |
1168 | 1211 | |
1169 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1170 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1171 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1172 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1173 | - else |
|
1212 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1213 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1214 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1215 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1216 | + } else |
|
1174 | 1217 | { |
1175 | 1218 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1176 | 1219 | $txt['theme_description'] = ''; |
@@ -1195,15 +1238,17 @@ discard block |
||
1195 | 1238 | loadLanguage('Settings'); |
1196 | 1239 | |
1197 | 1240 | $context['available_themes'][$id_theme]['variants'] = array(); |
1198 | - foreach ($settings['theme_variants'] as $variant) |
|
1199 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1241 | + foreach ($settings['theme_variants'] as $variant) { |
|
1242 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1200 | 1243 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1201 | 1244 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1202 | 1245 | ); |
1246 | + } |
|
1203 | 1247 | |
1204 | 1248 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1205 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1206 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1249 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1250 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1251 | + } |
|
1207 | 1252 | |
1208 | 1253 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1209 | 1254 | // Allow themes to override the text. |
@@ -1219,8 +1264,9 @@ discard block |
||
1219 | 1264 | // As long as we're not doing the default theme... |
1220 | 1265 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1221 | 1266 | { |
1222 | - if ($guest_theme != 0) |
|
1223 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1267 | + if ($guest_theme != 0) { |
|
1268 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1269 | + } |
|
1224 | 1270 | |
1225 | 1271 | $context['available_themes'][0]['id'] = 0; |
1226 | 1272 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1269,14 +1315,16 @@ discard block |
||
1269 | 1315 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1270 | 1316 | |
1271 | 1317 | // Got any info from the specific form? |
1272 | - if (!isset($_POST['save_' . $action])) |
|
1273 | - fatal_lang_error('theme_install_no_action', false); |
|
1318 | + if (!isset($_POST['save_' . $action])) { |
|
1319 | + fatal_lang_error('theme_install_no_action', false); |
|
1320 | + } |
|
1274 | 1321 | |
1275 | 1322 | validateToken('admin-t-' . $action); |
1276 | 1323 | |
1277 | 1324 | // Hopefully the themes directory is writable, or we might have a problem. |
1278 | - if (!is_writable($themedir)) |
|
1279 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1325 | + if (!is_writable($themedir)) { |
|
1326 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1327 | + } |
|
1280 | 1328 | |
1281 | 1329 | // Call the function and handle the result. |
1282 | 1330 | $result = $subActions[$action](); |
@@ -1291,9 +1339,10 @@ discard block |
||
1291 | 1339 | } |
1292 | 1340 | |
1293 | 1341 | // Nope, show a nice error. |
1294 | - else |
|
1295 | - fatal_lang_error('theme_install_no_action', false); |
|
1296 | -} |
|
1342 | + else { |
|
1343 | + fatal_lang_error('theme_install_no_action', false); |
|
1344 | + } |
|
1345 | + } |
|
1297 | 1346 | |
1298 | 1347 | /** |
1299 | 1348 | * Installs a theme from a theme package. |
@@ -1309,8 +1358,9 @@ discard block |
||
1309 | 1358 | $dirtemp = $themedir . '/temp'; |
1310 | 1359 | |
1311 | 1360 | // Make sure the temp dir doesn't already exist |
1312 | - if (file_exists($dirtemp)) |
|
1313 | - remove_dir($dirtemp); |
|
1361 | + if (file_exists($dirtemp)) { |
|
1362 | + remove_dir($dirtemp); |
|
1363 | + } |
|
1314 | 1364 | |
1315 | 1365 | // Create the temp dir. |
1316 | 1366 | mkdir($dirtemp, 0777); |
@@ -1322,17 +1372,20 @@ discard block |
||
1322 | 1372 | smf_chmod($dirtemp, '0755'); |
1323 | 1373 | |
1324 | 1374 | // How about now? |
1325 | - if (!is_writable($dirtemp)) |
|
1326 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1375 | + if (!is_writable($dirtemp)) { |
|
1376 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1377 | + } |
|
1327 | 1378 | } |
1328 | 1379 | |
1329 | 1380 | // This happens when the admin session is gone and the user has to login again. |
1330 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1331 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1381 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1382 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1383 | + } |
|
1332 | 1384 | |
1333 | 1385 | // Another error check layer, something went wrong with the upload. |
1334 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1335 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1386 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1387 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1388 | + } |
|
1336 | 1389 | |
1337 | 1390 | // Get the theme's name. |
1338 | 1391 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1363,11 +1416,10 @@ discard block |
||
1363 | 1416 | |
1364 | 1417 | // return all the info. |
1365 | 1418 | return $context['to_install']; |
1419 | + } else { |
|
1420 | + fatal_lang_error('theme_install_error_title', false); |
|
1421 | + } |
|
1366 | 1422 | } |
1367 | - |
|
1368 | - else |
|
1369 | - fatal_lang_error('theme_install_error_title', false); |
|
1370 | -} |
|
1371 | 1423 | |
1372 | 1424 | /** |
1373 | 1425 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1381,15 +1433,17 @@ discard block |
||
1381 | 1433 | global $forum_version; |
1382 | 1434 | |
1383 | 1435 | // There's gotta be something to work with. |
1384 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1385 | - fatal_lang_error('theme_install_error_title', false); |
|
1436 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1437 | + fatal_lang_error('theme_install_error_title', false); |
|
1438 | + } |
|
1386 | 1439 | |
1387 | 1440 | // Get a cleaner version. |
1388 | 1441 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1389 | 1442 | |
1390 | 1443 | // Is there a theme already named like this? |
1391 | - if (file_exists($themedir . '/' . $name)) |
|
1392 | - fatal_lang_error('theme_install_already_dir', false); |
|
1444 | + if (file_exists($themedir . '/' . $name)) { |
|
1445 | + fatal_lang_error('theme_install_already_dir', false); |
|
1446 | + } |
|
1393 | 1447 | |
1394 | 1448 | // This is a brand new theme so set all possible values. |
1395 | 1449 | $context['to_install'] = array( |
@@ -1409,8 +1463,9 @@ discard block |
||
1409 | 1463 | |
1410 | 1464 | // Buy some time. |
1411 | 1465 | @set_time_limit(600); |
1412 | - if (function_exists('apache_reset_timeout')) |
|
1413 | - @apache_reset_timeout(); |
|
1466 | + if (function_exists('apache_reset_timeout')) { |
|
1467 | + @apache_reset_timeout(); |
|
1468 | + } |
|
1414 | 1469 | |
1415 | 1470 | // Create subdirectories for css and javascript files. |
1416 | 1471 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1446,12 +1501,13 @@ discard block |
||
1446 | 1501 | |
1447 | 1502 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1448 | 1503 | { |
1449 | - if ($row['variable'] == 'theme_templates') |
|
1450 | - $theme_templates = $row['value']; |
|
1451 | - elseif ($row['variable'] == 'theme_layers') |
|
1452 | - $theme_layers = $row['value']; |
|
1453 | - else |
|
1454 | - continue; |
|
1504 | + if ($row['variable'] == 'theme_templates') { |
|
1505 | + $theme_templates = $row['value']; |
|
1506 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1507 | + $theme_layers = $row['value']; |
|
1508 | + } else { |
|
1509 | + continue; |
|
1510 | + } |
|
1455 | 1511 | } |
1456 | 1512 | |
1457 | 1513 | $smcFunc['db_free_result']($request); |
@@ -1510,12 +1566,14 @@ discard block |
||
1510 | 1566 | global $themedir, $themeurl, $context; |
1511 | 1567 | |
1512 | 1568 | // Cannot use the theme dir as a theme dir. |
1513 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1514 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1569 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1570 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1571 | + } |
|
1515 | 1572 | |
1516 | 1573 | // Check is there is "something" on the dir. |
1517 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1518 | - fatal_lang_error('theme_install_error', false); |
|
1574 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1575 | + fatal_lang_error('theme_install_error', false); |
|
1576 | + } |
|
1519 | 1577 | |
1520 | 1578 | $name = basename($_REQUEST['theme_dir']); |
1521 | 1579 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1559,24 +1617,27 @@ discard block |
||
1559 | 1617 | } |
1560 | 1618 | |
1561 | 1619 | // Any special layers? |
1562 | - if (isset($settings['catch_action']['layers'])) |
|
1563 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1620 | + if (isset($settings['catch_action']['layers'])) { |
|
1621 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1622 | + } |
|
1564 | 1623 | |
1565 | 1624 | // Any function to call? |
1566 | 1625 | if (isset($settings['catch_action']['function'])) |
1567 | 1626 | { |
1568 | 1627 | $hook = $settings['catch_action']['function']; |
1569 | 1628 | |
1570 | - if (!isset($settings['catch_action']['filename'])) |
|
1571 | - $settings['catch_action']['filename'] = ''; |
|
1629 | + if (!isset($settings['catch_action']['filename'])) { |
|
1630 | + $settings['catch_action']['filename'] = ''; |
|
1631 | + } |
|
1572 | 1632 | |
1573 | 1633 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1574 | 1634 | call_integration_hook('integrate_wrap_action'); |
1575 | 1635 | } |
1576 | 1636 | // And finally, the main sub template ;). |
1577 | - if (isset($settings['catch_action']['sub_template'])) |
|
1578 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1579 | -} |
|
1637 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1638 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1639 | + } |
|
1640 | + } |
|
1580 | 1641 | |
1581 | 1642 | /** |
1582 | 1643 | * Set an option via javascript. |
@@ -1595,12 +1656,14 @@ discard block |
||
1595 | 1656 | checkSession('get'); |
1596 | 1657 | |
1597 | 1658 | // This good-for-nothing pixel is being used to keep the session alive. |
1598 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1599 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1659 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1660 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1661 | + } |
|
1600 | 1662 | |
1601 | 1663 | // Sorry, guests can't go any further than this. |
1602 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1603 | - obExit(false); |
|
1664 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1665 | + obExit(false); |
|
1666 | + } |
|
1604 | 1667 | |
1605 | 1668 | $reservedVars = array( |
1606 | 1669 | 'actual_theme_url', |
@@ -1623,8 +1686,9 @@ discard block |
||
1623 | 1686 | ); |
1624 | 1687 | |
1625 | 1688 | // Can't change reserved vars. |
1626 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1627 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1689 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1690 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1691 | + } |
|
1628 | 1692 | |
1629 | 1693 | // Use a specific theme? |
1630 | 1694 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1640,8 +1704,9 @@ discard block |
||
1640 | 1704 | { |
1641 | 1705 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
1642 | 1706 | // New thingy... |
1643 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1644 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1707 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1708 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1709 | + } |
|
1645 | 1710 | |
1646 | 1711 | // Change the value to be something nice, |
1647 | 1712 | $_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']); |
@@ -1671,8 +1736,9 @@ discard block |
||
1671 | 1736 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1672 | 1737 | |
1673 | 1738 | // @todo Should this be removed? |
1674 | - if (isset($_REQUEST['preview'])) |
|
1675 | - die('die() with fire'); |
|
1739 | + if (isset($_REQUEST['preview'])) { |
|
1740 | + die('die() with fire'); |
|
1741 | + } |
|
1676 | 1742 | |
1677 | 1743 | isAllowedTo('admin_forum'); |
1678 | 1744 | loadTemplate('Themes'); |
@@ -1686,11 +1752,11 @@ discard block |
||
1686 | 1752 | foreach ($context['themes'] as $key => $theme) |
1687 | 1753 | { |
1688 | 1754 | // There has to be a Settings template! |
1689 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1690 | - unset($context['themes'][$key]); |
|
1691 | - |
|
1692 | - else |
|
1693 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1755 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1756 | + unset($context['themes'][$key]); |
|
1757 | + } else { |
|
1758 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1759 | + } |
|
1694 | 1760 | } |
1695 | 1761 | |
1696 | 1762 | $context['sub_template'] = 'edit_list'; |
@@ -1705,22 +1771,24 @@ discard block |
||
1705 | 1771 | $context['theme_id'] = $currentTheme['id']; |
1706 | 1772 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1707 | 1773 | |
1708 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1709 | - fatal_lang_error('theme_edit_missing', false); |
|
1774 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1775 | + fatal_lang_error('theme_edit_missing', false); |
|
1776 | + } |
|
1710 | 1777 | |
1711 | 1778 | if (!isset($_REQUEST['filename'])) |
1712 | 1779 | { |
1713 | 1780 | if (isset($_GET['directory'])) |
1714 | 1781 | { |
1715 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1716 | - $_GET['directory'] = ''; |
|
1717 | - else |
|
1782 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1783 | + $_GET['directory'] = ''; |
|
1784 | + } else |
|
1718 | 1785 | { |
1719 | 1786 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1720 | 1787 | |
1721 | 1788 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1722 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1723 | - $_GET['directory'] = ''; |
|
1789 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1790 | + $_GET['directory'] = ''; |
|
1791 | + } |
|
1724 | 1792 | } |
1725 | 1793 | } |
1726 | 1794 | |
@@ -1739,37 +1807,39 @@ discard block |
||
1739 | 1807 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1740 | 1808 | 'size' => '', |
1741 | 1809 | )); |
1810 | + } else { |
|
1811 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1742 | 1812 | } |
1743 | - else |
|
1744 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1745 | 1813 | |
1746 | 1814 | $context['sub_template'] = 'edit_browse'; |
1747 | 1815 | |
1748 | 1816 | return; |
1749 | - } |
|
1750 | - else |
|
1817 | + } else |
|
1751 | 1818 | { |
1752 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1753 | - $_REQUEST['filename'] = ''; |
|
1754 | - else |
|
1819 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1820 | + $_REQUEST['filename'] = ''; |
|
1821 | + } else |
|
1755 | 1822 | { |
1756 | 1823 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1757 | 1824 | |
1758 | 1825 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1759 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1760 | - $_REQUEST['filename'] = ''; |
|
1826 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1827 | + $_REQUEST['filename'] = ''; |
|
1828 | + } |
|
1761 | 1829 | } |
1762 | 1830 | |
1763 | - if (empty($_REQUEST['filename'])) |
|
1764 | - fatal_lang_error('theme_edit_missing', false); |
|
1831 | + if (empty($_REQUEST['filename'])) { |
|
1832 | + fatal_lang_error('theme_edit_missing', false); |
|
1833 | + } |
|
1765 | 1834 | } |
1766 | 1835 | |
1767 | 1836 | if (isset($_POST['save'])) |
1768 | 1837 | { |
1769 | 1838 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1770 | 1839 | { |
1771 | - if (is_array($_POST['entire_file'])) |
|
1772 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1840 | + if (is_array($_POST['entire_file'])) { |
|
1841 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1842 | + } |
|
1773 | 1843 | |
1774 | 1844 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1775 | 1845 | |
@@ -1781,10 +1851,11 @@ discard block |
||
1781 | 1851 | fclose($fp); |
1782 | 1852 | |
1783 | 1853 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1784 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1785 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1786 | - else |
|
1787 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1854 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1855 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1856 | + } else { |
|
1857 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1858 | + } |
|
1788 | 1859 | } |
1789 | 1860 | |
1790 | 1861 | if (!isset($error_file)) |
@@ -1805,10 +1876,11 @@ discard block |
||
1805 | 1876 | $context['sub_template'] = 'edit_file'; |
1806 | 1877 | |
1807 | 1878 | // Recycle the submitted data. |
1808 | - if (is_array($_POST['entire_file'])) |
|
1809 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1810 | - else |
|
1811 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1879 | + if (is_array($_POST['entire_file'])) { |
|
1880 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1881 | + } else { |
|
1882 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1883 | + } |
|
1812 | 1884 | |
1813 | 1885 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1814 | 1886 | |
@@ -1831,17 +1903,17 @@ discard block |
||
1831 | 1903 | $context['sub_template'] = 'edit_style'; |
1832 | 1904 | |
1833 | 1905 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1834 | - } |
|
1835 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1906 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1836 | 1907 | { |
1837 | 1908 | $context['sub_template'] = 'edit_template'; |
1838 | 1909 | |
1839 | - if (!isset($error_file)) |
|
1840 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1841 | - else |
|
1910 | + if (!isset($error_file)) { |
|
1911 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1912 | + } else |
|
1842 | 1913 | { |
1843 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1844 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1914 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1915 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1916 | + } |
|
1845 | 1917 | $file_data = file($error_file); |
1846 | 1918 | unlink($error_file); |
1847 | 1919 | } |
@@ -1855,8 +1927,9 @@ discard block |
||
1855 | 1927 | // Try to format the functions a little nicer... |
1856 | 1928 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1857 | 1929 | |
1858 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1859 | - unset($context['file_parts'][$j]); |
|
1930 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1931 | + unset($context['file_parts'][$j]); |
|
1932 | + } |
|
1860 | 1933 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1861 | 1934 | } |
1862 | 1935 | |
@@ -1865,8 +1938,7 @@ discard block |
||
1865 | 1938 | } |
1866 | 1939 | |
1867 | 1940 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1868 | - } |
|
1869 | - else |
|
1941 | + } else |
|
1870 | 1942 | { |
1871 | 1943 | $context['sub_template'] = 'edit_file'; |
1872 | 1944 | |
@@ -1892,8 +1964,9 @@ discard block |
||
1892 | 1964 | |
1893 | 1965 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1894 | 1966 | |
1895 | - if (empty($_GET['th'])) |
|
1896 | - fatal_lang_error('theme_install_invalid_id'); |
|
1967 | + if (empty($_GET['th'])) { |
|
1968 | + fatal_lang_error('theme_install_invalid_id'); |
|
1969 | + } |
|
1897 | 1970 | |
1898 | 1971 | // Get the theme info. |
1899 | 1972 | $theme = get_single_theme($_GET['th']); |
@@ -1901,25 +1974,24 @@ discard block |
||
1901 | 1974 | |
1902 | 1975 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1903 | 1976 | { |
1904 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1905 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1906 | - |
|
1907 | - else |
|
1908 | - fatal_lang_error('no_access', false); |
|
1977 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1978 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1979 | + } else { |
|
1980 | + fatal_lang_error('no_access', false); |
|
1981 | + } |
|
1909 | 1982 | |
1910 | 1983 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1911 | 1984 | fwrite($fp, file_get_contents($filename)); |
1912 | 1985 | fclose($fp); |
1913 | 1986 | |
1914 | 1987 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1915 | - } |
|
1916 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1988 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1917 | 1989 | { |
1918 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1919 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1920 | - |
|
1921 | - else |
|
1922 | - fatal_lang_error('no_access', false); |
|
1990 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1991 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1992 | + } else { |
|
1993 | + fatal_lang_error('no_access', false); |
|
1994 | + } |
|
1923 | 1995 | |
1924 | 1996 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1925 | 1997 | fwrite($fp, file_get_contents($filename)); |
@@ -1934,16 +2006,18 @@ discard block |
||
1934 | 2006 | $dir = dir($settings['default_theme_dir']); |
1935 | 2007 | while ($entry = $dir->read()) |
1936 | 2008 | { |
1937 | - if (substr($entry, -13) == '.template.php') |
|
1938 | - $templates[] = substr($entry, 0, -13); |
|
2009 | + if (substr($entry, -13) == '.template.php') { |
|
2010 | + $templates[] = substr($entry, 0, -13); |
|
2011 | + } |
|
1939 | 2012 | } |
1940 | 2013 | $dir->close(); |
1941 | 2014 | |
1942 | 2015 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1943 | 2016 | while ($entry = $dir->read()) |
1944 | 2017 | { |
1945 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1946 | - $lang_files[] = $matches[1]; |
|
2018 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2019 | + $lang_files[] = $matches[1]; |
|
2020 | + } |
|
1947 | 2021 | } |
1948 | 2022 | $dir->close(); |
1949 | 2023 | |
@@ -1951,21 +2025,23 @@ discard block |
||
1951 | 2025 | natcasesort($lang_files); |
1952 | 2026 | |
1953 | 2027 | $context['available_templates'] = array(); |
1954 | - foreach ($templates as $template) |
|
1955 | - $context['available_templates'][$template] = array( |
|
2028 | + foreach ($templates as $template) { |
|
2029 | + $context['available_templates'][$template] = array( |
|
1956 | 2030 | 'filename' => $template . '.template.php', |
1957 | 2031 | 'value' => $template, |
1958 | 2032 | 'already_exists' => false, |
1959 | 2033 | 'can_copy' => is_writable($theme['theme_dir']), |
1960 | 2034 | ); |
2035 | + } |
|
1961 | 2036 | $context['available_language_files'] = array(); |
1962 | - foreach ($lang_files as $file) |
|
1963 | - $context['available_language_files'][$file] = array( |
|
2037 | + foreach ($lang_files as $file) { |
|
2038 | + $context['available_language_files'][$file] = array( |
|
1964 | 2039 | 'filename' => $file . '.php', |
1965 | 2040 | 'value' => $file, |
1966 | 2041 | 'already_exists' => false, |
1967 | 2042 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1968 | 2043 | ); |
2044 | + } |
|
1969 | 2045 | |
1970 | 2046 | $dir = dir($theme['theme_dir']); |
1971 | 2047 | while ($entry = $dir->read()) |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | } |
39 | 39 | </script>'; |
40 | 40 | |
41 | - if (!empty($context['poll_error']['messages'])) |
|
42 | - echo ' |
|
41 | + if (!empty($context['poll_error']['messages'])) { |
|
42 | + echo ' |
|
43 | 43 | <div class="errorbox"> |
44 | 44 | <dl class="poll_error"> |
45 | 45 | <dt> |
@@ -50,6 +50,7 @@ discard block |
||
50 | 50 | </dt> |
51 | 51 | </dl> |
52 | 52 | </div>'; |
53 | + } |
|
53 | 54 | |
54 | 55 | // Start the main poll form. |
55 | 56 | echo ' |
@@ -79,8 +80,9 @@ discard block |
||
79 | 80 | <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" size="80" maxlength="255">'; |
80 | 81 | |
81 | 82 | // Does this option have a vote count yet, or is it new? |
82 | - if ($choice['votes'] != -1) |
|
83 | - echo ' (', $choice['votes'], ' ', $txt['votes'], ')'; |
|
83 | + if ($choice['votes'] != -1) { |
|
84 | + echo ' (', $choice['votes'], ' ', $txt['votes'], ')'; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </dd>'; |
@@ -118,14 +120,15 @@ discard block |
||
118 | 120 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
119 | 121 | </dd>'; |
120 | 122 | |
121 | - if ($context['poll']['guest_vote_allowed']) |
|
122 | - echo ' |
|
123 | + if ($context['poll']['guest_vote_allowed']) { |
|
124 | + echo ' |
|
123 | 125 | <dt> |
124 | 126 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
125 | 127 | </dt> |
126 | 128 | <dd> |
127 | 129 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll']['guest_vote']) ? ' checked' : '', '> |
128 | 130 | </dd>'; |
131 | + } |
|
129 | 132 | } |
130 | 133 | |
131 | 134 | echo ' |
@@ -141,12 +144,13 @@ discard block |
||
141 | 144 | </fieldset>'; |
142 | 145 | |
143 | 146 | // If this is an edit, we can allow them to reset the vote counts. |
144 | - if ($context['is_edit']) |
|
145 | - echo ' |
|
147 | + if ($context['is_edit']) { |
|
148 | + echo ' |
|
146 | 149 | <fieldset id="poll_reset"> |
147 | 150 | <legend>', $txt['reset_votes'], '</legend> |
148 | 151 | <input type="checkbox" name="resetVoteCount" value="on"> ' . $txt['reset_votes_check'] . ' |
149 | 152 | </fieldset>'; |
153 | + } |
|
150 | 154 | echo ' |
151 | 155 | <input type="submit" name="post" value="', $txt['save'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button"> |
152 | 156 | </div><!-- .roundframe --> |