@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
| 245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 246 | 247 | { |
| 247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
| 248 | - if (!empty($row['private'])) |
|
| 249 | - $row['subject'] = $txt['personal_message']; |
|
| 249 | + if (!empty($row['private'])) { |
|
| 250 | + $row['subject'] = $txt['personal_message']; |
|
| 251 | + } |
|
| 250 | 252 | |
| 251 | 253 | $mails[] = $row; |
| 252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
| 300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
| 301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
| 302 | 304 | } |
| 303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
| 304 | - $emails[$index] = $index; |
|
| 305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
| 306 | + $emails[$index] = $index; |
|
| 307 | + } |
|
| 305 | 308 | |
| 306 | 309 | $config_vars = array( |
| 307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
| 322 | 325 | |
| 323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
| 324 | 327 | |
| 325 | - if ($return_config) |
|
| 326 | - return $config_vars; |
|
| 328 | + if ($return_config) { |
|
| 329 | + return $config_vars; |
|
| 330 | + } |
|
| 327 | 331 | |
| 328 | 332 | // Saving? |
| 329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
| 398 | 402 | ); |
| 399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
| 400 | 404 | $smcFunc['db_free_result']($request); |
| 405 | + } else { |
|
| 406 | + $_GET['te'] = (int) $_GET['te']; |
|
| 401 | 407 | } |
| 402 | - else |
|
| 403 | - $_GET['te'] = (int) $_GET['te']; |
|
| 404 | 408 | |
| 405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
| 406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
| 424 | 428 | |
| 425 | 429 | // Try get more time... |
| 426 | 430 | @set_time_limit(600); |
| 427 | - if (function_exists('apache_reset_timeout')) |
|
| 428 | - @apache_reset_timeout(); |
|
| 431 | + if (function_exists('apache_reset_timeout')) { |
|
| 432 | + @apache_reset_timeout(); |
|
| 433 | + } |
|
| 429 | 434 | |
| 430 | 435 | // Have we already used our maximum time? |
| 431 | - if (time() - array_sum(explode(' ', $time_start)) < 5) |
|
| 432 | - return; |
|
| 436 | + if (time() - array_sum(explode(' ', $time_start)) < 5) { |
|
| 437 | + return; |
|
| 438 | + } |
|
| 433 | 439 | |
| 434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
| 459 | 465 | { |
| 460 | 466 | global $txt; |
| 461 | 467 | |
| 462 | - if ($time_diff < 0) |
|
| 463 | - $time_diff = 0; |
|
| 468 | + if ($time_diff < 0) { |
|
| 469 | + $time_diff = 0; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | // Just do a bit of an if fest... |
| 466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
| 481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
| 482 | 489 | } |
| 483 | 490 | // Otherwise must be second |
| 484 | - else |
|
| 485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 486 | -} |
|
| 491 | + else { |
|
| 492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 493 | + } |
|
| 494 | + } |
|
| 487 | 495 | |
| 488 | 496 | ?> |
@@ -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 | * The main 'Attachments and Avatars' management function. |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | call_integration_hook('integrate_manage_attachments', array(&$subActions)); |
| 64 | 65 | |
| 65 | 66 | // Pick the correct sub-action. |
| 66 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 67 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 68 | - else |
|
| 69 | - $context['sub_action'] = 'browse'; |
|
| 67 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 68 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 69 | + } else { |
|
| 70 | + $context['sub_action'] = 'browse'; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | // Default page title is good. |
| 72 | 74 | $context['page_title'] = $txt['attachments_avatars']; |
@@ -94,20 +96,20 @@ discard block |
||
| 94 | 96 | $context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
| 95 | 97 | |
| 96 | 98 | // If not set, show a default path for the base directory |
| 97 | - if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) |
|
| 98 | - if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
| 99 | + if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) { |
|
| 100 | + if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
| 99 | 101 | $modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1]; |
| 100 | - |
|
| 101 | - else |
|
| 102 | - $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
| 102 | + } else { |
|
| 103 | + $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
| 105 | 107 | |
| 106 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 108 | - |
|
| 109 | - else |
|
| 110 | - $context['valid_basedirectory'] = true; |
|
| 108 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 109 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 110 | + } else { |
|
| 111 | + $context['valid_basedirectory'] = true; |
|
| 112 | + } |
|
| 111 | 113 | |
| 112 | 114 | // A bit of razzle dazzle with the $txt strings. :) |
| 113 | 115 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
@@ -185,8 +187,9 @@ discard block |
||
| 185 | 187 | |
| 186 | 188 | call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars)); |
| 187 | 189 | |
| 188 | - if ($return_config) |
|
| 189 | - return $config_vars; |
|
| 190 | + if ($return_config) { |
|
| 191 | + return $config_vars; |
|
| 192 | + } |
|
| 190 | 193 | |
| 191 | 194 | // These are very likely to come in handy! (i.e. without them we're doomed!) |
| 192 | 195 | require_once($sourcedir . '/ManagePermissions.php'); |
@@ -197,21 +200,24 @@ discard block |
||
| 197 | 200 | { |
| 198 | 201 | checkSession(); |
| 199 | 202 | |
| 200 | - if (isset($_POST['attachmentUploadDir'])) |
|
| 201 | - unset($_POST['attachmentUploadDir']); |
|
| 203 | + if (isset($_POST['attachmentUploadDir'])) { |
|
| 204 | + unset($_POST['attachmentUploadDir']); |
|
| 205 | + } |
|
| 202 | 206 | |
| 203 | 207 | if (!empty($_POST['use_subdirectories_for_attachments'])) |
| 204 | 208 | { |
| 205 | - if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) |
|
| 206 | - $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
| 209 | + if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) { |
|
| 210 | + $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
| 211 | + } |
|
| 207 | 212 | |
| 208 | 213 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories'])) |
| 209 | 214 | { |
| 210 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
| 211 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 216 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 217 | + } |
|
| 218 | + } else { |
|
| 219 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 212 | 220 | } |
| 213 | - else |
|
| 214 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 215 | 221 | |
| 216 | 222 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
| 217 | 223 | { |
@@ -219,8 +225,9 @@ discard block |
||
| 219 | 225 | |
| 220 | 226 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) |
| 221 | 227 | { |
| 222 | - if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) |
|
| 223 | - $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 228 | + if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) { |
|
| 229 | + $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 230 | + } |
|
| 224 | 231 | } |
| 225 | 232 | |
| 226 | 233 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
@@ -336,8 +343,9 @@ discard block |
||
| 336 | 343 | |
| 337 | 344 | call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); |
| 338 | 345 | |
| 339 | - if ($return_config) |
|
| 340 | - return $config_vars; |
|
| 346 | + if ($return_config) { |
|
| 347 | + return $config_vars; |
|
| 348 | + } |
|
| 341 | 349 | |
| 342 | 350 | // We need this file for the settings template. |
| 343 | 351 | require_once($sourcedir . '/ManageServer.php'); |
@@ -348,17 +356,21 @@ discard block |
||
| 348 | 356 | checkSession(); |
| 349 | 357 | |
| 350 | 358 | // These settings cannot be left empty! |
| 351 | - if (empty($_POST['custom_avatar_dir'])) |
|
| 352 | - $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
| 359 | + if (empty($_POST['custom_avatar_dir'])) { |
|
| 360 | + $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
| 361 | + } |
|
| 353 | 362 | |
| 354 | - if (empty($_POST['custom_avatar_url'])) |
|
| 355 | - $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
| 363 | + if (empty($_POST['custom_avatar_url'])) { |
|
| 364 | + $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
| 365 | + } |
|
| 356 | 366 | |
| 357 | - if (empty($_POST['avatar_directory'])) |
|
| 358 | - $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
| 367 | + if (empty($_POST['avatar_directory'])) { |
|
| 368 | + $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
| 369 | + } |
|
| 359 | 370 | |
| 360 | - if (empty($_POST['avatar_url'])) |
|
| 361 | - $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
| 371 | + if (empty($_POST['avatar_url'])) { |
|
| 372 | + $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
| 373 | + } |
|
| 362 | 374 | |
| 363 | 375 | call_integration_hook('integrate_save_avatar_settings'); |
| 364 | 376 | |
@@ -406,11 +418,13 @@ discard block |
||
| 406 | 418 | $list_title = $txt['attachment_manager_browse_files'] . ': '; |
| 407 | 419 | foreach ($titles as $browse_type => $details) |
| 408 | 420 | { |
| 409 | - if ($browse_type != 'attachments') |
|
| 410 | - $list_title .= ' | '; |
|
| 421 | + if ($browse_type != 'attachments') { |
|
| 422 | + $list_title .= ' | '; |
|
| 423 | + } |
|
| 411 | 424 | |
| 412 | - if ($context['browse_type'] == $browse_type) |
|
| 413 | - $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 425 | + if ($context['browse_type'] == $browse_type) { |
|
| 426 | + $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 427 | + } |
|
| 414 | 428 | |
| 415 | 429 | $list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>'; |
| 416 | 430 | } |
@@ -446,28 +460,33 @@ discard block |
||
| 446 | 460 | $link = '<a href="'; |
| 447 | 461 | |
| 448 | 462 | // In case of a custom avatar URL attachments have a fixed directory. |
| 449 | - if ($rowData['attachment_type'] == 1) |
|
| 450 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 463 | + if ($rowData['attachment_type'] == 1) { |
|
| 464 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 465 | + } |
|
| 451 | 466 | |
| 452 | 467 | // By default avatars are downloaded almost as attachments. |
| 453 | - elseif ($context['browse_type'] == 'avatars') |
|
| 454 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 468 | + elseif ($context['browse_type'] == 'avatars') { |
|
| 469 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 470 | + } |
|
| 455 | 471 | |
| 456 | 472 | // Normal attachments are always linked to a topic ID. |
| 457 | - else |
|
| 458 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 473 | + else { |
|
| 474 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 475 | + } |
|
| 459 | 476 | |
| 460 | 477 | $link .= '"'; |
| 461 | 478 | |
| 462 | 479 | // Show a popup on click if it's a picture and we know its dimensions. |
| 463 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 464 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 480 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 481 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 482 | + } |
|
| 465 | 483 | |
| 466 | 484 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename']))); |
| 467 | 485 | |
| 468 | 486 | // Show the dimensions. |
| 469 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 470 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 487 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 488 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 489 | + } |
|
| 471 | 490 | |
| 472 | 491 | return $link; |
| 473 | 492 | }, |
@@ -500,12 +519,14 @@ discard block |
||
| 500 | 519 | 'function' => function ($rowData) use ($scripturl, $smcFunc) |
| 501 | 520 | { |
| 502 | 521 | // In case of an attachment, return the poster of the attachment. |
| 503 | - if (empty($rowData['id_member'])) |
|
| 504 | - return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 522 | + if (empty($rowData['id_member'])) { |
|
| 523 | + return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 524 | + } |
|
| 505 | 525 | |
| 506 | 526 | // Otherwise it must be an avatar, return the link to the owner of it. |
| 507 | - else |
|
| 508 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 527 | + else { |
|
| 528 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 529 | + } |
|
| 509 | 530 | }, |
| 510 | 531 | ), |
| 511 | 532 | 'sort' => array( |
@@ -524,8 +545,9 @@ discard block |
||
| 524 | 545 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
| 525 | 546 | |
| 526 | 547 | // Add a link to the topic in case of an attachment. |
| 527 | - if ($context['browse_type'] !== 'avatars') |
|
| 528 | - $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 548 | + if ($context['browse_type'] !== 'avatars') { |
|
| 549 | + $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 550 | + } |
|
| 529 | 551 | |
| 530 | 552 | return $date; |
| 531 | 553 | }, |
@@ -610,8 +632,8 @@ discard block |
||
| 610 | 632 | global $smcFunc, $txt; |
| 611 | 633 | |
| 612 | 634 | // Choose a query depending on what we are viewing. |
| 613 | - if ($browse_type === 'avatars') |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 635 | + if ($browse_type === 'avatars') { |
|
| 636 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 637 | SELECT |
| 616 | 638 | {string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name, |
| 617 | 639 | mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, |
@@ -630,8 +652,8 @@ discard block |
||
| 630 | 652 | 'per_page' => $items_per_page, |
| 631 | 653 | ) |
| 632 | 654 | ); |
| 633 | - else |
|
| 634 | - $request = $smcFunc['db_query']('', ' |
|
| 655 | + } else { |
|
| 656 | + $request = $smcFunc['db_query']('', ' |
|
| 635 | 657 | SELECT |
| 636 | 658 | m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member, |
| 637 | 659 | a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board |
@@ -650,9 +672,11 @@ discard block |
||
| 650 | 672 | 'per_page' => $items_per_page, |
| 651 | 673 | ) |
| 652 | 674 | ); |
| 675 | + } |
|
| 653 | 676 | $files = array(); |
| 654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 655 | - $files[] = $row; |
|
| 677 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 678 | + $files[] = $row; |
|
| 679 | + } |
|
| 656 | 680 | $smcFunc['db_free_result']($request); |
| 657 | 681 | |
| 658 | 682 | return $files; |
@@ -670,8 +694,8 @@ discard block |
||
| 670 | 694 | global $smcFunc; |
| 671 | 695 | |
| 672 | 696 | // Depending on the type of file, different queries are used. |
| 673 | - if ($browse_type === 'avatars') |
|
| 674 | - $request = $smcFunc['db_query']('', ' |
|
| 697 | + if ($browse_type === 'avatars') { |
|
| 698 | + $request = $smcFunc['db_query']('', ' |
|
| 675 | 699 | SELECT COUNT(*) |
| 676 | 700 | FROM {db_prefix}attachments |
| 677 | 701 | WHERE id_member != {int:guest_id_member}', |
@@ -679,8 +703,8 @@ discard block |
||
| 679 | 703 | 'guest_id_member' => 0, |
| 680 | 704 | ) |
| 681 | 705 | ); |
| 682 | - else |
|
| 683 | - $request = $smcFunc['db_query']('', ' |
|
| 706 | + } else { |
|
| 707 | + $request = $smcFunc['db_query']('', ' |
|
| 684 | 708 | SELECT COUNT(*) AS num_attach |
| 685 | 709 | FROM {db_prefix}attachments AS a |
| 686 | 710 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
@@ -693,6 +717,7 @@ discard block |
||
| 693 | 717 | 'guest_id_member' => 0, |
| 694 | 718 | ) |
| 695 | 719 | ); |
| 720 | + } |
|
| 696 | 721 | |
| 697 | 722 | list ($num_files) = $smcFunc['db_fetch_row']($request); |
| 698 | 723 | $smcFunc['db_free_result']($request); |
@@ -775,12 +800,14 @@ discard block |
||
| 775 | 800 | $current_dir_size /= 1024; |
| 776 | 801 | |
| 777 | 802 | // If they specified a limit only.... |
| 778 | - if (!empty($modSettings['attachmentDirSizeLimit'])) |
|
| 779 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 803 | + if (!empty($modSettings['attachmentDirSizeLimit'])) { |
|
| 804 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 805 | + } |
|
| 780 | 806 | $context['attachment_current_size'] = comma_format($current_dir_size, 2); |
| 781 | 807 | |
| 782 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
| 783 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 808 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
| 809 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 810 | + } |
|
| 784 | 811 | $context['attachment_current_files'] = comma_format($current_dir_files, 0); |
| 785 | 812 | |
| 786 | 813 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -817,8 +844,8 @@ discard block |
||
| 817 | 844 | $messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true); |
| 818 | 845 | |
| 819 | 846 | // Update the messages to reflect the change. |
| 820 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 821 | - $smcFunc['db_query']('', ' |
|
| 847 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 848 | + $smcFunc['db_query']('', ' |
|
| 822 | 849 | UPDATE {db_prefix}messages |
| 823 | 850 | SET body = CONCAT(body, {string:notice}) |
| 824 | 851 | WHERE id_msg IN ({array_int:messages})', |
@@ -827,8 +854,8 @@ discard block |
||
| 827 | 854 | 'notice' => '<br><br>' . $_POST['notice'], |
| 828 | 855 | ) |
| 829 | 856 | ); |
| 830 | - } |
|
| 831 | - else |
|
| 857 | + } |
|
| 858 | + } else |
|
| 832 | 859 | { |
| 833 | 860 | // Remove all the old avatars. |
| 834 | 861 | removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members'); |
@@ -853,8 +880,8 @@ discard block |
||
| 853 | 880 | $messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true); |
| 854 | 881 | |
| 855 | 882 | // And make a note on the post. |
| 856 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 857 | - $smcFunc['db_query']('', ' |
|
| 883 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 884 | + $smcFunc['db_query']('', ' |
|
| 858 | 885 | UPDATE {db_prefix}messages |
| 859 | 886 | SET body = CONCAT(body, {string:notice}) |
| 860 | 887 | WHERE id_msg IN ({array_int:messages})', |
@@ -863,6 +890,7 @@ discard block |
||
| 863 | 890 | 'notice' => '<br><br>' . $_POST['notice'], |
| 864 | 891 | ) |
| 865 | 892 | ); |
| 893 | + } |
|
| 866 | 894 | |
| 867 | 895 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 868 | 896 | } |
@@ -882,16 +910,17 @@ discard block |
||
| 882 | 910 | { |
| 883 | 911 | $attachments = array(); |
| 884 | 912 | // There must be a quicker way to pass this safety test?? |
| 885 | - foreach ($_POST['remove'] as $removeID => $dummy) |
|
| 886 | - $attachments[] = (int) $removeID; |
|
| 913 | + foreach ($_POST['remove'] as $removeID => $dummy) { |
|
| 914 | + $attachments[] = (int) $removeID; |
|
| 915 | + } |
|
| 887 | 916 | |
| 888 | 917 | // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. |
| 889 | 918 | $filesRemoved = false; |
| 890 | 919 | call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); |
| 891 | 920 | |
| 892 | - if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) |
|
| 893 | - removeAttachments(array('id_attach' => $attachments)); |
|
| 894 | - else if (!empty($attachments)) |
|
| 921 | + if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { |
|
| 922 | + removeAttachments(array('id_attach' => $attachments)); |
|
| 923 | + } else if (!empty($attachments)) |
|
| 895 | 924 | { |
| 896 | 925 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
| 897 | 926 | |
@@ -930,12 +959,13 @@ discard block |
||
| 930 | 959 | |
| 931 | 960 | $messages = removeAttachments(array('attachment_type' => 0), '', true); |
| 932 | 961 | |
| 933 | - if (!isset($_POST['notice'])) |
|
| 934 | - $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 962 | + if (!isset($_POST['notice'])) { |
|
| 963 | + $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 964 | + } |
|
| 935 | 965 | |
| 936 | 966 | // Add the notice on the end of the changed messages. |
| 937 | - if (!empty($messages)) |
|
| 938 | - $smcFunc['db_query']('', ' |
|
| 967 | + if (!empty($messages)) { |
|
| 968 | + $smcFunc['db_query']('', ' |
|
| 939 | 969 | UPDATE {db_prefix}messages |
| 940 | 970 | SET body = CONCAT(body, {string:deleted_message}) |
| 941 | 971 | WHERE id_msg IN ({array_int:messages})', |
@@ -944,6 +974,7 @@ discard block |
||
| 944 | 974 | 'deleted_message' => '<br><br>' . $_POST['notice'], |
| 945 | 975 | ) |
| 946 | 976 | ); |
| 977 | + } |
|
| 947 | 978 | |
| 948 | 979 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 949 | 980 | } |
@@ -982,24 +1013,26 @@ discard block |
||
| 982 | 1013 | $is_not = substr($real_type, 0, 4) == 'not_'; |
| 983 | 1014 | $type = $is_not ? substr($real_type, 4) : $real_type; |
| 984 | 1015 | |
| 985 | - if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) |
|
| 986 | - $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 987 | - elseif ($type == 'attachment_type') |
|
| 988 | - $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 989 | - elseif ($type == 'poster_time') |
|
| 990 | - $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 991 | - elseif ($type == 'last_login') |
|
| 992 | - $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 993 | - elseif ($type == 'size') |
|
| 994 | - $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 995 | - elseif ($type == 'id_topic') |
|
| 996 | - $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1016 | + if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) { |
|
| 1017 | + $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1018 | + } elseif ($type == 'attachment_type') { |
|
| 1019 | + $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 1020 | + } elseif ($type == 'poster_time') { |
|
| 1021 | + $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 1022 | + } elseif ($type == 'last_login') { |
|
| 1023 | + $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 1024 | + } elseif ($type == 'size') { |
|
| 1025 | + $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 1026 | + } elseif ($type == 'id_topic') { |
|
| 1027 | + $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1028 | + } |
|
| 997 | 1029 | |
| 998 | 1030 | // Add the parameter! |
| 999 | 1031 | $query_parameter[$real_type] = $restriction; |
| 1000 | 1032 | |
| 1001 | - if ($type == 'do_logging') |
|
| 1002 | - $do_logging = $condition['id_attach']; |
|
| 1033 | + if ($type == 'do_logging') { |
|
| 1034 | + $do_logging = $condition['id_attach']; |
|
| 1035 | + } |
|
| 1003 | 1036 | } |
| 1004 | 1037 | $condition = implode(' AND ', $new_condition); |
| 1005 | 1038 | } |
@@ -1031,15 +1064,15 @@ discard block |
||
| 1031 | 1064 | // wasn't it obvious? :P |
| 1032 | 1065 | // @todo look again at this. |
| 1033 | 1066 | @unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']); |
| 1034 | - } |
|
| 1035 | - else |
|
| 1067 | + } else |
|
| 1036 | 1068 | { |
| 1037 | 1069 | $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
| 1038 | 1070 | @unlink($filename); |
| 1039 | 1071 | |
| 1040 | 1072 | // If this was a thumb, the parent attachment should know about it. |
| 1041 | - if (!empty($row['id_parent'])) |
|
| 1042 | - $parents[] = $row['id_parent']; |
|
| 1073 | + if (!empty($row['id_parent'])) { |
|
| 1074 | + $parents[] = $row['id_parent']; |
|
| 1075 | + } |
|
| 1043 | 1076 | |
| 1044 | 1077 | // If this attachments has a thumb, remove it as well. |
| 1045 | 1078 | if (!empty($row['id_thumb']) && $autoThumbRemoval) |
@@ -1051,8 +1084,9 @@ discard block |
||
| 1051 | 1084 | } |
| 1052 | 1085 | |
| 1053 | 1086 | // Make a list. |
| 1054 | - if ($return_affected_messages && empty($row['attachment_type'])) |
|
| 1055 | - $msgs[] = $row['id_msg']; |
|
| 1087 | + if ($return_affected_messages && empty($row['attachment_type'])) { |
|
| 1088 | + $msgs[] = $row['id_msg']; |
|
| 1089 | + } |
|
| 1056 | 1090 | |
| 1057 | 1091 | $attach[] = $row['id_attach']; |
| 1058 | 1092 | } |
@@ -1060,8 +1094,8 @@ discard block |
||
| 1060 | 1094 | |
| 1061 | 1095 | // Removed attachments don't have to be updated anymore. |
| 1062 | 1096 | $parents = array_diff($parents, $attach); |
| 1063 | - if (!empty($parents)) |
|
| 1064 | - $smcFunc['db_query']('', ' |
|
| 1097 | + if (!empty($parents)) { |
|
| 1098 | + $smcFunc['db_query']('', ' |
|
| 1065 | 1099 | UPDATE {db_prefix}attachments |
| 1066 | 1100 | SET id_thumb = {int:no_thumb} |
| 1067 | 1101 | WHERE id_attach IN ({array_int:parent_attachments})', |
@@ -1070,6 +1104,7 @@ discard block |
||
| 1070 | 1104 | 'no_thumb' => 0, |
| 1071 | 1105 | ) |
| 1072 | 1106 | ); |
| 1107 | + } |
|
| 1073 | 1108 | |
| 1074 | 1109 | if (!empty($do_logging)) |
| 1075 | 1110 | { |
@@ -1086,31 +1121,34 @@ discard block |
||
| 1086 | 1121 | ) |
| 1087 | 1122 | ); |
| 1088 | 1123 | |
| 1089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1090 | - logAction( |
|
| 1124 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1125 | + logAction( |
|
| 1091 | 1126 | 'remove_attach', |
| 1092 | 1127 | array( |
| 1093 | 1128 | 'message' => $row['id_msg'], |
| 1094 | 1129 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1095 | 1130 | ) |
| 1096 | 1131 | ); |
| 1132 | + } |
|
| 1097 | 1133 | $smcFunc['db_free_result']($request); |
| 1098 | 1134 | } |
| 1099 | 1135 | |
| 1100 | - if (!empty($attach)) |
|
| 1101 | - $smcFunc['db_query']('', ' |
|
| 1136 | + if (!empty($attach)) { |
|
| 1137 | + $smcFunc['db_query']('', ' |
|
| 1102 | 1138 | DELETE FROM {db_prefix}attachments |
| 1103 | 1139 | WHERE id_attach IN ({array_int:attachment_list})', |
| 1104 | 1140 | array( |
| 1105 | 1141 | 'attachment_list' => $attach, |
| 1106 | 1142 | ) |
| 1107 | 1143 | ); |
| 1144 | + } |
|
| 1108 | 1145 | |
| 1109 | 1146 | call_integration_hook('integrate_remove_attachments', array($attach)); |
| 1110 | 1147 | |
| 1111 | - if ($return_affected_messages) |
|
| 1112 | - return array_unique($msgs); |
|
| 1113 | -} |
|
| 1148 | + if ($return_affected_messages) { |
|
| 1149 | + return array_unique($msgs); |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1114 | 1152 | |
| 1115 | 1153 | /** |
| 1116 | 1154 | * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues. |
@@ -1122,8 +1160,9 @@ discard block |
||
| 1122 | 1160 | checkSession('get'); |
| 1123 | 1161 | |
| 1124 | 1162 | // If we choose cancel, redirect right back. |
| 1125 | - if (isset($_POST['cancel'])) |
|
| 1126 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1163 | + if (isset($_POST['cancel'])) { |
|
| 1164 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1165 | + } |
|
| 1127 | 1166 | |
| 1128 | 1167 | // Try give us a while to sort this out... |
| 1129 | 1168 | @set_time_limit(600); |
@@ -1140,13 +1179,15 @@ discard block |
||
| 1140 | 1179 | if (isset($_GET['fixErrors'])) |
| 1141 | 1180 | { |
| 1142 | 1181 | // Nothing? |
| 1143 | - if (empty($_POST['to_fix'])) |
|
| 1144 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1182 | + if (empty($_POST['to_fix'])) { |
|
| 1183 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1184 | + } |
|
| 1145 | 1185 | |
| 1146 | 1186 | $_SESSION['attachments_to_fix'] = array(); |
| 1147 | 1187 | // @todo No need to do this I think. |
| 1148 | - foreach ($_POST['to_fix'] as $value) |
|
| 1149 | - $_SESSION['attachments_to_fix'][] = $value; |
|
| 1188 | + foreach ($_POST['to_fix'] as $value) { |
|
| 1189 | + $_SESSION['attachments_to_fix'][] = $value; |
|
| 1190 | + } |
|
| 1150 | 1191 | } |
| 1151 | 1192 | } |
| 1152 | 1193 | |
@@ -1213,13 +1254,14 @@ discard block |
||
| 1213 | 1254 | } |
| 1214 | 1255 | } |
| 1215 | 1256 | } |
| 1216 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1217 | - $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1257 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1258 | + $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1259 | + } |
|
| 1218 | 1260 | $smcFunc['db_free_result']($result); |
| 1219 | 1261 | |
| 1220 | 1262 | // Do we need to delete what we have? |
| 1221 | - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) |
|
| 1222 | - $smcFunc['db_query']('', ' |
|
| 1263 | + if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { |
|
| 1264 | + $smcFunc['db_query']('', ' |
|
| 1223 | 1265 | DELETE FROM {db_prefix}attachments |
| 1224 | 1266 | WHERE id_attach IN ({array_int:to_remove}) |
| 1225 | 1267 | AND attachment_type = {int:attachment_type}', |
@@ -1228,6 +1270,7 @@ discard block |
||
| 1228 | 1270 | 'attachment_type' => 3, |
| 1229 | 1271 | ) |
| 1230 | 1272 | ); |
| 1273 | + } |
|
| 1231 | 1274 | |
| 1232 | 1275 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1233 | 1276 | } |
@@ -1272,13 +1315,14 @@ discard block |
||
| 1272 | 1315 | $to_update[] = $row['id_attach']; |
| 1273 | 1316 | $context['repair_errors']['parent_missing_thumbnail']++; |
| 1274 | 1317 | } |
| 1275 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1276 | - $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1318 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1319 | + $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1320 | + } |
|
| 1277 | 1321 | $smcFunc['db_free_result']($result); |
| 1278 | 1322 | |
| 1279 | 1323 | // Do we need to delete what we have? |
| 1280 | - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) |
|
| 1281 | - $smcFunc['db_query']('', ' |
|
| 1324 | + if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { |
|
| 1325 | + $smcFunc['db_query']('', ' |
|
| 1282 | 1326 | UPDATE {db_prefix}attachments |
| 1283 | 1327 | SET id_thumb = {int:no_thumb} |
| 1284 | 1328 | WHERE id_attach IN ({array_int:to_update})', |
@@ -1287,6 +1331,7 @@ discard block |
||
| 1287 | 1331 | 'no_thumb' => 0, |
| 1288 | 1332 | ) |
| 1289 | 1333 | ); |
| 1334 | + } |
|
| 1290 | 1335 | |
| 1291 | 1336 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1292 | 1337 | } |
@@ -1324,10 +1369,11 @@ discard block |
||
| 1324 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1325 | 1370 | { |
| 1326 | 1371 | // Get the filename. |
| 1327 | - if ($row['attachment_type'] == 1) |
|
| 1328 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1329 | - else |
|
| 1330 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1372 | + if ($row['attachment_type'] == 1) { |
|
| 1373 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1374 | + } else { |
|
| 1375 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1376 | + } |
|
| 1331 | 1377 | |
| 1332 | 1378 | // File doesn't exist? |
| 1333 | 1379 | if (!file_exists($filename)) |
@@ -1339,15 +1385,16 @@ discard block |
||
| 1339 | 1385 | $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] .'.dat'; |
| 1340 | 1386 | |
| 1341 | 1387 | // Loop through the other folders. |
| 1342 | - foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
|
| 1343 | - if (file_exists($dir . '/' . $attachment_name)) |
|
| 1388 | + foreach ($modSettings['attachmentUploadDir'] as $id => $dir) { |
|
| 1389 | + if (file_exists($dir . '/' . $attachment_name)) |
|
| 1344 | 1390 | { |
| 1345 | 1391 | $context['repair_errors']['wrong_folder']++; |
| 1392 | + } |
|
| 1346 | 1393 | $errors_found[] = 'wrong_folder'; |
| 1347 | 1394 | |
| 1348 | 1395 | // Are we going to fix this now? |
| 1349 | - if ($fix_errors && in_array('wrong_folder', $to_fix)) |
|
| 1350 | - $smcFunc['db_query']('', ' |
|
| 1396 | + if ($fix_errors && in_array('wrong_folder', $to_fix)) { |
|
| 1397 | + $smcFunc['db_query']('', ' |
|
| 1351 | 1398 | UPDATE {db_prefix}attachments |
| 1352 | 1399 | SET id_folder = {int:new_folder} |
| 1353 | 1400 | WHERE id_attach = {int:id_attach}', |
@@ -1356,6 +1403,7 @@ discard block |
||
| 1356 | 1403 | 'id_attach' => $row['id_attach'], |
| 1357 | 1404 | ) |
| 1358 | 1405 | ); |
| 1406 | + } |
|
| 1359 | 1407 | |
| 1360 | 1408 | continue 2; |
| 1361 | 1409 | } |
@@ -1364,8 +1412,7 @@ discard block |
||
| 1364 | 1412 | $to_remove[] = $row['id_attach']; |
| 1365 | 1413 | $context['repair_errors']['file_missing_on_disk']++; |
| 1366 | 1414 | $errors_found[] = 'file_missing_on_disk'; |
| 1367 | - } |
|
| 1368 | - elseif (filesize($filename) == 0) |
|
| 1415 | + } elseif (filesize($filename) == 0) |
|
| 1369 | 1416 | { |
| 1370 | 1417 | $context['repair_errors']['file_size_of_zero']++; |
| 1371 | 1418 | $errors_found[] = 'file_size_of_zero'; |
@@ -1376,8 +1423,7 @@ discard block |
||
| 1376 | 1423 | $to_remove[] = $row['id_attach']; |
| 1377 | 1424 | @unlink($filename); |
| 1378 | 1425 | } |
| 1379 | - } |
|
| 1380 | - elseif (filesize($filename) != $row['size']) |
|
| 1426 | + } elseif (filesize($filename) != $row['size']) |
|
| 1381 | 1427 | { |
| 1382 | 1428 | $context['repair_errors']['file_wrong_size']++; |
| 1383 | 1429 | $errors_found[] = 'file_wrong_size'; |
@@ -1398,14 +1444,18 @@ discard block |
||
| 1398 | 1444 | } |
| 1399 | 1445 | } |
| 1400 | 1446 | |
| 1401 | - if (in_array('file_missing_on_disk', $errors_found)) |
|
| 1402 | - $to_fix[] = 'file_missing_on_disk'; |
|
| 1403 | - if (in_array('file_size_of_zero', $errors_found)) |
|
| 1404 | - $to_fix[] = 'file_size_of_zero'; |
|
| 1405 | - if (in_array('file_wrong_size', $errors_found)) |
|
| 1406 | - $to_fix[] = 'file_wrong_size'; |
|
| 1407 | - if (in_array('wrong_folder', $errors_found)) |
|
| 1408 | - $to_fix[] = 'wrong_folder'; |
|
| 1447 | + if (in_array('file_missing_on_disk', $errors_found)) { |
|
| 1448 | + $to_fix[] = 'file_missing_on_disk'; |
|
| 1449 | + } |
|
| 1450 | + if (in_array('file_size_of_zero', $errors_found)) { |
|
| 1451 | + $to_fix[] = 'file_size_of_zero'; |
|
| 1452 | + } |
|
| 1453 | + if (in_array('file_wrong_size', $errors_found)) { |
|
| 1454 | + $to_fix[] = 'file_wrong_size'; |
|
| 1455 | + } |
|
| 1456 | + if (in_array('wrong_folder', $errors_found)) { |
|
| 1457 | + $to_fix[] = 'wrong_folder'; |
|
| 1458 | + } |
|
| 1409 | 1459 | $smcFunc['db_free_result']($result); |
| 1410 | 1460 | |
| 1411 | 1461 | // Do we need to delete what we have? |
@@ -1475,20 +1525,22 @@ discard block |
||
| 1475 | 1525 | // If we are repairing remove the file from disk now. |
| 1476 | 1526 | if ($fix_errors && in_array('avatar_no_member', $to_fix)) |
| 1477 | 1527 | { |
| 1478 | - if ($row['attachment_type'] == 1) |
|
| 1479 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1480 | - else |
|
| 1481 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1528 | + if ($row['attachment_type'] == 1) { |
|
| 1529 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1530 | + } else { |
|
| 1531 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1532 | + } |
|
| 1482 | 1533 | @unlink($filename); |
| 1483 | 1534 | } |
| 1484 | 1535 | } |
| 1485 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1486 | - $to_fix[] = 'avatar_no_member'; |
|
| 1536 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1537 | + $to_fix[] = 'avatar_no_member'; |
|
| 1538 | + } |
|
| 1487 | 1539 | $smcFunc['db_free_result']($result); |
| 1488 | 1540 | |
| 1489 | 1541 | // Do we need to delete what we have? |
| 1490 | - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) |
|
| 1491 | - $smcFunc['db_query']('', ' |
|
| 1542 | + if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { |
|
| 1543 | + $smcFunc['db_query']('', ' |
|
| 1492 | 1544 | DELETE FROM {db_prefix}attachments |
| 1493 | 1545 | WHERE id_attach IN ({array_int:to_remove}) |
| 1494 | 1546 | AND id_member != {int:no_member} |
@@ -1499,6 +1551,7 @@ discard block |
||
| 1499 | 1551 | 'no_msg' => 0, |
| 1500 | 1552 | ) |
| 1501 | 1553 | ); |
| 1554 | + } |
|
| 1502 | 1555 | |
| 1503 | 1556 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1504 | 1557 | } |
@@ -1554,13 +1607,14 @@ discard block |
||
| 1554 | 1607 | @unlink($filename); |
| 1555 | 1608 | } |
| 1556 | 1609 | } |
| 1557 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1558 | - $to_fix[] = 'attachment_no_msg'; |
|
| 1610 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1611 | + $to_fix[] = 'attachment_no_msg'; |
|
| 1612 | + } |
|
| 1559 | 1613 | $smcFunc['db_free_result']($result); |
| 1560 | 1614 | |
| 1561 | 1615 | // Do we need to delete what we have? |
| 1562 | - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) |
|
| 1563 | - $smcFunc['db_query']('', ' |
|
| 1616 | + if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { |
|
| 1617 | + $smcFunc['db_query']('', ' |
|
| 1564 | 1618 | DELETE FROM {db_prefix}attachments |
| 1565 | 1619 | WHERE id_attach IN ({array_int:to_remove}) |
| 1566 | 1620 | AND id_member = {int:no_member} |
@@ -1571,6 +1625,7 @@ discard block |
||
| 1571 | 1625 | 'no_msg' => 0, |
| 1572 | 1626 | ) |
| 1573 | 1627 | ); |
| 1628 | + } |
|
| 1574 | 1629 | |
| 1575 | 1630 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1576 | 1631 | } |
@@ -1594,8 +1649,9 @@ discard block |
||
| 1594 | 1649 | { |
| 1595 | 1650 | while ($file = readdir($dir)) |
| 1596 | 1651 | { |
| 1597 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 1598 | - continue; |
|
| 1652 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 1653 | + continue; |
|
| 1654 | + } |
|
| 1599 | 1655 | |
| 1600 | 1656 | if ($files_checked <= $current_check) |
| 1601 | 1657 | { |
@@ -1603,8 +1659,9 @@ discard block |
||
| 1603 | 1659 | if (strpos($file, 'post_tmp_') !== false) |
| 1604 | 1660 | { |
| 1605 | 1661 | // Temp file is more than 5 hours old! |
| 1606 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1607 | - @unlink($attach_dir . '/' . $file); |
|
| 1662 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1663 | + @unlink($attach_dir . '/' . $file); |
|
| 1664 | + } |
|
| 1608 | 1665 | } |
| 1609 | 1666 | // That should be an attachment, let's check if we have it in the database |
| 1610 | 1667 | elseif (strpos($file, '_') !== false) |
@@ -1626,8 +1683,7 @@ discard block |
||
| 1626 | 1683 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1627 | 1684 | { |
| 1628 | 1685 | @unlink($attach_dir . '/' . $file); |
| 1629 | - } |
|
| 1630 | - else |
|
| 1686 | + } else |
|
| 1631 | 1687 | { |
| 1632 | 1688 | $context['repair_errors']['files_without_attachment']++; |
| 1633 | 1689 | $to_fix[] = 'files_without_attachment'; |
@@ -1635,14 +1691,12 @@ discard block |
||
| 1635 | 1691 | } |
| 1636 | 1692 | $smcFunc['db_free_result']($request); |
| 1637 | 1693 | } |
| 1638 | - } |
|
| 1639 | - else |
|
| 1694 | + } else |
|
| 1640 | 1695 | { |
| 1641 | 1696 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1642 | 1697 | { |
| 1643 | 1698 | @unlink($attach_dir . '/' . $file); |
| 1644 | - } |
|
| 1645 | - else |
|
| 1699 | + } else |
|
| 1646 | 1700 | { |
| 1647 | 1701 | $context['repair_errors']['files_without_attachment']++; |
| 1648 | 1702 | $to_fix[] = 'files_without_attachment'; |
@@ -1651,8 +1705,9 @@ discard block |
||
| 1651 | 1705 | } |
| 1652 | 1706 | $current_check++; |
| 1653 | 1707 | $_GET['substep'] = $current_check; |
| 1654 | - if ($current_check - $files_checked >= $max_checks) |
|
| 1655 | - pauseAttachmentMaintenance($to_fix); |
|
| 1708 | + if ($current_check - $files_checked >= $max_checks) { |
|
| 1709 | + pauseAttachmentMaintenance($to_fix); |
|
| 1710 | + } |
|
| 1656 | 1711 | } |
| 1657 | 1712 | closedir($dir); |
| 1658 | 1713 | } |
@@ -1688,12 +1743,14 @@ discard block |
||
| 1688 | 1743 | |
| 1689 | 1744 | // Try get more time... |
| 1690 | 1745 | @set_time_limit(600); |
| 1691 | - if (function_exists('apache_reset_timeout')) |
|
| 1692 | - @apache_reset_timeout(); |
|
| 1746 | + if (function_exists('apache_reset_timeout')) { |
|
| 1747 | + @apache_reset_timeout(); |
|
| 1748 | + } |
|
| 1693 | 1749 | |
| 1694 | 1750 | // Have we already used our maximum time? |
| 1695 | - if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
| 1696 | - return; |
|
| 1751 | + if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) { |
|
| 1752 | + return; |
|
| 1753 | + } |
|
| 1697 | 1754 | |
| 1698 | 1755 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1699 | 1756 | $context['page_title'] = $txt['not_done_title']; |
@@ -1705,10 +1762,11 @@ discard block |
||
| 1705 | 1762 | $context[$context['admin_menu_name']]['current_subsection'] = 'maintenance'; |
| 1706 | 1763 | |
| 1707 | 1764 | // Change these two if more steps are added! |
| 1708 | - if (empty($max_substep)) |
|
| 1709 | - $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1710 | - else |
|
| 1711 | - $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1765 | + if (empty($max_substep)) { |
|
| 1766 | + $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1767 | + } else { |
|
| 1768 | + $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1769 | + } |
|
| 1712 | 1770 | |
| 1713 | 1771 | // Never more than 100%! |
| 1714 | 1772 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1750,15 +1808,17 @@ discard block |
||
| 1750 | 1808 | 'attachment_type' => 0, |
| 1751 | 1809 | ) |
| 1752 | 1810 | ); |
| 1753 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1754 | - $attachments[] = $row['id_attach']; |
|
| 1811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1812 | + $attachments[] = $row['id_attach']; |
|
| 1813 | + } |
|
| 1755 | 1814 | $smcFunc['db_free_result']($request); |
| 1815 | + } elseif (!empty($_GET['aid'])) { |
|
| 1816 | + $attachments[] = (int) $_GET['aid']; |
|
| 1756 | 1817 | } |
| 1757 | - elseif (!empty($_GET['aid'])) |
|
| 1758 | - $attachments[] = (int) $_GET['aid']; |
|
| 1759 | 1818 | |
| 1760 | - if (empty($attachments)) |
|
| 1761 | - fatal_lang_error('no_access', false); |
|
| 1819 | + if (empty($attachments)) { |
|
| 1820 | + fatal_lang_error('no_access', false); |
|
| 1821 | + } |
|
| 1762 | 1822 | |
| 1763 | 1823 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
| 1764 | 1824 | $allowed_boards = boardsAllowedTo('approve_posts'); |
@@ -1791,17 +1851,18 @@ discard block |
||
| 1791 | 1851 | } |
| 1792 | 1852 | $smcFunc['db_free_result']($request); |
| 1793 | 1853 | |
| 1794 | - if (empty($attachments)) |
|
| 1795 | - fatal_lang_error('no_access', false); |
|
| 1854 | + if (empty($attachments)) { |
|
| 1855 | + fatal_lang_error('no_access', false); |
|
| 1856 | + } |
|
| 1796 | 1857 | |
| 1797 | 1858 | // Finally, we are there. Follow through! |
| 1798 | 1859 | if ($is_approve) |
| 1799 | 1860 | { |
| 1800 | 1861 | // Checked and deemed worthy. |
| 1801 | 1862 | ApproveAttachments($attachments); |
| 1863 | + } else { |
|
| 1864 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1802 | 1865 | } |
| 1803 | - else |
|
| 1804 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1805 | 1866 | |
| 1806 | 1867 | // Return to the topic.... |
| 1807 | 1868 | redirectexit($redirect); |
@@ -1817,8 +1878,9 @@ discard block |
||
| 1817 | 1878 | { |
| 1818 | 1879 | global $smcFunc; |
| 1819 | 1880 | |
| 1820 | - if (empty($attachments)) |
|
| 1821 | - return 0; |
|
| 1881 | + if (empty($attachments)) { |
|
| 1882 | + return 0; |
|
| 1883 | + } |
|
| 1822 | 1884 | |
| 1823 | 1885 | // For safety, check for thumbnails... |
| 1824 | 1886 | $request = $smcFunc['db_query']('', ' |
@@ -1837,15 +1899,17 @@ discard block |
||
| 1837 | 1899 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1838 | 1900 | { |
| 1839 | 1901 | // Update the thumbnail too... |
| 1840 | - if (!empty($row['id_thumb'])) |
|
| 1841 | - $attachments[] = $row['id_thumb']; |
|
| 1902 | + if (!empty($row['id_thumb'])) { |
|
| 1903 | + $attachments[] = $row['id_thumb']; |
|
| 1904 | + } |
|
| 1842 | 1905 | |
| 1843 | 1906 | $attachments[] = $row['id_attach']; |
| 1844 | 1907 | } |
| 1845 | 1908 | $smcFunc['db_free_result']($request); |
| 1846 | 1909 | |
| 1847 | - if (empty($attachments)) |
|
| 1848 | - return 0; |
|
| 1910 | + if (empty($attachments)) { |
|
| 1911 | + return 0; |
|
| 1912 | + } |
|
| 1849 | 1913 | |
| 1850 | 1914 | // Approving an attachment is not hard - it's easy. |
| 1851 | 1915 | $smcFunc['db_query']('', ' |
@@ -1871,14 +1935,15 @@ discard block |
||
| 1871 | 1935 | ) |
| 1872 | 1936 | ); |
| 1873 | 1937 | |
| 1874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1875 | - logAction( |
|
| 1938 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1939 | + logAction( |
|
| 1876 | 1940 | 'approve_attach', |
| 1877 | 1941 | array( |
| 1878 | 1942 | 'message' => $row['id_msg'], |
| 1879 | 1943 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1880 | 1944 | ) |
| 1881 | 1945 | ); |
| 1946 | + } |
|
| 1882 | 1947 | $smcFunc['db_free_result']($request); |
| 1883 | 1948 | |
| 1884 | 1949 | // Remove from the approval queue. |
@@ -1901,11 +1966,11 @@ discard block |
||
| 1901 | 1966 | global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings; |
| 1902 | 1967 | |
| 1903 | 1968 | // Since this needs to be done eventually. |
| 1904 | - if (!isset($modSettings['attachment_basedirectories'])) |
|
| 1905 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 1906 | - |
|
| 1907 | - elseif (!is_array($modSettings['attachment_basedirectories'])) |
|
| 1908 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 1969 | + if (!isset($modSettings['attachment_basedirectories'])) { |
|
| 1970 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 1971 | + } elseif (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 1972 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 1973 | + } |
|
| 1909 | 1974 | |
| 1910 | 1975 | $errors = array(); |
| 1911 | 1976 | |
@@ -1920,8 +1985,9 @@ discard block |
||
| 1920 | 1985 | { |
| 1921 | 1986 | $error = ''; |
| 1922 | 1987 | $id = (int) $id; |
| 1923 | - if ($id < 1) |
|
| 1924 | - continue; |
|
| 1988 | + if ($id < 1) { |
|
| 1989 | + continue; |
|
| 1990 | + } |
|
| 1925 | 1991 | |
| 1926 | 1992 | // Sorry, these dirs are NOT valid |
| 1927 | 1993 | $invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir); |
@@ -1940,8 +2006,7 @@ discard block |
||
| 1940 | 2006 | { |
| 1941 | 2007 | $errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg']; |
| 1942 | 2008 | continue; |
| 1943 | - } |
|
| 1944 | - elseif (empty($path)) |
|
| 2009 | + } elseif (empty($path)) |
|
| 1945 | 2010 | { |
| 1946 | 2011 | // Ignore this and set $id to one less |
| 1947 | 2012 | continue; |
@@ -1949,10 +2014,11 @@ discard block |
||
| 1949 | 2014 | |
| 1950 | 2015 | // OK, so let's try to create it then. |
| 1951 | 2016 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1952 | - if (automanage_attachments_create_directory($path)) |
|
| 1953 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 1954 | - else |
|
| 1955 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2017 | + if (automanage_attachments_create_directory($path)) { |
|
| 2018 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2019 | + } else { |
|
| 2020 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2021 | + } |
|
| 1956 | 2022 | } |
| 1957 | 2023 | |
| 1958 | 2024 | // Changing a directory name? |
@@ -1965,8 +2031,7 @@ discard block |
||
| 1965 | 2031 | $errors[] = $path . ': ' . $txt['attach_dir_no_rename']; |
| 1966 | 2032 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1967 | 2033 | } |
| 1968 | - } |
|
| 1969 | - else |
|
| 2034 | + } else |
|
| 1970 | 2035 | { |
| 1971 | 2036 | $errors[] = $path . ': ' . $txt['attach_dir_exists_msg']; |
| 1972 | 2037 | $path = $modSettings['attachmentUploadDir'][$id]; |
@@ -1991,12 +2056,13 @@ discard block |
||
| 1991 | 2056 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1992 | 2057 | |
| 1993 | 2058 | // It's not a good idea to delete the current directory. |
| 1994 | - if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) |
|
| 1995 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2059 | + if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) { |
|
| 2060 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2061 | + } |
|
| 1996 | 2062 | // Or the current base directory |
| 1997 | - elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
|
| 1998 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 1999 | - else |
|
| 2063 | + elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) { |
|
| 2064 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 2065 | + } else |
|
| 2000 | 2066 | { |
| 2001 | 2067 | // Let's not try to delete a path with files in it. |
| 2002 | 2068 | $request = $smcFunc['db_query']('', ' |
@@ -2015,17 +2081,18 @@ discard block |
||
| 2015 | 2081 | if (!empty($modSettings['attachment_basedirectories'])) |
| 2016 | 2082 | { |
| 2017 | 2083 | // Count any sub-folders. |
| 2018 | - foreach ($modSettings['attachmentUploadDir'] as $sub) |
|
| 2019 | - if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2084 | + foreach ($modSettings['attachmentUploadDir'] as $sub) { |
|
| 2085 | + if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2020 | 2086 | $num_attach++; |
| 2087 | + } |
|
| 2021 | 2088 | } |
| 2022 | 2089 | |
| 2023 | 2090 | // It's safe to delete. So try to delete the folder also |
| 2024 | 2091 | if ($num_attach == 0) |
| 2025 | 2092 | { |
| 2026 | - if (is_dir($path)) |
|
| 2027 | - $doit = true; |
|
| 2028 | - elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2093 | + if (is_dir($path)) { |
|
| 2094 | + $doit = true; |
|
| 2095 | + } elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2029 | 2096 | { |
| 2030 | 2097 | $doit = true; |
| 2031 | 2098 | $path = $boarddir . DIRECTORY_SEPARATOR . $path; |
@@ -2035,8 +2102,9 @@ discard block |
||
| 2035 | 2102 | { |
| 2036 | 2103 | unlink($path . '/.htaccess'); |
| 2037 | 2104 | unlink($path . '/index.php'); |
| 2038 | - if (!@rmdir($path)) |
|
| 2039 | - $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2105 | + if (!@rmdir($path)) { |
|
| 2106 | + $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2107 | + } |
|
| 2040 | 2108 | } |
| 2041 | 2109 | |
| 2042 | 2110 | // Remove it from the base directory list. |
@@ -2046,14 +2114,15 @@ discard block |
||
| 2046 | 2114 | updateSettings(array('attachment_basedirectories' => json_encode($modSettings['attachment_basedirectories']))); |
| 2047 | 2115 | $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
| 2048 | 2116 | } |
| 2117 | + } else { |
|
| 2118 | + $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2049 | 2119 | } |
| 2050 | - else |
|
| 2051 | - $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2052 | 2120 | |
| 2053 | - if (empty($error)) |
|
| 2054 | - continue; |
|
| 2055 | - else |
|
| 2056 | - $errors[] = $error; |
|
| 2121 | + if (empty($error)) { |
|
| 2122 | + continue; |
|
| 2123 | + } else { |
|
| 2124 | + $errors[] = $error; |
|
| 2125 | + } |
|
| 2057 | 2126 | } |
| 2058 | 2127 | } |
| 2059 | 2128 | |
@@ -2061,23 +2130,26 @@ discard block |
||
| 2061 | 2130 | } |
| 2062 | 2131 | |
| 2063 | 2132 | // We need to make sure the current directory is right. |
| 2064 | - if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) |
|
| 2065 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2133 | + if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 2134 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2135 | + } |
|
| 2066 | 2136 | |
| 2067 | 2137 | // Find the current directory if there's no value carried, |
| 2068 | 2138 | if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) |
| 2069 | 2139 | { |
| 2070 | - if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
|
| 2071 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2072 | - else |
|
| 2073 | - $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2140 | + if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) { |
|
| 2141 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2142 | + } else { |
|
| 2143 | + $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2144 | + } |
|
| 2074 | 2145 | } |
| 2075 | 2146 | |
| 2076 | 2147 | // If the user wishes to go back, update the last_dir array |
| 2077 | 2148 | if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
| 2078 | 2149 | { |
| 2079 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
| 2080 | - $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
| 2150 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
| 2151 | + $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
| 2152 | + } |
|
| 2081 | 2153 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1); |
| 2082 | 2154 | |
| 2083 | 2155 | if (is_numeric($num)) |
@@ -2085,16 +2157,18 @@ discard block |
||
| 2085 | 2157 | // Need to find the base folder. |
| 2086 | 2158 | $bid = -1; |
| 2087 | 2159 | $use_subdirectories_for_attachments = 0; |
| 2088 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2089 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2160 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2161 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2090 | 2162 | if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false) |
| 2091 | 2163 | { |
| 2092 | 2164 | $use_subdirectories_for_attachments = 1; |
| 2165 | + } |
|
| 2093 | 2166 | break; |
| 2094 | 2167 | } |
| 2095 | 2168 | |
| 2096 | - if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) |
|
| 2097 | - $bid = 0; |
|
| 2169 | + if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) { |
|
| 2170 | + $bid = 0; |
|
| 2171 | + } |
|
| 2098 | 2172 | |
| 2099 | 2173 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
| 2100 | 2174 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -2113,8 +2187,8 @@ discard block |
||
| 2113 | 2187 | // We might need to reset the paths. This loop will just loop through once. |
| 2114 | 2188 | foreach ($new_dirs as $id => $dir) |
| 2115 | 2189 | { |
| 2116 | - if ($id != 1) |
|
| 2117 | - $smcFunc['db_query']('', ' |
|
| 2190 | + if ($id != 1) { |
|
| 2191 | + $smcFunc['db_query']('', ' |
|
| 2118 | 2192 | UPDATE {db_prefix}attachments |
| 2119 | 2193 | SET id_folder = {int:default_folder} |
| 2120 | 2194 | WHERE id_folder = {int:current_folder}', |
@@ -2123,14 +2197,14 @@ discard block |
||
| 2123 | 2197 | 'current_folder' => $id, |
| 2124 | 2198 | ) |
| 2125 | 2199 | ); |
| 2200 | + } |
|
| 2126 | 2201 | |
| 2127 | 2202 | $update = array( |
| 2128 | 2203 | 'currentAttachmentUploadDir' => 1, |
| 2129 | 2204 | 'attachmentUploadDir' => json_encode(array(1 => $dir)), |
| 2130 | 2205 | ); |
| 2131 | 2206 | } |
| 2132 | - } |
|
| 2133 | - else |
|
| 2207 | + } else |
|
| 2134 | 2208 | { |
| 2135 | 2209 | // Save it to the database. |
| 2136 | 2210 | $update = array( |
@@ -2139,11 +2213,13 @@ discard block |
||
| 2139 | 2213 | ); |
| 2140 | 2214 | } |
| 2141 | 2215 | |
| 2142 | - if (!empty($update)) |
|
| 2143 | - updateSettings($update); |
|
| 2216 | + if (!empty($update)) { |
|
| 2217 | + updateSettings($update); |
|
| 2218 | + } |
|
| 2144 | 2219 | |
| 2145 | - if (!empty($errors)) |
|
| 2146 | - $_SESSION['errors']['dir'] = $errors; |
|
| 2220 | + if (!empty($errors)) { |
|
| 2221 | + $_SESSION['errors']['dir'] = $errors; |
|
| 2222 | + } |
|
| 2147 | 2223 | |
| 2148 | 2224 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2149 | 2225 | } |
@@ -2157,10 +2233,11 @@ discard block |
||
| 2157 | 2233 | $_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1; |
| 2158 | 2234 | if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir'])) |
| 2159 | 2235 | { |
| 2160 | - if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) |
|
| 2161 | - $update = (array( |
|
| 2236 | + if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) { |
|
| 2237 | + $update = (array( |
|
| 2162 | 2238 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']], |
| 2163 | 2239 | )); |
| 2240 | + } |
|
| 2164 | 2241 | } |
| 2165 | 2242 | |
| 2166 | 2243 | if (isset($_POST['base_dir'])) |
@@ -2208,13 +2285,15 @@ discard block |
||
| 2208 | 2285 | |
| 2209 | 2286 | if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir'])) |
| 2210 | 2287 | { |
| 2211 | - if (!automanage_attachments_create_directory($_POST['new_base_dir'])) |
|
| 2212 | - $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2288 | + if (!automanage_attachments_create_directory($_POST['new_base_dir'])) { |
|
| 2289 | + $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2290 | + } |
|
| 2213 | 2291 | } |
| 2214 | 2292 | |
| 2215 | 2293 | $modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']); |
| 2216 | - if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) |
|
| 2217 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2294 | + if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) { |
|
| 2295 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2296 | + } |
|
| 2218 | 2297 | ksort($modSettings['attachment_basedirectories']); |
| 2219 | 2298 | |
| 2220 | 2299 | $update = (array( |
@@ -2224,11 +2303,13 @@ discard block |
||
| 2224 | 2303 | )); |
| 2225 | 2304 | } |
| 2226 | 2305 | |
| 2227 | - if (!empty($errors)) |
|
| 2228 | - $_SESSION['errors']['base'] = $errors; |
|
| 2306 | + if (!empty($errors)) { |
|
| 2307 | + $_SESSION['errors']['base'] = $errors; |
|
| 2308 | + } |
|
| 2229 | 2309 | |
| 2230 | - if (!empty($update)) |
|
| 2231 | - updateSettings($update); |
|
| 2310 | + if (!empty($update)) { |
|
| 2311 | + updateSettings($update); |
|
| 2312 | + } |
|
| 2232 | 2313 | |
| 2233 | 2314 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2234 | 2315 | } |
@@ -2238,13 +2319,15 @@ discard block |
||
| 2238 | 2319 | if (is_array($_SESSION['errors'])) |
| 2239 | 2320 | { |
| 2240 | 2321 | $errors = array(); |
| 2241 | - if (!empty($_SESSION['errors']['dir'])) |
|
| 2242 | - foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2322 | + if (!empty($_SESSION['errors']['dir'])) { |
|
| 2323 | + foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2243 | 2324 | $errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2325 | + } |
|
| 2244 | 2326 | |
| 2245 | - if (!empty($_SESSION['errors']['base'])) |
|
| 2246 | - foreach ($_SESSION['errors']['base'] as $error) |
|
| 2327 | + if (!empty($_SESSION['errors']['base'])) { |
|
| 2328 | + foreach ($_SESSION['errors']['base'] as $error) |
|
| 2247 | 2329 | $errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2330 | + } |
|
| 2248 | 2331 | } |
| 2249 | 2332 | unset($_SESSION['errors']); |
| 2250 | 2333 | } |
@@ -2454,8 +2537,9 @@ discard block |
||
| 2454 | 2537 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
| 2455 | 2538 | { |
| 2456 | 2539 | // If there aren't any attachments in this directory this won't exist. |
| 2457 | - if (!isset($expected_files[$id])) |
|
| 2458 | - $expected_files[$id] = 0; |
|
| 2540 | + if (!isset($expected_files[$id])) { |
|
| 2541 | + $expected_files[$id] = 0; |
|
| 2542 | + } |
|
| 2459 | 2543 | |
| 2460 | 2544 | // Check if the directory is doing okay. |
| 2461 | 2545 | list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]); |
@@ -2468,10 +2552,11 @@ discard block |
||
| 2468 | 2552 | $is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']); |
| 2469 | 2553 | |
| 2470 | 2554 | // Count any sub-folders. |
| 2471 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2472 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2555 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2556 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2473 | 2557 | { |
| 2474 | 2558 | $expected_files[$id]++; |
| 2559 | + } |
|
| 2475 | 2560 | $sub_dirs++; |
| 2476 | 2561 | } |
| 2477 | 2562 | } |
@@ -2489,8 +2574,8 @@ discard block |
||
| 2489 | 2574 | } |
| 2490 | 2575 | |
| 2491 | 2576 | // Just stick a new directory on at the bottom. |
| 2492 | - if (isset($_REQUEST['new_path'])) |
|
| 2493 | - $attachdirs[] = array( |
|
| 2577 | + if (isset($_REQUEST['new_path'])) { |
|
| 2578 | + $attachdirs[] = array( |
|
| 2494 | 2579 | 'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1, |
| 2495 | 2580 | 'current' => false, |
| 2496 | 2581 | 'path' => '', |
@@ -2498,6 +2583,7 @@ discard block |
||
| 2498 | 2583 | 'num_files' => '', |
| 2499 | 2584 | 'status' => '', |
| 2500 | 2585 | ); |
| 2586 | + } |
|
| 2501 | 2587 | |
| 2502 | 2588 | return $attachdirs; |
| 2503 | 2589 | } |
@@ -2510,8 +2596,9 @@ discard block |
||
| 2510 | 2596 | { |
| 2511 | 2597 | global $modSettings, $txt; |
| 2512 | 2598 | |
| 2513 | - if (empty($modSettings['attachment_basedirectories'])) |
|
| 2514 | - return; |
|
| 2599 | + if (empty($modSettings['attachment_basedirectories'])) { |
|
| 2600 | + return; |
|
| 2601 | + } |
|
| 2515 | 2602 | |
| 2516 | 2603 | $basedirs = array(); |
| 2517 | 2604 | // Get a list of the base directories. |
@@ -2519,16 +2606,18 @@ discard block |
||
| 2519 | 2606 | { |
| 2520 | 2607 | // Loop through the attach directory array to count any sub-directories |
| 2521 | 2608 | $expected_dirs = 0; |
| 2522 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2523 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2609 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2610 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2524 | 2611 | $expected_dirs++; |
| 2612 | + } |
|
| 2525 | 2613 | |
| 2526 | - if (!is_dir($dir)) |
|
| 2527 | - $status = 'does_not_exist'; |
|
| 2528 | - elseif (!is_writeable($dir)) |
|
| 2529 | - $status = 'not_writable'; |
|
| 2530 | - else |
|
| 2531 | - $status = 'ok'; |
|
| 2614 | + if (!is_dir($dir)) { |
|
| 2615 | + $status = 'does_not_exist'; |
|
| 2616 | + } elseif (!is_writeable($dir)) { |
|
| 2617 | + $status = 'not_writable'; |
|
| 2618 | + } else { |
|
| 2619 | + $status = 'ok'; |
|
| 2620 | + } |
|
| 2532 | 2621 | |
| 2533 | 2622 | $basedirs[] = array( |
| 2534 | 2623 | 'id' => $id, |
@@ -2539,14 +2628,15 @@ discard block |
||
| 2539 | 2628 | ); |
| 2540 | 2629 | } |
| 2541 | 2630 | |
| 2542 | - if (isset($_REQUEST['new_base_path'])) |
|
| 2543 | - $basedirs[] = array( |
|
| 2631 | + if (isset($_REQUEST['new_base_path'])) { |
|
| 2632 | + $basedirs[] = array( |
|
| 2544 | 2633 | 'id' => '', |
| 2545 | 2634 | 'current' => false, |
| 2546 | 2635 | 'path' => '<input type="text" name="new_base_dir" value="" size="40">', |
| 2547 | 2636 | 'num_dirs' => '', |
| 2548 | 2637 | 'status' => '', |
| 2549 | 2638 | ); |
| 2639 | + } |
|
| 2550 | 2640 | |
| 2551 | 2641 | return $basedirs; |
| 2552 | 2642 | } |
@@ -2562,10 +2652,11 @@ discard block |
||
| 2562 | 2652 | */ |
| 2563 | 2653 | function attachDirStatus($dir, $expected_files) |
| 2564 | 2654 | { |
| 2565 | - if (!is_dir($dir)) |
|
| 2566 | - return array('does_not_exist', true, ''); |
|
| 2567 | - elseif (!is_writable($dir)) |
|
| 2568 | - return array('not_writable', true, ''); |
|
| 2655 | + if (!is_dir($dir)) { |
|
| 2656 | + return array('does_not_exist', true, ''); |
|
| 2657 | + } elseif (!is_writable($dir)) { |
|
| 2658 | + return array('not_writable', true, ''); |
|
| 2659 | + } |
|
| 2569 | 2660 | |
| 2570 | 2661 | // Everything is okay so far, start to scan through the directory. |
| 2571 | 2662 | $num_files = 0; |
@@ -2573,22 +2664,26 @@ discard block |
||
| 2573 | 2664 | while ($file = $dir_handle->read()) |
| 2574 | 2665 | { |
| 2575 | 2666 | // Now do we have a real file here? |
| 2576 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 2577 | - continue; |
|
| 2667 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 2668 | + continue; |
|
| 2669 | + } |
|
| 2578 | 2670 | |
| 2579 | 2671 | $num_files++; |
| 2580 | 2672 | } |
| 2581 | 2673 | $dir_handle->close(); |
| 2582 | 2674 | |
| 2583 | - if ($num_files < $expected_files) |
|
| 2584 | - return array('files_missing', true, $num_files); |
|
| 2675 | + if ($num_files < $expected_files) { |
|
| 2676 | + return array('files_missing', true, $num_files); |
|
| 2677 | + } |
|
| 2585 | 2678 | // Empty? |
| 2586 | - elseif ($expected_files == 0) |
|
| 2587 | - return array('unused', false, $num_files); |
|
| 2679 | + elseif ($expected_files == 0) { |
|
| 2680 | + return array('unused', false, $num_files); |
|
| 2681 | + } |
|
| 2588 | 2682 | // All good! |
| 2589 | - else |
|
| 2590 | - return array('ok', false, $num_files); |
|
| 2591 | -} |
|
| 2683 | + else { |
|
| 2684 | + return array('ok', false, $num_files); |
|
| 2685 | + } |
|
| 2686 | + } |
|
| 2592 | 2687 | |
| 2593 | 2688 | /** |
| 2594 | 2689 | * Maintance function to move attachments from one directory to another |
@@ -2600,10 +2695,11 @@ discard block |
||
| 2600 | 2695 | checkSession(); |
| 2601 | 2696 | |
| 2602 | 2697 | $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
| 2603 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2604 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 2605 | - else |
|
| 2606 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2698 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2699 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 2700 | + } else { |
|
| 2701 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2702 | + } |
|
| 2607 | 2703 | |
| 2608 | 2704 | $_POST['from'] = (int) $_POST['from']; |
| 2609 | 2705 | $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0; |
@@ -2617,11 +2713,13 @@ discard block |
||
| 2617 | 2713 | $total_moved = 0; |
| 2618 | 2714 | $total_not_moved = 0; |
| 2619 | 2715 | |
| 2620 | - if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) |
|
| 2621 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2716 | + if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) { |
|
| 2717 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2718 | + } |
|
| 2622 | 2719 | |
| 2623 | - if ($_POST['from'] == $_POST['to']) |
|
| 2624 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2720 | + if ($_POST['from'] == $_POST['to']) { |
|
| 2721 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2722 | + } |
|
| 2625 | 2723 | |
| 2626 | 2724 | if (empty($results)) |
| 2627 | 2725 | { |
@@ -2640,8 +2738,9 @@ discard block |
||
| 2640 | 2738 | $smcFunc['db_free_result']($request); |
| 2641 | 2739 | $total_progress -= $start; |
| 2642 | 2740 | |
| 2643 | - if ($total_progress < 1) |
|
| 2644 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2741 | + if ($total_progress < 1) { |
|
| 2742 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2743 | + } |
|
| 2645 | 2744 | } |
| 2646 | 2745 | |
| 2647 | 2746 | if (empty($results)) |
@@ -2657,9 +2756,9 @@ discard block |
||
| 2657 | 2756 | |
| 2658 | 2757 | automanage_attachments_check_directory(); |
| 2659 | 2758 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
| 2759 | + } else { |
|
| 2760 | + $new_dir = $_POST['to']; |
|
| 2660 | 2761 | } |
| 2661 | - else |
|
| 2662 | - $new_dir = $_POST['to']; |
|
| 2663 | 2762 | |
| 2664 | 2763 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
| 2665 | 2764 | |
@@ -2667,8 +2766,9 @@ discard block |
||
| 2667 | 2766 | while ($break == false) |
| 2668 | 2767 | { |
| 2669 | 2768 | @set_time_limit(300); |
| 2670 | - if (function_exists('apache_reset_timeout')) |
|
| 2671 | - @apache_reset_timeout(); |
|
| 2769 | + if (function_exists('apache_reset_timeout')) { |
|
| 2770 | + @apache_reset_timeout(); |
|
| 2771 | + } |
|
| 2672 | 2772 | |
| 2673 | 2773 | // If limits are set, get the file count and size for the destination folder |
| 2674 | 2774 | if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) |
@@ -2704,13 +2804,15 @@ discard block |
||
| 2704 | 2804 | |
| 2705 | 2805 | if ($smcFunc['db_num_rows']($request) === 0) |
| 2706 | 2806 | { |
| 2707 | - if (empty($current_progress)) |
|
| 2708 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2807 | + if (empty($current_progress)) { |
|
| 2808 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2809 | + } |
|
| 2709 | 2810 | break; |
| 2710 | 2811 | } |
| 2711 | 2812 | |
| 2712 | - if ($smcFunc['db_num_rows']($request) < $limit) |
|
| 2713 | - $break = true; |
|
| 2813 | + if ($smcFunc['db_num_rows']($request) < $limit) { |
|
| 2814 | + $break = true; |
|
| 2815 | + } |
|
| 2714 | 2816 | |
| 2715 | 2817 | // Move them |
| 2716 | 2818 | $moved = array(); |
@@ -2734,8 +2836,9 @@ discard block |
||
| 2734 | 2836 | automanage_attachments_by_space(); |
| 2735 | 2837 | |
| 2736 | 2838 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2737 | - if (!empty($total_not_moved)) |
|
| 2738 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2839 | + if (!empty($total_not_moved)) { |
|
| 2840 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2841 | + } |
|
| 2739 | 2842 | |
| 2740 | 2843 | $dir_files = 0; |
| 2741 | 2844 | $total_moved = 0; |
@@ -2743,8 +2846,7 @@ discard block |
||
| 2743 | 2846 | |
| 2744 | 2847 | $break = false; |
| 2745 | 2848 | break; |
| 2746 | - } |
|
| 2747 | - else |
|
| 2849 | + } else |
|
| 2748 | 2850 | { |
| 2749 | 2851 | // Hmm, not in auto. Time to bail out then... |
| 2750 | 2852 | $results[] = $txt['attachment_transfer_no_room']; |
@@ -2759,9 +2861,9 @@ discard block |
||
| 2759 | 2861 | $total_moved++; |
| 2760 | 2862 | $current_progress++; |
| 2761 | 2863 | $moved[] = $row['id_attach']; |
| 2864 | + } else { |
|
| 2865 | + $total_not_moved++; |
|
| 2762 | 2866 | } |
| 2763 | - else |
|
| 2764 | - $total_not_moved++; |
|
| 2765 | 2867 | } |
| 2766 | 2868 | $smcFunc['db_free_result']($request); |
| 2767 | 2869 | |
@@ -2800,13 +2902,15 @@ discard block |
||
| 2800 | 2902 | } |
| 2801 | 2903 | |
| 2802 | 2904 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2803 | - if (!empty($total_not_moved)) |
|
| 2804 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2905 | + if (!empty($total_not_moved)) { |
|
| 2906 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2907 | + } |
|
| 2805 | 2908 | } |
| 2806 | 2909 | |
| 2807 | 2910 | $_SESSION['results'] = $results; |
| 2808 | - if (file_exists($boarddir . '/progress.php')) |
|
| 2809 | - unlink($boarddir . '/progress.php'); |
|
| 2911 | + if (file_exists($boarddir . '/progress.php')) { |
|
| 2912 | + unlink($boarddir . '/progress.php'); |
|
| 2913 | + } |
|
| 2810 | 2914 | |
| 2811 | 2915 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
| 2812 | 2916 | } |
@@ -30,8 +30,9 @@ discard block |
||
| 30 | 30 | * @version 2.1 Beta 3 |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | -if (!defined('SMF')) |
|
| 33 | +if (!defined('SMF')) { |
|
| 34 | 34 | die('No direct access...'); |
| 35 | +} |
|
| 35 | 36 | |
| 36 | 37 | /** |
| 37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
| 103 | 104 | cache_put_data('minimized_css', null); |
| 104 | 105 | |
| 105 | 106 | // Follow the sa or just go to administration. |
| 106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
| 107 | - call_helper($subActions[$_GET['sa']]); |
|
| 108 | - |
|
| 109 | - else |
|
| 110 | - call_helper($subActions['admin']); |
|
| 111 | -} |
|
| 107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
| 108 | + call_helper($subActions[$_GET['sa']]); |
|
| 109 | + } else { |
|
| 110 | + call_helper($subActions['admin']); |
|
| 111 | + } |
|
| 112 | + } |
|
| 112 | 113 | |
| 113 | 114 | /** |
| 114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
| 130 | 131 | checkSession(); |
| 131 | 132 | validateToken('admin-tm'); |
| 132 | 133 | |
| 133 | - if (isset($_POST['options']['known_themes'])) |
|
| 134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 134 | + if (isset($_POST['options']['known_themes'])) { |
|
| 135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
| 137 | + } else { |
|
| 138 | + fatal_lang_error('themes_none_selectable', false); |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | - else |
|
| 138 | - fatal_lang_error('themes_none_selectable', false); |
|
| 139 | - |
|
| 140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
| 141 | - fatal_lang_error('themes_default_selectable', false); |
|
| 141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
| 142 | + fatal_lang_error('themes_default_selectable', false); |
|
| 143 | + } |
|
| 142 | 144 | |
| 143 | 145 | // Commit the new settings. |
| 144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
| 146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
| 147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
| 148 | 150 | )); |
| 149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
| 150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
| 152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
| 153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
| 166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
| 167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
| 168 | 171 | $i = 1; |
| 169 | - while (file_exists($theme_dir . $i)) |
|
| 170 | - $i++; |
|
| 172 | + while (file_exists($theme_dir . $i)) { |
|
| 173 | + $i++; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
| 173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
| 189 | 193 | loadLanguage('Admin'); |
| 190 | 194 | isAllowedTo('admin_forum'); |
| 191 | 195 | |
| 192 | - if (isset($_REQUEST['th'])) |
|
| 193 | - return SetThemeSettings(); |
|
| 196 | + if (isset($_REQUEST['th'])) { |
|
| 197 | + return SetThemeSettings(); |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | if (isset($_POST['save'])) |
| 196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
| 274 | 279 | $context['themes'] = array(); |
| 275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 276 | 281 | { |
| 277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
| 278 | - $context['themes'][$row['id_theme']] = array( |
|
| 282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
| 283 | + $context['themes'][$row['id_theme']] = array( |
|
| 279 | 284 | 'id' => $row['id_theme'], |
| 280 | 285 | 'num_default_options' => 0, |
| 281 | 286 | 'num_members' => 0, |
| 282 | 287 | ); |
| 288 | + } |
|
| 283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 284 | 290 | } |
| 285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
| 293 | 299 | 'guest_member' => -1, |
| 294 | 300 | ) |
| 295 | 301 | ); |
| 296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 304 | + } |
|
| 298 | 305 | $smcFunc['db_free_result']($request); |
| 299 | 306 | |
| 300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
| 305 | 312 | ) |
| 306 | 313 | ); |
| 307 | 314 | $customFields = array(); |
| 308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 309 | - $customFields[] = $row['col_name']; |
|
| 315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 316 | + $customFields[] = $row['col_name']; |
|
| 317 | + } |
|
| 310 | 318 | $smcFunc['db_free_result']($request); |
| 311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
| 312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
| 321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
| 322 | 330 | ) |
| 323 | 331 | ); |
| 324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 334 | + } |
|
| 326 | 335 | $smcFunc['db_free_result']($request); |
| 327 | 336 | |
| 328 | 337 | // There has to be a Settings template! |
| 329 | - foreach ($context['themes'] as $k => $v) |
|
| 330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 338 | + foreach ($context['themes'] as $k => $v) { |
|
| 339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 331 | 340 | unset($context['themes'][$k]); |
| 341 | + } |
|
| 332 | 342 | |
| 333 | 343 | loadTemplate('Themes'); |
| 334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
| 343 | 353 | checkSession(); |
| 344 | 354 | validateToken('admin-sto'); |
| 345 | 355 | |
| 346 | - if (empty($_POST['options'])) |
|
| 347 | - $_POST['options'] = array(); |
|
| 348 | - if (empty($_POST['default_options'])) |
|
| 349 | - $_POST['default_options'] = array(); |
|
| 356 | + if (empty($_POST['options'])) { |
|
| 357 | + $_POST['options'] = array(); |
|
| 358 | + } |
|
| 359 | + if (empty($_POST['default_options'])) { |
|
| 360 | + $_POST['default_options'] = array(); |
|
| 361 | + } |
|
| 350 | 362 | |
| 351 | 363 | // Set up the sql query. |
| 352 | 364 | $setValues = array(); |
| 353 | 365 | |
| 354 | - foreach ($_POST['options'] as $opt => $val) |
|
| 355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 366 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 368 | + } |
|
| 356 | 369 | |
| 357 | 370 | $old_settings = array(); |
| 358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
| 366 | 379 | if (!empty($setValues)) |
| 367 | 380 | { |
| 368 | 381 | // Are there options in non-default themes set that should be cleared? |
| 369 | - if (!empty($old_settings)) |
|
| 370 | - $smcFunc['db_query']('', ' |
|
| 382 | + if (!empty($old_settings)) { |
|
| 383 | + $smcFunc['db_query']('', ' |
|
| 371 | 384 | DELETE FROM {db_prefix}themes |
| 372 | 385 | WHERE id_theme != {int:default_theme} |
| 373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
| 378 | 391 | 'old_settings' => $old_settings, |
| 379 | 392 | ) |
| 380 | 393 | ); |
| 394 | + } |
|
| 381 | 395 | |
| 382 | 396 | $smcFunc['db_insert']('replace', |
| 383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
| 391 | 405 | cache_put_data('theme_settings-1', null, 90); |
| 392 | 406 | |
| 393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 394 | - } |
|
| 395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 396 | 409 | { |
| 397 | 410 | checkSession(); |
| 398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
| 405 | 418 | $old_settings = array(); |
| 406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
| 407 | 420 | { |
| 408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
| 409 | - continue; |
|
| 410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
| 422 | + continue; |
|
| 423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 411 | 424 | { |
| 412 | 425 | // Delete then insert for ease of database compatibility! |
| 413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
| 433 | 446 | ); |
| 434 | 447 | |
| 435 | 448 | $old_settings[] = $opt; |
| 436 | - } |
|
| 437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 438 | 450 | { |
| 439 | 451 | $smcFunc['db_query']('', ' |
| 440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
| 449 | 461 | } |
| 450 | 462 | |
| 451 | 463 | // Delete options from other themes. |
| 452 | - if (!empty($old_settings)) |
|
| 453 | - $smcFunc['db_query']('', ' |
|
| 464 | + if (!empty($old_settings)) { |
|
| 465 | + $smcFunc['db_query']('', ' |
|
| 454 | 466 | DELETE FROM {db_prefix}themes |
| 455 | 467 | WHERE id_theme != {int:default_theme} |
| 456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
| 461 | 473 | 'old_settings' => $old_settings, |
| 462 | 474 | ) |
| 463 | 475 | ); |
| 476 | + } |
|
| 464 | 477 | |
| 465 | 478 | foreach ($_POST['options'] as $opt => $val) |
| 466 | 479 | { |
| 467 | - if ($_POST['options_master'][$opt] == 0) |
|
| 468 | - continue; |
|
| 469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
| 480 | + if ($_POST['options_master'][$opt] == 0) { |
|
| 481 | + continue; |
|
| 482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
| 470 | 483 | { |
| 471 | 484 | // Delete then insert for ease of database compatibility - again! |
| 472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
| 491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
| 492 | 505 | ) |
| 493 | 506 | ); |
| 494 | - } |
|
| 495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
| 507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
| 496 | 508 | { |
| 497 | 509 | $smcFunc['db_query']('', ' |
| 498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
| 509 | 521 | } |
| 510 | 522 | |
| 511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 512 | - } |
|
| 513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 514 | 525 | { |
| 515 | 526 | checkSession('get'); |
| 516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
| 525 | 536 | ) |
| 526 | 537 | ); |
| 527 | 538 | $customFields = array(); |
| 528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 529 | - $customFields[] = $row['col_name']; |
|
| 539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 540 | + $customFields[] = $row['col_name']; |
|
| 541 | + } |
|
| 530 | 542 | $smcFunc['db_free_result']($request); |
| 531 | 543 | } |
| 532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -578,13 +590,13 @@ discard block |
||
| 578 | 590 | ) |
| 579 | 591 | ); |
| 580 | 592 | $context['theme_options'] = array(); |
| 581 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 582 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
| 593 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 594 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
| 595 | + } |
|
| 583 | 596 | $smcFunc['db_free_result']($request); |
| 584 | 597 | |
| 585 | 598 | $context['theme_options_reset'] = false; |
| 586 | - } |
|
| 587 | - else |
|
| 599 | + } else |
|
| 588 | 600 | { |
| 589 | 601 | $context['theme_options'] = array(); |
| 590 | 602 | $context['theme_options_reset'] = true; |
@@ -597,22 +609,23 @@ discard block |
||
| 597 | 609 | { |
| 598 | 610 | unset($context['options'][$i]); |
| 599 | 611 | continue; |
| 600 | - } |
|
| 601 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 612 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 602 | 613 | { |
| 603 | 614 | unset($context['options'][$i]); |
| 604 | 615 | continue; |
| 605 | 616 | } |
| 606 | 617 | |
| 607 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 608 | - $context['options'][$i]['type'] = 'checkbox'; |
|
| 609 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 610 | - $context['options'][$i]['type'] = 'number'; |
|
| 611 | - elseif ($setting['type'] == 'string') |
|
| 612 | - $context['options'][$i]['type'] = 'text'; |
|
| 618 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 619 | + $context['options'][$i]['type'] = 'checkbox'; |
|
| 620 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 621 | + $context['options'][$i]['type'] = 'number'; |
|
| 622 | + } elseif ($setting['type'] == 'string') { |
|
| 623 | + $context['options'][$i]['type'] = 'text'; |
|
| 624 | + } |
|
| 613 | 625 | |
| 614 | - if (isset($setting['options'])) |
|
| 615 | - $context['options'][$i]['type'] = 'list'; |
|
| 626 | + if (isset($setting['options'])) { |
|
| 627 | + $context['options'][$i]['type'] = 'list'; |
|
| 628 | + } |
|
| 616 | 629 | |
| 617 | 630 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
| 618 | 631 | } |
@@ -637,8 +650,9 @@ discard block |
||
| 637 | 650 | { |
| 638 | 651 | global $txt, $context, $settings, $modSettings, $smcFunc; |
| 639 | 652 | |
| 640 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
| 641 | - return ThemeAdmin(); |
|
| 653 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
| 654 | + return ThemeAdmin(); |
|
| 655 | + } |
|
| 642 | 656 | |
| 643 | 657 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 644 | 658 | |
@@ -649,8 +663,9 @@ discard block |
||
| 649 | 663 | isAllowedTo('admin_forum'); |
| 650 | 664 | |
| 651 | 665 | // Validate inputs/user. |
| 652 | - if (empty($_GET['th'])) |
|
| 653 | - fatal_lang_error('no_theme', false); |
|
| 666 | + if (empty($_GET['th'])) { |
|
| 667 | + fatal_lang_error('no_theme', false); |
|
| 668 | + } |
|
| 654 | 669 | |
| 655 | 670 | // Fetch the smiley sets... |
| 656 | 671 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -658,8 +673,9 @@ discard block |
||
| 658 | 673 | $context['smiley_sets'] = array( |
| 659 | 674 | '' => $txt['smileys_no_default'] |
| 660 | 675 | ); |
| 661 | - foreach ($sets as $i => $set) |
|
| 662 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 676 | + foreach ($sets as $i => $set) { |
|
| 677 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 678 | + } |
|
| 663 | 679 | |
| 664 | 680 | $old_id = $settings['theme_id']; |
| 665 | 681 | $old_settings = $settings; |
@@ -684,8 +700,9 @@ discard block |
||
| 684 | 700 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
| 685 | 701 | { |
| 686 | 702 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
| 687 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
| 688 | - eval('global $settings;' . $matches[0]); |
|
| 703 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
| 704 | + eval('global $settings;' . $matches[0]); |
|
| 705 | + } |
|
| 689 | 706 | } |
| 690 | 707 | |
| 691 | 708 | // Submitting! |
@@ -694,37 +711,45 @@ discard block |
||
| 694 | 711 | checkSession(); |
| 695 | 712 | validateToken('admin-sts'); |
| 696 | 713 | |
| 697 | - if (empty($_POST['options'])) |
|
| 698 | - $_POST['options'] = array(); |
|
| 699 | - if (empty($_POST['default_options'])) |
|
| 700 | - $_POST['default_options'] = array(); |
|
| 714 | + if (empty($_POST['options'])) { |
|
| 715 | + $_POST['options'] = array(); |
|
| 716 | + } |
|
| 717 | + if (empty($_POST['default_options'])) { |
|
| 718 | + $_POST['default_options'] = array(); |
|
| 719 | + } |
|
| 701 | 720 | |
| 702 | 721 | // Make sure items are cast correctly. |
| 703 | 722 | foreach ($context['theme_settings'] as $item) |
| 704 | 723 | { |
| 705 | 724 | // Disregard this item if this is just a separator. |
| 706 | - if (!is_array($item)) |
|
| 707 | - continue; |
|
| 725 | + if (!is_array($item)) { |
|
| 726 | + continue; |
|
| 727 | + } |
|
| 708 | 728 | |
| 709 | 729 | foreach (array('options', 'default_options') as $option) |
| 710 | 730 | { |
| 711 | - if (!isset($_POST[$option][$item['id']])) |
|
| 712 | - continue; |
|
| 731 | + if (!isset($_POST[$option][$item['id']])) { |
|
| 732 | + continue; |
|
| 733 | + } |
|
| 713 | 734 | // Checkbox. |
| 714 | - elseif (empty($item['type'])) |
|
| 715 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 735 | + elseif (empty($item['type'])) { |
|
| 736 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 737 | + } |
|
| 716 | 738 | // Number |
| 717 | - elseif ($item['type'] == 'number') |
|
| 718 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 739 | + elseif ($item['type'] == 'number') { |
|
| 740 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 741 | + } |
|
| 719 | 742 | } |
| 720 | 743 | } |
| 721 | 744 | |
| 722 | 745 | // Set up the sql query. |
| 723 | 746 | $inserts = array(); |
| 724 | - foreach ($_POST['options'] as $opt => $val) |
|
| 725 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 726 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 727 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 747 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 748 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 749 | + } |
|
| 750 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
| 751 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 752 | + } |
|
| 728 | 753 | // If we're actually inserting something.. |
| 729 | 754 | if (!empty($inserts)) |
| 730 | 755 | { |
@@ -750,8 +775,9 @@ discard block |
||
| 750 | 775 | |
| 751 | 776 | foreach ($settings as $setting => $dummy) |
| 752 | 777 | { |
| 753 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
| 754 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 778 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
| 779 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 780 | + } |
|
| 755 | 781 | } |
| 756 | 782 | |
| 757 | 783 | $context['settings'] = $context['theme_settings']; |
@@ -760,18 +786,21 @@ discard block |
||
| 760 | 786 | foreach ($context['settings'] as $i => $setting) |
| 761 | 787 | { |
| 762 | 788 | // Separators are dummies, so leave them alone. |
| 763 | - if (!is_array($setting)) |
|
| 764 | - continue; |
|
| 789 | + if (!is_array($setting)) { |
|
| 790 | + continue; |
|
| 791 | + } |
|
| 765 | 792 | |
| 766 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 767 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
| 768 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 769 | - $context['settings'][$i]['type'] = 'number'; |
|
| 770 | - elseif ($setting['type'] == 'string') |
|
| 771 | - $context['settings'][$i]['type'] = 'text'; |
|
| 793 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 794 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
| 795 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 796 | + $context['settings'][$i]['type'] = 'number'; |
|
| 797 | + } elseif ($setting['type'] == 'string') { |
|
| 798 | + $context['settings'][$i]['type'] = 'text'; |
|
| 799 | + } |
|
| 772 | 800 | |
| 773 | - if (isset($setting['options'])) |
|
| 774 | - $context['settings'][$i]['type'] = 'list'; |
|
| 801 | + if (isset($setting['options'])) { |
|
| 802 | + $context['settings'][$i]['type'] = 'list'; |
|
| 803 | + } |
|
| 775 | 804 | |
| 776 | 805 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
| 777 | 806 | } |
@@ -824,8 +853,9 @@ discard block |
||
| 824 | 853 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 825 | 854 | |
| 826 | 855 | // You can't delete the default theme! |
| 827 | - if ($themeID == 1) |
|
| 828 | - fatal_lang_error('no_access', false); |
|
| 856 | + if ($themeID == 1) { |
|
| 857 | + fatal_lang_error('no_access', false); |
|
| 858 | + } |
|
| 829 | 859 | |
| 830 | 860 | $theme_info = get_single_theme($themeID); |
| 831 | 861 | |
@@ -833,8 +863,9 @@ discard block |
||
| 833 | 863 | remove_theme($themeID); |
| 834 | 864 | |
| 835 | 865 | // And remove all its files and folders too. |
| 836 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
| 837 | - remove_dir($theme_info['theme_dir']); |
|
| 866 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
| 867 | + remove_dir($theme_info['theme_dir']); |
|
| 868 | + } |
|
| 838 | 869 | |
| 839 | 870 | // Go back to the list page. |
| 840 | 871 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] .';done=removing'); |
@@ -859,12 +890,14 @@ discard block |
||
| 859 | 890 | $enableThemes = explode(',', $modSettings['enableThemes']); |
| 860 | 891 | |
| 861 | 892 | // Are we disabling it? |
| 862 | - if (isset($_GET['disabled'])) |
|
| 863 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 893 | + if (isset($_GET['disabled'])) { |
|
| 894 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 895 | + } |
|
| 864 | 896 | |
| 865 | 897 | // Nope? then enable it! |
| 866 | - else |
|
| 867 | - $enableThemes[] = (string) $themeID; |
|
| 898 | + else { |
|
| 899 | + $enableThemes[] = (string) $themeID; |
|
| 900 | + } |
|
| 868 | 901 | |
| 869 | 902 | // Update the setting. |
| 870 | 903 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -899,18 +932,21 @@ discard block |
||
| 899 | 932 | |
| 900 | 933 | $_SESSION['id_theme'] = 0; |
| 901 | 934 | |
| 902 | - if (isset($_GET['id'])) |
|
| 903 | - $_GET['th'] = $_GET['id']; |
|
| 935 | + if (isset($_GET['id'])) { |
|
| 936 | + $_GET['th'] = $_GET['id']; |
|
| 937 | + } |
|
| 904 | 938 | |
| 905 | 939 | // Saving a variant cause JS doesn't work - pretend it did ;) |
| 906 | 940 | if (isset($_POST['save'])) |
| 907 | 941 | { |
| 908 | 942 | // Which theme? |
| 909 | - foreach ($_POST['save'] as $k => $v) |
|
| 910 | - $_GET['th'] = (int) $k; |
|
| 943 | + foreach ($_POST['save'] as $k => $v) { |
|
| 944 | + $_GET['th'] = (int) $k; |
|
| 945 | + } |
|
| 911 | 946 | |
| 912 | - if (isset($_POST['vrt'][$k])) |
|
| 913 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 947 | + if (isset($_POST['vrt'][$k])) { |
|
| 948 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 949 | + } |
|
| 914 | 950 | } |
| 915 | 951 | |
| 916 | 952 | // Have we made a decision, or are we just browsing? |
@@ -988,8 +1024,9 @@ discard block |
||
| 988 | 1024 | else |
| 989 | 1025 | { |
| 990 | 1026 | // The forum's default theme is always 0 and we |
| 991 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
| 992 | - $_GET['th'] = $modSettings['theme_guests']; |
|
| 1027 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
| 1028 | + $_GET['th'] = $modSettings['theme_guests']; |
|
| 1029 | + } |
|
| 993 | 1030 | |
| 994 | 1031 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
| 995 | 1032 | |
@@ -1003,8 +1040,9 @@ discard block |
||
| 1003 | 1040 | ); |
| 1004 | 1041 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
| 1005 | 1042 | |
| 1006 | - if ($user_info['id'] == $_REQUEST['u']) |
|
| 1007 | - $_SESSION['id_variant'] = 0; |
|
| 1043 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
| 1044 | + $_SESSION['id_variant'] = 0; |
|
| 1045 | + } |
|
| 1008 | 1046 | } |
| 1009 | 1047 | |
| 1010 | 1048 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1073,12 +1111,13 @@ discard block |
||
| 1073 | 1111 | ); |
| 1074 | 1112 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1075 | 1113 | { |
| 1076 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
| 1077 | - $context['available_themes'][$row['id_theme']] = array( |
|
| 1114 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
| 1115 | + $context['available_themes'][$row['id_theme']] = array( |
|
| 1078 | 1116 | 'id' => $row['id_theme'], |
| 1079 | 1117 | 'selected' => $context['current_theme'] == $row['id_theme'], |
| 1080 | 1118 | 'num_users' => 0 |
| 1081 | 1119 | ); |
| 1120 | + } |
|
| 1082 | 1121 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 1083 | 1122 | } |
| 1084 | 1123 | $smcFunc['db_free_result']($request); |
@@ -1091,9 +1130,9 @@ discard block |
||
| 1091 | 1130 | 'num_users' => 0 |
| 1092 | 1131 | ); |
| 1093 | 1132 | $guest_theme = 0; |
| 1133 | + } else { |
|
| 1134 | + $guest_theme = $modSettings['theme_guests']; |
|
| 1094 | 1135 | } |
| 1095 | - else |
|
| 1096 | - $guest_theme = $modSettings['theme_guests']; |
|
| 1097 | 1136 | |
| 1098 | 1137 | $request = $smcFunc['db_query']('', ' |
| 1099 | 1138 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1106,15 +1145,17 @@ discard block |
||
| 1106 | 1145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1107 | 1146 | { |
| 1108 | 1147 | // Figure out which theme it is they are REALLY using. |
| 1109 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',',$modSettings['knownThemes']))) |
|
| 1110 | - $row['id_theme'] = $guest_theme; |
|
| 1111 | - elseif (empty($modSettings['theme_allow'])) |
|
| 1112 | - $row['id_theme'] = $guest_theme; |
|
| 1148 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',',$modSettings['knownThemes']))) { |
|
| 1149 | + $row['id_theme'] = $guest_theme; |
|
| 1150 | + } elseif (empty($modSettings['theme_allow'])) { |
|
| 1151 | + $row['id_theme'] = $guest_theme; |
|
| 1152 | + } |
|
| 1113 | 1153 | |
| 1114 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
| 1115 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1116 | - else |
|
| 1117 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1154 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
| 1155 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1156 | + } else { |
|
| 1157 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1158 | + } |
|
| 1118 | 1159 | } |
| 1119 | 1160 | $smcFunc['db_free_result']($request); |
| 1120 | 1161 | |
@@ -1133,8 +1174,9 @@ discard block |
||
| 1133 | 1174 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
| 1134 | 1175 | ) |
| 1135 | 1176 | ); |
| 1136 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1137 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1177 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1178 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1179 | + } |
|
| 1138 | 1180 | $smcFunc['db_free_result']($request); |
| 1139 | 1181 | } |
| 1140 | 1182 | |
@@ -1145,17 +1187,18 @@ discard block |
||
| 1145 | 1187 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
| 1146 | 1188 | { |
| 1147 | 1189 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
| 1148 | - if ($id_theme == 0) |
|
| 1149 | - continue; |
|
| 1190 | + if ($id_theme == 0) { |
|
| 1191 | + continue; |
|
| 1192 | + } |
|
| 1150 | 1193 | |
| 1151 | 1194 | // The thumbnail needs the correct path. |
| 1152 | 1195 | $settings['images_url'] = &$theme_data['images_url']; |
| 1153 | 1196 | |
| 1154 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
| 1155 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1156 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
| 1157 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1158 | - else |
|
| 1197 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
| 1198 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1199 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
| 1200 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1201 | + } else |
|
| 1159 | 1202 | { |
| 1160 | 1203 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
| 1161 | 1204 | $txt['theme_description'] = ''; |
@@ -1180,15 +1223,17 @@ discard block |
||
| 1180 | 1223 | loadLanguage('Settings'); |
| 1181 | 1224 | |
| 1182 | 1225 | $context['available_themes'][$id_theme]['variants'] = array(); |
| 1183 | - foreach ($settings['theme_variants'] as $variant) |
|
| 1184 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1226 | + foreach ($settings['theme_variants'] as $variant) { |
|
| 1227 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1185 | 1228 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
| 1186 | 1229 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
| 1187 | 1230 | ); |
| 1231 | + } |
|
| 1188 | 1232 | |
| 1189 | 1233 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
| 1190 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
| 1191 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1234 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
| 1235 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1236 | + } |
|
| 1192 | 1237 | |
| 1193 | 1238 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
| 1194 | 1239 | // Allow themes to override the text. |
@@ -1204,8 +1249,9 @@ discard block |
||
| 1204 | 1249 | // As long as we're not doing the default theme... |
| 1205 | 1250 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
| 1206 | 1251 | { |
| 1207 | - if ($guest_theme != 0) |
|
| 1208 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1252 | + if ($guest_theme != 0) { |
|
| 1253 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1254 | + } |
|
| 1209 | 1255 | |
| 1210 | 1256 | $context['available_themes'][0]['id'] = 0; |
| 1211 | 1257 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1254,14 +1300,16 @@ discard block |
||
| 1254 | 1300 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
| 1255 | 1301 | |
| 1256 | 1302 | // Got any info from the specific form? |
| 1257 | - if (!isset($_POST['save_'. $action])) |
|
| 1258 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1303 | + if (!isset($_POST['save_'. $action])) { |
|
| 1304 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1305 | + } |
|
| 1259 | 1306 | |
| 1260 | 1307 | validateToken('admin-t-'. $action); |
| 1261 | 1308 | |
| 1262 | 1309 | // Hopefully the themes directory is writable, or we might have a problem. |
| 1263 | - if (!is_writable($themedir)) |
|
| 1264 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1310 | + if (!is_writable($themedir)) { |
|
| 1311 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1312 | + } |
|
| 1265 | 1313 | |
| 1266 | 1314 | // Call the function and handle the result. |
| 1267 | 1315 | $result = $subActions[$action](); |
@@ -1276,9 +1324,10 @@ discard block |
||
| 1276 | 1324 | } |
| 1277 | 1325 | |
| 1278 | 1326 | // Nope, show a nice error. |
| 1279 | - else |
|
| 1280 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1281 | -} |
|
| 1327 | + else { |
|
| 1328 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1329 | + } |
|
| 1330 | + } |
|
| 1282 | 1331 | |
| 1283 | 1332 | /** |
| 1284 | 1333 | * Installs a theme from a theme package. |
@@ -1294,8 +1343,9 @@ discard block |
||
| 1294 | 1343 | $dirtemp = $themedir .'/temp'; |
| 1295 | 1344 | |
| 1296 | 1345 | // Make sure the temp dir doesn't already exist |
| 1297 | - if (file_exists($dirtemp)) |
|
| 1298 | - remove_dir($dirtemp); |
|
| 1346 | + if (file_exists($dirtemp)) { |
|
| 1347 | + remove_dir($dirtemp); |
|
| 1348 | + } |
|
| 1299 | 1349 | |
| 1300 | 1350 | // Create the temp dir. |
| 1301 | 1351 | mkdir($dirtemp, 0777); |
@@ -1307,17 +1357,20 @@ discard block |
||
| 1307 | 1357 | smf_chmod($dirtemp, '0755'); |
| 1308 | 1358 | |
| 1309 | 1359 | // How about now? |
| 1310 | - if (!is_writable($dirtemp)) |
|
| 1311 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1360 | + if (!is_writable($dirtemp)) { |
|
| 1361 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1362 | + } |
|
| 1312 | 1363 | } |
| 1313 | 1364 | |
| 1314 | 1365 | // This happens when the admin session is gone and the user has to login again. |
| 1315 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
| 1316 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1366 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
| 1367 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1368 | + } |
|
| 1317 | 1369 | |
| 1318 | 1370 | // Another error check layer, something went wrong with the upload. |
| 1319 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
| 1320 | - fatal_lang_error('theme_install_error_file_'. $_FILES['theme_gz']['error'], false); |
|
| 1371 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
| 1372 | + fatal_lang_error('theme_install_error_file_'. $_FILES['theme_gz']['error'], false); |
|
| 1373 | + } |
|
| 1321 | 1374 | |
| 1322 | 1375 | // Get the theme's name. |
| 1323 | 1376 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1348,11 +1401,10 @@ discard block |
||
| 1348 | 1401 | |
| 1349 | 1402 | // return all the info. |
| 1350 | 1403 | return $context['to_install']; |
| 1404 | + } else { |
|
| 1405 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1406 | + } |
|
| 1351 | 1407 | } |
| 1352 | - |
|
| 1353 | - else |
|
| 1354 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1355 | -} |
|
| 1356 | 1408 | |
| 1357 | 1409 | /** |
| 1358 | 1410 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1366,15 +1418,17 @@ discard block |
||
| 1366 | 1418 | global $forum_version; |
| 1367 | 1419 | |
| 1368 | 1420 | // There's gotta be something to work with. |
| 1369 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
| 1370 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1421 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
| 1422 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1423 | + } |
|
| 1371 | 1424 | |
| 1372 | 1425 | // Get a cleaner version. |
| 1373 | 1426 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
| 1374 | 1427 | |
| 1375 | 1428 | // Is there a theme already named like this? |
| 1376 | - if (file_exists($themedir .'/'. $name)) |
|
| 1377 | - fatal_lang_error('theme_install_already_dir', false); |
|
| 1429 | + if (file_exists($themedir .'/'. $name)) { |
|
| 1430 | + fatal_lang_error('theme_install_already_dir', false); |
|
| 1431 | + } |
|
| 1378 | 1432 | |
| 1379 | 1433 | // This is a brand new theme so set all possible values. |
| 1380 | 1434 | $context['to_install'] = array( |
@@ -1394,8 +1448,9 @@ discard block |
||
| 1394 | 1448 | |
| 1395 | 1449 | // Buy some time. |
| 1396 | 1450 | @set_time_limit(600); |
| 1397 | - if (function_exists('apache_reset_timeout')) |
|
| 1398 | - @apache_reset_timeout(); |
|
| 1451 | + if (function_exists('apache_reset_timeout')) { |
|
| 1452 | + @apache_reset_timeout(); |
|
| 1453 | + } |
|
| 1399 | 1454 | |
| 1400 | 1455 | // Create subdirectories for css and javascript files. |
| 1401 | 1456 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1431,12 +1486,13 @@ discard block |
||
| 1431 | 1486 | |
| 1432 | 1487 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1433 | 1488 | { |
| 1434 | - if ($row['variable'] == 'theme_templates') |
|
| 1435 | - $theme_templates = $row['value']; |
|
| 1436 | - elseif ($row['variable'] == 'theme_layers') |
|
| 1437 | - $theme_layers = $row['value']; |
|
| 1438 | - else |
|
| 1439 | - continue; |
|
| 1489 | + if ($row['variable'] == 'theme_templates') { |
|
| 1490 | + $theme_templates = $row['value']; |
|
| 1491 | + } elseif ($row['variable'] == 'theme_layers') { |
|
| 1492 | + $theme_layers = $row['value']; |
|
| 1493 | + } else { |
|
| 1494 | + continue; |
|
| 1495 | + } |
|
| 1440 | 1496 | } |
| 1441 | 1497 | |
| 1442 | 1498 | $smcFunc['db_free_result']($request); |
@@ -1495,12 +1551,14 @@ discard block |
||
| 1495 | 1551 | global $themedir, $themeurl, $context; |
| 1496 | 1552 | |
| 1497 | 1553 | // Cannot use the theme dir as a theme dir. |
| 1498 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
| 1499 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1554 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
| 1555 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1556 | + } |
|
| 1500 | 1557 | |
| 1501 | 1558 | // Check is there is "something" on the dir. |
| 1502 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
| 1503 | - fatal_lang_error('theme_install_error', false); |
|
| 1559 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
| 1560 | + fatal_lang_error('theme_install_error', false); |
|
| 1561 | + } |
|
| 1504 | 1562 | |
| 1505 | 1563 | $name = basename($_REQUEST['theme_dir']); |
| 1506 | 1564 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1544,24 +1602,27 @@ discard block |
||
| 1544 | 1602 | } |
| 1545 | 1603 | |
| 1546 | 1604 | // Any special layers? |
| 1547 | - if (isset($settings['catch_action']['layers'])) |
|
| 1548 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1605 | + if (isset($settings['catch_action']['layers'])) { |
|
| 1606 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1607 | + } |
|
| 1549 | 1608 | |
| 1550 | 1609 | // Any function to call? |
| 1551 | 1610 | if (isset($settings['catch_action']['function'])) |
| 1552 | 1611 | { |
| 1553 | 1612 | $hook = $settings['catch_action']['function']; |
| 1554 | 1613 | |
| 1555 | - if (!isset($settings['catch_action']['filename'])) |
|
| 1556 | - $settings['catch_action']['filename'] = ''; |
|
| 1614 | + if (!isset($settings['catch_action']['filename'])) { |
|
| 1615 | + $settings['catch_action']['filename'] = ''; |
|
| 1616 | + } |
|
| 1557 | 1617 | |
| 1558 | 1618 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
| 1559 | 1619 | call_integration_hook('integrate_wrap_action'); |
| 1560 | 1620 | } |
| 1561 | 1621 | // And finally, the main sub template ;). |
| 1562 | - if (isset($settings['catch_action']['sub_template'])) |
|
| 1563 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1564 | -} |
|
| 1622 | + if (isset($settings['catch_action']['sub_template'])) { |
|
| 1623 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1565 | 1626 | |
| 1566 | 1627 | /** |
| 1567 | 1628 | * Set an option via javascript. |
@@ -1580,12 +1641,14 @@ discard block |
||
| 1580 | 1641 | checkSession('get'); |
| 1581 | 1642 | |
| 1582 | 1643 | // This good-for-nothing pixel is being used to keep the session alive. |
| 1583 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
| 1584 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1644 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
| 1645 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1646 | + } |
|
| 1585 | 1647 | |
| 1586 | 1648 | // Sorry, guests can't go any further than this. |
| 1587 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
| 1588 | - obExit(false); |
|
| 1649 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
| 1650 | + obExit(false); |
|
| 1651 | + } |
|
| 1589 | 1652 | |
| 1590 | 1653 | $reservedVars = array( |
| 1591 | 1654 | 'actual_theme_url', |
@@ -1608,8 +1671,9 @@ discard block |
||
| 1608 | 1671 | ); |
| 1609 | 1672 | |
| 1610 | 1673 | // Can't change reserved vars. |
| 1611 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
| 1612 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1674 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
| 1675 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1676 | + } |
|
| 1613 | 1677 | |
| 1614 | 1678 | // Use a specific theme? |
| 1615 | 1679 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1625,8 +1689,9 @@ discard block |
||
| 1625 | 1689 | { |
| 1626 | 1690 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
| 1627 | 1691 | // New thingy... |
| 1628 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
| 1629 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1692 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
| 1693 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1694 | + } |
|
| 1630 | 1695 | |
| 1631 | 1696 | // Change the value to be something nice, |
| 1632 | 1697 | $_GET['val'] = json_encode($options['admin_preferences']); |
@@ -1656,8 +1721,9 @@ discard block |
||
| 1656 | 1721 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
| 1657 | 1722 | |
| 1658 | 1723 | // @todo Should this be removed? |
| 1659 | - if (isset($_REQUEST['preview'])) |
|
| 1660 | - die('die() with fire'); |
|
| 1724 | + if (isset($_REQUEST['preview'])) { |
|
| 1725 | + die('die() with fire'); |
|
| 1726 | + } |
|
| 1661 | 1727 | |
| 1662 | 1728 | isAllowedTo('admin_forum'); |
| 1663 | 1729 | loadTemplate('Themes'); |
@@ -1671,11 +1737,11 @@ discard block |
||
| 1671 | 1737 | foreach ($context['themes'] as $key => $theme) |
| 1672 | 1738 | { |
| 1673 | 1739 | // There has to be a Settings template! |
| 1674 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
| 1675 | - unset($context['themes'][$key]); |
|
| 1676 | - |
|
| 1677 | - else |
|
| 1678 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1740 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
| 1741 | + unset($context['themes'][$key]); |
|
| 1742 | + } else { |
|
| 1743 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1744 | + } |
|
| 1679 | 1745 | } |
| 1680 | 1746 | |
| 1681 | 1747 | $context['sub_template'] = 'edit_list'; |
@@ -1690,22 +1756,24 @@ discard block |
||
| 1690 | 1756 | $context['theme_id'] = $currentTheme['id']; |
| 1691 | 1757 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
| 1692 | 1758 | |
| 1693 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
| 1694 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1759 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
| 1760 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1761 | + } |
|
| 1695 | 1762 | |
| 1696 | 1763 | if (!isset($_REQUEST['filename'])) |
| 1697 | 1764 | { |
| 1698 | 1765 | if (isset($_GET['directory'])) |
| 1699 | 1766 | { |
| 1700 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
| 1701 | - $_GET['directory'] = ''; |
|
| 1702 | - else |
|
| 1767 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
| 1768 | + $_GET['directory'] = ''; |
|
| 1769 | + } else |
|
| 1703 | 1770 | { |
| 1704 | 1771 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
| 1705 | 1772 | |
| 1706 | 1773 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
| 1707 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1708 | - $_GET['directory'] = ''; |
|
| 1774 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1775 | + $_GET['directory'] = ''; |
|
| 1776 | + } |
|
| 1709 | 1777 | } |
| 1710 | 1778 | } |
| 1711 | 1779 | |
@@ -1724,37 +1792,39 @@ discard block |
||
| 1724 | 1792 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
| 1725 | 1793 | 'size' => '', |
| 1726 | 1794 | )); |
| 1795 | + } else { |
|
| 1796 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1727 | 1797 | } |
| 1728 | - else |
|
| 1729 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1730 | 1798 | |
| 1731 | 1799 | $context['sub_template'] = 'edit_browse'; |
| 1732 | 1800 | |
| 1733 | 1801 | return; |
| 1734 | - } |
|
| 1735 | - else |
|
| 1802 | + } else |
|
| 1736 | 1803 | { |
| 1737 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
| 1738 | - $_REQUEST['filename'] = ''; |
|
| 1739 | - else |
|
| 1804 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
| 1805 | + $_REQUEST['filename'] = ''; |
|
| 1806 | + } else |
|
| 1740 | 1807 | { |
| 1741 | 1808 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
| 1742 | 1809 | |
| 1743 | 1810 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
| 1744 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1745 | - $_REQUEST['filename'] = ''; |
|
| 1811 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1812 | + $_REQUEST['filename'] = ''; |
|
| 1813 | + } |
|
| 1746 | 1814 | } |
| 1747 | 1815 | |
| 1748 | - if (empty($_REQUEST['filename'])) |
|
| 1749 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1816 | + if (empty($_REQUEST['filename'])) { |
|
| 1817 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1818 | + } |
|
| 1750 | 1819 | } |
| 1751 | 1820 | |
| 1752 | 1821 | if (isset($_POST['save'])) |
| 1753 | 1822 | { |
| 1754 | 1823 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
| 1755 | 1824 | { |
| 1756 | - if (is_array($_POST['entire_file'])) |
|
| 1757 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1825 | + if (is_array($_POST['entire_file'])) { |
|
| 1826 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1827 | + } |
|
| 1758 | 1828 | |
| 1759 | 1829 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
| 1760 | 1830 | |
@@ -1766,10 +1836,11 @@ discard block |
||
| 1766 | 1836 | fclose($fp); |
| 1767 | 1837 | |
| 1768 | 1838 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
| 1769 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
| 1770 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1771 | - else |
|
| 1772 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1839 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
| 1840 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1841 | + } else { |
|
| 1842 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1843 | + } |
|
| 1773 | 1844 | } |
| 1774 | 1845 | |
| 1775 | 1846 | if (!isset($error_file)) |
@@ -1790,10 +1861,11 @@ discard block |
||
| 1790 | 1861 | $context['sub_template'] = 'edit_file'; |
| 1791 | 1862 | |
| 1792 | 1863 | // Recycle the submitted data. |
| 1793 | - if (is_array($_POST['entire_file'])) |
|
| 1794 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1795 | - else |
|
| 1796 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1864 | + if (is_array($_POST['entire_file'])) { |
|
| 1865 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1866 | + } else { |
|
| 1867 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1868 | + } |
|
| 1797 | 1869 | |
| 1798 | 1870 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
| 1799 | 1871 | |
@@ -1816,17 +1888,17 @@ discard block |
||
| 1816 | 1888 | $context['sub_template'] = 'edit_style'; |
| 1817 | 1889 | |
| 1818 | 1890 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
| 1819 | - } |
|
| 1820 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1891 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1821 | 1892 | { |
| 1822 | 1893 | $context['sub_template'] = 'edit_template'; |
| 1823 | 1894 | |
| 1824 | - if (!isset($error_file)) |
|
| 1825 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1826 | - else |
|
| 1895 | + if (!isset($error_file)) { |
|
| 1896 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1897 | + } else |
|
| 1827 | 1898 | { |
| 1828 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
| 1829 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1899 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
| 1900 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1901 | + } |
|
| 1830 | 1902 | $file_data = file($error_file); |
| 1831 | 1903 | unlink($error_file); |
| 1832 | 1904 | } |
@@ -1840,8 +1912,9 @@ discard block |
||
| 1840 | 1912 | // Try to format the functions a little nicer... |
| 1841 | 1913 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
| 1842 | 1914 | |
| 1843 | - if (empty($context['file_parts'][$j]['lines'])) |
|
| 1844 | - unset($context['file_parts'][$j]); |
|
| 1915 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
| 1916 | + unset($context['file_parts'][$j]); |
|
| 1917 | + } |
|
| 1845 | 1918 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
| 1846 | 1919 | } |
| 1847 | 1920 | |
@@ -1850,8 +1923,7 @@ discard block |
||
| 1850 | 1923 | } |
| 1851 | 1924 | |
| 1852 | 1925 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
| 1853 | - } |
|
| 1854 | - else |
|
| 1926 | + } else |
|
| 1855 | 1927 | { |
| 1856 | 1928 | $context['sub_template'] = 'edit_file'; |
| 1857 | 1929 | |
@@ -1877,8 +1949,9 @@ discard block |
||
| 1877 | 1949 | |
| 1878 | 1950 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 1879 | 1951 | |
| 1880 | - if (empty($_GET['th'])) |
|
| 1881 | - fatal_lang_error('theme_install_invalid_id'); |
|
| 1952 | + if (empty($_GET['th'])) { |
|
| 1953 | + fatal_lang_error('theme_install_invalid_id'); |
|
| 1954 | + } |
|
| 1882 | 1955 | |
| 1883 | 1956 | // Get the theme info. |
| 1884 | 1957 | $theme = get_single_theme($_GET['th']); |
@@ -1886,25 +1959,24 @@ discard block |
||
| 1886 | 1959 | |
| 1887 | 1960 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
| 1888 | 1961 | { |
| 1889 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
| 1890 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1891 | - |
|
| 1892 | - else |
|
| 1893 | - fatal_lang_error('no_access', false); |
|
| 1962 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
| 1963 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1964 | + } else { |
|
| 1965 | + fatal_lang_error('no_access', false); |
|
| 1966 | + } |
|
| 1894 | 1967 | |
| 1895 | 1968 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
| 1896 | 1969 | fwrite($fp, file_get_contents($filename)); |
| 1897 | 1970 | fclose($fp); |
| 1898 | 1971 | |
| 1899 | 1972 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
| 1900 | - } |
|
| 1901 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1973 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1902 | 1974 | { |
| 1903 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
| 1904 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 1905 | - |
|
| 1906 | - else |
|
| 1907 | - fatal_lang_error('no_access', false); |
|
| 1975 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
| 1976 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 1977 | + } else { |
|
| 1978 | + fatal_lang_error('no_access', false); |
|
| 1979 | + } |
|
| 1908 | 1980 | |
| 1909 | 1981 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
| 1910 | 1982 | fwrite($fp, file_get_contents($filename)); |
@@ -1919,16 +1991,18 @@ discard block |
||
| 1919 | 1991 | $dir = dir($settings['default_theme_dir']); |
| 1920 | 1992 | while ($entry = $dir->read()) |
| 1921 | 1993 | { |
| 1922 | - if (substr($entry, -13) == '.template.php') |
|
| 1923 | - $templates[] = substr($entry, 0, -13); |
|
| 1994 | + if (substr($entry, -13) == '.template.php') { |
|
| 1995 | + $templates[] = substr($entry, 0, -13); |
|
| 1996 | + } |
|
| 1924 | 1997 | } |
| 1925 | 1998 | $dir->close(); |
| 1926 | 1999 | |
| 1927 | 2000 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
| 1928 | 2001 | while ($entry = $dir->read()) |
| 1929 | 2002 | { |
| 1930 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
| 1931 | - $lang_files[] = $matches[1]; |
|
| 2003 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
| 2004 | + $lang_files[] = $matches[1]; |
|
| 2005 | + } |
|
| 1932 | 2006 | } |
| 1933 | 2007 | $dir->close(); |
| 1934 | 2008 | |
@@ -1936,21 +2010,23 @@ discard block |
||
| 1936 | 2010 | natcasesort($lang_files); |
| 1937 | 2011 | |
| 1938 | 2012 | $context['available_templates'] = array(); |
| 1939 | - foreach ($templates as $template) |
|
| 1940 | - $context['available_templates'][$template] = array( |
|
| 2013 | + foreach ($templates as $template) { |
|
| 2014 | + $context['available_templates'][$template] = array( |
|
| 1941 | 2015 | 'filename' => $template . '.template.php', |
| 1942 | 2016 | 'value' => $template, |
| 1943 | 2017 | 'already_exists' => false, |
| 1944 | 2018 | 'can_copy' => is_writable($theme['theme_dir']), |
| 1945 | 2019 | ); |
| 2020 | + } |
|
| 1946 | 2021 | $context['available_language_files'] = array(); |
| 1947 | - foreach ($lang_files as $file) |
|
| 1948 | - $context['available_language_files'][$file] = array( |
|
| 2022 | + foreach ($lang_files as $file) { |
|
| 2023 | + $context['available_language_files'][$file] = array( |
|
| 1949 | 2024 | 'filename' => $file . '.php', |
| 1950 | 2025 | 'value' => $file, |
| 1951 | 2026 | 'already_exists' => false, |
| 1952 | 2027 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
| 1953 | 2028 | ); |
| 2029 | + } |
|
| 1954 | 2030 | |
| 1955 | 2031 | $dir = dir($theme['theme_dir']); |
| 1956 | 2032 | while ($entry = $dir->read()) |
@@ -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 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = smf_json_decode($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = smf_json_decode($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -709,8 +739,8 @@ discard block |
||
| 709 | 739 | ); |
| 710 | 740 | |
| 711 | 741 | // Give the translators some credit for their hard work. |
| 712 | - if (!empty($txt['translation_credits'])) |
|
| 713 | - $context['credits'][] = array( |
|
| 742 | + if (!empty($txt['translation_credits'])) { |
|
| 743 | + $context['credits'][] = array( |
|
| 714 | 744 | 'title' => $txt['credits_groups_translation'], |
| 715 | 745 | 'groups' => array( |
| 716 | 746 | array( |
@@ -719,6 +749,7 @@ discard block |
||
| 719 | 749 | ), |
| 720 | 750 | ), |
| 721 | 751 | ); |
| 752 | + } |
|
| 722 | 753 | |
| 723 | 754 | $context['credits'][] = array( |
| 724 | 755 | 'title' => $txt['credits_special'], |
@@ -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 functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
| 29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
| 30 | 31 | 'db_insert_sql' => 'smf_db_insert_sql', |
@@ -33,7 +34,8 @@ discard block |
||
| 33 | 34 | 'db_get_version' => 'smf_db_get_version', |
| 34 | 35 | 'db_get_engine' => 'smf_db_get_engine', |
| 35 | 36 | ); |
| 36 | -} |
|
| 37 | + } |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | /** |
| 39 | 41 | * Backup $table to $backup_table. |
@@ -75,8 +77,9 @@ discard block |
||
| 75 | 77 | )); |
| 76 | 78 | |
| 77 | 79 | // Old school or no school? |
| 78 | - if ($request) |
|
| 79 | - return $request; |
|
| 80 | + if ($request) { |
|
| 81 | + return $request; |
|
| 82 | + } |
|
| 80 | 83 | } |
| 81 | 84 | |
| 82 | 85 | // At this point, the quick method failed. |
@@ -100,8 +103,9 @@ discard block |
||
| 100 | 103 | foreach ($create as $k => $l) |
| 101 | 104 | { |
| 102 | 105 | // Get the name of the auto_increment column. |
| 103 | - if (strpos($l, 'auto_increment')) |
|
| 104 | - $auto_inc = trim($l); |
|
| 106 | + if (strpos($l, 'auto_increment')) { |
|
| 107 | + $auto_inc = trim($l); |
|
| 108 | + } |
|
| 105 | 109 | |
| 106 | 110 | // For the engine type, see if we can work out what it is. |
| 107 | 111 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -109,30 +113,36 @@ discard block |
||
| 109 | 113 | // Extract the engine type. |
| 110 | 114 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
| 111 | 115 | |
| 112 | - if (!empty($match[1])) |
|
| 113 | - $engine = $match[1]; |
|
| 116 | + if (!empty($match[1])) { |
|
| 117 | + $engine = $match[1]; |
|
| 118 | + } |
|
| 114 | 119 | |
| 115 | - if (!empty($match[2])) |
|
| 116 | - $engine = $match[2]; |
|
| 120 | + if (!empty($match[2])) { |
|
| 121 | + $engine = $match[2]; |
|
| 122 | + } |
|
| 117 | 123 | |
| 118 | - if (!empty($match[5])) |
|
| 119 | - $charset = $match[5]; |
|
| 124 | + if (!empty($match[5])) { |
|
| 125 | + $charset = $match[5]; |
|
| 126 | + } |
|
| 120 | 127 | |
| 121 | - if (!empty($match[7])) |
|
| 122 | - $collate = $match[7]; |
|
| 128 | + if (!empty($match[7])) { |
|
| 129 | + $collate = $match[7]; |
|
| 130 | + } |
|
| 123 | 131 | } |
| 124 | 132 | |
| 125 | 133 | // Skip everything but keys... |
| 126 | - if (strpos($l, 'KEY') === false) |
|
| 127 | - unset($create[$k]); |
|
| 134 | + if (strpos($l, 'KEY') === false) { |
|
| 135 | + unset($create[$k]); |
|
| 136 | + } |
|
| 128 | 137 | } |
| 129 | 138 | |
| 130 | - if (!empty($create)) |
|
| 131 | - $create = '( |
|
| 139 | + if (!empty($create)) { |
|
| 140 | + $create = '( |
|
| 132 | 141 | ' . implode(' |
| 133 | 142 | ', $create) . ')'; |
| 134 | - else |
|
| 135 | - $create = ''; |
|
| 143 | + } else { |
|
| 144 | + $create = ''; |
|
| 145 | + } |
|
| 136 | 146 | |
| 137 | 147 | $request = $smcFunc['db_query']('', ' |
| 138 | 148 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -151,8 +161,9 @@ discard block |
||
| 151 | 161 | |
| 152 | 162 | if ($auto_inc != '') |
| 153 | 163 | { |
| 154 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
| 155 | - $auto_inc = substr($auto_inc, 0, -1); |
|
| 164 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
| 165 | + $auto_inc = substr($auto_inc, 0, -1); |
|
| 166 | + } |
|
| 156 | 167 | |
| 157 | 168 | $smcFunc['db_query']('', ' |
| 158 | 169 | ALTER TABLE {raw:backup_table} |
@@ -196,8 +207,9 @@ discard block |
||
| 196 | 207 | 'table' => $table, |
| 197 | 208 | ) |
| 198 | 209 | ); |
| 199 | - if (!$request) |
|
| 200 | - return -1; |
|
| 210 | + if (!$request) { |
|
| 211 | + return -1; |
|
| 212 | + } |
|
| 201 | 213 | |
| 202 | 214 | // How much left? |
| 203 | 215 | $request = $smcFunc['db_query']('', ' |
@@ -240,8 +252,9 @@ discard block |
||
| 240 | 252 | ) |
| 241 | 253 | ); |
| 242 | 254 | $tables = array(); |
| 243 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 244 | - $tables[] = $row[0]; |
|
| 255 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 256 | + $tables[] = $row[0]; |
|
| 257 | + } |
|
| 245 | 258 | $smcFunc['db_free_result']($request); |
| 246 | 259 | |
| 247 | 260 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
| 284 | 297 | // The number of rows, just for record keeping and breaking INSERTs up. |
| 285 | 298 | $num_rows = $smcFunc['db_num_rows']($result); |
| 286 | 299 | |
| 287 | - if ($num_rows == 0) |
|
| 288 | - return ''; |
|
| 300 | + if ($num_rows == 0) { |
|
| 301 | + return ''; |
|
| 302 | + } |
|
| 289 | 303 | |
| 290 | 304 | if ($new_table) |
| 291 | 305 | { |
@@ -305,12 +319,13 @@ discard block |
||
| 305 | 319 | foreach ($row as $item) |
| 306 | 320 | { |
| 307 | 321 | // Try to figure out the type of each field. (NULL, number, or 'string'.) |
| 308 | - if (!isset($item)) |
|
| 309 | - $field_list[] = 'NULL'; |
|
| 310 | - elseif (is_numeric($item) && (int) $item == $item) |
|
| 311 | - $field_list[] = $item; |
|
| 312 | - else |
|
| 313 | - $field_list[] = '\'' . $smcFunc['db_escape_string']($item) . '\''; |
|
| 322 | + if (!isset($item)) { |
|
| 323 | + $field_list[] = 'NULL'; |
|
| 324 | + } elseif (is_numeric($item) && (int) $item == $item) { |
|
| 325 | + $field_list[] = $item; |
|
| 326 | + } else { |
|
| 327 | + $field_list[] = '\'' . $smcFunc['db_escape_string']($item) . '\''; |
|
| 328 | + } |
|
| 314 | 329 | } |
| 315 | 330 | |
| 316 | 331 | $data .= '(' . implode(', ', $field_list) . ')' . ',' . $crlf . "\t"; |
@@ -362,8 +377,9 @@ discard block |
||
| 362 | 377 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
| 363 | 378 | { |
| 364 | 379 | // Make a special case of auto-timestamp. |
| 365 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
| 366 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 380 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
| 381 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 382 | + } |
|
| 367 | 383 | // Text shouldn't have a default. |
| 368 | 384 | elseif ($row['Default'] !== null) |
| 369 | 385 | { |
@@ -398,14 +414,16 @@ discard block |
||
| 398 | 414 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
| 399 | 415 | |
| 400 | 416 | // Is this the first column in the index? |
| 401 | - if (empty($indexes[$row['Key_name']])) |
|
| 402 | - $indexes[$row['Key_name']] = array(); |
|
| 417 | + if (empty($indexes[$row['Key_name']])) { |
|
| 418 | + $indexes[$row['Key_name']] = array(); |
|
| 419 | + } |
|
| 403 | 420 | |
| 404 | 421 | // A sub part, like only indexing 15 characters of a varchar. |
| 405 | - if (!empty($row['Sub_part'])) |
|
| 406 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 407 | - else |
|
| 408 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 422 | + if (!empty($row['Sub_part'])) { |
|
| 423 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 424 | + } else { |
|
| 425 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 426 | + } |
|
| 409 | 427 | } |
| 410 | 428 | $smcFunc['db_free_result']($result); |
| 411 | 429 | |
@@ -443,8 +461,9 @@ discard block |
||
| 443 | 461 | { |
| 444 | 462 | static $ver; |
| 445 | 463 | |
| 446 | - if(!empty($ver)) |
|
| 447 | - return $ver; |
|
| 464 | + if(!empty($ver)) { |
|
| 465 | + return $ver; |
|
| 466 | + } |
|
| 448 | 467 | |
| 449 | 468 | global $smcFunc; |
| 450 | 469 | |
@@ -469,8 +488,9 @@ discard block |
||
| 469 | 488 | global $smcFunc; |
| 470 | 489 | static $db_type; |
| 471 | 490 | |
| 472 | - if (!empty($db_type)) |
|
| 473 | - return $db_type; |
|
| 491 | + if (!empty($db_type)) { |
|
| 492 | + return $db_type; |
|
| 493 | + } |
|
| 474 | 494 | |
| 475 | 495 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
| 476 | 496 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -479,13 +499,15 @@ discard block |
||
| 479 | 499 | // Skip these if we don't have a comment. |
| 480 | 500 | if (!empty($comment)) |
| 481 | 501 | { |
| 482 | - if (stripos($comment, 'percona') !== false) |
|
| 483 | - return 'Percona'; |
|
| 484 | - if (stripos($comment, 'mariadb') !== false) |
|
| 485 | - return 'MariaDB'; |
|
| 502 | + if (stripos($comment, 'percona') !== false) { |
|
| 503 | + return 'Percona'; |
|
| 504 | + } |
|
| 505 | + if (stripos($comment, 'mariadb') !== false) { |
|
| 506 | + return 'MariaDB'; |
|
| 507 | + } |
|
| 508 | + } else { |
|
| 509 | + return 'fail'; |
|
| 486 | 510 | } |
| 487 | - else |
|
| 488 | - return 'fail'; |
|
| 489 | 511 | |
| 490 | 512 | return 'MySQL'; |
| 491 | 513 | } |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $sourcedir, $profile_vars; |
| 30 | 31 | |
| 31 | 32 | // Don't load this twice! |
| 32 | - if (!empty($profile_fields) && !$force_reload) |
|
| 33 | - return; |
|
| 33 | + if (!empty($profile_fields) && !$force_reload) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
| 36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
| 103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
| 104 | 106 | { |
| 105 | 107 | // Set to blank? |
| 106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
| 107 | - $value = '0001-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '0001-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '0001-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '0001-01-01'; |
|
| 113 | 116 | |
| 114 | 117 | $profile_vars['birthdate'] = $value; |
| 115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
| 127 | 130 | { |
| 128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '0001-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-01-01' : $cur_profile['birthdate']; |
| 134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
| 150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
| 151 | 153 | } |
| 152 | 154 | // As long as it doesn't equal "N/A"... |
| 153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 155 | - else |
|
| 156 | - $value = $cur_profile['date_registered']; |
|
| 155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 157 | + } else { |
|
| 158 | + $value = $cur_profile['date_registered']; |
|
| 159 | + } |
|
| 157 | 160 | |
| 158 | 161 | return true; |
| 159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | { |
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 181 | - return false; |
|
| 183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) |
| 256 | 260 | { |
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 258 | - $_SESSION['language'] = $value; |
|
| 261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 262 | + $_SESSION['language'] = $value; |
|
| 263 | + } |
|
| 259 | 264 | return true; |
| 260 | - } |
|
| 261 | - else |
|
| 265 | + } else |
|
| 262 | 266 | { |
| 263 | 267 | $value = $cur_profile['lngfile']; |
| 264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? |
| 284 | 288 | $resetPassword = true; |
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
| 286 | - $resetPassword = false; |
|
| 289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
| 290 | + $resetPassword = false; |
|
| 291 | + } |
|
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. |
| 289 | - if ($resetPassword) |
|
| 290 | - resetPassword($context['id_member'], $value); |
|
| 291 | - elseif ($value !== null) |
|
| 294 | + if ($resetPassword) { |
|
| 295 | + resetPassword($context['id_member'], $value); |
|
| 296 | + } elseif ($value !== null) |
|
| 292 | 297 | { |
| 293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
| 294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
| 312 | 317 | 'input_validate' => function (&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 313 | 318 | { |
| 314 | 319 | // If we didn't try it then ignore it! |
| 315 | - if ($value == '') |
|
| 316 | - return false; |
|
| 320 | + if ($value == '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? |
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 320 | - return 'bad_new_password'; |
|
| 325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 326 | + return 'bad_new_password'; |
|
| 327 | + } |
|
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... |
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 325 | 332 | |
| 326 | 333 | // Were there errors? |
| 327 | - if ($passwordErrors != null) |
|
| 328 | - return 'password_' . $passwordErrors; |
|
| 334 | + if ($passwordErrors != null) { |
|
| 335 | + return 'password_' . $passwordErrors; |
|
| 336 | + } |
|
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. |
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
| 350 | 358 | 'permission' => 'profile_blurb', |
| 351 | 359 | 'input_validate' => function (&$value) use ($smcFunc) |
| 352 | 360 | { |
| 353 | - if ($smcFunc['strlen']($value) > 50) |
|
| 354 | - return 'personal_text_too_long'; |
|
| 361 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 362 | + return 'personal_text_too_long'; |
|
| 363 | + } |
|
| 355 | 364 | |
| 356 | 365 | return true; |
| 357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
| 386 | 395 | 'permission' => 'moderate_forum', |
| 387 | 396 | 'input_validate' => function (&$value) |
| 388 | 397 | { |
| 389 | - if (!is_numeric($value)) |
|
| 390 | - return 'digits_only'; |
|
| 391 | - else |
|
| 392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 398 | + if (!is_numeric($value)) { |
|
| 399 | + return 'digits_only'; |
|
| 400 | + } else { |
|
| 401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 402 | + } |
|
| 393 | 403 | return true; |
| 394 | 404 | }, |
| 395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
| 405 | 415 | { |
| 406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
| 407 | 417 | |
| 408 | - if (trim($value) == '') |
|
| 409 | - return 'no_name'; |
|
| 410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 411 | - return 'name_too_long'; |
|
| 412 | - elseif ($cur_profile['real_name'] != $value) |
|
| 418 | + if (trim($value) == '') { |
|
| 419 | + return 'no_name'; |
|
| 420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 421 | + return 'name_too_long'; |
|
| 422 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 413 | 423 | { |
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
| 415 | - if (isReservedName($value, $context['id_member'])) |
|
| 416 | - return 'name_taken'; |
|
| 425 | + if (isReservedName($value, $context['id_member'])) { |
|
| 426 | + return 'name_taken'; |
|
| 427 | + } |
|
| 417 | 428 | } |
| 418 | 429 | return true; |
| 419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 472 | 483 | ); |
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | return true; |
| 478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
| 481 | 493 | global $modSettings; |
| 482 | 494 | |
| 483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 485 | - $value = ''; |
|
| 496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 497 | + $value = ''; |
|
| 498 | + } |
|
| 486 | 499 | return true; |
| 487 | 500 | }, |
| 488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
| 497 | 510 | loadLanguage('Settings'); |
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; |
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 515 | + } |
|
| 502 | 516 | |
| 503 | 517 | return true; |
| 504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | 'input_validate' => function ($value) |
| 546 | 560 | { |
| 547 | 561 | $tz = smf_list_timezones(); |
| 548 | - if (!isset($tz[$value])) |
|
| 549 | - return 'bad_timezone'; |
|
| 562 | + if (!isset($tz[$value])) { |
|
| 563 | + return 'bad_timezone'; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | return true; |
| 552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 562 | 577 | 'input_validate' => function (&$value) use ($smcFunc) |
| 563 | 578 | { |
| 564 | - if ($smcFunc['strlen']($value) > 50) |
|
| 565 | - return 'user_title_too_long'; |
|
| 579 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 580 | + return 'user_title_too_long'; |
|
| 581 | + } |
|
| 566 | 582 | |
| 567 | 583 | return true; |
| 568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
| 584 | 600 | // Fix the URL... |
| 585 | 601 | 'input_validate' => function (&$value) |
| 586 | 602 | { |
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 588 | - $value = 'http://' . $value; |
|
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 590 | - $value = ''; |
|
| 603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 604 | + $value = 'http://' . $value; |
|
| 605 | + } |
|
| 606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 607 | + $value = ''; |
|
| 608 | + } |
|
| 591 | 609 | return true; |
| 592 | 610 | }, |
| 593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
| 601 | 619 | foreach ($profile_fields as $key => $field) |
| 602 | 620 | { |
| 603 | 621 | // Do we have permission to do this? |
| 604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 605 | - unset($profile_fields[$key]); |
|
| 622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 623 | + unset($profile_fields[$key]); |
|
| 624 | + } |
|
| 606 | 625 | |
| 607 | 626 | // Is it enabled? |
| 608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 609 | - unset($profile_fields[$key]); |
|
| 627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 628 | + unset($profile_fields[$key]); |
|
| 629 | + } |
|
| 610 | 630 | |
| 611 | 631 | // Is it specifically disabled? |
| 612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 613 | - unset($profile_fields[$key]); |
|
| 632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 633 | + unset($profile_fields[$key]); |
|
| 634 | + } |
|
| 614 | 635 | } |
| 615 | 636 | } |
| 616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
| 635 | 656 | loadProfileFields(true); |
| 636 | 657 | |
| 637 | 658 | // First check for any linked sets. |
| 638 | - foreach ($profile_fields as $key => $field) |
|
| 639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 659 | + foreach ($profile_fields as $key => $field) { |
|
| 660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 640 | 661 | $fields[] = $key; |
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | $i = 0; |
| 643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
| 649 | 671 | $cur_field = &$profile_fields[$field]; |
| 650 | 672 | |
| 651 | 673 | // Does it have a preload and does that preload succeed? |
| 652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 653 | - continue; |
|
| 674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 654 | 677 | |
| 655 | 678 | // If this is anything but complex we need to do more cleaning! |
| 656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 657 | 680 | { |
| 658 | - if (!isset($cur_field['label'])) |
|
| 659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 681 | + if (!isset($cur_field['label'])) { |
|
| 682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 683 | + } |
|
| 660 | 684 | |
| 661 | 685 | // Everything has a value! |
| 662 | - if (!isset($cur_field['value'])) |
|
| 663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 686 | + if (!isset($cur_field['value'])) { |
|
| 687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 688 | + } |
|
| 664 | 689 | |
| 665 | 690 | // Any input attributes? |
| 666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 667 | 692 | } |
| 668 | 693 | |
| 669 | 694 | // Was there an error with this field on posting? |
| 670 | - if (isset($context['profile_errors'][$field])) |
|
| 671 | - $cur_field['is_error'] = true; |
|
| 695 | + if (isset($context['profile_errors'][$field])) { |
|
| 696 | + $cur_field['is_error'] = true; |
|
| 697 | + } |
|
| 672 | 698 | |
| 673 | 699 | // Any javascript stuff? |
| 674 | - if (!empty($cur_field['js_submit'])) |
|
| 675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 676 | - if (!empty($cur_field['js'])) |
|
| 677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 700 | + if (!empty($cur_field['js_submit'])) { |
|
| 701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 702 | + } |
|
| 703 | + if (!empty($cur_field['js'])) { |
|
| 704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 705 | + } |
|
| 678 | 706 | |
| 679 | 707 | // Any template stuff? |
| 680 | - if (!empty($cur_field['prehtml'])) |
|
| 681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 682 | - if (!empty($cur_field['posthtml'])) |
|
| 683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 708 | + if (!empty($cur_field['prehtml'])) { |
|
| 709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 710 | + } |
|
| 711 | + if (!empty($cur_field['posthtml'])) { |
|
| 712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 713 | + } |
|
| 684 | 714 | |
| 685 | 715 | // Finally put it into context? |
| 686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
| 713 | 743 | }, false);' : ''), true); |
| 714 | 744 | |
| 715 | 745 | // Any onsubmit javascript? |
| 716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 748 | + } |
|
| 718 | 749 | |
| 719 | 750 | // Any totally custom stuff? |
| 720 | - if (!empty($context['profile_javascript'])) |
|
| 721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 751 | + if (!empty($context['profile_javascript'])) { |
|
| 752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 753 | + } |
|
| 722 | 754 | |
| 723 | 755 | // Free up some memory. |
| 724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
| 739 | 771 | |
| 740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
| 741 | 773 | $context['profile_execute_on_save'] = array(); |
| 742 | - if ($context['user']['is_owner']) |
|
| 743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 774 | + if ($context['user']['is_owner']) { |
|
| 775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 776 | + } |
|
| 744 | 777 | |
| 745 | 778 | // Assume we log nothing. |
| 746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
| 748 | 781 | // Cycle through the profile fields working out what to do! |
| 749 | 782 | foreach ($profile_fields as $key => $field) |
| 750 | 783 | { |
| 751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 752 | - continue; |
|
| 784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 785 | + continue; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // What gets updated? |
| 755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
| 777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 778 | 812 | |
| 779 | 813 | // Finally, clean up certain types. |
| 780 | - if ($field['cast_type'] == 'int') |
|
| 781 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 782 | - elseif ($field['cast_type'] == 'float') |
|
| 783 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 784 | - elseif ($field['cast_type'] == 'check') |
|
| 785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 814 | + if ($field['cast_type'] == 'int') { |
|
| 815 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 816 | + } elseif ($field['cast_type'] == 'float') { |
|
| 817 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 818 | + } elseif ($field['cast_type'] == 'check') { |
|
| 819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // If we got here we're doing OK. |
| 788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
| 793 | 828 | $cur_profile[$key] = $_POST[$key]; |
| 794 | 829 | |
| 795 | 830 | // Are we logging it? |
| 796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 797 | - $context['log_changes'][$key] = array( |
|
| 831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 832 | + $context['log_changes'][$key] = array( |
|
| 798 | 833 | 'previous' => $old_profile[$key], |
| 799 | 834 | 'new' => $_POST[$key], |
| 800 | 835 | ); |
| 836 | + } |
|
| 801 | 837 | } |
| 802 | 838 | |
| 803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
| 830 | 866 | { |
| 831 | 867 | foreach ($groups as $id => $group) |
| 832 | 868 | { |
| 833 | - if (isset($context['member_groups'][$group])) |
|
| 834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 835 | - else |
|
| 836 | - unset($additional_groups[$type][$id]); |
|
| 869 | + if (isset($context['member_groups'][$group])) { |
|
| 870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 871 | + } else { |
|
| 872 | + unset($additional_groups[$type][$id]); |
|
| 873 | + } |
|
| 837 | 874 | } |
| 838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
| 844 | 881 | } |
| 845 | 882 | |
| 846 | 883 | // @todo Temporary |
| 847 | - if ($context['user']['is_owner']) |
|
| 848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 849 | - else |
|
| 850 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 884 | + if ($context['user']['is_owner']) { |
|
| 885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 886 | + } else { |
|
| 887 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 888 | + } |
|
| 851 | 889 | if ($changeOther && empty($post_errors)) |
| 852 | 890 | { |
| 853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
| 855 | 893 | { |
| 856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 857 | 895 | |
| 858 | - if (!empty($custom_fields_errors)) |
|
| 859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 896 | + if (!empty($custom_fields_errors)) { |
|
| 897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 898 | + } |
|
| 860 | 899 | } |
| 861 | 900 | } |
| 862 | 901 | |
@@ -883,8 +922,7 @@ discard block |
||
| 883 | 922 | { |
| 884 | 923 | $changeIdentity = allowedTo(array('profile_identity_any', 'profile_identity_own', 'profile_password_any', 'profile_password_own')); |
| 885 | 924 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 886 | - } |
|
| 887 | - else |
|
| 925 | + } else |
|
| 888 | 926 | { |
| 889 | 927 | $changeIdentity = allowedTo('profile_identity_any', 'profile_signature_any'); |
| 890 | 928 | $changeOther = allowedTo('profile_extra_any', 'profile_website_any', 'profile_signature_any'); |
@@ -899,22 +937,25 @@ discard block |
||
| 899 | 937 | 'ignore_boards', |
| 900 | 938 | ); |
| 901 | 939 | |
| 902 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 903 | - $_POST['ignore_brd'] = array(); |
|
| 940 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 941 | + $_POST['ignore_brd'] = array(); |
|
| 942 | + } |
|
| 904 | 943 | |
| 905 | 944 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 906 | 945 | if (isset($_POST['ignore_brd'])) |
| 907 | 946 | { |
| 908 | - if (!is_array($_POST['ignore_brd'])) |
|
| 909 | - $_POST['ignore_brd'] = array ($_POST['ignore_brd']); |
|
| 947 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 948 | + $_POST['ignore_brd'] = array ($_POST['ignore_brd']); |
|
| 949 | + } |
|
| 910 | 950 | |
| 911 | 951 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 912 | 952 | { |
| 913 | 953 | $d = (int) $d; |
| 914 | - if ($d != 0) |
|
| 915 | - $_POST['ignore_brd'][$k] = $d; |
|
| 916 | - else |
|
| 917 | - unset($_POST['ignore_brd'][$k]); |
|
| 954 | + if ($d != 0) { |
|
| 955 | + $_POST['ignore_brd'][$k] = $d; |
|
| 956 | + } else { |
|
| 957 | + unset($_POST['ignore_brd'][$k]); |
|
| 958 | + } |
|
| 918 | 959 | } |
| 919 | 960 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 920 | 961 | unset($_POST['ignore_brd']); |
@@ -927,21 +968,26 @@ discard block |
||
| 927 | 968 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 928 | 969 | //makeAvatarChanges($memID, $post_errors); |
| 929 | 970 | |
| 930 | - if (!empty($_REQUEST['sa'])) |
|
| 931 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 971 | + if (!empty($_REQUEST['sa'])) { |
|
| 972 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 973 | + } |
|
| 932 | 974 | |
| 933 | - foreach ($profile_bools as $var) |
|
| 934 | - if (isset($_POST[$var])) |
|
| 975 | + foreach ($profile_bools as $var) { |
|
| 976 | + if (isset($_POST[$var])) |
|
| 935 | 977 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 936 | - foreach ($profile_ints as $var) |
|
| 937 | - if (isset($_POST[$var])) |
|
| 978 | + } |
|
| 979 | + foreach ($profile_ints as $var) { |
|
| 980 | + if (isset($_POST[$var])) |
|
| 938 | 981 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 939 | - foreach ($profile_floats as $var) |
|
| 940 | - if (isset($_POST[$var])) |
|
| 982 | + } |
|
| 983 | + foreach ($profile_floats as $var) { |
|
| 984 | + if (isset($_POST[$var])) |
|
| 941 | 985 | $profile_vars[$var] = (float) $_POST[$var]; |
| 942 | - foreach ($profile_strings as $var) |
|
| 943 | - if (isset($_POST[$var])) |
|
| 986 | + } |
|
| 987 | + foreach ($profile_strings as $var) { |
|
| 988 | + if (isset($_POST[$var])) |
|
| 944 | 989 | $profile_vars[$var] = $_POST[$var]; |
| 990 | + } |
|
| 945 | 991 | } |
| 946 | 992 | } |
| 947 | 993 | |
@@ -975,8 +1021,9 @@ discard block |
||
| 975 | 1021 | ); |
| 976 | 1022 | |
| 977 | 1023 | // Can't change reserved vars. |
| 978 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
| 979 | - fatal_lang_error('no_access', false); |
|
| 1024 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
| 1025 | + fatal_lang_error('no_access', false); |
|
| 1026 | + } |
|
| 980 | 1027 | |
| 981 | 1028 | // Don't allow any overriding of custom fields with default or non-default options. |
| 982 | 1029 | $request = $smcFunc['db_query']('', ' |
@@ -988,8 +1035,9 @@ discard block |
||
| 988 | 1035 | ) |
| 989 | 1036 | ); |
| 990 | 1037 | $custom_fields = array(); |
| 991 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 992 | - $custom_fields[] = $row['col_name']; |
|
| 1038 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1039 | + $custom_fields[] = $row['col_name']; |
|
| 1040 | + } |
|
| 993 | 1041 | $smcFunc['db_free_result']($request); |
| 994 | 1042 | |
| 995 | 1043 | // These are the theme changes... |
@@ -998,33 +1046,39 @@ discard block |
||
| 998 | 1046 | { |
| 999 | 1047 | foreach ($_POST['options'] as $opt => $val) |
| 1000 | 1048 | { |
| 1001 | - if (in_array($opt, $custom_fields)) |
|
| 1002 | - continue; |
|
| 1049 | + if (in_array($opt, $custom_fields)) { |
|
| 1050 | + continue; |
|
| 1051 | + } |
|
| 1003 | 1052 | |
| 1004 | 1053 | // These need to be controlled. |
| 1005 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1006 | - $val = max(0, min($val, 50)); |
|
| 1054 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1055 | + $val = max(0, min($val, 50)); |
|
| 1056 | + } |
|
| 1007 | 1057 | // We don't set this per theme anymore. |
| 1008 | - elseif ($opt == 'allow_no_censored') |
|
| 1009 | - continue; |
|
| 1058 | + elseif ($opt == 'allow_no_censored') { |
|
| 1059 | + continue; |
|
| 1060 | + } |
|
| 1010 | 1061 | |
| 1011 | 1062 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1012 | 1063 | } |
| 1013 | 1064 | } |
| 1014 | 1065 | |
| 1015 | 1066 | $erase_options = array(); |
| 1016 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1017 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1067 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1068 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1018 | 1069 | { |
| 1019 | 1070 | if (in_array($opt, $custom_fields)) |
| 1020 | 1071 | continue; |
| 1072 | + } |
|
| 1021 | 1073 | |
| 1022 | 1074 | // These need to be controlled. |
| 1023 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1024 | - $val = max(0, min($val, 50)); |
|
| 1075 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1076 | + $val = max(0, min($val, 50)); |
|
| 1077 | + } |
|
| 1025 | 1078 | // Only let admins and owners change the censor. |
| 1026 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1027 | - continue; |
|
| 1079 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1080 | + continue; |
|
| 1081 | + } |
|
| 1028 | 1082 | |
| 1029 | 1083 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1030 | 1084 | $erase_options[] = $opt; |
@@ -1060,8 +1114,9 @@ discard block |
||
| 1060 | 1114 | |
| 1061 | 1115 | // Admins can choose any theme, even if it's not enabled... |
| 1062 | 1116 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1063 | - foreach ($themes as $t) |
|
| 1064 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1117 | + foreach ($themes as $t) { |
|
| 1118 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1119 | + } |
|
| 1065 | 1120 | } |
| 1066 | 1121 | } |
| 1067 | 1122 | |
@@ -1080,8 +1135,9 @@ discard block |
||
| 1080 | 1135 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1081 | 1136 | { |
| 1082 | 1137 | // Make sure only integers are deleted. |
| 1083 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1084 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1138 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1139 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1140 | + } |
|
| 1085 | 1141 | |
| 1086 | 1142 | // id_board = 0 is reserved for topic notifications. |
| 1087 | 1143 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1100,8 +1156,9 @@ discard block |
||
| 1100 | 1156 | // We are editing topic notifications...... |
| 1101 | 1157 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1102 | 1158 | { |
| 1103 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1104 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1159 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1160 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1161 | + } |
|
| 1105 | 1162 | |
| 1106 | 1163 | // Make sure there are no zeros left. |
| 1107 | 1164 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1115,16 +1172,18 @@ discard block |
||
| 1115 | 1172 | 'selected_member' => $memID, |
| 1116 | 1173 | ) |
| 1117 | 1174 | ); |
| 1118 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1119 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1175 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1176 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1177 | + } |
|
| 1120 | 1178 | } |
| 1121 | 1179 | |
| 1122 | 1180 | // We are removing topic preferences |
| 1123 | 1181 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1124 | 1182 | { |
| 1125 | 1183 | $prefs = array(); |
| 1126 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1127 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1184 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1185 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1186 | + } |
|
| 1128 | 1187 | deleteNotifyPrefs($memID, $prefs); |
| 1129 | 1188 | } |
| 1130 | 1189 | |
@@ -1132,8 +1191,9 @@ discard block |
||
| 1132 | 1191 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1133 | 1192 | { |
| 1134 | 1193 | $prefs = array(); |
| 1135 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1136 | - $prefs[] = 'board_notify_' . $board; |
|
| 1194 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1195 | + $prefs[] = 'board_notify_' . $board; |
|
| 1196 | + } |
|
| 1137 | 1197 | deleteNotifyPrefs($memID, $prefs); |
| 1138 | 1198 | } |
| 1139 | 1199 | } |
@@ -1154,8 +1214,9 @@ discard block |
||
| 1154 | 1214 | |
| 1155 | 1215 | $errors = array(); |
| 1156 | 1216 | |
| 1157 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1158 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1217 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1218 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1219 | + } |
|
| 1159 | 1220 | |
| 1160 | 1221 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1161 | 1222 | |
@@ -1180,48 +1241,49 @@ discard block |
||
| 1180 | 1241 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1181 | 1242 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1182 | 1243 | */ |
| 1183 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1184 | - continue; |
|
| 1244 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1245 | + continue; |
|
| 1246 | + } |
|
| 1185 | 1247 | |
| 1186 | 1248 | // Validate the user data. |
| 1187 | - if ($row['field_type'] == 'check') |
|
| 1188 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1189 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1249 | + if ($row['field_type'] == 'check') { |
|
| 1250 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1251 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1190 | 1252 | { |
| 1191 | 1253 | $value = $row['default_value']; |
| 1192 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1193 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1254 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1255 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1194 | 1256 | $value = $v; |
| 1257 | + } |
|
| 1195 | 1258 | } |
| 1196 | 1259 | // Otherwise some form of text! |
| 1197 | 1260 | else |
| 1198 | 1261 | { |
| 1199 | 1262 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1200 | - if ($row['field_length']) |
|
| 1201 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1263 | + if ($row['field_length']) { |
|
| 1264 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1265 | + } |
|
| 1202 | 1266 | |
| 1203 | 1267 | // Any masks? |
| 1204 | 1268 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 1205 | 1269 | { |
| 1206 | 1270 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
| 1207 | 1271 | { |
| 1208 | - if ($returnErrors) |
|
| 1209 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1210 | - |
|
| 1211 | - else |
|
| 1212 | - $value = ''; |
|
| 1213 | - } |
|
| 1214 | - elseif ($row['mask'] == 'number') |
|
| 1272 | + if ($returnErrors) { |
|
| 1273 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1274 | + } else { |
|
| 1275 | + $value = ''; |
|
| 1276 | + } |
|
| 1277 | + } elseif ($row['mask'] == 'number') |
|
| 1215 | 1278 | { |
| 1216 | 1279 | $value = (int) $value; |
| 1217 | - } |
|
| 1218 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1280 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1219 | 1281 | { |
| 1220 | - if ($returnErrors) |
|
| 1221 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1222 | - |
|
| 1223 | - else |
|
| 1224 | - $value = ''; |
|
| 1282 | + if ($returnErrors) { |
|
| 1283 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1284 | + } else { |
|
| 1285 | + $value = ''; |
|
| 1286 | + } |
|
| 1225 | 1287 | } |
| 1226 | 1288 | } |
| 1227 | 1289 | } |
@@ -1248,8 +1310,9 @@ discard block |
||
| 1248 | 1310 | $hook_errors = array(); |
| 1249 | 1311 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1250 | 1312 | |
| 1251 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1252 | - $errors = array_merge($errors, $hook_errors); |
|
| 1313 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1314 | + $errors = array_merge($errors, $hook_errors); |
|
| 1315 | + } |
|
| 1253 | 1316 | |
| 1254 | 1317 | // Make those changes! |
| 1255 | 1318 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1267,9 +1330,10 @@ discard block |
||
| 1267 | 1330 | } |
| 1268 | 1331 | } |
| 1269 | 1332 | |
| 1270 | - if ($returnErrors) |
|
| 1271 | - return $errors; |
|
| 1272 | -} |
|
| 1333 | + if ($returnErrors) { |
|
| 1334 | + return $errors; |
|
| 1335 | + } |
|
| 1336 | + } |
|
| 1273 | 1337 | |
| 1274 | 1338 | /** |
| 1275 | 1339 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1281,8 +1345,9 @@ discard block |
||
| 1281 | 1345 | global $context, $txt, $modSettings; |
| 1282 | 1346 | |
| 1283 | 1347 | // Do a quick check to ensure people aren't getting here illegally! |
| 1284 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1285 | - fatal_lang_error('no_access', false); |
|
| 1348 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1349 | + fatal_lang_error('no_access', false); |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | // Can we email the user direct? |
| 1288 | 1353 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1312,9 +1377,10 @@ discard block |
||
| 1312 | 1377 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1313 | 1378 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1314 | 1379 | |
| 1315 | - if (!empty($call)) |
|
| 1316 | - call_user_func($call, $memID); |
|
| 1317 | -} |
|
| 1380 | + if (!empty($call)) { |
|
| 1381 | + call_user_func($call, $memID); |
|
| 1382 | + } |
|
| 1383 | + } |
|
| 1318 | 1384 | |
| 1319 | 1385 | /** |
| 1320 | 1386 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1328,9 +1394,10 @@ discard block |
||
| 1328 | 1394 | |
| 1329 | 1395 | // For making changes! |
| 1330 | 1396 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1331 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1332 | - if ($dummy == '') |
|
| 1397 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1398 | + if ($dummy == '') |
|
| 1333 | 1399 | unset($buddiesArray[$k]); |
| 1400 | + } |
|
| 1334 | 1401 | |
| 1335 | 1402 | // Removing a buddy? |
| 1336 | 1403 | if (isset($_GET['remove'])) |
@@ -1342,10 +1409,11 @@ discard block |
||
| 1342 | 1409 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1343 | 1410 | |
| 1344 | 1411 | // Heh, I'm lazy, do it the easy way... |
| 1345 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1346 | - if ($buddy == (int) $_GET['remove']) |
|
| 1412 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1413 | + if ($buddy == (int) $_GET['remove']) |
|
| 1347 | 1414 | { |
| 1348 | 1415 | unset($buddiesArray[$key]); |
| 1416 | + } |
|
| 1349 | 1417 | $_SESSION['prf-save'] = true; |
| 1350 | 1418 | } |
| 1351 | 1419 | |
@@ -1355,8 +1423,7 @@ discard block |
||
| 1355 | 1423 | |
| 1356 | 1424 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1357 | 1425 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1358 | - } |
|
| 1359 | - elseif (isset($_POST['new_buddy'])) |
|
| 1426 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1360 | 1427 | { |
| 1361 | 1428 | checkSession(); |
| 1362 | 1429 | |
@@ -1369,8 +1436,9 @@ discard block |
||
| 1369 | 1436 | { |
| 1370 | 1437 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1371 | 1438 | |
| 1372 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1373 | - unset($new_buddies[$k]); |
|
| 1439 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1440 | + unset($new_buddies[$k]); |
|
| 1441 | + } |
|
| 1374 | 1442 | } |
| 1375 | 1443 | |
| 1376 | 1444 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1390,16 +1458,18 @@ discard block |
||
| 1390 | 1458 | ) |
| 1391 | 1459 | ); |
| 1392 | 1460 | |
| 1393 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1394 | - $_SESSION['prf-save'] = true; |
|
| 1461 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1462 | + $_SESSION['prf-save'] = true; |
|
| 1463 | + } |
|
| 1395 | 1464 | |
| 1396 | 1465 | // Add the new member to the buddies array. |
| 1397 | 1466 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1398 | 1467 | { |
| 1399 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1400 | - continue; |
|
| 1401 | - else |
|
| 1402 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1468 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1469 | + continue; |
|
| 1470 | + } else { |
|
| 1471 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1472 | + } |
|
| 1403 | 1473 | } |
| 1404 | 1474 | $smcFunc['db_free_result']($request); |
| 1405 | 1475 | |
@@ -1429,18 +1499,20 @@ discard block |
||
| 1429 | 1499 | |
| 1430 | 1500 | $context['custom_pf'] = array(); |
| 1431 | 1501 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1432 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1433 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1502 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1503 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1434 | 1504 | $context['custom_pf'][$row['col_name']] = array( |
| 1435 | 1505 | 'label' => $row['field_name'], |
| 1436 | 1506 | 'type' => $row['field_type'], |
| 1437 | 1507 | 'bbc' => !empty($row['bbc']), |
| 1438 | 1508 | 'enclose' => $row['enclose'], |
| 1439 | 1509 | ); |
| 1510 | + } |
|
| 1440 | 1511 | |
| 1441 | 1512 | // Gotta disable the gender option. |
| 1442 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1443 | - unset($context['custom_pf']['cust_gender']); |
|
| 1513 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1514 | + unset($context['custom_pf']['cust_gender']); |
|
| 1515 | + } |
|
| 1444 | 1516 | |
| 1445 | 1517 | $smcFunc['db_free_result']($request); |
| 1446 | 1518 | |
@@ -1457,8 +1529,9 @@ discard block |
||
| 1457 | 1529 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1458 | 1530 | ) |
| 1459 | 1531 | ); |
| 1460 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1461 | - $buddies[] = $row['id_member']; |
|
| 1532 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1533 | + $buddies[] = $row['id_member']; |
|
| 1534 | + } |
|
| 1462 | 1535 | $smcFunc['db_free_result']($result); |
| 1463 | 1536 | } |
| 1464 | 1537 | |
@@ -1486,30 +1559,32 @@ discard block |
||
| 1486 | 1559 | continue; |
| 1487 | 1560 | } |
| 1488 | 1561 | |
| 1489 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1490 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1491 | - |
|
| 1492 | - elseif ($column['type'] == 'check') |
|
| 1493 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1562 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1563 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1564 | + } elseif ($column['type'] == 'check') { |
|
| 1565 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1566 | + } |
|
| 1494 | 1567 | |
| 1495 | 1568 | // Enclosing the user input within some other text? |
| 1496 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1497 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1569 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1570 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1498 | 1571 | '{SCRIPTURL}' => $scripturl, |
| 1499 | 1572 | '{IMAGES_URL}' => $settings['images_url'], |
| 1500 | 1573 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1501 | 1574 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1502 | 1575 | )); |
| 1576 | + } |
|
| 1503 | 1577 | } |
| 1504 | 1578 | } |
| 1505 | 1579 | } |
| 1506 | 1580 | |
| 1507 | 1581 | if (isset($_SESSION['prf-save'])) |
| 1508 | 1582 | { |
| 1509 | - if ($_SESSION['prf-save'] === true) |
|
| 1510 | - $context['saved_successful'] = true; |
|
| 1511 | - else |
|
| 1512 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1583 | + if ($_SESSION['prf-save'] === true) { |
|
| 1584 | + $context['saved_successful'] = true; |
|
| 1585 | + } else { |
|
| 1586 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1587 | + } |
|
| 1513 | 1588 | |
| 1514 | 1589 | unset($_SESSION['prf-save']); |
| 1515 | 1590 | } |
@@ -1529,9 +1604,10 @@ discard block |
||
| 1529 | 1604 | |
| 1530 | 1605 | // For making changes! |
| 1531 | 1606 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1532 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1533 | - if ($dummy == '') |
|
| 1607 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1608 | + if ($dummy == '') |
|
| 1534 | 1609 | unset($ignoreArray[$k]); |
| 1610 | + } |
|
| 1535 | 1611 | |
| 1536 | 1612 | // Removing a member from the ignore list? |
| 1537 | 1613 | if (isset($_GET['remove'])) |
@@ -1541,10 +1617,11 @@ discard block |
||
| 1541 | 1617 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1542 | 1618 | |
| 1543 | 1619 | // Heh, I'm lazy, do it the easy way... |
| 1544 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1545 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1620 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1621 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1546 | 1622 | { |
| 1547 | 1623 | unset($ignoreArray[$key]); |
| 1624 | + } |
|
| 1548 | 1625 | $_SESSION['prf-save'] = true; |
| 1549 | 1626 | } |
| 1550 | 1627 | |
@@ -1554,8 +1631,7 @@ discard block |
||
| 1554 | 1631 | |
| 1555 | 1632 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1556 | 1633 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1557 | - } |
|
| 1558 | - elseif (isset($_POST['new_ignore'])) |
|
| 1634 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1559 | 1635 | { |
| 1560 | 1636 | checkSession(); |
| 1561 | 1637 | // Prepare the string for extraction... |
@@ -1567,8 +1643,9 @@ discard block |
||
| 1567 | 1643 | { |
| 1568 | 1644 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1569 | 1645 | |
| 1570 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1571 | - unset($new_entries[$k]); |
|
| 1646 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1647 | + unset($new_entries[$k]); |
|
| 1648 | + } |
|
| 1572 | 1649 | } |
| 1573 | 1650 | |
| 1574 | 1651 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1586,16 +1663,18 @@ discard block |
||
| 1586 | 1663 | ) |
| 1587 | 1664 | ); |
| 1588 | 1665 | |
| 1589 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1590 | - $_SESSION['prf-save'] = true; |
|
| 1666 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1667 | + $_SESSION['prf-save'] = true; |
|
| 1668 | + } |
|
| 1591 | 1669 | |
| 1592 | 1670 | // Add the new member to the buddies array. |
| 1593 | 1671 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1594 | 1672 | { |
| 1595 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1596 | - continue; |
|
| 1597 | - else |
|
| 1598 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1673 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1674 | + continue; |
|
| 1675 | + } else { |
|
| 1676 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1677 | + } |
|
| 1599 | 1678 | } |
| 1600 | 1679 | $smcFunc['db_free_result']($request); |
| 1601 | 1680 | |
@@ -1624,8 +1703,9 @@ discard block |
||
| 1624 | 1703 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1625 | 1704 | ) |
| 1626 | 1705 | ); |
| 1627 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1628 | - $ignored[] = $row['id_member']; |
|
| 1706 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1707 | + $ignored[] = $row['id_member']; |
|
| 1708 | + } |
|
| 1629 | 1709 | $smcFunc['db_free_result']($result); |
| 1630 | 1710 | } |
| 1631 | 1711 | |
@@ -1644,10 +1724,11 @@ discard block |
||
| 1644 | 1724 | |
| 1645 | 1725 | if (isset($_SESSION['prf-save'])) |
| 1646 | 1726 | { |
| 1647 | - if ($_SESSION['prf-save'] === true) |
|
| 1648 | - $context['saved_successful'] = true; |
|
| 1649 | - else |
|
| 1650 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1727 | + if ($_SESSION['prf-save'] === true) { |
|
| 1728 | + $context['saved_successful'] = true; |
|
| 1729 | + } else { |
|
| 1730 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1731 | + } |
|
| 1651 | 1732 | |
| 1652 | 1733 | unset($_SESSION['prf-save']); |
| 1653 | 1734 | } |
@@ -1663,8 +1744,9 @@ discard block |
||
| 1663 | 1744 | global $context, $txt; |
| 1664 | 1745 | |
| 1665 | 1746 | loadThemeOptions($memID); |
| 1666 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1667 | - loadCustomFields($memID, 'account'); |
|
| 1747 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1748 | + loadCustomFields($memID, 'account'); |
|
| 1749 | + } |
|
| 1668 | 1750 | |
| 1669 | 1751 | $context['sub_template'] = 'edit_options'; |
| 1670 | 1752 | $context['page_desc'] = $txt['account_info']; |
@@ -1691,8 +1773,9 @@ discard block |
||
| 1691 | 1773 | global $context, $txt; |
| 1692 | 1774 | |
| 1693 | 1775 | loadThemeOptions($memID); |
| 1694 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1695 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1776 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1777 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1778 | + } |
|
| 1696 | 1779 | |
| 1697 | 1780 | $context['sub_template'] = 'edit_options'; |
| 1698 | 1781 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1725,18 +1808,21 @@ discard block |
||
| 1725 | 1808 | $dirs = array(); |
| 1726 | 1809 | $files = array(); |
| 1727 | 1810 | |
| 1728 | - if (!$dir) |
|
| 1729 | - return array(); |
|
| 1811 | + if (!$dir) { |
|
| 1812 | + return array(); |
|
| 1813 | + } |
|
| 1730 | 1814 | |
| 1731 | 1815 | while ($line = $dir->read()) |
| 1732 | 1816 | { |
| 1733 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1734 | - continue; |
|
| 1817 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1818 | + continue; |
|
| 1819 | + } |
|
| 1735 | 1820 | |
| 1736 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1737 | - $dirs[] = $line; |
|
| 1738 | - else |
|
| 1739 | - $files[] = $line; |
|
| 1821 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1822 | + $dirs[] = $line; |
|
| 1823 | + } else { |
|
| 1824 | + $files[] = $line; |
|
| 1825 | + } |
|
| 1740 | 1826 | } |
| 1741 | 1827 | $dir->close(); |
| 1742 | 1828 | |
@@ -1757,14 +1843,15 @@ discard block |
||
| 1757 | 1843 | foreach ($dirs as $line) |
| 1758 | 1844 | { |
| 1759 | 1845 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1760 | - if (!empty($tmp)) |
|
| 1761 | - $result[] = array( |
|
| 1846 | + if (!empty($tmp)) { |
|
| 1847 | + $result[] = array( |
|
| 1762 | 1848 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1763 | 1849 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1764 | 1850 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1765 | 1851 | 'is_dir' => true, |
| 1766 | 1852 | 'files' => $tmp |
| 1767 | 1853 | ); |
| 1854 | + } |
|
| 1768 | 1855 | unset($tmp); |
| 1769 | 1856 | } |
| 1770 | 1857 | |
@@ -1774,8 +1861,9 @@ discard block |
||
| 1774 | 1861 | $extension = substr(strrchr($line, '.'), 1); |
| 1775 | 1862 | |
| 1776 | 1863 | // Make sure it is an image. |
| 1777 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1778 | - continue; |
|
| 1864 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1865 | + continue; |
|
| 1866 | + } |
|
| 1779 | 1867 | |
| 1780 | 1868 | $result[] = array( |
| 1781 | 1869 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1783,8 +1871,9 @@ discard block |
||
| 1783 | 1871 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1784 | 1872 | 'is_dir' => false |
| 1785 | 1873 | ); |
| 1786 | - if ($level == 1) |
|
| 1787 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1874 | + if ($level == 1) { |
|
| 1875 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1876 | + } |
|
| 1788 | 1877 | } |
| 1789 | 1878 | |
| 1790 | 1879 | return $result; |
@@ -1800,8 +1889,9 @@ discard block |
||
| 1800 | 1889 | global $txt, $context; |
| 1801 | 1890 | |
| 1802 | 1891 | loadThemeOptions($memID); |
| 1803 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1804 | - loadCustomFields($memID, 'theme'); |
|
| 1892 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1893 | + loadCustomFields($memID, 'theme'); |
|
| 1894 | + } |
|
| 1805 | 1895 | |
| 1806 | 1896 | $context['sub_template'] = 'edit_options'; |
| 1807 | 1897 | $context['page_desc'] = $txt['theme_info']; |
@@ -1855,16 +1945,19 @@ discard block |
||
| 1855 | 1945 | { |
| 1856 | 1946 | global $txt, $user_profile, $context, $modSettings, $smcFunc, $sourcedir; |
| 1857 | 1947 | |
| 1858 | - if (!isset($context['token_check'])) |
|
| 1859 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1948 | + if (!isset($context['token_check'])) { |
|
| 1949 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1950 | + } |
|
| 1860 | 1951 | |
| 1861 | 1952 | is_not_guest(); |
| 1862 | - if (!$context['user']['is_owner']) |
|
| 1863 | - isAllowedTo('profile_extra_any'); |
|
| 1953 | + if (!$context['user']['is_owner']) { |
|
| 1954 | + isAllowedTo('profile_extra_any'); |
|
| 1955 | + } |
|
| 1864 | 1956 | |
| 1865 | 1957 | // Set the post action if we're coming from the profile... |
| 1866 | - if (!isset($context['action'])) |
|
| 1867 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1958 | + if (!isset($context['action'])) { |
|
| 1959 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1960 | + } |
|
| 1868 | 1961 | |
| 1869 | 1962 | // What options are set |
| 1870 | 1963 | loadThemeOptions($memID); |
@@ -1951,28 +2044,34 @@ discard block |
||
| 1951 | 2044 | ); |
| 1952 | 2045 | |
| 1953 | 2046 | // There are certain things that are disabled at the group level. |
| 1954 | - if (empty($modSettings['cal_enabled'])) |
|
| 1955 | - unset($alert_types['calendar']); |
|
| 2047 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2048 | + unset($alert_types['calendar']); |
|
| 2049 | + } |
|
| 1956 | 2050 | |
| 1957 | 2051 | // Disable paid subscriptions at group level if they're disabled |
| 1958 | - if (empty($modSettings['paid_enabled'])) |
|
| 1959 | - unset($alert_types['paidsubs']); |
|
| 2052 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2053 | + unset($alert_types['paidsubs']); |
|
| 2054 | + } |
|
| 1960 | 2055 | |
| 1961 | 2056 | // Disable membergroup requests at group level if they're disabled |
| 1962 | - if (empty($modSettings['show_group_membership'])) |
|
| 1963 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2057 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2058 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2059 | + } |
|
| 1964 | 2060 | |
| 1965 | 2061 | // Disable mentions if they're disabled |
| 1966 | - if (empty($modSettings['enable_mentions'])) |
|
| 1967 | - unset($alert_types['msg']['msg_mention']); |
|
| 2062 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2063 | + unset($alert_types['msg']['msg_mention']); |
|
| 2064 | + } |
|
| 1968 | 2065 | |
| 1969 | 2066 | // Disable likes if they're disabled |
| 1970 | - if (empty($modSettings['enable_likes'])) |
|
| 1971 | - unset($alert_types['msg']['msg_like']); |
|
| 2067 | + if (empty($modSettings['enable_likes'])) { |
|
| 2068 | + unset($alert_types['msg']['msg_like']); |
|
| 2069 | + } |
|
| 1972 | 2070 | |
| 1973 | 2071 | // Disable buddy requests if they're disabled |
| 1974 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1975 | - unset($alert_types['members']['buddy_request']); |
|
| 2072 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2073 | + unset($alert_types['members']['buddy_request']); |
|
| 2074 | + } |
|
| 1976 | 2075 | |
| 1977 | 2076 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1978 | 2077 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2000,15 +2099,17 @@ discard block |
||
| 2000 | 2099 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 2001 | 2100 | } |
| 2002 | 2101 | |
| 2003 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2004 | - unset($alert_types['members']['request_group']); |
|
| 2102 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2103 | + unset($alert_types['members']['request_group']); |
|
| 2104 | + } |
|
| 2005 | 2105 | |
| 2006 | 2106 | foreach ($alert_types as $group => $items) |
| 2007 | 2107 | { |
| 2008 | 2108 | foreach ($items as $alert_key => $alert_value) |
| 2009 | 2109 | { |
| 2010 | - if (!isset($alert_value['permission'])) |
|
| 2011 | - continue; |
|
| 2110 | + if (!isset($alert_value['permission'])) { |
|
| 2111 | + continue; |
|
| 2112 | + } |
|
| 2012 | 2113 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2013 | 2114 | { |
| 2014 | 2115 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2016,12 +2117,14 @@ discard block |
||
| 2016 | 2117 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2017 | 2118 | } |
| 2018 | 2119 | |
| 2019 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2020 | - unset ($alert_types[$group][$alert_key]); |
|
| 2120 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2121 | + unset ($alert_types[$group][$alert_key]); |
|
| 2122 | + } |
|
| 2021 | 2123 | } |
| 2022 | 2124 | |
| 2023 | - if (empty($alert_types[$group])) |
|
| 2024 | - unset ($alert_types[$group]); |
|
| 2125 | + if (empty($alert_types[$group])) { |
|
| 2126 | + unset ($alert_types[$group]); |
|
| 2127 | + } |
|
| 2025 | 2128 | } |
| 2026 | 2129 | } |
| 2027 | 2130 | |
@@ -2053,9 +2156,9 @@ discard block |
||
| 2053 | 2156 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2054 | 2157 | break; |
| 2055 | 2158 | case 'select': |
| 2056 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2057 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2058 | - else |
|
| 2159 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2160 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2161 | + } else |
|
| 2059 | 2162 | { |
| 2060 | 2163 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2061 | 2164 | $keys = array_keys($this_option['opts']); |
@@ -2075,23 +2178,28 @@ discard block |
||
| 2075 | 2178 | $this_value = 0; |
| 2076 | 2179 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2077 | 2180 | { |
| 2078 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2079 | - $this_value |= $bitvalue; |
|
| 2181 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2182 | + $this_value |= $bitvalue; |
|
| 2183 | + } |
|
| 2184 | + } |
|
| 2185 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2186 | + $update_prefs[$item_key] = $this_value; |
|
| 2080 | 2187 | } |
| 2081 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2082 | - $update_prefs[$item_key] = $this_value; |
|
| 2083 | 2188 | } |
| 2084 | 2189 | } |
| 2085 | 2190 | |
| 2086 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2087 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2191 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2192 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2193 | + } |
|
| 2088 | 2194 | |
| 2089 | - if (!empty($_POST['notify_announcements'])) |
|
| 2090 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2195 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2196 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2197 | + } |
|
| 2091 | 2198 | |
| 2092 | 2199 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2093 | - foreach ($update_prefs as $pref => $value) |
|
| 2094 | - $context['alert_prefs'][$pref] = $value; |
|
| 2200 | + foreach ($update_prefs as $pref => $value) { |
|
| 2201 | + $context['alert_prefs'][$pref] = $value; |
|
| 2202 | + } |
|
| 2095 | 2203 | |
| 2096 | 2204 | makeNotificationChanges($memID); |
| 2097 | 2205 | |
@@ -2121,8 +2229,9 @@ discard block |
||
| 2121 | 2229 | |
| 2122 | 2230 | // Now we're all set up. |
| 2123 | 2231 | is_not_guest(); |
| 2124 | - if (!$context['user']['is_owner']) |
|
| 2125 | - fatal_error('no_access'); |
|
| 2232 | + if (!$context['user']['is_owner']) { |
|
| 2233 | + fatal_error('no_access'); |
|
| 2234 | + } |
|
| 2126 | 2235 | |
| 2127 | 2236 | checkSession('get'); |
| 2128 | 2237 | |
@@ -2154,8 +2263,9 @@ discard block |
||
| 2154 | 2263 | { |
| 2155 | 2264 | global $smcFunc; |
| 2156 | 2265 | |
| 2157 | - if (empty($toMark) || empty($memID)) |
|
| 2158 | - return false; |
|
| 2266 | + if (empty($toMark) || empty($memID)) { |
|
| 2267 | + return false; |
|
| 2268 | + } |
|
| 2159 | 2269 | |
| 2160 | 2270 | $toMark = (array) $toMark; |
| 2161 | 2271 | $count = 0; |
@@ -2190,8 +2300,9 @@ discard block |
||
| 2190 | 2300 | { |
| 2191 | 2301 | global $smcFunc; |
| 2192 | 2302 | |
| 2193 | - if (empty($toDelete)) |
|
| 2194 | - return false; |
|
| 2303 | + if (empty($toDelete)) { |
|
| 2304 | + return false; |
|
| 2305 | + } |
|
| 2195 | 2306 | |
| 2196 | 2307 | $toDelete = (array) $toDelete; |
| 2197 | 2308 | |
@@ -2226,8 +2337,9 @@ discard block |
||
| 2226 | 2337 | { |
| 2227 | 2338 | global $smcFunc; |
| 2228 | 2339 | |
| 2229 | - if (empty($memID)) |
|
| 2230 | - return false; |
|
| 2340 | + if (empty($memID)) { |
|
| 2341 | + return false; |
|
| 2342 | + } |
|
| 2231 | 2343 | |
| 2232 | 2344 | $count = 0; |
| 2233 | 2345 | |
@@ -2306,8 +2418,9 @@ discard block |
||
| 2306 | 2418 | { |
| 2307 | 2419 | $link = $topic['link']; |
| 2308 | 2420 | |
| 2309 | - if ($topic['new']) |
|
| 2310 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2421 | + if ($topic['new']) { |
|
| 2422 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2423 | + } |
|
| 2311 | 2424 | |
| 2312 | 2425 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2313 | 2426 | |
@@ -2458,8 +2571,9 @@ discard block |
||
| 2458 | 2571 | { |
| 2459 | 2572 | $link = $board['link']; |
| 2460 | 2573 | |
| 2461 | - if ($board['new']) |
|
| 2462 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2574 | + if ($board['new']) { |
|
| 2575 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2576 | + } |
|
| 2463 | 2577 | |
| 2464 | 2578 | return $link; |
| 2465 | 2579 | }, |
@@ -2659,8 +2773,8 @@ discard block |
||
| 2659 | 2773 | ) |
| 2660 | 2774 | ); |
| 2661 | 2775 | $notification_boards = array(); |
| 2662 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2663 | - $notification_boards[] = array( |
|
| 2776 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2777 | + $notification_boards[] = array( |
|
| 2664 | 2778 | 'id' => $row['id_board'], |
| 2665 | 2779 | 'name' => $row['name'], |
| 2666 | 2780 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2668,6 +2782,7 @@ discard block |
||
| 2668 | 2782 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2669 | 2783 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2670 | 2784 | ); |
| 2785 | + } |
|
| 2671 | 2786 | $smcFunc['db_free_result']($request); |
| 2672 | 2787 | |
| 2673 | 2788 | return $notification_boards; |
@@ -2682,17 +2797,18 @@ discard block |
||
| 2682 | 2797 | { |
| 2683 | 2798 | global $context, $options, $cur_profile, $smcFunc; |
| 2684 | 2799 | |
| 2685 | - if (isset($_POST['default_options'])) |
|
| 2686 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2800 | + if (isset($_POST['default_options'])) { |
|
| 2801 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2802 | + } |
|
| 2687 | 2803 | |
| 2688 | 2804 | if ($context['user']['is_owner']) |
| 2689 | 2805 | { |
| 2690 | 2806 | $context['member']['options'] = $options; |
| 2691 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2692 | - foreach ($_POST['options'] as $k => $v) |
|
| 2807 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2808 | + foreach ($_POST['options'] as $k => $v) |
|
| 2693 | 2809 | $context['member']['options'][$k] = $v; |
| 2694 | - } |
|
| 2695 | - else |
|
| 2810 | + } |
|
| 2811 | + } else |
|
| 2696 | 2812 | { |
| 2697 | 2813 | $request = $smcFunc['db_query']('', ' |
| 2698 | 2814 | SELECT id_member, variable, value |
@@ -2713,8 +2829,9 @@ discard block |
||
| 2713 | 2829 | continue; |
| 2714 | 2830 | } |
| 2715 | 2831 | |
| 2716 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2717 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2832 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2833 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2834 | + } |
|
| 2718 | 2835 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2719 | 2836 | } |
| 2720 | 2837 | $smcFunc['db_free_result']($request); |
@@ -2722,8 +2839,9 @@ discard block |
||
| 2722 | 2839 | // Load up the default theme options for any missing. |
| 2723 | 2840 | foreach ($temp as $k => $v) |
| 2724 | 2841 | { |
| 2725 | - if (!isset($context['member']['options'][$k])) |
|
| 2726 | - $context['member']['options'][$k] = $v; |
|
| 2842 | + if (!isset($context['member']['options'][$k])) { |
|
| 2843 | + $context['member']['options'][$k] = $v; |
|
| 2844 | + } |
|
| 2727 | 2845 | } |
| 2728 | 2846 | } |
| 2729 | 2847 | } |
@@ -2738,8 +2856,9 @@ discard block |
||
| 2738 | 2856 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2739 | 2857 | |
| 2740 | 2858 | // Have the admins enabled this option? |
| 2741 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2742 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2859 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2860 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2861 | + } |
|
| 2743 | 2862 | |
| 2744 | 2863 | // Find all the boards this user is allowed to see. |
| 2745 | 2864 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2759,12 +2878,13 @@ discard block |
||
| 2759 | 2878 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2760 | 2879 | { |
| 2761 | 2880 | // This category hasn't been set up yet.. |
| 2762 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2763 | - $context['categories'][$row['id_cat']] = array( |
|
| 2881 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2882 | + $context['categories'][$row['id_cat']] = array( |
|
| 2764 | 2883 | 'id' => $row['id_cat'], |
| 2765 | 2884 | 'name' => $row['cat_name'], |
| 2766 | 2885 | 'boards' => array() |
| 2767 | 2886 | ); |
| 2887 | + } |
|
| 2768 | 2888 | |
| 2769 | 2889 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2770 | 2890 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2794,18 +2914,20 @@ discard block |
||
| 2794 | 2914 | } |
| 2795 | 2915 | |
| 2796 | 2916 | $max_boards = ceil(count($temp_boards) / 2); |
| 2797 | - if ($max_boards == 1) |
|
| 2798 | - $max_boards = 2; |
|
| 2917 | + if ($max_boards == 1) { |
|
| 2918 | + $max_boards = 2; |
|
| 2919 | + } |
|
| 2799 | 2920 | |
| 2800 | 2921 | // Now, alternate them so they can be shown left and right ;). |
| 2801 | 2922 | $context['board_columns'] = array(); |
| 2802 | 2923 | for ($i = 0; $i < $max_boards; $i++) |
| 2803 | 2924 | { |
| 2804 | 2925 | $context['board_columns'][] = $temp_boards[$i]; |
| 2805 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2806 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2807 | - else |
|
| 2808 | - $context['board_columns'][] = array(); |
|
| 2926 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2927 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2928 | + } else { |
|
| 2929 | + $context['board_columns'][] = array(); |
|
| 2930 | + } |
|
| 2809 | 2931 | } |
| 2810 | 2932 | |
| 2811 | 2933 | loadThemeOptions($memID); |
@@ -2874,8 +2996,9 @@ discard block |
||
| 2874 | 2996 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2875 | 2997 | { |
| 2876 | 2998 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2877 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2878 | - continue; |
|
| 2999 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 3000 | + continue; |
|
| 3001 | + } |
|
| 2879 | 3002 | |
| 2880 | 3003 | $context['member_groups'][$row['id_group']] = array( |
| 2881 | 3004 | 'id' => $row['id_group'], |
@@ -2921,16 +3044,17 @@ discard block |
||
| 2921 | 3044 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2922 | 3045 | // Warning message for signature image limits? |
| 2923 | 3046 | $context['signature_warning'] = ''; |
| 2924 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2925 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2926 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2927 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3047 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3048 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3049 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3050 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3051 | + } |
|
| 2928 | 3052 | |
| 2929 | 3053 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2930 | 3054 | |
| 2931 | - if (empty($context['do_preview'])) |
|
| 2932 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2933 | - else |
|
| 3055 | + if (empty($context['do_preview'])) { |
|
| 3056 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3057 | + } else |
|
| 2934 | 3058 | { |
| 2935 | 3059 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2936 | 3060 | $validation = profileValidateSignature($signature); |
@@ -2940,8 +3064,9 @@ discard block |
||
| 2940 | 3064 | $context['post_errors'] = array(); |
| 2941 | 3065 | } |
| 2942 | 3066 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2943 | - if ($validation !== true && $validation !== false) |
|
| 2944 | - $context['post_errors'][] = $validation; |
|
| 3067 | + if ($validation !== true && $validation !== false) { |
|
| 3068 | + $context['post_errors'][] = $validation; |
|
| 3069 | + } |
|
| 2945 | 3070 | |
| 2946 | 3071 | censorText($context['member']['signature']); |
| 2947 | 3072 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2951,8 +3076,9 @@ discard block |
||
| 2951 | 3076 | } |
| 2952 | 3077 | |
| 2953 | 3078 | // Load the spell checker? |
| 2954 | - if ($context['show_spellchecking']) |
|
| 2955 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3079 | + if ($context['show_spellchecking']) { |
|
| 3080 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3081 | + } |
|
| 2956 | 3082 | |
| 2957 | 3083 | return true; |
| 2958 | 3084 | } |
@@ -2986,8 +3112,7 @@ discard block |
||
| 2986 | 3112 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 2987 | 3113 | ); |
| 2988 | 3114 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 2989 | - } |
|
| 2990 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3115 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 2991 | 3116 | { |
| 2992 | 3117 | $context['member']['avatar'] += array( |
| 2993 | 3118 | 'choice' => 'upload', |
@@ -2995,34 +3120,34 @@ discard block |
||
| 2995 | 3120 | 'external' => 'http://' |
| 2996 | 3121 | ); |
| 2997 | 3122 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
| 2998 | - } |
|
| 2999 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 3000 | - $context['member']['avatar'] += array( |
|
| 3123 | + } elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3124 | + $context['member']['avatar'] += array( |
|
| 3001 | 3125 | 'choice' => 'external', |
| 3002 | 3126 | 'server_pic' => 'blank.png', |
| 3003 | 3127 | 'external' => $cur_profile['avatar'] |
| 3004 | 3128 | ); |
| 3005 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3006 | - $context['member']['avatar'] += array( |
|
| 3129 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3130 | + $context['member']['avatar'] += array( |
|
| 3007 | 3131 | 'choice' => 'server_stored', |
| 3008 | 3132 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3009 | 3133 | 'external' => 'http://' |
| 3010 | 3134 | ); |
| 3011 | - else |
|
| 3012 | - $context['member']['avatar'] += array( |
|
| 3135 | + } else { |
|
| 3136 | + $context['member']['avatar'] += array( |
|
| 3013 | 3137 | 'choice' => 'none', |
| 3014 | 3138 | 'server_pic' => 'blank.png', |
| 3015 | 3139 | 'external' => 'http://' |
| 3016 | 3140 | ); |
| 3141 | + } |
|
| 3017 | 3142 | |
| 3018 | 3143 | // Get a list of all the avatars. |
| 3019 | 3144 | if ($context['member']['avatar']['allow_server_stored']) |
| 3020 | 3145 | { |
| 3021 | 3146 | $context['avatar_list'] = array(); |
| 3022 | 3147 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3148 | + } else { |
|
| 3149 | + $context['avatars'] = array(); |
|
| 3023 | 3150 | } |
| 3024 | - else |
|
| 3025 | - $context['avatars'] = array(); |
|
| 3026 | 3151 | |
| 3027 | 3152 | // Second level selected avatar... |
| 3028 | 3153 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3051,19 +3176,22 @@ discard block |
||
| 3051 | 3176 | ) |
| 3052 | 3177 | ); |
| 3053 | 3178 | $protected_groups = array(1); |
| 3054 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3055 | - $protected_groups[] = $row['id_group']; |
|
| 3179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3180 | + $protected_groups[] = $row['id_group']; |
|
| 3181 | + } |
|
| 3056 | 3182 | $smcFunc['db_free_result']($request); |
| 3057 | 3183 | |
| 3058 | 3184 | $protected_groups = array_unique($protected_groups); |
| 3059 | 3185 | } |
| 3060 | 3186 | |
| 3061 | 3187 | // The account page allows the change of your id_group - but not to a protected group! |
| 3062 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3063 | - $value = (int) $value; |
|
| 3188 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3189 | + $value = (int) $value; |
|
| 3190 | + } |
|
| 3064 | 3191 | // ... otherwise it's the old group sir. |
| 3065 | - else |
|
| 3066 | - $value = $old_profile['id_group']; |
|
| 3192 | + else { |
|
| 3193 | + $value = $old_profile['id_group']; |
|
| 3194 | + } |
|
| 3067 | 3195 | |
| 3068 | 3196 | // Find the additional membergroups (if any) |
| 3069 | 3197 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3072,16 +3200,18 @@ discard block |
||
| 3072 | 3200 | foreach ($_POST['additional_groups'] as $group_id) |
| 3073 | 3201 | { |
| 3074 | 3202 | $group_id = (int) $group_id; |
| 3075 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3076 | - $additional_groups[] = $group_id; |
|
| 3203 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3204 | + $additional_groups[] = $group_id; |
|
| 3205 | + } |
|
| 3077 | 3206 | } |
| 3078 | 3207 | |
| 3079 | 3208 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3080 | 3209 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3081 | 3210 | foreach ($old_additional_groups as $group_id) |
| 3082 | 3211 | { |
| 3083 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3084 | - $additional_groups[] = $group_id; |
|
| 3212 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3213 | + $additional_groups[] = $group_id; |
|
| 3214 | + } |
|
| 3085 | 3215 | } |
| 3086 | 3216 | |
| 3087 | 3217 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3113,18 +3243,20 @@ discard block |
||
| 3113 | 3243 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3114 | 3244 | $smcFunc['db_free_result']($request); |
| 3115 | 3245 | |
| 3116 | - if (empty($another)) |
|
| 3117 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3246 | + if (empty($another)) { |
|
| 3247 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3248 | + } |
|
| 3118 | 3249 | } |
| 3119 | 3250 | } |
| 3120 | 3251 | |
| 3121 | 3252 | // If we are changing group status, update permission cache as necessary. |
| 3122 | 3253 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3123 | 3254 | { |
| 3124 | - if ($context['user']['is_owner']) |
|
| 3125 | - $_SESSION['mc']['time'] = 0; |
|
| 3126 | - else |
|
| 3127 | - updateSettings(array('settings_updated' => time())); |
|
| 3255 | + if ($context['user']['is_owner']) { |
|
| 3256 | + $_SESSION['mc']['time'] = 0; |
|
| 3257 | + } else { |
|
| 3258 | + updateSettings(array('settings_updated' => time())); |
|
| 3259 | + } |
|
| 3128 | 3260 | } |
| 3129 | 3261 | |
| 3130 | 3262 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3145,8 +3277,9 @@ discard block |
||
| 3145 | 3277 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3146 | 3278 | |
| 3147 | 3279 | $memID = $context['id_member']; |
| 3148 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3149 | - return false; |
|
| 3280 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3281 | + return false; |
|
| 3282 | + } |
|
| 3150 | 3283 | |
| 3151 | 3284 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3152 | 3285 | |
@@ -3157,8 +3290,9 @@ discard block |
||
| 3157 | 3290 | $downloadedExternalAvatar = false; |
| 3158 | 3291 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
| 3159 | 3292 | { |
| 3160 | - if (!is_writable($uploadDir)) |
|
| 3161 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3293 | + if (!is_writable($uploadDir)) { |
|
| 3294 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3295 | + } |
|
| 3162 | 3296 | |
| 3163 | 3297 | require_once($sourcedir . '/Subs-Package.php'); |
| 3164 | 3298 | |
@@ -3202,19 +3336,18 @@ discard block |
||
| 3202 | 3336 | |
| 3203 | 3337 | // Get rid of their old avatar. (if uploaded.) |
| 3204 | 3338 | removeAttachments(array('id_member' => $memID)); |
| 3205 | - } |
|
| 3206 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3339 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3207 | 3340 | { |
| 3208 | 3341 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
| 3209 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3210 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3211 | - else |
|
| 3212 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3342 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3343 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3344 | + } else { |
|
| 3345 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3346 | + } |
|
| 3213 | 3347 | |
| 3214 | 3348 | // Get rid of their old avatar. (if uploaded.) |
| 3215 | 3349 | removeAttachments(array('id_member' => $memID)); |
| 3216 | - } |
|
| 3217 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3350 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3218 | 3351 | { |
| 3219 | 3352 | // We need these clean... |
| 3220 | 3353 | $cur_profile['id_attach'] = 0; |
@@ -3226,11 +3359,13 @@ discard block |
||
| 3226 | 3359 | |
| 3227 | 3360 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3228 | 3361 | |
| 3229 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3230 | - $profile_vars['avatar'] = ''; |
|
| 3362 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3363 | + $profile_vars['avatar'] = ''; |
|
| 3364 | + } |
|
| 3231 | 3365 | // Trying to make us do something we'll regret? |
| 3232 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3233 | - return 'bad_avatar_invalid_url'; |
|
| 3366 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3367 | + return 'bad_avatar_invalid_url'; |
|
| 3368 | + } |
|
| 3234 | 3369 | // Should we check dimensions? |
| 3235 | 3370 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3236 | 3371 | { |
@@ -3240,9 +3375,9 @@ discard block |
||
| 3240 | 3375 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
| 3241 | 3376 | { |
| 3242 | 3377 | // Houston, we have a problem. The avatar is too large!! |
| 3243 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3244 | - return 'bad_avatar_too_large'; |
|
| 3245 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3378 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3379 | + return 'bad_avatar_too_large'; |
|
| 3380 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3246 | 3381 | { |
| 3247 | 3382 | // @todo remove this if appropriate |
| 3248 | 3383 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3252,26 +3387,27 @@ discard block |
||
| 3252 | 3387 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3253 | 3388 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3254 | 3389 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3390 | + } else { |
|
| 3391 | + return 'bad_avatar'; |
|
| 3255 | 3392 | } |
| 3256 | - else |
|
| 3257 | - return 'bad_avatar'; |
|
| 3258 | 3393 | } |
| 3259 | 3394 | } |
| 3260 | 3395 | } |
| 3261 | - } |
|
| 3262 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3396 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3263 | 3397 | { |
| 3264 | 3398 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3265 | 3399 | { |
| 3266 | 3400 | // Get the dimensions of the image. |
| 3267 | 3401 | if (!$downloadedExternalAvatar) |
| 3268 | 3402 | { |
| 3269 | - if (!is_writable($uploadDir)) |
|
| 3270 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3403 | + if (!is_writable($uploadDir)) { |
|
| 3404 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3405 | + } |
|
| 3271 | 3406 | |
| 3272 | 3407 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3273 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3274 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3408 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3409 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3410 | + } |
|
| 3275 | 3411 | |
| 3276 | 3412 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3277 | 3413 | } |
@@ -3384,17 +3520,19 @@ discard block |
||
| 3384 | 3520 | $profile_vars['avatar'] = ''; |
| 3385 | 3521 | |
| 3386 | 3522 | // Delete any temporary file. |
| 3387 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3388 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3523 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3524 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3525 | + } |
|
| 3389 | 3526 | } |
| 3390 | 3527 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3391 | - else |
|
| 3528 | + else { |
|
| 3529 | + $profile_vars['avatar'] = ''; |
|
| 3530 | + } |
|
| 3531 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3532 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3533 | + } else { |
|
| 3392 | 3534 | $profile_vars['avatar'] = ''; |
| 3393 | 3535 | } |
| 3394 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3395 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3396 | - else |
|
| 3397 | - $profile_vars['avatar'] = ''; |
|
| 3398 | 3536 | |
| 3399 | 3537 | // Setup the profile variables so it shows things right on display! |
| 3400 | 3538 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3442,9 +3580,9 @@ discard block |
||
| 3442 | 3580 | $smiley_parsed = $unparsed_signature; |
| 3443 | 3581 | parsesmileys($smiley_parsed); |
| 3444 | 3582 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3445 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3446 | - return 'signature_allow_smileys'; |
|
| 3447 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3583 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3584 | + return 'signature_allow_smileys'; |
|
| 3585 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3448 | 3586 | { |
| 3449 | 3587 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3450 | 3588 | return 'signature_max_smileys'; |
@@ -3457,14 +3595,15 @@ discard block |
||
| 3457 | 3595 | { |
| 3458 | 3596 | $limit_broke = 0; |
| 3459 | 3597 | // Attempt to allow all sizes of abuse, so to speak. |
| 3460 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3461 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3462 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3463 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3464 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3465 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3466 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3467 | - $limit_broke = 'large'; |
|
| 3598 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3599 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3600 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3601 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3602 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3603 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3604 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3605 | + $limit_broke = 'large'; |
|
| 3606 | + } |
|
| 3468 | 3607 | |
| 3469 | 3608 | if ($limit_broke) |
| 3470 | 3609 | { |
@@ -3506,24 +3645,26 @@ discard block |
||
| 3506 | 3645 | $width = -1; $height = -1; |
| 3507 | 3646 | |
| 3508 | 3647 | // Does it have predefined restraints? Width first. |
| 3509 | - if ($matches[6][$key]) |
|
| 3510 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3648 | + if ($matches[6][$key]) { |
|
| 3649 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3650 | + } |
|
| 3511 | 3651 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3512 | 3652 | { |
| 3513 | 3653 | $width = $sig_limits[5]; |
| 3514 | 3654 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3655 | + } elseif ($matches[2][$key]) { |
|
| 3656 | + $width = $matches[2][$key]; |
|
| 3515 | 3657 | } |
| 3516 | - elseif ($matches[2][$key]) |
|
| 3517 | - $width = $matches[2][$key]; |
|
| 3518 | 3658 | // ... and height. |
| 3519 | 3659 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3520 | 3660 | { |
| 3521 | 3661 | $height = $sig_limits[6]; |
| 3522 | - if ($width != -1) |
|
| 3523 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3662 | + if ($width != -1) { |
|
| 3663 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3664 | + } |
|
| 3665 | + } elseif ($matches[4][$key]) { |
|
| 3666 | + $height = $matches[4][$key]; |
|
| 3524 | 3667 | } |
| 3525 | - elseif ($matches[4][$key]) |
|
| 3526 | - $height = $matches[4][$key]; |
|
| 3527 | 3668 | |
| 3528 | 3669 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3529 | 3670 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3541,21 +3682,24 @@ discard block |
||
| 3541 | 3682 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3542 | 3683 | { |
| 3543 | 3684 | $height = $sig_limits[6]; |
| 3544 | - if ($width == -1) |
|
| 3545 | - $width = $sizes[0]; |
|
| 3685 | + if ($width == -1) { |
|
| 3686 | + $width = $sizes[0]; |
|
| 3687 | + } |
|
| 3546 | 3688 | $width = $width * ($height / $sizes[1]); |
| 3689 | + } elseif ($width != -1) { |
|
| 3690 | + $height = $sizes[1]; |
|
| 3547 | 3691 | } |
| 3548 | - elseif ($width != -1) |
|
| 3549 | - $height = $sizes[1]; |
|
| 3550 | 3692 | } |
| 3551 | 3693 | } |
| 3552 | 3694 | |
| 3553 | 3695 | // Did we come up with some changes? If so remake the string. |
| 3554 | - if ($width != -1 || $height != -1) |
|
| 3555 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3696 | + if ($width != -1 || $height != -1) { |
|
| 3697 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3698 | + } |
|
| 3699 | + } |
|
| 3700 | + if (!empty($replaces)) { |
|
| 3701 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3556 | 3702 | } |
| 3557 | - if (!empty($replaces)) |
|
| 3558 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3559 | 3703 | } |
| 3560 | 3704 | } |
| 3561 | 3705 | |
@@ -3599,10 +3743,12 @@ discard block |
||
| 3599 | 3743 | $email = strtr($email, array(''' => '\'')); |
| 3600 | 3744 | |
| 3601 | 3745 | // Check the name and email for validity. |
| 3602 | - if (trim($email) == '') |
|
| 3603 | - return 'no_email'; |
|
| 3604 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3605 | - return 'bad_email'; |
|
| 3746 | + if (trim($email) == '') { |
|
| 3747 | + return 'no_email'; |
|
| 3748 | + } |
|
| 3749 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3750 | + return 'bad_email'; |
|
| 3751 | + } |
|
| 3606 | 3752 | |
| 3607 | 3753 | // Email addresses should be and stay unique. |
| 3608 | 3754 | $request = $smcFunc['db_query']('', ' |
@@ -3617,8 +3763,9 @@ discard block |
||
| 3617 | 3763 | ) |
| 3618 | 3764 | ); |
| 3619 | 3765 | |
| 3620 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3621 | - return 'email_taken'; |
|
| 3766 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3767 | + return 'email_taken'; |
|
| 3768 | + } |
|
| 3622 | 3769 | $smcFunc['db_free_result']($request); |
| 3623 | 3770 | |
| 3624 | 3771 | return true; |
@@ -3631,8 +3778,9 @@ discard block |
||
| 3631 | 3778 | { |
| 3632 | 3779 | global $modSettings, $context, $cur_profile; |
| 3633 | 3780 | |
| 3634 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3635 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3781 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3782 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3783 | + } |
|
| 3636 | 3784 | |
| 3637 | 3785 | loadUserSettings(); |
| 3638 | 3786 | writeLog(); |
@@ -3648,8 +3796,9 @@ discard block |
||
| 3648 | 3796 | require_once($sourcedir . '/Subs-Post.php'); |
| 3649 | 3797 | |
| 3650 | 3798 | // Shouldn't happen but just in case. |
| 3651 | - if (empty($profile_vars['email_address'])) |
|
| 3652 | - return; |
|
| 3799 | + if (empty($profile_vars['email_address'])) { |
|
| 3800 | + return; |
|
| 3801 | + } |
|
| 3653 | 3802 | |
| 3654 | 3803 | $replacements = array( |
| 3655 | 3804 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3672,8 +3821,9 @@ discard block |
||
| 3672 | 3821 | $_SESSION['log_time'] = 0; |
| 3673 | 3822 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
| 3674 | 3823 | |
| 3675 | - if (isset($_COOKIE[$cookiename])) |
|
| 3676 | - $_COOKIE[$cookiename] = ''; |
|
| 3824 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3825 | + $_COOKIE[$cookiename] = ''; |
|
| 3826 | + } |
|
| 3677 | 3827 | |
| 3678 | 3828 | loadUserSettings(); |
| 3679 | 3829 | |
@@ -3706,11 +3856,13 @@ discard block |
||
| 3706 | 3856 | $groups[] = $curMember['id_group']; |
| 3707 | 3857 | |
| 3708 | 3858 | // Ensure the query doesn't croak! |
| 3709 | - if (empty($groups)) |
|
| 3710 | - $groups = array(0); |
|
| 3859 | + if (empty($groups)) { |
|
| 3860 | + $groups = array(0); |
|
| 3861 | + } |
|
| 3711 | 3862 | // Just to be sure... |
| 3712 | - foreach ($groups as $k => $v) |
|
| 3713 | - $groups[$k] = (int) $v; |
|
| 3863 | + foreach ($groups as $k => $v) { |
|
| 3864 | + $groups[$k] = (int) $v; |
|
| 3865 | + } |
|
| 3714 | 3866 | |
| 3715 | 3867 | // Get all the membergroups they can join. |
| 3716 | 3868 | $request = $smcFunc['db_query']('', ' |
@@ -3740,12 +3892,14 @@ discard block |
||
| 3740 | 3892 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3741 | 3893 | { |
| 3742 | 3894 | // Can they edit their primary group? |
| 3743 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3744 | - $context['can_edit_primary'] = true; |
|
| 3895 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3896 | + $context['can_edit_primary'] = true; |
|
| 3897 | + } |
|
| 3745 | 3898 | |
| 3746 | 3899 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3747 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3748 | - continue; |
|
| 3900 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3901 | + continue; |
|
| 3902 | + } |
|
| 3749 | 3903 | |
| 3750 | 3904 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3751 | 3905 | 'id' => $row['id_group'], |
@@ -3774,13 +3928,15 @@ discard block |
||
| 3774 | 3928 | ); |
| 3775 | 3929 | |
| 3776 | 3930 | // No changing primary one unless you have enough groups! |
| 3777 | - if (count($context['groups']['member']) < 2) |
|
| 3778 | - $context['can_edit_primary'] = false; |
|
| 3931 | + if (count($context['groups']['member']) < 2) { |
|
| 3932 | + $context['can_edit_primary'] = false; |
|
| 3933 | + } |
|
| 3779 | 3934 | |
| 3780 | 3935 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3781 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3782 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3783 | -} |
|
| 3936 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3937 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3938 | + } |
|
| 3939 | + } |
|
| 3784 | 3940 | |
| 3785 | 3941 | /** |
| 3786 | 3942 | * This function actually makes all the group changes |
@@ -3795,10 +3951,12 @@ discard block |
||
| 3795 | 3951 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3796 | 3952 | |
| 3797 | 3953 | // Let's be extra cautious... |
| 3798 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3799 | - isAllowedTo('manage_membergroups'); |
|
| 3800 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3801 | - fatal_lang_error('no_access', false); |
|
| 3954 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3955 | + isAllowedTo('manage_membergroups'); |
|
| 3956 | + } |
|
| 3957 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3958 | + fatal_lang_error('no_access', false); |
|
| 3959 | + } |
|
| 3802 | 3960 | |
| 3803 | 3961 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3804 | 3962 | |
@@ -3817,8 +3975,9 @@ discard block |
||
| 3817 | 3975 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3818 | 3976 | |
| 3819 | 3977 | // Sanity check!! |
| 3820 | - if ($group_id == 1) |
|
| 3821 | - isAllowedTo('admin_forum'); |
|
| 3978 | + if ($group_id == 1) { |
|
| 3979 | + isAllowedTo('admin_forum'); |
|
| 3980 | + } |
|
| 3822 | 3981 | // Protected groups too! |
| 3823 | 3982 | else |
| 3824 | 3983 | { |
@@ -3835,8 +3994,9 @@ discard block |
||
| 3835 | 3994 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3836 | 3995 | $smcFunc['db_free_result']($request); |
| 3837 | 3996 | |
| 3838 | - if ($is_protected == 1) |
|
| 3839 | - isAllowedTo('admin_forum'); |
|
| 3997 | + if ($is_protected == 1) { |
|
| 3998 | + isAllowedTo('admin_forum'); |
|
| 3999 | + } |
|
| 3840 | 4000 | } |
| 3841 | 4001 | |
| 3842 | 4002 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3858,36 +4018,43 @@ discard block |
||
| 3858 | 4018 | $group_name = $row['group_name']; |
| 3859 | 4019 | |
| 3860 | 4020 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3861 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3862 | - fatal_lang_error('no_access', false); |
|
| 4021 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4022 | + fatal_lang_error('no_access', false); |
|
| 4023 | + } |
|
| 3863 | 4024 | // What about leaving a requestable group we are not a member of? |
| 3864 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3865 | - fatal_lang_error('no_access', false); |
|
| 3866 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3867 | - fatal_lang_error('no_access', false); |
|
| 4025 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4026 | + fatal_lang_error('no_access', false); |
|
| 4027 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4028 | + fatal_lang_error('no_access', false); |
|
| 4029 | + } |
|
| 3868 | 4030 | |
| 3869 | 4031 | // We can't change the primary group if this is hidden! |
| 3870 | - if ($row['hidden'] == 2) |
|
| 3871 | - $canChangePrimary = false; |
|
| 4032 | + if ($row['hidden'] == 2) { |
|
| 4033 | + $canChangePrimary = false; |
|
| 4034 | + } |
|
| 3872 | 4035 | } |
| 3873 | 4036 | |
| 3874 | 4037 | // If this is their old primary, can we change it? |
| 3875 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3876 | - $canChangePrimary = 1; |
|
| 4038 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4039 | + $canChangePrimary = 1; |
|
| 4040 | + } |
|
| 3877 | 4041 | |
| 3878 | 4042 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3879 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3880 | - $canChangePrimary = false; |
|
| 4043 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4044 | + $canChangePrimary = false; |
|
| 4045 | + } |
|
| 3881 | 4046 | |
| 3882 | 4047 | // If this is the one we are acting on, can we even act? |
| 3883 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3884 | - $canChangePrimary = false; |
|
| 4048 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4049 | + $canChangePrimary = false; |
|
| 4050 | + } |
|
| 3885 | 4051 | } |
| 3886 | 4052 | $smcFunc['db_free_result']($request); |
| 3887 | 4053 | |
| 3888 | 4054 | // Didn't find the target? |
| 3889 | - if (!$foundTarget) |
|
| 3890 | - fatal_lang_error('no_access', false); |
|
| 4055 | + if (!$foundTarget) { |
|
| 4056 | + fatal_lang_error('no_access', false); |
|
| 4057 | + } |
|
| 3891 | 4058 | |
| 3892 | 4059 | // Final security check, don't allow users to promote themselves to admin. |
| 3893 | 4060 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3907,8 +4074,9 @@ discard block |
||
| 3907 | 4074 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3908 | 4075 | $smcFunc['db_free_result']($request); |
| 3909 | 4076 | |
| 3910 | - if ($disallow) |
|
| 3911 | - isAllowedTo('admin_forum'); |
|
| 4077 | + if ($disallow) { |
|
| 4078 | + isAllowedTo('admin_forum'); |
|
| 4079 | + } |
|
| 3912 | 4080 | } |
| 3913 | 4081 | |
| 3914 | 4082 | // If we're requesting, add the note then return. |
@@ -3926,8 +4094,9 @@ discard block |
||
| 3926 | 4094 | 'status_open' => 0, |
| 3927 | 4095 | ) |
| 3928 | 4096 | ); |
| 3929 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3930 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4097 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4098 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4099 | + } |
|
| 3931 | 4100 | $smcFunc['db_free_result']($request); |
| 3932 | 4101 | |
| 3933 | 4102 | // Log the request. |
@@ -3961,10 +4130,11 @@ discard block |
||
| 3961 | 4130 | // Are we leaving? |
| 3962 | 4131 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3963 | 4132 | { |
| 3964 | - if ($old_profile['id_group'] == $group_id) |
|
| 3965 | - $newPrimary = 0; |
|
| 3966 | - else |
|
| 3967 | - unset($addGroups[$group_id]); |
|
| 4133 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4134 | + $newPrimary = 0; |
|
| 4135 | + } else { |
|
| 4136 | + unset($addGroups[$group_id]); |
|
| 4137 | + } |
|
| 3968 | 4138 | } |
| 3969 | 4139 | // ... if not, must be joining. |
| 3970 | 4140 | else |
@@ -3972,36 +4142,42 @@ discard block |
||
| 3972 | 4142 | // Can we change the primary, and do we want to? |
| 3973 | 4143 | if ($canChangePrimary) |
| 3974 | 4144 | { |
| 3975 | - if ($old_profile['id_group'] != 0) |
|
| 3976 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4145 | + if ($old_profile['id_group'] != 0) { |
|
| 4146 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4147 | + } |
|
| 3977 | 4148 | $newPrimary = $group_id; |
| 3978 | 4149 | } |
| 3979 | 4150 | // Otherwise it's an additional group... |
| 3980 | - else |
|
| 3981 | - $addGroups[$group_id] = -1; |
|
| 4151 | + else { |
|
| 4152 | + $addGroups[$group_id] = -1; |
|
| 4153 | + } |
|
| 3982 | 4154 | } |
| 3983 | 4155 | } |
| 3984 | 4156 | // Finally, we must be setting the primary. |
| 3985 | 4157 | elseif ($canChangePrimary) |
| 3986 | 4158 | { |
| 3987 | - if ($old_profile['id_group'] != 0) |
|
| 3988 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 3989 | - if (isset($addGroups[$group_id])) |
|
| 3990 | - unset($addGroups[$group_id]); |
|
| 4159 | + if ($old_profile['id_group'] != 0) { |
|
| 4160 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4161 | + } |
|
| 4162 | + if (isset($addGroups[$group_id])) { |
|
| 4163 | + unset($addGroups[$group_id]); |
|
| 4164 | + } |
|
| 3991 | 4165 | $newPrimary = $group_id; |
| 3992 | 4166 | } |
| 3993 | 4167 | |
| 3994 | 4168 | // Finally, we can make the changes! |
| 3995 | - foreach ($addGroups as $id => $dummy) |
|
| 3996 | - if (empty($id)) |
|
| 4169 | + foreach ($addGroups as $id => $dummy) { |
|
| 4170 | + if (empty($id)) |
|
| 3997 | 4171 | unset($addGroups[$id]); |
| 4172 | + } |
|
| 3998 | 4173 | $addGroups = implode(',', array_flip($addGroups)); |
| 3999 | 4174 | |
| 4000 | 4175 | // Ensure that we don't cache permissions if the group is changing. |
| 4001 | - if ($context['user']['is_owner']) |
|
| 4002 | - $_SESSION['mc']['time'] = 0; |
|
| 4003 | - else |
|
| 4004 | - updateSettings(array('settings_updated' => time())); |
|
| 4176 | + if ($context['user']['is_owner']) { |
|
| 4177 | + $_SESSION['mc']['time'] = 0; |
|
| 4178 | + } else { |
|
| 4179 | + updateSettings(array('settings_updated' => time())); |
|
| 4180 | + } |
|
| 4005 | 4181 | |
| 4006 | 4182 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4007 | 4183 | |
@@ -4024,8 +4200,9 @@ discard block |
||
| 4024 | 4200 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4025 | 4201 | { |
| 4026 | 4202 | // Check to ensure we're forcing SSL for authentication |
| 4027 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4028 | - fatal_lang_error('login_ssl_required'); |
|
| 4203 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4204 | + fatal_lang_error('login_ssl_required'); |
|
| 4205 | + } |
|
| 4029 | 4206 | |
| 4030 | 4207 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4031 | 4208 | // we do not want too much AJAX to confuse them. |
@@ -4062,8 +4239,7 @@ discard block |
||
| 4062 | 4239 | $context['sub_template'] = 'tfasetup_backup'; |
| 4063 | 4240 | |
| 4064 | 4241 | return; |
| 4065 | - } |
|
| 4066 | - else |
|
| 4242 | + } else |
|
| 4067 | 4243 | { |
| 4068 | 4244 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4069 | 4245 | $context['tfa_error'] = !$valid_code; |
@@ -4071,8 +4247,7 @@ discard block |
||
| 4071 | 4247 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4072 | 4248 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4073 | 4249 | } |
| 4074 | - } |
|
| 4075 | - else |
|
| 4250 | + } else |
|
| 4076 | 4251 | { |
| 4077 | 4252 | $totp = new \TOTP\Auth(); |
| 4078 | 4253 | $secret = $totp->generateCode(); |
@@ -4082,17 +4257,16 @@ discard block |
||
| 4082 | 4257 | } |
| 4083 | 4258 | |
| 4084 | 4259 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4085 | - } |
|
| 4086 | - elseif (isset($_REQUEST['disable'])) |
|
| 4260 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4087 | 4261 | { |
| 4088 | 4262 | updateMemberData($memID, array( |
| 4089 | 4263 | 'tfa_secret' => '', |
| 4090 | 4264 | 'tfa_backup' => '', |
| 4091 | 4265 | )); |
| 4092 | 4266 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4267 | + } else { |
|
| 4268 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4269 | + } |
|
| 4093 | 4270 | } |
| 4094 | - else |
|
| 4095 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4096 | -} |
|
| 4097 | 4271 | |
| 4098 | 4272 | ?> |
| 4099 | 4273 | \ No newline at end of file |
@@ -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 | * Updates a report with the given parameters. Logs each action via logAction() |
@@ -28,19 +29,20 @@ discard block |
||
| 28 | 29 | global $smcFunc, $user_info, $context; |
| 29 | 30 | |
| 30 | 31 | // Don't bother. |
| 31 | - if (empty($action) || empty($report_id)) |
|
| 32 | - return false; |
|
| 32 | + if (empty($action) || empty($report_id)) { |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | // Add the "_all" thingy. |
| 35 | - if ($action == 'ignore') |
|
| 36 | - $action = 'ignore_all'; |
|
| 37 | + if ($action == 'ignore') { |
|
| 38 | + $action = 'ignore_all'; |
|
| 39 | + } |
|
| 37 | 40 | |
| 38 | 41 | // We don't need the board query for reported members |
| 39 | 42 | if ($context['report_type'] == 'members') |
| 40 | 43 | { |
| 41 | 44 | $board_query = ''; |
| 42 | - } |
|
| 43 | - else |
|
| 45 | + } else |
|
| 44 | 46 | { |
| 45 | 47 | $board_query = ' AND ' . $user_info['mod_cache']['bq']; |
| 46 | 48 | } |
@@ -76,17 +78,17 @@ discard block |
||
| 76 | 78 | ) |
| 77 | 79 | ); |
| 78 | 80 | |
| 79 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 80 | - $extra[$row['id_report']] = array( |
|
| 81 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 82 | + $extra[$row['id_report']] = array( |
|
| 81 | 83 | 'report' => $row['id_report'], |
| 82 | 84 | 'board' => $row['id_board'], |
| 83 | 85 | 'message' => $row['id_msg'], |
| 84 | 86 | 'topic' => $row['id_topic'], |
| 85 | 87 | ); |
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $smcFunc['db_free_result']($request); |
| 88 | - } |
|
| 89 | - else |
|
| 91 | + } else |
|
| 90 | 92 | { |
| 91 | 93 | $request = $smcFunc['db_query']('', ' |
| 92 | 94 | SELECT id_report, id_member, membername |
@@ -97,28 +99,32 @@ discard block |
||
| 97 | 99 | ) |
| 98 | 100 | ); |
| 99 | 101 | |
| 100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 101 | - $extra[$row['id_report']] = array( |
|
| 102 | + while($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 103 | + $extra[$row['id_report']] = array( |
|
| 102 | 104 | 'report' => $row['id_report'], |
| 103 | 105 | 'member' => $row['id_member'], |
| 104 | 106 | ); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | $smcFunc['db_free_result']($request); |
| 107 | 110 | } |
| 108 | 111 | |
| 109 | 112 | // Back to "ignore". |
| 110 | - if ($action == 'ignore_all') |
|
| 111 | - $action = 'ignore'; |
|
| 113 | + if ($action == 'ignore_all') { |
|
| 114 | + $action = 'ignore'; |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | $log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open'); |
| 114 | 118 | |
| 115 | - if ($context['report_type'] == 'members') |
|
| 116 | - $log_report .= '_user'; |
|
| 119 | + if ($context['report_type'] == 'members') { |
|
| 120 | + $log_report .= '_user'; |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | // Log this action. |
| 119 | - if (!empty($extra)) |
|
| 120 | - foreach ($extra as $report) |
|
| 124 | + if (!empty($extra)) { |
|
| 125 | + foreach ($extra as $report) |
|
| 121 | 126 | logAction($log_report . '_report', $report); |
| 127 | + } |
|
| 122 | 128 | |
| 123 | 129 | // Time to update. |
| 124 | 130 | updateSettings(array('last_mod_report_action' => time())); |
@@ -142,14 +148,12 @@ discard block |
||
| 142 | 148 | if ($context['report_type'] == 'members') |
| 143 | 149 | { |
| 144 | 150 | $and = 'lr.id_board = 0'; |
| 145 | - } |
|
| 146 | - else |
|
| 151 | + } else |
|
| 147 | 152 | { |
| 148 | 153 | if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1') |
| 149 | 154 | { |
| 150 | 155 | $bq = $user_info['mod_cache']['bq']; |
| 151 | - } |
|
| 152 | - else |
|
| 156 | + } else |
|
| 153 | 157 | { |
| 154 | 158 | $bq = 'lr.' . $user_info['mod_cache']['bq']; |
| 155 | 159 | } |
@@ -205,8 +209,7 @@ discard block |
||
| 205 | 209 | 'max' => 10, |
| 206 | 210 | ) |
| 207 | 211 | ); |
| 208 | - } |
|
| 209 | - else |
|
| 212 | + } else |
|
| 210 | 213 | { |
| 211 | 214 | $request = $smcFunc['db_query']('', ' |
| 212 | 215 | SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body, |
@@ -254,8 +257,7 @@ discard block |
||
| 254 | 257 | 'href' => $scripturl . '?action=profile;u=' . $row['id_user'], |
| 255 | 258 | ), |
| 256 | 259 | ); |
| 257 | - } |
|
| 258 | - else |
|
| 260 | + } else |
|
| 259 | 261 | { |
| 260 | 262 | $report_boards_ids[] = $row['id_board']; |
| 261 | 263 | $extraDetails = array( |
@@ -295,14 +297,16 @@ discard block |
||
| 295 | 297 | ) |
| 296 | 298 | ); |
| 297 | 299 | |
| 298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 299 | - $board_names[$row['id_board']] = $row['name']; |
|
| 300 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 301 | + $board_names[$row['id_board']] = $row['name']; |
|
| 302 | + } |
|
| 300 | 303 | |
| 301 | 304 | $smcFunc['db_free_result']($request); |
| 302 | 305 | |
| 303 | - foreach ($reports as $id_report => $report) |
|
| 304 | - if (!empty($board_names[$report['topic']['id_board']])) |
|
| 306 | + foreach ($reports as $id_report => $report) { |
|
| 307 | + if (!empty($board_names[$report['topic']['id_board']])) |
|
| 305 | 308 | $reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']]; |
| 309 | + } |
|
| 306 | 310 | } |
| 307 | 311 | |
| 308 | 312 | // Now get all the people who reported it. |
@@ -352,10 +356,11 @@ discard block |
||
| 352 | 356 | { |
| 353 | 357 | global $user_info, $smcFunc; |
| 354 | 358 | |
| 355 | - if ($type == 'members') |
|
| 356 | - $bq = ''; |
|
| 357 | - else |
|
| 358 | - $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
| 359 | + if ($type == 'members') { |
|
| 360 | + $bq = ''; |
|
| 361 | + } else { |
|
| 362 | + $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
| 363 | + } |
|
| 359 | 364 | |
| 360 | 365 | $request = $smcFunc['db_query']('', ' |
| 361 | 366 | SELECT COUNT(*) |
@@ -394,8 +399,9 @@ discard block |
||
| 394 | 399 | { |
| 395 | 400 | global $smcFunc, $user_info, $context; |
| 396 | 401 | |
| 397 | - if (empty($report_id)) |
|
| 398 | - return false; |
|
| 402 | + if (empty($report_id)) { |
|
| 403 | + return false; |
|
| 404 | + } |
|
| 399 | 405 | |
| 400 | 406 | // We don't need all this info if we're only getting user info |
| 401 | 407 | if ($context['report_type'] == 'members') |
@@ -413,8 +419,7 @@ discard block |
||
| 413 | 419 | 'id_report' => $report_id, |
| 414 | 420 | ) |
| 415 | 421 | ); |
| 416 | - } |
|
| 417 | - else |
|
| 422 | + } else |
|
| 418 | 423 | { |
| 419 | 424 | // Get the report details, need this so we can limit access to a particular board. |
| 420 | 425 | $request = $smcFunc['db_query']('', ' |
@@ -433,8 +438,9 @@ discard block |
||
| 433 | 438 | } |
| 434 | 439 | |
| 435 | 440 | // So did we find anything? |
| 436 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 437 | - return false; |
|
| 441 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 442 | + return false; |
|
| 443 | + } |
|
| 438 | 444 | |
| 439 | 445 | // Woohoo we found a report and they can see it! |
| 440 | 446 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -453,8 +459,9 @@ discard block |
||
| 453 | 459 | { |
| 454 | 460 | global $smcFunc, $scripturl, $user_info, $txt; |
| 455 | 461 | |
| 456 | - if (empty($report_id)) |
|
| 457 | - return false; |
|
| 462 | + if (empty($report_id)) { |
|
| 463 | + return false; |
|
| 464 | + } |
|
| 458 | 465 | |
| 459 | 466 | $report = array( |
| 460 | 467 | 'comments' => array(), |
@@ -537,8 +544,9 @@ discard block |
||
| 537 | 544 | |
| 538 | 545 | $comment = array(); |
| 539 | 546 | |
| 540 | - if (empty($comment_id)) |
|
| 541 | - return false; |
|
| 547 | + if (empty($comment_id)) { |
|
| 548 | + return false; |
|
| 549 | + } |
|
| 542 | 550 | |
| 543 | 551 | $request = $smcFunc['db_query']('', ' |
| 544 | 552 | SELECT id_comment, id_notice, log_time, body, id_member |
@@ -555,8 +563,9 @@ discard block |
||
| 555 | 563 | $smcFunc['db_free_result']($request); |
| 556 | 564 | |
| 557 | 565 | // Add the permission |
| 558 | - if (!empty($comment)) |
|
| 559 | - $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
| 566 | + if (!empty($comment)) { |
|
| 567 | + $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
| 568 | + } |
|
| 560 | 569 | |
| 561 | 570 | return $comment; |
| 562 | 571 | } |
@@ -572,8 +581,9 @@ discard block |
||
| 572 | 581 | { |
| 573 | 582 | global $smcFunc, $user_info, $context; |
| 574 | 583 | |
| 575 | - if (empty($data)) |
|
| 576 | - return false; |
|
| 584 | + if (empty($data)) { |
|
| 585 | + return false; |
|
| 586 | + } |
|
| 577 | 587 | |
| 578 | 588 | $data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data); |
| 579 | 589 | |
@@ -602,8 +612,7 @@ discard block |
||
| 602 | 612 | 'comment_id' => $last_comment, |
| 603 | 613 | 'time' => time(), |
| 604 | 614 | ); |
| 605 | - } |
|
| 606 | - else |
|
| 615 | + } else |
|
| 607 | 616 | { |
| 608 | 617 | $prefix = 'Msg'; |
| 609 | 618 | $data = array( |
@@ -619,14 +628,15 @@ discard block |
||
| 619 | 628 | } |
| 620 | 629 | |
| 621 | 630 | // And get ready to notify people. |
| 622 | - if (!empty($report)) |
|
| 623 | - $smcFunc['db_insert']('insert', |
|
| 631 | + if (!empty($report)) { |
|
| 632 | + $smcFunc['db_insert']('insert', |
|
| 624 | 633 | '{db_prefix}background_tasks', |
| 625 | 634 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 626 | 635 | array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', json_encode($data), 0), |
| 627 | 636 | array('id_task') |
| 628 | 637 | ); |
| 629 | -} |
|
| 638 | + } |
|
| 639 | + } |
|
| 630 | 640 | |
| 631 | 641 | /** |
| 632 | 642 | * Saves the new information whenever a moderator comment is edited. |
@@ -639,8 +649,9 @@ discard block |
||
| 639 | 649 | { |
| 640 | 650 | global $smcFunc; |
| 641 | 651 | |
| 642 | - if (empty($comment_id) || empty($edited_comment)) |
|
| 643 | - return false; |
|
| 652 | + if (empty($comment_id) || empty($edited_comment)) { |
|
| 653 | + return false; |
|
| 654 | + } |
|
| 644 | 655 | |
| 645 | 656 | $smcFunc['db_query']('', ' |
| 646 | 657 | UPDATE {db_prefix}log_comments |
@@ -663,8 +674,9 @@ discard block |
||
| 663 | 674 | { |
| 664 | 675 | global $smcFunc; |
| 665 | 676 | |
| 666 | - if (empty($comment_id)) |
|
| 667 | - return false; |
|
| 677 | + if (empty($comment_id)) { |
|
| 678 | + return false; |
|
| 679 | + } |
|
| 668 | 680 | |
| 669 | 681 | $smcFunc['db_query']('', ' |
| 670 | 682 | DELETE FROM {db_prefix}log_comments |
@@ -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 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $board_info, $smcFunc, $modSettings; |
| 33 | 34 | |
| 34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
| 35 | - if (empty($topic)) |
|
| 36 | - redirectexit(); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + redirectexit(); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
| 39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | ) |
| 60 | 62 | ); |
| 61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
| 62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 63 | - redirectexit(); |
|
| 64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 65 | + redirectexit(); |
|
| 66 | + } |
|
| 64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
| 65 | 68 | $smcFunc['db_free_result']($request); |
| 66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
| 134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
| 135 | 138 | { |
| 136 | 139 | $guestvoted = explode(',', $guestvoted); |
| 137 | - if ($guestvoted[0] == $row['id_poll']) |
|
| 138 | - break; |
|
| 140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
| 141 | + break; |
|
| 142 | + } |
|
| 139 | 143 | } |
| 140 | 144 | // Has the poll been reset since guest voted? |
| 141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 142 | 146 | { |
| 143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
| 144 | 148 | unset($guestinfo[$i]); |
| 145 | - if (!empty($guestinfo)) |
|
| 146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 147 | - else |
|
| 148 | - unset($_COOKIE['guest_poll_vote']); |
|
| 149 | - } |
|
| 150 | - else |
|
| 149 | + if (!empty($guestinfo)) { |
|
| 150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 151 | + } else { |
|
| 152 | + unset($_COOKIE['guest_poll_vote']); |
|
| 153 | + } |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | // What did they vote for? |
| 153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
| 233 | 237 | $context['poster_name'] = $row['poster_name']; |
| 234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
| 235 | 239 | $context['parent_boards'] = array(); |
| 236 | - foreach ($board_info['parent_boards'] as $parent) |
|
| 237 | - $context['parent_boards'][] = $parent['name']; |
|
| 240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
| 241 | + $context['parent_boards'][] = $parent['name']; |
|
| 242 | + } |
|
| 238 | 243 | |
| 239 | 244 | // Split the topics up so we can print them. |
| 240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
| 266 | 271 | 'id_msg' => $row['id_msg'], |
| 267 | 272 | ); |
| 268 | 273 | |
| 269 | - if (!isset($context['topic_subject'])) |
|
| 270 | - $context['topic_subject'] = $row['subject']; |
|
| 274 | + if (!isset($context['topic_subject'])) { |
|
| 275 | + $context['topic_subject'] = $row['subject']; |
|
| 276 | + } |
|
| 271 | 277 | } |
| 272 | 278 | $smcFunc['db_free_result']($request); |
| 273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
| 275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
| 276 | 282 | { |
| 277 | 283 | $messages = array(); |
| 278 | - foreach ($context['posts'] as $temp) |
|
| 279 | - $messages[] = $temp['id_msg']; |
|
| 284 | + foreach ($context['posts'] as $temp) { |
|
| 285 | + $messages[] = $temp['id_msg']; |
|
| 286 | + } |
|
| 280 | 287 | |
| 281 | 288 | // build the request |
| 282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
| 295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 296 | 303 | { |
| 297 | 304 | $temp[$row['id_attach']] = $row; |
| 298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
| 299 | - $context['printattach'][$row['id_msg']] = array(); |
|
| 305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
| 306 | + $context['printattach'][$row['id_msg']] = array(); |
|
| 307 | + } |
|
| 300 | 308 | } |
| 301 | 309 | $smcFunc['db_free_result']($request); |
| 302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
| 313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
| 314 | 322 | $row['width'] = $modSettings['max_image_width']; |
| 315 | 323 | } |
| 316 | - } |
|
| 317 | - elseif (!empty($modSettings['max_image_width'])) |
|
| 324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
| 318 | 325 | { |
| 319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
| 320 | 327 | { |