@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | * @version 2.1 Beta 3 |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -if (!defined('SMF')) |
|
| 20 | +if (!defined('SMF')) { |
|
| 21 | 21 | die('No direct access...'); |
| 22 | +} |
|
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | { |
| 39 | 40 | $parsed_url = parse_url($boardurl); |
| 40 | 41 | |
| 41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | // @todo Set the session cookie path? |
| 45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
| 47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
| 48 | 50 | { |
| 49 | 51 | // Attempt to end the already-started session. |
| 50 | - if (ini_get('session.auto_start') == 1) |
|
| 51 | - session_write_close(); |
|
| 52 | + if (ini_get('session.auto_start') == 1) { |
|
| 53 | + session_write_close(); |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
| 54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
| 65 | 68 | @ini_set('session.serialize_handler', 'php'); |
| 66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
| 67 | 70 | @ini_set('session.gc_probability', '1'); |
| 71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
| 72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 68 | 73 | } |
| 69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
| 70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 71 | 74 | |
| 72 | 75 | // Use cache setting sessions? |
| 73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
| 74 | - call_integration_hook('integrate_session_handlers'); |
|
| 76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
| 77 | + call_integration_hook('integrate_session_handlers'); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | session_start(); |
| 77 | 81 | |
| 78 | 82 | // Change it so the cache settings are a little looser than default. |
| 79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
| 80 | - header('Cache-Control: private'); |
|
| 83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
| 84 | + header('Cache-Control: private'); |
|
| 85 | + } |
|
| 81 | 86 | } |
| 82 | 87 | |
| 83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
| 123 | 128 | { |
| 124 | 129 | global $smcFunc; |
| 125 | 130 | |
| 126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 127 | - return ''; |
|
| 131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 132 | + return ''; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Look for it in the database. |
| 130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
| 153 | 159 | { |
| 154 | 160 | global $smcFunc; |
| 155 | 161 | |
| 156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 157 | - return false; |
|
| 162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 158 | 165 | |
| 159 | 166 | // First try to update an existing row... |
| 160 | 167 | $result = $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
| 169 | 176 | ); |
| 170 | 177 | |
| 171 | 178 | // If that didn't work, try inserting a new one. |
| 172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 173 | - $result = $smcFunc['db_insert']('ignore', |
|
| 179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 180 | + $result = $smcFunc['db_insert']('ignore', |
|
| 174 | 181 | '{db_prefix}sessions', |
| 175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
| 176 | 183 | array($session_id, $data, time()), |
| 177 | 184 | array('session_id') |
| 178 | 185 | ); |
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
| 181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
| 190 | 198 | { |
| 191 | 199 | global $smcFunc; |
| 192 | 200 | |
| 193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 194 | - return false; |
|
| 201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | 205 | // Just delete the row... |
| 197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
| 217 | 226 | global $modSettings, $smcFunc; |
| 218 | 227 | |
| 219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
| 220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
| 221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
| 230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 231 | + } |
|
| 222 | 232 | |
| 223 | 233 | // Clean up after yerself ;). |
| 224 | 234 | $smcFunc['db_query']('', ' |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | * @version 2.1 Beta 3 |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -if (!defined('SMF')) |
|
| 24 | +if (!defined('SMF')) { |
|
| 25 | 25 | die('No direct access...'); |
| 26 | +} |
|
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * Handling function for generating reports. |
@@ -69,14 +70,15 @@ discard block |
||
| 69 | 70 | ); |
| 70 | 71 | |
| 71 | 72 | $is_first = 0; |
| 72 | - foreach ($context['report_types'] as $k => $temp) |
|
| 73 | - $context['report_types'][$k] = array( |
|
| 73 | + foreach ($context['report_types'] as $k => $temp) { |
|
| 74 | + $context['report_types'][$k] = array( |
|
| 74 | 75 | 'id' => $k, |
| 75 | 76 | 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k, |
| 76 | 77 | 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, |
| 77 | 78 | 'function' => $temp, |
| 78 | 79 | 'is_first' => $is_first++ == 0, |
| 79 | 80 | ); |
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | // If they haven't chosen a report type which is valid, send them off to the report type chooser! |
| 82 | 84 | if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) |
@@ -102,8 +104,9 @@ discard block |
||
| 102 | 104 | $context['sub_template'] = $_REQUEST['st']; |
| 103 | 105 | |
| 104 | 106 | // Are we disabling the other layers - print friendly for example? |
| 105 | - if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) |
|
| 106 | - $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
| 107 | + if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) { |
|
| 108 | + $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
| 109 | + } |
|
| 107 | 110 | } |
| 108 | 111 | |
| 109 | 112 | // Make the page title more descriptive. |
@@ -151,8 +154,9 @@ discard block |
||
| 151 | 154 | ) |
| 152 | 155 | ); |
| 153 | 156 | $moderators = array(); |
| 154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 155 | - $moderators[$row['id_board']][] = $row['real_name']; |
|
| 157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 158 | + $moderators[$row['id_board']][] = $row['real_name']; |
|
| 159 | + } |
|
| 156 | 160 | $smcFunc['db_free_result']($request); |
| 157 | 161 | |
| 158 | 162 | // Get every moderator gruop. |
@@ -164,8 +168,9 @@ discard block |
||
| 164 | 168 | ) |
| 165 | 169 | ); |
| 166 | 170 | $moderator_groups = array(); |
| 167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 168 | - $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
| 171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 172 | + $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
| 173 | + } |
|
| 169 | 174 | $smcFunc['db_free_result']($request); |
| 170 | 175 | |
| 171 | 176 | // Get all the possible membergroups! |
@@ -176,8 +181,9 @@ discard block |
||
| 176 | 181 | ) |
| 177 | 182 | ); |
| 178 | 183 | $groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']); |
| 179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 180 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 185 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 186 | + } |
|
| 181 | 187 | $smcFunc['db_free_result']($request); |
| 182 | 188 | |
| 183 | 189 | // All the fields we'll show. |
@@ -195,8 +201,9 @@ discard block |
||
| 195 | 201 | 'moderator_groups' => $txt['board_moderator_groups'], |
| 196 | 202 | 'groups' => $txt['board_groups'], |
| 197 | 203 | ); |
| 198 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 199 | - $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 204 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 205 | + $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 206 | + } |
|
| 200 | 207 | |
| 201 | 208 | // Do it in columns, it's just easier. |
| 202 | 209 | setKeys('cols'); |
@@ -222,8 +229,9 @@ discard block |
||
| 222 | 229 | newTable($row['name'], '', 'left', 'auto', 'left', 200, 'left'); |
| 223 | 230 | |
| 224 | 231 | $this_boardSettings = $boardSettings; |
| 225 | - if (empty($row['redirect'])) |
|
| 226 | - unset($this_boardSettings['redirect']); |
|
| 232 | + if (empty($row['redirect'])) { |
|
| 233 | + unset($this_boardSettings['redirect']); |
|
| 234 | + } |
|
| 227 | 235 | |
| 228 | 236 | // First off, add in the side key. |
| 229 | 237 | addData($this_boardSettings); |
@@ -250,10 +258,11 @@ discard block |
||
| 250 | 258 | $allowedGroups = explode(',', $row['member_groups']); |
| 251 | 259 | foreach ($allowedGroups as $key => $group) |
| 252 | 260 | { |
| 253 | - if (isset($groups[$group])) |
|
| 254 | - $allowedGroups[$key] = $groups[$group]; |
|
| 255 | - else |
|
| 256 | - unset($allowedGroups[$key]); |
|
| 261 | + if (isset($groups[$group])) { |
|
| 262 | + $allowedGroups[$key] = $groups[$group]; |
|
| 263 | + } else { |
|
| 264 | + unset($allowedGroups[$key]); |
|
| 265 | + } |
|
| 257 | 266 | } |
| 258 | 267 | $boardData['groups'] = implode(', ', $allowedGroups); |
| 259 | 268 | if (!empty($modSettings['deny_boards_access'])) |
@@ -261,16 +270,18 @@ discard block |
||
| 261 | 270 | $disallowedGroups = explode(',', $row['deny_member_groups']); |
| 262 | 271 | foreach ($disallowedGroups as $key => $group) |
| 263 | 272 | { |
| 264 | - if (isset($groups[$group])) |
|
| 265 | - $disallowedGroups[$key] = $groups[$group]; |
|
| 266 | - else |
|
| 267 | - unset($disallowedGroups[$key]); |
|
| 273 | + if (isset($groups[$group])) { |
|
| 274 | + $disallowedGroups[$key] = $groups[$group]; |
|
| 275 | + } else { |
|
| 276 | + unset($disallowedGroups[$key]); |
|
| 277 | + } |
|
| 268 | 278 | } |
| 269 | 279 | $boardData['disallowed_groups'] = implode(', ', $disallowedGroups); |
| 270 | 280 | } |
| 271 | 281 | |
| 272 | - if (empty($row['redirect'])) |
|
| 273 | - unset ($boardData['redirect']); |
|
| 282 | + if (empty($row['redirect'])) { |
|
| 283 | + unset ($boardData['redirect']); |
|
| 284 | + } |
|
| 274 | 285 | |
| 275 | 286 | // Next add the main data. |
| 276 | 287 | addData($boardData); |
@@ -295,27 +306,31 @@ discard block |
||
| 295 | 306 | |
| 296 | 307 | if (isset($_REQUEST['boards'])) |
| 297 | 308 | { |
| 298 | - if (!is_array($_REQUEST['boards'])) |
|
| 299 | - $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
| 300 | - foreach ($_REQUEST['boards'] as $k => $dummy) |
|
| 301 | - $_REQUEST['boards'][$k] = (int) $dummy; |
|
| 309 | + if (!is_array($_REQUEST['boards'])) { |
|
| 310 | + $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
| 311 | + } |
|
| 312 | + foreach ($_REQUEST['boards'] as $k => $dummy) { |
|
| 313 | + $_REQUEST['boards'][$k] = (int) $dummy; |
|
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | $board_clause = 'id_board IN ({array_int:boards})'; |
| 317 | + } else { |
|
| 318 | + $board_clause = '1=1'; |
|
| 304 | 319 | } |
| 305 | - else |
|
| 306 | - $board_clause = '1=1'; |
|
| 307 | 320 | |
| 308 | 321 | if (isset($_REQUEST['groups'])) |
| 309 | 322 | { |
| 310 | - if (!is_array($_REQUEST['groups'])) |
|
| 311 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 312 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
| 313 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 323 | + if (!is_array($_REQUEST['groups'])) { |
|
| 324 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 325 | + } |
|
| 326 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
| 327 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | $group_clause = 'id_group IN ({array_int:groups})'; |
| 331 | + } else { |
|
| 332 | + $group_clause = '1=1'; |
|
| 316 | 333 | } |
| 317 | - else |
|
| 318 | - $group_clause = '1=1'; |
|
| 319 | 334 | |
| 320 | 335 | // Fetch all the board names. |
| 321 | 336 | $request = $smcFunc['db_query']('', ' |
@@ -369,12 +384,14 @@ discard block |
||
| 369 | 384 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
| 370 | 385 | ) |
| 371 | 386 | ); |
| 372 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
| 373 | - $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 374 | - else |
|
| 375 | - $member_groups = array('col' => ''); |
|
| 376 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 377 | - $member_groups[$row['id_group']] = $row['group_name']; |
|
| 387 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
| 388 | + $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 389 | + } else { |
|
| 390 | + $member_groups = array('col' => ''); |
|
| 391 | + } |
|
| 392 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 393 | + $member_groups[$row['id_group']] = $row['group_name']; |
|
| 394 | + } |
|
| 378 | 395 | $smcFunc['db_free_result']($request); |
| 379 | 396 | |
| 380 | 397 | // Make sure that every group is represented - plus in rows! |
@@ -411,12 +428,14 @@ discard block |
||
| 411 | 428 | ); |
| 412 | 429 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 413 | 430 | { |
| 414 | - if (in_array($row['permission'], $disabled_permissions)) |
|
| 415 | - continue; |
|
| 431 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
| 432 | + continue; |
|
| 433 | + } |
|
| 416 | 434 | |
| 417 | - foreach ($boards as $id => $board) |
|
| 418 | - if ($board['profile'] == $row['id_profile']) |
|
| 435 | + foreach ($boards as $id => $board) { |
|
| 436 | + if ($board['profile'] == $row['id_profile']) |
|
| 419 | 437 | $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny']; |
| 438 | + } |
|
| 420 | 439 | |
| 421 | 440 | // Make sure we get every permission. |
| 422 | 441 | if (!isset($permissions[$row['permission']])) |
@@ -454,8 +473,9 @@ discard block |
||
| 454 | 473 | foreach ($member_groups as $id_group => $name) |
| 455 | 474 | { |
| 456 | 475 | // Don't overwrite the key column! |
| 457 | - if ($id_group === 'col') |
|
| 458 | - continue; |
|
| 476 | + if ($id_group === 'col') { |
|
| 477 | + continue; |
|
| 478 | + } |
|
| 459 | 479 | |
| 460 | 480 | $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array(); |
| 461 | 481 | |
@@ -477,16 +497,18 @@ discard block |
||
| 477 | 497 | } |
| 478 | 498 | |
| 479 | 499 | // Now actually make the data for the group look right. |
| 480 | - if (empty($curData[$id_group])) |
|
| 481 | - $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 482 | - elseif ($curData[$id_group] == 1) |
|
| 483 | - $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 484 | - else |
|
| 485 | - $curData[$id_group] = 'x'; |
|
| 500 | + if (empty($curData[$id_group])) { |
|
| 501 | + $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 502 | + } elseif ($curData[$id_group] == 1) { |
|
| 503 | + $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 504 | + } else { |
|
| 505 | + $curData[$id_group] = 'x'; |
|
| 506 | + } |
|
| 486 | 507 | |
| 487 | 508 | // Embolden those permissions different from global (makes it a lot easier!) |
| 488 | - if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) |
|
| 489 | - $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
| 509 | + if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) { |
|
| 510 | + $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
| 511 | + } |
|
| 490 | 512 | } |
| 491 | 513 | |
| 492 | 514 | // Now add the data for this permission. |
@@ -516,15 +538,17 @@ discard block |
||
| 516 | 538 | ); |
| 517 | 539 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 518 | 540 | { |
| 519 | - if (trim($row['member_groups']) == '') |
|
| 520 | - $groups = array(1); |
|
| 521 | - else |
|
| 522 | - $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 541 | + if (trim($row['member_groups']) == '') { |
|
| 542 | + $groups = array(1); |
|
| 543 | + } else { |
|
| 544 | + $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 545 | + } |
|
| 523 | 546 | |
| 524 | - if (trim($row['deny_member_groups']) == '') |
|
| 525 | - $denyGroups = array(); |
|
| 526 | - else |
|
| 527 | - $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 547 | + if (trim($row['deny_member_groups']) == '') { |
|
| 548 | + $denyGroups = array(); |
|
| 549 | + } else { |
|
| 550 | + $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 551 | + } |
|
| 528 | 552 | |
| 529 | 553 | $boards[$row['id_board']] = array( |
| 530 | 554 | 'id' => $row['id_board'], |
@@ -548,8 +572,9 @@ discard block |
||
| 548 | 572 | ); |
| 549 | 573 | |
| 550 | 574 | // Add on the boards! |
| 551 | - foreach ($boards as $board) |
|
| 552 | - $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 575 | + foreach ($boards as $board) { |
|
| 576 | + $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 577 | + } |
|
| 553 | 578 | |
| 554 | 579 | // Add all the membergroup settings, plus we'll be adding in columns! |
| 555 | 580 | setKeys('cols', $mgSettings); |
@@ -594,8 +619,9 @@ discard block |
||
| 594 | 619 | 'icons' => '' |
| 595 | 620 | ), |
| 596 | 621 | ); |
| 597 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 598 | - $rows[] = $row; |
|
| 622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 623 | + $rows[] = $row; |
|
| 624 | + } |
|
| 599 | 625 | $smcFunc['db_free_result']($request); |
| 600 | 626 | |
| 601 | 627 | foreach ($rows as $row) |
@@ -611,8 +637,9 @@ discard block |
||
| 611 | 637 | ); |
| 612 | 638 | |
| 613 | 639 | // Board permissions. |
| 614 | - foreach ($boards as $board) |
|
| 615 | - $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 640 | + foreach ($boards as $board) { |
|
| 641 | + $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 642 | + } |
|
| 616 | 643 | |
| 617 | 644 | addData($group); |
| 618 | 645 | } |
@@ -632,16 +659,18 @@ discard block |
||
| 632 | 659 | |
| 633 | 660 | if (isset($_REQUEST['groups'])) |
| 634 | 661 | { |
| 635 | - if (!is_array($_REQUEST['groups'])) |
|
| 636 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 637 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
| 638 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 662 | + if (!is_array($_REQUEST['groups'])) { |
|
| 663 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 664 | + } |
|
| 665 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
| 666 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 667 | + } |
|
| 639 | 668 | $_REQUEST['groups'] = array_diff($_REQUEST['groups'], array(3)); |
| 640 | 669 | |
| 641 | 670 | $clause = 'id_group IN ({array_int:groups})'; |
| 671 | + } else { |
|
| 672 | + $clause = 'id_group != {int:moderator_group}'; |
|
| 642 | 673 | } |
| 643 | - else |
|
| 644 | - $clause = 'id_group != {int:moderator_group}'; |
|
| 645 | 674 | |
| 646 | 675 | // Get all the possible membergroups, except admin! |
| 647 | 676 | $request = $smcFunc['db_query']('', ' |
@@ -659,12 +688,14 @@ discard block |
||
| 659 | 688 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
| 660 | 689 | ) |
| 661 | 690 | ); |
| 662 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
| 663 | - $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 664 | - else |
|
| 665 | - $groups = array('col' => ''); |
|
| 666 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 667 | - $groups[$row['id_group']] = $row['group_name']; |
|
| 691 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
| 692 | + $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 693 | + } else { |
|
| 694 | + $groups = array('col' => ''); |
|
| 695 | + } |
|
| 696 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 697 | + $groups[$row['id_group']] = $row['group_name']; |
|
| 698 | + } |
|
| 668 | 699 | $smcFunc['db_free_result']($request); |
| 669 | 700 | |
| 670 | 701 | // Make sure that every group is represented! |
@@ -688,8 +719,9 @@ discard block |
||
| 688 | 719 | $disabled_permissions[] = 'calendar_edit_own'; |
| 689 | 720 | $disabled_permissions[] = 'calendar_edit_any'; |
| 690 | 721 | } |
| 691 | - if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) |
|
| 692 | - $disabled_permissions[] = 'issue_warning'; |
|
| 722 | + if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) { |
|
| 723 | + $disabled_permissions[] = 'issue_warning'; |
|
| 724 | + } |
|
| 693 | 725 | |
| 694 | 726 | call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions)); |
| 695 | 727 | |
@@ -710,15 +742,17 @@ discard block |
||
| 710 | 742 | $curData = array(); |
| 711 | 743 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 712 | 744 | { |
| 713 | - if (in_array($row['permission'], $disabled_permissions)) |
|
| 714 | - continue; |
|
| 745 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
| 746 | + continue; |
|
| 747 | + } |
|
| 715 | 748 | |
| 716 | 749 | // If this is a new permission flush the last row. |
| 717 | 750 | if ($row['permission'] != $lastPermission) |
| 718 | 751 | { |
| 719 | 752 | // Send the data! |
| 720 | - if ($lastPermission !== null) |
|
| 721 | - addData($curData); |
|
| 753 | + if ($lastPermission !== null) { |
|
| 754 | + addData($curData); |
|
| 755 | + } |
|
| 722 | 756 | |
| 723 | 757 | // Add the permission name in the left column. |
| 724 | 758 | $curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']); |
@@ -727,10 +761,11 @@ discard block |
||
| 727 | 761 | } |
| 728 | 762 | |
| 729 | 763 | // Good stuff - add the permission to the list! |
| 730 | - if ($row['add_deny']) |
|
| 731 | - $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 732 | - else |
|
| 733 | - $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 764 | + if ($row['add_deny']) { |
|
| 765 | + $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 766 | + } else { |
|
| 767 | + $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 768 | + } |
|
| 734 | 769 | } |
| 735 | 770 | $smcFunc['db_free_result']($request); |
| 736 | 771 | |
@@ -760,8 +795,9 @@ discard block |
||
| 760 | 795 | ) |
| 761 | 796 | ); |
| 762 | 797 | $boards = array(); |
| 763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 764 | - $boards[$row['id_board']] = $row['name']; |
|
| 798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 799 | + $boards[$row['id_board']] = $row['name']; |
|
| 800 | + } |
|
| 765 | 801 | $smcFunc['db_free_result']($request); |
| 766 | 802 | |
| 767 | 803 | // Get every moderator. |
@@ -793,12 +829,14 @@ discard block |
||
| 793 | 829 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 794 | 830 | { |
| 795 | 831 | // Either we don't have them as a moderator at all or at least not as a moderator of this board |
| 796 | - if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) |
|
| 797 | - $moderators[$row['id_member']][] = $row['id_board']; |
|
| 832 | + if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) { |
|
| 833 | + $moderators[$row['id_member']][] = $row['id_board']; |
|
| 834 | + } |
|
| 798 | 835 | |
| 799 | 836 | // We don't have them listed as a moderator yet |
| 800 | - if (!array_key_exists($row['id_member'], $local_mods)) |
|
| 801 | - $local_mods[$row['id_member']] = $row['id_member']; |
|
| 837 | + if (!array_key_exists($row['id_member'], $local_mods)) { |
|
| 838 | + $local_mods[$row['id_member']] = $row['id_member']; |
|
| 839 | + } |
|
| 802 | 840 | } |
| 803 | 841 | |
| 804 | 842 | // Get a list of global moderators (i.e. members with moderation powers). |
@@ -811,8 +849,9 @@ discard block |
||
| 811 | 849 | $allStaff = array_unique($allStaff); |
| 812 | 850 | |
| 813 | 851 | // This is a bit of a cop out - but we're protecting their forum, really! |
| 814 | - if (count($allStaff) > 300) |
|
| 815 | - fatal_lang_error('report_error_too_many_staff'); |
|
| 852 | + if (count($allStaff) > 300) { |
|
| 853 | + fatal_lang_error('report_error_too_many_staff'); |
|
| 854 | + } |
|
| 816 | 855 | |
| 817 | 856 | // Get all the possible membergroups! |
| 818 | 857 | $request = $smcFunc['db_query']('', ' |
@@ -822,8 +861,9 @@ discard block |
||
| 822 | 861 | ) |
| 823 | 862 | ); |
| 824 | 863 | $groups = array(0 => $txt['full_member']); |
| 825 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 826 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 864 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 865 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 866 | + } |
|
| 827 | 867 | $smcFunc['db_free_result']($request); |
| 828 | 868 | |
| 829 | 869 | // All the fields we'll show. |
@@ -864,19 +904,20 @@ discard block |
||
| 864 | 904 | ); |
| 865 | 905 | |
| 866 | 906 | // What do they moderate? |
| 867 | - if (in_array($row['id_member'], $global_mods)) |
|
| 868 | - $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 869 | - elseif (isset($moderators[$row['id_member']])) |
|
| 907 | + if (in_array($row['id_member'], $global_mods)) { |
|
| 908 | + $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 909 | + } elseif (isset($moderators[$row['id_member']])) |
|
| 870 | 910 | { |
| 871 | 911 | // Get the names |
| 872 | - foreach ($moderators[$row['id_member']] as $board) |
|
| 873 | - if (isset($boards[$board])) |
|
| 912 | + foreach ($moderators[$row['id_member']] as $board) { |
|
| 913 | + if (isset($boards[$board])) |
|
| 874 | 914 | $staffData['moderates'][] = $boards[$board]; |
| 915 | + } |
|
| 875 | 916 | |
| 876 | 917 | $staffData['moderates'] = implode(', ', $staffData['moderates']); |
| 918 | + } else { |
|
| 919 | + $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 877 | 920 | } |
| 878 | - else |
|
| 879 | - $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 880 | 921 | |
| 881 | 922 | // Next add the main data. |
| 882 | 923 | addData($staffData); |
@@ -904,8 +945,9 @@ discard block |
||
| 904 | 945 | global $context; |
| 905 | 946 | |
| 906 | 947 | // Set the table count if needed. |
| 907 | - if (empty($context['table_count'])) |
|
| 908 | - $context['table_count'] = 0; |
|
| 948 | + if (empty($context['table_count'])) { |
|
| 949 | + $context['table_count'] = 0; |
|
| 950 | + } |
|
| 909 | 951 | |
| 910 | 952 | // Create the table! |
| 911 | 953 | $context['tables'][$context['table_count']] = array( |
@@ -955,16 +997,18 @@ discard block |
||
| 955 | 997 | global $context; |
| 956 | 998 | |
| 957 | 999 | // No tables? Create one even though we are probably already in a bad state! |
| 958 | - if (empty($context['table_count'])) |
|
| 959 | - newTable(); |
|
| 1000 | + if (empty($context['table_count'])) { |
|
| 1001 | + newTable(); |
|
| 1002 | + } |
|
| 960 | 1003 | |
| 961 | 1004 | // Specific table? |
| 962 | - if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
|
| 963 | - return false; |
|
| 964 | - elseif ($custom_table !== null) |
|
| 965 | - $table = $custom_table; |
|
| 966 | - else |
|
| 967 | - $table = $context['current_table']; |
|
| 1005 | + if ($custom_table !== null && !isset($context['tables'][$custom_table])) { |
|
| 1006 | + return false; |
|
| 1007 | + } elseif ($custom_table !== null) { |
|
| 1008 | + $table = $custom_table; |
|
| 1009 | + } else { |
|
| 1010 | + $table = $context['current_table']; |
|
| 1011 | + } |
|
| 968 | 1012 | |
| 969 | 1013 | // If we have keys, sanitise the data... |
| 970 | 1014 | if (!empty($context['keys'])) |
@@ -976,11 +1020,11 @@ discard block |
||
| 976 | 1020 | 'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key], |
| 977 | 1021 | ); |
| 978 | 1022 | // Special "hack" the adding separators when doing data by column. |
| 979 | - if (substr($key, 0, 5) == '#sep#') |
|
| 980 | - $data[$key]['separator'] = true; |
|
| 1023 | + if (substr($key, 0, 5) == '#sep#') { |
|
| 1024 | + $data[$key]['separator'] = true; |
|
| 1025 | + } |
|
| 981 | 1026 | } |
| 982 | - } |
|
| 983 | - else |
|
| 1027 | + } else |
|
| 984 | 1028 | { |
| 985 | 1029 | $data = $inc_data; |
| 986 | 1030 | foreach ($data as $key => $value) |
@@ -988,8 +1032,9 @@ discard block |
||
| 988 | 1032 | $data[$key] = array( |
| 989 | 1033 | 'v' => $value, |
| 990 | 1034 | ); |
| 991 | - if (substr($key, 0, 5) == '#sep#') |
|
| 992 | - $data[$key]['separator'] = true; |
|
| 1035 | + if (substr($key, 0, 5) == '#sep#') { |
|
| 1036 | + $data[$key]['separator'] = true; |
|
| 1037 | + } |
|
| 993 | 1038 | } |
| 994 | 1039 | } |
| 995 | 1040 | |
@@ -1002,8 +1047,9 @@ discard block |
||
| 1002 | 1047 | // Otherwise, tricky! |
| 1003 | 1048 | else |
| 1004 | 1049 | { |
| 1005 | - foreach ($data as $key => $item) |
|
| 1006 | - $context['tables'][$table]['data'][$key][] = $item; |
|
| 1050 | + foreach ($data as $key => $item) { |
|
| 1051 | + $context['tables'][$table]['data'][$key][] = $item; |
|
| 1052 | + } |
|
| 1007 | 1053 | } |
| 1008 | 1054 | } |
| 1009 | 1055 | |
@@ -1020,16 +1066,18 @@ discard block |
||
| 1020 | 1066 | global $context; |
| 1021 | 1067 | |
| 1022 | 1068 | // No tables - return? |
| 1023 | - if (empty($context['table_count'])) |
|
| 1024 | - return; |
|
| 1069 | + if (empty($context['table_count'])) { |
|
| 1070 | + return; |
|
| 1071 | + } |
|
| 1025 | 1072 | |
| 1026 | 1073 | // Specific table? |
| 1027 | - if ($custom_table !== null && !isset($context['tables'][$table])) |
|
| 1028 | - return false; |
|
| 1029 | - elseif ($custom_table !== null) |
|
| 1030 | - $table = $custom_table; |
|
| 1031 | - else |
|
| 1032 | - $table = $context['current_table']; |
|
| 1074 | + if ($custom_table !== null && !isset($context['tables'][$table])) { |
|
| 1075 | + return false; |
|
| 1076 | + } elseif ($custom_table !== null) { |
|
| 1077 | + $table = $custom_table; |
|
| 1078 | + } else { |
|
| 1079 | + $table = $context['current_table']; |
|
| 1080 | + } |
|
| 1033 | 1081 | |
| 1034 | 1082 | // Plumb in the separator |
| 1035 | 1083 | $context['tables'][$table]['data'][] = array(0 => array( |
@@ -1050,8 +1098,9 @@ discard block |
||
| 1050 | 1098 | { |
| 1051 | 1099 | global $context; |
| 1052 | 1100 | |
| 1053 | - if (empty($context['tables'])) |
|
| 1054 | - return; |
|
| 1101 | + if (empty($context['tables'])) { |
|
| 1102 | + return; |
|
| 1103 | + } |
|
| 1055 | 1104 | |
| 1056 | 1105 | // Loop through each table counting up some basic values, to help with the templating. |
| 1057 | 1106 | foreach ($context['tables'] as $id => $table) |
@@ -1062,12 +1111,13 @@ discard block |
||
| 1062 | 1111 | $context['tables'][$id]['column_count'] = count($curElement); |
| 1063 | 1112 | |
| 1064 | 1113 | // Work out the rough width - for templates like the print template. Without this we might get funny tables. |
| 1065 | - if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') |
|
| 1066 | - $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 1067 | - elseif ($table['width']['normal'] != 'auto') |
|
| 1068 | - $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 1069 | - else |
|
| 1070 | - $context['tables'][$id]['max_width'] = 'auto'; |
|
| 1114 | + if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') { |
|
| 1115 | + $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 1116 | + } elseif ($table['width']['normal'] != 'auto') { |
|
| 1117 | + $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 1118 | + } else { |
|
| 1119 | + $context['tables'][$id]['max_width'] = 'auto'; |
|
| 1120 | + } |
|
| 1071 | 1121 | } |
| 1072 | 1122 | } |
| 1073 | 1123 | |
@@ -1092,10 +1142,11 @@ discard block |
||
| 1092 | 1142 | global $context; |
| 1093 | 1143 | |
| 1094 | 1144 | // Do we want to use the keys of the keys as the keys? :P |
| 1095 | - if ($reverse) |
|
| 1096 | - $context['keys'] = array_flip($keys); |
|
| 1097 | - else |
|
| 1098 | - $context['keys'] = $keys; |
|
| 1145 | + if ($reverse) { |
|
| 1146 | + $context['keys'] = array_flip($keys); |
|
| 1147 | + } else { |
|
| 1148 | + $context['keys'] = $keys; |
|
| 1149 | + } |
|
| 1099 | 1150 | |
| 1100 | 1151 | // Rows or columns? |
| 1101 | 1152 | $context['key_method'] = $method == 'rows' ? 'rows' : 'cols'; |
@@ -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 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,8 +170,9 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
@@ -173,12 +181,12 @@ discard block |
||
| 173 | 181 | { |
| 174 | 182 | isAllowedTo('move_own'); |
| 175 | 183 | $boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any')); |
| 184 | + } else { |
|
| 185 | + isAllowedTo('move_any'); |
|
| 176 | 186 | } |
| 177 | - else |
|
| 178 | - isAllowedTo('move_any'); |
|
| 187 | + } else { |
|
| 188 | + $boards = boardsAllowedTo('move_any'); |
|
| 179 | 189 | } |
| 180 | - else |
|
| 181 | - $boards = boardsAllowedTo('move_any'); |
|
| 182 | 190 | |
| 183 | 191 | // If this topic isn't approved don't let them move it if they can't approve it! |
| 184 | 192 | if ($modSettings['postmod_active'] && !$context['is_approved'] && !allowedTo('approve_posts')) |
@@ -210,8 +218,9 @@ discard block |
||
| 210 | 218 | 'blank_redirect' => '', |
| 211 | 219 | ) |
| 212 | 220 | ); |
| 213 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 214 | - fatal_lang_error('no_board'); |
|
| 221 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 222 | + fatal_lang_error('no_board'); |
|
| 223 | + } |
|
| 215 | 224 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 216 | 225 | $smcFunc['db_free_result']($request); |
| 217 | 226 | |
@@ -223,8 +232,9 @@ discard block |
||
| 223 | 232 | { |
| 224 | 233 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 225 | 234 | // Keep checking the length. |
| 226 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 227 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 235 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 236 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 237 | + } |
|
| 228 | 238 | |
| 229 | 239 | // If it's still valid move onwards and upwards. |
| 230 | 240 | if ($_POST['custom_subject'] != '') |
@@ -234,9 +244,9 @@ discard block |
||
| 234 | 244 | // Get a response prefix, but in the forum's default language. |
| 235 | 245 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 236 | 246 | { |
| 237 | - if ($language === $user_info['language']) |
|
| 238 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 239 | - else |
|
| 247 | + if ($language === $user_info['language']) { |
|
| 248 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 249 | + } else |
|
| 240 | 250 | { |
| 241 | 251 | loadLanguage('index', $language, false); |
| 242 | 252 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -276,8 +286,9 @@ discard block |
||
| 276 | 286 | if (isset($_POST['postRedirect'])) |
| 277 | 287 | { |
| 278 | 288 | // Should be in the boardwide language. |
| 279 | - if ($user_info['language'] != $language) |
|
| 280 | - loadLanguage('index', $language); |
|
| 289 | + if ($user_info['language'] != $language) { |
|
| 290 | + loadLanguage('index', $language); |
|
| 291 | + } |
|
| 281 | 292 | |
| 282 | 293 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 283 | 294 | preparsecode($_POST['reason']); |
@@ -341,8 +352,9 @@ discard block |
||
| 341 | 352 | $posters = array(); |
| 342 | 353 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 343 | 354 | { |
| 344 | - if (!isset($posters[$row['id_member']])) |
|
| 345 | - $posters[$row['id_member']] = 0; |
|
| 355 | + if (!isset($posters[$row['id_member']])) { |
|
| 356 | + $posters[$row['id_member']] = 0; |
|
| 357 | + } |
|
| 346 | 358 | |
| 347 | 359 | $posters[$row['id_member']]++; |
| 348 | 360 | } |
@@ -351,11 +363,13 @@ discard block |
||
| 351 | 363 | foreach ($posters as $id_member => $posts) |
| 352 | 364 | { |
| 353 | 365 | // The board we're moving from counted posts, but not to. |
| 354 | - if (empty($pcounter_from)) |
|
| 355 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 366 | + if (empty($pcounter_from)) { |
|
| 367 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 368 | + } |
|
| 356 | 369 | // The reverse: from didn't, to did. |
| 357 | - else |
|
| 358 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 370 | + else { |
|
| 371 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 372 | + } |
|
| 359 | 373 | } |
| 360 | 374 | } |
| 361 | 375 | |
@@ -363,17 +377,19 @@ discard block |
||
| 363 | 377 | moveTopics($topic, $_POST['toboard']); |
| 364 | 378 | |
| 365 | 379 | // Log that they moved this topic. |
| 366 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 367 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 380 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 381 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 382 | + } |
|
| 368 | 383 | // Notify people that this topic has been moved? |
| 369 | 384 | sendNotifications($topic, 'move'); |
| 370 | 385 | |
| 371 | 386 | // Why not go back to the original board in case they want to keep moving? |
| 372 | - if (!isset($_REQUEST['goback'])) |
|
| 373 | - redirectexit('board=' . $board . '.0'); |
|
| 374 | - else |
|
| 375 | - redirectexit('topic=' . $topic . '.0'); |
|
| 376 | -} |
|
| 387 | + if (!isset($_REQUEST['goback'])) { |
|
| 388 | + redirectexit('board=' . $board . '.0'); |
|
| 389 | + } else { |
|
| 390 | + redirectexit('topic=' . $topic . '.0'); |
|
| 391 | + } |
|
| 392 | + } |
|
| 377 | 393 | |
| 378 | 394 | /** |
| 379 | 395 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -389,18 +405,21 @@ discard block |
||
| 389 | 405 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 390 | 406 | |
| 391 | 407 | // Empty array? |
| 392 | - if (empty($topics)) |
|
| 393 | - return; |
|
| 408 | + if (empty($topics)) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 394 | 411 | |
| 395 | 412 | // Only a single topic. |
| 396 | - if (is_numeric($topics)) |
|
| 397 | - $topics = array($topics); |
|
| 413 | + if (is_numeric($topics)) { |
|
| 414 | + $topics = array($topics); |
|
| 415 | + } |
|
| 398 | 416 | $num_topics = count($topics); |
| 399 | 417 | $fromBoards = array(); |
| 400 | 418 | |
| 401 | 419 | // Destination board empty or equal to 0? |
| 402 | - if (empty($toBoard)) |
|
| 403 | - return; |
|
| 420 | + if (empty($toBoard)) { |
|
| 421 | + return; |
|
| 422 | + } |
|
| 404 | 423 | |
| 405 | 424 | // Are we moving to the recycle board? |
| 406 | 425 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -408,8 +427,9 @@ discard block |
||
| 408 | 427 | // Callback for search APIs to do their thing |
| 409 | 428 | require_once($sourcedir . '/Search.php'); |
| 410 | 429 | $searchAPI = findSearchAPI(); |
| 411 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 412 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 430 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 431 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 432 | + } |
|
| 413 | 433 | |
| 414 | 434 | // Determine the source boards... |
| 415 | 435 | $request = $smcFunc['db_query']('', ' |
@@ -423,8 +443,9 @@ discard block |
||
| 423 | 443 | ) |
| 424 | 444 | ); |
| 425 | 445 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 426 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 427 | - return; |
|
| 446 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 447 | + return; |
|
| 448 | + } |
|
| 428 | 449 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 429 | 450 | { |
| 430 | 451 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -442,10 +463,11 @@ discard block |
||
| 442 | 463 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 443 | 464 | |
| 444 | 465 | // Add the topics to the right type. |
| 445 | - if ($row['approved']) |
|
| 446 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 447 | - else |
|
| 448 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 466 | + if ($row['approved']) { |
|
| 467 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 468 | + } else { |
|
| 469 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 470 | + } |
|
| 449 | 471 | } |
| 450 | 472 | $smcFunc['db_free_result']($request); |
| 451 | 473 | |
@@ -571,13 +593,14 @@ discard block |
||
| 571 | 593 | ) |
| 572 | 594 | ); |
| 573 | 595 | $approval_msgs = array(); |
| 574 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 575 | - $approval_msgs[] = $row['id_msg']; |
|
| 596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 597 | + $approval_msgs[] = $row['id_msg']; |
|
| 598 | + } |
|
| 576 | 599 | $smcFunc['db_free_result']($request); |
| 577 | 600 | |
| 578 | 601 | // Empty the approval queue for these, as we're going to approve them next. |
| 579 | - if (!empty($approval_msgs)) |
|
| 580 | - $smcFunc['db_query']('', ' |
|
| 602 | + if (!empty($approval_msgs)) { |
|
| 603 | + $smcFunc['db_query']('', ' |
|
| 581 | 604 | DELETE FROM {db_prefix}approval_queue |
| 582 | 605 | WHERE id_msg IN ({array_int:message_list}) |
| 583 | 606 | AND id_attach = {int:id_attach}', |
@@ -586,6 +609,7 @@ discard block |
||
| 586 | 609 | 'id_attach' => 0, |
| 587 | 610 | ) |
| 588 | 611 | ); |
| 612 | + } |
|
| 589 | 613 | |
| 590 | 614 | // Get all the current max and mins. |
| 591 | 615 | $request = $smcFunc['db_query']('', ' |
@@ -619,8 +643,8 @@ discard block |
||
| 619 | 643 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 620 | 644 | { |
| 621 | 645 | // If not, update. |
| 622 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 623 | - $smcFunc['db_query']('', ' |
|
| 646 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 647 | + $smcFunc['db_query']('', ' |
|
| 624 | 648 | UPDATE {db_prefix}topics |
| 625 | 649 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 626 | 650 | WHERE id_topic = {int:selected_topic}', |
@@ -630,6 +654,7 @@ discard block |
||
| 630 | 654 | 'selected_topic' => $row['id_topic'], |
| 631 | 655 | ) |
| 632 | 656 | ); |
| 657 | + } |
|
| 633 | 658 | } |
| 634 | 659 | $smcFunc['db_free_result']($request); |
| 635 | 660 | } |
@@ -688,9 +713,10 @@ discard block |
||
| 688 | 713 | } |
| 689 | 714 | |
| 690 | 715 | // Update the cache? |
| 691 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 692 | - foreach ($topics as $topic_id) |
|
| 716 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 717 | + foreach ($topics as $topic_id) |
|
| 693 | 718 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 719 | + } |
|
| 694 | 720 | |
| 695 | 721 | require_once($sourcedir . '/Subs-Post.php'); |
| 696 | 722 | |
@@ -714,15 +740,17 @@ discard block |
||
| 714 | 740 | { |
| 715 | 741 | global $board, $topic, $smcFunc, $scripturl; |
| 716 | 742 | |
| 717 | - if (isset($_GET['current_board'])) |
|
| 718 | - $move_from = (int) $_GET['current_board']; |
|
| 743 | + if (isset($_GET['current_board'])) { |
|
| 744 | + $move_from = (int) $_GET['current_board']; |
|
| 745 | + } |
|
| 719 | 746 | |
| 720 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 721 | - return true; |
|
| 747 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 748 | + return true; |
|
| 749 | + } |
|
| 722 | 750 | |
| 723 | - if ($move_from == $board) |
|
| 724 | - return true; |
|
| 725 | - else |
|
| 751 | + if ($move_from == $board) { |
|
| 752 | + return true; |
|
| 753 | + } else |
|
| 726 | 754 | { |
| 727 | 755 | $request = $smcFunc['db_query']('', ' |
| 728 | 756 | SELECT m.subject, b.name |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Generates the query to determine the list of available boards for a user |
@@ -25,8 +26,9 @@ discard block |
||
| 25 | 26 | { |
| 26 | 27 | global $smcFunc, $sourcedir; |
| 27 | 28 | |
| 28 | - if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) |
|
| 29 | - trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR); |
|
| 29 | + if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) { |
|
| 30 | + trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR); |
|
| 31 | + } |
|
| 30 | 32 | |
| 31 | 33 | $where = array(); |
| 32 | 34 | $where_parameters = array(); |
@@ -42,11 +44,11 @@ discard block |
||
| 42 | 44 | $where_parameters['included_boards'] = $boardListOptions['included_boards']; |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | - if (!empty($boardListOptions['ignore_boards'])) |
|
| 46 | - $where[] = '{query_wanna_see_board}'; |
|
| 47 | - |
|
| 48 | - elseif (!empty($boardListOptions['use_permissions'])) |
|
| 49 | - $where[] = '{query_see_board}'; |
|
| 47 | + if (!empty($boardListOptions['ignore_boards'])) { |
|
| 48 | + $where[] = '{query_wanna_see_board}'; |
|
| 49 | + } elseif (!empty($boardListOptions['use_permissions'])) { |
|
| 50 | + $where[] = '{query_see_board}'; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | if (!empty($boardListOptions['not_redirection'])) |
| 52 | 54 | { |
@@ -68,12 +70,13 @@ discard block |
||
| 68 | 70 | { |
| 69 | 71 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 70 | 72 | { |
| 71 | - if (!isset($return_value[$row['id_cat']])) |
|
| 72 | - $return_value[$row['id_cat']] = array( |
|
| 73 | + if (!isset($return_value[$row['id_cat']])) { |
|
| 74 | + $return_value[$row['id_cat']] = array( |
|
| 73 | 75 | 'id' => $row['id_cat'], |
| 74 | 76 | 'name' => $row['cat_name'], |
| 75 | 77 | 'boards' => array(), |
| 76 | 78 | ); |
| 79 | + } |
|
| 77 | 80 | |
| 78 | 81 | $return_value[$row['id_cat']]['boards'][$row['id_board']] = array( |
| 79 | 82 | 'id' => $row['id_board'], |
@@ -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 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
| 24 | 25 | global $time_start, $smcFunc, $modSettings; |
| 25 | 26 | |
| 26 | 27 | // Special case for doing the mail queue. |
| 27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
| 28 | - ReduceMailQueue(); |
|
| 29 | - else |
|
| 28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
| 29 | + ReduceMailQueue(); |
|
| 30 | + } else |
|
| 30 | 31 | { |
| 31 | 32 | $task_string = ''; |
| 32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
| 53 | 54 | |
| 54 | 55 | // How long in seconds it the gap? |
| 55 | 56 | $duration = $row['time_regularity']; |
| 56 | - if ($row['time_unit'] == 'm') |
|
| 57 | - $duration *= 60; |
|
| 58 | - elseif ($row['time_unit'] == 'h') |
|
| 59 | - $duration *= 3600; |
|
| 60 | - elseif ($row['time_unit'] == 'd') |
|
| 61 | - $duration *= 86400; |
|
| 62 | - elseif ($row['time_unit'] == 'w') |
|
| 63 | - $duration *= 604800; |
|
| 57 | + if ($row['time_unit'] == 'm') { |
|
| 58 | + $duration *= 60; |
|
| 59 | + } elseif ($row['time_unit'] == 'h') { |
|
| 60 | + $duration *= 3600; |
|
| 61 | + } elseif ($row['time_unit'] == 'd') { |
|
| 62 | + $duration *= 86400; |
|
| 63 | + } elseif ($row['time_unit'] == 'w') { |
|
| 64 | + $duration *= 604800; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // If we were really late running this task actually skip the next one. |
| 66 | - if (time() + ($duration / 2) > $next_time) |
|
| 67 | - $next_time += $duration; |
|
| 68 | + if (time() + ($duration / 2) > $next_time) { |
|
| 69 | + $next_time += $duration; |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Update it now, so no others run this! |
| 70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
| 81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
| 82 | 85 | |
| 83 | 86 | // What kind of task are we handling? |
| 84 | - if (!empty($row['callable'])) |
|
| 85 | - $task_string = $row['callable']; |
|
| 87 | + if (!empty($row['callable'])) { |
|
| 88 | + $task_string = $row['callable']; |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | // Default SMF task or old mods? |
| 88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 89 | - $task_string = 'scheduled_' . $row['task']; |
|
| 92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 93 | + $task_string = 'scheduled_' . $row['task']; |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | // One last resource, the task name. |
| 92 | - elseif (!empty($row['task'])) |
|
| 93 | - $task_string = $row['task']; |
|
| 97 | + elseif (!empty($row['task'])) { |
|
| 98 | + $task_string = $row['task']; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
| 96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
| 101 | 107 | $callable_task = call_helper($task_string, true); |
| 102 | 108 | |
| 103 | 109 | // Perform the task. |
| 104 | - if (!empty($callable_task)) |
|
| 105 | - $completed = call_user_func($callable_task); |
|
| 106 | - |
|
| 107 | - else |
|
| 108 | - $completed = false; |
|
| 110 | + if (!empty($callable_task)) { |
|
| 111 | + $completed = call_user_func($callable_task); |
|
| 112 | + } else { |
|
| 113 | + $completed = false; |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | // Log that we did it ;) |
| 111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
| 138 | 144 | ) |
| 139 | 145 | ); |
| 140 | 146 | // No new task scheduled yet? |
| 141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 142 | - $nextEvent = time() + 86400; |
|
| 143 | - else |
|
| 144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 148 | + $nextEvent = time() + 86400; |
|
| 149 | + } else { |
|
| 150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 151 | + } |
|
| 145 | 152 | $smcFunc['db_free_result']($request); |
| 146 | 153 | |
| 147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
| 148 | 155 | } |
| 149 | 156 | |
| 150 | 157 | // Shall we return? |
| 151 | - if (!isset($_GET['scheduled'])) |
|
| 152 | - return true; |
|
| 158 | + if (!isset($_GET['scheduled'])) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | // Finally, send some stuff... |
| 155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
| 181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 182 | 190 | { |
| 183 | 191 | // If this is no longer around we'll ignore it. |
| 184 | - if (empty($row['id_topic'])) |
|
| 185 | - continue; |
|
| 192 | + if (empty($row['id_topic'])) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 186 | 195 | |
| 187 | 196 | // What type is it? |
| 188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
| 189 | - $type = 'topic'; |
|
| 190 | - elseif ($row['id_attach']) |
|
| 191 | - $type = 'attach'; |
|
| 192 | - else |
|
| 193 | - $type = 'msg'; |
|
| 197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
| 198 | + $type = 'topic'; |
|
| 199 | + } elseif ($row['id_attach']) { |
|
| 200 | + $type = 'attach'; |
|
| 201 | + } else { |
|
| 202 | + $type = 'msg'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | // Add it to the array otherwise. |
| 196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
| 211 | 221 | ); |
| 212 | 222 | |
| 213 | 223 | // If nothing quit now. |
| 214 | - if (empty($notices)) |
|
| 215 | - return true; |
|
| 224 | + if (empty($notices)) { |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 216 | 227 | |
| 217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
| 218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
| 231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 232 | 243 | { |
| 233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
| 234 | - if ($row['id_group'] < 2) |
|
| 235 | - continue; |
|
| 245 | + if ($row['id_group'] < 2) { |
|
| 246 | + continue; |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
| 238 | 250 | |
| 239 | 251 | // Anyone who can access has to be considered. |
| 240 | - if ($row['add_deny']) |
|
| 241 | - $addGroups[] = $row['id_group']; |
|
| 252 | + if ($row['add_deny']) { |
|
| 253 | + $addGroups[] = $row['id_group']; |
|
| 254 | + } |
|
| 242 | 255 | } |
| 243 | 256 | $smcFunc['db_free_result']($request); |
| 244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | if (!empty($row['mod_prefs'])) |
| 284 | 297 | { |
| 285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
| 286 | - if (!($pref_binary & 4)) |
|
| 287 | - continue; |
|
| 299 | + if (!($pref_binary & 4)) { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | |
| 290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
| 309 | 323 | $emailbody = ''; |
| 310 | 324 | |
| 311 | 325 | // Load the language file as required. |
| 312 | - if (empty($current_language) || $current_language != $member['language']) |
|
| 313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
| 327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | // Loop through each notice... |
| 316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
| 318 | 333 | $access = false; |
| 319 | 334 | |
| 320 | 335 | // Can they mod in this board? |
| 321 | - if (isset($mods[$id][$board])) |
|
| 322 | - $access = true; |
|
| 336 | + if (isset($mods[$id][$board])) { |
|
| 337 | + $access = true; |
|
| 338 | + } |
|
| 323 | 339 | |
| 324 | 340 | // Do the group check... |
| 325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
| 326 | 342 | { |
| 327 | 343 | // They can access?! |
| 328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
| 329 | - $access = true; |
|
| 344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
| 345 | + $access = true; |
|
| 346 | + } |
|
| 330 | 347 | |
| 331 | 348 | // If they have deny rights don't consider them! |
| 332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
| 333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
| 350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 334 | 351 | $access = false; |
| 352 | + } |
|
| 335 | 353 | } |
| 336 | 354 | |
| 337 | 355 | // Finally, fix it for admins! |
| 338 | - if (in_array(1, $member['groups'])) |
|
| 339 | - $access = true; |
|
| 356 | + if (in_array(1, $member['groups'])) { |
|
| 357 | + $access = true; |
|
| 358 | + } |
|
| 340 | 359 | |
| 341 | 360 | // If they can't access it then give it a break! |
| 342 | - if (!$access) |
|
| 343 | - continue; |
|
| 361 | + if (!$access) { |
|
| 362 | + continue; |
|
| 363 | + } |
|
| 344 | 364 | |
| 345 | 365 | foreach ($notice as $type => $items) |
| 346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
| 348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
| 349 | 369 | '------------------------------------------------------' . "\n"; |
| 350 | 370 | |
| 351 | - foreach ($items as $item) |
|
| 352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 371 | + foreach ($items as $item) { |
|
| 372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 373 | + } |
|
| 353 | 374 | |
| 354 | 375 | $emailbody .= "\n"; |
| 355 | 376 | } |
| 356 | 377 | } |
| 357 | 378 | |
| 358 | - if ($emailbody == '') |
|
| 359 | - continue; |
|
| 379 | + if ($emailbody == '') { |
|
| 380 | + continue; |
|
| 381 | + } |
|
| 360 | 382 | |
| 361 | 383 | $replacements = array( |
| 362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
| 397 | 419 | ) |
| 398 | 420 | ); |
| 399 | 421 | $members = array(); |
| 400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 401 | - $members[$row['id_member']] = $row['warning']; |
|
| 422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 423 | + $members[$row['id_member']] = $row['warning']; |
|
| 424 | + } |
|
| 402 | 425 | $smcFunc['db_free_result']($request); |
| 403 | 426 | |
| 404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
| 420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 421 | 444 | { |
| 422 | 445 | // More than 24 hours ago? |
| 423 | - if ($row['last_warning'] <= time() - 86400) |
|
| 424 | - $member_changes[] = array( |
|
| 446 | + if ($row['last_warning'] <= time() - 86400) { |
|
| 447 | + $member_changes[] = array( |
|
| 425 | 448 | 'id' => $row['id_recipient'], |
| 426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
| 427 | 450 | ); |
| 451 | + } |
|
| 428 | 452 | } |
| 429 | 453 | $smcFunc['db_free_result']($request); |
| 430 | 454 | |
| 431 | 455 | // Have some members to change? |
| 432 | - if (!empty($member_changes)) |
|
| 433 | - foreach ($member_changes as $change) |
|
| 456 | + if (!empty($member_changes)) { |
|
| 457 | + foreach ($member_changes as $change) |
|
| 434 | 458 | $smcFunc['db_query']('', ' |
| 435 | 459 | UPDATE {db_prefix}members |
| 436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
| 440 | 464 | 'id_member' => $change['id'], |
| 441 | 465 | ) |
| 442 | 466 | ); |
| 467 | + } |
|
| 443 | 468 | } |
| 444 | 469 | } |
| 445 | 470 | |
@@ -452,16 +477,17 @@ discard block |
||
| 452 | 477 | |
| 453 | 478 | // Check the database version - for some buggy MySQL version. |
| 454 | 479 | $server_version = $smcFunc['db_server_info'](); |
| 455 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 456 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 457 | - elseif (!empty($modSettings['db_mysql_group_by_fix'])) |
|
| 458 | - $smcFunc['db_query']('', ' |
|
| 480 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 481 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 482 | + } elseif (!empty($modSettings['db_mysql_group_by_fix'])) { |
|
| 483 | + $smcFunc['db_query']('', ' |
|
| 459 | 484 | DELETE FROM {db_prefix}settings |
| 460 | 485 | WHERE variable = {string:mysql_fix}', |
| 461 | 486 | array( |
| 462 | 487 | 'mysql_fix' => 'db_mysql_group_by_fix', |
| 463 | 488 | ) |
| 464 | 489 | ); |
| 490 | + } |
|
| 465 | 491 | |
| 466 | 492 | // Clean up some old login history information. |
| 467 | 493 | $smcFunc['db_query']('', ' |
@@ -519,15 +545,17 @@ discard block |
||
| 519 | 545 | |
| 520 | 546 | // Store this useful data! |
| 521 | 547 | $boards[$row['id_board']] = $row['id_board']; |
| 522 | - if ($row['id_topic']) |
|
| 523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 524 | - else |
|
| 525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 548 | + if ($row['id_topic']) { |
|
| 549 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 550 | + } else { |
|
| 551 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 552 | + } |
|
| 526 | 553 | } |
| 527 | 554 | $smcFunc['db_free_result']($request); |
| 528 | 555 | |
| 529 | - if (empty($boards)) |
|
| 530 | - return true; |
|
| 556 | + if (empty($boards)) { |
|
| 557 | + return true; |
|
| 558 | + } |
|
| 531 | 559 | |
| 532 | 560 | // Just get the board names. |
| 533 | 561 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +567,14 @@ discard block |
||
| 539 | 567 | ) |
| 540 | 568 | ); |
| 541 | 569 | $boards = array(); |
| 542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 543 | - $boards[$row['id_board']] = $row['name']; |
|
| 570 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 571 | + $boards[$row['id_board']] = $row['name']; |
|
| 572 | + } |
|
| 544 | 573 | $smcFunc['db_free_result']($request); |
| 545 | 574 | |
| 546 | - if (empty($boards)) |
|
| 547 | - return true; |
|
| 575 | + if (empty($boards)) { |
|
| 576 | + return true; |
|
| 577 | + } |
|
| 548 | 578 | |
| 549 | 579 | // Get the actual topics... |
| 550 | 580 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +594,57 @@ discard block |
||
| 564 | 594 | $types = array(); |
| 565 | 595 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 566 | 596 | { |
| 567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
| 568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
| 597 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
| 598 | + $types[$row['note_type']][$row['id_board']] = array( |
|
| 569 | 599 | 'lines' => array(), |
| 570 | 600 | 'name' => $row['board_name'], |
| 571 | 601 | 'id' => $row['id_board'], |
| 572 | 602 | ); |
| 603 | + } |
|
| 573 | 604 | |
| 574 | 605 | if ($row['note_type'] == 'reply') |
| 575 | 606 | { |
| 576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 578 | - else |
|
| 579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 607 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 608 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 609 | + } else { |
|
| 610 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 580 | 611 | 'id' => $row['id_topic'], |
| 581 | 612 | 'subject' => un_htmlspecialchars($row['subject']), |
| 582 | 613 | 'count' => 1, |
| 583 | 614 | ); |
| 584 | - } |
|
| 585 | - elseif ($row['note_type'] == 'topic') |
|
| 615 | + } |
|
| 616 | + } elseif ($row['note_type'] == 'topic') |
|
| 586 | 617 | { |
| 587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 618 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 619 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 589 | 620 | 'id' => $row['id_topic'], |
| 590 | 621 | 'subject' => un_htmlspecialchars($row['subject']), |
| 591 | 622 | ); |
| 592 | - } |
|
| 593 | - else |
|
| 623 | + } |
|
| 624 | + } else |
|
| 594 | 625 | { |
| 595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 626 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 627 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 597 | 628 | 'id' => $row['id_topic'], |
| 598 | 629 | 'subject' => un_htmlspecialchars($row['subject']), |
| 599 | 630 | 'starter' => $row['id_member_started'], |
| 600 | 631 | ); |
| 632 | + } |
|
| 601 | 633 | } |
| 602 | 634 | |
| 603 | 635 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
| 604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
| 605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
| 607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 636 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
| 637 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 638 | + } |
|
| 639 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
| 640 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 641 | + } |
|
| 608 | 642 | } |
| 609 | 643 | $smcFunc['db_free_result']($request); |
| 610 | 644 | |
| 611 | - if (empty($types)) |
|
| 612 | - return true; |
|
| 645 | + if (empty($types)) { |
|
| 646 | + return true; |
|
| 647 | + } |
|
| 613 | 648 | |
| 614 | 649 | // Let's load all the languages into a cache thingy. |
| 615 | 650 | $langtxt = array(); |
@@ -651,8 +686,9 @@ discard block |
||
| 651 | 686 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
| 652 | 687 | |
| 653 | 688 | // Did they not elect to choose this? |
| 654 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
| 655 | - continue; |
|
| 689 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
| 690 | + continue; |
|
| 691 | + } |
|
| 656 | 692 | |
| 657 | 693 | // Right character set! |
| 658 | 694 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -668,39 +704,43 @@ discard block |
||
| 668 | 704 | if (isset($types['topic'])) |
| 669 | 705 | { |
| 670 | 706 | $titled = false; |
| 671 | - foreach ($types['topic'] as $id => $board) |
|
| 672 | - foreach ($board['lines'] as $topic) |
|
| 707 | + foreach ($types['topic'] as $id => $board) { |
|
| 708 | + foreach ($board['lines'] as $topic) |
|
| 673 | 709 | if (in_array($mid, $topic['members'])) |
| 674 | 710 | { |
| 675 | 711 | if (!$titled) |
| 676 | 712 | { |
| 677 | 713 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
| 714 | + } |
|
| 678 | 715 | $titled = true; |
| 679 | 716 | } |
| 680 | 717 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
| 681 | 718 | } |
| 682 | - if ($titled) |
|
| 683 | - $email['body'] .= "\n"; |
|
| 719 | + if ($titled) { |
|
| 720 | + $email['body'] .= "\n"; |
|
| 721 | + } |
|
| 684 | 722 | } |
| 685 | 723 | |
| 686 | 724 | // What about replies? |
| 687 | 725 | if (isset($types['reply'])) |
| 688 | 726 | { |
| 689 | 727 | $titled = false; |
| 690 | - foreach ($types['reply'] as $id => $board) |
|
| 691 | - foreach ($board['lines'] as $topic) |
|
| 728 | + foreach ($types['reply'] as $id => $board) { |
|
| 729 | + foreach ($board['lines'] as $topic) |
|
| 692 | 730 | if (in_array($mid, $topic['members'])) |
| 693 | 731 | { |
| 694 | 732 | if (!$titled) |
| 695 | 733 | { |
| 696 | 734 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
| 735 | + } |
|
| 697 | 736 | $titled = true; |
| 698 | 737 | } |
| 699 | 738 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
| 700 | 739 | } |
| 701 | 740 | |
| 702 | - if ($titled) |
|
| 703 | - $email['body'] .= "\n"; |
|
| 741 | + if ($titled) { |
|
| 742 | + $email['body'] .= "\n"; |
|
| 743 | + } |
|
| 704 | 744 | } |
| 705 | 745 | |
| 706 | 746 | // Finally, moderation actions! |
@@ -709,24 +749,27 @@ discard block |
||
| 709 | 749 | $titled = false; |
| 710 | 750 | foreach ($types as $note_type => $type) |
| 711 | 751 | { |
| 712 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
| 713 | - continue; |
|
| 752 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
| 753 | + continue; |
|
| 754 | + } |
|
| 714 | 755 | |
| 715 | - foreach ($type as $id => $board) |
|
| 716 | - foreach ($board['lines'] as $topic) |
|
| 756 | + foreach ($type as $id => $board) { |
|
| 757 | + foreach ($board['lines'] as $topic) |
|
| 717 | 758 | if (in_array($mid, $topic['members'])) |
| 718 | 759 | { |
| 719 | 760 | if (!$titled) |
| 720 | 761 | { |
| 721 | 762 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
| 763 | + } |
|
| 722 | 764 | $titled = true; |
| 723 | 765 | } |
| 724 | 766 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
| 725 | 767 | } |
| 726 | 768 | } |
| 727 | 769 | } |
| 728 | - if ($titled) |
|
| 729 | - $email['body'] .= "\n"; |
|
| 770 | + if ($titled) { |
|
| 771 | + $email['body'] .= "\n"; |
|
| 772 | + } |
|
| 730 | 773 | |
| 731 | 774 | // Then just say our goodbyes! |
| 732 | 775 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -754,8 +797,7 @@ discard block |
||
| 754 | 797 | 'not_daily' => 0, |
| 755 | 798 | ) |
| 756 | 799 | ); |
| 757 | - } |
|
| 758 | - else |
|
| 800 | + } else |
|
| 759 | 801 | { |
| 760 | 802 | // Clear any only weekly ones, and stop us from sending daily again. |
| 761 | 803 | $smcFunc['db_query']('', ' |
@@ -817,16 +859,19 @@ discard block |
||
| 817 | 859 | global $modSettings, $smcFunc, $sourcedir; |
| 818 | 860 | |
| 819 | 861 | // Are we intending another script to be sending out the queue? |
| 820 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
| 821 | - return false; |
|
| 862 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
| 863 | + return false; |
|
| 864 | + } |
|
| 822 | 865 | |
| 823 | 866 | // By default send 5 at once. |
| 824 | - if (!$number) |
|
| 825 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 867 | + if (!$number) { |
|
| 868 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 869 | + } |
|
| 826 | 870 | |
| 827 | 871 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
| 828 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
| 829 | - return false; |
|
| 872 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
| 873 | + return false; |
|
| 874 | + } |
|
| 830 | 875 | |
| 831 | 876 | // By default move the next sending on by 10 seconds, and require an affected row. |
| 832 | 877 | if (!$override_limit) |
@@ -843,8 +888,9 @@ discard block |
||
| 843 | 888 | 'last_send' => $modSettings['mail_next_send'], |
| 844 | 889 | ) |
| 845 | 890 | ); |
| 846 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 847 | - return false; |
|
| 891 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 892 | + return false; |
|
| 893 | + } |
|
| 848 | 894 | $modSettings['mail_next_send'] = time() + $delay; |
| 849 | 895 | } |
| 850 | 896 | |
@@ -865,8 +911,9 @@ discard block |
||
| 865 | 911 | $mn += $number; |
| 866 | 912 | } |
| 867 | 913 | // No more I'm afraid, return! |
| 868 | - else |
|
| 869 | - return false; |
|
| 914 | + else { |
|
| 915 | + return false; |
|
| 916 | + } |
|
| 870 | 917 | |
| 871 | 918 | // Reflect that we're about to send some, do it now to be safe. |
| 872 | 919 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -901,14 +948,15 @@ discard block |
||
| 901 | 948 | $smcFunc['db_free_result']($request); |
| 902 | 949 | |
| 903 | 950 | // Delete, delete, delete!!! |
| 904 | - if (!empty($ids)) |
|
| 905 | - $smcFunc['db_query']('', ' |
|
| 951 | + if (!empty($ids)) { |
|
| 952 | + $smcFunc['db_query']('', ' |
|
| 906 | 953 | DELETE FROM {db_prefix}mail_queue |
| 907 | 954 | WHERE id_mail IN ({array_int:mail_list})', |
| 908 | 955 | array( |
| 909 | 956 | 'mail_list' => $ids, |
| 910 | 957 | ) |
| 911 | 958 | ); |
| 959 | + } |
|
| 912 | 960 | |
| 913 | 961 | // Don't believe we have any left? |
| 914 | 962 | if (count($ids) < $number) |
@@ -926,11 +974,13 @@ discard block |
||
| 926 | 974 | ); |
| 927 | 975 | } |
| 928 | 976 | |
| 929 | - if (empty($ids)) |
|
| 930 | - return false; |
|
| 977 | + if (empty($ids)) { |
|
| 978 | + return false; |
|
| 979 | + } |
|
| 931 | 980 | |
| 932 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
| 933 | - require_once($sourcedir . '/Subs-Post.php'); |
|
| 981 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
| 982 | + require_once($sourcedir . '/Subs-Post.php'); |
|
| 983 | + } |
|
| 934 | 984 | |
| 935 | 985 | // Send each email, yea! |
| 936 | 986 | $failed_emails = array(); |
@@ -950,15 +1000,17 @@ discard block |
||
| 950 | 1000 | |
| 951 | 1001 | // Try to stop a timeout, this would be bad... |
| 952 | 1002 | @set_time_limit(300); |
| 953 | - if (function_exists('apache_reset_timeout')) |
|
| 954 | - @apache_reset_timeout(); |
|
| 1003 | + if (function_exists('apache_reset_timeout')) { |
|
| 1004 | + @apache_reset_timeout(); |
|
| 1005 | + } |
|
| 1006 | + } else { |
|
| 1007 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 955 | 1008 | } |
| 956 | - else |
|
| 957 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 958 | 1009 | |
| 959 | 1010 | // Hopefully it sent? |
| 960 | - if (!$result) |
|
| 961 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 1011 | + if (!$result) { |
|
| 1012 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 1013 | + } |
|
| 962 | 1014 | } |
| 963 | 1015 | |
| 964 | 1016 | // Any emails that didn't send? |
@@ -973,8 +1025,8 @@ discard block |
||
| 973 | 1025 | ); |
| 974 | 1026 | |
| 975 | 1027 | // If we have failed to many times, tell mail to wait a bit and try again. |
| 976 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
| 977 | - $smcFunc['db_query']('', ' |
|
| 1028 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
| 1029 | + $smcFunc['db_query']('', ' |
|
| 978 | 1030 | UPDATE {db_prefix}settings |
| 979 | 1031 | SET value = {string:next_mail_send} |
| 980 | 1032 | WHERE variable = {literal:mail_next_send} |
@@ -983,6 +1035,7 @@ discard block |
||
| 983 | 1035 | 'next_mail_send' => time() + 60, |
| 984 | 1036 | 'last_send' => $modSettings['mail_next_send'], |
| 985 | 1037 | )); |
| 1038 | + } |
|
| 986 | 1039 | |
| 987 | 1040 | // Add our email back to the queue, manually. |
| 988 | 1041 | $smcFunc['db_insert']('insert', |
@@ -995,8 +1048,8 @@ discard block |
||
| 995 | 1048 | return false; |
| 996 | 1049 | } |
| 997 | 1050 | // We where unable to send the email, clear our failed attempts. |
| 998 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
| 999 | - $smcFunc['db_query']('', ' |
|
| 1051 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
| 1052 | + $smcFunc['db_query']('', ' |
|
| 1000 | 1053 | UPDATE {db_prefix}settings |
| 1001 | 1054 | SET value = {string:zero} |
| 1002 | 1055 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1004,6 +1057,7 @@ discard block |
||
| 1004 | 1057 | 'zero' => '0', |
| 1005 | 1058 | 'mail_failed_attempts' => 'mail_failed_attempts', |
| 1006 | 1059 | )); |
| 1060 | + } |
|
| 1007 | 1061 | |
| 1008 | 1062 | // Had something to send... |
| 1009 | 1063 | return true; |
@@ -1020,16 +1074,18 @@ discard block |
||
| 1020 | 1074 | global $modSettings, $smcFunc; |
| 1021 | 1075 | |
| 1022 | 1076 | $task_query = ''; |
| 1023 | - if (!is_array($tasks)) |
|
| 1024 | - $tasks = array($tasks); |
|
| 1077 | + if (!is_array($tasks)) { |
|
| 1078 | + $tasks = array($tasks); |
|
| 1079 | + } |
|
| 1025 | 1080 | |
| 1026 | 1081 | // Actually have something passed? |
| 1027 | 1082 | if (!empty($tasks)) |
| 1028 | 1083 | { |
| 1029 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
| 1030 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1031 | - else |
|
| 1032 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1084 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
| 1085 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1086 | + } else { |
|
| 1087 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1088 | + } |
|
| 1033 | 1089 | } |
| 1034 | 1090 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
| 1035 | 1091 | |
@@ -1050,20 +1106,22 @@ discard block |
||
| 1050 | 1106 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
| 1051 | 1107 | |
| 1052 | 1108 | // Only bother moving the task if it's out of place or we're forcing it! |
| 1053 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
| 1054 | - $tasks[$row['id_task']] = $next_time; |
|
| 1055 | - else |
|
| 1056 | - $next_time = $row['next_time']; |
|
| 1109 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
| 1110 | + $tasks[$row['id_task']] = $next_time; |
|
| 1111 | + } else { |
|
| 1112 | + $next_time = $row['next_time']; |
|
| 1113 | + } |
|
| 1057 | 1114 | |
| 1058 | 1115 | // If this is sooner than the current next task, make this the next task. |
| 1059 | - if ($next_time < $nextTaskTime) |
|
| 1060 | - $nextTaskTime = $next_time; |
|
| 1116 | + if ($next_time < $nextTaskTime) { |
|
| 1117 | + $nextTaskTime = $next_time; |
|
| 1118 | + } |
|
| 1061 | 1119 | } |
| 1062 | 1120 | $smcFunc['db_free_result']($request); |
| 1063 | 1121 | |
| 1064 | 1122 | // Now make the changes! |
| 1065 | - foreach ($tasks as $id => $time) |
|
| 1066 | - $smcFunc['db_query']('', ' |
|
| 1123 | + foreach ($tasks as $id => $time) { |
|
| 1124 | + $smcFunc['db_query']('', ' |
|
| 1067 | 1125 | UPDATE {db_prefix}scheduled_tasks |
| 1068 | 1126 | SET next_time = {int:next_time} |
| 1069 | 1127 | WHERE id_task = {int:id_task}', |
@@ -1072,11 +1130,13 @@ discard block |
||
| 1072 | 1130 | 'id_task' => $id, |
| 1073 | 1131 | ) |
| 1074 | 1132 | ); |
| 1133 | + } |
|
| 1075 | 1134 | |
| 1076 | 1135 | // If the next task is now different update. |
| 1077 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
| 1078 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1079 | -} |
|
| 1136 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
| 1137 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1138 | + } |
|
| 1139 | + } |
|
| 1080 | 1140 | |
| 1081 | 1141 | /** |
| 1082 | 1142 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1089,8 +1149,9 @@ discard block |
||
| 1089 | 1149 | function next_time($regularity, $unit, $offset) |
| 1090 | 1150 | { |
| 1091 | 1151 | // Just in case! |
| 1092 | - if ($regularity == 0) |
|
| 1093 | - $regularity = 2; |
|
| 1152 | + if ($regularity == 0) { |
|
| 1153 | + $regularity = 2; |
|
| 1154 | + } |
|
| 1094 | 1155 | |
| 1095 | 1156 | $curHour = date('H', time()); |
| 1096 | 1157 | $curMin = date('i', time()); |
@@ -1102,15 +1163,16 @@ discard block |
||
| 1102 | 1163 | $off = date('i', $offset); |
| 1103 | 1164 | |
| 1104 | 1165 | // If it's now just pretend it ain't, |
| 1105 | - if ($off == $curMin) |
|
| 1106 | - $next_time = time() + $regularity; |
|
| 1107 | - else |
|
| 1166 | + if ($off == $curMin) { |
|
| 1167 | + $next_time = time() + $regularity; |
|
| 1168 | + } else |
|
| 1108 | 1169 | { |
| 1109 | 1170 | // Make sure that the offset is always in the past. |
| 1110 | 1171 | $off = $off > $curMin ? $off - 60 : $off; |
| 1111 | 1172 | |
| 1112 | - while ($off <= $curMin) |
|
| 1113 | - $off += $regularity; |
|
| 1173 | + while ($off <= $curMin) { |
|
| 1174 | + $off += $regularity; |
|
| 1175 | + } |
|
| 1114 | 1176 | |
| 1115 | 1177 | // Now we know when the time should be! |
| 1116 | 1178 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1130,11 +1192,13 @@ discard block |
||
| 1130 | 1192 | // Default we'll jump in hours. |
| 1131 | 1193 | $applyOffset = 3600; |
| 1132 | 1194 | // 24 hours = 1 day. |
| 1133 | - if ($unit == 'd') |
|
| 1134 | - $applyOffset = 86400; |
|
| 1195 | + if ($unit == 'd') { |
|
| 1196 | + $applyOffset = 86400; |
|
| 1197 | + } |
|
| 1135 | 1198 | // Otherwise a week. |
| 1136 | - if ($unit == 'w') |
|
| 1137 | - $applyOffset = 604800; |
|
| 1199 | + if ($unit == 'w') { |
|
| 1200 | + $applyOffset = 604800; |
|
| 1201 | + } |
|
| 1138 | 1202 | |
| 1139 | 1203 | $applyOffset *= $regularity; |
| 1140 | 1204 | |
@@ -1171,8 +1235,9 @@ discard block |
||
| 1171 | 1235 | $settings[$row['variable']] = $row['value']; |
| 1172 | 1236 | |
| 1173 | 1237 | // Is this the default theme? |
| 1174 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
| 1175 | - $settings['default_' . $row['variable']] = $row['value']; |
|
| 1238 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
| 1239 | + $settings['default_' . $row['variable']] = $row['value']; |
|
| 1240 | + } |
|
| 1176 | 1241 | } |
| 1177 | 1242 | $smcFunc['db_free_result']($result); |
| 1178 | 1243 | |
@@ -1182,12 +1247,14 @@ discard block |
||
| 1182 | 1247 | $settings['template_dirs'] = array($settings['theme_dir']); |
| 1183 | 1248 | |
| 1184 | 1249 | // Based on theme (if there is one). |
| 1185 | - if (!empty($settings['base_theme_dir'])) |
|
| 1186 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1250 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1251 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1252 | + } |
|
| 1187 | 1253 | |
| 1188 | 1254 | // Lastly the default theme. |
| 1189 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1190 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1255 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1256 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1257 | + } |
|
| 1191 | 1258 | } |
| 1192 | 1259 | |
| 1193 | 1260 | // Assume we want this. |
@@ -1333,8 +1400,9 @@ discard block |
||
| 1333 | 1400 | // Ok should we prune the logs? |
| 1334 | 1401 | if (!empty($modSettings['pruningOptions'])) |
| 1335 | 1402 | { |
| 1336 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
| 1337 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1403 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
| 1404 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1405 | + } |
|
| 1338 | 1406 | |
| 1339 | 1407 | if (!empty($modSettings['pruneErrorLog'])) |
| 1340 | 1408 | { |
@@ -1400,8 +1468,9 @@ discard block |
||
| 1400 | 1468 | ) |
| 1401 | 1469 | ); |
| 1402 | 1470 | |
| 1403 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
| 1404 | - $reports[] = $row[0]; |
|
| 1471 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
| 1472 | + $reports[] = $row[0]; |
|
| 1473 | + } |
|
| 1405 | 1474 | |
| 1406 | 1475 | $smcFunc['db_free_result']($result); |
| 1407 | 1476 | |
@@ -1563,8 +1632,9 @@ discard block |
||
| 1563 | 1632 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
| 1564 | 1633 | |
| 1565 | 1634 | // Send the actual email. |
| 1566 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
| 1567 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1635 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
| 1636 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1637 | + } |
|
| 1568 | 1638 | |
| 1569 | 1639 | if ($notifyPrefs[$row['id_member']] & 0x01) |
| 1570 | 1640 | { |
@@ -1587,18 +1657,19 @@ discard block |
||
| 1587 | 1657 | } |
| 1588 | 1658 | |
| 1589 | 1659 | // Insert the alerts if any |
| 1590 | - if (!empty($alert_rows)) |
|
| 1591 | - $smcFunc['db_insert']('', |
|
| 1660 | + if (!empty($alert_rows)) { |
|
| 1661 | + $smcFunc['db_insert']('', |
|
| 1592 | 1662 | '{db_prefix}user_alerts', |
| 1593 | 1663 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 1594 | 1664 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 1595 | 1665 | $alert_rows, |
| 1596 | 1666 | array() |
| 1597 | 1667 | ); |
| 1668 | + } |
|
| 1598 | 1669 | |
| 1599 | 1670 | // Mark the reminder as sent. |
| 1600 | - if (!empty($subs_reminded)) |
|
| 1601 | - $smcFunc['db_query']('', ' |
|
| 1671 | + if (!empty($subs_reminded)) { |
|
| 1672 | + $smcFunc['db_query']('', ' |
|
| 1602 | 1673 | UPDATE {db_prefix}log_subscribed |
| 1603 | 1674 | SET reminder_sent = {int:reminder_sent} |
| 1604 | 1675 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1607,6 +1678,7 @@ discard block |
||
| 1607 | 1678 | 'reminder_sent' => 1, |
| 1608 | 1679 | ) |
| 1609 | 1680 | ); |
| 1681 | + } |
|
| 1610 | 1682 | |
| 1611 | 1683 | return true; |
| 1612 | 1684 | } |
@@ -1622,13 +1694,13 @@ discard block |
||
| 1622 | 1694 | // We need to know where this thing is going. |
| 1623 | 1695 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 1624 | 1696 | { |
| 1625 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 1626 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 1697 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 1698 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 1699 | + } |
|
| 1627 | 1700 | |
| 1628 | 1701 | // Just use the current path for temp files. |
| 1629 | 1702 | $attach_dirs = $modSettings['attachmentUploadDir']; |
| 1630 | - } |
|
| 1631 | - else |
|
| 1703 | + } else |
|
| 1632 | 1704 | { |
| 1633 | 1705 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
| 1634 | 1706 | } |
@@ -1647,14 +1719,16 @@ discard block |
||
| 1647 | 1719 | |
| 1648 | 1720 | while ($file = readdir($dir)) |
| 1649 | 1721 | { |
| 1650 | - if ($file == '.' || $file == '..') |
|
| 1651 | - continue; |
|
| 1722 | + if ($file == '.' || $file == '..') { |
|
| 1723 | + continue; |
|
| 1724 | + } |
|
| 1652 | 1725 | |
| 1653 | 1726 | if (strpos($file, 'post_tmp_') !== false) |
| 1654 | 1727 | { |
| 1655 | 1728 | // Temp file is more than 5 hours old! |
| 1656 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1657 | - @unlink($attach_dir . '/' . $file); |
|
| 1729 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1730 | + @unlink($attach_dir . '/' . $file); |
|
| 1731 | + } |
|
| 1658 | 1732 | } |
| 1659 | 1733 | } |
| 1660 | 1734 | closedir($dir); |
@@ -1687,8 +1761,9 @@ discard block |
||
| 1687 | 1761 | ) |
| 1688 | 1762 | ); |
| 1689 | 1763 | |
| 1690 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1691 | - $topics[] = $row[0]; |
|
| 1764 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1765 | + $topics[] = $row[0]; |
|
| 1766 | + } |
|
| 1692 | 1767 | $smcFunc['db_free_result']($request); |
| 1693 | 1768 | |
| 1694 | 1769 | // Zap, your gone |
@@ -1708,8 +1783,9 @@ discard block |
||
| 1708 | 1783 | { |
| 1709 | 1784 | global $smcFunc, $sourcedir, $modSettings; |
| 1710 | 1785 | |
| 1711 | - if (empty($modSettings['drafts_keep_days'])) |
|
| 1712 | - return true; |
|
| 1786 | + if (empty($modSettings['drafts_keep_days'])) { |
|
| 1787 | + return true; |
|
| 1788 | + } |
|
| 1713 | 1789 | |
| 1714 | 1790 | // init |
| 1715 | 1791 | $drafts = array(); |
@@ -1727,8 +1803,9 @@ discard block |
||
| 1727 | 1803 | ) |
| 1728 | 1804 | ); |
| 1729 | 1805 | |
| 1730 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1731 | - $drafts[] = (int) $row[0]; |
|
| 1806 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1807 | + $drafts[] = (int) $row[0]; |
|
| 1808 | + } |
|
| 1732 | 1809 | $smcFunc['db_free_result']($request); |
| 1733 | 1810 | |
| 1734 | 1811 | // If we have old one, remove them |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,28 +24,32 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_search_query' => 'smf_db_search_query', |
| 29 | 30 | 'db_search_support' => 'smf_db_search_support', |
| 30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
| 31 | 32 | 'db_support_ignore' => false, |
| 32 | 33 | ); |
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | db_extend(); |
| 35 | 37 | |
| 36 | 38 | //pg 9.5 got ignore support |
| 37 | 39 | $version = $smcFunc['db_get_version'](); |
| 38 | 40 | // if we got a Beta Version |
| 39 | - if (stripos($version, 'beta') !== false) |
|
| 40 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
| 41 | + if (stripos($version, 'beta') !== false) { |
|
| 42 | + $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
| 43 | + } |
|
| 41 | 44 | // or RC |
| 42 | - if (stripos($version, 'rc') !== false) |
|
| 43 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
| 45 | + if (stripos($version, 'rc') !== false) { |
|
| 46 | + $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
| 47 | + } |
|
| 44 | 48 | |
| 45 | - if (version_compare($version,'9.5.0','>=')) |
|
| 46 | - $smcFunc['db_support_ignore'] = true; |
|
| 47 | -} |
|
| 49 | + if (version_compare($version,'9.5.0','>=')) { |
|
| 50 | + $smcFunc['db_support_ignore'] = true; |
|
| 51 | + } |
|
| 52 | + } |
|
| 48 | 53 | |
| 49 | 54 | /** |
| 50 | 55 | * This function will tell you whether this database type supports this search type. |
@@ -103,16 +108,16 @@ discard block |
||
| 103 | 108 | ), |
| 104 | 109 | ); |
| 105 | 110 | |
| 106 | - if (isset($replacements[$identifier])) |
|
| 107 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 111 | + if (isset($replacements[$identifier])) { |
|
| 112 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 113 | + } |
|
| 108 | 114 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
| 109 | 115 | { |
| 110 | 116 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
| 111 | 117 | if ($smcFunc['db_support_ignore']){ |
| 112 | 118 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
| 113 | 119 | $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
| 114 | - } |
|
| 115 | - else |
|
| 120 | + } else |
|
| 116 | 121 | { |
| 117 | 122 | // Don't error on multi-insert. |
| 118 | 123 | $db_values['db_error_skip'] = true; |
@@ -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 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
| 120 | 121 | } |
| 121 | 122 | |
| 122 | 123 | // Create a date string so we don't overload them with date info. |
| 123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
| 125 | - else |
|
| 126 | - $context['ban_time_format'] = $matches[0]; |
|
| 124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
| 126 | + } else { |
|
| 127 | + $context['ban_time_format'] = $matches[0]; |
|
| 128 | + } |
|
| 127 | 129 | |
| 128 | 130 | $listOptions = array( |
| 129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
| 201 | 203 | 'function' => function ($rowData) use ($txt) |
| 202 | 204 | { |
| 203 | 205 | // This ban never expires...whahaha. |
| 204 | - if ($rowData['expire_time'] === null) |
|
| 205 | - return $txt['never']; |
|
| 206 | + if ($rowData['expire_time'] === null) { |
|
| 207 | + return $txt['never']; |
|
| 208 | + } |
|
| 206 | 209 | |
| 207 | 210 | // This ban has already expired. |
| 208 | - elseif ($rowData['expire_time'] < time()) |
|
| 209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 211 | + elseif ($rowData['expire_time'] < time()) { |
|
| 212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 213 | + } |
|
| 210 | 214 | |
| 211 | 215 | // Still need to wait a few days for this ban to expire. |
| 212 | - else |
|
| 213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 216 | + else { |
|
| 217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 218 | + } |
|
| 214 | 219 | }, |
| 215 | 220 | ), |
| 216 | 221 | 'sort' => array( |
@@ -309,8 +314,9 @@ discard block |
||
| 309 | 314 | ) |
| 310 | 315 | ); |
| 311 | 316 | $bans = array(); |
| 312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 313 | - $bans[] = $row; |
|
| 317 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 318 | + $bans[] = $row; |
|
| 319 | + } |
|
| 314 | 320 | |
| 315 | 321 | $smcFunc['db_free_result']($request); |
| 316 | 322 | |
@@ -352,8 +358,9 @@ discard block |
||
| 352 | 358 | { |
| 353 | 359 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
| 354 | 360 | |
| 355 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
| 356 | - BanEdit2(); |
|
| 361 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
| 362 | + BanEdit2(); |
|
| 363 | + } |
|
| 357 | 364 | |
| 358 | 365 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
| 359 | 366 | |
@@ -364,10 +371,10 @@ discard block |
||
| 364 | 371 | |
| 365 | 372 | if (!empty($context['ban_errors'])) |
| 366 | 373 | { |
| 367 | - foreach ($context['ban_errors'] as $error) |
|
| 368 | - $context['error_messages'][$error] = $txt[$error]; |
|
| 369 | - } |
|
| 370 | - else |
|
| 374 | + foreach ($context['ban_errors'] as $error) { |
|
| 375 | + $context['error_messages'][$error] = $txt[$error]; |
|
| 376 | + } |
|
| 377 | + } else |
|
| 371 | 378 | { |
| 372 | 379 | // If we're editing an existing ban, get it from the database. |
| 373 | 380 | if (!empty($ban_group_id)) |
@@ -403,12 +410,13 @@ discard block |
||
| 403 | 410 | 'data' => array( |
| 404 | 411 | 'function' => function ($ban_item) use ($txt) |
| 405 | 412 | { |
| 406 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
| 407 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 408 | - elseif ($ban_item['type'] == 'user') |
|
| 409 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 410 | - else |
|
| 411 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 413 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
| 414 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 415 | + } elseif ($ban_item['type'] == 'user') { |
|
| 416 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 417 | + } else { |
|
| 418 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 419 | + } |
|
| 412 | 420 | }, |
| 413 | 421 | 'style' => 'text-align: left;', |
| 414 | 422 | ), |
@@ -546,8 +554,9 @@ discard block |
||
| 546 | 554 | $context['ban']['from_user'] = true; |
| 547 | 555 | |
| 548 | 556 | // Would be nice if we could also ban the hostname. |
| 549 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
| 550 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 557 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
| 558 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 559 | + } |
|
| 551 | 560 | |
| 552 | 561 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
| 553 | 562 | } |
@@ -615,8 +624,9 @@ discard block |
||
| 615 | 624 | 'items_per_page' => $items_per_page, |
| 616 | 625 | ) |
| 617 | 626 | ); |
| 618 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 619 | - fatal_lang_error('ban_not_found', false); |
|
| 627 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 628 | + fatal_lang_error('ban_not_found', false); |
|
| 629 | + } |
|
| 620 | 630 | |
| 621 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 622 | 632 | { |
@@ -653,18 +663,15 @@ discard block |
||
| 653 | 663 | { |
| 654 | 664 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
| 655 | 665 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
| 656 | - } |
|
| 657 | - elseif (!empty($row['hostname'])) |
|
| 666 | + } elseif (!empty($row['hostname'])) |
|
| 658 | 667 | { |
| 659 | 668 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 660 | 669 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
| 661 | - } |
|
| 662 | - elseif (!empty($row['email_address'])) |
|
| 670 | + } elseif (!empty($row['email_address'])) |
|
| 663 | 671 | { |
| 664 | 672 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 665 | 673 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
| 666 | - } |
|
| 667 | - elseif (!empty($row['id_member'])) |
|
| 674 | + } elseif (!empty($row['id_member'])) |
|
| 668 | 675 | { |
| 669 | 676 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 670 | 677 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -730,9 +737,10 @@ discard block |
||
| 730 | 737 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
| 731 | 738 | |
| 732 | 739 | $return = array(); |
| 733 | - foreach ($search_list as $key => $callable) |
|
| 734 | - if (is_callable($callable)) |
|
| 740 | + foreach ($search_list as $key => $callable) { |
|
| 741 | + if (is_callable($callable)) |
|
| 735 | 742 | $return[$key] = call_user_func($callable, $member_id); |
| 743 | + } |
|
| 736 | 744 | |
| 737 | 745 | return $return; |
| 738 | 746 | } |
@@ -757,8 +765,9 @@ discard block |
||
| 757 | 765 | 'current_user' => $member_id, |
| 758 | 766 | ) |
| 759 | 767 | ); |
| 760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 761 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 768 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 769 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 770 | + } |
|
| 762 | 771 | $smcFunc['db_free_result']($request); |
| 763 | 772 | |
| 764 | 773 | return $message_ips; |
@@ -783,8 +792,9 @@ discard block |
||
| 783 | 792 | 'current_user' => $member_id, |
| 784 | 793 | ) |
| 785 | 794 | ); |
| 786 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 787 | - $error_ips[] = inet_dtop($row['ip']); |
|
| 795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 796 | + $error_ips[] = inet_dtop($row['ip']); |
|
| 797 | + } |
|
| 788 | 798 | $smcFunc['db_free_result']($request); |
| 789 | 799 | |
| 790 | 800 | return $error_ips; |
@@ -825,11 +835,13 @@ discard block |
||
| 825 | 835 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
| 826 | 836 | |
| 827 | 837 | // Adding a new ban group |
| 828 | - if (empty($_REQUEST['bg'])) |
|
| 829 | - $ban_group_id = insertBanGroup($ban_info); |
|
| 838 | + if (empty($_REQUEST['bg'])) { |
|
| 839 | + $ban_group_id = insertBanGroup($ban_info); |
|
| 840 | + } |
|
| 830 | 841 | // Editing an existing ban group |
| 831 | - else |
|
| 832 | - $ban_group_id = updateBanGroup($ban_info); |
|
| 842 | + else { |
|
| 843 | + $ban_group_id = updateBanGroup($ban_info); |
|
| 844 | + } |
|
| 833 | 845 | |
| 834 | 846 | if (is_numeric($ban_group_id)) |
| 835 | 847 | { |
@@ -840,9 +852,10 @@ discard block |
||
| 840 | 852 | $context['ban'] = $ban_info; |
| 841 | 853 | } |
| 842 | 854 | |
| 843 | - if (isset($_POST['ban_suggestions'])) |
|
| 844 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
| 855 | + if (isset($_POST['ban_suggestions'])) { |
|
| 856 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
| 845 | 857 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
| 858 | + } |
|
| 846 | 859 | |
| 847 | 860 | // Something went wrong somewhere... Oh well, let's go back. |
| 848 | 861 | if (!empty($context['ban_errors'])) |
@@ -852,8 +865,9 @@ discard block |
||
| 852 | 865 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
| 853 | 866 | |
| 854 | 867 | // Not strictly necessary, but it's nice |
| 855 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
| 856 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 868 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
| 869 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 870 | + } |
|
| 857 | 871 | return BanEdit(); |
| 858 | 872 | } |
| 859 | 873 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -902,10 +916,11 @@ discard block |
||
| 902 | 916 | |
| 903 | 917 | foreach ($suggestions as $key => $value) |
| 904 | 918 | { |
| 905 | - if (is_array($value)) |
|
| 906 | - $triggers[$key] = $value; |
|
| 907 | - else |
|
| 908 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 919 | + if (is_array($value)) { |
|
| 920 | + $triggers[$key] = $value; |
|
| 921 | + } else { |
|
| 922 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 923 | + } |
|
| 909 | 924 | } |
| 910 | 925 | |
| 911 | 926 | $ban_triggers = validateTriggers($triggers); |
@@ -913,16 +928,18 @@ discard block |
||
| 913 | 928 | // Time to save! |
| 914 | 929 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
| 915 | 930 | { |
| 916 | - if (empty($ban_id)) |
|
| 917 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 918 | - else |
|
| 919 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 931 | + if (empty($ban_id)) { |
|
| 932 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 933 | + } else { |
|
| 934 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 935 | + } |
|
| 936 | + } |
|
| 937 | + if (!empty($context['ban_errors'])) { |
|
| 938 | + return $triggers; |
|
| 939 | + } else { |
|
| 940 | + return false; |
|
| 941 | + } |
|
| 920 | 942 | } |
| 921 | - if (!empty($context['ban_errors'])) |
|
| 922 | - return $triggers; |
|
| 923 | - else |
|
| 924 | - return false; |
|
| 925 | -} |
|
| 926 | 943 | |
| 927 | 944 | /** |
| 928 | 945 | * This function removes a bunch of triggers based on ids |
@@ -936,14 +953,17 @@ discard block |
||
| 936 | 953 | { |
| 937 | 954 | global $smcFunc, $scripturl; |
| 938 | 955 | |
| 939 | - if ($group_id !== false) |
|
| 940 | - $group_id = (int) $group_id; |
|
| 956 | + if ($group_id !== false) { |
|
| 957 | + $group_id = (int) $group_id; |
|
| 958 | + } |
|
| 941 | 959 | |
| 942 | - if (empty($group_id) && empty($items_ids)) |
|
| 943 | - return false; |
|
| 960 | + if (empty($group_id) && empty($items_ids)) { |
|
| 961 | + return false; |
|
| 962 | + } |
|
| 944 | 963 | |
| 945 | - if (!is_array($items_ids)) |
|
| 946 | - $items_ids = array($items_ids); |
|
| 964 | + if (!is_array($items_ids)) { |
|
| 965 | + $items_ids = array($items_ids); |
|
| 966 | + } |
|
| 947 | 967 | |
| 948 | 968 | $log_info = array(); |
| 949 | 969 | $ban_items = array(); |
@@ -981,8 +1001,7 @@ discard block |
||
| 981 | 1001 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
| 982 | 1002 | 'value' => $ban_items[$row['id_ban']]['ip'], |
| 983 | 1003 | ); |
| 984 | - } |
|
| 985 | - elseif (!empty($row['hostname'])) |
|
| 1004 | + } elseif (!empty($row['hostname'])) |
|
| 986 | 1005 | { |
| 987 | 1006 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 988 | 1007 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -990,8 +1009,7 @@ discard block |
||
| 990 | 1009 | 'bantype' => 'hostname', |
| 991 | 1010 | 'value' => $row['hostname'], |
| 992 | 1011 | ); |
| 993 | - } |
|
| 994 | - elseif (!empty($row['email_address'])) |
|
| 1012 | + } elseif (!empty($row['email_address'])) |
|
| 995 | 1013 | { |
| 996 | 1014 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 997 | 1015 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -999,8 +1017,7 @@ discard block |
||
| 999 | 1017 | 'bantype' => 'email', |
| 1000 | 1018 | 'value' => $ban_items[$row['id_ban']]['email'], |
| 1001 | 1019 | ); |
| 1002 | - } |
|
| 1003 | - elseif (!empty($row['id_member'])) |
|
| 1020 | + } elseif (!empty($row['id_member'])) |
|
| 1004 | 1021 | { |
| 1005 | 1022 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 1006 | 1023 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1033,8 +1050,7 @@ discard block |
||
| 1033 | 1050 | 'ban_group' => $group_id, |
| 1034 | 1051 | ) |
| 1035 | 1052 | ); |
| 1036 | - } |
|
| 1037 | - elseif (!empty($items_ids)) |
|
| 1053 | + } elseif (!empty($items_ids)) |
|
| 1038 | 1054 | { |
| 1039 | 1055 | $smcFunc['db_query']('', ' |
| 1040 | 1056 | DELETE FROM {db_prefix}ban_items |
@@ -1059,13 +1075,15 @@ discard block |
||
| 1059 | 1075 | { |
| 1060 | 1076 | global $smcFunc; |
| 1061 | 1077 | |
| 1062 | - if (!is_array($group_ids)) |
|
| 1063 | - $group_ids = array($group_ids); |
|
| 1078 | + if (!is_array($group_ids)) { |
|
| 1079 | + $group_ids = array($group_ids); |
|
| 1080 | + } |
|
| 1064 | 1081 | |
| 1065 | 1082 | $group_ids = array_unique($group_ids); |
| 1066 | 1083 | |
| 1067 | - if (empty($group_ids)) |
|
| 1068 | - return false; |
|
| 1084 | + if (empty($group_ids)) { |
|
| 1085 | + return false; |
|
| 1086 | + } |
|
| 1069 | 1087 | |
| 1070 | 1088 | $smcFunc['db_query']('', ' |
| 1071 | 1089 | DELETE FROM {db_prefix}ban_groups |
@@ -1089,21 +1107,23 @@ discard block |
||
| 1089 | 1107 | { |
| 1090 | 1108 | global $smcFunc; |
| 1091 | 1109 | |
| 1092 | - if (empty($ids)) |
|
| 1093 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1110 | + if (empty($ids)) { |
|
| 1111 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1094 | 1112 | TRUNCATE {db_prefix}log_banned', |
| 1095 | 1113 | array( |
| 1096 | 1114 | ) |
| 1097 | 1115 | ); |
| 1098 | - else |
|
| 1116 | + } else |
|
| 1099 | 1117 | { |
| 1100 | - if (!is_array($ids)) |
|
| 1101 | - $ids = array($ids); |
|
| 1118 | + if (!is_array($ids)) { |
|
| 1119 | + $ids = array($ids); |
|
| 1120 | + } |
|
| 1102 | 1121 | |
| 1103 | 1122 | $ids = array_unique($ids); |
| 1104 | 1123 | |
| 1105 | - if (empty($ids)) |
|
| 1106 | - return false; |
|
| 1124 | + if (empty($ids)) { |
|
| 1125 | + return false; |
|
| 1126 | + } |
|
| 1107 | 1127 | |
| 1108 | 1128 | $smcFunc['db_query']('', ' |
| 1109 | 1129 | DELETE FROM {db_prefix}log_banned |
@@ -1129,8 +1149,9 @@ discard block |
||
| 1129 | 1149 | { |
| 1130 | 1150 | global $context, $smcFunc; |
| 1131 | 1151 | |
| 1132 | - if (empty($triggers)) |
|
| 1133 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1152 | + if (empty($triggers)) { |
|
| 1153 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1154 | + } |
|
| 1134 | 1155 | |
| 1135 | 1156 | $ban_triggers = array(); |
| 1136 | 1157 | $log_info = array(); |
@@ -1139,39 +1160,39 @@ discard block |
||
| 1139 | 1160 | { |
| 1140 | 1161 | if (!empty($value)) |
| 1141 | 1162 | { |
| 1142 | - if ($key == 'member') |
|
| 1143 | - continue; |
|
| 1163 | + if ($key == 'member') { |
|
| 1164 | + continue; |
|
| 1165 | + } |
|
| 1144 | 1166 | |
| 1145 | 1167 | if ($key == 'main_ip') |
| 1146 | 1168 | { |
| 1147 | 1169 | $value = trim($value); |
| 1148 | 1170 | $ip_parts = ip2range($value); |
| 1149 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
| 1150 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1151 | - else |
|
| 1171 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
| 1172 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1173 | + } else |
|
| 1152 | 1174 | { |
| 1153 | 1175 | $ban_triggers['main_ip'] = array( |
| 1154 | 1176 | 'ip_low' => $ip_parts['low'], |
| 1155 | 1177 | 'ip_high' => $ip_parts['high'] |
| 1156 | 1178 | ); |
| 1157 | 1179 | } |
| 1158 | - } |
|
| 1159 | - elseif ($key == 'hostname') |
|
| 1180 | + } elseif ($key == 'hostname') |
|
| 1160 | 1181 | { |
| 1161 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
| 1162 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1163 | - else |
|
| 1182 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
| 1183 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1184 | + } else |
|
| 1164 | 1185 | { |
| 1165 | 1186 | // Replace the * wildcard by a MySQL wildcard %. |
| 1166 | 1187 | $value = substr(str_replace('*', '%', $value), 0, 255); |
| 1167 | 1188 | |
| 1168 | 1189 | $ban_triggers['hostname']['hostname'] = $value; |
| 1169 | 1190 | } |
| 1170 | - } |
|
| 1171 | - elseif ($key == 'email') |
|
| 1191 | + } elseif ($key == 'email') |
|
| 1172 | 1192 | { |
| 1173 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
| 1174 | - $context['ban_erros'][] = 'invalid_email'; |
|
| 1193 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
| 1194 | + $context['ban_erros'][] = 'invalid_email'; |
|
| 1195 | + } |
|
| 1175 | 1196 | |
| 1176 | 1197 | // Check the user is not banning an admin. |
| 1177 | 1198 | $request = $smcFunc['db_query']('', ' |
@@ -1185,15 +1206,15 @@ discard block |
||
| 1185 | 1206 | 'email' => $value, |
| 1186 | 1207 | ) |
| 1187 | 1208 | ); |
| 1188 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1189 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1209 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1210 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1211 | + } |
|
| 1190 | 1212 | $smcFunc['db_free_result']($request); |
| 1191 | 1213 | |
| 1192 | 1214 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
| 1193 | 1215 | |
| 1194 | 1216 | $ban_triggers['email']['email_address'] = $value; |
| 1195 | - } |
|
| 1196 | - elseif ($key == 'user') |
|
| 1217 | + } elseif ($key == 'user') |
|
| 1197 | 1218 | { |
| 1198 | 1219 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
| 1199 | 1220 | |
@@ -1207,8 +1228,9 @@ discard block |
||
| 1207 | 1228 | 'username' => $user, |
| 1208 | 1229 | ) |
| 1209 | 1230 | ); |
| 1210 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1211 | - $context['ban_erros'][] = 'invalid_username'; |
|
| 1231 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1232 | + $context['ban_erros'][] = 'invalid_username'; |
|
| 1233 | + } |
|
| 1212 | 1234 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
| 1213 | 1235 | $smcFunc['db_free_result']($request); |
| 1214 | 1236 | |
@@ -1216,25 +1238,25 @@ discard block |
||
| 1216 | 1238 | { |
| 1217 | 1239 | unset($value); |
| 1218 | 1240 | $context['ban_erros'][] = 'no_ban_admin'; |
| 1241 | + } else { |
|
| 1242 | + $ban_triggers['user']['id_member'] = $value; |
|
| 1219 | 1243 | } |
| 1220 | - else |
|
| 1221 | - $ban_triggers['user']['id_member'] = $value; |
|
| 1222 | - } |
|
| 1223 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1244 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1224 | 1245 | { |
| 1225 | 1246 | // Special case, those two are arrays themselves |
| 1226 | 1247 | $values = array_unique($value); |
| 1227 | 1248 | // Don't add the main IP again. |
| 1228 | - if (isset($triggers['main_ip'])) |
|
| 1229 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1249 | + if (isset($triggers['main_ip'])) { |
|
| 1250 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1251 | + } |
|
| 1230 | 1252 | unset($value); |
| 1231 | 1253 | foreach ($values as $val) |
| 1232 | 1254 | { |
| 1233 | 1255 | $val = trim($val); |
| 1234 | 1256 | $ip_parts = ip2range($val); |
| 1235 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
| 1236 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1237 | - else |
|
| 1257 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
| 1258 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1259 | + } else |
|
| 1238 | 1260 | { |
| 1239 | 1261 | $ban_triggers[$key][] = array( |
| 1240 | 1262 | 'ip_low' => $ip_parts['low'], |
@@ -1247,15 +1269,16 @@ discard block |
||
| 1247 | 1269 | ); |
| 1248 | 1270 | } |
| 1249 | 1271 | } |
| 1272 | + } else { |
|
| 1273 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1250 | 1274 | } |
| 1251 | - else |
|
| 1252 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1253 | 1275 | |
| 1254 | - if (isset($value) && !is_array($value)) |
|
| 1255 | - $log_info[] = array( |
|
| 1276 | + if (isset($value) && !is_array($value)) { |
|
| 1277 | + $log_info[] = array( |
|
| 1256 | 1278 | 'value' => $value, |
| 1257 | 1279 | 'bantype' => $key, |
| 1258 | 1280 | ); |
| 1281 | + } |
|
| 1259 | 1282 | } |
| 1260 | 1283 | } |
| 1261 | 1284 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1275,8 +1298,9 @@ discard block |
||
| 1275 | 1298 | { |
| 1276 | 1299 | global $smcFunc, $context; |
| 1277 | 1300 | |
| 1278 | - if (empty($group_id)) |
|
| 1279 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1301 | + if (empty($group_id)) { |
|
| 1302 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1303 | + } |
|
| 1280 | 1304 | |
| 1281 | 1305 | // Preset all values that are required. |
| 1282 | 1306 | $values = array( |
@@ -1301,18 +1325,21 @@ discard block |
||
| 1301 | 1325 | foreach ($triggers as $key => $trigger) |
| 1302 | 1326 | { |
| 1303 | 1327 | // Exceptions, exceptions, exceptions...always exceptions... :P |
| 1304 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1305 | - foreach ($trigger as $real_trigger) |
|
| 1328 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
| 1329 | + foreach ($trigger as $real_trigger) |
|
| 1306 | 1330 | $insertTriggers[] = array_merge($values, $real_trigger); |
| 1307 | - else |
|
| 1308 | - $insertTriggers[] = array_merge($values, $trigger); |
|
| 1331 | + } else { |
|
| 1332 | + $insertTriggers[] = array_merge($values, $trigger); |
|
| 1333 | + } |
|
| 1309 | 1334 | } |
| 1310 | 1335 | |
| 1311 | - if (empty($insertTriggers)) |
|
| 1312 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1336 | + if (empty($insertTriggers)) { |
|
| 1337 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1338 | + } |
|
| 1313 | 1339 | |
| 1314 | - if (!empty($context['ban_errors'])) |
|
| 1315 | - return false; |
|
| 1340 | + if (!empty($context['ban_errors'])) { |
|
| 1341 | + return false; |
|
| 1342 | + } |
|
| 1316 | 1343 | |
| 1317 | 1344 | $smcFunc['db_insert']('', |
| 1318 | 1345 | '{db_prefix}ban_items', |
@@ -1340,15 +1367,19 @@ discard block |
||
| 1340 | 1367 | { |
| 1341 | 1368 | global $smcFunc, $context; |
| 1342 | 1369 | |
| 1343 | - if (empty($ban_item)) |
|
| 1344 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1345 | - if (empty($group_id)) |
|
| 1346 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1347 | - if (empty($trigger)) |
|
| 1348 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1370 | + if (empty($ban_item)) { |
|
| 1371 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1372 | + } |
|
| 1373 | + if (empty($group_id)) { |
|
| 1374 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1375 | + } |
|
| 1376 | + if (empty($trigger)) { |
|
| 1377 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1378 | + } |
|
| 1349 | 1379 | |
| 1350 | - if (!empty($context['ban_errors'])) |
|
| 1351 | - return; |
|
| 1380 | + if (!empty($context['ban_errors'])) { |
|
| 1381 | + return; |
|
| 1382 | + } |
|
| 1352 | 1383 | |
| 1353 | 1384 | // Preset all values that are required. |
| 1354 | 1385 | $values = array( |
@@ -1389,8 +1420,9 @@ discard block |
||
| 1389 | 1420 | */ |
| 1390 | 1421 | function logTriggersUpdates($logs, $new = true, $removal = false) |
| 1391 | 1422 | { |
| 1392 | - if (empty($logs)) |
|
| 1393 | - return; |
|
| 1423 | + if (empty($logs)) { |
|
| 1424 | + return; |
|
| 1425 | + } |
|
| 1394 | 1426 | |
| 1395 | 1427 | $log_name_map = array( |
| 1396 | 1428 | 'main_ip' => 'ip_range', |
@@ -1401,14 +1433,15 @@ discard block |
||
| 1401 | 1433 | ); |
| 1402 | 1434 | |
| 1403 | 1435 | // Log the addion of the ban entries into the moderation log. |
| 1404 | - foreach ($logs as $log) |
|
| 1405 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1436 | + foreach ($logs as $log) { |
|
| 1437 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1406 | 1438 | $log_name_map[$log['bantype']] => $log['value'], |
| 1407 | 1439 | 'new' => empty($new) ? 0 : 1, |
| 1408 | 1440 | 'remove' => empty($removal) ? 0 : 1, |
| 1409 | 1441 | 'type' => $log['bantype'], |
| 1410 | 1442 | )); |
| 1411 | -} |
|
| 1443 | + } |
|
| 1444 | + } |
|
| 1412 | 1445 | |
| 1413 | 1446 | /** |
| 1414 | 1447 | * Updates an existing ban group |
@@ -1422,12 +1455,15 @@ discard block |
||
| 1422 | 1455 | { |
| 1423 | 1456 | global $smcFunc, $context; |
| 1424 | 1457 | |
| 1425 | - if (empty($ban_info['name'])) |
|
| 1426 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1427 | - if (empty($ban_info['id'])) |
|
| 1428 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1429 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1430 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1458 | + if (empty($ban_info['name'])) { |
|
| 1459 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1460 | + } |
|
| 1461 | + if (empty($ban_info['id'])) { |
|
| 1462 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1463 | + } |
|
| 1464 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1465 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1466 | + } |
|
| 1431 | 1467 | |
| 1432 | 1468 | if(!empty($ban_info['id'])) |
| 1433 | 1469 | { |
@@ -1442,8 +1478,9 @@ discard block |
||
| 1442 | 1478 | ) |
| 1443 | 1479 | ); |
| 1444 | 1480 | |
| 1445 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1446 | - $context['ban_errors'][] = 'ban_not_found'; |
|
| 1481 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1482 | + $context['ban_errors'][] = 'ban_not_found'; |
|
| 1483 | + } |
|
| 1447 | 1484 | $smcFunc['db_free_result']($request); |
| 1448 | 1485 | } |
| 1449 | 1486 | |
@@ -1461,13 +1498,15 @@ discard block |
||
| 1461 | 1498 | 'new_ban_name' => $ban_info['name'], |
| 1462 | 1499 | ) |
| 1463 | 1500 | ); |
| 1464 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1465 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1501 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1502 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1503 | + } |
|
| 1466 | 1504 | $smcFunc['db_free_result']($request); |
| 1467 | 1505 | } |
| 1468 | 1506 | |
| 1469 | - if (!empty($context['ban_errors'])) |
|
| 1470 | - return $ban_info['id']; |
|
| 1507 | + if (!empty($context['ban_errors'])) { |
|
| 1508 | + return $ban_info['id']; |
|
| 1509 | + } |
|
| 1471 | 1510 | |
| 1472 | 1511 | $smcFunc['db_query']('', ' |
| 1473 | 1512 | UPDATE {db_prefix}ban_groups |
@@ -1511,10 +1550,12 @@ discard block |
||
| 1511 | 1550 | { |
| 1512 | 1551 | global $smcFunc, $context; |
| 1513 | 1552 | |
| 1514 | - if (empty($ban_info['name'])) |
|
| 1515 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1516 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1517 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1553 | + if (empty($ban_info['name'])) { |
|
| 1554 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1555 | + } |
|
| 1556 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1557 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1558 | + } |
|
| 1518 | 1559 | |
| 1519 | 1560 | if(!empty($ban_info['name'])) |
| 1520 | 1561 | { |
@@ -1529,13 +1570,15 @@ discard block |
||
| 1529 | 1570 | ) |
| 1530 | 1571 | ); |
| 1531 | 1572 | |
| 1532 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 1533 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1573 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 1574 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1575 | + } |
|
| 1534 | 1576 | $smcFunc['db_free_result']($request); |
| 1535 | 1577 | } |
| 1536 | 1578 | |
| 1537 | - if (!empty($context['ban_errors'])) |
|
| 1538 | - return; |
|
| 1579 | + if (!empty($context['ban_errors'])) { |
|
| 1580 | + return; |
|
| 1581 | + } |
|
| 1539 | 1582 | |
| 1540 | 1583 | // Yes yes, we're ready to add now. |
| 1541 | 1584 | $smcFunc['db_insert']('', |
@@ -1552,8 +1595,9 @@ discard block |
||
| 1552 | 1595 | ); |
| 1553 | 1596 | $ban_info['id'] = $smcFunc['db_insert_id']('{db_prefix}ban_groups', 'id_ban_group'); |
| 1554 | 1597 | |
| 1555 | - if (empty($ban_info['id'])) |
|
| 1556 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1598 | + if (empty($ban_info['id'])) { |
|
| 1599 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1600 | + } |
|
| 1557 | 1601 | |
| 1558 | 1602 | return $ban_info['id']; |
| 1559 | 1603 | } |
@@ -1578,24 +1622,24 @@ discard block |
||
| 1578 | 1622 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
| 1579 | 1623 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
| 1580 | 1624 | |
| 1581 | - if (empty($ban_group)) |
|
| 1582 | - fatal_lang_error('ban_not_found', false); |
|
| 1625 | + if (empty($ban_group)) { |
|
| 1626 | + fatal_lang_error('ban_not_found', false); |
|
| 1627 | + } |
|
| 1583 | 1628 | |
| 1584 | 1629 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
| 1585 | 1630 | { |
| 1586 | 1631 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
| 1587 | 1632 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1588 | - } |
|
| 1589 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1633 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1590 | 1634 | { |
| 1591 | 1635 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
| 1592 | 1636 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
| 1593 | - if (!empty($_POST['ban_suggestions'])) |
|
| 1594 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1637 | + if (!empty($_POST['ban_suggestions'])) { |
|
| 1638 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1639 | + } |
|
| 1595 | 1640 | |
| 1596 | 1641 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1597 | - } |
|
| 1598 | - elseif (isset($_POST['edit_trigger'])) |
|
| 1642 | + } elseif (isset($_POST['edit_trigger'])) |
|
| 1599 | 1643 | { |
| 1600 | 1644 | removeBanTriggers($ban_id); |
| 1601 | 1645 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1626,8 +1670,7 @@ discard block |
||
| 1626 | 1670 | ), |
| 1627 | 1671 | 'is_new' => true, |
| 1628 | 1672 | ); |
| 1629 | - } |
|
| 1630 | - else |
|
| 1673 | + } else |
|
| 1631 | 1674 | { |
| 1632 | 1675 | $request = $smcFunc['db_query']('', ' |
| 1633 | 1676 | SELECT |
@@ -1644,8 +1687,9 @@ discard block |
||
| 1644 | 1687 | 'ban_group' => $ban_group, |
| 1645 | 1688 | ) |
| 1646 | 1689 | ); |
| 1647 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1648 | - fatal_lang_error('ban_not_found', false); |
|
| 1690 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1691 | + fatal_lang_error('ban_not_found', false); |
|
| 1692 | + } |
|
| 1649 | 1693 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1650 | 1694 | $smcFunc['db_free_result']($request); |
| 1651 | 1695 | |
@@ -1694,8 +1738,9 @@ discard block |
||
| 1694 | 1738 | removeBanTriggers($_POST['remove']); |
| 1695 | 1739 | |
| 1696 | 1740 | // Rehabilitate some members. |
| 1697 | - if ($_REQUEST['entity'] == 'member') |
|
| 1698 | - updateBanMembers(); |
|
| 1741 | + if ($_REQUEST['entity'] == 'member') { |
|
| 1742 | + updateBanMembers(); |
|
| 1743 | + } |
|
| 1699 | 1744 | |
| 1700 | 1745 | // Make sure the ban cache is refreshed. |
| 1701 | 1746 | updateSettings(array('banLastUpdated' => time())); |
@@ -1808,8 +1853,7 @@ discard block |
||
| 1808 | 1853 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
| 1809 | 1854 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
| 1810 | 1855 | ); |
| 1811 | - } |
|
| 1812 | - elseif ($context['selected_entity'] === 'hostname') |
|
| 1856 | + } elseif ($context['selected_entity'] === 'hostname') |
|
| 1813 | 1857 | { |
| 1814 | 1858 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1815 | 1859 | 'function' => function ($rowData) use ($smcFunc) |
@@ -1821,8 +1865,7 @@ discard block |
||
| 1821 | 1865 | 'default' => 'bi.hostname', |
| 1822 | 1866 | 'reverse' => 'bi.hostname DESC', |
| 1823 | 1867 | ); |
| 1824 | - } |
|
| 1825 | - elseif ($context['selected_entity'] === 'email') |
|
| 1868 | + } elseif ($context['selected_entity'] === 'email') |
|
| 1826 | 1869 | { |
| 1827 | 1870 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1828 | 1871 | 'function' => function ($rowData) use ($smcFunc) |
@@ -1834,8 +1877,7 @@ discard block |
||
| 1834 | 1877 | 'default' => 'bi.email_address', |
| 1835 | 1878 | 'reverse' => 'bi.email_address DESC', |
| 1836 | 1879 | ); |
| 1837 | - } |
|
| 1838 | - elseif ($context['selected_entity'] === 'member') |
|
| 1880 | + } elseif ($context['selected_entity'] === 'member') |
|
| 1839 | 1881 | { |
| 1840 | 1882 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1841 | 1883 | 'sprintf' => array( |
@@ -1899,8 +1941,9 @@ discard block |
||
| 1899 | 1941 | ) |
| 1900 | 1942 | ); |
| 1901 | 1943 | $ban_triggers = array(); |
| 1902 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1903 | - $ban_triggers[] = $row; |
|
| 1944 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1945 | + $ban_triggers[] = $row; |
|
| 1946 | + } |
|
| 1904 | 1947 | $smcFunc['db_free_result']($request); |
| 1905 | 1948 | |
| 1906 | 1949 | return $ban_triggers; |
@@ -1956,8 +1999,9 @@ discard block |
||
| 1956 | 1999 | validateToken('admin-bl'); |
| 1957 | 2000 | |
| 1958 | 2001 | // 'Delete all entries' button was pressed. |
| 1959 | - if (!empty($_POST['removeAll'])) |
|
| 1960 | - removeBanLogs(); |
|
| 2002 | + if (!empty($_POST['removeAll'])) { |
|
| 2003 | + removeBanLogs(); |
|
| 2004 | + } |
|
| 1961 | 2005 | // 'Delete selection' button was pressed. |
| 1962 | 2006 | else |
| 1963 | 2007 | { |
@@ -2166,12 +2210,15 @@ discard block |
||
| 2166 | 2210 | $low = inet_dtop($low); |
| 2167 | 2211 | $high = inet_dtop($high); |
| 2168 | 2212 | |
| 2169 | - if ($low == '255.255.255.255') return 'unknown'; |
|
| 2170 | - if ($low == $high) |
|
| 2171 | - return $low; |
|
| 2172 | - else |
|
| 2173 | - return $low . '-'.$high; |
|
| 2174 | -} |
|
| 2213 | + if ($low == '255.255.255.255') { |
|
| 2214 | + return 'unknown'; |
|
| 2215 | + } |
|
| 2216 | + if ($low == $high) { |
|
| 2217 | + return $low; |
|
| 2218 | + } else { |
|
| 2219 | + return $low . '-'.$high; |
|
| 2220 | + } |
|
| 2221 | + } |
|
| 2175 | 2222 | |
| 2176 | 2223 | /** |
| 2177 | 2224 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2247,15 +2294,17 @@ discard block |
||
| 2247 | 2294 | $memberEmailWild = array(); |
| 2248 | 2295 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2249 | 2296 | { |
| 2250 | - if ($row['id_member']) |
|
| 2251 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2297 | + if ($row['id_member']) { |
|
| 2298 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2299 | + } |
|
| 2252 | 2300 | if ($row['email_address']) |
| 2253 | 2301 | { |
| 2254 | 2302 | // Does it have a wildcard - if so we can't do a IN on it. |
| 2255 | - if (strpos($row['email_address'], '%') !== false) |
|
| 2256 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2257 | - else |
|
| 2258 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2303 | + if (strpos($row['email_address'], '%') !== false) { |
|
| 2304 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2305 | + } else { |
|
| 2306 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2307 | + } |
|
| 2259 | 2308 | } |
| 2260 | 2309 | } |
| 2261 | 2310 | $smcFunc['db_free_result']($request); |
@@ -2306,14 +2355,15 @@ discard block |
||
| 2306 | 2355 | } |
| 2307 | 2356 | |
| 2308 | 2357 | // We welcome our new members in the realm of the banned. |
| 2309 | - if (!empty($newMembers)) |
|
| 2310 | - $smcFunc['db_query']('', ' |
|
| 2358 | + if (!empty($newMembers)) { |
|
| 2359 | + $smcFunc['db_query']('', ' |
|
| 2311 | 2360 | DELETE FROM {db_prefix}log_online |
| 2312 | 2361 | WHERE id_member IN ({array_int:new_banned_members})', |
| 2313 | 2362 | array( |
| 2314 | 2363 | 'new_banned_members' => $newMembers, |
| 2315 | 2364 | ) |
| 2316 | 2365 | ); |
| 2366 | + } |
|
| 2317 | 2367 | |
| 2318 | 2368 | // Find members that are wrongfully marked as banned. |
| 2319 | 2369 | $request = $smcFunc['db_query']('', ' |
@@ -2340,9 +2390,10 @@ discard block |
||
| 2340 | 2390 | } |
| 2341 | 2391 | $smcFunc['db_free_result']($request); |
| 2342 | 2392 | |
| 2343 | - if (!empty($updates)) |
|
| 2344 | - foreach ($updates as $newStatus => $members) |
|
| 2393 | + if (!empty($updates)) { |
|
| 2394 | + foreach ($updates as $newStatus => $members) |
|
| 2345 | 2395 | updateMemberData($members, array('is_activated' => $newStatus)); |
| 2396 | + } |
|
| 2346 | 2397 | |
| 2347 | 2398 | // Update the latest member and our total members as banning may change them. |
| 2348 | 2399 | updateStats('member'); |
@@ -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 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -202,16 +203,18 @@ discard block |
||
| 202 | 203 | { |
| 203 | 204 | $all_zones = timezone_identifiers_list(); |
| 204 | 205 | // Make sure we set the value to the same as the printed value. |
| 205 | - foreach ($all_zones as $zone) |
|
| 206 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 206 | + foreach ($all_zones as $zone) { |
|
| 207 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 208 | + } |
|
| 209 | + } else { |
|
| 210 | + unset($config_vars['default_timezone']); |
|
| 207 | 211 | } |
| 208 | - else |
|
| 209 | - unset($config_vars['default_timezone']); |
|
| 210 | 212 | |
| 211 | 213 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
| 212 | 214 | |
| 213 | - if ($return_config) |
|
| 214 | - return $config_vars; |
|
| 215 | + if ($return_config) { |
|
| 216 | + return $config_vars; |
|
| 217 | + } |
|
| 215 | 218 | |
| 216 | 219 | // Saving? |
| 217 | 220 | if (isset($_GET['save'])) |
@@ -219,8 +222,9 @@ discard block |
||
| 219 | 222 | checkSession(); |
| 220 | 223 | |
| 221 | 224 | // Prevent absurd boundaries here - make it a day tops. |
| 222 | - if (isset($_POST['lastActive'])) |
|
| 223 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 225 | + if (isset($_POST['lastActive'])) { |
|
| 226 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 227 | + } |
|
| 224 | 228 | |
| 225 | 229 | call_integration_hook('integrate_save_basic_settings'); |
| 226 | 230 | |
@@ -265,8 +269,9 @@ discard block |
||
| 265 | 269 | |
| 266 | 270 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
| 267 | 271 | |
| 268 | - if ($return_config) |
|
| 269 | - return $config_vars; |
|
| 272 | + if ($return_config) { |
|
| 273 | + return $config_vars; |
|
| 274 | + } |
|
| 270 | 275 | |
| 271 | 276 | // Setup the template. |
| 272 | 277 | require_once($sourcedir . '/ManageServer.php'); |
@@ -283,13 +288,15 @@ discard block |
||
| 283 | 288 | |
| 284 | 289 | // Clean up the tags. |
| 285 | 290 | $bbcTags = array(); |
| 286 | - foreach (parse_bbc(false) as $tag) |
|
| 287 | - $bbcTags[] = $tag['tag']; |
|
| 291 | + foreach (parse_bbc(false) as $tag) { |
|
| 292 | + $bbcTags[] = $tag['tag']; |
|
| 293 | + } |
|
| 288 | 294 | |
| 289 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
| 290 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
| 291 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
| 292 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 295 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
| 296 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
| 297 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
| 298 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 299 | + } |
|
| 293 | 300 | // Work out what is actually disabled! |
| 294 | 301 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
| 295 | 302 | |
@@ -333,8 +340,9 @@ discard block |
||
| 333 | 340 | |
| 334 | 341 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
| 335 | 342 | |
| 336 | - if ($return_config) |
|
| 337 | - return $config_vars; |
|
| 343 | + if ($return_config) { |
|
| 344 | + return $config_vars; |
|
| 345 | + } |
|
| 338 | 346 | |
| 339 | 347 | // Saving? |
| 340 | 348 | if (isset($_GET['save'])) |
@@ -375,8 +383,9 @@ discard block |
||
| 375 | 383 | |
| 376 | 384 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
| 377 | 385 | |
| 378 | - if ($return_config) |
|
| 379 | - return $config_vars; |
|
| 386 | + if ($return_config) { |
|
| 387 | + return $config_vars; |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | // Saving? |
| 382 | 391 | if (isset($_GET['save'])) |
@@ -414,8 +423,9 @@ discard block |
||
| 414 | 423 | |
| 415 | 424 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
| 416 | 425 | |
| 417 | - if ($return_config) |
|
| 418 | - return $config_vars; |
|
| 426 | + if ($return_config) { |
|
| 427 | + return $config_vars; |
|
| 428 | + } |
|
| 419 | 429 | |
| 420 | 430 | // Saving? |
| 421 | 431 | if (isset($_GET['save'])) |
@@ -459,8 +469,8 @@ discard block |
||
| 459 | 469 | 'enable' => array('check', 'warning_enable'), |
| 460 | 470 | ); |
| 461 | 471 | |
| 462 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
| 463 | - $config_vars += array( |
|
| 472 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
| 473 | + $config_vars += array( |
|
| 464 | 474 | '', |
| 465 | 475 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
| 466 | 476 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -469,15 +479,18 @@ discard block |
||
| 469 | 479 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
| 470 | 480 | array('permissions', 'view_warning'), |
| 471 | 481 | ); |
| 482 | + } |
|
| 472 | 483 | |
| 473 | 484 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
| 474 | 485 | |
| 475 | - if ($return_config) |
|
| 476 | - return $config_vars; |
|
| 486 | + if ($return_config) { |
|
| 487 | + return $config_vars; |
|
| 488 | + } |
|
| 477 | 489 | |
| 478 | 490 | // Cannot use moderation if post moderation is not enabled. |
| 479 | - if (!$modSettings['postmod_active']) |
|
| 480 | - unset($config_vars['moderate']); |
|
| 491 | + if (!$modSettings['postmod_active']) { |
|
| 492 | + unset($config_vars['moderate']); |
|
| 493 | + } |
|
| 481 | 494 | |
| 482 | 495 | // Will need the utility functions from here. |
| 483 | 496 | require_once($sourcedir . '/ManageServer.php'); |
@@ -502,16 +515,16 @@ discard block |
||
| 502 | 515 | 'warning_watch' => 10, |
| 503 | 516 | 'warning_mute' => 60, |
| 504 | 517 | ); |
| 505 | - if ($modSettings['postmod_active']) |
|
| 506 | - $vars['warning_moderate'] = 35; |
|
| 518 | + if ($modSettings['postmod_active']) { |
|
| 519 | + $vars['warning_moderate'] = 35; |
|
| 520 | + } |
|
| 507 | 521 | |
| 508 | 522 | foreach ($vars as $var => $value) |
| 509 | 523 | { |
| 510 | 524 | $config_vars[] = array('int', $var); |
| 511 | 525 | $_POST[$var] = $value; |
| 512 | 526 | } |
| 513 | - } |
|
| 514 | - else |
|
| 527 | + } else |
|
| 515 | 528 | { |
| 516 | 529 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
| 517 | 530 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -592,8 +605,9 @@ discard block |
||
| 592 | 605 | |
| 593 | 606 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
| 594 | 607 | |
| 595 | - if ($return_config) |
|
| 596 | - return $config_vars; |
|
| 608 | + if ($return_config) { |
|
| 609 | + return $config_vars; |
|
| 610 | + } |
|
| 597 | 611 | |
| 598 | 612 | // You need to be an admin to edit settings! |
| 599 | 613 | isAllowedTo('admin_forum'); |
@@ -627,8 +641,9 @@ discard block |
||
| 627 | 641 | |
| 628 | 642 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
| 629 | 643 | { |
| 630 | - if (empty($context['settings_insert_above'])) |
|
| 631 | - $context['settings_insert_above'] = ''; |
|
| 644 | + if (empty($context['settings_insert_above'])) { |
|
| 645 | + $context['settings_insert_above'] = ''; |
|
| 646 | + } |
|
| 632 | 647 | |
| 633 | 648 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
| 634 | 649 | } |
@@ -671,8 +686,9 @@ discard block |
||
| 671 | 686 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
| 672 | 687 | |
| 673 | 688 | // Hack in guest requiring verification! |
| 674 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
| 675 | - $_POST['posts_require_captcha'] = -1; |
|
| 689 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
| 690 | + $_POST['posts_require_captcha'] = -1; |
|
| 691 | + } |
|
| 676 | 692 | |
| 677 | 693 | $save_vars = $config_vars; |
| 678 | 694 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -689,14 +705,16 @@ discard block |
||
| 689 | 705 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
| 690 | 706 | { |
| 691 | 707 | // If we had some questions for this language before, but don't now, delete everything from that language. |
| 692 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
| 693 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 708 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
| 709 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 710 | + } |
|
| 694 | 711 | |
| 695 | 712 | // Now step through and see if any existing questions no longer exist. |
| 696 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 697 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 713 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 714 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 698 | 715 | if (empty($_POST['question'][$lang_id][$q_id])) |
| 699 | 716 | $changes['delete'][] = $q_id; |
| 717 | + } |
|
| 700 | 718 | |
| 701 | 719 | // Now let's see if there are new questions or ones that need updating. |
| 702 | 720 | if (isset($_POST['question'][$lang_id])) |
@@ -705,14 +723,16 @@ discard block |
||
| 705 | 723 | { |
| 706 | 724 | // Ignore junky ids. |
| 707 | 725 | $q_id = (int) $q_id; |
| 708 | - if ($q_id <= 0) |
|
| 709 | - continue; |
|
| 726 | + if ($q_id <= 0) { |
|
| 727 | + continue; |
|
| 728 | + } |
|
| 710 | 729 | |
| 711 | 730 | // Check the question isn't empty (because they want to delete it?) |
| 712 | 731 | if (empty($question) || trim($question) == '') |
| 713 | 732 | { |
| 714 | - if (isset($context['question_answers'][$q_id])) |
|
| 715 | - $changes['delete'][] = $q_id; |
|
| 733 | + if (isset($context['question_answers'][$q_id])) { |
|
| 734 | + $changes['delete'][] = $q_id; |
|
| 735 | + } |
|
| 716 | 736 | continue; |
| 717 | 737 | } |
| 718 | 738 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -720,19 +740,22 @@ discard block |
||
| 720 | 740 | // Get the answers. Firstly check there actually might be some. |
| 721 | 741 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
| 722 | 742 | { |
| 723 | - if (isset($context['question_answers'][$q_id])) |
|
| 724 | - $changes['delete'][] = $q_id; |
|
| 743 | + if (isset($context['question_answers'][$q_id])) { |
|
| 744 | + $changes['delete'][] = $q_id; |
|
| 745 | + } |
|
| 725 | 746 | continue; |
| 726 | 747 | } |
| 727 | 748 | // Now get them and check that they might be viable. |
| 728 | 749 | $answers = array(); |
| 729 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
| 730 | - if (!empty($answer) && trim($answer) !== '') |
|
| 750 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
| 751 | + if (!empty($answer) && trim($answer) !== '') |
|
| 731 | 752 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
| 753 | + } |
|
| 732 | 754 | if (empty($answers)) |
| 733 | 755 | { |
| 734 | - if (isset($context['question_answers'][$q_id])) |
|
| 735 | - $changes['delete'][] = $q_id; |
|
| 756 | + if (isset($context['question_answers'][$q_id])) { |
|
| 757 | + $changes['delete'][] = $q_id; |
|
| 758 | + } |
|
| 736 | 759 | continue; |
| 737 | 760 | } |
| 738 | 761 | $answers = json_encode($answers); |
@@ -742,16 +765,17 @@ discard block |
||
| 742 | 765 | { |
| 743 | 766 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
| 744 | 767 | $changes['insert'][] = array($lang_id, $question, $answers); |
| 745 | - } |
|
| 746 | - else |
|
| 768 | + } else |
|
| 747 | 769 | { |
| 748 | 770 | // It's an existing question. Let's see what's changed, if anything. |
| 749 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
| 750 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 771 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
| 772 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 773 | + } |
|
| 751 | 774 | } |
| 752 | 775 | |
| 753 | - if (!isset($qs_per_lang[$lang_id])) |
|
| 754 | - $qs_per_lang[$lang_id] = 0; |
|
| 776 | + if (!isset($qs_per_lang[$lang_id])) { |
|
| 777 | + $qs_per_lang[$lang_id] = 0; |
|
| 778 | + } |
|
| 755 | 779 | $qs_per_lang[$lang_id]++; |
| 756 | 780 | } |
| 757 | 781 | } |
@@ -801,8 +825,9 @@ discard block |
||
| 801 | 825 | |
| 802 | 826 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
| 803 | 827 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
| 804 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
| 805 | - $_POST['qa_verification_number'] = $count_questions; |
|
| 828 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
| 829 | + $_POST['qa_verification_number'] = $count_questions; |
|
| 830 | + } |
|
| 806 | 831 | |
| 807 | 832 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
| 808 | 833 | |
@@ -817,24 +842,27 @@ discard block |
||
| 817 | 842 | |
| 818 | 843 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
| 819 | 844 | $_SESSION['visual_verification_code'] = ''; |
| 820 | - for ($i = 0; $i < 6; $i++) |
|
| 821 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 845 | + for ($i = 0; $i < 6; $i++) { |
|
| 846 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 847 | + } |
|
| 822 | 848 | |
| 823 | 849 | // Some javascript for CAPTCHA. |
| 824 | 850 | $context['settings_post_javascript'] = ''; |
| 825 | - if ($context['use_graphic_library']) |
|
| 826 | - $context['settings_post_javascript'] .= ' |
|
| 851 | + if ($context['use_graphic_library']) { |
|
| 852 | + $context['settings_post_javascript'] .= ' |
|
| 827 | 853 | function refreshImages() |
| 828 | 854 | { |
| 829 | 855 | var imageType = document.getElementById(\'visual_verification_type\').value; |
| 830 | 856 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
| 831 | 857 | }'; |
| 858 | + } |
|
| 832 | 859 | |
| 833 | 860 | // Show the image itself, or text saying we can't. |
| 834 | - if ($context['use_graphic_library']) |
|
| 835 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 836 | - else |
|
| 837 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 861 | + if ($context['use_graphic_library']) { |
|
| 862 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 863 | + } else { |
|
| 864 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 865 | + } |
|
| 838 | 866 | |
| 839 | 867 | // Hack for PM spam settings. |
| 840 | 868 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -844,9 +872,10 @@ discard block |
||
| 844 | 872 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
| 845 | 873 | |
| 846 | 874 | // Some minor javascript for the guest post setting. |
| 847 | - if ($modSettings['posts_require_captcha']) |
|
| 848 | - $context['settings_post_javascript'] .= ' |
|
| 875 | + if ($modSettings['posts_require_captcha']) { |
|
| 876 | + $context['settings_post_javascript'] .= ' |
|
| 849 | 877 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
| 878 | + } |
|
| 850 | 879 | |
| 851 | 880 | // And everything else. |
| 852 | 881 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -893,8 +922,9 @@ discard block |
||
| 893 | 922 | |
| 894 | 923 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
| 895 | 924 | |
| 896 | - if ($return_config) |
|
| 897 | - return $config_vars; |
|
| 925 | + if ($return_config) { |
|
| 926 | + return $config_vars; |
|
| 927 | + } |
|
| 898 | 928 | |
| 899 | 929 | // Setup the template. |
| 900 | 930 | $context['page_title'] = $txt['signature_settings']; |
@@ -949,8 +979,9 @@ discard block |
||
| 949 | 979 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
| 950 | 980 | |
| 951 | 981 | // Max characters... |
| 952 | - if (!empty($sig_limits[1])) |
|
| 953 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 982 | + if (!empty($sig_limits[1])) { |
|
| 983 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 984 | + } |
|
| 954 | 985 | // Max lines... |
| 955 | 986 | if (!empty($sig_limits[2])) |
| 956 | 987 | { |
@@ -960,8 +991,9 @@ discard block |
||
| 960 | 991 | if ($sig[$i] == "\n") |
| 961 | 992 | { |
| 962 | 993 | $count++; |
| 963 | - if ($count >= $sig_limits[2]) |
|
| 964 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 994 | + if ($count >= $sig_limits[2]) { |
|
| 995 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 996 | + } |
|
| 965 | 997 | } |
| 966 | 998 | } |
| 967 | 999 | } |
@@ -972,17 +1004,19 @@ discard block |
||
| 972 | 1004 | { |
| 973 | 1005 | $limit_broke = 0; |
| 974 | 1006 | // Attempt to allow all sizes of abuse, so to speak. |
| 975 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 976 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 977 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 978 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 979 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 980 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 981 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 982 | - $limit_broke = 'large'; |
|
| 983 | - |
|
| 984 | - if ($limit_broke) |
|
| 985 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1007 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 1008 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 1009 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 1010 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 1011 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 1012 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 1013 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 1014 | + $limit_broke = 'large'; |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + if ($limit_broke) { |
|
| 1018 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1019 | + } |
|
| 986 | 1020 | } |
| 987 | 1021 | } |
| 988 | 1022 | |
@@ -1038,32 +1072,34 @@ discard block |
||
| 1038 | 1072 | $img_offset = false; |
| 1039 | 1073 | } |
| 1040 | 1074 | } |
| 1075 | + } else { |
|
| 1076 | + $replaces[$image] = ''; |
|
| 1041 | 1077 | } |
| 1042 | - else |
|
| 1043 | - $replaces[$image] = ''; |
|
| 1044 | 1078 | |
| 1045 | 1079 | continue; |
| 1046 | 1080 | } |
| 1047 | 1081 | |
| 1048 | 1082 | // Does it have predefined restraints? Width first. |
| 1049 | - if ($matches[6][$key]) |
|
| 1050 | - $matches[2][$key] = $matches[6][$key]; |
|
| 1083 | + if ($matches[6][$key]) { |
|
| 1084 | + $matches[2][$key] = $matches[6][$key]; |
|
| 1085 | + } |
|
| 1051 | 1086 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 1052 | 1087 | { |
| 1053 | 1088 | $width = $sig_limits[5]; |
| 1054 | 1089 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 1090 | + } elseif ($matches[2][$key]) { |
|
| 1091 | + $width = $matches[2][$key]; |
|
| 1055 | 1092 | } |
| 1056 | - elseif ($matches[2][$key]) |
|
| 1057 | - $width = $matches[2][$key]; |
|
| 1058 | 1093 | // ... and height. |
| 1059 | 1094 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 1060 | 1095 | { |
| 1061 | 1096 | $height = $sig_limits[6]; |
| 1062 | - if ($width != -1) |
|
| 1063 | - $width = $width * ($height / $matches[4][$key]); |
|
| 1097 | + if ($width != -1) { |
|
| 1098 | + $width = $width * ($height / $matches[4][$key]); |
|
| 1099 | + } |
|
| 1100 | + } elseif ($matches[4][$key]) { |
|
| 1101 | + $height = $matches[4][$key]; |
|
| 1064 | 1102 | } |
| 1065 | - elseif ($matches[4][$key]) |
|
| 1066 | - $height = $matches[4][$key]; |
|
| 1067 | 1103 | |
| 1068 | 1104 | // If the dimensions are still not fixed - we need to check the actual image. |
| 1069 | 1105 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1081,12 +1117,13 @@ discard block |
||
| 1081 | 1117 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 1082 | 1118 | { |
| 1083 | 1119 | $height = $sig_limits[6]; |
| 1084 | - if ($width == -1) |
|
| 1085 | - $width = $sizes[0]; |
|
| 1120 | + if ($width == -1) { |
|
| 1121 | + $width = $sizes[0]; |
|
| 1122 | + } |
|
| 1086 | 1123 | $width = $width * ($height / $sizes[1]); |
| 1124 | + } elseif ($width != -1) { |
|
| 1125 | + $height = $sizes[1]; |
|
| 1087 | 1126 | } |
| 1088 | - elseif ($width != -1) |
|
| 1089 | - $height = $sizes[1]; |
|
| 1090 | 1127 | } |
| 1091 | 1128 | } |
| 1092 | 1129 | |
@@ -1099,8 +1136,9 @@ discard block |
||
| 1099 | 1136 | // Record that we got one. |
| 1100 | 1137 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
| 1101 | 1138 | } |
| 1102 | - if (!empty($replaces)) |
|
| 1103 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1139 | + if (!empty($replaces)) { |
|
| 1140 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1141 | + } |
|
| 1104 | 1142 | } |
| 1105 | 1143 | } |
| 1106 | 1144 | // Try to fix disabled tags. |
@@ -1112,18 +1150,20 @@ discard block |
||
| 1112 | 1150 | |
| 1113 | 1151 | $sig = strtr($sig, array("\n" => '<br>')); |
| 1114 | 1152 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
| 1115 | - if ($sig != $row['signature']) |
|
| 1116 | - $changes[$row['id_member']] = $sig; |
|
| 1153 | + if ($sig != $row['signature']) { |
|
| 1154 | + $changes[$row['id_member']] = $sig; |
|
| 1155 | + } |
|
| 1156 | + } |
|
| 1157 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1158 | + $done = true; |
|
| 1117 | 1159 | } |
| 1118 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1119 | - $done = true; |
|
| 1120 | 1160 | $smcFunc['db_free_result']($request); |
| 1121 | 1161 | |
| 1122 | 1162 | // Do we need to delete what we have? |
| 1123 | 1163 | if (!empty($changes)) |
| 1124 | 1164 | { |
| 1125 | - foreach ($changes as $id => $sig) |
|
| 1126 | - $smcFunc['db_query']('', ' |
|
| 1165 | + foreach ($changes as $id => $sig) { |
|
| 1166 | + $smcFunc['db_query']('', ' |
|
| 1127 | 1167 | UPDATE {db_prefix}members |
| 1128 | 1168 | SET signature = {string:signature} |
| 1129 | 1169 | WHERE id_member = {int:id_member}', |
@@ -1132,11 +1172,13 @@ discard block |
||
| 1132 | 1172 | 'signature' => $sig, |
| 1133 | 1173 | ) |
| 1134 | 1174 | ); |
| 1175 | + } |
|
| 1135 | 1176 | } |
| 1136 | 1177 | |
| 1137 | 1178 | $_GET['step'] += 50; |
| 1138 | - if (!$done) |
|
| 1139 | - pauseSignatureApplySettings(); |
|
| 1179 | + if (!$done) { |
|
| 1180 | + pauseSignatureApplySettings(); |
|
| 1181 | + } |
|
| 1140 | 1182 | } |
| 1141 | 1183 | $settings_applied = true; |
| 1142 | 1184 | } |
@@ -1154,8 +1196,9 @@ discard block |
||
| 1154 | 1196 | ); |
| 1155 | 1197 | |
| 1156 | 1198 | // Temporarily make each setting a modSetting! |
| 1157 | - foreach ($context['signature_settings'] as $key => $value) |
|
| 1158 | - $modSettings['signature_' . $key] = $value; |
|
| 1199 | + foreach ($context['signature_settings'] as $key => $value) { |
|
| 1200 | + $modSettings['signature_' . $key] = $value; |
|
| 1201 | + } |
|
| 1159 | 1202 | |
| 1160 | 1203 | // Make sure we check the right tags! |
| 1161 | 1204 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1167,23 +1210,26 @@ discard block |
||
| 1167 | 1210 | |
| 1168 | 1211 | // Clean up the tag stuff! |
| 1169 | 1212 | $bbcTags = array(); |
| 1170 | - foreach (parse_bbc(false) as $tag) |
|
| 1171 | - $bbcTags[] = $tag['tag']; |
|
| 1213 | + foreach (parse_bbc(false) as $tag) { |
|
| 1214 | + $bbcTags[] = $tag['tag']; |
|
| 1215 | + } |
|
| 1172 | 1216 | |
| 1173 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
| 1174 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1175 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
| 1176 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1217 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
| 1218 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1219 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
| 1220 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1221 | + } |
|
| 1177 | 1222 | |
| 1178 | 1223 | $sig_limits = array(); |
| 1179 | 1224 | foreach ($context['signature_settings'] as $key => $value) |
| 1180 | 1225 | { |
| 1181 | - if ($key == 'allow_smileys') |
|
| 1182 | - continue; |
|
| 1183 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
| 1184 | - $sig_limits[] = -1; |
|
| 1185 | - else |
|
| 1186 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1226 | + if ($key == 'allow_smileys') { |
|
| 1227 | + continue; |
|
| 1228 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
| 1229 | + $sig_limits[] = -1; |
|
| 1230 | + } else { |
|
| 1231 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1232 | + } |
|
| 1187 | 1233 | } |
| 1188 | 1234 | |
| 1189 | 1235 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1216,12 +1262,14 @@ discard block |
||
| 1216 | 1262 | |
| 1217 | 1263 | // Try get more time... |
| 1218 | 1264 | @set_time_limit(600); |
| 1219 | - if (function_exists('apache_reset_timeout')) |
|
| 1220 | - @apache_reset_timeout(); |
|
| 1265 | + if (function_exists('apache_reset_timeout')) { |
|
| 1266 | + @apache_reset_timeout(); |
|
| 1267 | + } |
|
| 1221 | 1268 | |
| 1222 | 1269 | // Have we exhausted all the time we allowed? |
| 1223 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
| 1224 | - return; |
|
| 1270 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
| 1271 | + return; |
|
| 1272 | + } |
|
| 1225 | 1273 | |
| 1226 | 1274 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1227 | 1275 | $context['page_title'] = $txt['not_done_title']; |
@@ -1267,9 +1315,10 @@ discard block |
||
| 1267 | 1315 | $disable_fields = array_flip($standard_fields); |
| 1268 | 1316 | if (!empty($_POST['active'])) |
| 1269 | 1317 | { |
| 1270 | - foreach ($_POST['active'] as $value) |
|
| 1271 | - if (isset($disable_fields[$value])) |
|
| 1318 | + foreach ($_POST['active'] as $value) { |
|
| 1319 | + if (isset($disable_fields[$value])) |
|
| 1272 | 1320 | unset($disable_fields[$value]); |
| 1321 | + } |
|
| 1273 | 1322 | } |
| 1274 | 1323 | // What we have left! |
| 1275 | 1324 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1278,16 +1327,18 @@ discard block |
||
| 1278 | 1327 | $reg_fields = array(); |
| 1279 | 1328 | if (!empty($_POST['reg'])) |
| 1280 | 1329 | { |
| 1281 | - foreach ($_POST['reg'] as $value) |
|
| 1282 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1330 | + foreach ($_POST['reg'] as $value) { |
|
| 1331 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1283 | 1332 | $reg_fields[] = $value; |
| 1333 | + } |
|
| 1284 | 1334 | } |
| 1285 | 1335 | // What we have left! |
| 1286 | 1336 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
| 1287 | 1337 | |
| 1288 | 1338 | $_SESSION['adm-save'] = true; |
| 1289 | - if (!empty($changes)) |
|
| 1290 | - updateSettings($changes); |
|
| 1339 | + if (!empty($changes)) { |
|
| 1340 | + updateSettings($changes); |
|
| 1341 | + } |
|
| 1291 | 1342 | } |
| 1292 | 1343 | |
| 1293 | 1344 | createToken('admin-scp'); |
@@ -1390,11 +1441,13 @@ discard block |
||
| 1390 | 1441 | { |
| 1391 | 1442 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />'; |
| 1392 | 1443 | |
| 1393 | - if ($rowData['field_order'] > 1) |
|
| 1394 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1444 | + if ($rowData['field_order'] > 1) { |
|
| 1445 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1446 | + } |
|
| 1395 | 1447 | |
| 1396 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
| 1397 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1448 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
| 1449 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1450 | + } |
|
| 1398 | 1451 | |
| 1399 | 1452 | $return .= '</p>'; |
| 1400 | 1453 | |
@@ -1532,16 +1585,16 @@ discard block |
||
| 1532 | 1585 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
| 1533 | 1586 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
| 1534 | 1587 | |
| 1535 | - foreach ($standard_fields as $field) |
|
| 1536 | - $list[] = array( |
|
| 1588 | + foreach ($standard_fields as $field) { |
|
| 1589 | + $list[] = array( |
|
| 1537 | 1590 | 'id' => $field, |
| 1538 | 1591 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
| 1539 | 1592 | 'disabled' => in_array($field, $disabled_fields), |
| 1540 | 1593 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
| 1541 | 1594 | 'can_show_register' => !in_array($field, $fields_no_registration), |
| 1542 | 1595 | ); |
| 1543 | - } |
|
| 1544 | - else |
|
| 1596 | + } |
|
| 1597 | + } else |
|
| 1545 | 1598 | { |
| 1546 | 1599 | // Load all the fields. |
| 1547 | 1600 | $request = $smcFunc['db_query']('', ' |
@@ -1555,8 +1608,9 @@ discard block |
||
| 1555 | 1608 | 'items_per_page' => $items_per_page, |
| 1556 | 1609 | ) |
| 1557 | 1610 | ); |
| 1558 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1559 | - $list[] = $row; |
|
| 1611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1612 | + $list[] = $row; |
|
| 1613 | + } |
|
| 1560 | 1614 | $smcFunc['db_free_result']($request); |
| 1561 | 1615 | } |
| 1562 | 1616 | |
@@ -1622,9 +1676,9 @@ discard block |
||
| 1622 | 1676 | $context['field'] = array(); |
| 1623 | 1677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1624 | 1678 | { |
| 1625 | - if ($row['field_type'] == 'textarea') |
|
| 1626 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1627 | - else |
|
| 1679 | + if ($row['field_type'] == 'textarea') { |
|
| 1680 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1681 | + } else |
|
| 1628 | 1682 | { |
| 1629 | 1683 | $rows = 3; |
| 1630 | 1684 | $cols = 30; |
@@ -1660,8 +1714,8 @@ discard block |
||
| 1660 | 1714 | } |
| 1661 | 1715 | |
| 1662 | 1716 | // Setup the default values as needed. |
| 1663 | - if (empty($context['field'])) |
|
| 1664 | - $context['field'] = array( |
|
| 1717 | + if (empty($context['field'])) { |
|
| 1718 | + $context['field'] = array( |
|
| 1665 | 1719 | 'name' => '', |
| 1666 | 1720 | 'col_name' => '???', |
| 1667 | 1721 | 'desc' => '', |
@@ -1686,6 +1740,7 @@ discard block |
||
| 1686 | 1740 | 'enclose' => '', |
| 1687 | 1741 | 'placement' => 0, |
| 1688 | 1742 | ); |
| 1743 | + } |
|
| 1689 | 1744 | |
| 1690 | 1745 | // Are we moving it? |
| 1691 | 1746 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1694,8 +1749,10 @@ discard block |
||
| 1694 | 1749 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
| 1695 | 1750 | |
| 1696 | 1751 | // Is this a valid position? |
| 1697 | - if ($new_order <= 0 || $new_order > $order_count) |
|
| 1698 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
| 1752 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
| 1753 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
| 1754 | + } |
|
| 1755 | + // @todo implement an error handler |
|
| 1699 | 1756 | |
| 1700 | 1757 | // All good, proceed. |
| 1701 | 1758 | $smcFunc['db_query']('',' |
@@ -1726,12 +1783,14 @@ discard block |
||
| 1726 | 1783 | validateToken('admin-ecp'); |
| 1727 | 1784 | |
| 1728 | 1785 | // Everyone needs a name - even the (bracket) unknown... |
| 1729 | - if (trim($_POST['field_name']) == '') |
|
| 1730 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1786 | + if (trim($_POST['field_name']) == '') { |
|
| 1787 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1788 | + } |
|
| 1731 | 1789 | |
| 1732 | 1790 | // Regex you say? Do a very basic test to see if the pattern is valid |
| 1733 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
| 1734 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1791 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
| 1792 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1793 | + } |
|
| 1735 | 1794 | |
| 1736 | 1795 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
| 1737 | 1796 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1748,8 +1807,9 @@ discard block |
||
| 1748 | 1807 | |
| 1749 | 1808 | // Some masking stuff... |
| 1750 | 1809 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
| 1751 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
| 1752 | - $mask .= $_POST['regex']; |
|
| 1810 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
| 1811 | + $mask .= $_POST['regex']; |
|
| 1812 | + } |
|
| 1753 | 1813 | |
| 1754 | 1814 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
| 1755 | 1815 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1768,8 +1828,9 @@ discard block |
||
| 1768 | 1828 | $v = strtr($v, array(',' => '')); |
| 1769 | 1829 | |
| 1770 | 1830 | // Nada, zip, etc... |
| 1771 | - if (trim($v) == '') |
|
| 1772 | - continue; |
|
| 1831 | + if (trim($v) == '') { |
|
| 1832 | + continue; |
|
| 1833 | + } |
|
| 1773 | 1834 | |
| 1774 | 1835 | // Otherwise, save it boy. |
| 1775 | 1836 | $field_options .= $v . ','; |
@@ -1777,15 +1838,17 @@ discard block |
||
| 1777 | 1838 | $newOptions[$k] = $v; |
| 1778 | 1839 | |
| 1779 | 1840 | // Is it default? |
| 1780 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
| 1781 | - $default = $v; |
|
| 1841 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
| 1842 | + $default = $v; |
|
| 1843 | + } |
|
| 1782 | 1844 | } |
| 1783 | 1845 | $field_options = substr($field_options, 0, -1); |
| 1784 | 1846 | } |
| 1785 | 1847 | |
| 1786 | 1848 | // Text area has default has dimensions |
| 1787 | - if ($_POST['field_type'] == 'textarea') |
|
| 1788 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1849 | + if ($_POST['field_type'] == 'textarea') { |
|
| 1850 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1851 | + } |
|
| 1789 | 1852 | |
| 1790 | 1853 | // Come up with the unique name? |
| 1791 | 1854 | if (empty($context['fid'])) |
@@ -1794,32 +1857,36 @@ discard block |
||
| 1794 | 1857 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
| 1795 | 1858 | |
| 1796 | 1859 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
| 1797 | - if (isset($matches[1])) |
|
| 1798 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1799 | - else |
|
| 1800 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1860 | + if (isset($matches[1])) { |
|
| 1861 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1862 | + } else { |
|
| 1863 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1864 | + } |
|
| 1801 | 1865 | |
| 1802 | 1866 | // Make sure this is unique. |
| 1803 | 1867 | $current_fields = array(); |
| 1804 | 1868 | $request = $smcFunc['db_query']('', ' |
| 1805 | 1869 | SELECT id_field, col_name |
| 1806 | 1870 | FROM {db_prefix}custom_fields'); |
| 1807 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1808 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1871 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1872 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1873 | + } |
|
| 1809 | 1874 | $smcFunc['db_free_result']($request); |
| 1810 | 1875 | |
| 1811 | 1876 | $unique = false; |
| 1812 | 1877 | for ($i = 0; !$unique && $i < 9; $i ++) |
| 1813 | 1878 | { |
| 1814 | - if (!in_array($col_name, $current_fields)) |
|
| 1815 | - $unique = true; |
|
| 1816 | - else |
|
| 1817 | - $col_name = $initial_col_name . $i; |
|
| 1879 | + if (!in_array($col_name, $current_fields)) { |
|
| 1880 | + $unique = true; |
|
| 1881 | + } else { |
|
| 1882 | + $col_name = $initial_col_name . $i; |
|
| 1883 | + } |
|
| 1818 | 1884 | } |
| 1819 | 1885 | |
| 1820 | 1886 | // Still not a unique column name? Leave it up to the user, then. |
| 1821 | - if (!$unique) |
|
| 1822 | - fatal_lang_error('custom_option_not_unique'); |
|
| 1887 | + if (!$unique) { |
|
| 1888 | + fatal_lang_error('custom_option_not_unique'); |
|
| 1889 | + } |
|
| 1823 | 1890 | } |
| 1824 | 1891 | // Work out what to do with the user data otherwise... |
| 1825 | 1892 | else |
@@ -1847,8 +1914,9 @@ discard block |
||
| 1847 | 1914 | // Work out what's changed! |
| 1848 | 1915 | foreach ($context['field']['options'] as $k => $option) |
| 1849 | 1916 | { |
| 1850 | - if (trim($option) == '') |
|
| 1851 | - continue; |
|
| 1917 | + if (trim($option) == '') { |
|
| 1918 | + continue; |
|
| 1919 | + } |
|
| 1852 | 1920 | |
| 1853 | 1921 | // Still exists? |
| 1854 | 1922 | if (in_array($option, $newOptions)) |
@@ -1862,8 +1930,8 @@ discard block |
||
| 1862 | 1930 | foreach ($optionChanges as $k => $option) |
| 1863 | 1931 | { |
| 1864 | 1932 | // Just been renamed? |
| 1865 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
| 1866 | - $smcFunc['db_query']('', ' |
|
| 1933 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
| 1934 | + $smcFunc['db_query']('', ' |
|
| 1867 | 1935 | UPDATE {db_prefix}themes |
| 1868 | 1936 | SET value = {string:new_value} |
| 1869 | 1937 | WHERE variable = {string:current_column} |
@@ -1876,6 +1944,7 @@ discard block |
||
| 1876 | 1944 | 'old_value' => $option, |
| 1877 | 1945 | ) |
| 1878 | 1946 | ); |
| 1947 | + } |
|
| 1879 | 1948 | } |
| 1880 | 1949 | } |
| 1881 | 1950 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1918,8 +1987,8 @@ discard block |
||
| 1918 | 1987 | ); |
| 1919 | 1988 | |
| 1920 | 1989 | // Just clean up any old selects - these are a pain! |
| 1921 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
| 1922 | - $smcFunc['db_query']('', ' |
|
| 1990 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
| 1991 | + $smcFunc['db_query']('', ' |
|
| 1923 | 1992 | DELETE FROM {db_prefix}themes |
| 1924 | 1993 | WHERE variable = {string:current_column} |
| 1925 | 1994 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1930,8 +1999,8 @@ discard block |
||
| 1930 | 1999 | 'current_column' => $context['field']['col_name'], |
| 1931 | 2000 | ) |
| 1932 | 2001 | ); |
| 1933 | - } |
|
| 1934 | - else |
|
| 2002 | + } |
|
| 2003 | + } else |
|
| 1935 | 2004 | { |
| 1936 | 2005 | // Gotta figure it out the order. |
| 1937 | 2006 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2105,11 +2174,13 @@ discard block |
||
| 2105 | 2174 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
| 2106 | 2175 | |
| 2107 | 2176 | $prune_toggle_dt = array(); |
| 2108 | - foreach ($prune_toggle as $item) |
|
| 2109 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2177 | + foreach ($prune_toggle as $item) { |
|
| 2178 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2179 | + } |
|
| 2110 | 2180 | |
| 2111 | - if ($return_config) |
|
| 2112 | - return $config_vars; |
|
| 2181 | + if ($return_config) { |
|
| 2182 | + return $config_vars; |
|
| 2183 | + } |
|
| 2113 | 2184 | |
| 2114 | 2185 | addInlineJavaScript(' |
| 2115 | 2186 | function togglePruned() |
@@ -2147,15 +2218,16 @@ discard block |
||
| 2147 | 2218 | $vals = array(); |
| 2148 | 2219 | foreach ($config_vars as $index => $dummy) |
| 2149 | 2220 | { |
| 2150 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
| 2151 | - continue; |
|
| 2221 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
| 2222 | + continue; |
|
| 2223 | + } |
|
| 2152 | 2224 | |
| 2153 | 2225 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
| 2154 | 2226 | } |
| 2155 | 2227 | $_POST['pruningOptions'] = implode(',', $vals); |
| 2228 | + } else { |
|
| 2229 | + $_POST['pruningOptions'] = ''; |
|
| 2156 | 2230 | } |
| 2157 | - else |
|
| 2158 | - $_POST['pruningOptions'] = ''; |
|
| 2159 | 2231 | |
| 2160 | 2232 | saveDBSettings($savevar); |
| 2161 | 2233 | $_SESSION['adm-save'] = true; |
@@ -2167,10 +2239,11 @@ discard block |
||
| 2167 | 2239 | $context['sub_template'] = 'show_settings'; |
| 2168 | 2240 | |
| 2169 | 2241 | // Get the actual values |
| 2170 | - if (!empty($modSettings['pruningOptions'])) |
|
| 2171 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2172 | - else |
|
| 2173 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2242 | + if (!empty($modSettings['pruningOptions'])) { |
|
| 2243 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2244 | + } else { |
|
| 2245 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2246 | + } |
|
| 2174 | 2247 | |
| 2175 | 2248 | prepareDBSettingContext($config_vars); |
| 2176 | 2249 | } |
@@ -2192,8 +2265,9 @@ discard block |
||
| 2192 | 2265 | // Make it even easier to add new settings. |
| 2193 | 2266 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
| 2194 | 2267 | |
| 2195 | - if ($return_config) |
|
| 2196 | - return $config_vars; |
|
| 2268 | + if ($return_config) { |
|
| 2269 | + return $config_vars; |
|
| 2270 | + } |
|
| 2197 | 2271 | |
| 2198 | 2272 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
| 2199 | 2273 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -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 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
| 31 | 32 | |
| 32 | 33 | // Viewing contents of a file? |
| 33 | - if (isset($_GET['file'])) |
|
| 34 | - return ViewFile(); |
|
| 34 | + if (isset($_GET['file'])) { |
|
| 35 | + return ViewFile(); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Check for the administrative permission to do this. |
| 37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
| 85 | 87 | ); |
| 86 | 88 | |
| 87 | 89 | // Set up the filtering... |
| 88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
| 89 | - $filter = array( |
|
| 90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
| 91 | + $filter = array( |
|
| 90 | 92 | 'variable' => $_GET['filter'], |
| 91 | 93 | 'value' => array( |
| 92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
| 94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
| 95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
| 96 | 98 | ); |
| 99 | + } |
|
| 97 | 100 | |
| 98 | 101 | // Deleting, are we? |
| 99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
| 100 | - deleteErrors(); |
|
| 102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
| 103 | + deleteErrors(); |
|
| 104 | + } |
|
| 101 | 105 | |
| 102 | 106 | // Just how many errors are there? |
| 103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
| 112 | 116 | $smcFunc['db_free_result']($result); |
| 113 | 117 | |
| 114 | 118 | // If this filter is empty... |
| 115 | - if ($num_errors == 0 && isset($filter)) |
|
| 116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 119 | + if ($num_errors == 0 && isset($filter)) { |
|
| 120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | // Clean up start. |
| 119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
| 120 | - $_GET['start'] = 0; |
|
| 124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
| 125 | + $_GET['start'] = 0; |
|
| 126 | + } |
|
| 121 | 127 | |
| 122 | 128 | // Do we want to reverse error listing? |
| 123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
| 127 | 133 | $context['start'] = $_GET['start']; |
| 128 | 134 | |
| 129 | 135 | // Update the error count |
| 130 | - if (!isset($filter)) |
|
| 131 | - $context['num_errors'] = $num_errors; |
|
| 132 | - else |
|
| 136 | + if (!isset($filter)) { |
|
| 137 | + $context['num_errors'] = $num_errors; |
|
| 138 | + } else |
|
| 133 | 139 | { |
| 134 | 140 | // We want all errors, not just the number of filtered messages... |
| 135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
| 161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
| 162 | 168 | { |
| 163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
| 164 | - if ($search_message == $filter['value']['sql']) |
|
| 165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 170 | + if ($search_message == $filter['value']['sql']) { |
|
| 171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 172 | + } |
|
| 166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
| 167 | 174 | |
| 168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
| 221 | 228 | 'members' => count($members), |
| 222 | 229 | ) |
| 223 | 230 | ); |
| 224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 225 | - $members[$row['id_member']] = $row; |
|
| 231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 232 | + $members[$row['id_member']] = $row; |
|
| 233 | + } |
|
| 226 | 234 | $smcFunc['db_free_result']($request); |
| 227 | 235 | |
| 228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
| 254 | 262 | $id = $filter['value']['sql']; |
| 255 | 263 | loadMemberData($id, false, 'minimal'); |
| 256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
| 257 | - } |
|
| 258 | - elseif ($filter['variable'] == 'url') |
|
| 259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 260 | - elseif ($filter['variable'] == 'message') |
|
| 265 | + } elseif ($filter['variable'] == 'url') { |
|
| 266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 267 | + } elseif ($filter['variable'] == 'message') |
|
| 261 | 268 | { |
| 262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
| 264 | - } |
|
| 265 | - elseif ($filter['variable'] == 'error_type') |
|
| 271 | + } elseif ($filter['variable'] == 'error_type') |
|
| 266 | 272 | { |
| 267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 274 | + } else { |
|
| 275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 268 | 276 | } |
| 269 | - else |
|
| 270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 271 | 277 | } |
| 272 | 278 | |
| 273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
| 308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
| 309 | 315 | |
| 310 | 316 | // Finally, work out what is the last tab! |
| 311 | - if (isset($context['error_types'][$sum])) |
|
| 312 | - $context['error_types'][$sum]['is_last'] = true; |
|
| 313 | - else |
|
| 314 | - $context['error_types']['all']['is_last'] = true; |
|
| 317 | + if (isset($context['error_types'][$sum])) { |
|
| 318 | + $context['error_types'][$sum]['is_last'] = true; |
|
| 319 | + } else { |
|
| 320 | + $context['error_types']['all']['is_last'] = true; |
|
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // And this is pretty basic ;). |
| 317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
| 337 | 344 | validateToken('admin-el'); |
| 338 | 345 | |
| 339 | 346 | // Delete all or just some? |
| 340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
| 341 | - $smcFunc['db_query']('truncate_table', ' |
|
| 347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
| 348 | + $smcFunc['db_query']('truncate_table', ' |
|
| 342 | 349 | TRUNCATE {db_prefix}log_errors', |
| 343 | 350 | array( |
| 344 | 351 | ) |
| 345 | 352 | ); |
| 353 | + } |
|
| 346 | 354 | // Deleting all with a filter? |
| 347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
| 348 | - $smcFunc['db_query']('', ' |
|
| 355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
| 356 | + $smcFunc['db_query']('', ' |
|
| 349 | 357 | DELETE FROM {db_prefix}log_errors |
| 350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
| 351 | 359 | array( |
| 352 | 360 | 'filter' => $filter['value']['sql'], |
| 353 | 361 | ) |
| 354 | 362 | ); |
| 363 | + } |
|
| 355 | 364 | // Just specific errors? |
| 356 | 365 | elseif (!empty($_POST['delete'])) |
| 357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
| 397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
| 398 | 407 | |
| 399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
| 400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
| 401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
| 410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 411 | + } |
|
| 402 | 412 | |
| 403 | 413 | // get the min and max lines |
| 404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
| 405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
| 406 | 416 | |
| 407 | - if ($max <= 0 || $min >= $max) |
|
| 408 | - fatal_lang_error('error_bad_line'); |
|
| 417 | + if ($max <= 0 || $min >= $max) { |
|
| 418 | + fatal_lang_error('error_bad_line'); |
|
| 419 | + } |
|
| 409 | 420 | |
| 410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
| 411 | 422 | |