@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | $members = array(); |
53 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
54 | - $members[$row['id_member']] = array( |
|
53 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
54 | + $members[$row['id_member']] = array( |
|
55 | 55 | 'id' => $row['id_member'], |
56 | 56 | 'real_name' => $row['real_name'], |
57 | 57 | 'email_address' => $row['email_address'], |
@@ -62,6 +62,7 @@ discard block |
||
62 | 62 | ), |
63 | 63 | 'lngfile' => $row['lngfile'], |
64 | 64 | ); |
65 | + } |
|
65 | 66 | $smcFunc['db_free_result']($request); |
66 | 67 | |
67 | 68 | return $members; |
@@ -83,13 +84,14 @@ discard block |
||
83 | 84 | |
84 | 85 | call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members)); |
85 | 86 | |
86 | - foreach ($members as $member) |
|
87 | - $smcFunc['db_insert']('ignore', |
|
87 | + foreach ($members as $member) { |
|
88 | + $smcFunc['db_insert']('ignore', |
|
88 | 89 | '{db_prefix}mentions', |
89 | 90 | array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'), |
90 | 91 | array((int) $content_id, $content_type, $id_member, $member['id'], time()), |
91 | 92 | array('content_id', 'content_type', 'id_mentioned') |
92 | 93 | ); |
94 | + } |
|
93 | 95 | } |
94 | 96 | |
95 | 97 | /** |
@@ -103,8 +105,9 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public static function getBody($body, array $members) |
105 | 107 | { |
106 | - foreach ($members as $member) |
|
107 | - $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
108 | + foreach ($members as $member) { |
|
109 | + $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
110 | + } |
|
108 | 111 | |
109 | 112 | return $body; |
110 | 113 | } |
@@ -123,8 +126,9 @@ discard block |
||
123 | 126 | |
124 | 127 | $possible_names = self::getPossibleMentions($body); |
125 | 128 | |
126 | - if (empty($possible_names) || !allowedTo('mention')) |
|
127 | - return array(); |
|
129 | + if (empty($possible_names) || !allowedTo('mention')) { |
|
130 | + return array(); |
|
131 | + } |
|
128 | 132 | |
129 | 133 | $request = $smcFunc['db_query']('', ' |
130 | 134 | SELECT id_member, real_name |
@@ -140,8 +144,9 @@ discard block |
||
140 | 144 | $members = array(); |
141 | 145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
142 | 146 | { |
143 | - if (stripos($body, static::$char . $row['real_name']) === false) |
|
144 | - continue; |
|
147 | + if (stripos($body, static::$char . $row['real_name']) === false) { |
|
148 | + continue; |
|
149 | + } |
|
145 | 150 | |
146 | 151 | $members[$row['id_member']] = array( |
147 | 152 | 'id' => $row['id_member'], |
@@ -185,8 +190,9 @@ discard block |
||
185 | 190 | $body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace(' ', ' ', $body)), ENT_QUOTES); |
186 | 191 | |
187 | 192 | // Remove quotes, we don't want to get double mentions. |
188 | - while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) |
|
189 | - $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
193 | + while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) { |
|
194 | + $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
195 | + } |
|
190 | 196 | |
191 | 197 | $matches = array(); |
192 | 198 | $string = str_split($body); |
@@ -197,9 +203,9 @@ discard block |
||
197 | 203 | { |
198 | 204 | $depth++; |
199 | 205 | $matches[] = array(); |
206 | + } elseif ($char == "\n") { |
|
207 | + $depth = 0; |
|
200 | 208 | } |
201 | - elseif ($char == "\n") |
|
202 | - $depth = 0; |
|
203 | 209 | |
204 | 210 | for ($i = $depth; $i > 0; $i--) |
205 | 211 | { |
@@ -212,8 +218,9 @@ discard block |
||
212 | 218 | } |
213 | 219 | } |
214 | 220 | |
215 | - foreach ($matches as $k => $match) |
|
216 | - $matches[$k] = substr(implode('', $match), 1); |
|
221 | + foreach ($matches as $k => $match) { |
|
222 | + $matches[$k] = substr(implode('', $match), 1); |
|
223 | + } |
|
217 | 224 | |
218 | 225 | // Names can have spaces, other breaks, or they can't...we try to match every possible |
219 | 226 | // combination. |
@@ -223,8 +230,9 @@ discard block |
||
223 | 230 | $match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE); |
224 | 231 | $count = count($match); |
225 | 232 | |
226 | - for ($i = 1; $i <= $count; $i++) |
|
227 | - $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
233 | + for ($i = 1; $i <= $count; $i++) { |
|
234 | + $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
235 | + } |
|
228 | 236 | } |
229 | 237 | |
230 | 238 | $names = array_unique($names); |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | 'class' => 'centercol', |
1327 | 1327 | ), |
1328 | 1328 | 'data' => array( |
1329 | - 'function' => function ($rowData) |
|
1329 | + 'function' => function($rowData) |
|
1330 | 1330 | { |
1331 | 1331 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1332 | 1332 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | 'class' => 'centercol', |
1343 | 1343 | ), |
1344 | 1344 | 'data' => array( |
1345 | - 'function' => function ($rowData) |
|
1345 | + 'function' => function($rowData) |
|
1346 | 1346 | { |
1347 | 1347 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1348 | 1348 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1389,15 +1389,15 @@ discard block |
||
1389 | 1389 | 'value' => $txt['custom_profile_fieldorder'], |
1390 | 1390 | ), |
1391 | 1391 | 'data' => array( |
1392 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1392 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1393 | 1393 | { |
1394 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
|
1394 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br />'; |
|
1395 | 1395 | |
1396 | 1396 | if ($rowData['field_order'] > 1) |
1397 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1397 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1398 | 1398 | |
1399 | 1399 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1400 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1400 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1401 | 1401 | |
1402 | 1402 | $return .= '</p>'; |
1403 | 1403 | |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | 'value' => $txt['custom_profile_fieldname'], |
1416 | 1416 | ), |
1417 | 1417 | 'data' => array( |
1418 | - 'function' => function ($rowData) use ($scripturl) |
|
1418 | + 'function' => function($rowData) use ($scripturl) |
|
1419 | 1419 | { |
1420 | 1420 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1421 | 1421 | }, |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | 'value' => $txt['custom_profile_fieldtype'], |
1432 | 1432 | ), |
1433 | 1433 | 'data' => array( |
1434 | - 'function' => function ($rowData) use ($txt) |
|
1434 | + 'function' => function($rowData) use ($txt) |
|
1435 | 1435 | { |
1436 | 1436 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1437 | 1437 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | 'value' => $txt['custom_profile_active'], |
1450 | 1450 | ), |
1451 | 1451 | 'data' => array( |
1452 | - 'function' => function ($rowData) use ($txt) |
|
1452 | + 'function' => function($rowData) use ($txt) |
|
1453 | 1453 | { |
1454 | 1454 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1455 | 1455 | }, |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | 'value' => $txt['custom_profile_placement'], |
1467 | 1467 | ), |
1468 | 1468 | 'data' => array( |
1469 | - 'function' => function ($rowData) |
|
1469 | + 'function' => function($rowData) |
|
1470 | 1470 | { |
1471 | 1471 | global $txt, $context; |
1472 | 1472 | |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1702 | 1702 | |
1703 | 1703 | // All good, proceed. |
1704 | - $smcFunc['db_query']('',' |
|
1704 | + $smcFunc['db_query']('', ' |
|
1705 | 1705 | UPDATE {db_prefix}custom_fields |
1706 | 1706 | SET field_order = {int:old_order} |
1707 | 1707 | WHERE field_order = {int:new_order}', |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | 'old_order' => $context['field']['order'], |
1711 | 1711 | ) |
1712 | 1712 | ); |
1713 | - $smcFunc['db_query']('',' |
|
1713 | + $smcFunc['db_query']('', ' |
|
1714 | 1714 | UPDATE {db_prefix}custom_fields |
1715 | 1715 | SET field_order = {int:new_order} |
1716 | 1716 | WHERE id_field = {int:id_field}', |
@@ -1812,7 +1812,7 @@ discard block |
||
1812 | 1812 | $smcFunc['db_free_result']($request); |
1813 | 1813 | |
1814 | 1814 | $unique = false; |
1815 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1815 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1816 | 1816 | { |
1817 | 1817 | if (!in_array($col_name, $current_fields)) |
1818 | 1818 | $unique = true; |
@@ -1985,7 +1985,7 @@ discard block |
||
1985 | 1985 | ); |
1986 | 1986 | |
1987 | 1987 | // Re-arrange the order. |
1988 | - $smcFunc['db_query']('',' |
|
1988 | + $smcFunc['db_query']('', ' |
|
1989 | 1989 | UPDATE {db_prefix}custom_fields |
1990 | 1990 | SET field_order = field_order - 1 |
1991 | 1991 | WHERE field_order > {int:current_order}', |
@@ -2249,7 +2249,7 @@ discard block |
||
2249 | 2249 | $context['token_check'] = 'noti-admin'; |
2250 | 2250 | |
2251 | 2251 | // Specify our action since we'll want to post back here instead of the profile |
2252 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2252 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2253 | 2253 | |
2254 | 2254 | loadTemplate('Profile'); |
2255 | 2255 | loadLanguage('Profile'); |
@@ -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 makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
269 | 273 | |
270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
271 | 275 | |
272 | - if ($return_config) |
|
273 | - return $config_vars; |
|
276 | + if ($return_config) { |
|
277 | + return $config_vars; |
|
278 | + } |
|
274 | 279 | |
275 | 280 | // Setup the template. |
276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
287 | 292 | |
288 | 293 | // Clean up the tags. |
289 | 294 | $bbcTags = array(); |
290 | - foreach (parse_bbc(false) as $tag) |
|
291 | - $bbcTags[] = $tag['tag']; |
|
295 | + foreach (parse_bbc(false) as $tag) { |
|
296 | + $bbcTags[] = $tag['tag']; |
|
297 | + } |
|
292 | 298 | |
293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
303 | + } |
|
297 | 304 | // Work out what is actually disabled! |
298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
337 | 344 | |
338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
339 | 346 | |
340 | - if ($return_config) |
|
341 | - return $config_vars; |
|
347 | + if ($return_config) { |
|
348 | + return $config_vars; |
|
349 | + } |
|
342 | 350 | |
343 | 351 | // Saving? |
344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
379 | 387 | |
380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
381 | 389 | |
382 | - if ($return_config) |
|
383 | - return $config_vars; |
|
390 | + if ($return_config) { |
|
391 | + return $config_vars; |
|
392 | + } |
|
384 | 393 | |
385 | 394 | // Saving? |
386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
418 | 427 | |
419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
420 | 429 | |
421 | - if ($return_config) |
|
422 | - return $config_vars; |
|
430 | + if ($return_config) { |
|
431 | + return $config_vars; |
|
432 | + } |
|
423 | 433 | |
424 | 434 | // Saving? |
425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
463 | 473 | 'enable' => array('check', 'warning_enable'), |
464 | 474 | ); |
465 | 475 | |
466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
467 | - $config_vars += array( |
|
476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
477 | + $config_vars += array( |
|
468 | 478 | '', |
469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
474 | 484 | array('permissions', 'view_warning'), |
475 | 485 | ); |
486 | + } |
|
476 | 487 | |
477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
478 | 489 | |
479 | - if ($return_config) |
|
480 | - return $config_vars; |
|
490 | + if ($return_config) { |
|
491 | + return $config_vars; |
|
492 | + } |
|
481 | 493 | |
482 | 494 | // Cannot use moderation if post moderation is not enabled. |
483 | - if (!$modSettings['postmod_active']) |
|
484 | - unset($config_vars['moderate']); |
|
495 | + if (!$modSettings['postmod_active']) { |
|
496 | + unset($config_vars['moderate']); |
|
497 | + } |
|
485 | 498 | |
486 | 499 | // Will need the utility functions from here. |
487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
506 | 519 | 'warning_watch' => 10, |
507 | 520 | 'warning_mute' => 60, |
508 | 521 | ); |
509 | - if ($modSettings['postmod_active']) |
|
510 | - $vars['warning_moderate'] = 35; |
|
522 | + if ($modSettings['postmod_active']) { |
|
523 | + $vars['warning_moderate'] = 35; |
|
524 | + } |
|
511 | 525 | |
512 | 526 | foreach ($vars as $var => $value) |
513 | 527 | { |
514 | 528 | $config_vars[] = array('int', $var); |
515 | 529 | $_POST[$var] = $value; |
516 | 530 | } |
517 | - } |
|
518 | - else |
|
531 | + } else |
|
519 | 532 | { |
520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
603 | 616 | |
604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
605 | 618 | |
606 | - if ($return_config) |
|
607 | - return $config_vars; |
|
619 | + if ($return_config) { |
|
620 | + return $config_vars; |
|
621 | + } |
|
608 | 622 | |
609 | 623 | // You need to be an admin to edit settings! |
610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
638 | 652 | |
639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
640 | 654 | { |
641 | - if (empty($context['settings_insert_above'])) |
|
642 | - $context['settings_insert_above'] = ''; |
|
655 | + if (empty($context['settings_insert_above'])) { |
|
656 | + $context['settings_insert_above'] = ''; |
|
657 | + } |
|
643 | 658 | |
644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
683 | 698 | |
684 | 699 | // Hack in guest requiring verification! |
685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
686 | - $_POST['posts_require_captcha'] = -1; |
|
700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
701 | + $_POST['posts_require_captcha'] = -1; |
|
702 | + } |
|
687 | 703 | |
688 | 704 | $save_vars = $config_vars; |
689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
701 | 717 | { |
702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
721 | + } |
|
705 | 722 | |
706 | 723 | // Now step through and see if any existing questions no longer exist. |
707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
710 | 727 | $changes['delete'][] = $q_id; |
728 | + } |
|
711 | 729 | |
712 | 730 | // Now let's see if there are new questions or ones that need updating. |
713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
716 | 734 | { |
717 | 735 | // Ignore junky ids. |
718 | 736 | $q_id = (int) $q_id; |
719 | - if ($q_id <= 0) |
|
720 | - continue; |
|
737 | + if ($q_id <= 0) { |
|
738 | + continue; |
|
739 | + } |
|
721 | 740 | |
722 | 741 | // Check the question isn't empty (because they want to delete it?) |
723 | 742 | if (empty($question) || trim($question) == '') |
724 | 743 | { |
725 | - if (isset($context['question_answers'][$q_id])) |
|
726 | - $changes['delete'][] = $q_id; |
|
744 | + if (isset($context['question_answers'][$q_id])) { |
|
745 | + $changes['delete'][] = $q_id; |
|
746 | + } |
|
727 | 747 | continue; |
728 | 748 | } |
729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
731 | 751 | // Get the answers. Firstly check there actually might be some. |
732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
733 | 753 | { |
734 | - if (isset($context['question_answers'][$q_id])) |
|
735 | - $changes['delete'][] = $q_id; |
|
754 | + if (isset($context['question_answers'][$q_id])) { |
|
755 | + $changes['delete'][] = $q_id; |
|
756 | + } |
|
736 | 757 | continue; |
737 | 758 | } |
738 | 759 | // Now get them and check that they might be viable. |
739 | 760 | $answers = array(); |
740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
741 | - if (!empty($answer) && trim($answer) !== '') |
|
761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
762 | + if (!empty($answer) && trim($answer) !== '') |
|
742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
764 | + } |
|
743 | 765 | if (empty($answers)) |
744 | 766 | { |
745 | - if (isset($context['question_answers'][$q_id])) |
|
746 | - $changes['delete'][] = $q_id; |
|
767 | + if (isset($context['question_answers'][$q_id])) { |
|
768 | + $changes['delete'][] = $q_id; |
|
769 | + } |
|
747 | 770 | continue; |
748 | 771 | } |
749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
753 | 776 | { |
754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
756 | - } |
|
757 | - else |
|
779 | + } else |
|
758 | 780 | { |
759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
784 | + } |
|
762 | 785 | } |
763 | 786 | |
764 | - if (!isset($qs_per_lang[$lang_id])) |
|
765 | - $qs_per_lang[$lang_id] = 0; |
|
787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
788 | + $qs_per_lang[$lang_id] = 0; |
|
789 | + } |
|
766 | 790 | $qs_per_lang[$lang_id]++; |
767 | 791 | } |
768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
812 | 836 | |
813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
816 | - $_POST['qa_verification_number'] = $count_questions; |
|
839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
840 | + $_POST['qa_verification_number'] = $count_questions; |
|
841 | + } |
|
817 | 842 | |
818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
828 | 853 | |
829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
830 | 855 | $_SESSION['visual_verification_code'] = ''; |
831 | - for ($i = 0; $i < 6; $i++) |
|
832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
856 | + for ($i = 0; $i < 6; $i++) { |
|
857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
858 | + } |
|
833 | 859 | |
834 | 860 | // Some javascript for CAPTCHA. |
835 | 861 | $context['settings_post_javascript'] = ''; |
836 | - if ($context['use_graphic_library']) |
|
837 | - $context['settings_post_javascript'] .= ' |
|
862 | + if ($context['use_graphic_library']) { |
|
863 | + $context['settings_post_javascript'] .= ' |
|
838 | 864 | function refreshImages() |
839 | 865 | { |
840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
842 | 868 | }'; |
869 | + } |
|
843 | 870 | |
844 | 871 | // Show the image itself, or text saying we can't. |
845 | - if ($context['use_graphic_library']) |
|
846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
847 | - else |
|
848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
872 | + if ($context['use_graphic_library']) { |
|
873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
874 | + } else { |
|
875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + } |
|
849 | 877 | |
850 | 878 | // Hack for PM spam settings. |
851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
856 | 884 | |
857 | 885 | // Some minor javascript for the guest post setting. |
858 | - if ($modSettings['posts_require_captcha']) |
|
859 | - $context['settings_post_javascript'] .= ' |
|
886 | + if ($modSettings['posts_require_captcha']) { |
|
887 | + $context['settings_post_javascript'] .= ' |
|
860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
889 | + } |
|
861 | 890 | |
862 | 891 | // And everything else. |
863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
904 | 933 | |
905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
906 | 935 | |
907 | - if ($return_config) |
|
908 | - return $config_vars; |
|
936 | + if ($return_config) { |
|
937 | + return $config_vars; |
|
938 | + } |
|
909 | 939 | |
910 | 940 | // Setup the template. |
911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
961 | 991 | |
962 | 992 | // Max characters... |
963 | - if (!empty($sig_limits[1])) |
|
964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
993 | + if (!empty($sig_limits[1])) { |
|
994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
995 | + } |
|
965 | 996 | // Max lines... |
966 | 997 | if (!empty($sig_limits[2])) |
967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
971 | 1002 | if ($sig[$i] == "\n") |
972 | 1003 | { |
973 | 1004 | $count++; |
974 | - if ($count >= $sig_limits[2]) |
|
975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1005 | + if ($count >= $sig_limits[2]) { |
|
1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1007 | + } |
|
976 | 1008 | } |
977 | 1009 | } |
978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
983 | 1015 | { |
984 | 1016 | $limit_broke = 0; |
985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
993 | - $limit_broke = 'large'; |
|
994 | - |
|
995 | - if ($limit_broke) |
|
996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1025 | + $limit_broke = 'large'; |
|
1026 | + } |
|
1027 | + |
|
1028 | + if ($limit_broke) { |
|
1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1030 | + } |
|
997 | 1031 | } |
998 | 1032 | } |
999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
1049 | 1083 | $img_offset = false; |
1050 | 1084 | } |
1051 | 1085 | } |
1086 | + } else { |
|
1087 | + $replaces[$image] = ''; |
|
1052 | 1088 | } |
1053 | - else |
|
1054 | - $replaces[$image] = ''; |
|
1055 | 1089 | |
1056 | 1090 | continue; |
1057 | 1091 | } |
1058 | 1092 | |
1059 | 1093 | // Does it have predefined restraints? Width first. |
1060 | - if ($matches[6][$key]) |
|
1061 | - $matches[2][$key] = $matches[6][$key]; |
|
1094 | + if ($matches[6][$key]) { |
|
1095 | + $matches[2][$key] = $matches[6][$key]; |
|
1096 | + } |
|
1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1063 | 1098 | { |
1064 | 1099 | $width = $sig_limits[5]; |
1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1101 | + } elseif ($matches[2][$key]) { |
|
1102 | + $width = $matches[2][$key]; |
|
1066 | 1103 | } |
1067 | - elseif ($matches[2][$key]) |
|
1068 | - $width = $matches[2][$key]; |
|
1069 | 1104 | // ... and height. |
1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1071 | 1106 | { |
1072 | 1107 | $height = $sig_limits[6]; |
1073 | - if ($width != -1) |
|
1074 | - $width = $width * ($height / $matches[4][$key]); |
|
1108 | + if ($width != -1) { |
|
1109 | + $width = $width * ($height / $matches[4][$key]); |
|
1110 | + } |
|
1111 | + } elseif ($matches[4][$key]) { |
|
1112 | + $height = $matches[4][$key]; |
|
1075 | 1113 | } |
1076 | - elseif ($matches[4][$key]) |
|
1077 | - $height = $matches[4][$key]; |
|
1078 | 1114 | |
1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1093 | 1129 | { |
1094 | 1130 | $height = $sig_limits[6]; |
1095 | - if ($width == -1) |
|
1096 | - $width = $sizes[0]; |
|
1131 | + if ($width == -1) { |
|
1132 | + $width = $sizes[0]; |
|
1133 | + } |
|
1097 | 1134 | $width = $width * ($height / $sizes[1]); |
1135 | + } elseif ($width != -1) { |
|
1136 | + $height = $sizes[1]; |
|
1098 | 1137 | } |
1099 | - elseif ($width != -1) |
|
1100 | - $height = $sizes[1]; |
|
1101 | 1138 | } |
1102 | 1139 | } |
1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
1110 | 1147 | // Record that we got one. |
1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1112 | 1149 | } |
1113 | - if (!empty($replaces)) |
|
1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1150 | + if (!empty($replaces)) { |
|
1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1152 | + } |
|
1115 | 1153 | } |
1116 | 1154 | } |
1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
1123 | 1161 | |
1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1126 | - if ($sig != $row['signature']) |
|
1127 | - $changes[$row['id_member']] = $sig; |
|
1164 | + if ($sig != $row['signature']) { |
|
1165 | + $changes[$row['id_member']] = $sig; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1169 | + $done = true; |
|
1128 | 1170 | } |
1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1130 | - $done = true; |
|
1131 | 1171 | $smcFunc['db_free_result']($request); |
1132 | 1172 | |
1133 | 1173 | // Do we need to delete what we have? |
1134 | 1174 | if (!empty($changes)) |
1135 | 1175 | { |
1136 | - foreach ($changes as $id => $sig) |
|
1137 | - $smcFunc['db_query']('', ' |
|
1176 | + foreach ($changes as $id => $sig) { |
|
1177 | + $smcFunc['db_query']('', ' |
|
1138 | 1178 | UPDATE {db_prefix}members |
1139 | 1179 | SET signature = {string:signature} |
1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
1143 | 1183 | 'signature' => $sig, |
1144 | 1184 | ) |
1145 | 1185 | ); |
1186 | + } |
|
1146 | 1187 | } |
1147 | 1188 | |
1148 | 1189 | $_GET['step'] += 50; |
1149 | - if (!$done) |
|
1150 | - pauseSignatureApplySettings(); |
|
1190 | + if (!$done) { |
|
1191 | + pauseSignatureApplySettings(); |
|
1192 | + } |
|
1151 | 1193 | } |
1152 | 1194 | $settings_applied = true; |
1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
1165 | 1207 | ); |
1166 | 1208 | |
1167 | 1209 | // Temporarily make each setting a modSetting! |
1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
1169 | - $modSettings['signature_' . $key] = $value; |
|
1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1211 | + $modSettings['signature_' . $key] = $value; |
|
1212 | + } |
|
1170 | 1213 | |
1171 | 1214 | // Make sure we check the right tags! |
1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
1178 | 1221 | |
1179 | 1222 | // Clean up the tag stuff! |
1180 | 1223 | $bbcTags = array(); |
1181 | - foreach (parse_bbc(false) as $tag) |
|
1182 | - $bbcTags[] = $tag['tag']; |
|
1224 | + foreach (parse_bbc(false) as $tag) { |
|
1225 | + $bbcTags[] = $tag['tag']; |
|
1226 | + } |
|
1183 | 1227 | |
1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + } |
|
1188 | 1233 | |
1189 | 1234 | $sig_limits = array(); |
1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
1191 | 1236 | { |
1192 | - if ($key == 'allow_smileys') |
|
1193 | - continue; |
|
1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1195 | - $sig_limits[] = -1; |
|
1196 | - else |
|
1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1237 | + if ($key == 'allow_smileys') { |
|
1238 | + continue; |
|
1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1240 | + $sig_limits[] = -1; |
|
1241 | + } else { |
|
1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1243 | + } |
|
1198 | 1244 | } |
1199 | 1245 | |
1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
1227 | 1273 | |
1228 | 1274 | // Try get more time... |
1229 | 1275 | @set_time_limit(600); |
1230 | - if (function_exists('apache_reset_timeout')) |
|
1231 | - @apache_reset_timeout(); |
|
1276 | + if (function_exists('apache_reset_timeout')) { |
|
1277 | + @apache_reset_timeout(); |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | // Have we exhausted all the time we allowed? |
1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1235 | - return; |
|
1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1282 | + return; |
|
1283 | + } |
|
1236 | 1284 | |
1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
1278 | 1326 | $disable_fields = array_flip($standard_fields); |
1279 | 1327 | if (!empty($_POST['active'])) |
1280 | 1328 | { |
1281 | - foreach ($_POST['active'] as $value) |
|
1282 | - if (isset($disable_fields[$value])) |
|
1329 | + foreach ($_POST['active'] as $value) { |
|
1330 | + if (isset($disable_fields[$value])) |
|
1283 | 1331 | unset($disable_fields[$value]); |
1332 | + } |
|
1284 | 1333 | } |
1285 | 1334 | // What we have left! |
1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
1289 | 1338 | $reg_fields = array(); |
1290 | 1339 | if (!empty($_POST['reg'])) |
1291 | 1340 | { |
1292 | - foreach ($_POST['reg'] as $value) |
|
1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1341 | + foreach ($_POST['reg'] as $value) { |
|
1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1294 | 1343 | $reg_fields[] = $value; |
1344 | + } |
|
1295 | 1345 | } |
1296 | 1346 | // What we have left! |
1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1298 | 1348 | |
1299 | 1349 | $_SESSION['adm-save'] = true; |
1300 | - if (!empty($changes)) |
|
1301 | - updateSettings($changes); |
|
1350 | + if (!empty($changes)) { |
|
1351 | + updateSettings($changes); |
|
1352 | + } |
|
1302 | 1353 | } |
1303 | 1354 | |
1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
1401 | 1452 | { |
1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
1403 | 1454 | |
1404 | - if ($rowData['field_order'] > 1) |
|
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1455 | + if ($rowData['field_order'] > 1) { |
|
1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1457 | + } |
|
1406 | 1458 | |
1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | 1463 | $return .= '</p>'; |
1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1545 | 1598 | |
1546 | - foreach ($standard_fields as $field) |
|
1547 | - $list[] = array( |
|
1599 | + foreach ($standard_fields as $field) { |
|
1600 | + $list[] = array( |
|
1548 | 1601 | 'id' => $field, |
1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1553 | 1606 | ); |
1554 | - } |
|
1555 | - else |
|
1607 | + } |
|
1608 | + } else |
|
1556 | 1609 | { |
1557 | 1610 | // Load all the fields. |
1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
1566 | 1619 | 'items_per_page' => $items_per_page, |
1567 | 1620 | ) |
1568 | 1621 | ); |
1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1570 | - $list[] = $row; |
|
1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1623 | + $list[] = $row; |
|
1624 | + } |
|
1571 | 1625 | $smcFunc['db_free_result']($request); |
1572 | 1626 | } |
1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
1633 | 1687 | $context['field'] = array(); |
1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1635 | 1689 | { |
1636 | - if ($row['field_type'] == 'textarea') |
|
1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1638 | - else |
|
1690 | + if ($row['field_type'] == 'textarea') { |
|
1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1692 | + } else |
|
1639 | 1693 | { |
1640 | 1694 | $rows = 3; |
1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
1671 | 1725 | } |
1672 | 1726 | |
1673 | 1727 | // Setup the default values as needed. |
1674 | - if (empty($context['field'])) |
|
1675 | - $context['field'] = array( |
|
1728 | + if (empty($context['field'])) { |
|
1729 | + $context['field'] = array( |
|
1676 | 1730 | 'name' => '', |
1677 | 1731 | 'col_name' => '???', |
1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
1697 | 1751 | 'enclose' => '', |
1698 | 1752 | 'placement' => 0, |
1699 | 1753 | ); |
1754 | + } |
|
1700 | 1755 | |
1701 | 1756 | // Are we moving it? |
1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1706 | 1761 | |
1707 | 1762 | // Is this a valid position? |
1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1765 | + } |
|
1766 | + // @todo implement an error handler |
|
1710 | 1767 | |
1711 | 1768 | // All good, proceed. |
1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
1737 | 1794 | validateToken('admin-ecp'); |
1738 | 1795 | |
1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
1740 | - if (trim($_POST['field_name']) == '') |
|
1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1797 | + if (trim($_POST['field_name']) == '') { |
|
1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1799 | + } |
|
1742 | 1800 | |
1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1804 | + } |
|
1746 | 1805 | |
1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
1759 | 1818 | |
1760 | 1819 | // Some masking stuff... |
1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1763 | - $mask .= $_POST['regex']; |
|
1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1822 | + $mask .= $_POST['regex']; |
|
1823 | + } |
|
1764 | 1824 | |
1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
1779 | 1839 | $v = strtr($v, array(',' => '')); |
1780 | 1840 | |
1781 | 1841 | // Nada, zip, etc... |
1782 | - if (trim($v) == '') |
|
1783 | - continue; |
|
1842 | + if (trim($v) == '') { |
|
1843 | + continue; |
|
1844 | + } |
|
1784 | 1845 | |
1785 | 1846 | // Otherwise, save it boy. |
1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
1788 | 1849 | $newOptions[$k] = $v; |
1789 | 1850 | |
1790 | 1851 | // Is it default? |
1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1792 | - $default = $v; |
|
1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1853 | + $default = $v; |
|
1854 | + } |
|
1793 | 1855 | } |
1794 | 1856 | $field_options = substr($field_options, 0, -1); |
1795 | 1857 | } |
1796 | 1858 | |
1797 | 1859 | // Text area has default has dimensions |
1798 | - if ($_POST['field_type'] == 'textarea') |
|
1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1860 | + if ($_POST['field_type'] == 'textarea') { |
|
1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1862 | + } |
|
1800 | 1863 | |
1801 | 1864 | // Come up with the unique name? |
1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1806 | 1869 | |
1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1808 | - if (isset($matches[1])) |
|
1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1810 | - else |
|
1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1871 | + if (isset($matches[1])) { |
|
1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1873 | + } else { |
|
1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + } |
|
1812 | 1876 | |
1813 | 1877 | // Make sure this is unique. |
1814 | 1878 | $current_fields = array(); |
1815 | 1879 | $request = $smcFunc['db_query']('', ' |
1816 | 1880 | SELECT id_field, col_name |
1817 | 1881 | FROM {db_prefix}custom_fields'); |
1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1884 | + } |
|
1820 | 1885 | $smcFunc['db_free_result']($request); |
1821 | 1886 | |
1822 | 1887 | $unique = false; |
1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
1824 | 1889 | { |
1825 | - if (!in_array($col_name, $current_fields)) |
|
1826 | - $unique = true; |
|
1827 | - else |
|
1828 | - $col_name = $initial_col_name . $i; |
|
1890 | + if (!in_array($col_name, $current_fields)) { |
|
1891 | + $unique = true; |
|
1892 | + } else { |
|
1893 | + $col_name = $initial_col_name . $i; |
|
1894 | + } |
|
1829 | 1895 | } |
1830 | 1896 | |
1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
1832 | - if (!$unique) |
|
1833 | - fatal_lang_error('custom_option_not_unique'); |
|
1898 | + if (!$unique) { |
|
1899 | + fatal_lang_error('custom_option_not_unique'); |
|
1900 | + } |
|
1834 | 1901 | } |
1835 | 1902 | // Work out what to do with the user data otherwise... |
1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
1858 | 1925 | // Work out what's changed! |
1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
1860 | 1927 | { |
1861 | - if (trim($option) == '') |
|
1862 | - continue; |
|
1928 | + if (trim($option) == '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1863 | 1931 | |
1864 | 1932 | // Still exists? |
1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
1873 | 1941 | foreach ($optionChanges as $k => $option) |
1874 | 1942 | { |
1875 | 1943 | // Just been renamed? |
1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1877 | - $smcFunc['db_query']('', ' |
|
1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1945 | + $smcFunc['db_query']('', ' |
|
1878 | 1946 | UPDATE {db_prefix}themes |
1879 | 1947 | SET value = {string:new_value} |
1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
1887 | 1955 | 'old_value' => $option, |
1888 | 1956 | ) |
1889 | 1957 | ); |
1958 | + } |
|
1890 | 1959 | } |
1891 | 1960 | } |
1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
1929 | 1998 | ); |
1930 | 1999 | |
1931 | 2000 | // Just clean up any old selects - these are a pain! |
1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1933 | - $smcFunc['db_query']('', ' |
|
2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2002 | + $smcFunc['db_query']('', ' |
|
1934 | 2003 | DELETE FROM {db_prefix}themes |
1935 | 2004 | WHERE variable = {string:current_column} |
1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
1941 | 2010 | 'current_column' => $context['field']['col_name'], |
1942 | 2011 | ) |
1943 | 2012 | ); |
1944 | - } |
|
1945 | - else |
|
2013 | + } |
|
2014 | + } else |
|
1946 | 2015 | { |
1947 | 2016 | // Gotta figure it out the order. |
1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2117 | 2186 | |
2118 | 2187 | $prune_toggle_dt = array(); |
2119 | - foreach ($prune_toggle as $item) |
|
2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2188 | + foreach ($prune_toggle as $item) { |
|
2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2190 | + } |
|
2121 | 2191 | |
2122 | - if ($return_config) |
|
2123 | - return $config_vars; |
|
2192 | + if ($return_config) { |
|
2193 | + return $config_vars; |
|
2194 | + } |
|
2124 | 2195 | |
2125 | 2196 | addInlineJavaScript(' |
2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
2158 | 2229 | $vals = array(); |
2159 | 2230 | foreach ($config_vars as $index => $dummy) |
2160 | 2231 | { |
2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2162 | - continue; |
|
2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2233 | + continue; |
|
2234 | + } |
|
2163 | 2235 | |
2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2165 | 2237 | } |
2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
2239 | + } else { |
|
2240 | + $_POST['pruningOptions'] = ''; |
|
2167 | 2241 | } |
2168 | - else |
|
2169 | - $_POST['pruningOptions'] = ''; |
|
2170 | 2242 | |
2171 | 2243 | saveDBSettings($savevar); |
2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
2178 | 2250 | $context['sub_template'] = 'show_settings'; |
2179 | 2251 | |
2180 | 2252 | // Get the actual values |
2181 | - if (!empty($modSettings['pruningOptions'])) |
|
2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2183 | - else |
|
2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2255 | + } else { |
|
2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2257 | + } |
|
2185 | 2258 | |
2186 | 2259 | prepareDBSettingContext($config_vars); |
2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
2203 | 2276 | // Make it even easier to add new settings. |
2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2205 | 2278 | |
2206 | - if ($return_config) |
|
2207 | - return $config_vars; |
|
2279 | + if ($return_config) { |
|
2280 | + return $config_vars; |
|
2281 | + } |
|
2208 | 2282 | |
2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | 'class' => 'centercol', |
394 | 394 | ), |
395 | 395 | 'data' => array( |
396 | - 'function' => function ($rowData) |
|
396 | + 'function' => function($rowData) |
|
397 | 397 | { |
398 | 398 | return $rowData['selected'] ? '<span class="generic_icons valid"></span>' : ''; |
399 | 399 | }, |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | 'class' => 'centercol', |
454 | 454 | ), |
455 | 455 | 'data' => array( |
456 | - 'function' => function ($rowData) |
|
456 | + 'function' => function($rowData) |
|
457 | 457 | { |
458 | 458 | return $rowData['selected'] ? '' : sprintf('<input type="checkbox" name="smiley_set[%1$d]" class="input_check">', $rowData['id']); |
459 | 459 | }, |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | 'value' => $txt['smileys_location'], |
998 | 998 | ), |
999 | 999 | 'data' => array( |
1000 | - 'function' => function ($rowData) use ($txt) |
|
1000 | + 'function' => function($rowData) use ($txt) |
|
1001 | 1001 | { |
1002 | 1002 | if (empty($rowData['hidden'])) |
1003 | 1003 | return $txt['smileys_location_form']; |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | 'value' => $txt['smileys_description'], |
1018 | 1018 | ), |
1019 | 1019 | 'data' => array( |
1020 | - 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
1020 | + 'function' => function($rowData) use ($context, $txt, $modSettings, $smcFunc) |
|
1021 | 1021 | { |
1022 | 1022 | if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
1023 | 1023 | return $smcFunc['htmlspecialchars']($rowData['description']); |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
1558 | 1558 | ); |
1559 | 1559 | |
1560 | - $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
1560 | + $file = $packagesdir . '/temp/' . $base_path . $action['filename']; |
|
1561 | 1561 | if (isset($action['filename']) && (!file_exists($file) || !is_writable(dirname($action['destination'])))) |
1562 | 1562 | { |
1563 | 1563 | $context['has_failure'] = true; |
@@ -1601,7 +1601,7 @@ discard block |
||
1601 | 1601 | { |
1602 | 1602 | updateSettings(array( |
1603 | 1603 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . basename($action['action']), |
1604 | - 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
1604 | + 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''), |
|
1605 | 1605 | )); |
1606 | 1606 | } |
1607 | 1607 | |
@@ -1613,7 +1613,7 @@ discard block |
||
1613 | 1613 | '{db_prefix}log_packages', |
1614 | 1614 | array( |
1615 | 1615 | 'filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', |
1616 | - 'id_member_installed' => 'int', 'member_installed' => 'string','time_installed' => 'int', |
|
1616 | + 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', |
|
1617 | 1617 | 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', |
1618 | 1618 | 'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string', |
1619 | 1619 | ), |
@@ -1862,7 +1862,7 @@ discard block |
||
1862 | 1862 | 'columns' => array( |
1863 | 1863 | 'icon' => array( |
1864 | 1864 | 'data' => array( |
1865 | - 'function' => function ($rowData) use ($settings, $smcFunc) |
|
1865 | + 'function' => function($rowData) use ($settings, $smcFunc) |
|
1866 | 1866 | { |
1867 | 1867 | $images_url = $settings[file_exists(sprintf('%1$s/images/post/%2$s.png', $settings['theme_dir'], $rowData['filename'])) ? 'actual_images_url' : 'default_images_url']; |
1868 | 1868 | return sprintf('<img src="%1$s/post/%2$s.png" alt="%3$s">', $images_url, $rowData['filename'], $smcFunc['htmlspecialchars']($rowData['title'])); |
@@ -1896,7 +1896,7 @@ discard block |
||
1896 | 1896 | 'value' => $txt['icons_board'], |
1897 | 1897 | ), |
1898 | 1898 | 'data' => array( |
1899 | - 'function' => function ($rowData) use ($txt) |
|
1899 | + 'function' => function($rowData) use ($txt) |
|
1900 | 1900 | { |
1901 | 1901 | return empty($rowData['board_name']) ? $txt['icons_edit_icons_all_boards'] : $rowData['board_name']; |
1902 | 1902 | }, |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This is the dispatcher of smileys administration. |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | ); |
92 | 93 | |
93 | 94 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
94 | - if (empty($modSettings['messageIcons_enable'])) |
|
95 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
95 | + if (empty($modSettings['messageIcons_enable'])) { |
|
96 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
97 | + } |
|
96 | 98 | if (empty($modSettings['smiley_enable'])) |
97 | 99 | { |
98 | 100 | $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true; |
@@ -125,8 +127,9 @@ discard block |
||
125 | 127 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
126 | 128 | |
127 | 129 | $smiley_context = array(); |
128 | - foreach ($smiley_sets as $i => $set) |
|
129 | - $smiley_context[$set] = $set_names[$i]; |
|
130 | + foreach ($smiley_sets as $i => $set) { |
|
131 | + $smiley_context[$set] = $set_names[$i]; |
|
132 | + } |
|
130 | 133 | |
131 | 134 | // All the settings for the page... |
132 | 135 | $config_vars = array( |
@@ -147,8 +150,9 @@ discard block |
||
147 | 150 | |
148 | 151 | call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); |
149 | 152 | |
150 | - if ($return_config) |
|
151 | - return $config_vars; |
|
153 | + if ($return_config) { |
|
154 | + return $config_vars; |
|
155 | + } |
|
152 | 156 | |
153 | 157 | // Setup the basics of the settings template. |
154 | 158 | require_once($sourcedir . '/ManageServer.php'); |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | foreach ($_POST['smiley_set'] as $id => $val) |
208 | 212 | { |
209 | 213 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
210 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
211 | - unset($set_paths[$id], $set_names[$id]); |
|
214 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
215 | + unset($set_paths[$id], $set_names[$id]); |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | |
214 | 219 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -222,8 +227,9 @@ discard block |
||
222 | 227 | )); |
223 | 228 | } |
224 | 229 | // Add a new smiley set. |
225 | - elseif (!empty($_POST['add'])) |
|
226 | - $context['sub_action'] = 'modifyset'; |
|
230 | + elseif (!empty($_POST['add'])) { |
|
231 | + $context['sub_action'] = 'modifyset'; |
|
232 | + } |
|
227 | 233 | // Create or modify a smiley set. |
228 | 234 | elseif (isset($_POST['set'])) |
229 | 235 | { |
@@ -233,8 +239,9 @@ discard block |
||
233 | 239 | // Create a new smiley set. |
234 | 240 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
235 | 241 | { |
236 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
237 | - fatal_lang_error('smiley_set_already_exists'); |
|
242 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
243 | + fatal_lang_error('smiley_set_already_exists'); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | updateSettings(array( |
240 | 247 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -246,12 +253,14 @@ discard block |
||
246 | 253 | else |
247 | 254 | { |
248 | 255 | // Make sure the smiley set exists. |
249 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
250 | - fatal_lang_error('smiley_set_not_found'); |
|
256 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
257 | + fatal_lang_error('smiley_set_not_found'); |
|
258 | + } |
|
251 | 259 | |
252 | 260 | // Make sure the path is not yet used by another smileyset. |
253 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
254 | - fatal_lang_error('smiley_set_path_already_used'); |
|
261 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
262 | + fatal_lang_error('smiley_set_path_already_used'); |
|
263 | + } |
|
255 | 264 | |
256 | 265 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
257 | 266 | $set_names[$_POST['set']] = $_POST['smiley_sets_name']; |
@@ -263,8 +272,9 @@ discard block |
||
263 | 272 | } |
264 | 273 | |
265 | 274 | // The user might have checked to also import smileys. |
266 | - if (!empty($_POST['smiley_sets_import'])) |
|
267 | - ImportSmileys($_POST['smiley_sets_path']); |
|
275 | + if (!empty($_POST['smiley_sets_import'])) { |
|
276 | + ImportSmileys($_POST['smiley_sets_path']); |
|
277 | + } |
|
268 | 278 | } |
269 | 279 | cache_put_data('parsing_smileys', null, 480); |
270 | 280 | cache_put_data('posting_smileys', null, 480); |
@@ -273,13 +283,14 @@ discard block |
||
273 | 283 | // Load all available smileysets... |
274 | 284 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
275 | 285 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
276 | - foreach ($context['smiley_sets'] as $i => $set) |
|
277 | - $context['smiley_sets'][$i] = array( |
|
286 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
287 | + $context['smiley_sets'][$i] = array( |
|
278 | 288 | 'id' => $i, |
279 | 289 | 'path' => $smcFunc['htmlspecialchars']($set), |
280 | 290 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
281 | 291 | 'selected' => $set == $modSettings['smiley_sets_default'] |
282 | 292 | ); |
293 | + } |
|
283 | 294 | |
284 | 295 | // Importing any smileys from an existing set? |
285 | 296 | if ($context['sub_action'] == 'import') |
@@ -290,8 +301,9 @@ discard block |
||
290 | 301 | $_GET['set'] = (int) $_GET['set']; |
291 | 302 | |
292 | 303 | // Sanity check - then import. |
293 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
294 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
304 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
305 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
306 | + } |
|
295 | 307 | |
296 | 308 | // Force the process to continue. |
297 | 309 | $context['sub_action'] = 'modifyset'; |
@@ -301,15 +313,15 @@ discard block |
||
301 | 313 | if ($context['sub_action'] == 'modifyset') |
302 | 314 | { |
303 | 315 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
304 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
305 | - $context['current_set'] = array( |
|
316 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
317 | + $context['current_set'] = array( |
|
306 | 318 | 'id' => '-1', |
307 | 319 | 'path' => '', |
308 | 320 | 'name' => '', |
309 | 321 | 'selected' => false, |
310 | 322 | 'is_new' => true, |
311 | 323 | ); |
312 | - else |
|
324 | + } else |
|
313 | 325 | { |
314 | 326 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
315 | 327 | $context['current_set']['is_new'] = false; |
@@ -321,13 +333,15 @@ discard block |
||
321 | 333 | $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']); |
322 | 334 | while ($entry = $dir->read()) |
323 | 335 | { |
324 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
325 | - $smileys[strtolower($entry)] = $entry; |
|
336 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
337 | + $smileys[strtolower($entry)] = $entry; |
|
338 | + } |
|
326 | 339 | } |
327 | 340 | $dir->close(); |
328 | 341 | |
329 | - if (empty($smileys)) |
|
330 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
342 | + if (empty($smileys)) { |
|
343 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
344 | + } |
|
331 | 345 | |
332 | 346 | // Exclude the smileys that are already in the database. |
333 | 347 | $request = $smcFunc['db_query']('', ' |
@@ -338,9 +352,10 @@ discard block |
||
338 | 352 | 'smiley_list' => $smileys, |
339 | 353 | ) |
340 | 354 | ); |
341 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
342 | - if (isset($smileys[strtolower($row['filename'])])) |
|
355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
356 | + if (isset($smileys[strtolower($row['filename'])])) |
|
343 | 357 | unset($smileys[strtolower($row['filename'])]); |
358 | + } |
|
344 | 359 | $smcFunc['db_free_result']($request); |
345 | 360 | |
346 | 361 | $context['current_set']['can_import'] = count($smileys); |
@@ -355,13 +370,14 @@ discard block |
||
355 | 370 | $dir = dir($modSettings['smileys_dir']); |
356 | 371 | while ($entry = $dir->read()) |
357 | 372 | { |
358 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
359 | - $context['smiley_set_dirs'][] = array( |
|
373 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
374 | + $context['smiley_set_dirs'][] = array( |
|
360 | 375 | 'id' => $entry, |
361 | 376 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
362 | 377 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
363 | 378 | 'current' => $entry == $context['current_set']['path'], |
364 | 379 | ); |
380 | + } |
|
365 | 381 | } |
366 | 382 | $dir->close(); |
367 | 383 | } |
@@ -371,8 +387,9 @@ discard block |
||
371 | 387 | createToken('admin-mss', 'request'); |
372 | 388 | |
373 | 389 | // In case we need to import smileys, we need to add the token in now. |
374 | - if (isset($context['current_set']['import_url'])) |
|
375 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
390 | + if (isset($context['current_set']['import_url'])) { |
|
391 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
392 | + } |
|
376 | 393 | |
377 | 394 | $listOptions = array( |
378 | 395 | 'id' => 'smiley_set_list', |
@@ -510,21 +527,23 @@ discard block |
||
510 | 527 | $cols['name'][] = $set_names[$i]; |
511 | 528 | } |
512 | 529 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
513 | - if (substr($sort, 0, 4) === 'name') |
|
514 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
515 | - elseif (substr($sort, 0, 4) === 'path') |
|
516 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
517 | - else |
|
518 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
530 | + if (substr($sort, 0, 4) === 'name') { |
|
531 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
532 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
533 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
534 | + } else { |
|
535 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
536 | + } |
|
519 | 537 | |
520 | 538 | $smiley_sets = array(); |
521 | - foreach ($cols['id'] as $i => $id) |
|
522 | - $smiley_sets[] = array( |
|
539 | + foreach ($cols['id'] as $i => $id) { |
|
540 | + $smiley_sets[] = array( |
|
523 | 541 | 'id' => $id, |
524 | 542 | 'path' => $cols['path'][$i], |
525 | 543 | 'name' => $cols['name'][$i], |
526 | 544 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
527 | 545 | ); |
546 | + } |
|
528 | 547 | |
529 | 548 | return $smiley_sets; |
530 | 549 | } |
@@ -553,13 +572,14 @@ discard block |
||
553 | 572 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
554 | 573 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
555 | 574 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
556 | - foreach ($context['smiley_sets'] as $i => $set) |
|
557 | - $context['smiley_sets'][$i] = array( |
|
575 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
576 | + $context['smiley_sets'][$i] = array( |
|
558 | 577 | 'id' => $i, |
559 | 578 | 'path' => $smcFunc['htmlspecialchars']($set), |
560 | 579 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
561 | 580 | 'selected' => $set == $modSettings['smiley_sets_default'] |
562 | 581 | ); |
582 | + } |
|
563 | 583 | |
564 | 584 | // Submitting a form? |
565 | 585 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -575,8 +595,9 @@ discard block |
||
575 | 595 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
576 | 596 | |
577 | 597 | // Make sure some code was entered. |
578 | - if (empty($_POST['smiley_code'])) |
|
579 | - fatal_lang_error('smiley_has_no_code'); |
|
598 | + if (empty($_POST['smiley_code'])) { |
|
599 | + fatal_lang_error('smiley_has_no_code'); |
|
600 | + } |
|
580 | 601 | |
581 | 602 | // Check whether the new code has duplicates. It should be unique. |
582 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -588,8 +609,9 @@ discard block |
||
588 | 609 | 'smiley_code' => $_POST['smiley_code'], |
589 | 610 | ) |
590 | 611 | ); |
591 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
592 | - fatal_lang_error('smiley_not_unique'); |
|
612 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
613 | + fatal_lang_error('smiley_not_unique'); |
|
614 | + } |
|
593 | 615 | $smcFunc['db_free_result']($request); |
594 | 616 | |
595 | 617 | // If we are uploading - check all the smiley sets are writable! |
@@ -598,38 +620,44 @@ discard block |
||
598 | 620 | $writeErrors = array(); |
599 | 621 | foreach ($context['smiley_sets'] as $set) |
600 | 622 | { |
601 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
602 | - $writeErrors[] = $set['path']; |
|
623 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
624 | + $writeErrors[] = $set['path']; |
|
625 | + } |
|
626 | + } |
|
627 | + if (!empty($writeErrors)) { |
|
628 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
603 | 629 | } |
604 | - if (!empty($writeErrors)) |
|
605 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
606 | 630 | } |
607 | 631 | |
608 | 632 | // Uploading just one smiley for all of them? |
609 | 633 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
610 | 634 | { |
611 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
612 | - fatal_lang_error('smileys_upload_error'); |
|
635 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
636 | + fatal_lang_error('smileys_upload_error'); |
|
637 | + } |
|
613 | 638 | |
614 | 639 | // Sorry, no spaces, dots, or anything else but letters allowed. |
615 | 640 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
616 | 641 | |
617 | 642 | // We only allow image files - it's THAT simple - no messing around here... |
618 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
619 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
643 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
644 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
645 | + } |
|
620 | 646 | |
621 | 647 | // We only need the filename... |
622 | 648 | $destName = basename($_FILES['uploadSmiley']['name']); |
623 | 649 | |
624 | 650 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
625 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
626 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
651 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
652 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
653 | + } |
|
627 | 654 | |
628 | 655 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
629 | 656 | $i = 0; |
630 | 657 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
631 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
632 | - $i++; |
|
658 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
659 | + $i++; |
|
660 | + } |
|
633 | 661 | |
634 | 662 | // Okay, we're going to put the smiley right here, since it's not there yet! |
635 | 663 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -644,8 +672,9 @@ discard block |
||
644 | 672 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
645 | 673 | |
646 | 674 | // The file is already there! Don't overwrite it! |
647 | - if (file_exists($currentPath)) |
|
648 | - continue; |
|
675 | + if (file_exists($currentPath)) { |
|
676 | + continue; |
|
677 | + } |
|
649 | 678 | |
650 | 679 | // Okay, so copy the first one we made to here. |
651 | 680 | copy($smileyLocation, $currentPath); |
@@ -662,13 +691,15 @@ discard block |
||
662 | 691 | $newName = ''; |
663 | 692 | foreach ($_FILES as $name => $data) |
664 | 693 | { |
665 | - if ($_FILES[$name]['name'] == '') |
|
666 | - fatal_lang_error('smileys_upload_error_blank'); |
|
694 | + if ($_FILES[$name]['name'] == '') { |
|
695 | + fatal_lang_error('smileys_upload_error_blank'); |
|
696 | + } |
|
667 | 697 | |
668 | - if (empty($newName)) |
|
669 | - $newName = basename($_FILES[$name]['name']); |
|
670 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
671 | - fatal_lang_error('smileys_upload_error_name'); |
|
698 | + if (empty($newName)) { |
|
699 | + $newName = basename($_FILES[$name]['name']); |
|
700 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
701 | + fatal_lang_error('smileys_upload_error_name'); |
|
702 | + } |
|
672 | 703 | } |
673 | 704 | |
674 | 705 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -676,31 +707,36 @@ discard block |
||
676 | 707 | $set['name'] = un_htmlspecialchars($set['name']); |
677 | 708 | $set['path'] = un_htmlspecialchars($set['path']); |
678 | 709 | |
679 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
680 | - continue; |
|
710 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
711 | + continue; |
|
712 | + } |
|
681 | 713 | |
682 | 714 | // Got one... |
683 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
684 | - fatal_lang_error('smileys_upload_error'); |
|
715 | + if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) { |
|
716 | + fatal_lang_error('smileys_upload_error'); |
|
717 | + } |
|
685 | 718 | |
686 | 719 | // Sorry, no spaces, dots, or anything else but letters allowed. |
687 | 720 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
688 | 721 | |
689 | 722 | // We only allow image files - it's THAT simple - no messing around here... |
690 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
691 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
723 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
724 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
725 | + } |
|
692 | 726 | |
693 | 727 | // We only need the filename... |
694 | 728 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
695 | 729 | |
696 | 730 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
697 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
698 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
731 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
732 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
733 | + } |
|
699 | 734 | |
700 | 735 | // If the file exists - ignore it. |
701 | 736 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
702 | - if (file_exists($smileyLocation)) |
|
703 | - continue; |
|
737 | + if (file_exists($smileyLocation)) { |
|
738 | + continue; |
|
739 | + } |
|
704 | 740 | |
705 | 741 | // Finally - move the image! |
706 | 742 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -712,8 +748,9 @@ discard block |
||
712 | 748 | } |
713 | 749 | |
714 | 750 | // Also make sure a filename was given. |
715 | - if (empty($_POST['smiley_filename'])) |
|
716 | - fatal_lang_error('smiley_has_no_filename'); |
|
751 | + if (empty($_POST['smiley_filename'])) { |
|
752 | + fatal_lang_error('smiley_has_no_filename'); |
|
753 | + } |
|
717 | 754 | |
718 | 755 | // Find the position on the right. |
719 | 756 | $smiley_order = '0'; |
@@ -732,8 +769,9 @@ discard block |
||
732 | 769 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
733 | 770 | $smcFunc['db_free_result']($request); |
734 | 771 | |
735 | - if (empty($smiley_order)) |
|
736 | - $smiley_order = '0'; |
|
772 | + if (empty($smiley_order)) { |
|
773 | + $smiley_order = '0'; |
|
774 | + } |
|
737 | 775 | } |
738 | 776 | $smcFunc['db_insert']('', |
739 | 777 | '{db_prefix}smileys', |
@@ -761,17 +799,19 @@ discard block |
||
761 | 799 | { |
762 | 800 | foreach ($context['smiley_sets'] as $smiley_set) |
763 | 801 | { |
764 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
765 | - continue; |
|
802 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
803 | + continue; |
|
804 | + } |
|
766 | 805 | |
767 | 806 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
768 | 807 | while ($entry = $dir->read()) |
769 | 808 | { |
770 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
771 | - $context['filenames'][strtolower($entry)] = array( |
|
809 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
810 | + $context['filenames'][strtolower($entry)] = array( |
|
772 | 811 | 'id' => $smcFunc['htmlspecialchars']($entry), |
773 | 812 | 'selected' => false, |
774 | 813 | ); |
814 | + } |
|
775 | 815 | } |
776 | 816 | $dir->close(); |
777 | 817 | } |
@@ -809,17 +849,19 @@ discard block |
||
809 | 849 | // Changing the selected smileys? |
810 | 850 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
811 | 851 | { |
812 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
813 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
852 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
853 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
854 | + } |
|
814 | 855 | |
815 | - if ($_POST['smiley_action'] == 'delete') |
|
816 | - $smcFunc['db_query']('', ' |
|
856 | + if ($_POST['smiley_action'] == 'delete') { |
|
857 | + $smcFunc['db_query']('', ' |
|
817 | 858 | DELETE FROM {db_prefix}smileys |
818 | 859 | WHERE id_smiley IN ({array_int:checked_smileys})', |
819 | 860 | array( |
820 | 861 | 'checked_smileys' => $_POST['checked_smileys'], |
821 | 862 | ) |
822 | 863 | ); |
864 | + } |
|
823 | 865 | // Changing the status of the smiley? |
824 | 866 | else |
825 | 867 | { |
@@ -829,8 +871,8 @@ discard block |
||
829 | 871 | 'hidden' => 1, |
830 | 872 | 'popup' => 2 |
831 | 873 | ); |
832 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
833 | - $smcFunc['db_query']('', ' |
|
874 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
875 | + $smcFunc['db_query']('', ' |
|
834 | 876 | UPDATE {db_prefix}smileys |
835 | 877 | SET hidden = {int:display_type} |
836 | 878 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -839,6 +881,7 @@ discard block |
||
839 | 881 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
840 | 882 | ) |
841 | 883 | ); |
884 | + } |
|
842 | 885 | } |
843 | 886 | } |
844 | 887 | // Create/modify a smiley. |
@@ -864,12 +907,14 @@ discard block |
||
864 | 907 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
865 | 908 | |
866 | 909 | // Make sure some code was entered. |
867 | - if (empty($_POST['smiley_code'])) |
|
868 | - fatal_lang_error('smiley_has_no_code'); |
|
910 | + if (empty($_POST['smiley_code'])) { |
|
911 | + fatal_lang_error('smiley_has_no_code'); |
|
912 | + } |
|
869 | 913 | |
870 | 914 | // Also make sure a filename was given. |
871 | - if (empty($_POST['smiley_filename'])) |
|
872 | - fatal_lang_error('smiley_has_no_filename'); |
|
915 | + if (empty($_POST['smiley_filename'])) { |
|
916 | + fatal_lang_error('smiley_has_no_filename'); |
|
917 | + } |
|
873 | 918 | |
874 | 919 | // Check whether the new code has duplicates. It should be unique. |
875 | 920 | $request = $smcFunc['db_query']('', ' |
@@ -883,8 +928,9 @@ discard block |
||
883 | 928 | 'smiley_code' => $_POST['smiley_code'], |
884 | 929 | ) |
885 | 930 | ); |
886 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
887 | - fatal_lang_error('smiley_not_unique'); |
|
931 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
932 | + fatal_lang_error('smiley_not_unique'); |
|
933 | + } |
|
888 | 934 | $smcFunc['db_free_result']($request); |
889 | 935 | |
890 | 936 | $smcFunc['db_query']('', ' |
@@ -913,13 +959,14 @@ discard block |
||
913 | 959 | // Load all known smiley sets. |
914 | 960 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
915 | 961 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
916 | - foreach ($context['smiley_sets'] as $i => $set) |
|
917 | - $context['smiley_sets'][$i] = array( |
|
962 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
963 | + $context['smiley_sets'][$i] = array( |
|
918 | 964 | 'id' => $i, |
919 | 965 | 'path' => $smcFunc['htmlspecialchars']($set), |
920 | 966 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
921 | 967 | 'selected' => $set == $modSettings['smiley_sets_default'] |
922 | 968 | ); |
969 | + } |
|
923 | 970 | |
924 | 971 | // Prepare overview of all (custom) smileys. |
925 | 972 | if ($context['sub_action'] == 'editsmileys') |
@@ -935,9 +982,10 @@ discard block |
||
935 | 982 | // Create a list of options for selecting smiley sets. |
936 | 983 | $smileyset_option_list = ' |
937 | 984 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
938 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
939 | - $smileyset_option_list .= ' |
|
985 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
986 | + $smileyset_option_list .= ' |
|
940 | 987 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
988 | + } |
|
941 | 989 | $smileyset_option_list .= ' |
942 | 990 | </select>'; |
943 | 991 | |
@@ -999,12 +1047,13 @@ discard block |
||
999 | 1047 | 'data' => array( |
1000 | 1048 | 'function' => function ($rowData) use ($txt) |
1001 | 1049 | { |
1002 | - if (empty($rowData['hidden'])) |
|
1003 | - return $txt['smileys_location_form']; |
|
1004 | - elseif ($rowData['hidden'] == 1) |
|
1005 | - return $txt['smileys_location_hidden']; |
|
1006 | - else |
|
1007 | - return $txt['smileys_location_popup']; |
|
1050 | + if (empty($rowData['hidden'])) { |
|
1051 | + return $txt['smileys_location_form']; |
|
1052 | + } elseif ($rowData['hidden'] == 1) { |
|
1053 | + return $txt['smileys_location_hidden']; |
|
1054 | + } else { |
|
1055 | + return $txt['smileys_location_popup']; |
|
1056 | + } |
|
1008 | 1057 | }, |
1009 | 1058 | ), |
1010 | 1059 | 'sort' => array( |
@@ -1019,19 +1068,22 @@ discard block |
||
1019 | 1068 | 'data' => array( |
1020 | 1069 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
1021 | 1070 | { |
1022 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
1023 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1071 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
1072 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1073 | + } |
|
1024 | 1074 | |
1025 | 1075 | // Check if there are smileys missing in some sets. |
1026 | 1076 | $missing_sets = array(); |
1027 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
1028 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1077 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
1078 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1029 | 1079 | $missing_sets[] = $smiley_set['path']; |
1080 | + } |
|
1030 | 1081 | |
1031 | 1082 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
1032 | 1083 | |
1033 | - if (!empty($missing_sets)) |
|
1034 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1084 | + if (!empty($missing_sets)) { |
|
1085 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1086 | + } |
|
1035 | 1087 | |
1036 | 1088 | return $description; |
1037 | 1089 | }, |
@@ -1147,13 +1199,14 @@ discard block |
||
1147 | 1199 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
1148 | 1200 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
1149 | 1201 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
1150 | - foreach ($context['smiley_sets'] as $i => $set) |
|
1151 | - $context['smiley_sets'][$i] = array( |
|
1202 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
1203 | + $context['smiley_sets'][$i] = array( |
|
1152 | 1204 | 'id' => $i, |
1153 | 1205 | 'path' => $smcFunc['htmlspecialchars']($set), |
1154 | 1206 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
1155 | 1207 | 'selected' => $set == $modSettings['smiley_sets_default'] |
1156 | 1208 | ); |
1209 | + } |
|
1157 | 1210 | |
1158 | 1211 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
1159 | 1212 | |
@@ -1163,17 +1216,19 @@ discard block |
||
1163 | 1216 | { |
1164 | 1217 | foreach ($context['smiley_sets'] as $smiley_set) |
1165 | 1218 | { |
1166 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
1167 | - continue; |
|
1219 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
1220 | + continue; |
|
1221 | + } |
|
1168 | 1222 | |
1169 | 1223 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
1170 | 1224 | while ($entry = $dir->read()) |
1171 | 1225 | { |
1172 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1173 | - $context['filenames'][strtolower($entry)] = array( |
|
1226 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1227 | + $context['filenames'][strtolower($entry)] = array( |
|
1174 | 1228 | 'id' => $smcFunc['htmlspecialchars']($entry), |
1175 | 1229 | 'selected' => false, |
1176 | 1230 | ); |
1231 | + } |
|
1177 | 1232 | } |
1178 | 1233 | $dir->close(); |
1179 | 1234 | } |
@@ -1188,8 +1243,9 @@ discard block |
||
1188 | 1243 | 'current_smiley' => (int) $_REQUEST['smiley'], |
1189 | 1244 | ) |
1190 | 1245 | ); |
1191 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1192 | - fatal_lang_error('smiley_not_found'); |
|
1246 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1247 | + fatal_lang_error('smiley_not_found'); |
|
1248 | + } |
|
1193 | 1249 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
1194 | 1250 | $smcFunc['db_free_result']($request); |
1195 | 1251 | |
@@ -1197,8 +1253,9 @@ discard block |
||
1197 | 1253 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
1198 | 1254 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
1199 | 1255 | |
1200 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
1201 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1256 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
1257 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1258 | + } |
|
1202 | 1259 | } |
1203 | 1260 | } |
1204 | 1261 | |
@@ -1223,8 +1280,9 @@ discard block |
||
1223 | 1280 | ) |
1224 | 1281 | ); |
1225 | 1282 | $smileys = array(); |
1226 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1227 | - $smileys[] = $row; |
|
1283 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1284 | + $smileys[] = $row; |
|
1285 | + } |
|
1228 | 1286 | $smcFunc['db_free_result']($request); |
1229 | 1287 | |
1230 | 1288 | return $smileys; |
@@ -1264,8 +1322,9 @@ discard block |
||
1264 | 1322 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
1265 | 1323 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
1266 | 1324 | |
1267 | - if (empty($_GET['source'])) |
|
1268 | - fatal_lang_error('smiley_not_found'); |
|
1325 | + if (empty($_GET['source'])) { |
|
1326 | + fatal_lang_error('smiley_not_found'); |
|
1327 | + } |
|
1269 | 1328 | |
1270 | 1329 | if (!empty($_GET['after'])) |
1271 | 1330 | { |
@@ -1281,12 +1340,12 @@ discard block |
||
1281 | 1340 | 'after_smiley' => $_GET['after'], |
1282 | 1341 | ) |
1283 | 1342 | ); |
1284 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1285 | - fatal_lang_error('smiley_not_found'); |
|
1343 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1344 | + fatal_lang_error('smiley_not_found'); |
|
1345 | + } |
|
1286 | 1346 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
1287 | 1347 | $smcFunc['db_free_result']($request); |
1288 | - } |
|
1289 | - else |
|
1348 | + } else |
|
1290 | 1349 | { |
1291 | 1350 | $smiley_row = (int) $_GET['row']; |
1292 | 1351 | $smiley_order = -1; |
@@ -1360,14 +1419,15 @@ discard block |
||
1360 | 1419 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
1361 | 1420 | |
1362 | 1421 | // Make sure all rows are sequential. |
1363 | - foreach (array_keys($context['smileys']) as $location) |
|
1364 | - $context['smileys'][$location] = array( |
|
1422 | + foreach (array_keys($context['smileys']) as $location) { |
|
1423 | + $context['smileys'][$location] = array( |
|
1365 | 1424 | 'id' => $location, |
1366 | 1425 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
1367 | 1426 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
1368 | 1427 | 'last_row' => count($context['smileys'][$location]['rows']), |
1369 | 1428 | 'rows' => array_values($context['smileys'][$location]['rows']), |
1370 | 1429 | ); |
1430 | + } |
|
1371 | 1431 | |
1372 | 1432 | // Check & fix smileys that are not ordered properly in the database. |
1373 | 1433 | foreach (array_keys($context['smileys']) as $location) |
@@ -1392,8 +1452,8 @@ discard block |
||
1392 | 1452 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
1393 | 1453 | } |
1394 | 1454 | // Make sure the smiley order is always sequential. |
1395 | - foreach ($smiley_row as $order_id => $smiley) |
|
1396 | - if ($order_id != $smiley['order']) |
|
1455 | + foreach ($smiley_row as $order_id => $smiley) { |
|
1456 | + if ($order_id != $smiley['order']) |
|
1397 | 1457 | $smcFunc['db_query']('', ' |
1398 | 1458 | UPDATE {db_prefix}smileys |
1399 | 1459 | SET smiley_order = {int:new_order} |
@@ -1403,6 +1463,7 @@ discard block |
||
1403 | 1463 | 'current_smiley' => $smiley['id'], |
1404 | 1464 | ) |
1405 | 1465 | ); |
1466 | + } |
|
1406 | 1467 | } |
1407 | 1468 | } |
1408 | 1469 | |
@@ -1436,19 +1497,20 @@ discard block |
||
1436 | 1497 | |
1437 | 1498 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
1438 | 1499 | // @ TODO: Our current xml files serve http links. Allowing both for now until we serve https. |
1439 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
1440 | - fatal_lang_error('not_on_simplemachines'); |
|
1500 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
1501 | + fatal_lang_error('not_on_simplemachines'); |
|
1502 | + } |
|
1441 | 1503 | |
1442 | 1504 | $destination = $packagesdir . '/' . $base_name; |
1443 | 1505 | |
1444 | - if (file_exists($destination)) |
|
1445 | - fatal_lang_error('package_upload_error_exists'); |
|
1506 | + if (file_exists($destination)) { |
|
1507 | + fatal_lang_error('package_upload_error_exists'); |
|
1508 | + } |
|
1446 | 1509 | |
1447 | 1510 | // Let's copy it to the Packages directory |
1448 | 1511 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
1449 | 1512 | $testing = true; |
1450 | - } |
|
1451 | - elseif (isset($_REQUEST['package'])) |
|
1513 | + } elseif (isset($_REQUEST['package'])) |
|
1452 | 1514 | { |
1453 | 1515 | $base_name = basename($_REQUEST['package']); |
1454 | 1516 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1457,12 +1519,14 @@ discard block |
||
1457 | 1519 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
1458 | 1520 | } |
1459 | 1521 | |
1460 | - if (empty($destination) || !file_exists($destination)) |
|
1461 | - fatal_lang_error('package_no_file', false); |
|
1522 | + if (empty($destination) || !file_exists($destination)) { |
|
1523 | + fatal_lang_error('package_no_file', false); |
|
1524 | + } |
|
1462 | 1525 | |
1463 | 1526 | // Make sure temp directory exists and is empty. |
1464 | - if (file_exists($packagesdir . '/temp')) |
|
1465 | - deltree($packagesdir . '/temp', false); |
|
1527 | + if (file_exists($packagesdir . '/temp')) { |
|
1528 | + deltree($packagesdir . '/temp', false); |
|
1529 | + } |
|
1466 | 1530 | |
1467 | 1531 | if (!mktree($packagesdir . '/temp', 0755)) |
1468 | 1532 | { |
@@ -1474,31 +1538,37 @@ discard block |
||
1474 | 1538 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true)); |
1475 | 1539 | |
1476 | 1540 | deltree($packagesdir . '/temp', false); |
1477 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
1478 | - fatal_lang_error('package_cant_download', false); |
|
1541 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
1542 | + fatal_lang_error('package_cant_download', false); |
|
1543 | + } |
|
1479 | 1544 | } |
1480 | 1545 | } |
1481 | 1546 | |
1482 | 1547 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
1483 | - if (!$extracted) |
|
1484 | - fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1485 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
1486 | - foreach ($extracted as $file) |
|
1548 | + if (!$extracted) { |
|
1549 | + fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1550 | + } |
|
1551 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
1552 | + foreach ($extracted as $file) |
|
1487 | 1553 | if (basename($file['filename']) == 'package-info.xml') |
1488 | 1554 | { |
1489 | 1555 | $base_path = dirname($file['filename']) . '/'; |
1556 | + } |
|
1490 | 1557 | break; |
1491 | 1558 | } |
1492 | 1559 | |
1493 | - if (!isset($base_path)) |
|
1494 | - $base_path = ''; |
|
1560 | + if (!isset($base_path)) { |
|
1561 | + $base_path = ''; |
|
1562 | + } |
|
1495 | 1563 | |
1496 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
1497 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
1564 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
1565 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
1566 | + } |
|
1498 | 1567 | |
1499 | 1568 | $smileyInfo = getPackageInfo($context['filename']); |
1500 | - if (!is_array($smileyInfo)) |
|
1501 | - fatal_lang_error($smileyInfo); |
|
1569 | + if (!is_array($smileyInfo)) { |
|
1570 | + fatal_lang_error($smileyInfo); |
|
1571 | + } |
|
1502 | 1572 | |
1503 | 1573 | // See if it is installed? |
1504 | 1574 | $request = $smcFunc['db_query']('', ' |
@@ -1514,8 +1584,9 @@ discard block |
||
1514 | 1584 | ) |
1515 | 1585 | ); |
1516 | 1586 | |
1517 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1518 | - fatal_lang_error('package_installed_warning1'); |
|
1587 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1588 | + fatal_lang_error('package_installed_warning1'); |
|
1589 | + } |
|
1519 | 1590 | |
1520 | 1591 | // Everything is fine, now it's time to do something |
1521 | 1592 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1530,23 +1601,23 @@ discard block |
||
1530 | 1601 | if ($action['type'] == 'readme' || $action['type'] == 'license') |
1531 | 1602 | { |
1532 | 1603 | $type = 'package_' . $action['type']; |
1533 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
1534 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1535 | - elseif (file_exists($action['filename'])) |
|
1536 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1604 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
1605 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1606 | + } elseif (file_exists($action['filename'])) { |
|
1607 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1608 | + } |
|
1537 | 1609 | |
1538 | 1610 | if (!empty($action['parse_bbc'])) |
1539 | 1611 | { |
1540 | 1612 | require_once($sourcedir . '/Subs-Post.php'); |
1541 | 1613 | preparsecode($context[$type]); |
1542 | 1614 | $context[$type] = parse_bbc($context[$type]); |
1615 | + } else { |
|
1616 | + $context[$type] = nl2br($context[$type]); |
|
1543 | 1617 | } |
1544 | - else |
|
1545 | - $context[$type] = nl2br($context[$type]); |
|
1546 | 1618 | |
1547 | 1619 | continue; |
1548 | - } |
|
1549 | - elseif ($action['type'] == 'require-dir') |
|
1620 | + } elseif ($action['type'] == 'require-dir') |
|
1550 | 1621 | { |
1551 | 1622 | // Do this one... |
1552 | 1623 | $thisAction = array( |
@@ -1565,12 +1636,12 @@ discard block |
||
1565 | 1636 | ); |
1566 | 1637 | } |
1567 | 1638 | // @todo None given? |
1568 | - if (empty($thisAction['description'])) |
|
1569 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1639 | + if (empty($thisAction['description'])) { |
|
1640 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1641 | + } |
|
1570 | 1642 | |
1571 | 1643 | $context['actions'][] = $thisAction; |
1572 | - } |
|
1573 | - elseif ($action['type'] == 'credits') |
|
1644 | + } elseif ($action['type'] == 'credits') |
|
1574 | 1645 | { |
1575 | 1646 | // Time to build the billboard |
1576 | 1647 | $credits_tag = array( |
@@ -1630,12 +1701,14 @@ discard block |
||
1630 | 1701 | cache_put_data('posting_smileys', null, 480); |
1631 | 1702 | } |
1632 | 1703 | |
1633 | - if (file_exists($packagesdir . '/temp')) |
|
1634 | - deltree($packagesdir . '/temp'); |
|
1704 | + if (file_exists($packagesdir . '/temp')) { |
|
1705 | + deltree($packagesdir . '/temp'); |
|
1706 | + } |
|
1635 | 1707 | |
1636 | - if (!$testing) |
|
1637 | - redirectexit('action=admin;area=smileys'); |
|
1638 | -} |
|
1708 | + if (!$testing) { |
|
1709 | + redirectexit('action=admin;area=smileys'); |
|
1710 | + } |
|
1711 | + } |
|
1639 | 1712 | |
1640 | 1713 | /** |
1641 | 1714 | * A function to import new smileys from an existing directory into the database. |
@@ -1646,15 +1719,17 @@ discard block |
||
1646 | 1719 | { |
1647 | 1720 | global $modSettings, $smcFunc; |
1648 | 1721 | |
1649 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
1650 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
1722 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
1723 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
1724 | + } |
|
1651 | 1725 | |
1652 | 1726 | $smileys = array(); |
1653 | 1727 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
1654 | 1728 | while ($entry = $dir->read()) |
1655 | 1729 | { |
1656 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1657 | - $smileys[strtolower($entry)] = $entry; |
|
1730 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1731 | + $smileys[strtolower($entry)] = $entry; |
|
1732 | + } |
|
1658 | 1733 | } |
1659 | 1734 | $dir->close(); |
1660 | 1735 | |
@@ -1667,9 +1742,10 @@ discard block |
||
1667 | 1742 | 'smiley_list' => $smileys, |
1668 | 1743 | ) |
1669 | 1744 | ); |
1670 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1671 | - if (isset($smileys[strtolower($row['filename'])])) |
|
1745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1746 | + if (isset($smileys[strtolower($row['filename'])])) |
|
1672 | 1747 | unset($smileys[strtolower($row['filename'])]); |
1748 | + } |
|
1673 | 1749 | $smcFunc['db_free_result']($request); |
1674 | 1750 | |
1675 | 1751 | $request = $smcFunc['db_query']('', ' |
@@ -1686,9 +1762,10 @@ discard block |
||
1686 | 1762 | $smcFunc['db_free_result']($request); |
1687 | 1763 | |
1688 | 1764 | $new_smileys = array(); |
1689 | - foreach ($smileys as $smiley) |
|
1690 | - if (strlen($smiley) <= 48) |
|
1765 | + foreach ($smileys as $smiley) { |
|
1766 | + if (strlen($smiley) <= 48) |
|
1691 | 1767 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
1768 | + } |
|
1692 | 1769 | |
1693 | 1770 | if (!empty($new_smileys)) |
1694 | 1771 | { |
@@ -1753,8 +1830,9 @@ discard block |
||
1753 | 1830 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
1754 | 1831 | { |
1755 | 1832 | $deleteIcons = array(); |
1756 | - foreach ($_POST['checked_icons'] as $icon) |
|
1757 | - $deleteIcons[] = (int) $icon; |
|
1833 | + foreach ($_POST['checked_icons'] as $icon) { |
|
1834 | + $deleteIcons[] = (int) $icon; |
|
1835 | + } |
|
1758 | 1836 | |
1759 | 1837 | // Do the actual delete! |
1760 | 1838 | $smcFunc['db_query']('', ' |
@@ -1771,35 +1849,41 @@ discard block |
||
1771 | 1849 | $_GET['icon'] = (int) $_GET['icon']; |
1772 | 1850 | |
1773 | 1851 | // Do some preperation with the data... like check the icon exists *somewhere* |
1774 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
1775 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1776 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
1777 | - fatal_lang_error('icon_not_found'); |
|
1852 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
1853 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1854 | + } |
|
1855 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
1856 | + fatal_lang_error('icon_not_found'); |
|
1857 | + } |
|
1778 | 1858 | // There is a 16 character limit on message icons... |
1779 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
1780 | - fatal_lang_error('icon_name_too_long'); |
|
1781 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
1782 | - fatal_lang_error('icon_after_itself'); |
|
1859 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
1860 | + fatal_lang_error('icon_name_too_long'); |
|
1861 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
1862 | + fatal_lang_error('icon_after_itself'); |
|
1863 | + } |
|
1783 | 1864 | |
1784 | 1865 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
1785 | 1866 | if ($_GET['icon'] != 0) |
1786 | 1867 | { |
1787 | 1868 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
1788 | - foreach ($context['icons'] as $id => $data) |
|
1789 | - if ($data['true_order'] > $oldOrder) |
|
1869 | + foreach ($context['icons'] as $id => $data) { |
|
1870 | + if ($data['true_order'] > $oldOrder) |
|
1790 | 1871 | $context['icons'][$id]['true_order']--; |
1872 | + } |
|
1791 | 1873 | } |
1792 | 1874 | |
1793 | 1875 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
1794 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
1795 | - $_GET['icon'] = 1; |
|
1876 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
1877 | + $_GET['icon'] = 1; |
|
1878 | + } |
|
1796 | 1879 | |
1797 | 1880 | // Get the new order. |
1798 | 1881 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
1799 | 1882 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
1800 | - foreach ($context['icons'] as $id => $data) |
|
1801 | - if ($data['true_order'] >= $newOrder) |
|
1883 | + foreach ($context['icons'] as $id => $data) { |
|
1884 | + if ($data['true_order'] >= $newOrder) |
|
1802 | 1885 | $context['icons'][$id]['true_order']++; |
1886 | + } |
|
1803 | 1887 | |
1804 | 1888 | // Finally set the current icon's position! |
1805 | 1889 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1817,8 +1901,7 @@ discard block |
||
1817 | 1901 | if ($id != 0) |
1818 | 1902 | { |
1819 | 1903 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1820 | - } |
|
1821 | - else |
|
1904 | + } else |
|
1822 | 1905 | { |
1823 | 1906 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1824 | 1907 | } |
@@ -1843,8 +1926,9 @@ discard block |
||
1843 | 1926 | } |
1844 | 1927 | |
1845 | 1928 | // Unless we're adding a new thing, we'll escape |
1846 | - if (!isset($_POST['add'])) |
|
1847 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1929 | + if (!isset($_POST['add'])) { |
|
1930 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1931 | + } |
|
1848 | 1932 | } |
1849 | 1933 | |
1850 | 1934 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1954,8 +2038,9 @@ discard block |
||
1954 | 2038 | $context['new_icon'] = !isset($_GET['icon']); |
1955 | 2039 | |
1956 | 2040 | // Get the properties of the current icon from the icon list. |
1957 | - if (!$context['new_icon']) |
|
1958 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2041 | + if (!$context['new_icon']) { |
|
2042 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2043 | + } |
|
1959 | 2044 | |
1960 | 2045 | // Get a list of boards needed for assigning this icon to a specific board. |
1961 | 2046 | $boardListOptions = array( |
@@ -1989,8 +2074,9 @@ discard block |
||
1989 | 2074 | ); |
1990 | 2075 | |
1991 | 2076 | $message_icons = array(); |
1992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1993 | - $message_icons[] = $row; |
|
2077 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2078 | + $message_icons[] = $row; |
|
2079 | + } |
|
1994 | 2080 | $smcFunc['db_free_result']($request); |
1995 | 2081 | |
1996 | 2082 | return $message_icons; |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | 'member_name' => $regOptions['username'], |
587 | 587 | 'email_address' => $regOptions['email'], |
588 | 588 | 'passwd' => hash_password($regOptions['username'], $regOptions['password']), |
589 | - 'password_salt' => substr(md5(mt_rand()), 0, 4) , |
|
589 | + 'password_salt' => substr(md5(mt_rand()), 0, 4), |
|
590 | 590 | 'posts' => 0, |
591 | 591 | 'date_registered' => time(), |
592 | 592 | 'member_ip' => $regOptions['interface'] == 'admin' ? '127.0.0.1' : $user_info['ip'], |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | 'time_offset', |
677 | 677 | ); |
678 | 678 | $knownInets = array( |
679 | - 'member_ip','member_ip2', |
|
679 | + 'member_ip', 'member_ip2', |
|
680 | 680 | ); |
681 | 681 | |
682 | 682 | // Call an optional function to validate the users' input. |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
905 | 905 | |
906 | 906 | //when we got no wildcard we can use equal -> fast |
907 | - $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '=' ); |
|
907 | + $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '='); |
|
908 | 908 | |
909 | 909 | // Make sure they don't want someone else's name. |
910 | 910 | $request = $smcFunc['db_query']('', ' |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | $user_info['buddies'][] = $userReceiver; |
1274 | 1274 | |
1275 | 1275 | // And add a nice alert. Don't abuse though! |
1276 | - if ((cache_get_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, 86400)) == null) |
|
1276 | + if ((cache_get_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, 86400)) == null) |
|
1277 | 1277 | { |
1278 | 1278 | $smcFunc['db_insert']('insert', |
1279 | 1279 | '{db_prefix}background_tasks', |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | ); |
1289 | 1289 | |
1290 | 1290 | // Store this in a cache entry to avoid creating multiple alerts. Give it a long life cycle. |
1291 | - cache_put_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, '1', 86400); |
|
1291 | + cache_put_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, '1', 86400); |
|
1292 | 1292 | } |
1293 | 1293 | } |
1294 | 1294 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Delete one or more members. |
@@ -43,30 +44,32 @@ discard block |
||
43 | 44 | setMemoryLimit('128M'); |
44 | 45 | |
45 | 46 | // If it's not an array, make it so! |
46 | - if (!is_array($users)) |
|
47 | - $users = array($users); |
|
48 | - else |
|
49 | - $users = array_unique($users); |
|
47 | + if (!is_array($users)) { |
|
48 | + $users = array($users); |
|
49 | + } else { |
|
50 | + $users = array_unique($users); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // Make sure there's no void user in here. |
52 | 54 | $users = array_diff($users, array(0)); |
53 | 55 | |
54 | 56 | // How many are they deleting? |
55 | - if (empty($users)) |
|
56 | - return; |
|
57 | - elseif (count($users) == 1) |
|
57 | + if (empty($users)) { |
|
58 | + return; |
|
59 | + } elseif (count($users) == 1) |
|
58 | 60 | { |
59 | 61 | list ($user) = $users; |
60 | 62 | |
61 | - if ($user == $user_info['id']) |
|
62 | - isAllowedTo('profile_remove_own'); |
|
63 | - else |
|
64 | - isAllowedTo('profile_remove_any'); |
|
65 | - } |
|
66 | - else |
|
63 | + if ($user == $user_info['id']) { |
|
64 | + isAllowedTo('profile_remove_own'); |
|
65 | + } else { |
|
66 | + isAllowedTo('profile_remove_any'); |
|
67 | + } |
|
68 | + } else |
|
67 | 69 | { |
68 | - foreach ($users as $k => $v) |
|
69 | - $users[$k] = (int) $v; |
|
70 | + foreach ($users as $k => $v) { |
|
71 | + $users[$k] = (int) $v; |
|
72 | + } |
|
70 | 73 | |
71 | 74 | // Deleting more than one? You can't have more than one account... |
72 | 75 | isAllowedTo('profile_remove_any'); |
@@ -88,26 +91,30 @@ discard block |
||
88 | 91 | $user_log_details = array(); |
89 | 92 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
90 | 93 | { |
91 | - if ($row['is_admin']) |
|
92 | - $admins[] = $row['id_member']; |
|
94 | + if ($row['is_admin']) { |
|
95 | + $admins[] = $row['id_member']; |
|
96 | + } |
|
93 | 97 | $user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']); |
94 | 98 | } |
95 | 99 | $smcFunc['db_free_result']($request); |
96 | 100 | |
97 | - if (empty($user_log_details)) |
|
98 | - return; |
|
101 | + if (empty($user_log_details)) { |
|
102 | + return; |
|
103 | + } |
|
99 | 104 | |
100 | 105 | // Make sure they aren't trying to delete administrators if they aren't one. But don't bother checking if it's just themself. |
101 | 106 | if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id'])))) |
102 | 107 | { |
103 | 108 | $users = array_diff($users, $admins); |
104 | - foreach ($admins as $id) |
|
105 | - unset($user_log_details[$id]); |
|
109 | + foreach ($admins as $id) { |
|
110 | + unset($user_log_details[$id]); |
|
111 | + } |
|
106 | 112 | } |
107 | 113 | |
108 | 114 | // No one left? |
109 | - if (empty($users)) |
|
110 | - return; |
|
115 | + if (empty($users)) { |
|
116 | + return; |
|
117 | + } |
|
111 | 118 | |
112 | 119 | // Log the action - regardless of who is deleting it. |
113 | 120 | $log_changes = array(); |
@@ -124,8 +131,9 @@ discard block |
||
124 | 131 | ); |
125 | 132 | |
126 | 133 | // Remove any cached data if enabled. |
127 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
128 | - cache_put_data('user_settings-' . $user[0], null, 60); |
|
134 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
135 | + cache_put_data('user_settings-' . $user[0], null, 60); |
|
136 | + } |
|
129 | 137 | } |
130 | 138 | |
131 | 139 | // Make these peoples' posts guest posts. |
@@ -388,8 +396,8 @@ discard block |
||
388 | 396 | 'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users), |
389 | 397 | ) |
390 | 398 | ); |
391 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
392 | - $smcFunc['db_query']('', ' |
|
399 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
400 | + $smcFunc['db_query']('', ' |
|
393 | 401 | UPDATE {db_prefix}members |
394 | 402 | SET |
395 | 403 | pm_ignore_list = {string:pm_ignore_list}, |
@@ -401,6 +409,7 @@ discard block |
||
401 | 409 | 'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users)), |
402 | 410 | ) |
403 | 411 | ); |
412 | + } |
|
404 | 413 | $smcFunc['db_free_result']($request); |
405 | 414 | |
406 | 415 | // Make sure no member's birthday is still sticking in the calendar... |
@@ -455,29 +464,34 @@ discard block |
||
455 | 464 | elseif ($regOptions['interface'] == 'guest') |
456 | 465 | { |
457 | 466 | // You cannot register twice... |
458 | - if (empty($user_info['is_guest'])) |
|
459 | - redirectexit(); |
|
467 | + if (empty($user_info['is_guest'])) { |
|
468 | + redirectexit(); |
|
469 | + } |
|
460 | 470 | |
461 | 471 | // Make sure they didn't just register with this session. |
462 | - if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) |
|
463 | - fatal_lang_error('register_only_once', false); |
|
472 | + if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) { |
|
473 | + fatal_lang_error('register_only_once', false); |
|
474 | + } |
|
464 | 475 | } |
465 | 476 | |
466 | 477 | // Spaces and other odd characters are evil... |
467 | 478 | $regOptions['username'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $regOptions['username'])); |
468 | 479 | |
469 | 480 | // @todo Separate the sprintf? |
470 | - if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) |
|
471 | - $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
481 | + if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) { |
|
482 | + $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
483 | + } |
|
472 | 484 | |
473 | 485 | $username_validation_errors = validateUsername(0, $regOptions['username'], true, !empty($regOptions['check_reserved_name'])); |
474 | - if (!empty($username_validation_errors)) |
|
475 | - $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
486 | + if (!empty($username_validation_errors)) { |
|
487 | + $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
488 | + } |
|
476 | 489 | |
477 | 490 | // Generate a validation code if it's supposed to be emailed. |
478 | 491 | $validation_code = ''; |
479 | - if ($regOptions['require'] == 'activation') |
|
480 | - $validation_code = generateValidationCode(); |
|
492 | + if ($regOptions['require'] == 'activation') { |
|
493 | + $validation_code = generateValidationCode(); |
|
494 | + } |
|
481 | 495 | |
482 | 496 | // If you haven't put in a password generate one. |
483 | 497 | if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '') |
@@ -487,8 +501,9 @@ discard block |
||
487 | 501 | $regOptions['password_check'] = $regOptions['password']; |
488 | 502 | } |
489 | 503 | // Does the first password match the second? |
490 | - elseif ($regOptions['password'] != $regOptions['password_check']) |
|
491 | - $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
504 | + elseif ($regOptions['password'] != $regOptions['password_check']) { |
|
505 | + $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
506 | + } |
|
492 | 507 | |
493 | 508 | // That's kind of easy to guess... |
494 | 509 | if ($regOptions['password'] == '') |
@@ -502,13 +517,15 @@ discard block |
||
502 | 517 | $passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email'])); |
503 | 518 | |
504 | 519 | // Password isn't legal? |
505 | - if ($passwordError != null) |
|
506 | - $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
520 | + if ($passwordError != null) { |
|
521 | + $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
522 | + } |
|
507 | 523 | } |
508 | 524 | |
509 | 525 | // You may not be allowed to register this email. |
510 | - if (!empty($regOptions['check_email_ban'])) |
|
511 | - isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
526 | + if (!empty($regOptions['check_email_ban'])) { |
|
527 | + isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
528 | + } |
|
512 | 529 | |
513 | 530 | // Check if the email address is in use. |
514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -523,8 +540,9 @@ discard block |
||
523 | 540 | ) |
524 | 541 | ); |
525 | 542 | // @todo Separate the sprintf? |
526 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
527 | - $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
543 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
544 | + $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
545 | + } |
|
528 | 546 | |
529 | 547 | $smcFunc['db_free_result']($request); |
530 | 548 | |
@@ -539,24 +557,27 @@ discard block |
||
539 | 557 | 1 = The text/index. |
540 | 558 | 2 = Whether to log. |
541 | 559 | 3 = sprintf data if necessary. */ |
542 | - if ($error[0] == 'lang') |
|
543 | - loadLanguage('Errors'); |
|
560 | + if ($error[0] == 'lang') { |
|
561 | + loadLanguage('Errors'); |
|
562 | + } |
|
544 | 563 | $message = $error[0] == 'lang' ? (empty($error[3]) ? $txt[$error[1]] : vsprintf($txt[$error[1]], $error[3])) : $error[1]; |
545 | 564 | |
546 | 565 | // What to do, what to do, what to do. |
547 | 566 | if ($return_errors) |
548 | 567 | { |
549 | - if (!empty($error[2])) |
|
550 | - log_error($message, $error[2]); |
|
568 | + if (!empty($error[2])) { |
|
569 | + log_error($message, $error[2]); |
|
570 | + } |
|
551 | 571 | $reg_errors[$key] = $message; |
572 | + } else { |
|
573 | + fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
552 | 574 | } |
553 | - else |
|
554 | - fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
555 | 575 | } |
556 | 576 | |
557 | 577 | // If there's any errors left return them at once! |
558 | - if (!empty($reg_errors)) |
|
559 | - return $reg_errors; |
|
578 | + if (!empty($reg_errors)) { |
|
579 | + return $reg_errors; |
|
580 | + } |
|
560 | 581 | |
561 | 582 | $reservedVars = array( |
562 | 583 | 'actual_theme_url', |
@@ -578,8 +599,9 @@ discard block |
||
578 | 599 | ); |
579 | 600 | |
580 | 601 | // Can't change reserved vars. |
581 | - if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) |
|
582 | - fatal_lang_error('no_theme'); |
|
602 | + if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) { |
|
603 | + fatal_lang_error('no_theme'); |
|
604 | + } |
|
583 | 605 | |
584 | 606 | // Some of these might be overwritten. (the lower ones that are in the arrays below.) |
585 | 607 | $regOptions['register_vars'] = array( |
@@ -621,14 +643,17 @@ discard block |
||
621 | 643 | $regOptions['register_vars']['validation_code'] = ''; |
622 | 644 | } |
623 | 645 | // Maybe it can be activated right away? |
624 | - elseif ($regOptions['require'] == 'nothing') |
|
625 | - $regOptions['register_vars']['is_activated'] = 1; |
|
646 | + elseif ($regOptions['require'] == 'nothing') { |
|
647 | + $regOptions['register_vars']['is_activated'] = 1; |
|
648 | + } |
|
626 | 649 | // Maybe it must be activated by email? |
627 | - elseif ($regOptions['require'] == 'activation') |
|
628 | - $regOptions['register_vars']['is_activated'] = 0; |
|
650 | + elseif ($regOptions['require'] == 'activation') { |
|
651 | + $regOptions['register_vars']['is_activated'] = 0; |
|
652 | + } |
|
629 | 653 | // Otherwise it must be awaiting approval! |
630 | - else |
|
631 | - $regOptions['register_vars']['is_activated'] = 3; |
|
654 | + else { |
|
655 | + $regOptions['register_vars']['is_activated'] = 3; |
|
656 | + } |
|
632 | 657 | |
633 | 658 | if (isset($regOptions['memberGroup'])) |
634 | 659 | { |
@@ -647,24 +672,28 @@ discard block |
||
647 | 672 | 'is_protected' => 1, |
648 | 673 | ) |
649 | 674 | ); |
650 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
651 | - $unassignableGroups[] = $row['id_group']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $unassignableGroups[] = $row['id_group']; |
|
677 | + } |
|
652 | 678 | $smcFunc['db_free_result']($request); |
653 | 679 | |
654 | - if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) |
|
655 | - $regOptions['register_vars']['id_group'] = 0; |
|
680 | + if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) { |
|
681 | + $regOptions['register_vars']['id_group'] = 0; |
|
682 | + } |
|
656 | 683 | } |
657 | 684 | |
658 | 685 | // Integrate optional member settings to be set. |
659 | - if (!empty($regOptions['extra_register_vars'])) |
|
660 | - foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
686 | + if (!empty($regOptions['extra_register_vars'])) { |
|
687 | + foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
661 | 688 | $regOptions['register_vars'][$var] = $value; |
689 | + } |
|
662 | 690 | |
663 | 691 | // Integrate optional user theme options to be set. |
664 | 692 | $theme_vars = array(); |
665 | - if (!empty($regOptions['theme_vars'])) |
|
666 | - foreach ($regOptions['theme_vars'] as $var => $value) |
|
693 | + if (!empty($regOptions['theme_vars'])) { |
|
694 | + foreach ($regOptions['theme_vars'] as $var => $value) |
|
667 | 695 | $theme_vars[$var] = $value; |
696 | + } |
|
668 | 697 | |
669 | 698 | // Right, now let's prepare for insertion. |
670 | 699 | $knownInts = array( |
@@ -687,14 +716,15 @@ discard block |
||
687 | 716 | foreach ($regOptions['register_vars'] as $var => $val) |
688 | 717 | { |
689 | 718 | $type = 'string'; |
690 | - if (in_array($var, $knownInts)) |
|
691 | - $type = 'int'; |
|
692 | - elseif (in_array($var, $knownFloats)) |
|
693 | - $type = 'float'; |
|
694 | - elseif (in_array($var, $knownInets)) |
|
695 | - $type = 'inet'; |
|
696 | - elseif ($var == 'birthdate') |
|
697 | - $type = 'date'; |
|
719 | + if (in_array($var, $knownInts)) { |
|
720 | + $type = 'int'; |
|
721 | + } elseif (in_array($var, $knownFloats)) { |
|
722 | + $type = 'float'; |
|
723 | + } elseif (in_array($var, $knownInets)) { |
|
724 | + $type = 'inet'; |
|
725 | + } elseif ($var == 'birthdate') { |
|
726 | + $type = 'date'; |
|
727 | + } |
|
698 | 728 | |
699 | 729 | $column_names[$var] = $type; |
700 | 730 | $values[$var] = $val; |
@@ -713,17 +743,19 @@ discard block |
||
713 | 743 | call_integration_hook('integrate_post_register', array(&$regOptions, &$theme_vars, &$memberID)); |
714 | 744 | |
715 | 745 | // Update the number of members and latest member's info - and pass the name, but remove the 's. |
716 | - if ($regOptions['register_vars']['is_activated'] == 1) |
|
717 | - updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
718 | - else |
|
719 | - updateStats('member'); |
|
746 | + if ($regOptions['register_vars']['is_activated'] == 1) { |
|
747 | + updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
748 | + } else { |
|
749 | + updateStats('member'); |
|
750 | + } |
|
720 | 751 | |
721 | 752 | // Theme variables too? |
722 | 753 | if (!empty($theme_vars)) |
723 | 754 | { |
724 | 755 | $inserts = array(); |
725 | - foreach ($theme_vars as $var => $val) |
|
726 | - $inserts[] = array($memberID, $var, $val); |
|
756 | + foreach ($theme_vars as $var => $val) { |
|
757 | + $inserts[] = array($memberID, $var, $val); |
|
758 | + } |
|
727 | 759 | $smcFunc['db_insert']('insert', |
728 | 760 | '{db_prefix}themes', |
729 | 761 | array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
@@ -738,10 +770,11 @@ discard block |
||
738 | 770 | // Administrative registrations are a bit different... |
739 | 771 | if ($regOptions['interface'] == 'admin') |
740 | 772 | { |
741 | - if ($regOptions['require'] == 'activation') |
|
742 | - $email_message = 'admin_register_activate'; |
|
743 | - elseif (!empty($regOptions['send_welcome_email'])) |
|
744 | - $email_message = 'admin_register_immediate'; |
|
773 | + if ($regOptions['require'] == 'activation') { |
|
774 | + $email_message = 'admin_register_activate'; |
|
775 | + } elseif (!empty($regOptions['send_welcome_email'])) { |
|
776 | + $email_message = 'admin_register_immediate'; |
|
777 | + } |
|
745 | 778 | |
746 | 779 | if (isset($email_message)) |
747 | 780 | { |
@@ -792,16 +825,17 @@ discard block |
||
792 | 825 | 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', |
793 | 826 | ); |
794 | 827 | |
795 | - if ($regOptions['require'] == 'activation') |
|
796 | - $replacements += array( |
|
828 | + if ($regOptions['require'] == 'activation') { |
|
829 | + $replacements += array( |
|
797 | 830 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code, |
798 | 831 | 'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID, |
799 | 832 | 'ACTIVATIONCODE' => $validation_code, |
800 | 833 | ); |
801 | - else |
|
802 | - $replacements += array( |
|
834 | + } else { |
|
835 | + $replacements += array( |
|
803 | 836 | 'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID, |
804 | 837 | ); |
838 | + } |
|
805 | 839 | |
806 | 840 | $emaildata = loadEmailTemplate('register_' . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements); |
807 | 841 | |
@@ -866,39 +900,45 @@ discard block |
||
866 | 900 | // Check each name in the list... |
867 | 901 | foreach ($reservedNames as $reserved) |
868 | 902 | { |
869 | - if ($reserved == '') |
|
870 | - continue; |
|
903 | + if ($reserved == '') { |
|
904 | + continue; |
|
905 | + } |
|
871 | 906 | |
872 | 907 | // The admin might've used entities too, level the playing field. |
873 | 908 | $reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved); |
874 | 909 | |
875 | 910 | // Case sensitive name? |
876 | - if (empty($modSettings['reserveCase'])) |
|
877 | - $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
911 | + if (empty($modSettings['reserveCase'])) { |
|
912 | + $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
913 | + } |
|
878 | 914 | |
879 | 915 | // If it's not just entire word, check for it in there somewhere... |
880 | - if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) |
|
881 | - if ($fatal) |
|
916 | + if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) { |
|
917 | + if ($fatal) |
|
882 | 918 | fatal_lang_error('username_reserved', 'password', array($reserved)); |
883 | - else |
|
884 | - return true; |
|
919 | + } else { |
|
920 | + return true; |
|
921 | + } |
|
885 | 922 | } |
886 | 923 | |
887 | 924 | $censor_name = $name; |
888 | - if (censorText($censor_name) != $name) |
|
889 | - if ($fatal) |
|
925 | + if (censorText($censor_name) != $name) { |
|
926 | + if ($fatal) |
|
890 | 927 | fatal_lang_error('name_censored', 'password', array($name)); |
891 | - else |
|
892 | - return true; |
|
928 | + } else { |
|
929 | + return true; |
|
930 | + } |
|
893 | 931 | } |
894 | 932 | |
895 | 933 | // Characters we just shouldn't allow, regardless. |
896 | - foreach (array('*') as $char) |
|
897 | - if (strpos($checkName, $char) !== false) |
|
934 | + foreach (array('*') as $char) { |
|
935 | + if (strpos($checkName, $char) !== false) |
|
898 | 936 | if ($fatal) |
899 | 937 | fatal_lang_error('username_reserved', 'password', array($char)); |
900 | - else |
|
901 | - return true; |
|
938 | + } |
|
939 | + else { |
|
940 | + return true; |
|
941 | + } |
|
902 | 942 | |
903 | 943 | // Get rid of any SQL parts of the reserved name... |
904 | 944 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
@@ -980,8 +1020,9 @@ discard block |
||
980 | 1020 | 'permission' => $permission, |
981 | 1021 | ) |
982 | 1022 | ); |
983 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
984 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1023 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1024 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1025 | + } |
|
985 | 1026 | $smcFunc['db_free_result']($request); |
986 | 1027 | } |
987 | 1028 | |
@@ -989,9 +1030,9 @@ discard block |
||
989 | 1030 | else |
990 | 1031 | { |
991 | 1032 | // First get the profile of the given board. |
992 | - if (isset($board_info['id']) && $board_info['id'] == $board_id) |
|
993 | - $profile_id = $board_info['profile']; |
|
994 | - elseif ($board_id !== 0) |
|
1033 | + if (isset($board_info['id']) && $board_info['id'] == $board_id) { |
|
1034 | + $profile_id = $board_info['profile']; |
|
1035 | + } elseif ($board_id !== 0) |
|
995 | 1036 | { |
996 | 1037 | $request = $smcFunc['db_query']('', ' |
997 | 1038 | SELECT id_profile |
@@ -1002,13 +1043,14 @@ discard block |
||
1002 | 1043 | 'id_board' => $board_id, |
1003 | 1044 | ) |
1004 | 1045 | ); |
1005 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1006 | - fatal_lang_error('no_board'); |
|
1046 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1047 | + fatal_lang_error('no_board'); |
|
1048 | + } |
|
1007 | 1049 | list ($profile_id) = $smcFunc['db_fetch_row']($request); |
1008 | 1050 | $smcFunc['db_free_result']($request); |
1051 | + } else { |
|
1052 | + $profile_id = 1; |
|
1009 | 1053 | } |
1010 | - else |
|
1011 | - $profile_id = 1; |
|
1012 | 1054 | |
1013 | 1055 | $request = $smcFunc['db_query']('', ' |
1014 | 1056 | SELECT bp.id_group, bp.add_deny |
@@ -1020,8 +1062,9 @@ discard block |
||
1020 | 1062 | 'permission' => $permission, |
1021 | 1063 | ) |
1022 | 1064 | ); |
1023 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1024 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1065 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1066 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1067 | + } |
|
1025 | 1068 | $smcFunc['db_free_result']($request); |
1026 | 1069 | |
1027 | 1070 | $moderator_groups = array(); |
@@ -1030,8 +1073,7 @@ discard block |
||
1030 | 1073 | if (isset($board_info['moderator_groups'])) |
1031 | 1074 | { |
1032 | 1075 | $moderator_groups = array_keys($board_info['moderator_groups']); |
1033 | - } |
|
1034 | - elseif ($board_id !== 0) |
|
1076 | + } elseif ($board_id !== 0) |
|
1035 | 1077 | { |
1036 | 1078 | // Get the groups that can moderate this board |
1037 | 1079 | $request = $smcFunc['db_query']('', ' |
@@ -1116,8 +1158,9 @@ discard block |
||
1116 | 1158 | ) |
1117 | 1159 | ); |
1118 | 1160 | $members = array(); |
1119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1120 | - $members[] = $row['id_member']; |
|
1161 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1162 | + $members[] = $row['id_member']; |
|
1163 | + } |
|
1121 | 1164 | $smcFunc['db_free_result']($request); |
1122 | 1165 | |
1123 | 1166 | return $members; |
@@ -1190,10 +1233,12 @@ discard block |
||
1190 | 1233 | } |
1191 | 1234 | |
1192 | 1235 | $query_parts = array(); |
1193 | - if (!empty($email)) |
|
1194 | - $query_parts[] = 'poster_email = {string:email_address}'; |
|
1195 | - if (!empty($membername)) |
|
1196 | - $query_parts[] = 'poster_name = {string:member_name}'; |
|
1236 | + if (!empty($email)) { |
|
1237 | + $query_parts[] = 'poster_email = {string:email_address}'; |
|
1238 | + } |
|
1239 | + if (!empty($membername)) { |
|
1240 | + $query_parts[] = 'poster_name = {string:member_name}'; |
|
1241 | + } |
|
1197 | 1242 | $query = implode(' AND ', $query_parts); |
1198 | 1243 | |
1199 | 1244 | // Finally, update the posts themselves! |
@@ -1260,12 +1305,14 @@ discard block |
||
1260 | 1305 | |
1261 | 1306 | $userReceiver = (int) !empty($_REQUEST['u']) ? $_REQUEST['u'] : 0; |
1262 | 1307 | |
1263 | - if (empty($userReceiver)) |
|
1264 | - fatal_lang_error('no_access', false); |
|
1308 | + if (empty($userReceiver)) { |
|
1309 | + fatal_lang_error('no_access', false); |
|
1310 | + } |
|
1265 | 1311 | |
1266 | 1312 | // Remove if it's already there... |
1267 | - if (in_array($userReceiver, $user_info['buddies'])) |
|
1268 | - $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
1313 | + if (in_array($userReceiver, $user_info['buddies'])) { |
|
1314 | + $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
1315 | + } |
|
1269 | 1316 | |
1270 | 1317 | // ...or add if it's not and if it's not you. |
1271 | 1318 | elseif ($user_info['id'] != $userReceiver) |
@@ -1340,8 +1387,9 @@ discard block |
||
1340 | 1387 | $smcFunc['db_free_result']($request); |
1341 | 1388 | |
1342 | 1389 | // If we want duplicates pass the members array off. |
1343 | - if ($get_duplicates) |
|
1344 | - populateDuplicateMembers($members); |
|
1390 | + if ($get_duplicates) { |
|
1391 | + populateDuplicateMembers($members); |
|
1392 | + } |
|
1345 | 1393 | |
1346 | 1394 | return $members; |
1347 | 1395 | } |
@@ -1358,8 +1406,9 @@ discard block |
||
1358 | 1406 | global $smcFunc, $modSettings; |
1359 | 1407 | |
1360 | 1408 | // We know how many members there are in total. |
1361 | - if (empty($where) || $where == '1=1') |
|
1362 | - $num_members = $modSettings['totalMembers']; |
|
1409 | + if (empty($where) || $where == '1=1') { |
|
1410 | + $num_members = $modSettings['totalMembers']; |
|
1411 | + } |
|
1363 | 1412 | |
1364 | 1413 | // The database knows the amount when there are extra conditions. |
1365 | 1414 | else |
@@ -1395,16 +1444,19 @@ discard block |
||
1395 | 1444 | $members[$key]['duplicate_members'] = array(); |
1396 | 1445 | |
1397 | 1446 | // Store the IPs. |
1398 | - if (!empty($member['member_ip'])) |
|
1399 | - $ips[] = $member['member_ip']; |
|
1400 | - if (!empty($member['member_ip2'])) |
|
1401 | - $ips[] = $member['member_ip2']; |
|
1447 | + if (!empty($member['member_ip'])) { |
|
1448 | + $ips[] = $member['member_ip']; |
|
1449 | + } |
|
1450 | + if (!empty($member['member_ip2'])) { |
|
1451 | + $ips[] = $member['member_ip2']; |
|
1452 | + } |
|
1402 | 1453 | } |
1403 | 1454 | |
1404 | 1455 | $ips = array_unique($ips); |
1405 | 1456 | |
1406 | - if (empty($ips)) |
|
1407 | - return false; |
|
1457 | + if (empty($ips)) { |
|
1458 | + return false; |
|
1459 | + } |
|
1408 | 1460 | |
1409 | 1461 | // Fetch all members with this IP address, we'll filter out the current ones in a sec. |
1410 | 1462 | $request = $smcFunc['db_query']('', ' |
@@ -1434,10 +1486,12 @@ discard block |
||
1434 | 1486 | 'ip2' => $row['member_ip2'], |
1435 | 1487 | ); |
1436 | 1488 | |
1437 | - if (in_array($row['member_ip'], $ips)) |
|
1438 | - $duplicate_members[$row['member_ip']][] = $member_context; |
|
1439 | - if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) |
|
1440 | - $duplicate_members[$row['member_ip2']][] = $member_context; |
|
1489 | + if (in_array($row['member_ip'], $ips)) { |
|
1490 | + $duplicate_members[$row['member_ip']][] = $member_context; |
|
1491 | + } |
|
1492 | + if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) { |
|
1493 | + $duplicate_members[$row['member_ip2']][] = $member_context; |
|
1494 | + } |
|
1441 | 1495 | } |
1442 | 1496 | $smcFunc['db_free_result']($request); |
1443 | 1497 | |
@@ -1462,8 +1516,9 @@ discard block |
||
1462 | 1516 | $row['poster_ip'] = inet_dtop($row['poster_ip']); |
1463 | 1517 | |
1464 | 1518 | // Don't collect lots of the same. |
1465 | - if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) |
|
1466 | - continue; |
|
1519 | + if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) { |
|
1520 | + continue; |
|
1521 | + } |
|
1467 | 1522 | $had_ips[$row['poster_ip']][] = $row['id_member']; |
1468 | 1523 | |
1469 | 1524 | $duplicate_members[$row['poster_ip']][] = array( |
@@ -1478,13 +1533,15 @@ discard block |
||
1478 | 1533 | $smcFunc['db_free_result']($request); |
1479 | 1534 | |
1480 | 1535 | // Now we have all the duplicate members, stick them with their respective member in the list. |
1481 | - if (!empty($duplicate_members)) |
|
1482 | - foreach ($members as $key => $member) |
|
1536 | + if (!empty($duplicate_members)) { |
|
1537 | + foreach ($members as $key => $member) |
|
1483 | 1538 | { |
1484 | 1539 | if (isset($duplicate_members[$member['member_ip']])) |
1485 | 1540 | $members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']]; |
1486 | - if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) |
|
1487 | - $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
1541 | + } |
|
1542 | + if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) { |
|
1543 | + $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
1544 | + } |
|
1488 | 1545 | |
1489 | 1546 | // Check we don't have lots of the same member. |
1490 | 1547 | $member_track = array($member['id_member']); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | else |
238 | 238 | { |
239 | 239 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
240 | - AND b.id_board != {int:recycle_board}' : ''). ' |
|
240 | + AND b.id_board != {int:recycle_board}' : '') . ' |
|
241 | 241 | AND m.id_msg >= {int:max_id_msg}'; |
242 | 242 | $query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6); |
243 | 243 | $query_parameters['recycle_board'] = $modSettings['recycle_board']; |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | ); |
1125 | 1125 | else |
1126 | 1126 | $request = $smcFunc['db_query']('', ' |
1127 | - SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
|
1127 | + SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'] . ' |
|
1128 | 1128 | FROM {db_prefix}topics AS t |
1129 | 1129 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
1130 | 1130 | INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : ' |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | if ($is_topics) |
1392 | 1392 | { |
1393 | 1393 | $context['recent_buttons'] = array( |
1394 | - 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1394 | + 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1395 | 1395 | ); |
1396 | 1396 | |
1397 | 1397 | if ($context['showCheckboxes']) |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | elseif (!$is_topics && isset($context['topics_to_mark'])) |
1408 | 1408 | { |
1409 | 1409 | $context['recent_buttons'] = array( |
1410 | - 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1410 | + 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1411 | 1411 | ); |
1412 | 1412 | |
1413 | 1413 | if ($context['showCheckboxes']) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | 'is_approved' => 1, |
45 | 46 | ) |
46 | 47 | ); |
47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
48 | - return array(); |
|
48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
49 | + return array(); |
|
50 | + } |
|
49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
50 | 52 | $smcFunc['db_free_result']($request); |
51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | censorText($row['body']); |
55 | 57 | |
56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | // Send the data. |
61 | 64 | return array( |
@@ -83,15 +86,17 @@ discard block |
||
83 | 86 | |
84 | 87 | $context['is_redirect'] = false; |
85 | 88 | |
86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
87 | - $_REQUEST['start'] = 95; |
|
89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
90 | + $_REQUEST['start'] = 95; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $query_parameters = array(); |
90 | 94 | if (!empty($_REQUEST['c']) && empty($board)) |
91 | 95 | { |
92 | 96 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
93 | - foreach ($_REQUEST['c'] as $i => $c) |
|
94 | - $_REQUEST['c'][$i] = (int) $c; |
|
97 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
98 | + $_REQUEST['c'][$i] = (int) $c; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | if (count($_REQUEST['c']) == 1) |
97 | 102 | { |
@@ -107,8 +112,9 @@ discard block |
||
107 | 112 | list ($name) = $smcFunc['db_fetch_row']($request); |
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | - if (empty($name)) |
|
111 | - fatal_lang_error('no_access', false); |
|
115 | + if (empty($name)) { |
|
116 | + fatal_lang_error('no_access', false); |
|
117 | + } |
|
112 | 118 | |
113 | 119 | $context['linktree'][] = array( |
114 | 120 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -140,8 +146,9 @@ discard block |
||
140 | 146 | } |
141 | 147 | $smcFunc['db_free_result']($request); |
142 | 148 | |
143 | - if (empty($boards)) |
|
144 | - fatal_lang_error('error_no_boards_selected'); |
|
149 | + if (empty($boards)) { |
|
150 | + fatal_lang_error('error_no_boards_selected'); |
|
151 | + } |
|
145 | 152 | |
146 | 153 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
147 | 154 | $query_parameters['boards'] = $boards; |
@@ -155,12 +162,12 @@ discard block |
||
155 | 162 | } |
156 | 163 | |
157 | 164 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
158 | - } |
|
159 | - elseif (!empty($_REQUEST['boards'])) |
|
165 | + } elseif (!empty($_REQUEST['boards'])) |
|
160 | 166 | { |
161 | 167 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
162 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
163 | - $_REQUEST['boards'][$i] = (int) $b; |
|
168 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
169 | + $_REQUEST['boards'][$i] = (int) $b; |
|
170 | + } |
|
164 | 171 | |
165 | 172 | $request = $smcFunc['db_query']('', ' |
166 | 173 | SELECT b.id_board, b.num_posts |
@@ -184,8 +191,9 @@ discard block |
||
184 | 191 | } |
185 | 192 | $smcFunc['db_free_result']($request); |
186 | 193 | |
187 | - if (empty($boards)) |
|
188 | - fatal_lang_error('error_no_boards_selected'); |
|
194 | + if (empty($boards)) { |
|
195 | + fatal_lang_error('error_no_boards_selected'); |
|
196 | + } |
|
189 | 197 | |
190 | 198 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
191 | 199 | $query_parameters['boards'] = $boards; |
@@ -199,8 +207,7 @@ discard block |
||
199 | 207 | } |
200 | 208 | |
201 | 209 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
202 | - } |
|
203 | - elseif (!empty($board)) |
|
210 | + } elseif (!empty($board)) |
|
204 | 211 | { |
205 | 212 | $request = $smcFunc['db_query']('', ' |
206 | 213 | SELECT num_posts, redirect |
@@ -233,8 +240,7 @@ discard block |
||
233 | 240 | } |
234 | 241 | |
235 | 242 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
236 | - } |
|
237 | - else |
|
243 | + } else |
|
238 | 244 | { |
239 | 245 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
240 | 246 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -269,8 +275,9 @@ discard block |
||
269 | 275 | ); |
270 | 276 | |
271 | 277 | // If you selected a redirection board, don't try getting posts for it... |
272 | - if ($context['is_redirect']) |
|
273 | - $messages = 0; |
|
278 | + if ($context['is_redirect']) { |
|
279 | + $messages = 0; |
|
280 | + } |
|
274 | 281 | |
275 | 282 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
276 | 283 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -301,16 +308,18 @@ discard block |
||
301 | 308 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
302 | 309 | $cache_results = true; |
303 | 310 | unset($query_parameters['max_id_msg']); |
311 | + } else { |
|
312 | + $done = true; |
|
304 | 313 | } |
305 | - else |
|
306 | - $done = true; |
|
307 | 314 | } |
308 | 315 | $messages = array(); |
309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
310 | - $messages[] = $row['id_msg']; |
|
316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
317 | + $messages[] = $row['id_msg']; |
|
318 | + } |
|
311 | 319 | $smcFunc['db_free_result']($request); |
312 | - if (!empty($cache_results)) |
|
313 | - cache_put_data($key, $messages, 120); |
|
320 | + if (!empty($cache_results)) { |
|
321 | + cache_put_data($key, $messages, 120); |
|
322 | + } |
|
314 | 323 | } |
315 | 324 | |
316 | 325 | // Nothing here... Or at least, nothing you can see... |
@@ -397,8 +406,9 @@ discard block |
||
397 | 406 | 'css_class' => 'windowbg', |
398 | 407 | ); |
399 | 408 | |
400 | - if ($user_info['id'] == $row['id_first_member']) |
|
401 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
409 | + if ($user_info['id'] == $row['id_first_member']) { |
|
410 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
411 | + } |
|
402 | 412 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
403 | 413 | } |
404 | 414 | $smcFunc['db_free_result']($request); |
@@ -424,20 +434,23 @@ discard block |
||
424 | 434 | $boards = boardsAllowedTo($permission); |
425 | 435 | |
426 | 436 | // If 0 is the only thing in the array, they can do it everywhere! |
427 | - if (!empty($boards) && $boards[0] == 0) |
|
428 | - $boards = array_keys($board_ids[$type]); |
|
437 | + if (!empty($boards) && $boards[0] == 0) { |
|
438 | + $boards = array_keys($board_ids[$type]); |
|
439 | + } |
|
429 | 440 | |
430 | 441 | // Go through the boards, and look for posts they can do this on. |
431 | 442 | foreach ($boards as $board_id) |
432 | 443 | { |
433 | 444 | // Hmm, they have permission, but there are no topics from that board on this page. |
434 | - if (!isset($board_ids[$type][$board_id])) |
|
435 | - continue; |
|
445 | + if (!isset($board_ids[$type][$board_id])) { |
|
446 | + continue; |
|
447 | + } |
|
436 | 448 | |
437 | 449 | // Okay, looks like they can do it for these posts. |
438 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
439 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
450 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
451 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
440 | 452 | $context['posts'][$counter][$allowed] = true; |
453 | + } |
|
441 | 454 | } |
442 | 455 | } |
443 | 456 | } |
@@ -480,17 +493,19 @@ discard block |
||
480 | 493 | $context['showing_all_topics'] = isset($_GET['all']); |
481 | 494 | $context['start'] = (int) $_REQUEST['start']; |
482 | 495 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
483 | - if ($_REQUEST['action'] == 'unread') |
|
484 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
485 | - else |
|
486 | - $context['page_title'] = $txt['unread_replies']; |
|
496 | + if ($_REQUEST['action'] == 'unread') { |
|
497 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
498 | + } else { |
|
499 | + $context['page_title'] = $txt['unread_replies']; |
|
500 | + } |
|
487 | 501 | |
488 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
489 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
490 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
491 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
492 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
493 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
502 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
503 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
504 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
505 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
506 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
507 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
508 | + } |
|
494 | 509 | |
495 | 510 | // Parameters for the main query. |
496 | 511 | $query_parameters = array(); |
@@ -503,12 +518,14 @@ discard block |
||
503 | 518 | if (!empty($_REQUEST['boards'])) |
504 | 519 | { |
505 | 520 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
506 | - foreach ($_REQUEST['boards'] as $b) |
|
507 | - $boards[] = (int) $b; |
|
521 | + foreach ($_REQUEST['boards'] as $b) { |
|
522 | + $boards[] = (int) $b; |
|
523 | + } |
|
508 | 524 | } |
509 | 525 | |
510 | - if (!empty($board)) |
|
511 | - $boards[] = (int) $board; |
|
526 | + if (!empty($board)) { |
|
527 | + $boards[] = (int) $board; |
|
528 | + } |
|
512 | 529 | |
513 | 530 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -525,30 +542,31 @@ discard block |
||
525 | 542 | ) |
526 | 543 | ); |
527 | 544 | |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - if (in_array($row['id_parent'], $boards)) |
|
545 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
546 | + if (in_array($row['id_parent'], $boards)) |
|
530 | 547 | $boards[] = $row['id_board']; |
548 | + } |
|
531 | 549 | |
532 | 550 | $smcFunc['db_free_result']($request); |
533 | 551 | |
534 | - if (empty($boards)) |
|
535 | - fatal_lang_error('error_no_boards_selected'); |
|
552 | + if (empty($boards)) { |
|
553 | + fatal_lang_error('error_no_boards_selected'); |
|
554 | + } |
|
536 | 555 | |
537 | 556 | $query_this_board = 'id_board IN ({array_int:boards})'; |
538 | 557 | $query_parameters['boards'] = $boards; |
539 | 558 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
540 | - } |
|
541 | - elseif (!empty($board)) |
|
559 | + } elseif (!empty($board)) |
|
542 | 560 | { |
543 | 561 | $query_this_board = 'id_board = {int:board}'; |
544 | 562 | $query_parameters['board'] = $board; |
545 | 563 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
546 | - } |
|
547 | - elseif (!empty($_REQUEST['boards'])) |
|
564 | + } elseif (!empty($_REQUEST['boards'])) |
|
548 | 565 | { |
549 | 566 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
550 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
551 | - $_REQUEST['boards'][$i] = (int) $b; |
|
567 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
568 | + $_REQUEST['boards'][$i] = (int) $b; |
|
569 | + } |
|
552 | 570 | |
553 | 571 | $request = $smcFunc['db_query']('', ' |
554 | 572 | SELECT b.id_board |
@@ -560,22 +578,24 @@ discard block |
||
560 | 578 | ) |
561 | 579 | ); |
562 | 580 | $boards = array(); |
563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
564 | - $boards[] = $row['id_board']; |
|
581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
582 | + $boards[] = $row['id_board']; |
|
583 | + } |
|
565 | 584 | $smcFunc['db_free_result']($request); |
566 | 585 | |
567 | - if (empty($boards)) |
|
568 | - fatal_lang_error('error_no_boards_selected'); |
|
586 | + if (empty($boards)) { |
|
587 | + fatal_lang_error('error_no_boards_selected'); |
|
588 | + } |
|
569 | 589 | |
570 | 590 | $query_this_board = 'id_board IN ({array_int:boards})'; |
571 | 591 | $query_parameters['boards'] = $boards; |
572 | 592 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
573 | - } |
|
574 | - elseif (!empty($_REQUEST['c'])) |
|
593 | + } elseif (!empty($_REQUEST['c'])) |
|
575 | 594 | { |
576 | 595 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
577 | - foreach ($_REQUEST['c'] as $i => $c) |
|
578 | - $_REQUEST['c'][$i] = (int) $c; |
|
596 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
597 | + $_REQUEST['c'][$i] = (int) $c; |
|
598 | + } |
|
579 | 599 | |
580 | 600 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
581 | 601 | $request = $smcFunc['db_query']('', ' |
@@ -588,18 +608,19 @@ discard block |
||
588 | 608 | ) |
589 | 609 | ); |
590 | 610 | $boards = array(); |
591 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
592 | - $boards[] = $row['id_board']; |
|
611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
612 | + $boards[] = $row['id_board']; |
|
613 | + } |
|
593 | 614 | $smcFunc['db_free_result']($request); |
594 | 615 | |
595 | - if (empty($boards)) |
|
596 | - fatal_lang_error('error_no_boards_selected'); |
|
616 | + if (empty($boards)) { |
|
617 | + fatal_lang_error('error_no_boards_selected'); |
|
618 | + } |
|
597 | 619 | |
598 | 620 | $query_this_board = 'id_board IN ({array_int:boards})'; |
599 | 621 | $query_parameters['boards'] = $boards; |
600 | 622 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
601 | - } |
|
602 | - else |
|
623 | + } else |
|
603 | 624 | { |
604 | 625 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
605 | 626 | // Don't bother to show deleted posts! |
@@ -613,12 +634,14 @@ discard block |
||
613 | 634 | ) |
614 | 635 | ); |
615 | 636 | $boards = array(); |
616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
617 | - $boards[] = $row['id_board']; |
|
637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
638 | + $boards[] = $row['id_board']; |
|
639 | + } |
|
618 | 640 | $smcFunc['db_free_result']($request); |
619 | 641 | |
620 | - if (empty($boards)) |
|
621 | - fatal_lang_error('error_no_boards_available', false); |
|
642 | + if (empty($boards)) { |
|
643 | + fatal_lang_error('error_no_boards_available', false); |
|
644 | + } |
|
622 | 645 | |
623 | 646 | $query_this_board = 'id_board IN ({array_int:boards})'; |
624 | 647 | $query_parameters['boards'] = $boards; |
@@ -680,13 +703,14 @@ discard block |
||
680 | 703 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
681 | 704 | ); |
682 | 705 | |
683 | - if ($context['showing_all_topics']) |
|
684 | - $context['linktree'][] = array( |
|
706 | + if ($context['showing_all_topics']) { |
|
707 | + $context['linktree'][] = array( |
|
685 | 708 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
686 | 709 | 'name' => $txt['unread_topics_all'] |
687 | 710 | ); |
688 | - else |
|
689 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
711 | + } else { |
|
712 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
713 | + } |
|
690 | 714 | |
691 | 715 | loadTemplate('Recent'); |
692 | 716 | loadTemplate('MessageIndex'); |
@@ -694,8 +718,9 @@ discard block |
||
694 | 718 | |
695 | 719 | // Setup the default topic icons... for checking they exist and the like ;) |
696 | 720 | $context['icon_sources'] = array(); |
697 | - foreach ($context['stable_icons'] as $icon) |
|
698 | - $context['icon_sources'][$icon] = 'images_url'; |
|
721 | + foreach ($context['stable_icons'] as $icon) { |
|
722 | + $context['icon_sources'][$icon] = 'images_url'; |
|
723 | + } |
|
699 | 724 | |
700 | 725 | $is_topics = $_REQUEST['action'] == 'unread'; |
701 | 726 | |
@@ -725,8 +750,7 @@ discard block |
||
725 | 750 | ); |
726 | 751 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
727 | 752 | $smcFunc['db_free_result']($request); |
728 | - } |
|
729 | - else |
|
753 | + } else |
|
730 | 754 | { |
731 | 755 | $request = $smcFunc['db_query']('', ' |
732 | 756 | SELECT MIN(lmr.id_msg) |
@@ -742,14 +766,14 @@ discard block |
||
742 | 766 | } |
743 | 767 | |
744 | 768 | // This is needed in case of topics marked unread. |
745 | - if (empty($earliest_msg)) |
|
746 | - $earliest_msg = 0; |
|
747 | - else |
|
769 | + if (empty($earliest_msg)) { |
|
770 | + $earliest_msg = 0; |
|
771 | + } else |
|
748 | 772 | { |
749 | 773 | // Using caching, when possible, to ignore the below slow query. |
750 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
751 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
752 | - else |
|
774 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
775 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
776 | + } else |
|
753 | 777 | { |
754 | 778 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
755 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -764,8 +788,9 @@ discard block |
||
764 | 788 | $smcFunc['db_free_result']($request); |
765 | 789 | |
766 | 790 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
767 | - if ($earliest_msg2 == 0) |
|
768 | - $earliest_msg2 = -1; |
|
791 | + if ($earliest_msg2 == 0) { |
|
792 | + $earliest_msg2 = -1; |
|
793 | + } |
|
769 | 794 | |
770 | 795 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
771 | 796 | } |
@@ -803,9 +828,9 @@ discard block |
||
803 | 828 | 'db_error_skip' => true, |
804 | 829 | )) |
805 | 830 | ) !== false; |
831 | + } else { |
|
832 | + $have_temp_table = false; |
|
806 | 833 | } |
807 | - else |
|
808 | - $have_temp_table = false; |
|
809 | 834 | |
810 | 835 | if ($context['showing_all_topics'] && $have_temp_table) |
811 | 836 | { |
@@ -851,14 +876,15 @@ discard block |
||
851 | 876 | |
852 | 877 | $context['topics'] = array(); |
853 | 878 | $context['no_topic_listing'] = true; |
854 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
855 | - $context['querystring_board_limits'] = ''; |
|
856 | - else |
|
857 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
879 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
880 | + $context['querystring_board_limits'] = ''; |
|
881 | + } else { |
|
882 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
883 | + } |
|
858 | 884 | return; |
885 | + } else { |
|
886 | + $min_message = (int) $min_message; |
|
859 | 887 | } |
860 | - else |
|
861 | - $min_message = (int) $min_message; |
|
862 | 888 | |
863 | 889 | $request = $smcFunc['db_query']('substring', ' |
864 | 890 | SELECT ' . $select_clause . ' |
@@ -887,8 +913,7 @@ discard block |
||
887 | 913 | 'limit' => $context['topics_per_page'], |
888 | 914 | )) |
889 | 915 | ); |
890 | - } |
|
891 | - elseif ($is_topics) |
|
916 | + } elseif ($is_topics) |
|
892 | 917 | { |
893 | 918 | $request = $smcFunc['db_query']('', ' |
894 | 919 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -939,14 +964,15 @@ discard block |
||
939 | 964 | |
940 | 965 | $context['topics'] = array(); |
941 | 966 | $context['no_topic_listing'] = true; |
942 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
943 | - $context['querystring_board_limits'] = ''; |
|
944 | - else |
|
945 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
967 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
968 | + $context['querystring_board_limits'] = ''; |
|
969 | + } else { |
|
970 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
971 | + } |
|
946 | 972 | return; |
973 | + } else { |
|
974 | + $min_message = (int) $min_message; |
|
947 | 975 | } |
948 | - else |
|
949 | - $min_message = (int) $min_message; |
|
950 | 976 | |
951 | 977 | $request = $smcFunc['db_query']('substring', ' |
952 | 978 | SELECT ' . $select_clause . ' |
@@ -976,8 +1002,7 @@ discard block |
||
976 | 1002 | 'limit' => $context['topics_per_page'], |
977 | 1003 | )) |
978 | 1004 | ); |
979 | - } |
|
980 | - else |
|
1005 | + } else |
|
981 | 1006 | { |
982 | 1007 | if ($modSettings['totalMessages'] > 100000) |
983 | 1008 | { |
@@ -1029,8 +1054,8 @@ discard block |
||
1029 | 1054 | ) !== false; |
1030 | 1055 | |
1031 | 1056 | // If that worked, create a sample of the log_topics table too. |
1032 | - if ($have_temp_table) |
|
1033 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
1057 | + if ($have_temp_table) { |
|
1058 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
1034 | 1059 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
1035 | 1060 | PRIMARY KEY (id_topic) |
1036 | 1061 | ) |
@@ -1043,6 +1068,7 @@ discard block |
||
1043 | 1068 | 'db_error_skip' => true, |
1044 | 1069 | ) |
1045 | 1070 | ) !== false; |
1071 | + } |
|
1046 | 1072 | } |
1047 | 1073 | |
1048 | 1074 | if (!empty($have_temp_table)) |
@@ -1058,8 +1084,7 @@ discard block |
||
1058 | 1084 | ); |
1059 | 1085 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
1060 | 1086 | $smcFunc['db_free_result']($request); |
1061 | - } |
|
1062 | - else |
|
1087 | + } else |
|
1063 | 1088 | { |
1064 | 1089 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
1065 | 1090 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1100,15 +1125,16 @@ discard block |
||
1100 | 1125 | { |
1101 | 1126 | $context['topics'] = array(); |
1102 | 1127 | $context['no_topic_listing'] = true; |
1103 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1104 | - $context['querystring_board_limits'] = ''; |
|
1105 | - else |
|
1106 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1128 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1129 | + $context['querystring_board_limits'] = ''; |
|
1130 | + } else { |
|
1131 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1132 | + } |
|
1107 | 1133 | return; |
1108 | 1134 | } |
1109 | 1135 | |
1110 | - if (!empty($have_temp_table)) |
|
1111 | - $request = $smcFunc['db_query']('', ' |
|
1136 | + if (!empty($have_temp_table)) { |
|
1137 | + $request = $smcFunc['db_query']('', ' |
|
1112 | 1138 | SELECT t.id_topic |
1113 | 1139 | FROM {db_prefix}topics_posted_in AS t |
1114 | 1140 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1122,8 +1148,8 @@ discard block |
||
1122 | 1148 | 'limit' => $context['topics_per_page'], |
1123 | 1149 | )) |
1124 | 1150 | ); |
1125 | - else |
|
1126 | - $request = $smcFunc['db_query']('', ' |
|
1151 | + } else { |
|
1152 | + $request = $smcFunc['db_query']('', ' |
|
1127 | 1153 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
1128 | 1154 | FROM {db_prefix}topics AS t |
1129 | 1155 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1147,10 +1173,12 @@ discard block |
||
1147 | 1173 | 'sort' => $_REQUEST['sort'], |
1148 | 1174 | )) |
1149 | 1175 | ); |
1176 | + } |
|
1150 | 1177 | |
1151 | 1178 | $topics = array(); |
1152 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1153 | - $topics[] = $row['id_topic']; |
|
1179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1180 | + $topics[] = $row['id_topic']; |
|
1181 | + } |
|
1154 | 1182 | $smcFunc['db_free_result']($request); |
1155 | 1183 | |
1156 | 1184 | // Sanity... where have you gone? |
@@ -1158,10 +1186,11 @@ discard block |
||
1158 | 1186 | { |
1159 | 1187 | $context['topics'] = array(); |
1160 | 1188 | $context['no_topic_listing'] = true; |
1161 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1162 | - $context['querystring_board_limits'] = ''; |
|
1163 | - else |
|
1164 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1189 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1190 | + $context['querystring_board_limits'] = ''; |
|
1191 | + } else { |
|
1192 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1193 | + } |
|
1165 | 1194 | return; |
1166 | 1195 | } |
1167 | 1196 | |
@@ -1195,8 +1224,9 @@ discard block |
||
1195 | 1224 | |
1196 | 1225 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1197 | 1226 | { |
1198 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
1199 | - continue; |
|
1227 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
1228 | + continue; |
|
1229 | + } |
|
1200 | 1230 | |
1201 | 1231 | $topic_ids[] = $row['id_topic']; |
1202 | 1232 | |
@@ -1204,11 +1234,13 @@ discard block |
||
1204 | 1234 | { |
1205 | 1235 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
1206 | 1236 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
1207 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
1208 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1237 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
1238 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1239 | + } |
|
1209 | 1240 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
1210 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
1211 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1241 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
1242 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1243 | + } |
|
1212 | 1244 | |
1213 | 1245 | // Censor the subject and message preview. |
1214 | 1246 | censorText($row['first_subject']); |
@@ -1219,23 +1251,22 @@ discard block |
||
1219 | 1251 | { |
1220 | 1252 | $row['last_subject'] = $row['first_subject']; |
1221 | 1253 | $row['last_body'] = $row['first_body']; |
1222 | - } |
|
1223 | - else |
|
1254 | + } else |
|
1224 | 1255 | { |
1225 | 1256 | censorText($row['last_subject']); |
1226 | 1257 | censorText($row['last_body']); |
1227 | 1258 | } |
1228 | - } |
|
1229 | - else |
|
1259 | + } else |
|
1230 | 1260 | { |
1231 | 1261 | $row['first_body'] = ''; |
1232 | 1262 | $row['last_body'] = ''; |
1233 | 1263 | censorText($row['first_subject']); |
1234 | 1264 | |
1235 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
1236 | - $row['last_subject'] = $row['first_subject']; |
|
1237 | - else |
|
1238 | - censorText($row['last_subject']); |
|
1265 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
1266 | + $row['last_subject'] = $row['first_subject']; |
|
1267 | + } else { |
|
1268 | + censorText($row['last_subject']); |
|
1269 | + } |
|
1239 | 1270 | } |
1240 | 1271 | |
1241 | 1272 | // Decide how many pages the topic should have. |
@@ -1247,22 +1278,24 @@ discard block |
||
1247 | 1278 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
1248 | 1279 | |
1249 | 1280 | // If we can use all, show all. |
1250 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
1251 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1281 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
1282 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1283 | + } |
|
1284 | + } else { |
|
1285 | + $pages = ''; |
|
1252 | 1286 | } |
1253 | 1287 | |
1254 | - else |
|
1255 | - $pages = ''; |
|
1256 | - |
|
1257 | 1288 | // We need to check the topic icons exist... you can never be too sure! |
1258 | 1289 | if (!empty($modSettings['messageIconChecks_enable'])) |
1259 | 1290 | { |
1260 | 1291 | // First icon first... as you'd expect. |
1261 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1262 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1292 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1293 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1294 | + } |
|
1263 | 1295 | // Last icon... last... duh. |
1264 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1265 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1296 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1297 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1298 | + } |
|
1266 | 1299 | } |
1267 | 1300 | |
1268 | 1301 | // Force the recycling icon if appropriate |
@@ -1276,12 +1309,14 @@ discard block |
||
1276 | 1309 | $colorClass = 'windowbg'; |
1277 | 1310 | |
1278 | 1311 | // Sticky topics should get a different color, too. |
1279 | - if ($row['is_sticky']) |
|
1280 | - $colorClass .= ' sticky'; |
|
1312 | + if ($row['is_sticky']) { |
|
1313 | + $colorClass .= ' sticky'; |
|
1314 | + } |
|
1281 | 1315 | |
1282 | 1316 | // Locked topics get special treatment as well. |
1283 | - if ($row['locked']) |
|
1284 | - $colorClass .= ' locked'; |
|
1317 | + if ($row['locked']) { |
|
1318 | + $colorClass .= ' locked'; |
|
1319 | + } |
|
1285 | 1320 | |
1286 | 1321 | // And build the array. |
1287 | 1322 | $context['topics'][$row['id_topic']] = array( |
@@ -1378,8 +1413,9 @@ discard block |
||
1378 | 1413 | ); |
1379 | 1414 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1380 | 1415 | { |
1381 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
1382 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1416 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
1417 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1418 | + } |
|
1383 | 1419 | } |
1384 | 1420 | $smcFunc['db_free_result']($result); |
1385 | 1421 | } |
@@ -1394,28 +1430,30 @@ discard block |
||
1394 | 1430 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
1395 | 1431 | ); |
1396 | 1432 | |
1397 | - if ($context['showCheckboxes']) |
|
1398 | - $context['recent_buttons']['markselectread'] = array( |
|
1433 | + if ($context['showCheckboxes']) { |
|
1434 | + $context['recent_buttons']['markselectread'] = array( |
|
1399 | 1435 | 'text' => 'quick_mod_markread', |
1400 | 1436 | 'image' => 'markselectedread.png', |
1401 | 1437 | 'url' => 'javascript:document.quickModForm.submit();', |
1402 | 1438 | ); |
1439 | + } |
|
1403 | 1440 | |
1404 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
1405 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1406 | - } |
|
1407 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1441 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
1442 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1443 | + } |
|
1444 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1408 | 1445 | { |
1409 | 1446 | $context['recent_buttons'] = array( |
1410 | 1447 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
1411 | 1448 | ); |
1412 | 1449 | |
1413 | - if ($context['showCheckboxes']) |
|
1414 | - $context['recent_buttons']['markselectread'] = array( |
|
1450 | + if ($context['showCheckboxes']) { |
|
1451 | + $context['recent_buttons']['markselectread'] = array( |
|
1415 | 1452 | 'text' => 'quick_mod_markread', |
1416 | 1453 | 'image' => 'markselectedread.png', |
1417 | 1454 | 'url' => 'javascript:document.quickModForm.submit();', |
1418 | 1455 | ); |
1456 | + } |
|
1419 | 1457 | } |
1420 | 1458 | |
1421 | 1459 | // Allow mods to add additional buttons here |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'class' => 'centercol', |
257 | 257 | ), |
258 | 258 | 'data' => array( |
259 | - 'function' => function ($entry) |
|
259 | + 'function' => function($entry) |
|
260 | 260 | { |
261 | 261 | return '<input type="checkbox" class="input_check" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | if (empty($entries[$k]['action_text'])) |
639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | - function ($matches) use ($entries, $k) |
|
641 | + function($matches) use ($entries, $k) |
|
642 | 642 | { |
643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
644 | 644 | }, $entries[$k]['action_text']); |
@@ -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 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -297,13 +301,14 @@ discard block |
||
297 | 301 | $context['sub_template'] = 'show_list'; |
298 | 302 | $context['default_list'] = 'moderation_log_list'; |
299 | 303 | |
300 | - if (isset($context['moderation_menu_name'])) |
|
301 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
304 | + if (isset($context['moderation_menu_name'])) { |
|
305 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
302 | 306 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
303 | 307 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
304 | 308 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
305 | 309 | ); |
306 | -} |
|
310 | + } |
|
311 | + } |
|
307 | 312 | |
308 | 313 | /** |
309 | 314 | * Get the number of mod log entries. |
@@ -407,30 +412,35 @@ discard block |
||
407 | 412 | // Add on some of the column stuff info |
408 | 413 | if (!empty($row['id_board'])) |
409 | 414 | { |
410 | - if ($row['action'] == 'move') |
|
411 | - $row['extra']['board_to'] = $row['id_board']; |
|
412 | - else |
|
413 | - $row['extra']['board'] = $row['id_board']; |
|
415 | + if ($row['action'] == 'move') { |
|
416 | + $row['extra']['board_to'] = $row['id_board']; |
|
417 | + } else { |
|
418 | + $row['extra']['board'] = $row['id_board']; |
|
419 | + } |
|
414 | 420 | } |
415 | 421 | |
416 | - if (!empty($row['id_topic'])) |
|
417 | - $row['extra']['topic'] = $row['id_topic']; |
|
418 | - if (!empty($row['id_msg'])) |
|
419 | - $row['extra']['message'] = $row['id_msg']; |
|
422 | + if (!empty($row['id_topic'])) { |
|
423 | + $row['extra']['topic'] = $row['id_topic']; |
|
424 | + } |
|
425 | + if (!empty($row['id_msg'])) { |
|
426 | + $row['extra']['message'] = $row['id_msg']; |
|
427 | + } |
|
420 | 428 | |
421 | 429 | // Is this associated with a topic? |
422 | - if (isset($row['extra']['topic'])) |
|
423 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
424 | - if (isset($row['extra']['new_topic'])) |
|
425 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
430 | + if (isset($row['extra']['topic'])) { |
|
431 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
432 | + } |
|
433 | + if (isset($row['extra']['new_topic'])) { |
|
434 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
435 | + } |
|
426 | 436 | |
427 | 437 | // How about a member? |
428 | 438 | if (isset($row['extra']['member'])) |
429 | 439 | { |
430 | 440 | // Guests don't have names! |
431 | - if (empty($row['extra']['member'])) |
|
432 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
433 | - else |
|
441 | + if (empty($row['extra']['member'])) { |
|
442 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
443 | + } else |
|
434 | 444 | { |
435 | 445 | // Try to find it... |
436 | 446 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -438,35 +448,42 @@ discard block |
||
438 | 448 | } |
439 | 449 | |
440 | 450 | // Associated with a board? |
441 | - if (isset($row['extra']['board_to'])) |
|
442 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
443 | - if (isset($row['extra']['board_from'])) |
|
444 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
445 | - if (isset($row['extra']['board'])) |
|
446 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
451 | + if (isset($row['extra']['board_to'])) { |
|
452 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
453 | + } |
|
454 | + if (isset($row['extra']['board_from'])) { |
|
455 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
456 | + } |
|
457 | + if (isset($row['extra']['board'])) { |
|
458 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
459 | + } |
|
447 | 460 | |
448 | 461 | // A message? |
449 | - if (isset($row['extra']['message'])) |
|
450 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
462 | + if (isset($row['extra']['message'])) { |
|
463 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
464 | + } |
|
451 | 465 | |
452 | 466 | // IP Info? |
453 | - if (isset($row['extra']['ip_range'])) |
|
454 | - if ($seeIP) |
|
467 | + if (isset($row['extra']['ip_range'])) { |
|
468 | + if ($seeIP) |
|
455 | 469 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
456 | - else |
|
457 | - $row['extra']['ip_range'] = $txt['logged']; |
|
470 | + } else { |
|
471 | + $row['extra']['ip_range'] = $txt['logged']; |
|
472 | + } |
|
458 | 473 | |
459 | 474 | // Email? |
460 | - if (isset($row['extra']['email'])) |
|
461 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
475 | + if (isset($row['extra']['email'])) { |
|
476 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
477 | + } |
|
462 | 478 | |
463 | 479 | // Bans are complex. |
464 | 480 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
465 | 481 | { |
466 | 482 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
467 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
468 | - if (isset($row['extra'][$type])) |
|
483 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
484 | + if (isset($row['extra'][$type])) |
|
469 | 485 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
486 | + } |
|
470 | 487 | } |
471 | 488 | |
472 | 489 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -502,12 +519,13 @@ discard block |
||
502 | 519 | foreach ($boards[$row['id_board']] as $action) |
503 | 520 | { |
504 | 521 | // Make the board number into a link - dealing with moving too. |
505 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
506 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
507 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
508 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
509 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
510 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
522 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
523 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
524 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
525 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
526 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
527 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + } |
|
511 | 529 | } |
512 | 530 | } |
513 | 531 | $smcFunc['db_free_result']($request); |
@@ -541,10 +559,11 @@ discard block |
||
541 | 559 | ); |
542 | 560 | |
543 | 561 | // Make the topic number into a link - dealing with splitting too. |
544 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
545 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
546 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
547 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
562 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
563 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
564 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
565 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
566 | + } |
|
548 | 567 | } |
549 | 568 | } |
550 | 569 | $smcFunc['db_free_result']($request); |
@@ -577,8 +596,9 @@ discard block |
||
577 | 596 | ); |
578 | 597 | |
579 | 598 | // Make the message number into a link. |
580 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
581 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
599 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
600 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
601 | + } |
|
582 | 602 | } |
583 | 603 | } |
584 | 604 | $smcFunc['db_free_result']($request); |
@@ -618,25 +638,29 @@ discard block |
||
618 | 638 | foreach ($entries as $k => $entry) |
619 | 639 | { |
620 | 640 | // Make any message info links so its easier to go find that message. |
621 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
622 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
641 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
642 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
643 | + } |
|
623 | 644 | |
624 | 645 | // Mark up any deleted members, topics and boards. |
625 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
626 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
646 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
647 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
627 | 648 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
649 | + } |
|
628 | 650 | |
629 | 651 | if (isset($entry['extra']['report'])) |
630 | 652 | { |
631 | 653 | // Member profile reports go in a different area |
632 | - if (stristr($entry['action'], 'user_report')) |
|
633 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
634 | - else |
|
635 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
654 | + if (stristr($entry['action'], 'user_report')) { |
|
655 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
656 | + } else { |
|
657 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
658 | + } |
|
636 | 659 | } |
637 | 660 | |
638 | - if (empty($entries[$k]['action_text'])) |
|
639 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
661 | + if (empty($entries[$k]['action_text'])) { |
|
662 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
663 | + } |
|
640 | 664 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | 665 | function ($matches) use ($entries, $k) |
642 | 666 | { |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | - * Determine if the browser is Opera or not |
|
105 | - * @return boolean Whether or not this is Opera |
|
106 | - */ |
|
104 | + * Determine if the browser is Opera or not |
|
105 | + * @return boolean Whether or not this is Opera |
|
106 | + */ |
|
107 | 107 | function isOpera() |
108 | 108 | { |
109 | 109 | if (!isset($this->_browsers['is_opera'])) |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * Determine if the browser is IE or not |
|
116 | - * @return boolean true Whether or not the browser is IE |
|
117 | - */ |
|
115 | + * Determine if the browser is IE or not |
|
116 | + * @return boolean true Whether or not the browser is IE |
|
117 | + */ |
|
118 | 118 | function isIe() |
119 | 119 | { |
120 | 120 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * Determine if the browser is IE11 or not |
|
128 | - * @return boolean Whether or not the browser is IE11 |
|
129 | - */ |
|
127 | + * Determine if the browser is IE11 or not |
|
128 | + * @return boolean Whether or not the browser is IE11 |
|
129 | + */ |
|
130 | 130 | function isIe11() |
131 | 131 | { |
132 | 132 | // IE11 is a bit different than earlier versions |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Determine if the browser is Edge or not |
|
141 | - * @return boolean Whether or not the browser is Edge |
|
142 | - */ |
|
140 | + * Determine if the browser is Edge or not |
|
141 | + * @return boolean Whether or not the browser is Edge |
|
142 | + */ |
|
143 | 143 | function isEdge() |
144 | 144 | { |
145 | 145 | if (!isset($this->_browsers['is_edge'])) |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * Determine if the browser is a Webkit based one or not |
|
152 | - * @return boolean Whether or not this is a Webkit-based browser |
|
153 | - */ |
|
151 | + * Determine if the browser is a Webkit based one or not |
|
152 | + * @return boolean Whether or not this is a Webkit-based browser |
|
153 | + */ |
|
154 | 154 | function isWebkit() |
155 | 155 | { |
156 | 156 | if (!isset($this->_browsers['is_webkit'])) |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | - * Determine if the browser is Firefox or one of its variants |
|
163 | - * @return boolean Whether or not this is Firefox (or one of its variants) |
|
164 | - */ |
|
162 | + * Determine if the browser is Firefox or one of its variants |
|
163 | + * @return boolean Whether or not this is Firefox (or one of its variants) |
|
164 | + */ |
|
165 | 165 | function isFirefox() |
166 | 166 | { |
167 | 167 | if (!isset($this->_browsers['is_firefox'])) |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Determine if the browser is WebTv or not |
|
174 | - * @return boolean Whether or not this is WebTV |
|
175 | - */ |
|
173 | + * Determine if the browser is WebTv or not |
|
174 | + * @return boolean Whether or not this is WebTV |
|
175 | + */ |
|
176 | 176 | function isWebTv() |
177 | 177 | { |
178 | 178 | if (!isset($this->_browsers['is_web_tv'])) |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | - * Determine if the browser is konqueror or not |
|
185 | - * @return boolean Whether or not this is Konqueror |
|
186 | - */ |
|
184 | + * Determine if the browser is konqueror or not |
|
185 | + * @return boolean Whether or not this is Konqueror |
|
186 | + */ |
|
187 | 187 | function isKonqueror() |
188 | 188 | { |
189 | 189 | if (!isset($this->_browsers['is_konqueror'])) |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
195 | - * Determine if the browser is Gecko or not |
|
196 | - * @return boolean Whether or not this is a Gecko-based browser |
|
197 | - */ |
|
195 | + * Determine if the browser is Gecko or not |
|
196 | + * @return boolean Whether or not this is a Gecko-based browser |
|
197 | + */ |
|
198 | 198 | function isGecko() |
199 | 199 | { |
200 | 200 | if (!isset($this->_browsers['is_gecko'])) |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * Determine if the browser is Opera Mini or not |
|
207 | - * @return boolean Whether or not this is Opera Mini |
|
208 | - */ |
|
206 | + * Determine if the browser is Opera Mini or not |
|
207 | + * @return boolean Whether or not this is Opera Mini |
|
208 | + */ |
|
209 | 209 | function isOperaMini() |
210 | 210 | { |
211 | 211 | if (!isset($this->_browsers['is_opera_mini'])) |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
219 | - * Determine if the browser is Opera Mobile or not |
|
220 | - * @return boolean Whether or not this is Opera Mobile |
|
221 | - */ |
|
219 | + * Determine if the browser is Opera Mobile or not |
|
220 | + * @return boolean Whether or not this is Opera Mobile |
|
221 | + */ |
|
222 | 222 | function isOperaMobi() |
223 | 223 | { |
224 | 224 | if (!isset($this->_browsers['is_opera_mobi'])) |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class browser_detector |
@@ -55,20 +56,25 @@ discard block |
||
55 | 56 | $this->_browsers['needs_size_fix'] = false; |
56 | 57 | |
57 | 58 | // One at a time, one at a time, and in this order too |
58 | - if ($this->isOpera()) |
|
59 | - $this->setupOpera(); |
|
59 | + if ($this->isOpera()) { |
|
60 | + $this->setupOpera(); |
|
61 | + } |
|
60 | 62 | // Meh... |
61 | - elseif ($this->isEdge()) |
|
62 | - $this->setupEdge(); |
|
63 | + elseif ($this->isEdge()) { |
|
64 | + $this->setupEdge(); |
|
65 | + } |
|
63 | 66 | // Them webkits need to be set up too |
64 | - elseif ($this->isWebkit()) |
|
65 | - $this->setupWebkit(); |
|
67 | + elseif ($this->isWebkit()) { |
|
68 | + $this->setupWebkit(); |
|
69 | + } |
|
66 | 70 | // We may have work to do on Firefox... |
67 | - elseif ($this->isFirefox()) |
|
68 | - $this->setupFirefox(); |
|
71 | + elseif ($this->isFirefox()) { |
|
72 | + $this->setupFirefox(); |
|
73 | + } |
|
69 | 74 | // Old friend, old frenemy |
70 | - elseif ($this->isIe()) |
|
71 | - $this->setupIe(); |
|
75 | + elseif ($this->isIe()) { |
|
76 | + $this->setupIe(); |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // Just a few mobile checks |
74 | 80 | $this->isOperaMini(); |
@@ -84,11 +90,12 @@ discard block |
||
84 | 90 | $this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']); |
85 | 91 | |
86 | 92 | // Robots shouldn't be logging in or registering. So, they aren't a bot. Better to be wrong than sorry (or people won't be able to log in!), anyway. |
87 | - if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) |
|
88 | - $this->_browsers['possibly_robot'] = false; |
|
93 | + if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) { |
|
94 | + $this->_browsers['possibly_robot'] = false; |
|
95 | + } |
|
96 | + } else { |
|
97 | + $this->_browsers['possibly_robot'] = false; |
|
89 | 98 | } |
90 | - else |
|
91 | - $this->_browsers['possibly_robot'] = false; |
|
92 | 99 | |
93 | 100 | // Fill out the historical array as needed to support old mods that don't use isBrowser |
94 | 101 | $this->fillInformation(); |
@@ -106,8 +113,9 @@ discard block |
||
106 | 113 | */ |
107 | 114 | function isOpera() |
108 | 115 | { |
109 | - if (!isset($this->_browsers['is_opera'])) |
|
110 | - $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
116 | + if (!isset($this->_browsers['is_opera'])) { |
|
117 | + $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
118 | + } |
|
111 | 119 | return $this->_browsers['is_opera']; |
112 | 120 | } |
113 | 121 | |
@@ -118,8 +126,9 @@ discard block |
||
118 | 126 | function isIe() |
119 | 127 | { |
120 | 128 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
121 | - if (!isset($this->_browsers['is_ie'])) |
|
122 | - $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
129 | + if (!isset($this->_browsers['is_ie'])) { |
|
130 | + $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
131 | + } |
|
123 | 132 | return $this->_browsers['is_ie']; |
124 | 133 | } |
125 | 134 | |
@@ -131,8 +140,9 @@ discard block |
||
131 | 140 | { |
132 | 141 | // IE11 is a bit different than earlier versions |
133 | 142 | // The isGecko() part is to ensure we get this right... |
134 | - if (!isset($this->_browsers['is_ie11'])) |
|
135 | - $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
143 | + if (!isset($this->_browsers['is_ie11'])) { |
|
144 | + $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
145 | + } |
|
136 | 146 | return $this->_browsers['is_ie11']; |
137 | 147 | } |
138 | 148 | |
@@ -142,8 +152,9 @@ discard block |
||
142 | 152 | */ |
143 | 153 | function isEdge() |
144 | 154 | { |
145 | - if (!isset($this->_browsers['is_edge'])) |
|
146 | - $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
155 | + if (!isset($this->_browsers['is_edge'])) { |
|
156 | + $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
157 | + } |
|
147 | 158 | return $this->_browsers['is_edge']; |
148 | 159 | } |
149 | 160 | |
@@ -153,8 +164,9 @@ discard block |
||
153 | 164 | */ |
154 | 165 | function isWebkit() |
155 | 166 | { |
156 | - if (!isset($this->_browsers['is_webkit'])) |
|
157 | - $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
167 | + if (!isset($this->_browsers['is_webkit'])) { |
|
168 | + $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
169 | + } |
|
158 | 170 | return $this->_browsers['is_webkit']; |
159 | 171 | } |
160 | 172 | |
@@ -164,8 +176,9 @@ discard block |
||
164 | 176 | */ |
165 | 177 | function isFirefox() |
166 | 178 | { |
167 | - if (!isset($this->_browsers['is_firefox'])) |
|
168 | - $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
179 | + if (!isset($this->_browsers['is_firefox'])) { |
|
180 | + $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
181 | + } |
|
169 | 182 | return $this->_browsers['is_firefox']; |
170 | 183 | } |
171 | 184 | |
@@ -175,8 +188,9 @@ discard block |
||
175 | 188 | */ |
176 | 189 | function isWebTv() |
177 | 190 | { |
178 | - if (!isset($this->_browsers['is_web_tv'])) |
|
179 | - $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
191 | + if (!isset($this->_browsers['is_web_tv'])) { |
|
192 | + $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
193 | + } |
|
180 | 194 | return $this->_browsers['is_web_tv']; |
181 | 195 | } |
182 | 196 | |
@@ -186,8 +200,9 @@ discard block |
||
186 | 200 | */ |
187 | 201 | function isKonqueror() |
188 | 202 | { |
189 | - if (!isset($this->_browsers['is_konqueror'])) |
|
190 | - $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
203 | + if (!isset($this->_browsers['is_konqueror'])) { |
|
204 | + $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
205 | + } |
|
191 | 206 | return $this->_browsers['is_konqueror']; |
192 | 207 | } |
193 | 208 | |
@@ -197,8 +212,9 @@ discard block |
||
197 | 212 | */ |
198 | 213 | function isGecko() |
199 | 214 | { |
200 | - if (!isset($this->_browsers['is_gecko'])) |
|
201 | - $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
215 | + if (!isset($this->_browsers['is_gecko'])) { |
|
216 | + $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
217 | + } |
|
202 | 218 | return $this->_browsers['is_gecko']; |
203 | 219 | } |
204 | 220 | |
@@ -208,10 +224,12 @@ discard block |
||
208 | 224 | */ |
209 | 225 | function isOperaMini() |
210 | 226 | { |
211 | - if (!isset($this->_browsers['is_opera_mini'])) |
|
212 | - $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
213 | - if ($this->_browsers['is_opera_mini']) |
|
214 | - $this->_is_mobile = true; |
|
227 | + if (!isset($this->_browsers['is_opera_mini'])) { |
|
228 | + $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
229 | + } |
|
230 | + if ($this->_browsers['is_opera_mini']) { |
|
231 | + $this->_is_mobile = true; |
|
232 | + } |
|
215 | 233 | return $this->_browsers['is_opera_mini']; |
216 | 234 | } |
217 | 235 | |
@@ -221,10 +239,12 @@ discard block |
||
221 | 239 | */ |
222 | 240 | function isOperaMobi() |
223 | 241 | { |
224 | - if (!isset($this->_browsers['is_opera_mobi'])) |
|
225 | - $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
226 | - if ($this->_browsers['is_opera_mobi']) |
|
227 | - $this->_is_mobile = true; |
|
242 | + if (!isset($this->_browsers['is_opera_mobi'])) { |
|
243 | + $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
244 | + } |
|
245 | + if ($this->_browsers['is_opera_mobi']) { |
|
246 | + $this->_is_mobile = true; |
|
247 | + } |
|
228 | 248 | return $this->_browsers['is_opera_mini']; |
229 | 249 | } |
230 | 250 | |
@@ -244,8 +264,9 @@ discard block |
||
244 | 264 | ); |
245 | 265 | |
246 | 266 | // blackberry, playbook, iphone, nokia, android and ipods set a mobile flag |
247 | - if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) |
|
248 | - $this->_is_mobile = true; |
|
267 | + if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) { |
|
268 | + $this->_is_mobile = true; |
|
269 | + } |
|
249 | 270 | |
250 | 271 | // @todo what to do with the blaPad? ... for now leave it detected as Safari ... |
251 | 272 | $this->_browsers['is_safari'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && !$this->_browsers['is_chrome'] && !$this->_browsers['is_iphone']; |
@@ -254,15 +275,17 @@ discard block |
||
254 | 275 | // if Chrome, get the major version |
255 | 276 | if ($this->_browsers['is_chrome']) |
256 | 277 | { |
257 | - if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
258 | - $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
278 | + if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
279 | + $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
280 | + } |
|
259 | 281 | } |
260 | 282 | |
261 | 283 | // or if Safari get its major version |
262 | 284 | if ($this->_browsers['is_safari']) |
263 | 285 | { |
264 | - if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
265 | - $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
286 | + if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
287 | + $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
288 | + } |
|
266 | 289 | } |
267 | 290 | } |
268 | 291 | |
@@ -291,8 +314,9 @@ discard block |
||
291 | 314 | $this->_browsers['is_ie' . ((int) $trident_match[1] + 4)] = true; |
292 | 315 | |
293 | 316 | // If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view |
294 | - if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) |
|
295 | - $this->_browsers['is_ie_compat_view'] = true; |
|
317 | + if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) { |
|
318 | + $this->_browsers['is_ie_compat_view'] = true; |
|
319 | + } |
|
296 | 320 | } |
297 | 321 | |
298 | 322 | // Detect true IE6 and IE7 and not IE in compat mode. |
@@ -326,8 +350,9 @@ discard block |
||
326 | 350 | */ |
327 | 351 | private function setupFirefox() |
328 | 352 | { |
329 | - if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
330 | - $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
353 | + if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
354 | + $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
355 | + } |
|
331 | 356 | } |
332 | 357 | |
333 | 358 | /** |
@@ -338,11 +363,13 @@ discard block |
||
338 | 363 | private function setupOpera() |
339 | 364 | { |
340 | 365 | // Opera 10+ uses the version tag at the end of the string |
341 | - if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
342 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
366 | + if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
367 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
368 | + } |
|
343 | 369 | // Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers |
344 | - elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
345 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
370 | + elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
371 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
372 | + } |
|
346 | 373 | |
347 | 374 | // Needs size fix? |
348 | 375 | $this->_browsers['needs_size_fix'] = !empty($this->_browsers['is_opera6']); |
@@ -353,8 +380,9 @@ discard block |
||
353 | 380 | */ |
354 | 381 | private function setupEdge() |
355 | 382 | { |
356 | - if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
357 | - $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
383 | + if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
384 | + $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
385 | + } |
|
358 | 386 | } |
359 | 387 | |
360 | 388 | /** |
@@ -367,9 +395,9 @@ discard block |
||
367 | 395 | { |
368 | 396 | global $context; |
369 | 397 | |
370 | - if ($this->_is_mobile) |
|
371 | - $context['browser_body_id'] = 'mobile'; |
|
372 | - else |
|
398 | + if ($this->_is_mobile) { |
|
399 | + $context['browser_body_id'] = 'mobile'; |
|
400 | + } else |
|
373 | 401 | { |
374 | 402 | // add in any specific detection conversions here if you want a special body id e.g. 'is_opera9' => 'opera9' |
375 | 403 | $browser_priority = array( |
@@ -694,7 +694,6 @@ |
||
694 | 694 | * It shows as the maintain_forum admin area. |
695 | 695 | * It is accessed from ?action=admin;area=maintain;sa=database;activity=optimize. |
696 | 696 | * It also updates the optimize scheduled task such that the tables are not automatically optimized again too soon. |
697 | - |
|
698 | 697 | * @uses the optimize sub template |
699 | 698 | */ |
700 | 699 | function OptimizeTables() |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Main dispatcher, the maintenance access point. |
@@ -96,14 +97,16 @@ discard block |
||
96 | 97 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
97 | 98 | |
98 | 99 | // Yep, sub-action time! |
99 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
100 | - $subAction = $_REQUEST['sa']; |
|
101 | - else |
|
102 | - $subAction = 'routine'; |
|
100 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
101 | + $subAction = $_REQUEST['sa']; |
|
102 | + } else { |
|
103 | + $subAction = 'routine'; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | // Doing something special? |
105 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
106 | - $activity = $_REQUEST['activity']; |
|
107 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
108 | + $activity = $_REQUEST['activity']; |
|
109 | + } |
|
107 | 110 | |
108 | 111 | // Set a few things. |
109 | 112 | $context['page_title'] = $txt['maintain_title']; |
@@ -114,12 +117,14 @@ discard block |
||
114 | 117 | call_helper($subActions[$subAction]['function']); |
115 | 118 | |
116 | 119 | // Any special activity? |
117 | - if (isset($activity)) |
|
118 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
120 | + if (isset($activity)) { |
|
121 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
122 | + } |
|
119 | 123 | |
120 | 124 | //converted to UTF-8? show a small maintenance info |
121 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
122 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
125 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
126 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
127 | + } |
|
123 | 128 | |
124 | 129 | // Create a maintenance token. Kinda hard to do it any other way. |
125 | 130 | createToken('admin-maint'); |
@@ -141,19 +146,22 @@ discard block |
||
141 | 146 | db_extend('packages'); |
142 | 147 | |
143 | 148 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
144 | - foreach ($colData as $column) |
|
145 | - if ($column['name'] == 'body') |
|
149 | + foreach ($colData as $column) { |
|
150 | + if ($column['name'] == 'body') |
|
146 | 151 | $body_type = $column['type']; |
152 | + } |
|
147 | 153 | |
148 | 154 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
149 | 155 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
150 | 156 | } |
151 | 157 | |
152 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
153 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
154 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
155 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
156 | -} |
|
158 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
159 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
160 | + } |
|
161 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
162 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
163 | + } |
|
164 | + } |
|
157 | 165 | |
158 | 166 | /** |
159 | 167 | * Supporting function for the routine maintenance area. |
@@ -162,9 +170,10 @@ discard block |
||
162 | 170 | { |
163 | 171 | global $context, $txt; |
164 | 172 | |
165 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
166 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
167 | -} |
|
173 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
174 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
175 | + } |
|
176 | + } |
|
168 | 177 | |
169 | 178 | /** |
170 | 179 | * Supporting function for the members maintenance area. |
@@ -195,8 +204,9 @@ discard block |
||
195 | 204 | } |
196 | 205 | $smcFunc['db_free_result']($result); |
197 | 206 | |
198 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
199 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
207 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
208 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
209 | + } |
|
200 | 210 | |
201 | 211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
202 | 212 | } |
@@ -222,11 +232,12 @@ discard block |
||
222 | 232 | $context['categories'] = array(); |
223 | 233 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
224 | 234 | { |
225 | - if (!isset($context['categories'][$row['id_cat']])) |
|
226 | - $context['categories'][$row['id_cat']] = array( |
|
235 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
236 | + $context['categories'][$row['id_cat']] = array( |
|
227 | 237 | 'name' => $row['cat_name'], |
228 | 238 | 'boards' => array() |
229 | 239 | ); |
240 | + } |
|
230 | 241 | |
231 | 242 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
232 | 243 | 'id' => $row['id_board'], |
@@ -239,11 +250,12 @@ discard block |
||
239 | 250 | require_once($sourcedir . '/Subs-Boards.php'); |
240 | 251 | sortCategories($context['categories']); |
241 | 252 | |
242 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
243 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
244 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
245 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
246 | -} |
|
253 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
254 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
255 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
256 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
257 | + } |
|
258 | + } |
|
247 | 259 | |
248 | 260 | /** |
249 | 261 | * Find and fix all errors on the forum. |
@@ -351,15 +363,17 @@ discard block |
||
351 | 363 | // Show me your badge! |
352 | 364 | isAllowedTo('admin_forum'); |
353 | 365 | |
354 | - if ($db_type != 'mysql') |
|
355 | - return; |
|
366 | + if ($db_type != 'mysql') { |
|
367 | + return; |
|
368 | + } |
|
356 | 369 | |
357 | 370 | db_extend('packages'); |
358 | 371 | |
359 | 372 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
360 | - foreach ($colData as $column) |
|
361 | - if ($column['name'] == 'body') |
|
373 | + foreach ($colData as $column) { |
|
374 | + if ($column['name'] == 'body') |
|
362 | 375 | $body_type = $column['type']; |
376 | + } |
|
363 | 377 | |
364 | 378 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
365 | 379 | |
@@ -369,33 +383,36 @@ discard block |
||
369 | 383 | validateToken('admin-maint'); |
370 | 384 | |
371 | 385 | // Make it longer so we can do their limit. |
372 | - if ($body_type == 'text') |
|
373 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
386 | + if ($body_type == 'text') { |
|
387 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
388 | + } |
|
374 | 389 | // Shorten the column so we can have a bit (literally per record) less space occupied |
375 | - else |
|
376 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
390 | + else { |
|
391 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
392 | + } |
|
377 | 393 | |
378 | 394 | // 3rd party integrations may be interested in knowning about this. |
379 | 395 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
380 | 396 | |
381 | 397 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
382 | - foreach ($colData as $column) |
|
383 | - if ($column['name'] == 'body') |
|
398 | + foreach ($colData as $column) { |
|
399 | + if ($column['name'] == 'body') |
|
384 | 400 | $body_type = $column['type']; |
401 | + } |
|
385 | 402 | |
386 | 403 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
387 | 404 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
388 | 405 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
389 | 406 | |
390 | 407 | return; |
391 | - } |
|
392 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
408 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
393 | 409 | { |
394 | 410 | checkSession(); |
395 | - if (empty($_REQUEST['start'])) |
|
396 | - validateToken('admin-maint'); |
|
397 | - else |
|
398 | - validateToken('admin-convertMsg'); |
|
411 | + if (empty($_REQUEST['start'])) { |
|
412 | + validateToken('admin-maint'); |
|
413 | + } else { |
|
414 | + validateToken('admin-convertMsg'); |
|
415 | + } |
|
399 | 416 | |
400 | 417 | $context['page_title'] = $txt['not_done_title']; |
401 | 418 | $context['continue_post_data'] = ''; |
@@ -427,8 +444,9 @@ discard block |
||
427 | 444 | 'increment' => $increment - 1, |
428 | 445 | ) |
429 | 446 | ); |
430 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
431 | - $id_msg_exceeding[] = $row['id_msg']; |
|
447 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
448 | + $id_msg_exceeding[] = $row['id_msg']; |
|
449 | + } |
|
432 | 450 | $smcFunc['db_free_result']($request); |
433 | 451 | |
434 | 452 | $_REQUEST['start'] += $increment; |
@@ -457,9 +475,9 @@ discard block |
||
457 | 475 | { |
458 | 476 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
459 | 477 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
478 | + } else { |
|
479 | + $query_msg = $id_msg_exceeding; |
|
460 | 480 | } |
461 | - else |
|
462 | - $query_msg = $id_msg_exceeding; |
|
463 | 481 | |
464 | 482 | $context['exceeding_messages'] = array(); |
465 | 483 | $request = $smcFunc['db_query']('', ' |
@@ -470,8 +488,9 @@ discard block |
||
470 | 488 | 'messages' => $query_msg, |
471 | 489 | ) |
472 | 490 | ); |
473 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
474 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
491 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
492 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
493 | + } |
|
475 | 494 | $smcFunc['db_free_result']($request); |
476 | 495 | } |
477 | 496 | } |
@@ -495,8 +514,9 @@ discard block |
||
495 | 514 | isAllowedTo('admin_forum'); |
496 | 515 | |
497 | 516 | // Check to see if UTF-8 is currently the default character set. |
498 | - if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') |
|
499 | - fatal_lang_error('entity_convert_only_utf8'); |
|
517 | + if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') { |
|
518 | + fatal_lang_error('entity_convert_only_utf8'); |
|
519 | + } |
|
500 | 520 | |
501 | 521 | // Some starting values. |
502 | 522 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -558,8 +578,9 @@ discard block |
||
558 | 578 | // Make sure we keep stuff unique! |
559 | 579 | $primary_keys = array(); |
560 | 580 | |
561 | - if (function_exists('apache_reset_timeout')) |
|
562 | - @apache_reset_timeout(); |
|
581 | + if (function_exists('apache_reset_timeout')) { |
|
582 | + @apache_reset_timeout(); |
|
583 | + } |
|
563 | 584 | |
564 | 585 | // Get a list of text columns. |
565 | 586 | $columns = array(); |
@@ -570,9 +591,10 @@ discard block |
||
570 | 591 | 'cur_table' => $cur_table, |
571 | 592 | ) |
572 | 593 | ); |
573 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
574 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
594 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
595 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
575 | 596 | $columns[] = strtolower($column_info['Field']); |
597 | + } |
|
576 | 598 | |
577 | 599 | // Get the column with the (first) primary key. |
578 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -586,8 +608,9 @@ discard block |
||
586 | 608 | { |
587 | 609 | if ($row['Key_name'] === 'PRIMARY') |
588 | 610 | { |
589 | - if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) |
|
590 | - $primary_key = $row['Column_name']; |
|
611 | + if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) { |
|
612 | + $primary_key = $row['Column_name']; |
|
613 | + } |
|
591 | 614 | |
592 | 615 | $primary_keys[] = $row['Column_name']; |
593 | 616 | } |
@@ -596,8 +619,9 @@ discard block |
||
596 | 619 | |
597 | 620 | // No primary key, no glory. |
598 | 621 | // Same for columns. Just to be sure we've work to do! |
599 | - if (empty($primary_key) || empty($columns)) |
|
600 | - continue; |
|
622 | + if (empty($primary_key) || empty($columns)) { |
|
623 | + continue; |
|
624 | + } |
|
601 | 625 | |
602 | 626 | // Get the maximum value for the primary key. |
603 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -611,8 +635,9 @@ discard block |
||
611 | 635 | list($max_value) = $smcFunc['db_fetch_row']($request); |
612 | 636 | $smcFunc['db_free_result']($request); |
613 | 637 | |
614 | - if (empty($max_value)) |
|
615 | - continue; |
|
638 | + if (empty($max_value)) { |
|
639 | + continue; |
|
640 | + } |
|
616 | 641 | |
617 | 642 | while ($context['start'] <= $max_value) |
618 | 643 | { |
@@ -636,10 +661,11 @@ discard block |
||
636 | 661 | { |
637 | 662 | $insertion_variables = array(); |
638 | 663 | $changes = array(); |
639 | - foreach ($row as $column_name => $column_value) |
|
640 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
664 | + foreach ($row as $column_name => $column_value) { |
|
665 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
641 | 666 | { |
642 | 667 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
668 | + } |
|
643 | 669 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value); |
644 | 670 | } |
645 | 671 | |
@@ -651,8 +677,8 @@ discard block |
||
651 | 677 | } |
652 | 678 | |
653 | 679 | // Update the row. |
654 | - if (!empty($changes)) |
|
655 | - $smcFunc['db_query']('', ' |
|
680 | + if (!empty($changes)) { |
|
681 | + $smcFunc['db_query']('', ' |
|
656 | 682 | UPDATE {db_prefix}' . $cur_table . ' |
657 | 683 | SET |
658 | 684 | ' . implode(', |
@@ -660,6 +686,7 @@ discard block |
||
660 | 686 | WHERE ' . implode(' AND ', $where), |
661 | 687 | $insertion_variables |
662 | 688 | ); |
689 | + } |
|
663 | 690 | } |
664 | 691 | $smcFunc['db_free_result']($request); |
665 | 692 | $context['start'] += 500; |
@@ -704,10 +731,11 @@ discard block |
||
704 | 731 | |
705 | 732 | checkSession('request'); |
706 | 733 | |
707 | - if (!isset($_SESSION['optimized_tables'])) |
|
708 | - validateToken('admin-maint'); |
|
709 | - else |
|
710 | - validateToken('admin-optimize', 'post', false); |
|
734 | + if (!isset($_SESSION['optimized_tables'])) { |
|
735 | + validateToken('admin-maint'); |
|
736 | + } else { |
|
737 | + validateToken('admin-optimize', 'post', false); |
|
738 | + } |
|
711 | 739 | |
712 | 740 | ignore_user_abort(true); |
713 | 741 | db_extend(); |
@@ -723,13 +751,15 @@ discard block |
||
723 | 751 | // Get a list of tables, as well as how many there are. |
724 | 752 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
725 | 753 | $tables = array(); |
726 | - foreach ($temp_tables as $table) |
|
727 | - $tables[] = array('table_name' => $table); |
|
754 | + foreach ($temp_tables as $table) { |
|
755 | + $tables[] = array('table_name' => $table); |
|
756 | + } |
|
728 | 757 | |
729 | 758 | // If there aren't any tables then I believe that would mean the world has exploded... |
730 | 759 | $context['num_tables'] = count($tables); |
731 | - if ($context['num_tables'] == 0) |
|
732 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
760 | + if ($context['num_tables'] == 0) { |
|
761 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
762 | + } |
|
733 | 763 | |
734 | 764 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
735 | 765 | |
@@ -740,8 +770,9 @@ discard block |
||
740 | 770 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
741 | 771 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
742 | 772 | { |
743 | - if (empty($tables[$key])) |
|
744 | - break; |
|
773 | + if (empty($tables[$key])) { |
|
774 | + break; |
|
775 | + } |
|
745 | 776 | |
746 | 777 | // Continue? |
747 | 778 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10) |
@@ -755,8 +786,9 @@ discard block |
||
755 | 786 | createToken('admin-optimize'); |
756 | 787 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
757 | 788 | |
758 | - if (function_exists('apache_reset_timeout')) |
|
759 | - apache_reset_timeout(); |
|
789 | + if (function_exists('apache_reset_timeout')) { |
|
790 | + apache_reset_timeout(); |
|
791 | + } |
|
760 | 792 | |
761 | 793 | return; |
762 | 794 | } |
@@ -764,11 +796,12 @@ discard block |
||
764 | 796 | // Optimize the table! We use backticks here because it might be a custom table. |
765 | 797 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
766 | 798 | |
767 | - if ($data_freed > 0) |
|
768 | - $_SESSION['optimized_tables'][] = array( |
|
799 | + if ($data_freed > 0) { |
|
800 | + $_SESSION['optimized_tables'][] = array( |
|
769 | 801 | 'name' => $tables[$key]['table_name'], |
770 | 802 | 'data_freed' => $data_freed, |
771 | 803 | ); |
804 | + } |
|
772 | 805 | } |
773 | 806 | |
774 | 807 | // Number of tables, etc... |
@@ -803,10 +836,11 @@ discard block |
||
803 | 836 | checkSession('request'); |
804 | 837 | |
805 | 838 | // validate the request or the loop |
806 | - if (!isset($_REQUEST['step'])) |
|
807 | - validateToken('admin-maint'); |
|
808 | - else |
|
809 | - validateToken('admin-boardrecount'); |
|
839 | + if (!isset($_REQUEST['step'])) { |
|
840 | + validateToken('admin-maint'); |
|
841 | + } else { |
|
842 | + validateToken('admin-boardrecount'); |
|
843 | + } |
|
810 | 844 | |
811 | 845 | $context['page_title'] = $txt['not_done_title']; |
812 | 846 | $context['continue_post_data'] = ''; |
@@ -827,8 +861,9 @@ discard block |
||
827 | 861 | $smcFunc['db_free_result']($request); |
828 | 862 | |
829 | 863 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
830 | - if (empty($_REQUEST['start'])) |
|
831 | - $_REQUEST['start'] = 0; |
|
864 | + if (empty($_REQUEST['start'])) { |
|
865 | + $_REQUEST['start'] = 0; |
|
866 | + } |
|
832 | 867 | |
833 | 868 | $total_steps = 8; |
834 | 869 | |
@@ -855,8 +890,8 @@ discard block |
||
855 | 890 | 'max_id' => $_REQUEST['start'] + $increment, |
856 | 891 | ) |
857 | 892 | ); |
858 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
859 | - $smcFunc['db_query']('', ' |
|
893 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
894 | + $smcFunc['db_query']('', ' |
|
860 | 895 | UPDATE {db_prefix}topics |
861 | 896 | SET num_replies = {int:num_replies} |
862 | 897 | WHERE id_topic = {int:id_topic}', |
@@ -865,6 +900,7 @@ discard block |
||
865 | 900 | 'id_topic' => $row['id_topic'], |
866 | 901 | ) |
867 | 902 | ); |
903 | + } |
|
868 | 904 | $smcFunc['db_free_result']($request); |
869 | 905 | |
870 | 906 | // Recount unapproved messages |
@@ -883,8 +919,8 @@ discard block |
||
883 | 919 | 'max_id' => $_REQUEST['start'] + $increment, |
884 | 920 | ) |
885 | 921 | ); |
886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
887 | - $smcFunc['db_query']('', ' |
|
922 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
923 | + $smcFunc['db_query']('', ' |
|
888 | 924 | UPDATE {db_prefix}topics |
889 | 925 | SET unapproved_posts = {int:unapproved_posts} |
890 | 926 | WHERE id_topic = {int:id_topic}', |
@@ -893,6 +929,7 @@ discard block |
||
893 | 929 | 'id_topic' => $row['id_topic'], |
894 | 930 | ) |
895 | 931 | ); |
932 | + } |
|
896 | 933 | $smcFunc['db_free_result']($request); |
897 | 934 | |
898 | 935 | $_REQUEST['start'] += $increment; |
@@ -915,8 +952,8 @@ discard block |
||
915 | 952 | // Update the post count of each board. |
916 | 953 | if ($_REQUEST['step'] <= 1) |
917 | 954 | { |
918 | - if (empty($_REQUEST['start'])) |
|
919 | - $smcFunc['db_query']('', ' |
|
955 | + if (empty($_REQUEST['start'])) { |
|
956 | + $smcFunc['db_query']('', ' |
|
920 | 957 | UPDATE {db_prefix}boards |
921 | 958 | SET num_posts = {int:num_posts} |
922 | 959 | WHERE redirect = {string:redirect}', |
@@ -925,6 +962,7 @@ discard block |
||
925 | 962 | 'redirect' => '', |
926 | 963 | ) |
927 | 964 | ); |
965 | + } |
|
928 | 966 | |
929 | 967 | while ($_REQUEST['start'] < $max_topics) |
930 | 968 | { |
@@ -941,8 +979,8 @@ discard block |
||
941 | 979 | 'is_approved' => 1, |
942 | 980 | ) |
943 | 981 | ); |
944 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
945 | - $smcFunc['db_query']('', ' |
|
982 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
983 | + $smcFunc['db_query']('', ' |
|
946 | 984 | UPDATE {db_prefix}boards |
947 | 985 | SET num_posts = num_posts + {int:real_num_posts} |
948 | 986 | WHERE id_board = {int:id_board}', |
@@ -951,6 +989,7 @@ discard block |
||
951 | 989 | 'real_num_posts' => $row['real_num_posts'], |
952 | 990 | ) |
953 | 991 | ); |
992 | + } |
|
954 | 993 | $smcFunc['db_free_result']($request); |
955 | 994 | |
956 | 995 | $_REQUEST['start'] += $increment; |
@@ -973,14 +1012,15 @@ discard block |
||
973 | 1012 | // Update the topic count of each board. |
974 | 1013 | if ($_REQUEST['step'] <= 2) |
975 | 1014 | { |
976 | - if (empty($_REQUEST['start'])) |
|
977 | - $smcFunc['db_query']('', ' |
|
1015 | + if (empty($_REQUEST['start'])) { |
|
1016 | + $smcFunc['db_query']('', ' |
|
978 | 1017 | UPDATE {db_prefix}boards |
979 | 1018 | SET num_topics = {int:num_topics}', |
980 | 1019 | array( |
981 | 1020 | 'num_topics' => 0, |
982 | 1021 | ) |
983 | 1022 | ); |
1023 | + } |
|
984 | 1024 | |
985 | 1025 | while ($_REQUEST['start'] < $max_topics) |
986 | 1026 | { |
@@ -997,8 +1037,8 @@ discard block |
||
997 | 1037 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
998 | 1038 | ) |
999 | 1039 | ); |
1000 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1001 | - $smcFunc['db_query']('', ' |
|
1040 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1041 | + $smcFunc['db_query']('', ' |
|
1002 | 1042 | UPDATE {db_prefix}boards |
1003 | 1043 | SET num_topics = num_topics + {int:real_num_topics} |
1004 | 1044 | WHERE id_board = {int:id_board}', |
@@ -1007,6 +1047,7 @@ discard block |
||
1007 | 1047 | 'real_num_topics' => $row['real_num_topics'], |
1008 | 1048 | ) |
1009 | 1049 | ); |
1050 | + } |
|
1010 | 1051 | $smcFunc['db_free_result']($request); |
1011 | 1052 | |
1012 | 1053 | $_REQUEST['start'] += $increment; |
@@ -1029,14 +1070,15 @@ discard block |
||
1029 | 1070 | // Update the unapproved post count of each board. |
1030 | 1071 | if ($_REQUEST['step'] <= 3) |
1031 | 1072 | { |
1032 | - if (empty($_REQUEST['start'])) |
|
1033 | - $smcFunc['db_query']('', ' |
|
1073 | + if (empty($_REQUEST['start'])) { |
|
1074 | + $smcFunc['db_query']('', ' |
|
1034 | 1075 | UPDATE {db_prefix}boards |
1035 | 1076 | SET unapproved_posts = {int:unapproved_posts}', |
1036 | 1077 | array( |
1037 | 1078 | 'unapproved_posts' => 0, |
1038 | 1079 | ) |
1039 | 1080 | ); |
1081 | + } |
|
1040 | 1082 | |
1041 | 1083 | while ($_REQUEST['start'] < $max_topics) |
1042 | 1084 | { |
@@ -1053,8 +1095,8 @@ discard block |
||
1053 | 1095 | 'is_approved' => 0, |
1054 | 1096 | ) |
1055 | 1097 | ); |
1056 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1057 | - $smcFunc['db_query']('', ' |
|
1098 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1099 | + $smcFunc['db_query']('', ' |
|
1058 | 1100 | UPDATE {db_prefix}boards |
1059 | 1101 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
1060 | 1102 | WHERE id_board = {int:id_board}', |
@@ -1063,6 +1105,7 @@ discard block |
||
1063 | 1105 | 'unapproved_posts' => $row['real_unapproved_posts'], |
1064 | 1106 | ) |
1065 | 1107 | ); |
1108 | + } |
|
1066 | 1109 | $smcFunc['db_free_result']($request); |
1067 | 1110 | |
1068 | 1111 | $_REQUEST['start'] += $increment; |
@@ -1085,14 +1128,15 @@ discard block |
||
1085 | 1128 | // Update the unapproved topic count of each board. |
1086 | 1129 | if ($_REQUEST['step'] <= 4) |
1087 | 1130 | { |
1088 | - if (empty($_REQUEST['start'])) |
|
1089 | - $smcFunc['db_query']('', ' |
|
1131 | + if (empty($_REQUEST['start'])) { |
|
1132 | + $smcFunc['db_query']('', ' |
|
1090 | 1133 | UPDATE {db_prefix}boards |
1091 | 1134 | SET unapproved_topics = {int:unapproved_topics}', |
1092 | 1135 | array( |
1093 | 1136 | 'unapproved_topics' => 0, |
1094 | 1137 | ) |
1095 | 1138 | ); |
1139 | + } |
|
1096 | 1140 | |
1097 | 1141 | while ($_REQUEST['start'] < $max_topics) |
1098 | 1142 | { |
@@ -1109,8 +1153,8 @@ discard block |
||
1109 | 1153 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
1110 | 1154 | ) |
1111 | 1155 | ); |
1112 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1113 | - $smcFunc['db_query']('', ' |
|
1156 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1157 | + $smcFunc['db_query']('', ' |
|
1114 | 1158 | UPDATE {db_prefix}boards |
1115 | 1159 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
1116 | 1160 | WHERE id_board = {int:id_board}', |
@@ -1119,6 +1163,7 @@ discard block |
||
1119 | 1163 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
1120 | 1164 | ) |
1121 | 1165 | ); |
1166 | + } |
|
1122 | 1167 | $smcFunc['db_free_result']($request); |
1123 | 1168 | |
1124 | 1169 | $_REQUEST['start'] += $increment; |
@@ -1152,8 +1197,9 @@ discard block |
||
1152 | 1197 | 'is_not_deleted' => 0, |
1153 | 1198 | ) |
1154 | 1199 | ); |
1155 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1156 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1201 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1202 | + } |
|
1157 | 1203 | $smcFunc['db_free_result']($request); |
1158 | 1204 | |
1159 | 1205 | $request = $smcFunc['db_query']('', ' |
@@ -1168,8 +1214,9 @@ discard block |
||
1168 | 1214 | 'is_not_read' => 0, |
1169 | 1215 | ) |
1170 | 1216 | ); |
1171 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1172 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1217 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1218 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1219 | + } |
|
1173 | 1220 | $smcFunc['db_free_result']($request); |
1174 | 1221 | |
1175 | 1222 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3) |
@@ -1201,12 +1248,13 @@ discard block |
||
1201 | 1248 | ) |
1202 | 1249 | ); |
1203 | 1250 | $boards = array(); |
1204 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1205 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
1251 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1252 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
1253 | + } |
|
1206 | 1254 | $smcFunc['db_free_result']($request); |
1207 | 1255 | |
1208 | - foreach ($boards as $board_id => $messages) |
|
1209 | - $smcFunc['db_query']('', ' |
|
1256 | + foreach ($boards as $board_id => $messages) { |
|
1257 | + $smcFunc['db_query']('', ' |
|
1210 | 1258 | UPDATE {db_prefix}messages |
1211 | 1259 | SET id_board = {int:id_board} |
1212 | 1260 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1215,6 +1263,7 @@ discard block |
||
1215 | 1263 | 'id_board' => $board_id, |
1216 | 1264 | ) |
1217 | 1265 | ); |
1266 | + } |
|
1218 | 1267 | |
1219 | 1268 | $_REQUEST['start'] += $increment; |
1220 | 1269 | |
@@ -1244,8 +1293,9 @@ discard block |
||
1244 | 1293 | ) |
1245 | 1294 | ); |
1246 | 1295 | $realBoardCounts = array(); |
1247 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1248 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1296 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1297 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1298 | + } |
|
1249 | 1299 | $smcFunc['db_free_result']($request); |
1250 | 1300 | |
1251 | 1301 | $request = $smcFunc['db_query']('', ' |
@@ -1265,18 +1315,20 @@ discard block |
||
1265 | 1315 | krsort($resort_me); |
1266 | 1316 | |
1267 | 1317 | $lastModifiedMsg = array(); |
1268 | - foreach ($resort_me as $rows) |
|
1269 | - foreach ($rows as $row) |
|
1318 | + foreach ($resort_me as $rows) { |
|
1319 | + foreach ($rows as $row) |
|
1270 | 1320 | { |
1271 | 1321 | // The latest message is the latest of the current board and its children. |
1272 | 1322 | if (isset($lastModifiedMsg[$row['id_board']])) |
1273 | 1323 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
1274 | - else |
|
1275 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
1324 | + } |
|
1325 | + else { |
|
1326 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
1327 | + } |
|
1276 | 1328 | |
1277 | 1329 | // If what is and what should be the latest message differ, an update is necessary. |
1278 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
1279 | - $smcFunc['db_query']('', ' |
|
1330 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
1331 | + $smcFunc['db_query']('', ' |
|
1280 | 1332 | UPDATE {db_prefix}boards |
1281 | 1333 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
1282 | 1334 | WHERE id_board = {int:id_board}', |
@@ -1286,12 +1338,14 @@ discard block |
||
1286 | 1338 | 'id_board' => $row['id_board'], |
1287 | 1339 | ) |
1288 | 1340 | ); |
1341 | + } |
|
1289 | 1342 | |
1290 | 1343 | // Parent boards inherit the latest modified message of their children. |
1291 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
1292 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1293 | - else |
|
1294 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1344 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
1345 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1346 | + } else { |
|
1347 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1348 | + } |
|
1295 | 1349 | } |
1296 | 1350 | |
1297 | 1351 | // Update all the basic statistics. |
@@ -1363,8 +1417,9 @@ discard block |
||
1363 | 1417 | require_once($sourcedir . '/Subs-Auth.php'); |
1364 | 1418 | $members = findMembers($_POST['to']); |
1365 | 1419 | |
1366 | - if (empty($members)) |
|
1367 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
1420 | + if (empty($members)) { |
|
1421 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
1422 | + } |
|
1368 | 1423 | |
1369 | 1424 | $memID = array_shift($members); |
1370 | 1425 | $memID = $memID['id']; |
@@ -1394,8 +1449,9 @@ discard block |
||
1394 | 1449 | validateToken('admin-maint'); |
1395 | 1450 | |
1396 | 1451 | $groups = array(); |
1397 | - foreach ($_POST['groups'] as $id => $dummy) |
|
1398 | - $groups[] = (int) $id; |
|
1452 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
1453 | + $groups[] = (int) $id; |
|
1454 | + } |
|
1399 | 1455 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
1400 | 1456 | $where_vars = array( |
1401 | 1457 | 'time_limit' => $time_limit, |
@@ -1404,9 +1460,9 @@ discard block |
||
1404 | 1460 | { |
1405 | 1461 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
1406 | 1462 | $where_vars['is_activated'] = 0; |
1463 | + } else { |
|
1464 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1407 | 1465 | } |
1408 | - else |
|
1409 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1410 | 1466 | |
1411 | 1467 | // Need to get *all* groups then work out which (if any) we avoid. |
1412 | 1468 | $request = $smcFunc['db_query']('', ' |
@@ -1425,8 +1481,7 @@ discard block |
||
1425 | 1481 | { |
1426 | 1482 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
1427 | 1483 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
1428 | - } |
|
1429 | - else |
|
1484 | + } else |
|
1430 | 1485 | { |
1431 | 1486 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
1432 | 1487 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1453,8 +1508,9 @@ discard block |
||
1453 | 1508 | $members = array(); |
1454 | 1509 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1455 | 1510 | { |
1456 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
1457 | - $members[] = $row['id_member']; |
|
1511 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
1512 | + $members[] = $row['id_member']; |
|
1513 | + } |
|
1458 | 1514 | } |
1459 | 1515 | $smcFunc['db_free_result']($request); |
1460 | 1516 | |
@@ -1501,8 +1557,9 @@ discard block |
||
1501 | 1557 | ) |
1502 | 1558 | ); |
1503 | 1559 | |
1504 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1505 | - $drafts[] = (int) $row[0]; |
|
1560 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1561 | + $drafts[] = (int) $row[0]; |
|
1562 | + } |
|
1506 | 1563 | $smcFunc['db_free_result']($request); |
1507 | 1564 | |
1508 | 1565 | // If we have old drafts, remove them |
@@ -1545,8 +1602,9 @@ discard block |
||
1545 | 1602 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
1546 | 1603 | |
1547 | 1604 | // No boards then this is your stop. |
1548 | - if (empty($id_board_from) || empty($id_board_to)) |
|
1549 | - return; |
|
1605 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
1606 | + return; |
|
1607 | + } |
|
1550 | 1608 | |
1551 | 1609 | // The big WHERE clause |
1552 | 1610 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1594,18 +1652,20 @@ discard block |
||
1594 | 1652 | ); |
1595 | 1653 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
1596 | 1654 | $smcFunc['db_free_result']($request); |
1655 | + } else { |
|
1656 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
1597 | 1657 | } |
1598 | - else |
|
1599 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
1600 | 1658 | |
1601 | 1659 | // Seems like we need this here. |
1602 | 1660 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
1603 | 1661 | |
1604 | - if ($locked) |
|
1605 | - $context['continue_get_data'] .= ';locked'; |
|
1662 | + if ($locked) { |
|
1663 | + $context['continue_get_data'] .= ';locked'; |
|
1664 | + } |
|
1606 | 1665 | |
1607 | - if ($sticky) |
|
1608 | - $context['continue_get_data'] .= ';sticky'; |
|
1666 | + if ($sticky) { |
|
1667 | + $context['continue_get_data'] .= ';sticky'; |
|
1668 | + } |
|
1609 | 1669 | |
1610 | 1670 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1611 | 1671 | |
@@ -1626,8 +1686,9 @@ discard block |
||
1626 | 1686 | |
1627 | 1687 | // Get the ids. |
1628 | 1688 | $topics = array(); |
1629 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1630 | - $topics[] = $row['id_topic']; |
|
1689 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1690 | + $topics[] = $row['id_topic']; |
|
1691 | + } |
|
1631 | 1692 | |
1632 | 1693 | // Just return if we don't have any topics left to move. |
1633 | 1694 | if (empty($topics)) |
@@ -1718,9 +1779,9 @@ discard block |
||
1718 | 1779 | // save it so we don't do this again for this task |
1719 | 1780 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
1720 | 1781 | $smcFunc['db_free_result']($request); |
1782 | + } else { |
|
1783 | + validateToken('admin-recountposts'); |
|
1721 | 1784 | } |
1722 | - else |
|
1723 | - validateToken('admin-recountposts'); |
|
1724 | 1785 | |
1725 | 1786 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
1726 | 1787 | $request = $smcFunc['db_query']('', ' |
@@ -1766,8 +1827,9 @@ discard block |
||
1766 | 1827 | createToken('admin-recountposts'); |
1767 | 1828 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
1768 | 1829 | |
1769 | - if (function_exists('apache_reset_timeout')) |
|
1770 | - apache_reset_timeout(); |
|
1830 | + if (function_exists('apache_reset_timeout')) { |
|
1831 | + apache_reset_timeout(); |
|
1832 | + } |
|
1771 | 1833 | return; |
1772 | 1834 | } |
1773 | 1835 | |
@@ -1853,10 +1915,9 @@ discard block |
||
1853 | 1915 | checkSession('request'); |
1854 | 1916 | validateToken('admin-hook', 'request'); |
1855 | 1917 | |
1856 | - if ($_REQUEST['do'] == 'remove') |
|
1857 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1858 | - |
|
1859 | - else |
|
1918 | + if ($_REQUEST['do'] == 'remove') { |
|
1919 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1920 | + } else |
|
1860 | 1921 | { |
1861 | 1922 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
1862 | 1923 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1906,11 +1967,11 @@ discard block |
||
1906 | 1967 | // Show a nice icon to indicate this is an instance. |
1907 | 1968 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
1908 | 1969 | |
1909 | - if (!empty($data['included_file'])) |
|
1910 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1911 | - |
|
1912 | - else |
|
1913 | - return $instance . $data['real_function']; |
|
1970 | + if (!empty($data['included_file'])) { |
|
1971 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1972 | + } else { |
|
1973 | + return $instance . $data['real_function']; |
|
1974 | + } |
|
1914 | 1975 | }, |
1915 | 1976 | ), |
1916 | 1977 | 'sort' => array( |
@@ -1975,11 +2036,12 @@ discard block |
||
1975 | 2036 | 'data' => array( |
1976 | 2037 | 'function' => function($data) use ($txt, $scripturl, $context) |
1977 | 2038 | { |
1978 | - if (!$data['hook_exists']) |
|
1979 | - return ' |
|
2039 | + if (!$data['hook_exists']) { |
|
2040 | + return ' |
|
1980 | 2041 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
1981 | 2042 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
1982 | 2043 | </a>'; |
2044 | + } |
|
1983 | 2045 | }, |
1984 | 2046 | 'class' => 'centertext', |
1985 | 2047 | ), |
@@ -2014,10 +2076,11 @@ discard block |
||
2014 | 2076 | { |
2015 | 2077 | if ($file != '.' && $file != '..') |
2016 | 2078 | { |
2017 | - if (is_dir($dir_path . '/' . $file)) |
|
2018 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2019 | - else |
|
2020 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2079 | + if (is_dir($dir_path . '/' . $file)) { |
|
2080 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2081 | + } else { |
|
2082 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2083 | + } |
|
2021 | 2084 | } |
2022 | 2085 | } |
2023 | 2086 | } |
@@ -2066,16 +2129,16 @@ discard block |
||
2066 | 2129 | // I need to know if there is at least one function called in this file. |
2067 | 2130 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
2068 | 2131 | unset($temp_hooks[$hook][$rawFunc]); |
2069 | - } |
|
2070 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2132 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2071 | 2133 | { |
2072 | 2134 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
2073 | 2135 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
2074 | 2136 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
2075 | 2137 | |
2076 | 2138 | // Does the hook has its own file? |
2077 | - if (!empty($hookParsedData['hookFile'])) |
|
2078 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2139 | + if (!empty($hookParsedData['hookFile'])) { |
|
2140 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2141 | + } |
|
2079 | 2142 | |
2080 | 2143 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
2081 | 2144 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2102,15 +2165,17 @@ discard block |
||
2102 | 2165 | $sort = array(); |
2103 | 2166 | $hooks_filters = array(); |
2104 | 2167 | |
2105 | - foreach ($hooks as $hook => $functions) |
|
2106 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2168 | + foreach ($hooks as $hook => $functions) { |
|
2169 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2170 | + } |
|
2107 | 2171 | |
2108 | - if (!empty($hooks_filters)) |
|
2109 | - $context['insert_after_template'] .= ' |
|
2172 | + if (!empty($hooks_filters)) { |
|
2173 | + $context['insert_after_template'] .= ' |
|
2110 | 2174 | <script> |
2111 | 2175 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
2112 | 2176 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . '; |
2113 | 2177 | </script>'; |
2178 | + } |
|
2114 | 2179 | |
2115 | 2180 | $temp_data = array(); |
2116 | 2181 | $id = 0; |
@@ -2152,10 +2217,11 @@ discard block |
||
2152 | 2217 | |
2153 | 2218 | foreach ($temp_data as $data) |
2154 | 2219 | { |
2155 | - if (++$counter < $start) |
|
2156 | - continue; |
|
2157 | - elseif ($counter == $start + $per_page) |
|
2158 | - break; |
|
2220 | + if (++$counter < $start) { |
|
2221 | + continue; |
|
2222 | + } elseif ($counter == $start + $per_page) { |
|
2223 | + break; |
|
2224 | + } |
|
2159 | 2225 | |
2160 | 2226 | $hooks_data[] = $data; |
2161 | 2227 | } |
@@ -2177,13 +2243,15 @@ discard block |
||
2177 | 2243 | $hooks_count = 0; |
2178 | 2244 | |
2179 | 2245 | $context['filter'] = false; |
2180 | - if (isset($_GET['filter'])) |
|
2181 | - $context['filter'] = $_GET['filter']; |
|
2246 | + if (isset($_GET['filter'])) { |
|
2247 | + $context['filter'] = $_GET['filter']; |
|
2248 | + } |
|
2182 | 2249 | |
2183 | 2250 | foreach ($hooks as $hook => $functions) |
2184 | 2251 | { |
2185 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
2186 | - $hooks_count += count($functions); |
|
2252 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
2253 | + $hooks_count += count($functions); |
|
2254 | + } |
|
2187 | 2255 | } |
2188 | 2256 | |
2189 | 2257 | return $hooks_count; |
@@ -2204,8 +2272,9 @@ discard block |
||
2204 | 2272 | $integration_hooks = array(); |
2205 | 2273 | foreach ($modSettings as $key => $value) |
2206 | 2274 | { |
2207 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
2208 | - $integration_hooks[$key] = explode(',', $value); |
|
2275 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
2276 | + $integration_hooks[$key] = explode(',', $value); |
|
2277 | + } |
|
2209 | 2278 | } |
2210 | 2279 | } |
2211 | 2280 | |
@@ -2236,8 +2305,9 @@ discard block |
||
2236 | 2305 | ); |
2237 | 2306 | |
2238 | 2307 | // Meh... |
2239 | - if (empty($rawData)) |
|
2240 | - return $hookData; |
|
2308 | + if (empty($rawData)) { |
|
2309 | + return $hookData; |
|
2310 | + } |
|
2241 | 2311 | |
2242 | 2312 | // For convenience purposes only! |
2243 | 2313 | $modFunc = $rawData; |
@@ -2248,11 +2318,11 @@ discard block |
||
2248 | 2318 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
2249 | 2319 | |
2250 | 2320 | // Does the file exists? who knows! |
2251 | - if (empty($settings['theme_dir'])) |
|
2252 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2253 | - |
|
2254 | - else |
|
2255 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2321 | + if (empty($settings['theme_dir'])) { |
|
2322 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2323 | + } else { |
|
2324 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2325 | + } |
|
2256 | 2326 | |
2257 | 2327 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
2258 | 2328 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2277,11 +2347,10 @@ discard block |
||
2277 | 2347 | { |
2278 | 2348 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
2279 | 2349 | $hookData['pureFunc'] = $hookData['method']; |
2350 | + } else { |
|
2351 | + $hookData['pureFunc'] = $modFunc; |
|
2280 | 2352 | } |
2281 | 2353 | |
2282 | - else |
|
2283 | - $hookData['pureFunc'] = $modFunc; |
|
2284 | - |
|
2285 | 2354 | return $hookData; |
2286 | 2355 | } |
2287 | 2356 |
@@ -130,7 +130,6 @@ |
||
130 | 130 | * |
131 | 131 | * @param int $closed 1 for counting closed reports, 0 for open ones. |
132 | 132 | * @return integer How many reports. |
133 | - |
|
134 | 133 | */ |
135 | 134 | function countReports($closed = 0) |
136 | 135 | { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $smcFunc['db_query']('', ' |
50 | 50 | UPDATE {db_prefix}log_reported |
51 | 51 | SET {raw:action} = {string:value} |
52 | - '. (is_array($report_id) ? 'WHERE id_report IN ({array_int:id_report})' : 'WHERE id_report = {int:id_report}') .' |
|
52 | + '. (is_array($report_id) ? 'WHERE id_report IN ({array_int:id_report})' : 'WHERE id_report = {int:id_report}') . ' |
|
53 | 53 | ' . $board_query, |
54 | 54 | array( |
55 | 55 | 'action' => $action, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | |
100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
100 | + while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
101 | 101 | $extra[$row['id_report']] = array( |
102 | 102 | 'report' => $row['id_report'], |
103 | 103 | 'member' => $row['id_member'], |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Updates a report with the given parameters. Logs each action via logAction() |
@@ -28,19 +29,20 @@ discard block |
||
28 | 29 | global $smcFunc, $user_info, $context; |
29 | 30 | |
30 | 31 | // Don't bother. |
31 | - if (empty($action) || empty($report_id)) |
|
32 | - return false; |
|
32 | + if (empty($action) || empty($report_id)) { |
|
33 | + return false; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | // Add the "_all" thingy. |
35 | - if ($action == 'ignore') |
|
36 | - $action = 'ignore_all'; |
|
37 | + if ($action == 'ignore') { |
|
38 | + $action = 'ignore_all'; |
|
39 | + } |
|
37 | 40 | |
38 | 41 | // We don't need the board query for reported members |
39 | 42 | if ($context['report_type'] == 'members') |
40 | 43 | { |
41 | 44 | $board_query = ''; |
42 | - } |
|
43 | - else |
|
45 | + } else |
|
44 | 46 | { |
45 | 47 | $board_query = ' AND ' . $user_info['mod_cache']['bq']; |
46 | 48 | } |
@@ -76,17 +78,17 @@ discard block |
||
76 | 78 | ) |
77 | 79 | ); |
78 | 80 | |
79 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
80 | - $extra[$row['id_report']] = array( |
|
81 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
82 | + $extra[$row['id_report']] = array( |
|
81 | 83 | 'report' => $row['id_report'], |
82 | 84 | 'board' => $row['id_board'], |
83 | 85 | 'message' => $row['id_msg'], |
84 | 86 | 'topic' => $row['id_topic'], |
85 | 87 | ); |
88 | + } |
|
86 | 89 | |
87 | 90 | $smcFunc['db_free_result']($request); |
88 | - } |
|
89 | - else |
|
91 | + } else |
|
90 | 92 | { |
91 | 93 | $request = $smcFunc['db_query']('', ' |
92 | 94 | SELECT id_report, id_member, membername |
@@ -97,28 +99,32 @@ discard block |
||
97 | 99 | ) |
98 | 100 | ); |
99 | 101 | |
100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
101 | - $extra[$row['id_report']] = array( |
|
102 | + while($row = $smcFunc['db_fetch_assoc']($request)) { |
|
103 | + $extra[$row['id_report']] = array( |
|
102 | 104 | 'report' => $row['id_report'], |
103 | 105 | 'member' => $row['id_member'], |
104 | 106 | ); |
107 | + } |
|
105 | 108 | |
106 | 109 | $smcFunc['db_free_result']($request); |
107 | 110 | } |
108 | 111 | |
109 | 112 | // Back to "ignore". |
110 | - if ($action == 'ignore_all') |
|
111 | - $action = 'ignore'; |
|
113 | + if ($action == 'ignore_all') { |
|
114 | + $action = 'ignore'; |
|
115 | + } |
|
112 | 116 | |
113 | 117 | $log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open'); |
114 | 118 | |
115 | - if ($context['report_type'] == 'members') |
|
116 | - $log_report .= '_user'; |
|
119 | + if ($context['report_type'] == 'members') { |
|
120 | + $log_report .= '_user'; |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Log this action. |
119 | - if (!empty($extra)) |
|
120 | - foreach ($extra as $report) |
|
124 | + if (!empty($extra)) { |
|
125 | + foreach ($extra as $report) |
|
121 | 126 | logAction($log_report . '_report', $report); |
127 | + } |
|
122 | 128 | |
123 | 129 | // Time to update. |
124 | 130 | updateSettings(array('last_mod_report_action' => time())); |
@@ -140,14 +146,12 @@ discard block |
||
140 | 146 | if ($context['report_type'] == 'members') |
141 | 147 | { |
142 | 148 | $and = 'lr.id_board = 0'; |
143 | - } |
|
144 | - else |
|
149 | + } else |
|
145 | 150 | { |
146 | 151 | if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1') |
147 | 152 | { |
148 | 153 | $bq = $user_info['mod_cache']['bq']; |
149 | - } |
|
150 | - else |
|
154 | + } else |
|
151 | 155 | { |
152 | 156 | $bq = 'lr.' . $user_info['mod_cache']['bq']; |
153 | 157 | } |
@@ -203,8 +207,7 @@ discard block |
||
203 | 207 | 'max' => 10, |
204 | 208 | ) |
205 | 209 | ); |
206 | - } |
|
207 | - else |
|
210 | + } else |
|
208 | 211 | { |
209 | 212 | $request = $smcFunc['db_query']('', ' |
210 | 213 | SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body, |
@@ -252,8 +255,7 @@ discard block |
||
252 | 255 | 'href' => $scripturl . '?action=profile;u=' . $row['id_user'], |
253 | 256 | ), |
254 | 257 | ); |
255 | - } |
|
256 | - else |
|
258 | + } else |
|
257 | 259 | { |
258 | 260 | $report_boards_ids[] = $row['id_board']; |
259 | 261 | $extraDetails = array( |
@@ -293,14 +295,16 @@ discard block |
||
293 | 295 | ) |
294 | 296 | ); |
295 | 297 | |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $board_names[$row['id_board']] = $row['name']; |
|
298 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
299 | + $board_names[$row['id_board']] = $row['name']; |
|
300 | + } |
|
298 | 301 | |
299 | 302 | $smcFunc['db_free_result']($request); |
300 | 303 | |
301 | - foreach ($reports as $id_report => $report) |
|
302 | - if (!empty($board_names[$report['topic']['id_board']])) |
|
304 | + foreach ($reports as $id_report => $report) { |
|
305 | + if (!empty($board_names[$report['topic']['id_board']])) |
|
303 | 306 | $reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']]; |
307 | + } |
|
304 | 308 | } |
305 | 309 | |
306 | 310 | // Now get all the people who reported it. |
@@ -350,10 +354,11 @@ discard block |
||
350 | 354 | { |
351 | 355 | global $user_info, $smcFunc; |
352 | 356 | |
353 | - if ($type == 'members') |
|
354 | - $bq = ''; |
|
355 | - else |
|
356 | - $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
357 | + if ($type == 'members') { |
|
358 | + $bq = ''; |
|
359 | + } else { |
|
360 | + $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
361 | + } |
|
357 | 362 | |
358 | 363 | $request = $smcFunc['db_query']('', ' |
359 | 364 | SELECT COUNT(*) |
@@ -392,8 +397,9 @@ discard block |
||
392 | 397 | { |
393 | 398 | global $smcFunc, $user_info, $context; |
394 | 399 | |
395 | - if (empty($report_id)) |
|
396 | - return false; |
|
400 | + if (empty($report_id)) { |
|
401 | + return false; |
|
402 | + } |
|
397 | 403 | |
398 | 404 | // We don't need all this info if we're only getting user info |
399 | 405 | if ($context['report_type'] == 'members') |
@@ -411,8 +417,7 @@ discard block |
||
411 | 417 | 'id_report' => $report_id, |
412 | 418 | ) |
413 | 419 | ); |
414 | - } |
|
415 | - else |
|
420 | + } else |
|
416 | 421 | { |
417 | 422 | // Get the report details, need this so we can limit access to a particular board. |
418 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -431,8 +436,9 @@ discard block |
||
431 | 436 | } |
432 | 437 | |
433 | 438 | // So did we find anything? |
434 | - if (!$smcFunc['db_num_rows']($request)) |
|
435 | - return false; |
|
439 | + if (!$smcFunc['db_num_rows']($request)) { |
|
440 | + return false; |
|
441 | + } |
|
436 | 442 | |
437 | 443 | // Woohoo we found a report and they can see it! |
438 | 444 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -451,8 +457,9 @@ discard block |
||
451 | 457 | { |
452 | 458 | global $smcFunc, $scripturl, $user_info, $txt; |
453 | 459 | |
454 | - if (empty($report_id)) |
|
455 | - return false; |
|
460 | + if (empty($report_id)) { |
|
461 | + return false; |
|
462 | + } |
|
456 | 463 | |
457 | 464 | $report = array( |
458 | 465 | 'comments' => array(), |
@@ -533,8 +540,9 @@ discard block |
||
533 | 540 | { |
534 | 541 | global $smcFunc, $user_info; |
535 | 542 | |
536 | - if (empty($comment_id)) |
|
537 | - return false; |
|
543 | + if (empty($comment_id)) { |
|
544 | + return false; |
|
545 | + } |
|
538 | 546 | |
539 | 547 | $request = $smcFunc['db_query']('', ' |
540 | 548 | SELECT id_comment, id_notice, log_time, body, id_member |
@@ -551,8 +559,9 @@ discard block |
||
551 | 559 | $smcFunc['db_free_result']($request); |
552 | 560 | |
553 | 561 | // Add the permission |
554 | - if (!empty($comment)) |
|
555 | - $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
562 | + if (!empty($comment)) { |
|
563 | + $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
564 | + } |
|
556 | 565 | |
557 | 566 | return $comment; |
558 | 567 | } |
@@ -568,8 +577,9 @@ discard block |
||
568 | 577 | { |
569 | 578 | global $smcFunc, $user_info, $context; |
570 | 579 | |
571 | - if (empty($data)) |
|
572 | - return false; |
|
580 | + if (empty($data)) { |
|
581 | + return false; |
|
582 | + } |
|
573 | 583 | |
574 | 584 | $data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data); |
575 | 585 | |
@@ -598,8 +608,7 @@ discard block |
||
598 | 608 | 'comment_id' => $last_comment, |
599 | 609 | 'time' => time(), |
600 | 610 | ); |
601 | - } |
|
602 | - else |
|
611 | + } else |
|
603 | 612 | { |
604 | 613 | $prefix = 'Msg'; |
605 | 614 | $data = array( |
@@ -615,14 +624,15 @@ discard block |
||
615 | 624 | } |
616 | 625 | |
617 | 626 | // And get ready to notify people. |
618 | - if (!empty($report)) |
|
619 | - $smcFunc['db_insert']('insert', |
|
627 | + if (!empty($report)) { |
|
628 | + $smcFunc['db_insert']('insert', |
|
620 | 629 | '{db_prefix}background_tasks', |
621 | 630 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
622 | 631 | array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', $smcFunc['json_encode']($data), 0), |
623 | 632 | array('id_task') |
624 | 633 | ); |
625 | -} |
|
634 | + } |
|
635 | + } |
|
626 | 636 | |
627 | 637 | /** |
628 | 638 | * Saves the new information whenever a moderator comment is edited. |
@@ -635,8 +645,9 @@ discard block |
||
635 | 645 | { |
636 | 646 | global $smcFunc; |
637 | 647 | |
638 | - if (empty($comment_id) || empty($edited_comment)) |
|
639 | - return false; |
|
648 | + if (empty($comment_id) || empty($edited_comment)) { |
|
649 | + return false; |
|
650 | + } |
|
640 | 651 | |
641 | 652 | $smcFunc['db_query']('', ' |
642 | 653 | UPDATE {db_prefix}log_comments |
@@ -659,8 +670,9 @@ discard block |
||
659 | 670 | { |
660 | 671 | global $smcFunc; |
661 | 672 | |
662 | - if (empty($comment_id)) |
|
663 | - return false; |
|
673 | + if (empty($comment_id)) { |
|
674 | + return false; |
|
675 | + } |
|
664 | 676 | |
665 | 677 | $smcFunc['db_query']('', ' |
666 | 678 | DELETE FROM {db_prefix}log_comments |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param integer $value The new value to update. |
24 | 24 | * @param integer|array $report_id The affected report(s). |
25 | 25 | * |
26 | - * @return bool |
|
26 | + * @return false|null |
|
27 | 27 | */ |
28 | 28 | function updateReport($action, $value, $report_id) |
29 | 29 | { |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @param int $report_id The report ID is used to fire a notification about the event. |
566 | 566 | * @param array $data a formatted array of data to be inserted. Should be already properly sanitized. |
567 | - * @return bool Boolean false if no data was provided. |
|
567 | + * @return false|null Boolean false if no data was provided. |
|
568 | 568 | */ |
569 | 569 | function saveModComment($report_id, $data) |
570 | 570 | { |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | * Deletes a moderator comment from the DB. |
657 | 657 | * |
658 | 658 | * @param int $comment_id The moderator comment ID used to identify which report will be deleted. |
659 | - * @return bool Boolean false if no data was provided. |
|
659 | + * @return false|null Boolean false if no data was provided. |
|
660 | 660 | */ |
661 | 661 | function deleteModComment($comment_id) |
662 | 662 | { |