@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | 'value' => $txt['date'], |
| 137 | 137 | ), |
| 138 | 138 | 'data' => array( |
| 139 | - 'function' => function ($rowData) use ($txt) |
|
| 139 | + 'function' => function($rowData) use ($txt) |
|
| 140 | 140 | { |
| 141 | 141 | // Recurring every year or just a single year? |
| 142 | 142 | $year = $rowData['year'] == '0004' ? sprintf('(%1$s)', $txt['every_year']) : $rowData['year']; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | checkSession(); |
| 219 | 219 | |
| 220 | 220 | // Not too long good sir? |
| 221 | - $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 221 | + $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 222 | 222 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 223 | |
| 224 | 224 | if (isset($_REQUEST['delete'])) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main controlling function doesn't have much to do... yet. |
@@ -43,8 +44,7 @@ discard block |
||
| 43 | 44 | 'settings' => 'ModifyCalendarSettings' |
| 44 | 45 | ); |
| 45 | 46 | $default = 'holidays'; |
| 46 | - } |
|
| 47 | - else |
|
| 47 | + } else |
|
| 48 | 48 | { |
| 49 | 49 | $subActions = array( |
| 50 | 50 | 'settings' => 'ModifyCalendarSettings' |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | 'help' => 'calendar', |
| 61 | 61 | 'description' => $txt['calendar_settings_desc'], |
| 62 | 62 | ); |
| 63 | - if (!empty($modSettings['cal_enabled'])) |
|
| 64 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 63 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 64 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 65 | 65 | 'holidays' => array( |
| 66 | 66 | 'description' => $txt['manage_holidays_desc'], |
| 67 | 67 | ), |
@@ -69,6 +69,7 @@ discard block |
||
| 69 | 69 | 'description' => $txt['calendar_settings_desc'], |
| 70 | 70 | ), |
| 71 | 71 | ); |
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | call_integration_hook('integrate_manage_calendar', array(&$subActions)); |
| 74 | 75 | |
@@ -88,8 +89,9 @@ discard block |
||
| 88 | 89 | checkSession(); |
| 89 | 90 | validateToken('admin-mc'); |
| 90 | 91 | |
| 91 | - foreach ($_REQUEST['holiday'] as $id => $value) |
|
| 92 | - $_REQUEST['holiday'][$id] = (int) $id; |
|
| 92 | + foreach ($_REQUEST['holiday'] as $id => $value) { |
|
| 93 | + $_REQUEST['holiday'][$id] = (int) $id; |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | // Now the IDs are "safe" do the delete... |
| 95 | 97 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -209,8 +211,9 @@ discard block |
||
| 209 | 211 | $context['sub_template'] = 'edit_holiday'; |
| 210 | 212 | |
| 211 | 213 | // Cast this for safety... |
| 212 | - if (isset($_REQUEST['holiday'])) |
|
| 213 | - $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 214 | + if (isset($_REQUEST['holiday'])) { |
|
| 215 | + $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 216 | + } |
|
| 214 | 217 | |
| 215 | 218 | // Submitting? |
| 216 | 219 | if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != '')) |
@@ -221,19 +224,19 @@ discard block |
||
| 221 | 224 | $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
| 222 | 225 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 226 | |
| 224 | - if (isset($_REQUEST['delete'])) |
|
| 225 | - $smcFunc['db_query']('', ' |
|
| 227 | + if (isset($_REQUEST['delete'])) { |
|
| 228 | + $smcFunc['db_query']('', ' |
|
| 226 | 229 | DELETE FROM {db_prefix}calendar_holidays |
| 227 | 230 | WHERE id_holiday = {int:selected_holiday}', |
| 228 | 231 | array( |
| 229 | 232 | 'selected_holiday' => $_REQUEST['holiday'], |
| 230 | 233 | ) |
| 231 | 234 | ); |
| 232 | - else |
|
| 235 | + } else |
|
| 233 | 236 | { |
| 234 | 237 | $date = strftime($_REQUEST['year'] <= 4 ? '0004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year'])); |
| 235 | - if (isset($_REQUEST['edit'])) |
|
| 236 | - $smcFunc['db_query']('', ' |
|
| 238 | + if (isset($_REQUEST['edit'])) { |
|
| 239 | + $smcFunc['db_query']('', ' |
|
| 237 | 240 | UPDATE {db_prefix}calendar_holidays |
| 238 | 241 | SET event_date = {date:holiday_date}, title = {string:holiday_title} |
| 239 | 242 | WHERE id_holiday = {int:selected_holiday}', |
@@ -243,8 +246,8 @@ discard block |
||
| 243 | 246 | 'holiday_title' => $_REQUEST['title'], |
| 244 | 247 | ) |
| 245 | 248 | ); |
| 246 | - else |
|
| 247 | - $smcFunc['db_insert']('', |
|
| 249 | + } else { |
|
| 250 | + $smcFunc['db_insert']('', |
|
| 248 | 251 | '{db_prefix}calendar_holidays', |
| 249 | 252 | array( |
| 250 | 253 | 'event_date' => 'date', 'title' => 'string-60', |
@@ -254,6 +257,7 @@ discard block |
||
| 254 | 257 | ), |
| 255 | 258 | array('id_holiday') |
| 256 | 259 | ); |
| 260 | + } |
|
| 257 | 261 | } |
| 258 | 262 | |
| 259 | 263 | updateSettings(array( |
@@ -265,14 +269,15 @@ discard block |
||
| 265 | 269 | } |
| 266 | 270 | |
| 267 | 271 | // Default states... |
| 268 | - if ($context['is_new']) |
|
| 269 | - $context['holiday'] = array( |
|
| 272 | + if ($context['is_new']) { |
|
| 273 | + $context['holiday'] = array( |
|
| 270 | 274 | 'id' => 0, |
| 271 | 275 | 'day' => date('d'), |
| 272 | 276 | 'month' => date('m'), |
| 273 | 277 | 'year' => '0000', |
| 274 | 278 | 'title' => '' |
| 275 | 279 | ); |
| 280 | + } |
|
| 276 | 281 | // If it's not new load the data. |
| 277 | 282 | else |
| 278 | 283 | { |
@@ -285,14 +290,15 @@ discard block |
||
| 285 | 290 | 'selected_holiday' => $_REQUEST['holiday'], |
| 286 | 291 | ) |
| 287 | 292 | ); |
| 288 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 289 | - $context['holiday'] = array( |
|
| 293 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 294 | + $context['holiday'] = array( |
|
| 290 | 295 | 'id' => $row['id_holiday'], |
| 291 | 296 | 'day' => $row['day'], |
| 292 | 297 | 'month' => $row['month'], |
| 293 | 298 | 'year' => $row['year'] <= 4 ? 0 : $row['year'], |
| 294 | 299 | 'title' => $row['title'] |
| 295 | 300 | ); |
| 301 | + } |
|
| 296 | 302 | $smcFunc['db_free_result']($request); |
| 297 | 303 | } |
| 298 | 304 | |
@@ -319,16 +325,17 @@ discard block |
||
| 319 | 325 | array( |
| 320 | 326 | ) |
| 321 | 327 | ); |
| 322 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 323 | - $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 329 | + $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 330 | + } |
|
| 324 | 331 | $smcFunc['db_free_result']($request); |
| 325 | 332 | |
| 326 | 333 | require_once($sourcedir . '/Subs-Boards.php'); |
| 327 | 334 | sortBoards($boards); |
| 328 | 335 | |
| 329 | 336 | // Look, all the calendar settings - of which there are many! |
| 330 | - if (!empty($modSettings['cal_enabled'])) |
|
| 331 | - $config_vars = array( |
|
| 337 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 338 | + $config_vars = array( |
|
| 332 | 339 | array('check', 'cal_enabled'), |
| 333 | 340 | '', |
| 334 | 341 | // All the permissions: |
@@ -371,14 +378,16 @@ discard block |
||
| 371 | 378 | array('check', 'cal_short_days'), |
| 372 | 379 | array('check', 'cal_short_months'), |
| 373 | 380 | ); |
| 374 | - else |
|
| 375 | - $config_vars = array( |
|
| 381 | + } else { |
|
| 382 | + $config_vars = array( |
|
| 376 | 383 | array('check', 'cal_enabled'), |
| 377 | 384 | ); |
| 385 | + } |
|
| 378 | 386 | |
| 379 | 387 | call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars)); |
| 380 | - if ($return_config) |
|
| 381 | - return $config_vars; |
|
| 388 | + if ($return_config) { |
|
| 389 | + return $config_vars; |
|
| 390 | + } |
|
| 382 | 391 | |
| 383 | 392 | // Get the settings template fired up. |
| 384 | 393 | require_once($sourcedir . '/ManageServer.php'); |
@@ -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 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * 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']); |
@@ -59,8 +59,9 @@ discard block |
||
| 59 | 59 | * @version 2.1 Beta 3 |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | -if (!defined('SMF')) |
|
| 62 | +if (!defined('SMF')) { |
|
| 63 | 63 | die('No direct access...'); |
| 64 | +} |
|
| 64 | 65 | |
| 65 | 66 | /** |
| 66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
| 111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
| 112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
| 113 | 114 | |
| 114 | - if ($settings_not_writable) |
|
| 115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 116 | - elseif ($settings_backup_fail) |
|
| 117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 115 | + if ($settings_not_writable) { |
|
| 116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 117 | + } elseif ($settings_backup_fail) { |
|
| 118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
| 120 | 122 | |
@@ -166,8 +168,9 @@ discard block |
||
| 166 | 168 | |
| 167 | 169 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
| 168 | 170 | |
| 169 | - if ($return_config) |
|
| 170 | - return $config_vars; |
|
| 171 | + if ($return_config) { |
|
| 172 | + return $config_vars; |
|
| 173 | + } |
|
| 171 | 174 | |
| 172 | 175 | // Setup the template stuff. |
| 173 | 176 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -232,8 +235,9 @@ discard block |
||
| 232 | 235 | |
| 233 | 236 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
| 234 | 237 | |
| 235 | - if ($return_config) |
|
| 236 | - return $config_vars; |
|
| 238 | + if ($return_config) { |
|
| 239 | + return $config_vars; |
|
| 240 | + } |
|
| 237 | 241 | |
| 238 | 242 | // Setup the template stuff. |
| 239 | 243 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -308,13 +312,15 @@ discard block |
||
| 308 | 312 | hideGlobalCookies(); |
| 309 | 313 | });', true); |
| 310 | 314 | |
| 311 | - if (empty($user_settings['tfa_secret'])) |
|
| 312 | - addInlineJavaScript(''); |
|
| 315 | + if (empty($user_settings['tfa_secret'])) { |
|
| 316 | + addInlineJavaScript(''); |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
| 315 | 320 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 321 | + if ($return_config) { |
|
| 322 | + return $config_vars; |
|
| 323 | + } |
|
| 318 | 324 | |
| 319 | 325 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
| 320 | 326 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -325,11 +331,13 @@ discard block |
||
| 325 | 331 | call_integration_hook('integrate_save_cookie_settings'); |
| 326 | 332 | |
| 327 | 333 | // Local and global do not play nicely together. |
| 328 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
| 329 | - unset ($_POST['globalCookies']); |
|
| 334 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
| 335 | + unset ($_POST['globalCookies']); |
|
| 336 | + } |
|
| 330 | 337 | |
| 331 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
| 332 | - fatal_lang_error('invalid_cookie_domain', false); |
|
| 338 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
| 339 | + fatal_lang_error('invalid_cookie_domain', false); |
|
| 340 | + } |
|
| 333 | 341 | |
| 334 | 342 | saveSettings($config_vars); |
| 335 | 343 | |
@@ -412,8 +420,9 @@ discard block |
||
| 412 | 420 | |
| 413 | 421 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
| 414 | 422 | |
| 415 | - if ($return_config) |
|
| 416 | - return $config_vars; |
|
| 423 | + if ($return_config) { |
|
| 424 | + return $config_vars; |
|
| 425 | + } |
|
| 417 | 426 | |
| 418 | 427 | // Saving? |
| 419 | 428 | if (isset($_GET['save'])) |
@@ -452,8 +461,7 @@ discard block |
||
| 452 | 461 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
| 453 | 462 | $cache_level = array($txt['cache_off']); |
| 454 | 463 | $detected['none'] = $txt['cache_off']; |
| 455 | - } |
|
| 456 | - else |
|
| 464 | + } else |
|
| 457 | 465 | { |
| 458 | 466 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
| 459 | 467 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -490,8 +498,9 @@ discard block |
||
| 490 | 498 | } |
| 491 | 499 | } |
| 492 | 500 | } |
| 493 | - if ($return_config) |
|
| 494 | - return $config_vars; |
|
| 501 | + if ($return_config) { |
|
| 502 | + return $config_vars; |
|
| 503 | + } |
|
| 495 | 504 | |
| 496 | 505 | // Saving again? |
| 497 | 506 | if (isset($_GET['save'])) |
@@ -519,8 +528,9 @@ discard block |
||
| 519 | 528 | $context['save_disabled'] = $context['settings_not_writable']; |
| 520 | 529 | |
| 521 | 530 | // Decide what message to show. |
| 522 | - if (!$context['save_disabled']) |
|
| 523 | - $context['settings_message'] = $txt['caching_information']; |
|
| 531 | + if (!$context['save_disabled']) { |
|
| 532 | + $context['settings_message'] = $txt['caching_information']; |
|
| 533 | + } |
|
| 524 | 534 | |
| 525 | 535 | // Prepare the template. |
| 526 | 536 | prepareServerSettingsContext($config_vars); |
@@ -543,24 +553,25 @@ discard block |
||
| 543 | 553 | if (stripos(PHP_OS, 'win') === 0) |
| 544 | 554 | { |
| 545 | 555 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
| 546 | - if (isset($_GET['save'])) |
|
| 547 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 548 | - } |
|
| 549 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 556 | + if (isset($_GET['save'])) { |
|
| 557 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
| 558 | + } |
|
| 559 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
| 550 | 560 | { |
| 551 | 561 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
| 552 | - if (isset($_GET['save'])) |
|
| 553 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 554 | - } |
|
| 555 | - else |
|
| 562 | + if (isset($_GET['save'])) { |
|
| 563 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
| 564 | + } |
|
| 565 | + } else |
|
| 556 | 566 | { |
| 557 | 567 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 558 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
| 559 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 560 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
| 561 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 562 | - else |
|
| 563 | - unset($modSettings['load_average']); |
|
| 568 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
| 569 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 570 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
| 571 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 572 | + } else { |
|
| 573 | + unset($modSettings['load_average']); |
|
| 574 | + } |
|
| 564 | 575 | |
| 565 | 576 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
| 566 | 577 | { |
@@ -596,8 +607,9 @@ discard block |
||
| 596 | 607 | |
| 597 | 608 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
| 598 | 609 | |
| 599 | - if ($return_config) |
|
| 600 | - return $config_vars; |
|
| 610 | + if ($return_config) { |
|
| 611 | + return $config_vars; |
|
| 612 | + } |
|
| 601 | 613 | |
| 602 | 614 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
| 603 | 615 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -608,24 +620,27 @@ discard block |
||
| 608 | 620 | // Stupidity is not allowed. |
| 609 | 621 | foreach ($_POST as $key => $value) |
| 610 | 622 | { |
| 611 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
| 612 | - continue; |
|
| 613 | - else |
|
| 614 | - $_POST[$key] = (float) $value; |
|
| 615 | - |
|
| 616 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
| 617 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
| 618 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
| 619 | - $_POST['loadavg_forum'] = 10.0; |
|
| 620 | - elseif ($value < 2) |
|
| 621 | - $_POST[$key] = 2.0; |
|
| 623 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
| 624 | + continue; |
|
| 625 | + } else { |
|
| 626 | + $_POST[$key] = (float) $value; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
| 630 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
| 631 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
| 632 | + $_POST['loadavg_forum'] = 10.0; |
|
| 633 | + } elseif ($value < 2) { |
|
| 634 | + $_POST[$key] = 2.0; |
|
| 635 | + } |
|
| 622 | 636 | } |
| 623 | 637 | |
| 624 | 638 | call_integration_hook('integrate_save_loadavg_settings'); |
| 625 | 639 | |
| 626 | 640 | saveDBSettings($config_vars); |
| 627 | - if (!isset($_SESSION['adm-save'])) |
|
| 628 | - $_SESSION['adm-save'] = true; |
|
| 641 | + if (!isset($_SESSION['adm-save'])) { |
|
| 642 | + $_SESSION['adm-save'] = true; |
|
| 643 | + } |
|
| 629 | 644 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
| 630 | 645 | } |
| 631 | 646 | |
@@ -661,10 +676,11 @@ discard block |
||
| 661 | 676 | |
| 662 | 677 | if (isset($_SESSION['adm-save'])) |
| 663 | 678 | { |
| 664 | - if ($_SESSION['adm-save'] === true) |
|
| 665 | - $context['saved_successful'] = true; |
|
| 666 | - else |
|
| 667 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 679 | + if ($_SESSION['adm-save'] === true) { |
|
| 680 | + $context['saved_successful'] = true; |
|
| 681 | + } else { |
|
| 682 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 683 | + } |
|
| 668 | 684 | |
| 669 | 685 | unset($_SESSION['adm-save']); |
| 670 | 686 | } |
@@ -672,9 +688,9 @@ discard block |
||
| 672 | 688 | $context['config_vars'] = array(); |
| 673 | 689 | foreach ($config_vars as $identifier => $config_var) |
| 674 | 690 | { |
| 675 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
| 676 | - $context['config_vars'][] = $config_var; |
|
| 677 | - else |
|
| 691 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
| 692 | + $context['config_vars'][] = $config_var; |
|
| 693 | + } else |
|
| 678 | 694 | { |
| 679 | 695 | $varname = $config_var[0]; |
| 680 | 696 | global $$varname; |
@@ -709,16 +725,19 @@ discard block |
||
| 709 | 725 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
| 710 | 726 | { |
| 711 | 727 | // Default to a min of 0 if one isn't set |
| 712 | - if (isset($config_var['min'])) |
|
| 713 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 714 | - else |
|
| 715 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 728 | + if (isset($config_var['min'])) { |
|
| 729 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
| 730 | + } else { |
|
| 731 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
| 732 | + } |
|
| 716 | 733 | |
| 717 | - if (isset($config_var['max'])) |
|
| 718 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 734 | + if (isset($config_var['max'])) { |
|
| 735 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
| 736 | + } |
|
| 719 | 737 | |
| 720 | - if (isset($config_var['step'])) |
|
| 721 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 738 | + if (isset($config_var['step'])) { |
|
| 739 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
| 740 | + } |
|
| 722 | 741 | } |
| 723 | 742 | |
| 724 | 743 | // If this is a select box handle any data. |
@@ -726,12 +745,13 @@ discard block |
||
| 726 | 745 | { |
| 727 | 746 | // If it's associative |
| 728 | 747 | $config_values = array_values($config_var[4]); |
| 729 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
| 730 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 731 | - else |
|
| 748 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
| 749 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
| 750 | + } else |
|
| 732 | 751 | { |
| 733 | - foreach ($config_var[4] as $key => $item) |
|
| 734 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 752 | + foreach ($config_var[4] as $key => $item) { |
|
| 753 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
| 754 | + } |
|
| 735 | 755 | } |
| 736 | 756 | } |
| 737 | 757 | } |
@@ -756,10 +776,11 @@ discard block |
||
| 756 | 776 | |
| 757 | 777 | if (isset($_SESSION['adm-save'])) |
| 758 | 778 | { |
| 759 | - if ($_SESSION['adm-save'] === true) |
|
| 760 | - $context['saved_successful'] = true; |
|
| 761 | - else |
|
| 762 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 779 | + if ($_SESSION['adm-save'] === true) { |
|
| 780 | + $context['saved_successful'] = true; |
|
| 781 | + } else { |
|
| 782 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
| 783 | + } |
|
| 763 | 784 | |
| 764 | 785 | unset($_SESSION['adm-save']); |
| 765 | 786 | } |
@@ -771,26 +792,30 @@ discard block |
||
| 771 | 792 | foreach ($config_vars as $config_var) |
| 772 | 793 | { |
| 773 | 794 | // HR? |
| 774 | - if (!is_array($config_var)) |
|
| 775 | - $context['config_vars'][] = $config_var; |
|
| 776 | - else |
|
| 795 | + if (!is_array($config_var)) { |
|
| 796 | + $context['config_vars'][] = $config_var; |
|
| 797 | + } else |
|
| 777 | 798 | { |
| 778 | 799 | // If it has no name it doesn't have any purpose! |
| 779 | - if (empty($config_var[1])) |
|
| 780 | - continue; |
|
| 800 | + if (empty($config_var[1])) { |
|
| 801 | + continue; |
|
| 802 | + } |
|
| 781 | 803 | |
| 782 | 804 | // Special case for inline permissions |
| 783 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
| 784 | - $inlinePermissions[] = $config_var[1]; |
|
| 785 | - elseif ($config_var[0] == 'permissions') |
|
| 786 | - continue; |
|
| 805 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
| 806 | + $inlinePermissions[] = $config_var[1]; |
|
| 807 | + } elseif ($config_var[0] == 'permissions') { |
|
| 808 | + continue; |
|
| 809 | + } |
|
| 787 | 810 | |
| 788 | - if ($config_var[0] == 'boards') |
|
| 789 | - $board_list = true; |
|
| 811 | + if ($config_var[0] == 'boards') { |
|
| 812 | + $board_list = true; |
|
| 813 | + } |
|
| 790 | 814 | |
| 791 | 815 | // Are we showing the BBC selection box? |
| 792 | - if ($config_var[0] == 'bbc') |
|
| 793 | - $bbcChoice[] = $config_var[1]; |
|
| 816 | + if ($config_var[0] == 'bbc') { |
|
| 817 | + $bbcChoice[] = $config_var[1]; |
|
| 818 | + } |
|
| 794 | 819 | |
| 795 | 820 | // We need to do some parsing of the value before we pass it in. |
| 796 | 821 | if (isset($modSettings[$config_var[1]])) |
@@ -809,8 +834,7 @@ discard block |
||
| 809 | 834 | default: |
| 810 | 835 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
| 811 | 836 | } |
| 812 | - } |
|
| 813 | - else |
|
| 837 | + } else |
|
| 814 | 838 | { |
| 815 | 839 | // Darn, it's empty. What type is expected? |
| 816 | 840 | switch ($config_var[0]) |
@@ -850,16 +874,19 @@ discard block |
||
| 850 | 874 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
| 851 | 875 | { |
| 852 | 876 | // Default to a min of 0 if one isn't set |
| 853 | - if (isset($config_var['min'])) |
|
| 854 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 855 | - else |
|
| 856 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 877 | + if (isset($config_var['min'])) { |
|
| 878 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
| 879 | + } else { |
|
| 880 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
| 881 | + } |
|
| 857 | 882 | |
| 858 | - if (isset($config_var['max'])) |
|
| 859 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 883 | + if (isset($config_var['max'])) { |
|
| 884 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
| 885 | + } |
|
| 860 | 886 | |
| 861 | - if (isset($config_var['step'])) |
|
| 862 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 887 | + if (isset($config_var['step'])) { |
|
| 888 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
| 889 | + } |
|
| 863 | 890 | } |
| 864 | 891 | |
| 865 | 892 | // If this is a select box handle any data. |
@@ -873,12 +900,13 @@ discard block |
||
| 873 | 900 | } |
| 874 | 901 | |
| 875 | 902 | // If it's associative |
| 876 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
| 877 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 878 | - else |
|
| 903 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
| 904 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
| 905 | + } else |
|
| 879 | 906 | { |
| 880 | - foreach ($config_var[2] as $key => $item) |
|
| 881 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 907 | + foreach ($config_var[2] as $key => $item) { |
|
| 908 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
| 909 | + } |
|
| 882 | 910 | } |
| 883 | 911 | } |
| 884 | 912 | |
@@ -887,17 +915,19 @@ discard block |
||
| 887 | 915 | { |
| 888 | 916 | if (!is_numeric($k)) |
| 889 | 917 | { |
| 890 | - if (substr($k, 0, 2) == 'on') |
|
| 891 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 892 | - else |
|
| 893 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 918 | + if (substr($k, 0, 2) == 'on') { |
|
| 919 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
| 920 | + } else { |
|
| 921 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
| 922 | + } |
|
| 894 | 923 | } |
| 895 | 924 | |
| 896 | 925 | // See if there are any other labels that might fit? |
| 897 | - if (isset($txt['setting_' . $config_var[1]])) |
|
| 898 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 899 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
| 900 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 926 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
| 927 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
| 928 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
| 929 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
| 930 | + } |
|
| 901 | 931 | } |
| 902 | 932 | |
| 903 | 933 | // Set the subtext in case it's part of the label. |
@@ -930,8 +960,9 @@ discard block |
||
| 930 | 960 | // What are the options, eh? |
| 931 | 961 | $temp = parse_bbc(false); |
| 932 | 962 | $bbcTags = array(); |
| 933 | - foreach ($temp as $tag) |
|
| 934 | - $bbcTags[] = $tag['tag']; |
|
| 963 | + foreach ($temp as $tag) { |
|
| 964 | + $bbcTags[] = $tag['tag']; |
|
| 965 | + } |
|
| 935 | 966 | |
| 936 | 967 | $bbcTags = array_unique($bbcTags); |
| 937 | 968 | $totalTags = count($bbcTags); |
@@ -946,8 +977,9 @@ discard block |
||
| 946 | 977 | $col = 0; $i = 0; |
| 947 | 978 | foreach ($bbcTags as $tag) |
| 948 | 979 | { |
| 949 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
| 950 | - $col++; |
|
| 980 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
| 981 | + $col++; |
|
| 982 | + } |
|
| 951 | 983 | |
| 952 | 984 | $context['bbc_columns'][$col][] = array( |
| 953 | 985 | 'tag' => $tag, |
@@ -990,18 +1022,21 @@ discard block |
||
| 990 | 1022 | validateToken('admin-ssc'); |
| 991 | 1023 | |
| 992 | 1024 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
| 993 | - if (isset($_POST['cookiename'])) |
|
| 994 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1025 | + if (isset($_POST['cookiename'])) { |
|
| 1026 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
| 1027 | + } |
|
| 995 | 1028 | |
| 996 | 1029 | // Fix the forum's URL if necessary. |
| 997 | 1030 | if (isset($_POST['boardurl'])) |
| 998 | 1031 | { |
| 999 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 1000 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1001 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 1002 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1003 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 1004 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1032 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1033 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1034 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1035 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1036 | + } |
|
| 1037 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1038 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1039 | + } |
|
| 1005 | 1040 | } |
| 1006 | 1041 | |
| 1007 | 1042 | // Any passwords? |
@@ -1036,21 +1071,21 @@ discard block |
||
| 1036 | 1071 | // Figure out which config vars we're saving here... |
| 1037 | 1072 | foreach ($config_vars as $var) |
| 1038 | 1073 | { |
| 1039 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
| 1040 | - continue; |
|
| 1074 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
| 1075 | + continue; |
|
| 1076 | + } |
|
| 1041 | 1077 | |
| 1042 | 1078 | $config_var = $var[0]; |
| 1043 | 1079 | |
| 1044 | 1080 | if (in_array($config_var, $config_passwords)) |
| 1045 | 1081 | { |
| 1046 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
| 1047 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1048 | - } |
|
| 1049 | - elseif (in_array($config_var, $config_strs)) |
|
| 1082 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
| 1083 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
| 1084 | + } |
|
| 1085 | + } elseif (in_array($config_var, $config_strs)) |
|
| 1050 | 1086 | { |
| 1051 | 1087 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
| 1052 | - } |
|
| 1053 | - elseif (in_array($config_var, $config_ints)) |
|
| 1088 | + } elseif (in_array($config_var, $config_ints)) |
|
| 1054 | 1089 | { |
| 1055 | 1090 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
| 1056 | 1091 | |
@@ -1059,17 +1094,17 @@ discard block |
||
| 1059 | 1094 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
| 1060 | 1095 | |
| 1061 | 1096 | // Is there a max value for this as well? |
| 1062 | - if (isset($var['max'])) |
|
| 1063 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1064 | - } |
|
| 1065 | - elseif (in_array($config_var, $config_bools)) |
|
| 1097 | + if (isset($var['max'])) { |
|
| 1098 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
| 1099 | + } |
|
| 1100 | + } elseif (in_array($config_var, $config_bools)) |
|
| 1066 | 1101 | { |
| 1067 | - if (!empty($_POST[$config_var])) |
|
| 1068 | - $new_settings[$config_var] = '1'; |
|
| 1069 | - else |
|
| 1070 | - $new_settings[$config_var] = '0'; |
|
| 1071 | - } |
|
| 1072 | - else |
|
| 1102 | + if (!empty($_POST[$config_var])) { |
|
| 1103 | + $new_settings[$config_var] = '1'; |
|
| 1104 | + } else { |
|
| 1105 | + $new_settings[$config_var] = '0'; |
|
| 1106 | + } |
|
| 1107 | + } else |
|
| 1073 | 1108 | { |
| 1074 | 1109 | // This shouldn't happen, but it might... |
| 1075 | 1110 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1085,30 +1120,35 @@ discard block |
||
| 1085 | 1120 | foreach ($config_vars as $config_var) |
| 1086 | 1121 | { |
| 1087 | 1122 | // We just saved the file-based settings, so skip their definitions. |
| 1088 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
| 1089 | - continue; |
|
| 1123 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
| 1124 | + continue; |
|
| 1125 | + } |
|
| 1090 | 1126 | |
| 1091 | 1127 | $new_setting = array($config_var[3], $config_var[0]); |
| 1092 | 1128 | |
| 1093 | 1129 | // Select options need carried over, too. |
| 1094 | - if (isset($config_var[4])) |
|
| 1095 | - $new_setting[] = $config_var[4]; |
|
| 1130 | + if (isset($config_var[4])) { |
|
| 1131 | + $new_setting[] = $config_var[4]; |
|
| 1132 | + } |
|
| 1096 | 1133 | |
| 1097 | 1134 | // Include min and max if necessary |
| 1098 | - if (isset($config_var['min'])) |
|
| 1099 | - $new_setting['min'] = $config_var['min']; |
|
| 1135 | + if (isset($config_var['min'])) { |
|
| 1136 | + $new_setting['min'] = $config_var['min']; |
|
| 1137 | + } |
|
| 1100 | 1138 | |
| 1101 | - if (isset($config_var['max'])) |
|
| 1102 | - $new_setting['max'] = $config_var['max']; |
|
| 1139 | + if (isset($config_var['max'])) { |
|
| 1140 | + $new_setting['max'] = $config_var['max']; |
|
| 1141 | + } |
|
| 1103 | 1142 | |
| 1104 | 1143 | // Rewrite the definition a bit. |
| 1105 | 1144 | $new_settings[] = $new_setting; |
| 1106 | 1145 | } |
| 1107 | 1146 | |
| 1108 | 1147 | // Save the new database-based settings, if any. |
| 1109 | - if (!empty($new_settings)) |
|
| 1110 | - saveDBSettings($new_settings); |
|
| 1111 | -} |
|
| 1148 | + if (!empty($new_settings)) { |
|
| 1149 | + saveDBSettings($new_settings); |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1112 | 1152 | |
| 1113 | 1153 | /** |
| 1114 | 1154 | * Helper function for saving database settings. |
@@ -1126,22 +1166,25 @@ discard block |
||
| 1126 | 1166 | $inlinePermissions = array(); |
| 1127 | 1167 | foreach ($config_vars as $var) |
| 1128 | 1168 | { |
| 1129 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
| 1130 | - continue; |
|
| 1169 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
| 1170 | + continue; |
|
| 1171 | + } |
|
| 1131 | 1172 | |
| 1132 | 1173 | // Checkboxes! |
| 1133 | - elseif ($var[0] == 'check') |
|
| 1134 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1174 | + elseif ($var[0] == 'check') { |
|
| 1175 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
| 1176 | + } |
|
| 1135 | 1177 | // Select boxes! |
| 1136 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
| 1137 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1138 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1178 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
| 1179 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1180 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
| 1139 | 1181 | { |
| 1140 | 1182 | // For security purposes we validate this line by line. |
| 1141 | 1183 | $lOptions = array(); |
| 1142 | - foreach ($_POST[$var[1]] as $invar) |
|
| 1143 | - if (in_array($invar, array_keys($var[2]))) |
|
| 1184 | + foreach ($_POST[$var[1]] as $invar) { |
|
| 1185 | + if (in_array($invar, array_keys($var[2]))) |
|
| 1144 | 1186 | $lOptions[] = $invar; |
| 1187 | + } |
|
| 1145 | 1188 | |
| 1146 | 1189 | $setArray[$var[1]] = json_encode($lOptions); |
| 1147 | 1190 | } |
@@ -1155,18 +1198,20 @@ discard block |
||
| 1155 | 1198 | $request = $smcFunc['db_query']('', ' |
| 1156 | 1199 | SELECT id_board |
| 1157 | 1200 | FROM {db_prefix}boards'); |
| 1158 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1159 | - $board_list[$row[0]] = true; |
|
| 1201 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1202 | + $board_list[$row[0]] = true; |
|
| 1203 | + } |
|
| 1160 | 1204 | |
| 1161 | 1205 | $smcFunc['db_free_result']($request); |
| 1162 | 1206 | } |
| 1163 | 1207 | |
| 1164 | 1208 | $lOptions = array(); |
| 1165 | 1209 | |
| 1166 | - if (!empty($_POST[$var[1]])) |
|
| 1167 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1210 | + if (!empty($_POST[$var[1]])) { |
|
| 1211 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
| 1168 | 1212 | if (isset($board_list[$invar])) |
| 1169 | 1213 | $lOptions[] = $invar; |
| 1214 | + } |
|
| 1170 | 1215 | |
| 1171 | 1216 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
| 1172 | 1217 | } |
@@ -1180,8 +1225,9 @@ discard block |
||
| 1180 | 1225 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1181 | 1226 | |
| 1182 | 1227 | // Do we have a max value for this as well? |
| 1183 | - if (isset($var['max'])) |
|
| 1184 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1228 | + if (isset($var['max'])) { |
|
| 1229 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1230 | + } |
|
| 1185 | 1231 | } |
| 1186 | 1232 | // Floating point! |
| 1187 | 1233 | elseif ($var[0] == 'float') |
@@ -1193,40 +1239,47 @@ discard block |
||
| 1193 | 1239 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
| 1194 | 1240 | |
| 1195 | 1241 | // Do we have a max value for this as well? |
| 1196 | - if (isset($var['max'])) |
|
| 1197 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1242 | + if (isset($var['max'])) { |
|
| 1243 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
| 1244 | + } |
|
| 1198 | 1245 | } |
| 1199 | 1246 | // Text! |
| 1200 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
| 1201 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1247 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
| 1248 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
| 1249 | + } |
|
| 1202 | 1250 | // Passwords! |
| 1203 | 1251 | elseif ($var[0] == 'password') |
| 1204 | 1252 | { |
| 1205 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
| 1206 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1253 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
| 1254 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
| 1255 | + } |
|
| 1207 | 1256 | } |
| 1208 | 1257 | // BBC. |
| 1209 | 1258 | elseif ($var[0] == 'bbc') |
| 1210 | 1259 | { |
| 1211 | 1260 | |
| 1212 | 1261 | $bbcTags = array(); |
| 1213 | - foreach (parse_bbc(false) as $tag) |
|
| 1214 | - $bbcTags[] = $tag['tag']; |
|
| 1262 | + foreach (parse_bbc(false) as $tag) { |
|
| 1263 | + $bbcTags[] = $tag['tag']; |
|
| 1264 | + } |
|
| 1215 | 1265 | |
| 1216 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
| 1217 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1218 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
| 1219 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1266 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
| 1267 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
| 1268 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
| 1269 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
| 1270 | + } |
|
| 1220 | 1271 | |
| 1221 | 1272 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
| 1222 | 1273 | } |
| 1223 | 1274 | // Permissions? |
| 1224 | - elseif ($var[0] == 'permissions') |
|
| 1225 | - $inlinePermissions[] = $var[1]; |
|
| 1275 | + elseif ($var[0] == 'permissions') { |
|
| 1276 | + $inlinePermissions[] = $var[1]; |
|
| 1277 | + } |
|
| 1226 | 1278 | } |
| 1227 | 1279 | |
| 1228 | - if (!empty($setArray)) |
|
| 1229 | - updateSettings($setArray); |
|
| 1280 | + if (!empty($setArray)) { |
|
| 1281 | + updateSettings($setArray); |
|
| 1282 | + } |
|
| 1230 | 1283 | |
| 1231 | 1284 | // If we have inline permissions we need to save them. |
| 1232 | 1285 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1264,18 +1317,21 @@ discard block |
||
| 1264 | 1317 | // put all of it into an array |
| 1265 | 1318 | foreach ($info_lines as $line) |
| 1266 | 1319 | { |
| 1267 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
| 1268 | - continue; |
|
| 1320 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
| 1321 | + continue; |
|
| 1322 | + } |
|
| 1269 | 1323 | |
| 1270 | 1324 | // new category? |
| 1271 | - if (strpos($line, '<h2>') !== false) |
|
| 1272 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1325 | + if (strpos($line, '<h2>') !== false) { |
|
| 1326 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
| 1327 | + } |
|
| 1273 | 1328 | |
| 1274 | 1329 | // load it as setting => value or the old setting local master |
| 1275 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1276 | - $pinfo[$category][$val[1]] = $val[2]; |
|
| 1277 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
| 1278 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1330 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1331 | + $pinfo[$category][$val[1]] = $val[2]; |
|
| 1332 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
| 1333 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
| 1334 | + } |
|
| 1279 | 1335 | } |
| 1280 | 1336 | |
| 1281 | 1337 | // load it in to context and display it |
@@ -1310,8 +1366,9 @@ discard block |
||
| 1310 | 1366 | $testAPI = new $cache_class_name(); |
| 1311 | 1367 | |
| 1312 | 1368 | // No Support? NEXT! |
| 1313 | - if (!$testAPI->isSupported(true)) |
|
| 1314 | - continue; |
|
| 1369 | + if (!$testAPI->isSupported(true)) { |
|
| 1370 | + continue; |
|
| 1371 | + } |
|
| 1315 | 1372 | |
| 1316 | 1373 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
| 1317 | 1374 | } |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | * @version 2.1 Beta 3 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if (!defined('SMF')) |
|
| 15 | +if (!defined('SMF')) { |
|
| 16 | 16 | die('No direct access...'); |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Create a new list |
@@ -41,21 +42,21 @@ discard block |
||
| 41 | 42 | { |
| 42 | 43 | $list_context['sort'] = array(); |
| 43 | 44 | $sort = '1=1'; |
| 44 | - } |
|
| 45 | - else |
|
| 45 | + } else |
|
| 46 | 46 | { |
| 47 | 47 | $request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort'; |
| 48 | 48 | $request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc'; |
| 49 | - if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) |
|
| 50 | - $list_context['sort'] = array( |
|
| 49 | + if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) { |
|
| 50 | + $list_context['sort'] = array( |
|
| 51 | 51 | 'id' => $_REQUEST[$request_var_sort], |
| 52 | 52 | 'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']), |
| 53 | 53 | ); |
| 54 | - else |
|
| 55 | - $list_context['sort'] = array( |
|
| 54 | + } else { |
|
| 55 | + $list_context['sort'] = array( |
|
| 56 | 56 | 'id' => $listOptions['default_sort_col'], |
| 57 | 57 | 'desc' => (!empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc') || (!empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc') ? true : false, |
| 58 | 58 | ); |
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | // Set the database column sort. |
| 61 | 62 | $sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default']; |
@@ -72,8 +73,9 @@ discard block |
||
| 72 | 73 | else |
| 73 | 74 | { |
| 74 | 75 | // First get an impression of how many items to expect. |
| 75 | - if (isset($listOptions['get_count']['file'])) |
|
| 76 | - require_once($listOptions['get_count']['file']); |
|
| 76 | + if (isset($listOptions['get_count']['file'])) { |
|
| 77 | + require_once($listOptions['get_count']['file']); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $call = call_helper($listOptions['get_count']['function'], true); |
| 79 | 81 | $list_context['total_num_items'] = call_user_func_array($call, empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']); |
@@ -83,14 +85,15 @@ discard block |
||
| 83 | 85 | $list_context['items_per_page'] = $listOptions['items_per_page']; |
| 84 | 86 | |
| 85 | 87 | // Then create a page index. |
| 86 | - if ($list_context['total_num_items'] > $list_context['items_per_page']) |
|
| 87 | - $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 88 | + if ($list_context['total_num_items'] > $list_context['items_per_page']) { |
|
| 89 | + $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); |
|
| 90 | + } |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | // Prepare the headers of the table. |
| 91 | 94 | $list_context['headers'] = array(); |
| 92 | - foreach ($listOptions['columns'] as $column_id => $column) |
|
| 93 | - $list_context['headers'][] = array( |
|
| 95 | + foreach ($listOptions['columns'] as $column_id => $column) { |
|
| 96 | + $list_context['headers'][] = array( |
|
| 94 | 97 | 'id' => $column_id, |
| 95 | 98 | 'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''), |
| 96 | 99 | 'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']), |
@@ -99,14 +102,16 @@ discard block |
||
| 99 | 102 | 'style' => isset($column['header']['style']) ? $column['header']['style'] : '', |
| 100 | 103 | 'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '', |
| 101 | 104 | ); |
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | // We know the amount of columns, might be useful for the template. |
| 104 | 108 | $list_context['num_columns'] = count($listOptions['columns']); |
| 105 | 109 | $list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0'; |
| 106 | 110 | |
| 107 | 111 | // Get the file with the function for the item list. |
| 108 | - if (isset($listOptions['get_items']['file'])) |
|
| 109 | - require_once($listOptions['get_items']['file']); |
|
| 112 | + if (isset($listOptions['get_items']['file'])) { |
|
| 113 | + require_once($listOptions['get_items']['file']); |
|
| 114 | + } |
|
| 110 | 115 | |
| 111 | 116 | // Call the function and include which items we want and in what order. |
| 112 | 117 | $call = call_helper($listOptions['get_items']['function'], true); |
@@ -123,51 +128,61 @@ discard block |
||
| 123 | 128 | $cur_data = array(); |
| 124 | 129 | |
| 125 | 130 | // A value straight from the database? |
| 126 | - if (isset($column['data']['db'])) |
|
| 127 | - $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 131 | + if (isset($column['data']['db'])) { |
|
| 132 | + $cur_data['value'] = $list_item[$column['data']['db']]; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Take the value from the database and make it HTML safe. |
| 130 | - elseif (isset($column['data']['db_htmlsafe'])) |
|
| 131 | - $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 136 | + elseif (isset($column['data']['db_htmlsafe'])) { |
|
| 137 | + $cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]); |
|
| 138 | + } |
|
| 132 | 139 | |
| 133 | 140 | // Using sprintf is probably the most readable way of injecting data. |
| 134 | 141 | elseif (isset($column['data']['sprintf'])) |
| 135 | 142 | { |
| 136 | 143 | $params = array(); |
| 137 | - foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) |
|
| 138 | - $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 144 | + foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) { |
|
| 145 | + $params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param]; |
|
| 146 | + } |
|
| 139 | 147 | $cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params); |
| 140 | 148 | } |
| 141 | 149 | |
| 142 | 150 | // The most flexible way probably is applying a custom function. |
| 143 | - elseif (isset($column['data']['function'])) |
|
| 144 | - $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 151 | + elseif (isset($column['data']['function'])) { |
|
| 152 | + $cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item)); |
|
| 153 | + } |
|
| 145 | 154 | |
| 146 | 155 | // A modified value (inject the database values). |
| 147 | - elseif (isset($column['data']['eval'])) |
|
| 148 | - $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 156 | + elseif (isset($column['data']['eval'])) { |
|
| 157 | + $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); |
|
| 158 | + } |
|
| 149 | 159 | |
| 150 | 160 | // A literal value. |
| 151 | - elseif (isset($column['data']['value'])) |
|
| 152 | - $cur_data['value'] = $column['data']['value']; |
|
| 161 | + elseif (isset($column['data']['value'])) { |
|
| 162 | + $cur_data['value'] = $column['data']['value']; |
|
| 163 | + } |
|
| 153 | 164 | |
| 154 | 165 | // Empty value. |
| 155 | - else |
|
| 156 | - $cur_data['value'] = ''; |
|
| 166 | + else { |
|
| 167 | + $cur_data['value'] = ''; |
|
| 168 | + } |
|
| 157 | 169 | |
| 158 | 170 | // Allow for basic formatting. |
| 159 | - if (!empty($column['data']['comma_format'])) |
|
| 160 | - $cur_data['value'] = comma_format($cur_data['value']); |
|
| 161 | - elseif (!empty($column['data']['timeformat'])) |
|
| 162 | - $cur_data['value'] = timeformat($cur_data['value']); |
|
| 171 | + if (!empty($column['data']['comma_format'])) { |
|
| 172 | + $cur_data['value'] = comma_format($cur_data['value']); |
|
| 173 | + } elseif (!empty($column['data']['timeformat'])) { |
|
| 174 | + $cur_data['value'] = timeformat($cur_data['value']); |
|
| 175 | + } |
|
| 163 | 176 | |
| 164 | 177 | // Set a style class for this column? |
| 165 | - if (isset($column['data']['class'])) |
|
| 166 | - $cur_data['class'] = $column['data']['class']; |
|
| 178 | + if (isset($column['data']['class'])) { |
|
| 179 | + $cur_data['class'] = $column['data']['class']; |
|
| 180 | + } |
|
| 167 | 181 | |
| 168 | 182 | // Fully customized styling for the cells in this column only. |
| 169 | - if (isset($column['data']['style'])) |
|
| 170 | - $cur_data['style'] = $column['data']['style']; |
|
| 183 | + if (isset($column['data']['style'])) { |
|
| 184 | + $cur_data['style'] = $column['data']['style']; |
|
| 185 | + } |
|
| 171 | 186 | |
| 172 | 187 | // Add the data cell properties to the current row. |
| 173 | 188 | $cur_row[$column_id] = $cur_data; |
@@ -176,10 +191,12 @@ discard block |
||
| 176 | 191 | // Maybe we wat set a custom class for the row based on the data in the row itself |
| 177 | 192 | if (isset($listOptions['data_check'])) |
| 178 | 193 | { |
| 179 | - if (isset($listOptions['data_check']['class'])) |
|
| 180 | - $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 181 | - if (isset($listOptions['data_check']['style'])) |
|
| 182 | - $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 194 | + if (isset($listOptions['data_check']['class'])) { |
|
| 195 | + $list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item); |
|
| 196 | + } |
|
| 197 | + if (isset($listOptions['data_check']['style'])) { |
|
| 198 | + $list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item); |
|
| 199 | + } |
|
| 183 | 200 | } |
| 184 | 201 | |
| 185 | 202 | // Insert the row into the list. |
@@ -187,34 +204,39 @@ discard block |
||
| 187 | 204 | } |
| 188 | 205 | |
| 189 | 206 | // The title is currently optional. |
| 190 | - if (isset($listOptions['title'])) |
|
| 191 | - $list_context['title'] = $listOptions['title']; |
|
| 207 | + if (isset($listOptions['title'])) { |
|
| 208 | + $list_context['title'] = $listOptions['title']; |
|
| 209 | + } |
|
| 192 | 210 | |
| 193 | 211 | // In case there's a form, share it with the template context. |
| 194 | 212 | if (isset($listOptions['form'])) |
| 195 | 213 | { |
| 196 | 214 | $list_context['form'] = $listOptions['form']; |
| 197 | 215 | |
| 198 | - if (!isset($list_context['form']['hidden_fields'])) |
|
| 199 | - $list_context['form']['hidden_fields'] = array(); |
|
| 216 | + if (!isset($list_context['form']['hidden_fields'])) { |
|
| 217 | + $list_context['form']['hidden_fields'] = array(); |
|
| 218 | + } |
|
| 200 | 219 | |
| 201 | 220 | // Always add a session check field. |
| 202 | 221 | $list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id']; |
| 203 | 222 | |
| 204 | 223 | // Will this do a token check? |
| 205 | - if (isset($listOptions['form']['token'])) |
|
| 206 | - $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 224 | + if (isset($listOptions['form']['token'])) { |
|
| 225 | + $list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token']; |
|
| 226 | + } |
|
| 207 | 227 | |
| 208 | 228 | // Include the starting page as hidden field? |
| 209 | - if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) |
|
| 210 | - $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 229 | + if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) { |
|
| 230 | + $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; |
|
| 231 | + } |
|
| 211 | 232 | |
| 212 | 233 | // If sorting needs to be the same after submitting, add the parameter. |
| 213 | 234 | if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort'])) |
| 214 | 235 | { |
| 215 | 236 | $list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id']; |
| 216 | - if ($list_context['sort']['desc']) |
|
| 217 | - $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 237 | + if ($list_context['sort']['desc']) { |
|
| 238 | + $list_context['form']['hidden_fields']['desc'] = 1; |
|
| 239 | + } |
|
| 218 | 240 | } |
| 219 | 241 | } |
| 220 | 242 | |
@@ -231,24 +253,28 @@ discard block |
||
| 231 | 253 | $list_context['additional_rows'] = array(); |
| 232 | 254 | foreach ($listOptions['additional_rows'] as $row) |
| 233 | 255 | { |
| 234 | - if (empty($row)) |
|
| 235 | - continue; |
|
| 256 | + if (empty($row)) { |
|
| 257 | + continue; |
|
| 258 | + } |
|
| 236 | 259 | |
| 237 | 260 | // Supported row positions: top_of_list, after_title, |
| 238 | 261 | // above_column_headers, below_table_data, bottom_of_list. |
| 239 | - if (!isset($list_context['additional_rows'][$row['position']])) |
|
| 240 | - $list_context['additional_rows'][$row['position']] = array(); |
|
| 262 | + if (!isset($list_context['additional_rows'][$row['position']])) { |
|
| 263 | + $list_context['additional_rows'][$row['position']] = array(); |
|
| 264 | + } |
|
| 241 | 265 | $list_context['additional_rows'][$row['position']][] = $row; |
| 242 | 266 | } |
| 243 | 267 | } |
| 244 | 268 | |
| 245 | 269 | // Add an option for inline JavaScript. |
| 246 | - if (isset($listOptions['javascript'])) |
|
| 247 | - $list_context['javascript'] = $listOptions['javascript']; |
|
| 270 | + if (isset($listOptions['javascript'])) { |
|
| 271 | + $list_context['javascript'] = $listOptions['javascript']; |
|
| 272 | + } |
|
| 248 | 273 | |
| 249 | 274 | // We want a menu. |
| 250 | - if (isset($listOptions['list_menu'])) |
|
| 251 | - $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 275 | + if (isset($listOptions['list_menu'])) { |
|
| 276 | + $list_context['list_menu'] = $listOptions['list_menu']; |
|
| 277 | + } |
|
| 252 | 278 | |
| 253 | 279 | // Make sure the template is loaded. |
| 254 | 280 | loadTemplate('GenericList'); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
| 95 | 96 | ); |
| 96 | 97 | |
| 97 | 98 | // Have we got a localized one? |
| 98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
| 99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
| 101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 102 | - else |
|
| 103 | - $context['agreement'] = ''; |
|
| 99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
| 100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
| 102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 103 | + } else { |
|
| 104 | + $context['agreement'] = ''; |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | // Nothing to show, so let's get out of here |
| 106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
| 128 | 130 | { |
| 129 | 131 | global $txt, $helptxt, $context, $scripturl; |
| 130 | 132 | |
| 131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
| 132 | - fatal_lang_error('no_access', false); |
|
| 133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
| 134 | + fatal_lang_error('no_access', false); |
|
| 135 | + } |
|
| 133 | 136 | |
| 134 | - if (!isset($helptxt)) |
|
| 135 | - $helptxt = array(); |
|
| 137 | + if (!isset($helptxt)) { |
|
| 138 | + $helptxt = array(); |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | 141 | // Load the admin help language file and template. |
| 138 | 142 | loadLanguage('Help'); |
| 139 | 143 | |
| 140 | 144 | // Permission specific help? |
| 141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
| 142 | - loadLanguage('ManagePermissions'); |
|
| 145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
| 146 | + loadLanguage('ManagePermissions'); |
|
| 147 | + } |
|
| 143 | 148 | |
| 144 | 149 | loadTemplate('Help'); |
| 145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
| 154 | 159 | $context['sub_template'] = 'popup'; |
| 155 | 160 | |
| 156 | 161 | // What help string should be used? |
| 157 | - if (isset($helptxt[$_GET['help']])) |
|
| 158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
| 159 | - elseif (isset($txt[$_GET['help']])) |
|
| 160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
| 161 | - else |
|
| 162 | - $context['help_text'] = $_GET['help']; |
|
| 162 | + if (isset($helptxt[$_GET['help']])) { |
|
| 163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
| 164 | + } elseif (isset($txt[$_GET['help']])) { |
|
| 165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
| 166 | + } else { |
|
| 167 | + $context['help_text'] = $_GET['help']; |
|
| 168 | + } |
|
| 163 | 169 | |
| 164 | 170 | // Does this text contain a link that we should fill in? |
| 165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
| 166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
| 167 | -} |
|
| 171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
| 172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
| 173 | + } |
|
| 174 | + } |
|
| 168 | 175 | |
| 169 | 176 | ?> |
| 170 | 177 | \ No newline at end of file |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 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 | * Standard non full index, non custom index search |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change) |
| 176 | 176 | { |
| 177 | 177 | // Write the change |
| 178 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 178 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 179 | 179 | $written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX); |
| 180 | 180 | |
| 181 | 181 | // survey says ... |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
| 249 | 249 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
| 250 | 250 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
| 251 | - ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
|
| 251 | + ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), ' |
|
| 252 | 252 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 253 | 253 | |
| 254 | 254 | if (function_exists('memory_get_peak_usage')) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Put this user in the online log. |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 34 | 35 | if ($topic) |
| 35 | 36 | { |
| 36 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 37 | - $force = false; |
|
| 37 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 38 | + $force = false; |
|
| 39 | + } |
|
| 38 | 40 | $_SESSION['last_topic_id'] = $topic; |
| 39 | 41 | } |
| 40 | 42 | } |
@@ -47,22 +49,24 @@ discard block |
||
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | // Don't mark them as online more than every so often. |
| 50 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 51 | - return; |
|
| 52 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | if (!empty($modSettings['who_enabled'])) |
| 54 | 57 | { |
| 55 | 58 | $serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 56 | 59 | |
| 57 | 60 | // In the case of a dlattach action, session_var may not be set. |
| 58 | - if (!isset($context['session_var'])) |
|
| 59 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 61 | + if (!isset($context['session_var'])) { |
|
| 62 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
| 62 | 66 | $serialized = json_encode($serialized); |
| 67 | + } else { |
|
| 68 | + $serialized = ''; |
|
| 63 | 69 | } |
| 64 | - else |
|
| 65 | - $serialized = ''; |
|
| 66 | 70 | |
| 67 | 71 | // Guests use 0, members use their session ID. |
| 68 | 72 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -102,17 +106,18 @@ discard block |
||
| 102 | 106 | ); |
| 103 | 107 | |
| 104 | 108 | // Guess it got deleted. |
| 105 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 109 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 110 | + $_SESSION['log_time'] = 0; |
|
| 111 | + } |
|
| 112 | + } else { |
|
| 106 | 113 | $_SESSION['log_time'] = 0; |
| 107 | 114 | } |
| 108 | - else |
|
| 109 | - $_SESSION['log_time'] = 0; |
|
| 110 | 115 | |
| 111 | 116 | // Otherwise, we have to delete and insert. |
| 112 | 117 | if (empty($_SESSION['log_time'])) |
| 113 | 118 | { |
| 114 | - if ($do_delete || !empty($user_info['id'])) |
|
| 115 | - $smcFunc['db_query']('', ' |
|
| 119 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 120 | + $smcFunc['db_query']('', ' |
|
| 116 | 121 | DELETE FROM {db_prefix}log_online |
| 117 | 122 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 118 | 123 | array( |
@@ -120,6 +125,7 @@ discard block |
||
| 120 | 125 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 121 | 126 | ) |
| 122 | 127 | ); |
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 125 | 131 | '{db_prefix}log_online', |
@@ -133,21 +139,24 @@ discard block |
||
| 133 | 139 | $_SESSION['log_time'] = time(); |
| 134 | 140 | |
| 135 | 141 | // Well, they are online now. |
| 136 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 137 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 142 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 143 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 144 | + } |
|
| 138 | 145 | |
| 139 | 146 | // Set their login time, if not already done within the last minute. |
| 140 | 147 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 141 | 148 | { |
| 142 | 149 | // Don't count longer than 15 minutes. |
| 143 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 144 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 150 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 151 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 152 | + } |
|
| 145 | 153 | |
| 146 | 154 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 147 | 155 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 148 | 156 | |
| 149 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 150 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 157 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 158 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 159 | + } |
|
| 151 | 160 | |
| 152 | 161 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 153 | 162 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -184,8 +193,7 @@ discard block |
||
| 184 | 193 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 185 | 194 | // Copy the file back and run for your life! |
| 186 | 195 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
| 187 | - } |
|
| 188 | - else |
|
| 196 | + } else |
|
| 189 | 197 | { |
| 190 | 198 | @touch($boarddir . '/' . 'Settings.php'); |
| 191 | 199 | return true; |
@@ -205,22 +213,27 @@ discard block |
||
| 205 | 213 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 206 | 214 | |
| 207 | 215 | // Add to Settings.php if you want to show the debugging information. |
| 208 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 209 | - return; |
|
| 216 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 210 | 219 | |
| 211 | - if (empty($_SESSION['view_queries'])) |
|
| 212 | - $_SESSION['view_queries'] = 0; |
|
| 213 | - if (empty($context['debug']['language_files'])) |
|
| 214 | - $context['debug']['language_files'] = array(); |
|
| 215 | - if (empty($context['debug']['sheets'])) |
|
| 216 | - $context['debug']['sheets'] = array(); |
|
| 220 | + if (empty($_SESSION['view_queries'])) { |
|
| 221 | + $_SESSION['view_queries'] = 0; |
|
| 222 | + } |
|
| 223 | + if (empty($context['debug']['language_files'])) { |
|
| 224 | + $context['debug']['language_files'] = array(); |
|
| 225 | + } |
|
| 226 | + if (empty($context['debug']['sheets'])) { |
|
| 227 | + $context['debug']['sheets'] = array(); |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | $files = get_included_files(); |
| 219 | 231 | $total_size = 0; |
| 220 | 232 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 221 | 233 | { |
| 222 | - if (file_exists($files[$i])) |
|
| 223 | - $total_size += filesize($files[$i]); |
|
| 234 | + if (file_exists($files[$i])) { |
|
| 235 | + $total_size += filesize($files[$i]); |
|
| 236 | + } |
|
| 224 | 237 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 225 | 238 | } |
| 226 | 239 | |
@@ -229,8 +242,9 @@ discard block |
||
| 229 | 242 | { |
| 230 | 243 | foreach ($db_cache as $q => $qq) |
| 231 | 244 | { |
| 232 | - if (!empty($qq['w'])) |
|
| 233 | - $warnings += count($qq['w']); |
|
| 245 | + if (!empty($qq['w'])) { |
|
| 246 | + $warnings += count($qq['w']); |
|
| 247 | + } |
|
| 234 | 248 | } |
| 235 | 249 | |
| 236 | 250 | $_SESSION['debug'] = &$db_cache; |
@@ -251,12 +265,14 @@ discard block |
||
| 251 | 265 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 252 | 266 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 253 | 267 | |
| 254 | - if (function_exists('memory_get_peak_usage')) |
|
| 255 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 268 | + if (function_exists('memory_get_peak_usage')) { |
|
| 269 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 270 | + } |
|
| 256 | 271 | |
| 257 | 272 | // What tokens are active? |
| 258 | - if (isset($_SESSION['token'])) |
|
| 259 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 273 | + if (isset($_SESSION['token'])) { |
|
| 274 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 275 | + } |
|
| 260 | 276 | |
| 261 | 277 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 262 | 278 | { |
@@ -269,10 +285,12 @@ discard block |
||
| 269 | 285 | $total_t += $cache_hit['t']; |
| 270 | 286 | $total_s += $cache_hit['s']; |
| 271 | 287 | } |
| 272 | - if (!isset($cache_misses)) |
|
| 273 | - $cache_misses = array(); |
|
| 274 | - foreach ($cache_misses as $missed) |
|
| 275 | - $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 288 | + if (!isset($cache_misses)) { |
|
| 289 | + $cache_misses = array(); |
|
| 290 | + } |
|
| 291 | + foreach ($cache_misses as $missed) { |
|
| 292 | + $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 293 | + } |
|
| 276 | 294 | |
| 277 | 295 | echo ' |
| 278 | 296 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -283,38 +301,44 @@ discard block |
||
| 283 | 301 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 284 | 302 | <br>'; |
| 285 | 303 | |
| 286 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 287 | - foreach ($db_cache as $q => $qq) |
|
| 304 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 305 | + foreach ($db_cache as $q => $qq) |
|
| 288 | 306 | { |
| 289 | 307 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
| 308 | + } |
|
| 290 | 309 | // Temporary tables created in earlier queries are not explainable. |
| 291 | 310 | if ($is_select) |
| 292 | 311 | { |
| 293 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 294 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 312 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 313 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 295 | 314 | { |
| 296 | 315 | $is_select = false; |
| 316 | + } |
|
| 297 | 317 | break; |
| 298 | 318 | } |
| 299 | 319 | } |
| 300 | 320 | // But actual creation of the temporary tables are. |
| 301 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
| 302 | - $is_select = true; |
|
| 321 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
| 322 | + $is_select = true; |
|
| 323 | + } |
|
| 303 | 324 | |
| 304 | 325 | // Make the filenames look a bit better. |
| 305 | - if (isset($qq['f'])) |
|
| 306 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 326 | + if (isset($qq['f'])) { |
|
| 327 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | echo ' |
| 309 | 331 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 310 | 332 | '; |
| 311 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
| 312 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 333 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
| 334 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 335 | + } |
|
| 313 | 336 | |
| 314 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 315 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 316 | - elseif (isset($qq['t'])) |
|
| 317 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 337 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 338 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 339 | + } elseif (isset($qq['t'])) { |
|
| 340 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 341 | + } |
|
| 318 | 342 | echo ' |
| 319 | 343 | <br>'; |
| 320 | 344 | } |
@@ -339,12 +363,14 @@ discard block |
||
| 339 | 363 | global $modSettings, $smcFunc; |
| 340 | 364 | static $cache_stats = array(); |
| 341 | 365 | |
| 342 | - if (empty($modSettings['trackStats'])) |
|
| 343 | - return false; |
|
| 344 | - if (!empty($stats)) |
|
| 345 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 346 | - elseif (empty($cache_stats)) |
|
| 347 | - return false; |
|
| 366 | + if (empty($modSettings['trackStats'])) { |
|
| 367 | + return false; |
|
| 368 | + } |
|
| 369 | + if (!empty($stats)) { |
|
| 370 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 371 | + } elseif (empty($cache_stats)) { |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 348 | 374 | |
| 349 | 375 | $setStringUpdate = ''; |
| 350 | 376 | $insert_keys = array(); |
@@ -357,10 +383,11 @@ discard block |
||
| 357 | 383 | $setStringUpdate .= ' |
| 358 | 384 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 359 | 385 | |
| 360 | - if ($change === '+') |
|
| 361 | - $cache_stats[$field] = 1; |
|
| 362 | - else |
|
| 363 | - $update_parameters[$field] = $change; |
|
| 386 | + if ($change === '+') { |
|
| 387 | + $cache_stats[$field] = 1; |
|
| 388 | + } else { |
|
| 389 | + $update_parameters[$field] = $change; |
|
| 390 | + } |
|
| 364 | 391 | $insert_keys[$field] = 'int'; |
| 365 | 392 | } |
| 366 | 393 | |
@@ -424,43 +451,50 @@ discard block |
||
| 424 | 451 | ); |
| 425 | 452 | |
| 426 | 453 | // Make sure this particular log is enabled first... |
| 427 | - if (empty($modSettings['modlog_enabled'])) |
|
| 428 | - unset ($log_types['moderate']); |
|
| 429 | - if (empty($modSettings['userlog_enabled'])) |
|
| 430 | - unset ($log_types['user']); |
|
| 431 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 432 | - unset ($log_types['admin']); |
|
| 454 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 455 | + unset ($log_types['moderate']); |
|
| 456 | + } |
|
| 457 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 458 | + unset ($log_types['user']); |
|
| 459 | + } |
|
| 460 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 461 | + unset ($log_types['admin']); |
|
| 462 | + } |
|
| 433 | 463 | |
| 434 | 464 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 435 | 465 | |
| 436 | 466 | foreach ($logs as $log) |
| 437 | 467 | { |
| 438 | - if (!isset($log_types[$log['log_type']])) |
|
| 439 | - return false; |
|
| 468 | + if (!isset($log_types[$log['log_type']])) { |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 440 | 471 | |
| 441 | - if (!is_array($log['extra'])) |
|
| 442 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 472 | + if (!is_array($log['extra'])) { |
|
| 473 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 474 | + } |
|
| 443 | 475 | |
| 444 | 476 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 445 | 477 | if (isset($log['extra']['topic'])) |
| 446 | 478 | { |
| 447 | - if (!is_numeric($log['extra']['topic'])) |
|
| 448 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 479 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 480 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 481 | + } |
|
| 449 | 482 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 450 | 483 | unset($log['extra']['topic']); |
| 484 | + } else { |
|
| 485 | + $topic_id = 0; |
|
| 451 | 486 | } |
| 452 | - else |
|
| 453 | - $topic_id = 0; |
|
| 454 | 487 | |
| 455 | 488 | if (isset($log['extra']['message'])) |
| 456 | 489 | { |
| 457 | - if (!is_numeric($log['extra']['message'])) |
|
| 458 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 490 | + if (!is_numeric($log['extra']['message'])) { |
|
| 491 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 492 | + } |
|
| 459 | 493 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 460 | 494 | unset($log['extra']['message']); |
| 495 | + } else { |
|
| 496 | + $msg_id = 0; |
|
| 461 | 497 | } |
| 462 | - else |
|
| 463 | - $msg_id = 0; |
|
| 464 | 498 | |
| 465 | 499 | // @todo cache this? |
| 466 | 500 | // Is there an associated report on this? |
@@ -487,23 +521,26 @@ discard block |
||
| 487 | 521 | $smcFunc['db_free_result']($request); |
| 488 | 522 | } |
| 489 | 523 | |
| 490 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 491 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 524 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 525 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 526 | + } |
|
| 492 | 527 | |
| 493 | 528 | if (isset($log['extra']['board'])) |
| 494 | 529 | { |
| 495 | - if (!is_numeric($log['extra']['board'])) |
|
| 496 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 530 | + if (!is_numeric($log['extra']['board'])) { |
|
| 531 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 532 | + } |
|
| 497 | 533 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 498 | 534 | unset($log['extra']['board']); |
| 535 | + } else { |
|
| 536 | + $board_id = 0; |
|
| 499 | 537 | } |
| 500 | - else |
|
| 501 | - $board_id = 0; |
|
| 502 | 538 | |
| 503 | 539 | if (isset($log['extra']['board_to'])) |
| 504 | 540 | { |
| 505 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 506 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 541 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 542 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 543 | + } |
|
| 507 | 544 | if (empty($board_id)) |
| 508 | 545 | { |
| 509 | 546 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -511,10 +548,11 @@ discard block |
||
| 511 | 548 | } |
| 512 | 549 | } |
| 513 | 550 | |
| 514 | - if (isset($log['extra']['member_affected'])) |
|
| 515 | - $memID = $log['extra']['member_affected']; |
|
| 516 | - else |
|
| 517 | - $memID = $user_info['id']; |
|
| 551 | + if (isset($log['extra']['member_affected'])) { |
|
| 552 | + $memID = $log['extra']['member_affected']; |
|
| 553 | + } else { |
|
| 554 | + $memID = $user_info['id']; |
|
| 555 | + } |
|
| 518 | 556 | |
| 519 | 557 | $inserts[] = array( |
| 520 | 558 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -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 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * 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(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 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * 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 | { |