@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | <div id="personal_messages">'; |
| 22 | 22 | |
| 23 | 23 | // Show the capacity bar, if available. |
| 24 | - if (!empty($context['limit_bar'])) |
|
| 25 | - echo ' |
|
| 24 | + if (!empty($context['limit_bar'])) { |
|
| 25 | + echo ' |
|
| 26 | 26 | <div class="cat_bar"> |
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
@@ -32,14 +32,16 @@ discard block |
||
| 32 | 32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
| 33 | 33 | </h3> |
| 34 | 34 | </div>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | // Message sent? Show a small indication. |
| 37 | - if (isset($context['pm_sent'])) |
|
| 38 | - echo ' |
|
| 38 | + if (isset($context['pm_sent'])) { |
|
| 39 | + echo ' |
|
| 39 | 40 | <div class="infobox"> |
| 40 | 41 | ', $txt['pm_sent'], ' |
| 41 | 42 | </div>'; |
| 42 | -} |
|
| 43 | + } |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | /** |
| 45 | 47 | * Just the end of the index bar, nothing special. |
@@ -68,13 +70,13 @@ discard block |
||
| 68 | 70 | </div> |
| 69 | 71 | <div class="pm_unread">'; |
| 70 | 72 | |
| 71 | - if (empty($context['unread_pms'])) |
|
| 72 | - echo ' |
|
| 73 | + if (empty($context['unread_pms'])) { |
|
| 74 | + echo ' |
|
| 73 | 75 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
| 74 | - else |
|
| 76 | + } else |
|
| 75 | 77 | { |
| 76 | - foreach ($context['unread_pms'] as $id_pm => $pm_details) |
|
| 77 | - echo ' |
|
| 78 | + foreach ($context['unread_pms'] as $id_pm => $pm_details) { |
|
| 79 | + echo ' |
|
| 78 | 80 | <div class="unread"> |
| 79 | 81 | ', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', ' |
| 80 | 82 | <div class="details"> |
@@ -85,6 +87,7 @@ discard block |
||
| 85 | 87 | </div> |
| 86 | 88 | </div> |
| 87 | 89 | </div>'; |
| 90 | + } |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | echo ' |
@@ -193,14 +196,15 @@ discard block |
||
| 193 | 196 | if ($context['get_pmessage']('message', true)) |
| 194 | 197 | { |
| 195 | 198 | // Show the helpful titlebar - generally. |
| 196 | - if ($context['display_mode'] != 1) |
|
| 197 | - echo ' |
|
| 199 | + if ($context['display_mode'] != 1) { |
|
| 200 | + echo ' |
|
| 198 | 201 | <div class="cat_bar"> |
| 199 | 202 | <h3 class="catbg"> |
| 200 | 203 | <span id="author">', $txt['author'], '</span> |
| 201 | 204 | <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span> |
| 202 | 205 | </h3> |
| 203 | 206 | </div>'; |
| 207 | + } |
|
| 204 | 208 | |
| 205 | 209 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 206 | 210 | if ($context['display_mode'] == 2) |
@@ -228,9 +232,10 @@ discard block |
||
| 228 | 232 | <div class="custom_fields_above_member"> |
| 229 | 233 | <ul class="nolist">'; |
| 230 | 234 | |
| 231 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 232 | - echo ' |
|
| 235 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 236 | + echo ' |
|
| 233 | 237 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 238 | + } |
|
| 234 | 239 | |
| 235 | 240 | echo ' |
| 236 | 241 | </ul> |
@@ -242,25 +247,28 @@ discard block |
||
| 242 | 247 | <a id="msg', $message['id'], '"></a>'; |
| 243 | 248 | |
| 244 | 249 | // Show online and offline buttons? |
| 245 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 246 | - echo ' |
|
| 250 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 251 | + echo ' |
|
| 247 | 252 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | 255 | // Custom fields BEFORE the username? |
| 250 | - if (!empty($message['custom_fields']['before_member'])) |
|
| 251 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 256 | + if (!empty($message['custom_fields']['before_member'])) { |
|
| 257 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 252 | 258 | echo ' |
| 253 | 259 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 260 | + } |
|
| 254 | 261 | |
| 255 | 262 | // Show a link to the member's profile. |
| 256 | 263 | echo ' |
| 257 | 264 | ', $message['member']['link']; |
| 258 | 265 | |
| 259 | 266 | // Custom fields AFTER the username? |
| 260 | - if (!empty($message['custom_fields']['after_member'])) |
|
| 261 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 267 | + if (!empty($message['custom_fields']['after_member'])) { |
|
| 268 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 262 | 269 | echo ' |
| 263 | 270 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 271 | + } |
|
| 264 | 272 | |
| 265 | 273 | echo ' |
| 266 | 274 | </h4>'; |
@@ -269,48 +277,56 @@ discard block |
||
| 269 | 277 | <ul class="user_info">'; |
| 270 | 278 | |
| 271 | 279 | // Show the user's avatar. |
| 272 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 273 | - echo ' |
|
| 280 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 281 | + echo ' |
|
| 274 | 282 | <li class="avatar"> |
| 275 | 283 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
| 276 | 284 | </li>'; |
| 285 | + } |
|
| 277 | 286 | |
| 278 | 287 | // Are there any custom fields below the avatar? |
| 279 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 280 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 288 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 289 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 281 | 290 | echo ' |
| 282 | 291 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 292 | + } |
|
| 283 | 293 | |
| 284 | - if (!$message['member']['is_guest']) |
|
| 285 | - echo ' |
|
| 294 | + if (!$message['member']['is_guest']) { |
|
| 295 | + echo ' |
|
| 286 | 296 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 297 | + } |
|
| 287 | 298 | // Show the member's primary group (like 'Administrator') if they have one. |
| 288 | - if (isset($message['member']['group']) && $message['member']['group'] != '') |
|
| 289 | - echo ' |
|
| 299 | + if (isset($message['member']['group']) && $message['member']['group'] != '') { |
|
| 300 | + echo ' |
|
| 290 | 301 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 302 | + } |
|
| 291 | 303 | |
| 292 | 304 | // Show the member's custom title, if they have one. |
| 293 | - if (isset($message['member']['title']) && $message['member']['title'] != '') |
|
| 294 | - echo ' |
|
| 305 | + if (isset($message['member']['title']) && $message['member']['title'] != '') { |
|
| 306 | + echo ' |
|
| 295 | 307 | <li class="title">', $message['member']['title'], '</li>'; |
| 308 | + } |
|
| 296 | 309 | |
| 297 | 310 | // Don't show these things for guests. |
| 298 | 311 | if (!$message['member']['is_guest']) |
| 299 | 312 | { |
| 300 | 313 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 301 | - if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
|
| 302 | - echo ' |
|
| 314 | + if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') { |
|
| 315 | + echo ' |
|
| 303 | 316 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 317 | + } |
|
| 304 | 318 | |
| 305 | 319 | // Show how many posts they have made. |
| 306 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 307 | - echo ' |
|
| 320 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 321 | + echo ' |
|
| 308 | 322 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 323 | + } |
|
| 309 | 324 | |
| 310 | 325 | // Show their personal text? |
| 311 | - if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
|
| 312 | - echo ' |
|
| 326 | + if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') { |
|
| 327 | + echo ' |
|
| 313 | 328 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 329 | + } |
|
| 314 | 330 | |
| 315 | 331 | // Any custom fields to show as icons? |
| 316 | 332 | if (!empty($message['custom_fields']['icons'])) |
@@ -319,9 +335,10 @@ discard block |
||
| 319 | 335 | <li class="im_icons"> |
| 320 | 336 | <ol>'; |
| 321 | 337 | |
| 322 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 323 | - echo ' |
|
| 338 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 339 | + echo ' |
|
| 324 | 340 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 341 | + } |
|
| 325 | 342 | |
| 326 | 343 | echo ' |
| 327 | 344 | </ol> |
@@ -329,25 +346,28 @@ discard block |
||
| 329 | 346 | } |
| 330 | 347 | |
| 331 | 348 | // Show the IP to this user for this post - because you can moderate? |
| 332 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 333 | - echo ' |
|
| 349 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 350 | + echo ' |
|
| 334 | 351 | <li class="poster_ip"> |
| 335 | 352 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
| 336 | 353 | </li>'; |
| 354 | + } |
|
| 337 | 355 | |
| 338 | 356 | // Or, should we show it because this is you? |
| 339 | - elseif ($message['can_see_ip']) |
|
| 340 | - echo ' |
|
| 357 | + elseif ($message['can_see_ip']) { |
|
| 358 | + echo ' |
|
| 341 | 359 | <li class="poster_ip"> |
| 342 | 360 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
| 343 | 361 | </li>'; |
| 362 | + } |
|
| 344 | 363 | |
| 345 | 364 | // Okay, you are logged in, then we can show something about why IPs are logged... |
| 346 | - else |
|
| 347 | - echo ' |
|
| 365 | + else { |
|
| 366 | + echo ' |
|
| 348 | 367 | <li class="poster_ip"> |
| 349 | 368 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
| 350 | 369 | </li>'; |
| 370 | + } |
|
| 351 | 371 | |
| 352 | 372 | // Show the profile, website, email address, and personal message buttons. |
| 353 | 373 | if ($message['member']['show_profile_buttons']) |
@@ -357,24 +377,28 @@ discard block |
||
| 357 | 377 | <ol class="profile_icons">'; |
| 358 | 378 | |
| 359 | 379 | // Show the profile button |
| 360 | - if ($message['member']['can_view_profile']) |
|
| 361 | - echo ' |
|
| 380 | + if ($message['member']['can_view_profile']) { |
|
| 381 | + echo ' |
|
| 362 | 382 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
| 383 | + } |
|
| 363 | 384 | |
| 364 | 385 | // Don't show an icon if they haven't specified a website. |
| 365 | - if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
|
| 366 | - echo ' |
|
| 386 | + if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) { |
|
| 387 | + echo ' |
|
| 367 | 388 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 389 | + } |
|
| 368 | 390 | |
| 369 | 391 | // Don't show the email address if they want it hidden. |
| 370 | - if ($message['member']['show_email']) |
|
| 371 | - echo ' |
|
| 392 | + if ($message['member']['show_email']) { |
|
| 393 | + echo ' |
|
| 372 | 394 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 395 | + } |
|
| 373 | 396 | |
| 374 | 397 | // Since we know this person isn't a guest, you *can* message them. |
| 375 | - if ($context['can_send_pm']) |
|
| 376 | - echo ' |
|
| 398 | + if ($context['can_send_pm']) { |
|
| 399 | + echo ' |
|
| 377 | 400 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 401 | + } |
|
| 378 | 402 | |
| 379 | 403 | echo ' |
| 380 | 404 | </ol> |
@@ -382,21 +406,24 @@ discard block |
||
| 382 | 406 | } |
| 383 | 407 | |
| 384 | 408 | // Any custom fields for standard placement? |
| 385 | - if (!empty($message['custom_fields']['standard'])) |
|
| 386 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 409 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 410 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 387 | 411 | echo ' |
| 388 | 412 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 413 | + } |
|
| 389 | 414 | |
| 390 | 415 | // Are we showing the warning status? |
| 391 | - if ($message['member']['can_see_warning']) |
|
| 392 | - echo ' |
|
| 416 | + if ($message['member']['can_see_warning']) { |
|
| 417 | + echo ' |
|
| 393 | 418 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 419 | + } |
|
| 394 | 420 | |
| 395 | 421 | // Are there any custom fields to show at the bottom of the poster info? |
| 396 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 397 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 422 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 423 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 398 | 424 | echo ' |
| 399 | 425 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 426 | + } |
|
| 400 | 427 | } |
| 401 | 428 | |
| 402 | 429 | // Done with the information about the poster... on to the post itself. |
@@ -415,25 +442,29 @@ discard block |
||
| 415 | 442 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
| 416 | 443 | |
| 417 | 444 | // People it was sent directly to.... |
| 418 | - if (!empty($message['recipients']['to'])) |
|
| 419 | - echo implode(', ', $message['recipients']['to']); |
|
| 445 | + if (!empty($message['recipients']['to'])) { |
|
| 446 | + echo implode(', ', $message['recipients']['to']); |
|
| 447 | + } |
|
| 420 | 448 | |
| 421 | 449 | // Otherwise, we're just going to say "some people"... |
| 422 | - elseif ($context['folder'] != 'sent') |
|
| 423 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 450 | + elseif ($context['folder'] != 'sent') { |
|
| 451 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 452 | + } |
|
| 424 | 453 | |
| 425 | 454 | echo ' |
| 426 | 455 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
| 427 | 456 | </span>'; |
| 428 | 457 | |
| 429 | 458 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
| 430 | - if (!empty($message['recipients']['bcc'])) |
|
| 431 | - echo '<br> |
|
| 459 | + if (!empty($message['recipients']['bcc'])) { |
|
| 460 | + echo '<br> |
|
| 432 | 461 | <span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
| 462 | + } |
|
| 433 | 463 | |
| 434 | - if (!empty($message['is_replied_to'])) |
|
| 435 | - echo '<br> |
|
| 464 | + if (!empty($message['is_replied_to'])) { |
|
| 465 | + echo '<br> |
|
| 436 | 466 | <span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
| 467 | + } |
|
| 437 | 468 | |
| 438 | 469 | echo ' |
| 439 | 470 | </div><!-- .keyinfo --> |
@@ -443,13 +474,15 @@ discard block |
||
| 443 | 474 | ', $message['body'], ' |
| 444 | 475 | </div>'; |
| 445 | 476 | |
| 446 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 447 | - echo ' |
|
| 477 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 478 | + echo ' |
|
| 448 | 479 | <div class="under_message">'; |
| 480 | + } |
|
| 449 | 481 | |
| 450 | - if ($message['can_report']) |
|
| 451 | - echo ' |
|
| 482 | + if ($message['can_report']) { |
|
| 483 | + echo ' |
|
| 452 | 484 | <a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>'; |
| 485 | + } |
|
| 453 | 486 | |
| 454 | 487 | echo ' |
| 455 | 488 | <ul class="quickbuttons">'; |
@@ -461,32 +494,36 @@ discard block |
||
| 461 | 494 | if (!$message['member']['is_guest']) |
| 462 | 495 | { |
| 463 | 496 | // Is there than more than one recipient you can reply to? |
| 464 | - if ($message['number_recipients'] > 1) |
|
| 465 | - echo ' |
|
| 497 | + if ($message['number_recipients'] > 1) { |
|
| 498 | + echo ' |
|
| 466 | 499 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>'; |
| 500 | + } |
|
| 467 | 501 | |
| 468 | 502 | echo ' |
| 469 | 503 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li> |
| 470 | 504 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 471 | 505 | } |
| 472 | 506 | // This is for "forwarding" - even if the member is gone. |
| 473 | - else |
|
| 474 | - echo ' |
|
| 507 | + else { |
|
| 508 | + echo ' |
|
| 475 | 509 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>'; |
| 510 | + } |
|
| 476 | 511 | } |
| 477 | 512 | echo ' |
| 478 | 513 | <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>'; |
| 479 | 514 | |
| 480 | - if (empty($context['display_mode'])) |
|
| 481 | - echo ' |
|
| 515 | + if (empty($context['display_mode'])) { |
|
| 516 | + echo ' |
|
| 482 | 517 | <li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>'; |
| 518 | + } |
|
| 483 | 519 | |
| 484 | 520 | echo ' |
| 485 | 521 | </ul>'; |
| 486 | 522 | |
| 487 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 488 | - echo ' |
|
| 523 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 524 | + echo ' |
|
| 489 | 525 | </div><!-- .under_message -->'; |
| 526 | + } |
|
| 490 | 527 | |
| 491 | 528 | // Are there any custom profile fields for above the signature? |
| 492 | 529 | if (!empty($message['custom_fields']['above_signature'])) |
@@ -495,9 +532,10 @@ discard block |
||
| 495 | 532 | <div class="custom_fields_above_signature"> |
| 496 | 533 | <ul class="nolist">'; |
| 497 | 534 | |
| 498 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 499 | - echo ' |
|
| 535 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 536 | + echo ' |
|
| 500 | 537 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 538 | + } |
|
| 501 | 539 | |
| 502 | 540 | echo ' |
| 503 | 541 | </ul> |
@@ -505,11 +543,12 @@ discard block |
||
| 505 | 543 | } |
| 506 | 544 | |
| 507 | 545 | // Show the member's signature? |
| 508 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 509 | - echo ' |
|
| 546 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 547 | + echo ' |
|
| 510 | 548 | <div class="signature"> |
| 511 | 549 | ', $message['member']['signature'], ' |
| 512 | 550 | </div>'; |
| 551 | + } |
|
| 513 | 552 | |
| 514 | 553 | // Are there any custom profile fields for below the signature? |
| 515 | 554 | if (!empty($message['custom_fields']['below_signature'])) |
@@ -518,9 +557,10 @@ discard block |
||
| 518 | 557 | <div class="custom_fields_below_signature"> |
| 519 | 558 | <ul class="nolist">'; |
| 520 | 559 | |
| 521 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 522 | - echo ' |
|
| 560 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 561 | + echo ' |
|
| 523 | 562 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 563 | + } |
|
| 524 | 564 | |
| 525 | 565 | echo ' |
| 526 | 566 | </ul> |
@@ -547,10 +587,11 @@ discard block |
||
| 547 | 587 | echo ' |
| 548 | 588 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
| 549 | 589 | |
| 550 | - foreach ($context['labels'] as $label) |
|
| 551 | - if (!isset($message['labels'][$label['id']])) |
|
| 590 | + foreach ($context['labels'] as $label) { |
|
| 591 | + if (!isset($message['labels'][$label['id']])) |
|
| 552 | 592 | echo ' |
| 553 | 593 | <option value="', $label['id'], '">', $label['name'], '</option>'; |
| 594 | + } |
|
| 554 | 595 | } |
| 555 | 596 | |
| 556 | 597 | // ... and are there any that can be removed? |
@@ -559,9 +600,10 @@ discard block |
||
| 559 | 600 | echo ' |
| 560 | 601 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
| 561 | 602 | |
| 562 | - foreach ($message['labels'] as $label) |
|
| 563 | - echo ' |
|
| 603 | + foreach ($message['labels'] as $label) { |
|
| 604 | + echo ' |
|
| 564 | 605 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
| 606 | + } |
|
| 565 | 607 | } |
| 566 | 608 | echo ' |
| 567 | 609 | </select> |
@@ -580,14 +622,15 @@ discard block |
||
| 580 | 622 | </div><!-- .windowbg -->'; |
| 581 | 623 | } |
| 582 | 624 | |
| 583 | - if (empty($context['display_mode'])) |
|
| 584 | - echo ' |
|
| 625 | + if (empty($context['display_mode'])) { |
|
| 626 | + echo ' |
|
| 585 | 627 | <div class="pagesection"> |
| 586 | 628 | <div class="floatleft">', $context['page_index'], '</div> |
| 587 | 629 | <div class="floatright"> |
| 588 | 630 | <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button"> |
| 589 | 631 | </div> |
| 590 | 632 | </div>'; |
| 633 | + } |
|
| 591 | 634 | |
| 592 | 635 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 593 | 636 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
@@ -647,11 +690,12 @@ discard block |
||
| 647 | 690 | </thead> |
| 648 | 691 | <tbody>'; |
| 649 | 692 | |
| 650 | - if (!$context['show_delete']) |
|
| 651 | - echo ' |
|
| 693 | + if (!$context['show_delete']) { |
|
| 694 | + echo ' |
|
| 652 | 695 | <tr class="windowbg"> |
| 653 | 696 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
| 654 | 697 | </tr>'; |
| 698 | + } |
|
| 655 | 699 | |
| 656 | 700 | while ($message = $context['get_pmessage']('subject')) |
| 657 | 701 | { |
@@ -709,17 +753,19 @@ discard block |
||
| 709 | 753 | |
| 710 | 754 | foreach ($context['labels'] as $label) |
| 711 | 755 | { |
| 712 | - if ($label['id'] != $context['current_label_id']) |
|
| 713 | - echo ' |
|
| 756 | + if ($label['id'] != $context['current_label_id']) { |
|
| 757 | + echo ' |
|
| 714 | 758 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
| 759 | + } |
|
| 715 | 760 | } |
| 716 | 761 | |
| 717 | 762 | echo ' |
| 718 | 763 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
| 719 | 764 | |
| 720 | - foreach ($context['labels'] as $label) |
|
| 721 | - echo ' |
|
| 765 | + foreach ($context['labels'] as $label) { |
|
| 766 | + echo ' |
|
| 722 | 767 | <option value="rem_', $label['id'], '"> ', $label['name'], '</option>'; |
| 768 | + } |
|
| 723 | 769 | |
| 724 | 770 | echo ' |
| 725 | 771 | </select> |
@@ -744,11 +790,12 @@ discard block |
||
| 744 | 790 | { |
| 745 | 791 | global $context, $scripturl, $txt; |
| 746 | 792 | |
| 747 | - if (!empty($context['search_errors'])) |
|
| 748 | - echo ' |
|
| 793 | + if (!empty($context['search_errors'])) { |
|
| 794 | + echo ' |
|
| 749 | 795 | <div class="errorbox"> |
| 750 | 796 | ', implode('<br>', $context['search_errors']['messages']), ' |
| 751 | 797 | </div>'; |
| 798 | + } |
|
| 752 | 799 | |
| 753 | 800 | echo ' |
| 754 | 801 | <form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform"> |
@@ -816,9 +863,10 @@ discard block |
||
| 816 | 863 | </dd> |
| 817 | 864 | </dl>'; |
| 818 | 865 | |
| 819 | - if (!$context['currently_using_labels']) |
|
| 820 | - echo ' |
|
| 866 | + if (!$context['currently_using_labels']) { |
|
| 867 | + echo ' |
|
| 821 | 868 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button floatright">'; |
| 869 | + } |
|
| 822 | 870 | |
| 823 | 871 | echo ' |
| 824 | 872 | </div><!-- .roundframe -->'; |
@@ -837,12 +885,13 @@ discard block |
||
| 837 | 885 | <div id="advanced_panel_div"> |
| 838 | 886 | <ul id="searchLabelsExpand">'; |
| 839 | 887 | |
| 840 | - foreach ($context['search_labels'] as $label) |
|
| 841 | - echo ' |
|
| 888 | + foreach ($context['search_labels'] as $label) { |
|
| 889 | + echo ' |
|
| 842 | 890 | <li> |
| 843 | 891 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '> |
| 844 | 892 | ', $label['name'], '</label> |
| 845 | 893 | </li>'; |
| 894 | + } |
|
| 846 | 895 | |
| 847 | 896 | echo ' |
| 848 | 897 | </ul> |
@@ -904,8 +953,8 @@ discard block |
||
| 904 | 953 | </div>'; |
| 905 | 954 | |
| 906 | 955 | // Complete results? |
| 907 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 908 | - echo ' |
|
| 956 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 957 | + echo ' |
|
| 909 | 958 | <table class="table_grid"> |
| 910 | 959 | <thead> |
| 911 | 960 | <tr class="title_bar"> |
@@ -915,6 +964,7 @@ discard block |
||
| 915 | 964 | </tr> |
| 916 | 965 | </thead> |
| 917 | 966 | <tbody>'; |
| 967 | + } |
|
| 918 | 968 | |
| 919 | 969 | // Print each message out... |
| 920 | 970 | foreach ($context['personal_messages'] as $message) |
@@ -934,12 +984,14 @@ discard block |
||
| 934 | 984 | |
| 935 | 985 | // Show the recipients. |
| 936 | 986 | // @todo This doesn't deal with the sent item searching quite right for bcc. |
| 937 | - if (!empty($message['recipients']['to'])) |
|
| 938 | - echo implode(', ', $message['recipients']['to']); |
|
| 987 | + if (!empty($message['recipients']['to'])) { |
|
| 988 | + echo implode(', ', $message['recipients']['to']); |
|
| 989 | + } |
|
| 939 | 990 | |
| 940 | 991 | // Otherwise, we're just going to say "some people"... |
| 941 | - elseif ($context['folder'] != 'sent') |
|
| 942 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 992 | + elseif ($context['folder'] != 'sent') { |
|
| 993 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 994 | + } |
|
| 943 | 995 | |
| 944 | 996 | echo ' |
| 945 | 997 | </h3> |
@@ -954,15 +1006,17 @@ discard block |
||
| 954 | 1006 | $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"'); |
| 955 | 1007 | |
| 956 | 1008 | // You can only reply if they are not a guest... |
| 957 | - if (!$message['member']['is_guest']) |
|
| 958 | - echo ' |
|
| 1009 | + if (!$message['member']['is_guest']) { |
|
| 1010 | + echo ' |
|
| 959 | 1011 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
| 960 | 1012 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
| 1013 | + } |
|
| 961 | 1014 | |
| 962 | 1015 | // This is for "forwarding" - even if the member is gone. |
| 963 | - else |
|
| 964 | - echo ' |
|
| 1016 | + else { |
|
| 1017 | + echo ' |
|
| 965 | 1018 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
| 1019 | + } |
|
| 966 | 1020 | } |
| 967 | 1021 | |
| 968 | 1022 | echo ' |
@@ -971,27 +1025,30 @@ discard block |
||
| 971 | 1025 | } |
| 972 | 1026 | // Otherwise just a simple list! |
| 973 | 1027 | // @todo No context at all of the search? |
| 974 | - else |
|
| 975 | - echo ' |
|
| 1028 | + else { |
|
| 1029 | + echo ' |
|
| 976 | 1030 | <tr class="windowbg"> |
| 977 | 1031 | <td>', $message['time'], '</td> |
| 978 | 1032 | <td>', $message['link'], '</td> |
| 979 | 1033 | <td>', $message['member']['link'], '</td> |
| 980 | 1034 | </tr>'; |
| 1035 | + } |
|
| 981 | 1036 | } |
| 982 | 1037 | |
| 983 | 1038 | // Finish off the page... |
| 984 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 985 | - echo ' |
|
| 1039 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 1040 | + echo ' |
|
| 986 | 1041 | </tbody> |
| 987 | 1042 | </table>'; |
| 1043 | + } |
|
| 988 | 1044 | |
| 989 | 1045 | // No results? |
| 990 | - if (empty($context['personal_messages'])) |
|
| 991 | - echo ' |
|
| 1046 | + if (empty($context['personal_messages'])) { |
|
| 1047 | + echo ' |
|
| 992 | 1048 | <div class="windowbg"> |
| 993 | 1049 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
| 994 | 1050 | </div>'; |
| 1051 | + } |
|
| 995 | 1052 | |
| 996 | 1053 | echo ' |
| 997 | 1054 | <div class="pagesection"> |
@@ -1016,15 +1073,17 @@ discard block |
||
| 1016 | 1073 | </div> |
| 1017 | 1074 | <div class="windowbg">'; |
| 1018 | 1075 | |
| 1019 | - if (!empty($context['send_log']['sent'])) |
|
| 1020 | - foreach ($context['send_log']['sent'] as $log_entry) |
|
| 1076 | + if (!empty($context['send_log']['sent'])) { |
|
| 1077 | + foreach ($context['send_log']['sent'] as $log_entry) |
|
| 1021 | 1078 | echo ' |
| 1022 | 1079 | <span class="error">', $log_entry, '</span><br>'; |
| 1080 | + } |
|
| 1023 | 1081 | |
| 1024 | - if (!empty($context['send_log']['failed'])) |
|
| 1025 | - foreach ($context['send_log']['failed'] as $log_entry) |
|
| 1082 | + if (!empty($context['send_log']['failed'])) { |
|
| 1083 | + foreach ($context['send_log']['failed'] as $log_entry) |
|
| 1026 | 1084 | echo ' |
| 1027 | 1085 | <span class="error">', $log_entry, '</span><br>'; |
| 1086 | + } |
|
| 1028 | 1087 | |
| 1029 | 1088 | echo ' |
| 1030 | 1089 | </div> |
@@ -1070,12 +1129,13 @@ discard block |
||
| 1070 | 1129 | </dl> |
| 1071 | 1130 | </div>'; |
| 1072 | 1131 | |
| 1073 | - if (!empty($modSettings['drafts_pm_enabled'])) |
|
| 1074 | - echo ' |
|
| 1132 | + if (!empty($modSettings['drafts_pm_enabled'])) { |
|
| 1133 | + echo ' |
|
| 1075 | 1134 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
| 1076 | 1135 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
| 1077 | 1136 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
| 1078 | 1137 | </div>'; |
| 1138 | + } |
|
| 1079 | 1139 | |
| 1080 | 1140 | echo ' |
| 1081 | 1141 | <dl id="post_header">'; |
@@ -1141,22 +1201,24 @@ discard block |
||
| 1141 | 1201 | <dt><strong>', $txt['subject'], '</strong></dt> |
| 1142 | 1202 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
| 1143 | 1203 | |
| 1144 | - foreach ($context['drafts'] as $draft) |
|
| 1145 | - echo ' |
|
| 1204 | + foreach ($context['drafts'] as $draft) { |
|
| 1205 | + echo ' |
|
| 1146 | 1206 | <dt>', $draft['link'], '</dt> |
| 1147 | 1207 | <dd>', $draft['poster_time'], '</dd>'; |
| 1208 | + } |
|
| 1148 | 1209 | echo ' |
| 1149 | 1210 | </dl> |
| 1150 | 1211 | </div>'; |
| 1151 | 1212 | } |
| 1152 | 1213 | |
| 1153 | 1214 | // Require an image to be typed to save spamming? |
| 1154 | - if ($context['require_verification']) |
|
| 1155 | - echo ' |
|
| 1215 | + if ($context['require_verification']) { |
|
| 1216 | + echo ' |
|
| 1156 | 1217 | <div class="post_verification"> |
| 1157 | 1218 | <strong>', $txt['pm_visual_verification_label'], ':</strong> |
| 1158 | 1219 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 1159 | 1220 | </div>'; |
| 1221 | + } |
|
| 1160 | 1222 | |
| 1161 | 1223 | // Send, Preview, spellcheck buttons. |
| 1162 | 1224 | echo ' |
@@ -1274,8 +1336,8 @@ discard block |
||
| 1274 | 1336 | }'; |
| 1275 | 1337 | |
| 1276 | 1338 | // Code for showing and hiding drafts |
| 1277 | - if (!empty($context['drafts'])) |
|
| 1278 | - echo ' |
|
| 1339 | + if (!empty($context['drafts'])) { |
|
| 1340 | + echo ' |
|
| 1279 | 1341 | var oSwapDraftOptions = new smc_Toggle({ |
| 1280 | 1342 | bToggleEnabled: true, |
| 1281 | 1343 | bCurrentlyCollapsed: true, |
@@ -1297,13 +1359,14 @@ discard block |
||
| 1297 | 1359 | } |
| 1298 | 1360 | ] |
| 1299 | 1361 | });'; |
| 1362 | + } |
|
| 1300 | 1363 | |
| 1301 | 1364 | echo ' |
| 1302 | 1365 | </script>'; |
| 1303 | 1366 | |
| 1304 | 1367 | // Show the message you're replying to. |
| 1305 | - if ($context['reply']) |
|
| 1306 | - echo ' |
|
| 1368 | + if ($context['reply']) { |
|
| 1369 | + echo ' |
|
| 1307 | 1370 | <br><br> |
| 1308 | 1371 | <div class="cat_bar"> |
| 1309 | 1372 | <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3> |
@@ -1317,6 +1380,7 @@ discard block |
||
| 1317 | 1380 | ', $context['quoted_message']['body'], ' |
| 1318 | 1381 | </div> |
| 1319 | 1382 | <br class="clear">'; |
| 1383 | + } |
|
| 1320 | 1384 | |
| 1321 | 1385 | echo ' |
| 1322 | 1386 | <script> |
@@ -1328,23 +1392,25 @@ discard block |
||
| 1328 | 1392 | sToControlId: \'to_control\', |
| 1329 | 1393 | aToRecipients: ['; |
| 1330 | 1394 | |
| 1331 | - foreach ($context['recipients']['to'] as $i => $member) |
|
| 1332 | - echo ' |
|
| 1395 | + foreach ($context['recipients']['to'] as $i => $member) { |
|
| 1396 | + echo ' |
|
| 1333 | 1397 | { |
| 1334 | 1398 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1335 | 1399 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1336 | 1400 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
| 1401 | + } |
|
| 1337 | 1402 | |
| 1338 | 1403 | echo ' |
| 1339 | 1404 | ], |
| 1340 | 1405 | aBccRecipients: ['; |
| 1341 | 1406 | |
| 1342 | - foreach ($context['recipients']['bcc'] as $i => $member) |
|
| 1343 | - echo ' |
|
| 1407 | + foreach ($context['recipients']['bcc'] as $i => $member) { |
|
| 1408 | + echo ' |
|
| 1344 | 1409 | { |
| 1345 | 1410 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1346 | 1411 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1347 | 1412 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
| 1413 | + } |
|
| 1348 | 1414 | |
| 1349 | 1415 | echo ' |
| 1350 | 1416 | ], |
@@ -1433,26 +1499,28 @@ discard block |
||
| 1433 | 1499 | </th> |
| 1434 | 1500 | <th class="centertext table_icon">'; |
| 1435 | 1501 | |
| 1436 | - if (count($context['labels']) > 2) |
|
| 1437 | - echo ' |
|
| 1502 | + if (count($context['labels']) > 2) { |
|
| 1503 | + echo ' |
|
| 1438 | 1504 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
| 1505 | + } |
|
| 1439 | 1506 | |
| 1440 | 1507 | echo ' |
| 1441 | 1508 | </th> |
| 1442 | 1509 | </tr> |
| 1443 | 1510 | </thead> |
| 1444 | 1511 | <tbody>'; |
| 1445 | - if (count($context['labels']) < 2) |
|
| 1446 | - echo ' |
|
| 1512 | + if (count($context['labels']) < 2) { |
|
| 1513 | + echo ' |
|
| 1447 | 1514 | <tr class="windowbg"> |
| 1448 | 1515 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
| 1449 | 1516 | </tr>'; |
| 1450 | - else |
|
| 1517 | + } else |
|
| 1451 | 1518 | { |
| 1452 | 1519 | foreach ($context['labels'] as $label) |
| 1453 | 1520 | { |
| 1454 | - if ($label['id'] == -1) |
|
| 1455 | - continue; |
|
| 1521 | + if ($label['id'] == -1) { |
|
| 1522 | + continue; |
|
| 1523 | + } |
|
| 1456 | 1524 | |
| 1457 | 1525 | echo ' |
| 1458 | 1526 | <tr class="windowbg"> |
@@ -1467,12 +1535,13 @@ discard block |
||
| 1467 | 1535 | </tbody> |
| 1468 | 1536 | </table>'; |
| 1469 | 1537 | |
| 1470 | - if (!count($context['labels']) < 2) |
|
| 1471 | - echo ' |
|
| 1538 | + if (!count($context['labels']) < 2) { |
|
| 1539 | + echo ' |
|
| 1472 | 1540 | <div class="block righttext"> |
| 1473 | 1541 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
| 1474 | 1542 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure"> |
| 1475 | 1543 | </div>'; |
| 1544 | + } |
|
| 1476 | 1545 | |
| 1477 | 1546 | echo ' |
| 1478 | 1547 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1528,9 +1597,10 @@ discard block |
||
| 1528 | 1597 | <select name="id_admin"> |
| 1529 | 1598 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
| 1530 | 1599 | |
| 1531 | - foreach ($context['admins'] as $id => $name) |
|
| 1532 | - echo ' |
|
| 1600 | + foreach ($context['admins'] as $id => $name) { |
|
| 1601 | + echo ' |
|
| 1533 | 1602 | <option value="', $id, '">', $name, '</option>'; |
| 1603 | + } |
|
| 1534 | 1604 | |
| 1535 | 1605 | echo ' |
| 1536 | 1606 | </select> |
@@ -1593,9 +1663,10 @@ discard block |
||
| 1593 | 1663 | </th> |
| 1594 | 1664 | <th class="centertext table_icon">'; |
| 1595 | 1665 | |
| 1596 | - if (!empty($context['rules'])) |
|
| 1597 | - echo ' |
|
| 1666 | + if (!empty($context['rules'])) { |
|
| 1667 | + echo ' |
|
| 1598 | 1668 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
| 1669 | + } |
|
| 1599 | 1670 | |
| 1600 | 1671 | echo ' |
| 1601 | 1672 | </th> |
@@ -1603,16 +1674,17 @@ discard block |
||
| 1603 | 1674 | </thead> |
| 1604 | 1675 | <tbody>'; |
| 1605 | 1676 | |
| 1606 | - if (empty($context['rules'])) |
|
| 1607 | - echo ' |
|
| 1677 | + if (empty($context['rules'])) { |
|
| 1678 | + echo ' |
|
| 1608 | 1679 | <tr class="windowbg"> |
| 1609 | 1680 | <td colspan="2"> |
| 1610 | 1681 | ', $txt['pm_rules_none'], ' |
| 1611 | 1682 | </td> |
| 1612 | 1683 | </tr>'; |
| 1684 | + } |
|
| 1613 | 1685 | |
| 1614 | - foreach ($context['rules'] as $rule) |
|
| 1615 | - echo ' |
|
| 1686 | + foreach ($context['rules'] as $rule) { |
|
| 1687 | + echo ' |
|
| 1616 | 1688 | <tr class="windowbg"> |
| 1617 | 1689 | <td> |
| 1618 | 1690 | <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a> |
@@ -1621,6 +1693,7 @@ discard block |
||
| 1621 | 1693 | <input type="checkbox" name="delrule[', $rule['id'], ']"> |
| 1622 | 1694 | </td> |
| 1623 | 1695 | </tr>'; |
| 1696 | + } |
|
| 1624 | 1697 | |
| 1625 | 1698 | echo ' |
| 1626 | 1699 | </tbody> |
@@ -1628,14 +1701,16 @@ discard block |
||
| 1628 | 1701 | <div class="righttext"> |
| 1629 | 1702 | <a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
| 1630 | 1703 | |
| 1631 | - if (!empty($context['rules'])) |
|
| 1632 | - echo ' |
|
| 1704 | + if (!empty($context['rules'])) { |
|
| 1705 | + echo ' |
|
| 1633 | 1706 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
| 1707 | + } |
|
| 1634 | 1708 | |
| 1635 | - if (!empty($context['rules'])) |
|
| 1636 | - echo ' |
|
| 1709 | + if (!empty($context['rules'])) { |
|
| 1710 | + echo ' |
|
| 1637 | 1711 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1638 | 1712 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">'; |
| 1713 | + } |
|
| 1639 | 1714 | |
| 1640 | 1715 | echo ' |
| 1641 | 1716 | </div> |
@@ -1657,14 +1732,16 @@ discard block |
||
| 1657 | 1732 | var groups = new Array() |
| 1658 | 1733 | var labels = new Array()'; |
| 1659 | 1734 | |
| 1660 | - foreach ($context['groups'] as $id => $title) |
|
| 1661 | - echo ' |
|
| 1735 | + foreach ($context['groups'] as $id => $title) { |
|
| 1736 | + echo ' |
|
| 1662 | 1737 | groups[', $id, '] = "', addslashes($title), '";'; |
| 1738 | + } |
|
| 1663 | 1739 | |
| 1664 | - foreach ($context['labels'] as $label) |
|
| 1665 | - if ($label['id'] != -1) |
|
| 1740 | + foreach ($context['labels'] as $label) { |
|
| 1741 | + if ($label['id'] != -1) |
|
| 1666 | 1742 | echo ' |
| 1667 | 1743 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
| 1744 | + } |
|
| 1668 | 1745 | |
| 1669 | 1746 | echo ' |
| 1670 | 1747 | function addCriteriaOption() |
@@ -1679,8 +1756,9 @@ discard block |
||
| 1679 | 1756 | |
| 1680 | 1757 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
| 1681 | 1758 | |
| 1682 | - foreach ($context['groups'] as $id => $group) |
|
| 1683 | - echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1759 | + foreach ($context['groups'] as $id => $group) { |
|
| 1760 | + echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1761 | + } |
|
| 1684 | 1762 | |
| 1685 | 1763 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
| 1686 | 1764 | } |
@@ -1697,9 +1775,10 @@ discard block |
||
| 1697 | 1775 | |
| 1698 | 1776 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
| 1699 | 1777 | |
| 1700 | - foreach ($context['labels'] as $label) |
|
| 1701 | - if ($label['id'] != -1) |
|
| 1778 | + foreach ($context['labels'] as $label) { |
|
| 1779 | + if ($label['id'] != -1) |
|
| 1702 | 1780 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
| 1781 | + } |
|
| 1703 | 1782 | |
| 1704 | 1783 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
| 1705 | 1784 | } |
@@ -1813,19 +1892,20 @@ discard block |
||
| 1813 | 1892 | $isFirst = true; |
| 1814 | 1893 | foreach ($context['rule']['criteria'] as $k => $criteria) |
| 1815 | 1894 | { |
| 1816 | - if (!$isFirst && $criteria['t'] == '') |
|
| 1817 | - echo '<div id="removeonjs1">'; |
|
| 1818 | - |
|
| 1819 | - elseif (!$isFirst) |
|
| 1820 | - echo '<br>'; |
|
| 1895 | + if (!$isFirst && $criteria['t'] == '') { |
|
| 1896 | + echo '<div id="removeonjs1">'; |
|
| 1897 | + } elseif (!$isFirst) { |
|
| 1898 | + echo '<br>'; |
|
| 1899 | + } |
|
| 1821 | 1900 | |
| 1822 | 1901 | echo ' |
| 1823 | 1902 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
| 1824 | 1903 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
| 1825 | 1904 | |
| 1826 | - foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
|
| 1827 | - echo ' |
|
| 1905 | + foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) { |
|
| 1906 | + echo ' |
|
| 1828 | 1907 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
| 1908 | + } |
|
| 1829 | 1909 | |
| 1830 | 1910 | echo ' |
| 1831 | 1911 | </select> |
@@ -1836,19 +1916,20 @@ discard block |
||
| 1836 | 1916 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
| 1837 | 1917 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
| 1838 | 1918 | |
| 1839 | - foreach ($context['groups'] as $id => $group) |
|
| 1840 | - echo ' |
|
| 1919 | + foreach ($context['groups'] as $id => $group) { |
|
| 1920 | + echo ' |
|
| 1841 | 1921 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
| 1922 | + } |
|
| 1842 | 1923 | echo ' |
| 1843 | 1924 | </select> |
| 1844 | 1925 | </span>'; |
| 1845 | 1926 | |
| 1846 | 1927 | // If this is the dummy we add a means to hide for non js users. |
| 1847 | - if ($isFirst) |
|
| 1848 | - $isFirst = false; |
|
| 1849 | - |
|
| 1850 | - elseif ($criteria['t'] == '') |
|
| 1851 | - echo '</div><!-- .removeonjs1 -->'; |
|
| 1928 | + if ($isFirst) { |
|
| 1929 | + $isFirst = false; |
|
| 1930 | + } elseif ($criteria['t'] == '') { |
|
| 1931 | + echo '</div><!-- .removeonjs1 -->'; |
|
| 1932 | + } |
|
| 1852 | 1933 | } |
| 1853 | 1934 | |
| 1854 | 1935 | echo ' |
@@ -1871,10 +1952,11 @@ discard block |
||
| 1871 | 1952 | $isFirst = true; |
| 1872 | 1953 | foreach ($context['rule']['actions'] as $k => $action) |
| 1873 | 1954 | { |
| 1874 | - if (!$isFirst && $action['t'] == '') |
|
| 1875 | - echo '<div id="removeonjs2">'; |
|
| 1876 | - elseif (!$isFirst) |
|
| 1877 | - echo '<br>'; |
|
| 1955 | + if (!$isFirst && $action['t'] == '') { |
|
| 1956 | + echo '<div id="removeonjs2">'; |
|
| 1957 | + } elseif (!$isFirst) { |
|
| 1958 | + echo '<br>'; |
|
| 1959 | + } |
|
| 1878 | 1960 | |
| 1879 | 1961 | echo ' |
| 1880 | 1962 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
@@ -1886,20 +1968,21 @@ discard block |
||
| 1886 | 1968 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
| 1887 | 1969 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
| 1888 | 1970 | |
| 1889 | - foreach ($context['labels'] as $label) |
|
| 1890 | - if ($label['id'] != -1) |
|
| 1971 | + foreach ($context['labels'] as $label) { |
|
| 1972 | + if ($label['id'] != -1) |
|
| 1891 | 1973 | echo ' |
| 1892 | 1974 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
| 1975 | + } |
|
| 1893 | 1976 | |
| 1894 | 1977 | echo ' |
| 1895 | 1978 | </select> |
| 1896 | 1979 | </span>'; |
| 1897 | 1980 | |
| 1898 | - if ($isFirst) |
|
| 1899 | - $isFirst = false; |
|
| 1900 | - |
|
| 1901 | - elseif ($action['t'] == '') |
|
| 1902 | - echo '</div><!-- .removeonjs2 -->'; |
|
| 1981 | + if ($isFirst) { |
|
| 1982 | + $isFirst = false; |
|
| 1983 | + } elseif ($action['t'] == '') { |
|
| 1984 | + echo '</div><!-- .removeonjs2 -->'; |
|
| 1985 | + } |
|
| 1903 | 1986 | } |
| 1904 | 1987 | |
| 1905 | 1988 | echo ' |
@@ -1923,22 +2006,25 @@ discard block |
||
| 1923 | 2006 | echo ' |
| 1924 | 2007 | <script>'; |
| 1925 | 2008 | |
| 1926 | - foreach ($context['rule']['criteria'] as $k => $c) |
|
| 1927 | - echo ' |
|
| 2009 | + foreach ($context['rule']['criteria'] as $k => $c) { |
|
| 2010 | + echo ' |
|
| 1928 | 2011 | updateRuleDef(', $k, ');'; |
| 2012 | + } |
|
| 1929 | 2013 | |
| 1930 | - foreach ($context['rule']['actions'] as $k => $c) |
|
| 1931 | - echo ' |
|
| 2014 | + foreach ($context['rule']['actions'] as $k => $c) { |
|
| 2015 | + echo ' |
|
| 1932 | 2016 | updateActionDef(', $k, ');'; |
| 2017 | + } |
|
| 1933 | 2018 | |
| 1934 | 2019 | echo ' |
| 1935 | 2020 | rebuildRuleDesc();'; |
| 1936 | 2021 | |
| 1937 | 2022 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
| 1938 | - if ($context['rid']) |
|
| 1939 | - echo ' |
|
| 2023 | + if ($context['rid']) { |
|
| 2024 | + echo ' |
|
| 1940 | 2025 | document.getElementById("removeonjs1").style.display = "none"; |
| 1941 | 2026 | document.getElementById("removeonjs2").style.display = "none";'; |
| 2027 | + } |
|
| 1942 | 2028 | |
| 1943 | 2029 | echo ' |
| 1944 | 2030 | document.getElementById("addonjs1").style.display = ""; |
@@ -1966,12 +2052,12 @@ discard block |
||
| 1966 | 2052 | </div>'; |
| 1967 | 2053 | |
| 1968 | 2054 | // No drafts? Just show an informative message. |
| 1969 | - if (empty($context['drafts'])) |
|
| 1970 | - echo ' |
|
| 2055 | + if (empty($context['drafts'])) { |
|
| 2056 | + echo ' |
|
| 1971 | 2057 | <div class="windowbg centertext"> |
| 1972 | 2058 | ', $txt['draft_none'], ' |
| 1973 | 2059 | </div>'; |
| 1974 | - else |
|
| 2060 | + } else |
|
| 1975 | 2061 | { |
| 1976 | 2062 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 1977 | 2063 | foreach ($context['drafts'] as $draft) |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | is_not_guest(); |
| 35 | 36 | |
| 36 | 37 | // You have to specify a board to turn notifications on! |
| 37 | - if (empty($board)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($board)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // No subaction: find out what to do. |
| 41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
| 48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
| 49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
| 50 | 52 | |
| 51 | - if ($mode > 1) |
|
| 52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | + if ($mode > 1) { |
|
| 54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | 55 | $smcFunc['db_insert']('ignore', |
| 54 | 56 | '{db_prefix}log_notify', |
| 55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
| 56 | 58 | array($user_info['id'], $board), |
| 57 | 59 | array('id_member', 'id_board') |
| 58 | 60 | ); |
| 59 | - else |
|
| 60 | - $smcFunc['db_query']('', ' |
|
| 61 | + } else { |
|
| 62 | + $smcFunc['db_query']('', ' |
|
| 61 | 63 | DELETE FROM {db_prefix}log_notify |
| 62 | 64 | WHERE id_member = {int:current_member} |
| 63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
| 66 | 68 | 'current_member' => $user_info['id'], |
| 67 | 69 | ) |
| 68 | 70 | ); |
| 71 | + } |
|
| 69 | 72 | } |
| 70 | 73 | |
| 71 | 74 | // Back to the board! |
@@ -80,10 +83,10 @@ discard block |
||
| 80 | 83 | ), |
| 81 | 84 | ); |
| 82 | 85 | $context['sub_template'] = 'generic_xml'; |
| 86 | + } else { |
|
| 87 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 88 | + } |
|
| 83 | 89 | } |
| 84 | - else |
|
| 85 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 86 | -} |
|
| 87 | 90 | |
| 88 | 91 | /** |
| 89 | 92 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -128,8 +131,7 @@ discard block |
||
| 128 | 131 | 'id_msg' => 0, |
| 129 | 132 | 'unwatched' => empty($mode) ? 1 : 0, |
| 130 | 133 | ); |
| 131 | - } |
|
| 132 | - else |
|
| 134 | + } else |
|
| 133 | 135 | { |
| 134 | 136 | $insert = false; |
| 135 | 137 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -156,9 +158,8 @@ discard block |
||
| 156 | 158 | array($user_info['id'], $log['id_topic']), |
| 157 | 159 | array('id_member', 'id_board') |
| 158 | 160 | ); |
| 159 | - } |
|
| 160 | - else |
|
| 161 | - $smcFunc['db_query']('', ' |
|
| 161 | + } else { |
|
| 162 | + $smcFunc['db_query']('', ' |
|
| 162 | 163 | DELETE FROM {db_prefix}log_notify |
| 163 | 164 | WHERE id_topic = {int:topic} |
| 164 | 165 | AND id_member = {int:member}', |
@@ -166,6 +167,7 @@ discard block |
||
| 166 | 167 | 'topic' => $log['id_topic'], |
| 167 | 168 | 'member' => $user_info['id'], |
| 168 | 169 | )); |
| 170 | + } |
|
| 169 | 171 | } |
| 170 | 172 | } |
| 171 | 173 | |
@@ -181,9 +183,9 @@ discard block |
||
| 181 | 183 | ), |
| 182 | 184 | ); |
| 183 | 185 | $context['sub_template'] = 'generic_xml'; |
| 186 | + } else { |
|
| 187 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 188 | + } |
|
| 184 | 189 | } |
| 185 | - else |
|
| 186 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 187 | -} |
|
| 188 | 190 | |
| 189 | 191 | ?> |
| 190 | 192 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | 53 | // Start displaying errors without fixing them. |
| 53 | - if (isset($_GET['fixErrors'])) |
|
| 54 | - checkSession('get'); |
|
| 54 | + if (isset($_GET['fixErrors'])) { |
|
| 55 | + checkSession('get'); |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // Will want this. |
| 57 | 59 | loadForumTests(); |
@@ -69,14 +71,14 @@ discard block |
||
| 69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
| 70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
| 71 | 73 | |
| 72 | - if (empty($context['repair_errors'])) |
|
| 73 | - $context['repair_errors'][] = '???'; |
|
| 74 | + if (empty($context['repair_errors'])) { |
|
| 75 | + $context['repair_errors'][] = '???'; |
|
| 76 | + } |
|
| 74 | 77 | } |
| 75 | 78 | |
| 76 | 79 | // Need a token here. |
| 77 | 80 | createToken('admin-repairboards', 'request'); |
| 78 | - } |
|
| 79 | - else |
|
| 81 | + } else |
|
| 80 | 82 | { |
| 81 | 83 | // Validate the token, create a new one and tell the not done template. |
| 82 | 84 | validateToken('admin-repairboards', 'request'); |
@@ -134,16 +136,19 @@ discard block |
||
| 134 | 136 | |
| 135 | 137 | // More time, I need more time! |
| 136 | 138 | @set_time_limit(600); |
| 137 | - if (function_exists('apache_reset_timeout')) |
|
| 138 | - @apache_reset_timeout(); |
|
| 139 | + if (function_exists('apache_reset_timeout')) { |
|
| 140 | + @apache_reset_timeout(); |
|
| 141 | + } |
|
| 139 | 142 | |
| 140 | 143 | // Errr, wait. How much time has this taken already? |
| 141 | - if (!$force && (time() - $time_start) < 3) |
|
| 142 | - return; |
|
| 144 | + if (!$force && (time() - $time_start) < 3) { |
|
| 145 | + return; |
|
| 146 | + } |
|
| 143 | 147 | |
| 144 | 148 | // Restore the query cache if interested. |
| 145 | - if (!empty($db_temp_cache)) |
|
| 146 | - $db_cache = $db_temp_cache; |
|
| 149 | + if (!empty($db_temp_cache)) { |
|
| 150 | + $db_cache = $db_temp_cache; |
|
| 151 | + } |
|
| 147 | 152 | |
| 148 | 153 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 149 | 154 | $context['page_title'] = $txt['not_done_title']; |
@@ -152,10 +157,11 @@ discard block |
||
| 152 | 157 | $context['sub_template'] = 'not_done'; |
| 153 | 158 | |
| 154 | 159 | // Change these two if more steps are added! |
| 155 | - if (empty($max_substep)) |
|
| 156 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 157 | - else |
|
| 158 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 160 | + if (empty($max_substep)) { |
|
| 161 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 162 | + } else { |
|
| 163 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 164 | + } |
|
| 159 | 165 | |
| 160 | 166 | // Never more than 100%! |
| 161 | 167 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -624,8 +630,9 @@ discard block |
||
| 624 | 630 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
| 625 | 631 | |
| 626 | 632 | // Not really a problem? |
| 627 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 628 | - return false; |
|
| 633 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 634 | + return false; |
|
| 635 | + } |
|
| 629 | 636 | |
| 630 | 637 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
| 631 | 638 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -649,15 +656,19 @@ discard block |
||
| 649 | 656 | 'message_function' => function ($row) use ($txt, &$context) |
| 650 | 657 | { |
| 651 | 658 | // A pretend error? |
| 652 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 653 | - return false; |
|
| 659 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 660 | + return false; |
|
| 661 | + } |
|
| 654 | 662 | |
| 655 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
| 656 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 657 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
| 658 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 659 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
| 660 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 663 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
| 664 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 665 | + } |
|
| 666 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
| 667 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 668 | + } |
|
| 669 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
| 670 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 671 | + } |
|
| 661 | 672 | |
| 662 | 673 | return true; |
| 663 | 674 | }, |
@@ -686,8 +697,9 @@ discard block |
||
| 686 | 697 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 687 | 698 | |
| 688 | 699 | // Not really a problem? |
| 689 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 690 | - return false; |
|
| 700 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 701 | + return false; |
|
| 702 | + } |
|
| 691 | 703 | |
| 692 | 704 | $smcFunc['db_query']('', ' |
| 693 | 705 | UPDATE {db_prefix}topics |
@@ -704,11 +716,13 @@ discard block |
||
| 704 | 716 | global $txt, $context; |
| 705 | 717 | |
| 706 | 718 | // Just joking? |
| 707 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 708 | - return false; |
|
| 719 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 720 | + return false; |
|
| 721 | + } |
|
| 709 | 722 | |
| 710 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
| 711 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 723 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
| 724 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 725 | + } |
|
| 712 | 726 | |
| 713 | 727 | return true; |
| 714 | 728 | }, |
@@ -1280,8 +1294,9 @@ discard block |
||
| 1280 | 1294 | $inserts = array(); |
| 1281 | 1295 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1282 | 1296 | { |
| 1283 | - foreach (text2words($row['subject']) as $word) |
|
| 1284 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1297 | + foreach (text2words($row['subject']) as $word) { |
|
| 1298 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1299 | + } |
|
| 1285 | 1300 | if (count($inserts) > 500) |
| 1286 | 1301 | { |
| 1287 | 1302 | $smcFunc['db_insert']('ignore', |
@@ -1294,13 +1309,14 @@ discard block |
||
| 1294 | 1309 | } |
| 1295 | 1310 | } |
| 1296 | 1311 | |
| 1297 | - if (!empty($inserts)) |
|
| 1298 | - $smcFunc['db_insert']('ignore', |
|
| 1312 | + if (!empty($inserts)) { |
|
| 1313 | + $smcFunc['db_insert']('ignore', |
|
| 1299 | 1314 | '{db_prefix}log_search_subjects', |
| 1300 | 1315 | array('word' => 'string', 'id_topic' => 'int'), |
| 1301 | 1316 | $inserts, |
| 1302 | 1317 | array('word', 'id_topic') |
| 1303 | 1318 | ); |
| 1319 | + } |
|
| 1304 | 1320 | }, |
| 1305 | 1321 | 'message_function' => function ($row) |
| 1306 | 1322 | { |
@@ -1559,8 +1575,9 @@ discard block |
||
| 1559 | 1575 | $current_step++; |
| 1560 | 1576 | |
| 1561 | 1577 | // Already done this? |
| 1562 | - if ($_GET['step'] > $current_step) |
|
| 1563 | - continue; |
|
| 1578 | + if ($_GET['step'] > $current_step) { |
|
| 1579 | + continue; |
|
| 1580 | + } |
|
| 1564 | 1581 | |
| 1565 | 1582 | // If we're fixing it but it ain't broke why try? |
| 1566 | 1583 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1589,14 +1606,16 @@ discard block |
||
| 1589 | 1606 | while (!$done) |
| 1590 | 1607 | { |
| 1591 | 1608 | // Make sure there's at least one ID to test. |
| 1592 | - if (isset($test['substeps']) && empty($step_max)) |
|
| 1593 | - break; |
|
| 1609 | + if (isset($test['substeps']) && empty($step_max)) { |
|
| 1610 | + break; |
|
| 1611 | + } |
|
| 1594 | 1612 | |
| 1595 | 1613 | // What is the testing query (Changes if we are testing or fixing) |
| 1596 | - if (!$do_fix) |
|
| 1597 | - $test_query = 'check_query'; |
|
| 1598 | - else |
|
| 1599 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1614 | + if (!$do_fix) { |
|
| 1615 | + $test_query = 'check_query'; |
|
| 1616 | + } else { |
|
| 1617 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1618 | + } |
|
| 1600 | 1619 | |
| 1601 | 1620 | // Do the test... |
| 1602 | 1621 | $request = $smcFunc['db_query']('', |
@@ -1606,10 +1625,11 @@ discard block |
||
| 1606 | 1625 | ); |
| 1607 | 1626 | |
| 1608 | 1627 | // Does it need a fix? |
| 1609 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
| 1610 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1611 | - else |
|
| 1612 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1628 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
| 1629 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1630 | + } else { |
|
| 1631 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1632 | + } |
|
| 1613 | 1633 | |
| 1614 | 1634 | $total_queries++; |
| 1615 | 1635 | |
@@ -1621,8 +1641,9 @@ discard block |
||
| 1621 | 1641 | // Assume need to fix. |
| 1622 | 1642 | $found_errors = true; |
| 1623 | 1643 | |
| 1624 | - if (isset($test['message'])) |
|
| 1625 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1644 | + if (isset($test['message'])) { |
|
| 1645 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1646 | + } |
|
| 1626 | 1647 | |
| 1627 | 1648 | // One per row! |
| 1628 | 1649 | elseif (isset($test['messages'])) |
@@ -1632,10 +1653,11 @@ discard block |
||
| 1632 | 1653 | $variables = $test['messages']; |
| 1633 | 1654 | foreach ($variables as $k => $v) |
| 1634 | 1655 | { |
| 1635 | - if ($k == 0 && isset($txt[$v])) |
|
| 1636 | - $variables[$k] = $txt[$v]; |
|
| 1637 | - elseif ($k > 0 && isset($row[$v])) |
|
| 1638 | - $variables[$k] = $row[$v]; |
|
| 1656 | + if ($k == 0 && isset($txt[$v])) { |
|
| 1657 | + $variables[$k] = $txt[$v]; |
|
| 1658 | + } elseif ($k > 0 && isset($row[$v])) { |
|
| 1659 | + $variables[$k] = $row[$v]; |
|
| 1660 | + } |
|
| 1639 | 1661 | } |
| 1640 | 1662 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1641 | 1663 | } |
@@ -1646,13 +1668,15 @@ discard block |
||
| 1646 | 1668 | { |
| 1647 | 1669 | // Find out if there are actually errors. |
| 1648 | 1670 | $found_errors = false; |
| 1649 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1650 | - $found_errors |= $test['message_function']($row); |
|
| 1671 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1672 | + $found_errors |= $test['message_function']($row); |
|
| 1673 | + } |
|
| 1651 | 1674 | } |
| 1652 | 1675 | |
| 1653 | 1676 | // Actually have something to fix? |
| 1654 | - if ($found_errors) |
|
| 1655 | - $to_fix[] = $error_type; |
|
| 1677 | + if ($found_errors) { |
|
| 1678 | + $to_fix[] = $error_type; |
|
| 1679 | + } |
|
| 1656 | 1680 | } |
| 1657 | 1681 | |
| 1658 | 1682 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1662,8 +1686,9 @@ discard block |
||
| 1662 | 1686 | if (isset($test['fix_collect'])) |
| 1663 | 1687 | { |
| 1664 | 1688 | $ids = array(); |
| 1665 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1666 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1689 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1690 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1691 | + } |
|
| 1667 | 1692 | if (!empty($ids)) |
| 1668 | 1693 | { |
| 1669 | 1694 | // Fix it! |
@@ -1672,30 +1697,34 @@ discard block |
||
| 1672 | 1697 | } |
| 1673 | 1698 | |
| 1674 | 1699 | // Simply executing a fix it query? |
| 1675 | - elseif (isset($test['fix_it_query'])) |
|
| 1676 | - $smcFunc['db_query']('', |
|
| 1700 | + elseif (isset($test['fix_it_query'])) { |
|
| 1701 | + $smcFunc['db_query']('', |
|
| 1677 | 1702 | $test['fix_it_query'], |
| 1678 | 1703 | array( |
| 1679 | 1704 | ) |
| 1680 | 1705 | ); |
| 1706 | + } |
|
| 1681 | 1707 | |
| 1682 | 1708 | // Do we have some processing to do? |
| 1683 | 1709 | elseif (isset($test['fix_processing'])) |
| 1684 | 1710 | { |
| 1685 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1686 | - $test['fix_processing']($row); |
|
| 1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1712 | + $test['fix_processing']($row); |
|
| 1713 | + } |
|
| 1687 | 1714 | } |
| 1688 | 1715 | |
| 1689 | 1716 | // What about the full set of processing? |
| 1690 | - elseif (isset($test['fix_full_processing'])) |
|
| 1691 | - $test['fix_full_processing']($request); |
|
| 1717 | + elseif (isset($test['fix_full_processing'])) { |
|
| 1718 | + $test['fix_full_processing']($request); |
|
| 1719 | + } |
|
| 1692 | 1720 | |
| 1693 | 1721 | // Do we have other things we need to fix as a result? |
| 1694 | 1722 | if (!empty($test['force_fix'])) |
| 1695 | 1723 | { |
| 1696 | - foreach ($test['force_fix'] as $item) |
|
| 1697 | - if (!in_array($item, $to_fix)) |
|
| 1724 | + foreach ($test['force_fix'] as $item) { |
|
| 1725 | + if (!in_array($item, $to_fix)) |
|
| 1698 | 1726 | $to_fix[] = $item; |
| 1727 | + } |
|
| 1699 | 1728 | } |
| 1700 | 1729 | } |
| 1701 | 1730 | } |
@@ -1713,16 +1742,17 @@ discard block |
||
| 1713 | 1742 | if ($_GET['substep'] <= $step_max) |
| 1714 | 1743 | { |
| 1715 | 1744 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1745 | + } else { |
|
| 1746 | + $done = true; |
|
| 1716 | 1747 | } |
| 1717 | - else |
|
| 1718 | - $done = true; |
|
| 1748 | + } else { |
|
| 1749 | + $done = true; |
|
| 1719 | 1750 | } |
| 1720 | - else |
|
| 1721 | - $done = true; |
|
| 1722 | 1751 | |
| 1723 | 1752 | // Don't allow more than 1000 queries at a time. |
| 1724 | - if ($total_queries >= 1000) |
|
| 1725 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1753 | + if ($total_queries >= 1000) { |
|
| 1754 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1755 | + } |
|
| 1726 | 1756 | } |
| 1727 | 1757 | |
| 1728 | 1758 | // Keep going. |
@@ -1735,8 +1765,9 @@ discard block |
||
| 1735 | 1765 | if ($do_fix) |
| 1736 | 1766 | { |
| 1737 | 1767 | $key = array_search($error_type, $to_fix); |
| 1738 | - if ($key !== false && isset($to_fix[$key])) |
|
| 1739 | - unset($to_fix[$key]); |
|
| 1768 | + if ($key !== false && isset($to_fix[$key])) { |
|
| 1769 | + unset($to_fix[$key]); |
|
| 1770 | + } |
|
| 1740 | 1771 | } |
| 1741 | 1772 | |
| 1742 | 1773 | // Are we done? |
@@ -1759,10 +1790,11 @@ discard block |
||
| 1759 | 1790 | static $createOnce = false; |
| 1760 | 1791 | |
| 1761 | 1792 | // Have we already created it? |
| 1762 | - if ($createOnce) |
|
| 1763 | - return; |
|
| 1764 | - else |
|
| 1765 | - $createOnce = true; |
|
| 1793 | + if ($createOnce) { |
|
| 1794 | + return; |
|
| 1795 | + } else { |
|
| 1796 | + $createOnce = true; |
|
| 1797 | + } |
|
| 1766 | 1798 | |
| 1767 | 1799 | // Back to the forum's default language. |
| 1768 | 1800 | loadLanguage('Admin', $language); |
@@ -1777,8 +1809,9 @@ discard block |
||
| 1777 | 1809 | 'cat_name' => $txt['salvaged_category_name'], |
| 1778 | 1810 | ) |
| 1779 | 1811 | ); |
| 1780 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1781 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1812 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1813 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1814 | + } |
|
| 1782 | 1815 | $smcFunc['db_free_result']($result); |
| 1783 | 1816 | |
| 1784 | 1817 | if (empty($salvageCatID)) |
@@ -1810,8 +1843,9 @@ discard block |
||
| 1810 | 1843 | 'board_name' => $txt['salvaged_board_name'], |
| 1811 | 1844 | ) |
| 1812 | 1845 | ); |
| 1813 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1814 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1846 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1847 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1848 | + } |
|
| 1815 | 1849 | $smcFunc['db_free_result']($result); |
| 1816 | 1850 | |
| 1817 | 1851 | if (empty($salvageBoardID)) |
@@ -61,9 +61,10 @@ discard block |
||
| 61 | 61 | ', implode(', ', $context['administrators']); |
| 62 | 62 | |
| 63 | 63 | // If we have lots of admins... don't show them all. |
| 64 | - if (!empty($context['more_admins_link'])) |
|
| 65 | - echo ' |
|
| 64 | + if (!empty($context['more_admins_link'])) { |
|
| 65 | + echo ' |
|
| 66 | 66 | (', $context['more_admins_link'], ')'; |
| 67 | + } |
|
| 67 | 68 | |
| 68 | 69 | echo ' |
| 69 | 70 | </div><!-- #version_details --> |
@@ -80,17 +81,19 @@ discard block |
||
| 80 | 81 | foreach ($area['areas'] as $item_id => $item) |
| 81 | 82 | { |
| 82 | 83 | // No point showing the 'home' page here, we're already on it! |
| 83 | - if ($area_id == 'forum' && $item_id == 'index') |
|
| 84 | - continue; |
|
| 84 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 85 | 87 | |
| 86 | 88 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
| 87 | 89 | |
| 88 | - if (!empty($item['icon_file'])) |
|
| 89 | - echo ' |
|
| 90 | + if (!empty($item['icon_file'])) { |
|
| 91 | + echo ' |
|
| 90 | 92 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
| 91 | - else |
|
| 92 | - echo ' |
|
| 93 | + } else { |
|
| 94 | + echo ' |
|
| 93 | 95 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
| 96 | + } |
|
| 94 | 97 | } |
| 95 | 98 | |
| 96 | 99 | echo ' |
@@ -98,10 +101,11 @@ discard block |
||
| 98 | 101 | } |
| 99 | 102 | |
| 100 | 103 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
| 101 | - if (empty($modSettings['disable_smf_js'])) |
|
| 102 | - echo ' |
|
| 104 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 105 | + echo ' |
|
| 103 | 106 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
| 104 | 107 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 108 | + } |
|
| 105 | 109 | |
| 106 | 110 | // This sets the announcements and current versions themselves ;). |
| 107 | 111 | echo ' |
@@ -178,9 +182,10 @@ discard block |
||
| 178 | 182 | <em>', $version['version'], '</em>'; |
| 179 | 183 | |
| 180 | 184 | // more details for this item, show them a link |
| 181 | - if ($context['can_admin'] && isset($version['more'])) |
|
| 182 | - echo |
|
| 185 | + if ($context['can_admin'] && isset($version['more'])) { |
|
| 186 | + echo |
|
| 183 | 187 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
| 188 | + } |
|
| 184 | 189 | echo ' |
| 185 | 190 | <br>'; |
| 186 | 191 | } |
@@ -211,21 +216,23 @@ discard block |
||
| 211 | 216 | |
| 212 | 217 | foreach ($context['credits'] as $section) |
| 213 | 218 | { |
| 214 | - if (isset($section['pretext'])) |
|
| 215 | - echo ' |
|
| 219 | + if (isset($section['pretext'])) { |
|
| 220 | + echo ' |
|
| 216 | 221 | <p>', $section['pretext'], '</p> |
| 217 | 222 | <hr>'; |
| 223 | + } |
|
| 218 | 224 | |
| 219 | 225 | echo ' |
| 220 | 226 | <dl>'; |
| 221 | 227 | |
| 222 | 228 | foreach ($section['groups'] as $group) |
| 223 | 229 | { |
| 224 | - if (isset($group['title'])) |
|
| 225 | - echo ' |
|
| 230 | + if (isset($group['title'])) { |
|
| 231 | + echo ' |
|
| 226 | 232 | <dt> |
| 227 | 233 | <strong>', $group['title'], ':</strong> |
| 228 | 234 | </dt>'; |
| 235 | + } |
|
| 229 | 236 | |
| 230 | 237 | echo ' |
| 231 | 238 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -234,10 +241,11 @@ discard block |
||
| 234 | 241 | echo ' |
| 235 | 242 | </dl>'; |
| 236 | 243 | |
| 237 | - if (isset($section['posttext'])) |
|
| 238 | - echo ' |
|
| 244 | + if (isset($section['posttext'])) { |
|
| 245 | + echo ' |
|
| 239 | 246 | <hr> |
| 240 | 247 | <p>', $section['posttext'], '</p>'; |
| 248 | + } |
|
| 241 | 249 | } |
| 242 | 250 | |
| 243 | 251 | echo ' |
@@ -252,9 +260,10 @@ discard block |
||
| 252 | 260 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
| 253 | 261 | |
| 254 | 262 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
| 255 | - foreach ($context['current_versions'] as $variable => $version) |
|
| 256 | - echo ' |
|
| 263 | + foreach ($context['current_versions'] as $variable => $version) { |
|
| 264 | + echo ' |
|
| 257 | 265 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
| 266 | + } |
|
| 258 | 267 | |
| 259 | 268 | // Now we just have to include the script and wait ;). |
| 260 | 269 | echo ' |
@@ -350,8 +359,8 @@ discard block |
||
| 350 | 359 | <tbody>'; |
| 351 | 360 | |
| 352 | 361 | // Loop through every source file displaying its version - using javascript. |
| 353 | - foreach ($context['file_versions'] as $filename => $version) |
|
| 354 | - echo ' |
|
| 362 | + foreach ($context['file_versions'] as $filename => $version) { |
|
| 363 | + echo ' |
|
| 355 | 364 | <tr class="windowbg"> |
| 356 | 365 | <td class="half_table"> |
| 357 | 366 | ', $filename, ' |
@@ -363,6 +372,7 @@ discard block |
||
| 363 | 372 | <em id="currentSources', $filename, '">??</em> |
| 364 | 373 | </td> |
| 365 | 374 | </tr>'; |
| 375 | + } |
|
| 366 | 376 | |
| 367 | 377 | // Default template files. |
| 368 | 378 | echo ' |
@@ -388,8 +398,8 @@ discard block |
||
| 388 | 398 | <table id="Default" class="table_grid"> |
| 389 | 399 | <tbody>'; |
| 390 | 400 | |
| 391 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
| 392 | - echo ' |
|
| 401 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
| 402 | + echo ' |
|
| 393 | 403 | <tr class="windowbg"> |
| 394 | 404 | <td class="half_table"> |
| 395 | 405 | ', $filename, ' |
@@ -401,6 +411,7 @@ discard block |
||
| 401 | 411 | <em id="currentDefault', $filename, '">??</em> |
| 402 | 412 | </td> |
| 403 | 413 | </tr>'; |
| 414 | + } |
|
| 404 | 415 | |
| 405 | 416 | // Now the language files... |
| 406 | 417 | echo ' |
@@ -428,8 +439,8 @@ discard block |
||
| 428 | 439 | |
| 429 | 440 | foreach ($context['default_language_versions'] as $language => $files) |
| 430 | 441 | { |
| 431 | - foreach ($files as $filename => $version) |
|
| 432 | - echo ' |
|
| 442 | + foreach ($files as $filename => $version) { |
|
| 443 | + echo ' |
|
| 433 | 444 | <tr class="windowbg"> |
| 434 | 445 | <td class="half_table"> |
| 435 | 446 | ', $filename, '.<em>', $language, '</em>.php |
@@ -441,6 +452,7 @@ discard block |
||
| 441 | 452 | <em id="current', $filename, '.', $language, '">??</em> |
| 442 | 453 | </td> |
| 443 | 454 | </tr>'; |
| 455 | + } |
|
| 444 | 456 | } |
| 445 | 457 | |
| 446 | 458 | echo ' |
@@ -470,8 +482,8 @@ discard block |
||
| 470 | 482 | <table id="Templates" class="table_grid"> |
| 471 | 483 | <tbody>'; |
| 472 | 484 | |
| 473 | - foreach ($context['template_versions'] as $filename => $version) |
|
| 474 | - echo ' |
|
| 485 | + foreach ($context['template_versions'] as $filename => $version) { |
|
| 486 | + echo ' |
|
| 475 | 487 | <tr class="windowbg"> |
| 476 | 488 | <td class="half_table"> |
| 477 | 489 | ', $filename, ' |
@@ -483,6 +495,7 @@ discard block |
||
| 483 | 495 | <em id="currentTemplates', $filename, '">??</em> |
| 484 | 496 | </td> |
| 485 | 497 | </tr>'; |
| 498 | + } |
|
| 486 | 499 | |
| 487 | 500 | echo ' |
| 488 | 501 | </tbody> |
@@ -512,8 +525,8 @@ discard block |
||
| 512 | 525 | <table id="Tasks" class="table_grid"> |
| 513 | 526 | <tbody>'; |
| 514 | 527 | |
| 515 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
| 516 | - echo ' |
|
| 528 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
| 529 | + echo ' |
|
| 517 | 530 | <tr class="windowbg"> |
| 518 | 531 | <td class="half_table"> |
| 519 | 532 | ', $filename, ' |
@@ -525,6 +538,7 @@ discard block |
||
| 525 | 538 | <em id="currentTasks', $filename, '">??</em> |
| 526 | 539 | </td> |
| 527 | 540 | </tr>'; |
| 541 | + } |
|
| 528 | 542 | |
| 529 | 543 | echo ' |
| 530 | 544 | </tbody> |
@@ -565,9 +579,10 @@ discard block |
||
| 565 | 579 | { |
| 566 | 580 | global $context, $scripturl, $txt, $modSettings; |
| 567 | 581 | |
| 568 | - if (!empty($context['saved_successful'])) |
|
| 569 | - echo ' |
|
| 582 | + if (!empty($context['saved_successful'])) { |
|
| 583 | + echo ' |
|
| 570 | 584 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 585 | + } |
|
| 571 | 586 | |
| 572 | 587 | // First section is for adding/removing words from the censored list. |
| 573 | 588 | echo ' |
@@ -581,11 +596,12 @@ discard block |
||
| 581 | 596 | <p>', $txt['admin_censored_where'], '</p>'; |
| 582 | 597 | |
| 583 | 598 | // Show text boxes for censoring [bad ] => [good ]. |
| 584 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
| 585 | - echo ' |
|
| 599 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
| 600 | + echo ' |
|
| 586 | 601 | <div class="block"> |
| 587 | 602 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
| 588 | 603 | </div>'; |
| 604 | + } |
|
| 589 | 605 | |
| 590 | 606 | // Now provide a way to censor more words. |
| 591 | 607 | echo ' |
@@ -658,27 +674,30 @@ discard block |
||
| 658 | 674 | <div class="windowbg"> |
| 659 | 675 | ', $txt['not_done_reason']; |
| 660 | 676 | |
| 661 | - if (!empty($context['continue_percent'])) |
|
| 662 | - echo ' |
|
| 677 | + if (!empty($context['continue_percent'])) { |
|
| 678 | + echo ' |
|
| 663 | 679 | <div class="progress_bar"> |
| 664 | 680 | <span>', $context['continue_percent'], '%</span> |
| 665 | 681 | <div class="bar" style="width: ', $context['continue_percent'], '%;"></div> |
| 666 | 682 | </div>'; |
| 683 | + } |
|
| 667 | 684 | |
| 668 | - if (!empty($context['substep_enabled'])) |
|
| 669 | - echo ' |
|
| 685 | + if (!empty($context['substep_enabled'])) { |
|
| 686 | + echo ' |
|
| 670 | 687 | <div class="progress_bar progress_blue"> |
| 671 | 688 | <span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span> |
| 672 | 689 | <div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div> |
| 673 | 690 | </div>'; |
| 691 | + } |
|
| 674 | 692 | |
| 675 | 693 | echo ' |
| 676 | 694 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">'; |
| 677 | 695 | |
| 678 | 696 | // Do we have a token? |
| 679 | - if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) |
|
| 680 | - echo ' |
|
| 697 | + if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) { |
|
| 698 | + echo ' |
|
| 681 | 699 | <input type="hidden" name="', $context[$context['not_done_token'] . '_token_var'], '" value="', $context[$context['not_done_token'] . '_token'], '">'; |
| 700 | + } |
|
| 682 | 701 | |
| 683 | 702 | echo ' |
| 684 | 703 | <input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="button"> |
@@ -711,34 +730,39 @@ discard block |
||
| 711 | 730 | { |
| 712 | 731 | global $context, $txt, $scripturl; |
| 713 | 732 | |
| 714 | - if (!empty($context['saved_successful'])) |
|
| 715 | - echo ' |
|
| 733 | + if (!empty($context['saved_successful'])) { |
|
| 734 | + echo ' |
|
| 716 | 735 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 717 | - elseif (!empty($context['saved_failed'])) |
|
| 718 | - echo ' |
|
| 736 | + } elseif (!empty($context['saved_failed'])) { |
|
| 737 | + echo ' |
|
| 719 | 738 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
| 739 | + } |
|
| 720 | 740 | |
| 721 | - if (!empty($context['settings_pre_javascript'])) |
|
| 722 | - echo ' |
|
| 741 | + if (!empty($context['settings_pre_javascript'])) { |
|
| 742 | + echo ' |
|
| 723 | 743 | <script>', $context['settings_pre_javascript'], '</script>'; |
| 744 | + } |
|
| 724 | 745 | |
| 725 | - if (!empty($context['settings_insert_above'])) |
|
| 726 | - echo $context['settings_insert_above']; |
|
| 746 | + if (!empty($context['settings_insert_above'])) { |
|
| 747 | + echo $context['settings_insert_above']; |
|
| 748 | + } |
|
| 727 | 749 | |
| 728 | 750 | echo ' |
| 729 | 751 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
| 730 | 752 | |
| 731 | 753 | // Is there a custom title? |
| 732 | - if (isset($context['settings_title'])) |
|
| 733 | - echo ' |
|
| 754 | + if (isset($context['settings_title'])) { |
|
| 755 | + echo ' |
|
| 734 | 756 | <div class="cat_bar"> |
| 735 | 757 | <h3 class="catbg">', $context['settings_title'], '</h3> |
| 736 | 758 | </div>'; |
| 759 | + } |
|
| 737 | 760 | |
| 738 | 761 | // Have we got a message to display? |
| 739 | - if (!empty($context['settings_message'])) |
|
| 740 | - echo ' |
|
| 762 | + if (!empty($context['settings_message'])) { |
|
| 763 | + echo ' |
|
| 741 | 764 | <div class="information">', $context['settings_message'], '</div>'; |
| 765 | + } |
|
| 742 | 766 | |
| 743 | 767 | // Now actually loop through all the variables. |
| 744 | 768 | $is_open = false; |
@@ -791,8 +815,9 @@ discard block |
||
| 791 | 815 | // Hang about? Are you pulling my leg - a callback?! |
| 792 | 816 | if (is_array($config_var) && $config_var['type'] == 'callback') |
| 793 | 817 | { |
| 794 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
| 795 | - call_user_func('template_callback_' . $config_var['name']); |
|
| 818 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
| 819 | + call_user_func('template_callback_' . $config_var['name']); |
|
| 820 | + } |
|
| 796 | 821 | |
| 797 | 822 | continue; |
| 798 | 823 | } |
@@ -822,9 +847,10 @@ discard block |
||
| 822 | 847 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
| 823 | 848 | |
| 824 | 849 | // Show the [?] button. |
| 825 | - if ($config_var['help']) |
|
| 826 | - echo ' |
|
| 850 | + if ($config_var['help']) { |
|
| 851 | + echo ' |
|
| 827 | 852 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
| 853 | + } |
|
| 828 | 854 | |
| 829 | 855 | echo ' |
| 830 | 856 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -833,23 +859,26 @@ discard block |
||
| 833 | 859 | $config_var['preinput']; |
| 834 | 860 | |
| 835 | 861 | // Show a check box. |
| 836 | - if ($config_var['type'] == 'check') |
|
| 837 | - echo ' |
|
| 862 | + if ($config_var['type'] == 'check') { |
|
| 863 | + echo ' |
|
| 838 | 864 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
| 865 | + } |
|
| 839 | 866 | // Escape (via htmlspecialchars.) the text box. |
| 840 | - elseif ($config_var['type'] == 'password') |
|
| 841 | - echo ' |
|
| 867 | + elseif ($config_var['type'] == 'password') { |
|
| 868 | + echo ' |
|
| 842 | 869 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
| 843 | 870 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
| 871 | + } |
|
| 844 | 872 | // Show a selection box. |
| 845 | 873 | elseif ($config_var['type'] == 'select') |
| 846 | 874 | { |
| 847 | 875 | echo ' |
| 848 | 876 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
| 849 | 877 | |
| 850 | - foreach ($config_var['data'] as $option) |
|
| 851 | - echo ' |
|
| 878 | + foreach ($config_var['data'] as $option) { |
|
| 879 | + echo ' |
|
| 852 | 880 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
| 881 | + } |
|
| 853 | 882 | echo ' |
| 854 | 883 | </select>'; |
| 855 | 884 | } |
@@ -866,16 +895,18 @@ discard block |
||
| 866 | 895 | |
| 867 | 896 | foreach ($context['board_list'] as $id_cat => $cat) |
| 868 | 897 | { |
| 869 | - if (!$first) |
|
| 870 | - echo ' |
|
| 898 | + if (!$first) { |
|
| 899 | + echo ' |
|
| 871 | 900 | <hr>'; |
| 901 | + } |
|
| 872 | 902 | echo ' |
| 873 | 903 | <strong>', $cat['name'], '</strong> |
| 874 | 904 | <ul>'; |
| 875 | 905 | |
| 876 | - foreach ($cat['boards'] as $id_board => $brd) |
|
| 877 | - echo ' |
|
| 906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
| 907 | + echo ' |
|
| 878 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
| 909 | + } |
|
| 879 | 910 | |
| 880 | 911 | echo ' |
| 881 | 912 | </ul>'; |
@@ -885,12 +916,14 @@ discard block |
||
| 885 | 916 | </fieldset>'; |
| 886 | 917 | } |
| 887 | 918 | // Text area? |
| 888 | - elseif ($config_var['type'] == 'large_text') |
|
| 889 | - echo ' |
|
| 919 | + elseif ($config_var['type'] == 'large_text') { |
|
| 920 | + echo ' |
|
| 890 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
| 922 | + } |
|
| 891 | 923 | // Permission group? |
| 892 | - elseif ($config_var['type'] == 'permissions') |
|
| 893 | - theme_inline_permissions($config_var['name']); |
|
| 924 | + elseif ($config_var['type'] == 'permissions') { |
|
| 925 | + theme_inline_permissions($config_var['name']); |
|
| 926 | + } |
|
| 894 | 927 | |
| 895 | 928 | // BBC selection? |
| 896 | 929 | elseif ($config_var['type'] == 'bbc') |
@@ -902,22 +935,24 @@ discard block |
||
| 902 | 935 | |
| 903 | 936 | foreach ($context['bbc_columns'] as $bbcColumn) |
| 904 | 937 | { |
| 905 | - foreach ($bbcColumn as $bbcTag) |
|
| 906 | - echo ' |
|
| 938 | + foreach ($bbcColumn as $bbcTag) { |
|
| 939 | + echo ' |
|
| 907 | 940 | <li class="list_bbc floatleft"> |
| 908 | 941 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
| 909 | 942 | </li>'; |
| 943 | + } |
|
| 910 | 944 | } |
| 911 | 945 | echo ' </ul> |
| 912 | 946 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
| 913 | 947 | </fieldset>'; |
| 914 | 948 | } |
| 915 | 949 | // A simple message? |
| 916 | - elseif ($config_var['type'] == 'var_message') |
|
| 917 | - echo ' |
|
| 950 | + elseif ($config_var['type'] == 'var_message') { |
|
| 951 | + echo ' |
|
| 918 | 952 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '> |
| 919 | 953 | ', $config_var['var_message'], ' |
| 920 | 954 | </div>'; |
| 955 | + } |
|
| 921 | 956 | // Assume it must be a text box |
| 922 | 957 | else |
| 923 | 958 | { |
@@ -942,61 +977,69 @@ discard block |
||
| 942 | 977 | ' . $config_var['postinput'] : '',' |
| 943 | 978 | </dd>'; |
| 944 | 979 | } |
| 945 | - } |
|
| 946 | - else |
|
| 980 | + } else |
|
| 947 | 981 | { |
| 948 | 982 | // Just show a separator. |
| 949 | - if ($config_var == '') |
|
| 950 | - echo ' |
|
| 983 | + if ($config_var == '') { |
|
| 984 | + echo ' |
|
| 951 | 985 | </dl> |
| 952 | 986 | <hr> |
| 953 | 987 | <dl class="settings">'; |
| 954 | - else |
|
| 955 | - echo ' |
|
| 988 | + } else { |
|
| 989 | + echo ' |
|
| 956 | 990 | <dd> |
| 957 | 991 | <strong>' . $config_var . '</strong> |
| 958 | 992 | </dd>'; |
| 993 | + } |
|
| 959 | 994 | } |
| 960 | 995 | } |
| 961 | 996 | |
| 962 | - if ($is_open) |
|
| 963 | - echo ' |
|
| 997 | + if ($is_open) { |
|
| 998 | + echo ' |
|
| 964 | 999 | </dl>'; |
| 1000 | + } |
|
| 965 | 1001 | |
| 966 | - if (empty($context['settings_save_dont_show'])) |
|
| 967 | - echo ' |
|
| 1002 | + if (empty($context['settings_save_dont_show'])) { |
|
| 1003 | + echo ' |
|
| 968 | 1004 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
| 1005 | + } |
|
| 969 | 1006 | |
| 970 | - if ($is_open) |
|
| 971 | - echo ' |
|
| 1007 | + if ($is_open) { |
|
| 1008 | + echo ' |
|
| 972 | 1009 | </div><!-- .windowbg -->'; |
| 1010 | + } |
|
| 973 | 1011 | |
| 974 | 1012 | |
| 975 | 1013 | // At least one token has to be used! |
| 976 | - if (isset($context['admin-ssc_token'])) |
|
| 977 | - echo ' |
|
| 1014 | + if (isset($context['admin-ssc_token'])) { |
|
| 1015 | + echo ' |
|
| 978 | 1016 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
| 1017 | + } |
|
| 979 | 1018 | |
| 980 | - if (isset($context['admin-dbsc_token'])) |
|
| 981 | - echo ' |
|
| 1019 | + if (isset($context['admin-dbsc_token'])) { |
|
| 1020 | + echo ' |
|
| 982 | 1021 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
| 1022 | + } |
|
| 983 | 1023 | |
| 984 | - if (isset($context['admin-mp_token'])) |
|
| 985 | - echo ' |
|
| 1024 | + if (isset($context['admin-mp_token'])) { |
|
| 1025 | + echo ' |
|
| 986 | 1026 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
| 1027 | + } |
|
| 987 | 1028 | |
| 988 | 1029 | echo ' |
| 989 | 1030 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 990 | 1031 | </form>'; |
| 991 | 1032 | |
| 992 | - if (!empty($context['settings_post_javascript'])) |
|
| 993 | - echo ' |
|
| 1033 | + if (!empty($context['settings_post_javascript'])) { |
|
| 1034 | + echo ' |
|
| 994 | 1035 | <script> |
| 995 | 1036 | ', $context['settings_post_javascript'], ' |
| 996 | 1037 | </script>'; |
| 1038 | + } |
|
| 997 | 1039 | |
| 998 | - if (!empty($context['settings_insert_below'])) |
|
| 999 | - echo $context['settings_insert_below']; |
|
| 1040 | + if (!empty($context['settings_insert_below'])) { |
|
| 1041 | + echo $context['settings_insert_below']; |
|
| 1042 | + } |
|
| 1000 | 1043 | |
| 1001 | 1044 | // We may have added a board listing. If we did, we need to make it work. |
| 1002 | 1045 | addInlineJavascript(' |
@@ -1019,9 +1062,10 @@ discard block |
||
| 1019 | 1062 | { |
| 1020 | 1063 | global $context, $txt; |
| 1021 | 1064 | |
| 1022 | - if (!empty($context['saved_successful'])) |
|
| 1023 | - echo ' |
|
| 1065 | + if (!empty($context['saved_successful'])) { |
|
| 1066 | + echo ' |
|
| 1024 | 1067 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1068 | + } |
|
| 1025 | 1069 | |
| 1026 | 1070 | // Standard fields. |
| 1027 | 1071 | template_show_list('standard_profile_fields'); |
@@ -1055,11 +1099,12 @@ discard block |
||
| 1055 | 1099 | { |
| 1056 | 1100 | loadLanguage('Errors'); |
| 1057 | 1101 | |
| 1058 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
| 1059 | - echo ' |
|
| 1102 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
| 1103 | + echo ' |
|
| 1060 | 1104 | <div class="errorbox">', |
| 1061 | 1105 | $txt['custom_option_' . $_GET['msg']], ' |
| 1062 | 1106 | </div>'; |
| 1107 | + } |
|
| 1063 | 1108 | } |
| 1064 | 1109 | |
| 1065 | 1110 | echo ' |
@@ -1125,9 +1170,10 @@ discard block |
||
| 1125 | 1170 | <dd> |
| 1126 | 1171 | <select name="placement" id="placement">'; |
| 1127 | 1172 | |
| 1128 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
| 1129 | - echo ' |
|
| 1173 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
| 1174 | + echo ' |
|
| 1130 | 1175 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
| 1176 | + } |
|
| 1131 | 1177 | |
| 1132 | 1178 | echo ' |
| 1133 | 1179 | </select> |
@@ -1151,9 +1197,10 @@ discard block |
||
| 1151 | 1197 | <dd> |
| 1152 | 1198 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
| 1153 | 1199 | |
| 1154 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
| 1155 | - echo ' |
|
| 1200 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
| 1201 | + echo ' |
|
| 1156 | 1202 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
| 1203 | + } |
|
| 1157 | 1204 | |
| 1158 | 1205 | echo ' |
| 1159 | 1206 | </select> |
@@ -1185,9 +1232,10 @@ discard block |
||
| 1185 | 1232 | </dt> |
| 1186 | 1233 | <dd id="options_dd">'; |
| 1187 | 1234 | |
| 1188 | - foreach ($context['field']['options'] as $k => $option) |
|
| 1189 | - echo ' |
|
| 1235 | + foreach ($context['field']['options'] as $k => $option) { |
|
| 1236 | + echo ' |
|
| 1190 | 1237 | ', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">'; |
| 1238 | + } |
|
| 1191 | 1239 | |
| 1192 | 1240 | echo ' |
| 1193 | 1241 | <span id="addopt"></span> |
@@ -1251,9 +1299,10 @@ discard block |
||
| 1251 | 1299 | </fieldset> |
| 1252 | 1300 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
| 1253 | 1301 | |
| 1254 | - if ($context['fid']) |
|
| 1255 | - echo ' |
|
| 1302 | + if ($context['fid']) { |
|
| 1303 | + echo ' |
|
| 1256 | 1304 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
| 1305 | + } |
|
| 1257 | 1306 | |
| 1258 | 1307 | echo ' |
| 1259 | 1308 | </div><!-- .windowbg --> |
@@ -1299,8 +1348,7 @@ discard block |
||
| 1299 | 1348 | <p class="centertext"> |
| 1300 | 1349 | <strong>', $txt['admin_search_results_none'], '</strong> |
| 1301 | 1350 | </p>'; |
| 1302 | - } |
|
| 1303 | - else |
|
| 1351 | + } else |
|
| 1304 | 1352 | { |
| 1305 | 1353 | echo ' |
| 1306 | 1354 | <ol class="search_results">'; |
@@ -1327,9 +1375,10 @@ discard block |
||
| 1327 | 1375 | <li> |
| 1328 | 1376 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
| 1329 | 1377 | |
| 1330 | - if ($result['help']) |
|
| 1331 | - echo ' |
|
| 1378 | + if ($result['help']) { |
|
| 1379 | + echo ' |
|
| 1332 | 1380 | <p class="double_height">', $result['help'], '</p>'; |
| 1381 | + } |
|
| 1333 | 1382 | |
| 1334 | 1383 | echo ' |
| 1335 | 1384 | </li>'; |
@@ -1369,10 +1418,11 @@ discard block |
||
| 1369 | 1418 | <strong>', $txt['setup_verification_answer'], '</strong> |
| 1370 | 1419 | </dd>'; |
| 1371 | 1420 | |
| 1372 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 1373 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1421 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 1422 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1374 | 1423 | { |
| 1375 | 1424 | $question = $context['question_answers'][$q_id]; |
| 1425 | + } |
|
| 1376 | 1426 | |
| 1377 | 1427 | echo ' |
| 1378 | 1428 | <dt> |
@@ -1380,9 +1430,10 @@ discard block |
||
| 1380 | 1430 | </dt> |
| 1381 | 1431 | <dd>'; |
| 1382 | 1432 | |
| 1383 | - foreach ($question['answers'] as $answer) |
|
| 1384 | - echo ' |
|
| 1433 | + foreach ($question['answers'] as $answer) { |
|
| 1434 | + echo ' |
|
| 1385 | 1435 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
| 1436 | + } |
|
| 1386 | 1437 | |
| 1387 | 1438 | echo ' |
| 1388 | 1439 | <div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1420,11 +1471,12 @@ discard block |
||
| 1420 | 1471 | ', $txt['errors_found'], ': |
| 1421 | 1472 | <ul>'; |
| 1422 | 1473 | |
| 1423 | - foreach ($context['repair_errors'] as $error) |
|
| 1424 | - echo ' |
|
| 1474 | + foreach ($context['repair_errors'] as $error) { |
|
| 1475 | + echo ' |
|
| 1425 | 1476 | <li> |
| 1426 | 1477 | ', $error, ' |
| 1427 | 1478 | </li>'; |
| 1479 | + } |
|
| 1428 | 1480 | |
| 1429 | 1481 | echo ' |
| 1430 | 1482 | </ul> |
@@ -1434,15 +1486,14 @@ discard block |
||
| 1434 | 1486 | <p class="padding"> |
| 1435 | 1487 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-repairboards_token_var'], '=', $context['admin-repairboards_token'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
| 1436 | 1488 | </p>'; |
| 1437 | - } |
|
| 1438 | - else |
|
| 1439 | - echo ' |
|
| 1489 | + } else { |
|
| 1490 | + echo ' |
|
| 1440 | 1491 | <p>', $txt['maintain_no_errors'], '</p> |
| 1441 | 1492 | <p class="padding"> |
| 1442 | 1493 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
| 1443 | 1494 | </p>'; |
| 1444 | - } |
|
| 1445 | - else |
|
| 1495 | + } |
|
| 1496 | + } else |
|
| 1446 | 1497 | { |
| 1447 | 1498 | if (!empty($context['redirect_to_recount'])) |
| 1448 | 1499 | { |
@@ -1455,8 +1506,7 @@ discard block |
||
| 1455 | 1506 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1456 | 1507 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
| 1457 | 1508 | </form>'; |
| 1458 | - } |
|
| 1459 | - else |
|
| 1509 | + } else |
|
| 1460 | 1510 | { |
| 1461 | 1511 | echo ' |
| 1462 | 1512 | <p>', $txt['errors_fixed'], '</p> |
@@ -1546,9 +1596,10 @@ discard block |
||
| 1546 | 1596 | <tr class="windowbg"> |
| 1547 | 1597 | <td class="equal_table">', $key, '</td>'; |
| 1548 | 1598 | |
| 1549 | - foreach ($setting as $key_lm => $value) |
|
| 1550 | - echo ' |
|
| 1599 | + foreach ($setting as $key_lm => $value) { |
|
| 1600 | + echo ' |
|
| 1551 | 1601 | <td class="equal_table">', $value, '</td>'; |
| 1602 | + } |
|
| 1552 | 1603 | |
| 1553 | 1604 | echo ' |
| 1554 | 1605 | </tr>'; |
@@ -1608,8 +1659,8 @@ discard block |
||
| 1608 | 1659 | { |
| 1609 | 1660 | global $context, $txt; |
| 1610 | 1661 | |
| 1611 | - if ($context['user']['is_admin']) |
|
| 1612 | - echo ' |
|
| 1662 | + if ($context['user']['is_admin']) { |
|
| 1663 | + echo ' |
|
| 1613 | 1664 | <span class="floatright admin_search"> |
| 1614 | 1665 | <span class="generic_icons filter centericon"></span> |
| 1615 | 1666 | <input type="search" name="search_term" placeholder="', $txt['admin_search'], '"> |
@@ -1620,6 +1671,7 @@ discard block |
||
| 1620 | 1671 | </select> |
| 1621 | 1672 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
| 1622 | 1673 | </span>'; |
| 1623 | -} |
|
| 1674 | + } |
|
| 1675 | + } |
|
| 1624 | 1676 | |
| 1625 | 1677 | ?> |
| 1626 | 1678 | \ No newline at end of file |
@@ -18,11 +18,12 @@ discard block |
||
| 18 | 18 | global $context, $settings, $options, $scripturl, $modSettings, $txt; |
| 19 | 19 | |
| 20 | 20 | // Let them know why their message became unapproved. |
| 21 | - if ($context['becomesUnapproved']) |
|
| 22 | - echo ' |
|
| 21 | + if ($context['becomesUnapproved']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="noticebox"> |
| 24 | 24 | ', $txt['post_becomesUnapproved'], ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0)) |
| 28 | 29 | { |
@@ -46,17 +47,19 @@ discard block |
||
| 46 | 47 | </a>'; |
| 47 | 48 | |
| 48 | 49 | // Has it outstanding posts for approval? |
| 49 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 50 | - echo ' |
|
| 50 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 51 | + echo ' |
|
| 51 | 52 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | echo ' |
| 54 | 56 | <p class="board_description">', $board['description'], '</p>'; |
| 55 | 57 | |
| 56 | 58 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 57 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
| 58 | - echo ' |
|
| 59 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
| 60 | + echo ' |
|
| 59 | 61 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 62 | + } |
|
| 60 | 63 | |
| 61 | 64 | // Show some basic information about the number of posts, etc. |
| 62 | 65 | echo ' |
@@ -67,9 +70,10 @@ discard block |
||
| 67 | 70 | </div> |
| 68 | 71 | <div class="lastpost ', !empty($board['last_post']['id']) ? 'lpr_border' : 'hidden', '">'; |
| 69 | 72 | |
| 70 | - if (!empty($board['last_post']['id'])) |
|
| 71 | - echo ' |
|
| 73 | + if (!empty($board['last_post']['id'])) { |
|
| 74 | + echo ' |
|
| 72 | 75 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 76 | + } |
|
| 73 | 77 | |
| 74 | 78 | echo ' |
| 75 | 79 | </div>'; |
@@ -83,14 +87,16 @@ discard block |
||
| 83 | 87 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
| 84 | 88 | foreach ($board['children'] as $child) |
| 85 | 89 | { |
| 86 | - if (!$child['is_redirect']) |
|
| 87 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')" class="new_posts">' . $txt['new'] . '</a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 88 | - else |
|
| 89 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 90 | + if (!$child['is_redirect']) { |
|
| 91 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')" class="new_posts">' . $txt['new'] . '</a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 92 | + } else { |
|
| 93 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | // Has it posts awaiting approval? |
| 92 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
| 93 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 97 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
| 98 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 96 | 102 | } |
@@ -112,11 +118,12 @@ discard block |
||
| 112 | 118 | if (!$context['no_topic_listing']) |
| 113 | 119 | { |
| 114 | 120 | // Mobile action buttons (top) |
| 115 | - if (!empty($context['normal_buttons'])) |
|
| 116 | - echo ' |
|
| 121 | + if (!empty($context['normal_buttons'])) { |
|
| 122 | + echo ' |
|
| 117 | 123 | <div class="mobile_buttons floatright"> |
| 118 | 124 | <a class="button mobile_act">', $txt['mobile_action'], '</a> |
| 119 | 125 | </div>'; |
| 126 | + } |
|
| 120 | 127 | |
| 121 | 128 | echo ' |
| 122 | 129 | <div class="pagesection"> |
@@ -135,13 +142,15 @@ discard block |
||
| 135 | 142 | <h3>', $context['name'], '</h3> |
| 136 | 143 | <p>'; |
| 137 | 144 | |
| 138 | - if ($context['description'] != '') |
|
| 139 | - echo ' |
|
| 145 | + if ($context['description'] != '') { |
|
| 146 | + echo ' |
|
| 140 | 147 | ', $context['description']; |
| 148 | + } |
|
| 141 | 149 | |
| 142 | - if (!empty($context['moderators'])) |
|
| 143 | - echo ' |
|
| 150 | + if (!empty($context['moderators'])) { |
|
| 151 | + echo ' |
|
| 144 | 152 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
| 153 | + } |
|
| 145 | 154 | |
| 146 | 155 | echo ' |
| 147 | 156 | </p> |
@@ -149,9 +158,10 @@ discard block |
||
| 149 | 158 | } |
| 150 | 159 | |
| 151 | 160 | // If Quick Moderation is enabled start the form. |
| 152 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 153 | - echo ' |
|
| 161 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 162 | + echo ' |
|
| 154 | 163 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
| 164 | + } |
|
| 155 | 165 | |
| 156 | 166 | echo ' |
| 157 | 167 | <div id="messageindex">'; |
@@ -161,11 +171,11 @@ discard block |
||
| 161 | 171 | echo ' |
| 162 | 172 | <div class="information">'; |
| 163 | 173 | |
| 164 | - if ($settings['display_who_viewing'] == 1) |
|
| 165 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 166 | - |
|
| 167 | - else |
|
| 168 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 174 | + if ($settings['display_who_viewing'] == 1) { |
|
| 175 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 176 | + } else { |
|
| 177 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 178 | + } |
|
| 169 | 179 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
| 170 | 180 | |
| 171 | 181 | echo ' |
@@ -185,32 +195,36 @@ discard block |
||
| 185 | 195 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
| 186 | 196 | |
| 187 | 197 | // Show a "select all" box for quick moderation? |
| 188 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 189 | - echo ' |
|
| 198 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 199 | + echo ' |
|
| 190 | 200 | <div class="moderation"> |
| 191 | 201 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 192 | 202 | </div>'; |
| 203 | + } |
|
| 193 | 204 | |
| 194 | 205 | // If it's on in "image" mode, don't show anything but the column. |
| 195 | - elseif (!empty($context['can_quick_mod'])) |
|
| 196 | - echo ' |
|
| 206 | + elseif (!empty($context['can_quick_mod'])) { |
|
| 207 | + echo ' |
|
| 197 | 208 | <div class="moderation"></div>'; |
| 209 | + } |
|
| 198 | 210 | } |
| 199 | 211 | |
| 200 | 212 | // No topics... just say, "sorry bub". |
| 201 | - else |
|
| 202 | - echo ' |
|
| 213 | + else { |
|
| 214 | + echo ' |
|
| 203 | 215 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
| 216 | + } |
|
| 204 | 217 | |
| 205 | 218 | echo ' |
| 206 | 219 | </div><!-- #topic_header -->'; |
| 207 | 220 | |
| 208 | 221 | // If this person can approve items and we have some awaiting approval tell them. |
| 209 | - if (!empty($context['unapproved_posts_message'])) |
|
| 210 | - echo ' |
|
| 222 | + if (!empty($context['unapproved_posts_message'])) { |
|
| 223 | + echo ' |
|
| 211 | 224 | <div class="information"> |
| 212 | 225 | <span class="alert">!</span> ', $context['unapproved_posts_message'], ' |
| 213 | 226 | </div>'; |
| 227 | + } |
|
| 214 | 228 | |
| 215 | 229 | // Contain the topic list |
| 216 | 230 | echo ' |
@@ -231,25 +245,30 @@ discard block |
||
| 231 | 245 | echo ' |
| 232 | 246 | <div class="icons floatright">'; |
| 233 | 247 | |
| 234 | - if ($topic['is_watched']) |
|
| 235 | - echo ' |
|
| 248 | + if ($topic['is_watched']) { |
|
| 249 | + echo ' |
|
| 236 | 250 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
| 251 | + } |
|
| 237 | 252 | |
| 238 | - if ($topic['is_locked']) |
|
| 239 | - echo ' |
|
| 253 | + if ($topic['is_locked']) { |
|
| 254 | + echo ' |
|
| 240 | 255 | <span class="generic_icons lock"></span>'; |
| 256 | + } |
|
| 241 | 257 | |
| 242 | - if ($topic['is_sticky']) |
|
| 243 | - echo ' |
|
| 258 | + if ($topic['is_sticky']) { |
|
| 259 | + echo ' |
|
| 244 | 260 | <span class="generic_icons sticky"></span>'; |
| 261 | + } |
|
| 245 | 262 | |
| 246 | - if ($topic['is_redirect']) |
|
| 247 | - echo ' |
|
| 263 | + if ($topic['is_redirect']) { |
|
| 264 | + echo ' |
|
| 248 | 265 | <span class="generic_icons move"></span>'; |
| 266 | + } |
|
| 249 | 267 | |
| 250 | - if ($topic['is_poll']) |
|
| 251 | - echo ' |
|
| 268 | + if ($topic['is_poll']) { |
|
| 269 | + echo ' |
|
| 252 | 270 | <span class="generic_icons poll"></span>'; |
| 271 | + } |
|
| 253 | 272 | |
| 254 | 273 | echo ' |
| 255 | 274 | </div>'; |
@@ -281,26 +300,31 @@ discard block |
||
| 281 | 300 | echo ' |
| 282 | 301 | <div class="moderation">'; |
| 283 | 302 | |
| 284 | - if ($options['display_quick_mod'] == 1) |
|
| 285 | - echo ' |
|
| 303 | + if ($options['display_quick_mod'] == 1) { |
|
| 304 | + echo ' |
|
| 286 | 305 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
| 287 | - else |
|
| 306 | + } else |
|
| 288 | 307 | { |
| 289 | 308 | // Check permissions on each and show only the ones they are allowed to use. |
| 290 | - if ($topic['quick_mod']['remove']) |
|
| 291 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 309 | + if ($topic['quick_mod']['remove']) { |
|
| 310 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 311 | + } |
|
| 292 | 312 | |
| 293 | - if ($topic['quick_mod']['lock']) |
|
| 294 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 313 | + if ($topic['quick_mod']['lock']) { |
|
| 314 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 315 | + } |
|
| 295 | 316 | |
| 296 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
| 297 | - echo '<br>'; |
|
| 317 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
| 318 | + echo '<br>'; |
|
| 319 | + } |
|
| 298 | 320 | |
| 299 | - if ($topic['quick_mod']['sticky']) |
|
| 300 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 321 | + if ($topic['quick_mod']['sticky']) { |
|
| 322 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 323 | + } |
|
| 301 | 324 | |
| 302 | - if ($topic['quick_mod']['move']) |
|
| 303 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 325 | + if ($topic['quick_mod']['move']) { |
|
| 326 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 327 | + } |
|
| 304 | 328 | } |
| 305 | 329 | echo ' |
| 306 | 330 | </div><!-- .moderation -->'; |
@@ -318,18 +342,20 @@ discard block |
||
| 318 | 342 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
| 319 | 343 | <option value="">--------</option>'; |
| 320 | 344 | |
| 321 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
| 322 | - if ($context['can_' . $qmod_action]) |
|
| 345 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
| 346 | + if ($context['can_' . $qmod_action]) |
|
| 323 | 347 | echo ' |
| 324 | 348 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
| 349 | + } |
|
| 325 | 350 | |
| 326 | 351 | echo ' |
| 327 | 352 | </select>'; |
| 328 | 353 | |
| 329 | 354 | // Show a list of boards they can move the topic to. |
| 330 | - if ($context['can_move']) |
|
| 331 | - echo ' |
|
| 355 | + if ($context['can_move']) { |
|
| 356 | + echo ' |
|
| 332 | 357 | <span id="quick_mod_jump_to"></span>'; |
| 358 | + } |
|
| 333 | 359 | |
| 334 | 360 | echo ' |
| 335 | 361 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -340,17 +366,19 @@ discard block |
||
| 340 | 366 | </div><!-- #messageindex -->'; |
| 341 | 367 | |
| 342 | 368 | // Finish off the form - again. |
| 343 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 344 | - echo ' |
|
| 369 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 370 | + echo ' |
|
| 345 | 371 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
| 346 | 372 | </form>'; |
| 373 | + } |
|
| 347 | 374 | |
| 348 | 375 | // Mobile action buttons (bottom) |
| 349 | - if (!empty($context['normal_buttons'])) |
|
| 350 | - echo ' |
|
| 376 | + if (!empty($context['normal_buttons'])) { |
|
| 377 | + echo ' |
|
| 351 | 378 | <div class="mobile_buttons floatright"> |
| 352 | 379 | <a class="button mobile_act">', $txt['mobile_action'], '</a> |
| 353 | 380 | </div>'; |
| 381 | + } |
|
| 354 | 382 | |
| 355 | 383 | echo ' |
| 356 | 384 | <div class="pagesection"> |
@@ -366,8 +394,8 @@ discard block |
||
| 366 | 394 | // Show breadcrumbs at the bottom too. |
| 367 | 395 | theme_linktree(); |
| 368 | 396 | |
| 369 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
| 370 | - echo ' |
|
| 397 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
| 398 | + echo ' |
|
| 371 | 399 | <script> |
| 372 | 400 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 373 | 401 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -386,6 +414,7 @@ discard block |
||
| 386 | 414 | sCustomName: "move_to" |
| 387 | 415 | }); |
| 388 | 416 | </script>'; |
| 417 | + } |
|
| 389 | 418 | |
| 390 | 419 | // Javascript for inline editing. |
| 391 | 420 | echo ' |
@@ -422,8 +451,8 @@ discard block |
||
| 422 | 451 | <div class="information"> |
| 423 | 452 | <p class="floatright" id="message_index_jump_to"></p>'; |
| 424 | 453 | |
| 425 | - if (empty($context['no_topic_listing'])) |
|
| 426 | - echo ' |
|
| 454 | + if (empty($context['no_topic_listing'])) { |
|
| 455 | + echo ' |
|
| 427 | 456 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
| 428 | 457 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
| 429 | 458 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -433,9 +462,10 @@ discard block |
||
| 433 | 462 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
| 434 | 463 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
| 435 | 464 | </p>'; |
| 465 | + } |
|
| 436 | 466 | |
| 437 | - if (!empty($context['jump_to'])) |
|
| 438 | - echo ' |
|
| 467 | + if (!empty($context['jump_to'])) { |
|
| 468 | + echo ' |
|
| 439 | 469 | <script> |
| 440 | 470 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 441 | 471 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -451,6 +481,7 @@ discard block |
||
| 451 | 481 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
| 452 | 482 | }); |
| 453 | 483 | </script>'; |
| 484 | + } |
|
| 454 | 485 | |
| 455 | 486 | echo ' |
| 456 | 487 | <br class="clear"> |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 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 | * Log an error, if the error logging is enabled. |
@@ -39,10 +40,11 @@ discard block |
||
| 39 | 40 | $error_call++; |
| 40 | 41 | |
| 41 | 42 | // Collect a backtrace |
| 42 | - if (!isset($db_show_debug) || $db_show_debug === false) |
|
| 43 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
| 44 | - else |
|
| 45 | - $backtrace = debug_backtrace(); |
|
| 43 | + if (!isset($db_show_debug) || $db_show_debug === false) { |
|
| 44 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
| 45 | + } else { |
|
| 46 | + $backtrace = debug_backtrace(); |
|
| 47 | + } |
|
| 46 | 48 | |
| 47 | 49 | // are we in a loop? |
| 48 | 50 | if($error_call > 2) |
@@ -52,8 +54,9 @@ discard block |
||
| 52 | 54 | } |
| 53 | 55 | |
| 54 | 56 | // Check if error logging is actually on. |
| 55 | - if (empty($modSettings['enableErrorLogging'])) |
|
| 56 | - return $error_message; |
|
| 57 | + if (empty($modSettings['enableErrorLogging'])) { |
|
| 58 | + return $error_message; |
|
| 59 | + } |
|
| 57 | 60 | |
| 58 | 61 | // Basically, htmlspecialchars it minus &. (for entities!) |
| 59 | 62 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -61,33 +64,39 @@ discard block |
||
| 61 | 64 | |
| 62 | 65 | // Add a file and line to the error message? |
| 63 | 66 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
| 64 | - if ($file == null) |
|
| 65 | - $file = ''; |
|
| 66 | - else |
|
| 67 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
| 67 | + if ($file == null) { |
|
| 68 | + $file = ''; |
|
| 69 | + } else { |
|
| 70 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
| 68 | 71 | $file = str_replace('\\', '/', $file); |
| 72 | + } |
|
| 69 | 73 | |
| 70 | - if ($line == null) |
|
| 71 | - $line = 0; |
|
| 72 | - else |
|
| 73 | - $line = (int) $line; |
|
| 74 | + if ($line == null) { |
|
| 75 | + $line = 0; |
|
| 76 | + } else { |
|
| 77 | + $line = (int) $line; |
|
| 78 | + } |
|
| 74 | 79 | |
| 75 | 80 | // Just in case there's no id_member or IP set yet. |
| 76 | - if (empty($user_info['id'])) |
|
| 77 | - $user_info['id'] = 0; |
|
| 78 | - if (empty($user_info['ip'])) |
|
| 79 | - $user_info['ip'] = ''; |
|
| 81 | + if (empty($user_info['id'])) { |
|
| 82 | + $user_info['id'] = 0; |
|
| 83 | + } |
|
| 84 | + if (empty($user_info['ip'])) { |
|
| 85 | + $user_info['ip'] = ''; |
|
| 86 | + } |
|
| 80 | 87 | |
| 81 | 88 | // Find the best query string we can... |
| 82 | 89 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
| 83 | 90 | |
| 84 | 91 | // Don't log the session hash in the url twice, it's a waste. |
| 85 | - if (!empty($smcFunc['htmlspecialchars'])) |
|
| 86 | - $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
| 92 | + if (!empty($smcFunc['htmlspecialchars'])) { |
|
| 93 | + $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
| 94 | + } |
|
| 87 | 95 | |
| 88 | 96 | // Just so we know what board error messages are from. |
| 89 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
| 90 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 97 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
| 98 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 99 | + } |
|
| 91 | 100 | |
| 92 | 101 | // What types of categories do we have? |
| 93 | 102 | $known_error_types = array( |
@@ -140,9 +149,9 @@ discard block |
||
| 140 | 149 | |
| 141 | 150 | list($context['num_errors']) = $smcFunc['db_fetch_row']($query); |
| 142 | 151 | $smcFunc['db_free_result']($query); |
| 152 | + } else { |
|
| 153 | + $context['num_errors']++; |
|
| 143 | 154 | } |
| 144 | - else |
|
| 145 | - $context['num_errors']++; |
|
| 146 | 155 | } |
| 147 | 156 | |
| 148 | 157 | // reset error call |
@@ -164,12 +173,14 @@ discard block |
||
| 164 | 173 | global $txt; |
| 165 | 174 | |
| 166 | 175 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
| 167 | - if (!empty($status)) |
|
| 168 | - send_http_status($status); |
|
| 176 | + if (!empty($status)) { |
|
| 177 | + send_http_status($status); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | // We don't have $txt yet, but that's okay... |
| 171 | - if (empty($txt)) |
|
| 172 | - die($error); |
|
| 181 | + if (empty($txt)) { |
|
| 182 | + die($error); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | log_error_online($error, false); |
| 175 | 186 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -196,8 +207,9 @@ discard block |
||
| 196 | 207 | static $fatal_error_called = false; |
| 197 | 208 | |
| 198 | 209 | // Send the status header - set this to 0 or false if you don't want to send one at all |
| 199 | - if (!empty($status)) |
|
| 200 | - send_http_status($status); |
|
| 210 | + if (!empty($status)) { |
|
| 211 | + send_http_status($status); |
|
| 212 | + } |
|
| 201 | 213 | |
| 202 | 214 | // Try to load a theme if we don't have one. |
| 203 | 215 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -207,8 +219,9 @@ discard block |
||
| 207 | 219 | } |
| 208 | 220 | |
| 209 | 221 | // If we have no theme stuff we can't have the language file... |
| 210 | - if (empty($context['theme_loaded'])) |
|
| 211 | - die($error); |
|
| 222 | + if (empty($context['theme_loaded'])) { |
|
| 223 | + die($error); |
|
| 224 | + } |
|
| 212 | 225 | |
| 213 | 226 | $reload_lang_file = true; |
| 214 | 227 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -244,8 +257,9 @@ discard block |
||
| 244 | 257 | global $settings, $modSettings, $db_show_debug; |
| 245 | 258 | |
| 246 | 259 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
| 247 | - if (error_reporting() == 0) |
|
| 248 | - return; |
|
| 260 | + if (error_reporting() == 0) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 249 | 263 | |
| 250 | 264 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
| 251 | 265 | { |
@@ -253,19 +267,22 @@ discard block |
||
| 253 | 267 | $count = count($array); |
| 254 | 268 | for ($i = 0; $i < $count; $i++) |
| 255 | 269 | { |
| 256 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
| 257 | - continue; |
|
| 270 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
| 271 | + continue; |
|
| 272 | + } |
|
| 258 | 273 | |
| 259 | 274 | // This is a bug in PHP, with eval, it seems! |
| 260 | - if (empty($array[$i]['args'])) |
|
| 261 | - $i++; |
|
| 275 | + if (empty($array[$i]['args'])) { |
|
| 276 | + $i++; |
|
| 277 | + } |
|
| 262 | 278 | break; |
| 263 | 279 | } |
| 264 | 280 | |
| 265 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
| 266 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 267 | - else |
|
| 268 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 281 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
| 282 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 283 | + } else { |
|
| 284 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 285 | + } |
|
| 269 | 286 | } |
| 270 | 287 | |
| 271 | 288 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -274,8 +291,9 @@ discard block |
||
| 274 | 291 | if ($error_level % 255 != E_ERROR) |
| 275 | 292 | { |
| 276 | 293 | $temporary = ob_get_contents(); |
| 277 | - if (substr($temporary, -2) == '="') |
|
| 278 | - echo '"'; |
|
| 294 | + if (substr($temporary, -2) == '="') { |
|
| 295 | + echo '"'; |
|
| 296 | + } |
|
| 279 | 297 | } |
| 280 | 298 | |
| 281 | 299 | // Debugging! This should look like a PHP error message. |
@@ -291,23 +309,27 @@ discard block |
||
| 291 | 309 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
| 292 | 310 | |
| 293 | 311 | // Dying on these errors only causes MORE problems (blank pages!) |
| 294 | - if ($file == 'Unknown') |
|
| 295 | - return; |
|
| 312 | + if ($file == 'Unknown') { |
|
| 313 | + return; |
|
| 314 | + } |
|
| 296 | 315 | |
| 297 | 316 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 298 | - if ($error_level % 255 == E_ERROR) |
|
| 299 | - obExit(false); |
|
| 300 | - else |
|
| 301 | - return; |
|
| 317 | + if ($error_level % 255 == E_ERROR) { |
|
| 318 | + obExit(false); |
|
| 319 | + } else { |
|
| 320 | + return; |
|
| 321 | + } |
|
| 302 | 322 | |
| 303 | 323 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
| 304 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
| 305 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 324 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
| 325 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 326 | + } |
|
| 306 | 327 | |
| 307 | 328 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
| 308 | - if ($error_level % 255 == E_ERROR) |
|
| 309 | - die('No direct access...'); |
|
| 310 | -} |
|
| 329 | + if ($error_level % 255 == E_ERROR) { |
|
| 330 | + die('No direct access...'); |
|
| 331 | + } |
|
| 332 | + } |
|
| 311 | 333 | |
| 312 | 334 | /** |
| 313 | 335 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -323,24 +345,28 @@ discard block |
||
| 323 | 345 | |
| 324 | 346 | // Attempt to prevent a recursive loop. |
| 325 | 347 | ++$level; |
| 326 | - if ($level > 1) |
|
| 327 | - return false; |
|
| 348 | + if ($level > 1) { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 328 | 351 | |
| 329 | 352 | // Maybe they came from dlattach or similar? |
| 330 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
| 331 | - loadTheme(); |
|
| 353 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
| 354 | + loadTheme(); |
|
| 355 | + } |
|
| 332 | 356 | |
| 333 | 357 | // Don't bother indexing errors mate... |
| 334 | 358 | $context['robot_no_index'] = true; |
| 335 | 359 | |
| 336 | - if (!isset($context['error_title'])) |
|
| 337 | - $context['error_title'] = $txt['error_occured']; |
|
| 360 | + if (!isset($context['error_title'])) { |
|
| 361 | + $context['error_title'] = $txt['error_occured']; |
|
| 362 | + } |
|
| 338 | 363 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
| 339 | 364 | |
| 340 | 365 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
| 341 | 366 | |
| 342 | - if (empty($context['page_title'])) |
|
| 343 | - $context['page_title'] = $context['error_title']; |
|
| 367 | + if (empty($context['page_title'])) { |
|
| 368 | + $context['page_title'] = $context['error_title']; |
|
| 369 | + } |
|
| 344 | 370 | |
| 345 | 371 | loadTemplate('Errors'); |
| 346 | 372 | $context['sub_template'] = 'fatal_error'; |
@@ -348,23 +374,26 @@ discard block |
||
| 348 | 374 | // If this is SSI, what do they want us to do? |
| 349 | 375 | if (SMF == 'SSI') |
| 350 | 376 | { |
| 351 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
| 352 | - $ssi_on_error_method(); |
|
| 353 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 354 | - loadSubTemplate('fatal_error'); |
|
| 377 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
| 378 | + $ssi_on_error_method(); |
|
| 379 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 380 | + loadSubTemplate('fatal_error'); |
|
| 381 | + } |
|
| 355 | 382 | |
| 356 | 383 | // No layers? |
| 357 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 358 | - exit; |
|
| 384 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 385 | + exit; |
|
| 386 | + } |
|
| 359 | 387 | } |
| 360 | 388 | // Alternatively from the cron call? |
| 361 | 389 | elseif (SMF == 'BACKGROUND') |
| 362 | 390 | { |
| 363 | 391 | // We can't rely on even having language files available. |
| 364 | - if (defined('FROM_CLI') && FROM_CLI) |
|
| 365 | - echo 'cron error: ', $context['error_message']; |
|
| 366 | - else |
|
| 367 | - echo 'An error occurred. More information may be available in your logs.'; |
|
| 392 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
| 393 | + echo 'cron error: ', $context['error_message']; |
|
| 394 | + } else { |
|
| 395 | + echo 'An error occurred. More information may be available in your logs.'; |
|
| 396 | + } |
|
| 368 | 397 | exit; |
| 369 | 398 | } |
| 370 | 399 | |
@@ -392,8 +421,8 @@ discard block |
||
| 392 | 421 | |
| 393 | 422 | set_fatal_error_headers(); |
| 394 | 423 | |
| 395 | - if (!empty($maintenance)) |
|
| 396 | - echo '<!DOCTYPE html> |
|
| 424 | + if (!empty($maintenance)) { |
|
| 425 | + echo '<!DOCTYPE html> |
|
| 397 | 426 | <html> |
| 398 | 427 | <head> |
| 399 | 428 | <meta name="robots" content="noindex"> |
@@ -404,6 +433,7 @@ discard block |
||
| 404 | 433 | ', $mmessage, ' |
| 405 | 434 | </body> |
| 406 | 435 | </html>'; |
| 436 | + } |
|
| 407 | 437 | |
| 408 | 438 | die(); |
| 409 | 439 | } |
@@ -425,15 +455,17 @@ discard block |
||
| 425 | 455 | // For our purposes, we're gonna want this on if at all possible. |
| 426 | 456 | $modSettings['cache_enable'] = '1'; |
| 427 | 457 | |
| 428 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 429 | - $db_last_error = max($db_last_error, $temp); |
|
| 458 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 459 | + $db_last_error = max($db_last_error, $temp); |
|
| 460 | + } |
|
| 430 | 461 | |
| 431 | 462 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
| 432 | 463 | { |
| 433 | 464 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
| 434 | 465 | cache_put_data('db_last_error', time(), 600); |
| 435 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 436 | - logLastDatabaseError(); |
|
| 466 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 467 | + logLastDatabaseError(); |
|
| 468 | + } |
|
| 437 | 469 | |
| 438 | 470 | // Language files aren't loaded yet :(. |
| 439 | 471 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -490,8 +522,9 @@ discard block |
||
| 490 | 522 | */ |
| 491 | 523 | function set_fatal_error_headers() |
| 492 | 524 | { |
| 493 | - if (headers_sent()) |
|
| 494 | - return; |
|
| 525 | + if (headers_sent()) { |
|
| 526 | + return; |
|
| 527 | + } |
|
| 495 | 528 | |
| 496 | 529 | // Don't cache this page! |
| 497 | 530 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -517,12 +550,14 @@ discard block |
||
| 517 | 550 | global $smcFunc, $user_info, $modSettings; |
| 518 | 551 | |
| 519 | 552 | // Don't bother if Who's Online is disabled. |
| 520 | - if (empty($modSettings['who_enabled'])) |
|
| 521 | - return; |
|
| 553 | + if (empty($modSettings['who_enabled'])) { |
|
| 554 | + return; |
|
| 555 | + } |
|
| 522 | 556 | |
| 523 | 557 | // Maybe they came from SSI or similar where sessions are not recorded? |
| 524 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
| 525 | - return; |
|
| 558 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
| 559 | + return; |
|
| 560 | + } |
|
| 526 | 561 | |
| 527 | 562 | $session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id(); |
| 528 | 563 | |
@@ -548,11 +583,13 @@ discard block |
||
| 548 | 583 | $url = $smcFunc['json_decode']($url, true); |
| 549 | 584 | $url['error'] = $error; |
| 550 | 585 | // Url field got a max length of 1024 in db |
| 551 | - if (strlen($url['error']) > 500) |
|
| 552 | - $url['error'] = substr($url['error'],0,500); |
|
| 586 | + if (strlen($url['error']) > 500) { |
|
| 587 | + $url['error'] = substr($url['error'],0,500); |
|
| 588 | + } |
|
| 553 | 589 | |
| 554 | - if (!empty($sprintf)) |
|
| 555 | - $url['error_params'] = $sprintf; |
|
| 590 | + if (!empty($sprintf)) { |
|
| 591 | + $url['error_params'] = $sprintf; |
|
| 592 | + } |
|
| 556 | 593 | |
| 557 | 594 | $smcFunc['db_query']('', ' |
| 558 | 595 | UPDATE {db_prefix}log_online |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
| 42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
| 43 | 44 | |
| 44 | 45 | // Is the security option off? |
| 45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
| 46 | - return; |
|
| 46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
| 49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
| 50 | - return; |
|
| 51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
| 53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
| 55 | 58 | if (isset($_POST[$type . '_pass'])) |
| 56 | 59 | { |
| 57 | 60 | // Check to ensure we're forcing SSL for authentication |
| 58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 59 | - fatal_lang_error('login_ssl_required'); |
|
| 61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 62 | + fatal_lang_error('login_ssl_required'); |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | checkSession(); |
| 62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
| 72 | 76 | } |
| 73 | 77 | |
| 74 | 78 | // Better be sure to remember the real referer |
| 75 | - if (empty($_SESSION['request_referer'])) |
|
| 76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 77 | - elseif (empty($_POST)) |
|
| 78 | - unset($_SESSION['request_referer']); |
|
| 79 | + if (empty($_SESSION['request_referer'])) { |
|
| 80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 81 | + } elseif (empty($_POST)) { |
|
| 82 | + unset($_SESSION['request_referer']); |
|
| 83 | + } |
|
| 79 | 84 | |
| 80 | 85 | // Need to type in a password for that, man. |
| 81 | - if (!isset($_GET['xml'])) |
|
| 82 | - adminLogin($type); |
|
| 83 | - else |
|
| 84 | - return 'session_verify_fail'; |
|
| 85 | -} |
|
| 86 | + if (!isset($_GET['xml'])) { |
|
| 87 | + adminLogin($type); |
|
| 88 | + } else { |
|
| 89 | + return 'session_verify_fail'; |
|
| 90 | + } |
|
| 91 | + } |
|
| 86 | 92 | |
| 87 | 93 | /** |
| 88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
| 96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
| 97 | 103 | |
| 98 | 104 | // Luckily, this person isn't a guest. |
| 99 | - if (!$user_info['is_guest']) |
|
| 100 | - return; |
|
| 105 | + if (!$user_info['is_guest']) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 101 | 108 | |
| 102 | 109 | // Log what they were trying to do didn't work) |
| 103 | - if (!empty($modSettings['who_enabled'])) |
|
| 104 | - $_GET['error'] = 'guest_login'; |
|
| 110 | + if (!empty($modSettings['who_enabled'])) { |
|
| 111 | + $_GET['error'] = 'guest_login'; |
|
| 112 | + } |
|
| 105 | 113 | writeLog(true); |
| 106 | 114 | |
| 107 | 115 | // Just die. |
| 108 | - if (isset($_REQUEST['xml'])) |
|
| 109 | - obExit(false); |
|
| 116 | + if (isset($_REQUEST['xml'])) { |
|
| 117 | + obExit(false); |
|
| 118 | + } |
|
| 110 | 119 | |
| 111 | 120 | // Attempt to detect if they came from dlattach. |
| 112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
| 113 | - loadTheme(); |
|
| 121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
| 122 | + loadTheme(); |
|
| 123 | + } |
|
| 114 | 124 | |
| 115 | 125 | // Never redirect to an attachment |
| 116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
| 117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
| 127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 128 | + } |
|
| 118 | 129 | |
| 119 | 130 | // Load the Login template and language file. |
| 120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
| 124 | 135 | { |
| 125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
| 126 | 137 | redirectexit('action=login'); |
| 127 | - } |
|
| 128 | - else |
|
| 138 | + } else |
|
| 129 | 139 | { |
| 130 | 140 | loadTemplate('Login'); |
| 131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
| 155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
| 156 | 166 | |
| 157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
| 158 | - if ($user_info['is_admin']) |
|
| 159 | - return; |
|
| 168 | + if ($user_info['is_admin']) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 160 | 171 | |
| 161 | 172 | // Only check the ban every so often. (to reduce load.) |
| 162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
| 177 | 188 | // Check both IP addresses. |
| 178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
| 179 | 190 | { |
| 180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
| 181 | - continue; |
|
| 191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
| 192 | + continue; |
|
| 193 | + } |
|
| 182 | 194 | $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
| 183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
| 184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
| 228 | 240 | // Store every type of ban that applies to you in your session. |
| 229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 230 | 242 | { |
| 231 | - foreach ($restrictions as $restriction) |
|
| 232 | - if (!empty($row[$restriction])) |
|
| 243 | + foreach ($restrictions as $restriction) { |
|
| 244 | + if (!empty($row[$restriction])) |
|
| 233 | 245 | { |
| 234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
| 247 | + } |
|
| 235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
| 236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
| 237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
| 249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
| 250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
| 251 | + } |
|
| 238 | 252 | |
| 239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
| 240 | - $flag_is_activated = true; |
|
| 253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
| 254 | + $flag_is_activated = true; |
|
| 255 | + } |
|
| 241 | 256 | } |
| 242 | 257 | } |
| 243 | 258 | $smcFunc['db_free_result']($request); |
| 244 | 259 | } |
| 245 | 260 | |
| 246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
| 247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
| 248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
| 262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
| 263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
| 264 | + } |
|
| 249 | 265 | |
| 250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
| 251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
| 260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
| 261 | 277 | { |
| 262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
| 263 | - foreach ($bans as $key => $value) |
|
| 264 | - $bans[$key] = (int) $value; |
|
| 279 | + foreach ($bans as $key => $value) { |
|
| 280 | + $bans[$key] = (int) $value; |
|
| 281 | + } |
|
| 265 | 282 | $request = $smcFunc['db_query']('', ' |
| 266 | 283 | SELECT bi.id_ban, bg.reason, COALESCE(bg.expire_time, 0) AS expire_time |
| 267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -298,14 +315,15 @@ discard block |
||
| 298 | 315 | if (isset($_SESSION['ban']['cannot_access'])) |
| 299 | 316 | { |
| 300 | 317 | // We don't wanna see you! |
| 301 | - if (!$user_info['is_guest']) |
|
| 302 | - $smcFunc['db_query']('', ' |
|
| 318 | + if (!$user_info['is_guest']) { |
|
| 319 | + $smcFunc['db_query']('', ' |
|
| 303 | 320 | DELETE FROM {db_prefix}log_online |
| 304 | 321 | WHERE id_member = {int:current_member}', |
| 305 | 322 | array( |
| 306 | 323 | 'current_member' => $user_info['id'], |
| 307 | 324 | ) |
| 308 | 325 | ); |
| 326 | + } |
|
| 309 | 327 | |
| 310 | 328 | // 'Log' the user out. Can't have any funny business... (save the name!) |
| 311 | 329 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -391,9 +409,10 @@ discard block |
||
| 391 | 409 | } |
| 392 | 410 | |
| 393 | 411 | // Fix up the banning permissions. |
| 394 | - if (isset($user_info['permissions'])) |
|
| 395 | - banPermissions(); |
|
| 396 | -} |
|
| 412 | + if (isset($user_info['permissions'])) { |
|
| 413 | + banPermissions(); |
|
| 414 | + } |
|
| 415 | + } |
|
| 397 | 416 | |
| 398 | 417 | /** |
| 399 | 418 | * Fix permissions according to ban status. |
@@ -404,8 +423,9 @@ discard block |
||
| 404 | 423 | global $user_info, $sourcedir, $modSettings, $context; |
| 405 | 424 | |
| 406 | 425 | // Somehow they got here, at least take away all permissions... |
| 407 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
| 408 | - $user_info['permissions'] = array(); |
|
| 426 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
| 427 | + $user_info['permissions'] = array(); |
|
| 428 | + } |
|
| 409 | 429 | // Okay, well, you can watch, but don't touch a thing. |
| 410 | 430 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
| 411 | 431 | { |
@@ -447,19 +467,20 @@ discard block |
||
| 447 | 467 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
| 448 | 468 | foreach ($permission_change as $old => $new) |
| 449 | 469 | { |
| 450 | - if (!in_array($old, $user_info['permissions'])) |
|
| 451 | - unset($permission_change[$old]); |
|
| 452 | - else |
|
| 453 | - $user_info['permissions'][] = $new; |
|
| 470 | + if (!in_array($old, $user_info['permissions'])) { |
|
| 471 | + unset($permission_change[$old]); |
|
| 472 | + } else { |
|
| 473 | + $user_info['permissions'][] = $new; |
|
| 474 | + } |
|
| 454 | 475 | } |
| 455 | 476 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
| 456 | 477 | } |
| 457 | 478 | |
| 458 | 479 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
| 459 | 480 | // Finally, some bits we cache in the session because it saves queries. |
| 460 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
| 461 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 462 | - else |
|
| 481 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
| 482 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 483 | + } else |
|
| 463 | 484 | { |
| 464 | 485 | require_once($sourcedir . '/Subs-Auth.php'); |
| 465 | 486 | rebuildModCache(); |
@@ -470,14 +491,12 @@ discard block |
||
| 470 | 491 | { |
| 471 | 492 | $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
| 472 | 493 | $context['open_member_reports'] = $_SESSION['rc']['member_reports']; |
| 473 | - } |
|
| 474 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
| 494 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
| 475 | 495 | { |
| 476 | 496 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
| 477 | 497 | $context['open_mod_reports'] = recountOpenReports('posts'); |
| 478 | 498 | $context['open_member_reports'] = recountOpenReports('members'); |
| 479 | - } |
|
| 480 | - else |
|
| 499 | + } else |
|
| 481 | 500 | { |
| 482 | 501 | $context['open_mod_reports'] = 0; |
| 483 | 502 | $context['open_member_reports'] = 0; |
@@ -497,8 +516,9 @@ discard block |
||
| 497 | 516 | global $user_info, $smcFunc; |
| 498 | 517 | |
| 499 | 518 | // Don't log web accelerators, it's very confusing... |
| 500 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
| 501 | - return; |
|
| 519 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
| 520 | + return; |
|
| 521 | + } |
|
| 502 | 522 | |
| 503 | 523 | $smcFunc['db_insert']('', |
| 504 | 524 | '{db_prefix}log_banned', |
@@ -508,8 +528,8 @@ discard block |
||
| 508 | 528 | ); |
| 509 | 529 | |
| 510 | 530 | // One extra point for these bans. |
| 511 | - if (!empty($ban_ids)) |
|
| 512 | - $smcFunc['db_query']('', ' |
|
| 531 | + if (!empty($ban_ids)) { |
|
| 532 | + $smcFunc['db_query']('', ' |
|
| 513 | 533 | UPDATE {db_prefix}ban_items |
| 514 | 534 | SET hits = hits + 1 |
| 515 | 535 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -517,7 +537,8 @@ discard block |
||
| 517 | 537 | 'ban_ids' => $ban_ids, |
| 518 | 538 | ) |
| 519 | 539 | ); |
| 520 | -} |
|
| 540 | + } |
|
| 541 | + } |
|
| 521 | 542 | |
| 522 | 543 | /** |
| 523 | 544 | * Checks if a given email address might be banned. |
@@ -533,8 +554,9 @@ discard block |
||
| 533 | 554 | global $txt, $smcFunc; |
| 534 | 555 | |
| 535 | 556 | // Can't ban an empty email |
| 536 | - if (empty($email) || trim($email) == '') |
|
| 537 | - return; |
|
| 557 | + if (empty($email) || trim($email) == '') { |
|
| 558 | + return; |
|
| 559 | + } |
|
| 538 | 560 | |
| 539 | 561 | // Let's start with the bans based on your IP/hostname/memberID... |
| 540 | 562 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -607,16 +629,18 @@ discard block |
||
| 607 | 629 | if ($type == 'post') |
| 608 | 630 | { |
| 609 | 631 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
| 610 | - if ($check !== $sc) |
|
| 611 | - $error = 'session_timeout'; |
|
| 632 | + if ($check !== $sc) { |
|
| 633 | + $error = 'session_timeout'; |
|
| 634 | + } |
|
| 612 | 635 | } |
| 613 | 636 | |
| 614 | 637 | // How about $_GET['sesc']? |
| 615 | 638 | elseif ($type == 'get') |
| 616 | 639 | { |
| 617 | 640 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
| 618 | - if ($check !== $sc) |
|
| 619 | - $error = 'session_verify_fail'; |
|
| 641 | + if ($check !== $sc) { |
|
| 642 | + $error = 'session_verify_fail'; |
|
| 643 | + } |
|
| 620 | 644 | } |
| 621 | 645 | |
| 622 | 646 | // Or can it be in either? |
@@ -624,13 +648,15 @@ discard block |
||
| 624 | 648 | { |
| 625 | 649 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
| 626 | 650 | |
| 627 | - if ($check !== $sc) |
|
| 628 | - $error = 'session_verify_fail'; |
|
| 651 | + if ($check !== $sc) { |
|
| 652 | + $error = 'session_verify_fail'; |
|
| 653 | + } |
|
| 629 | 654 | } |
| 630 | 655 | |
| 631 | 656 | // Verify that they aren't changing user agents on us - that could be bad. |
| 632 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
| 633 | - $error = 'session_verify_fail'; |
|
| 657 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
| 658 | + $error = 'session_verify_fail'; |
|
| 659 | + } |
|
| 634 | 660 | |
| 635 | 661 | // Make sure a page with session check requirement is not being prefetched. |
| 636 | 662 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -641,30 +667,35 @@ discard block |
||
| 641 | 667 | } |
| 642 | 668 | |
| 643 | 669 | // Check the referring site - it should be the same server at least! |
| 644 | - if (isset($_SESSION['request_referer'])) |
|
| 645 | - $referrer = $_SESSION['request_referer']; |
|
| 646 | - else |
|
| 647 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 670 | + if (isset($_SESSION['request_referer'])) { |
|
| 671 | + $referrer = $_SESSION['request_referer']; |
|
| 672 | + } else { |
|
| 673 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 674 | + } |
|
| 648 | 675 | if (!empty($referrer['host'])) |
| 649 | 676 | { |
| 650 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
| 651 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
| 652 | - else |
|
| 653 | - $real_host = $_SERVER['HTTP_HOST']; |
|
| 677 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
| 678 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
| 679 | + } else { |
|
| 680 | + $real_host = $_SERVER['HTTP_HOST']; |
|
| 681 | + } |
|
| 654 | 682 | |
| 655 | 683 | $parsed_url = parse_url($boardurl); |
| 656 | 684 | |
| 657 | 685 | // Are global cookies on? If so, let's check them ;). |
| 658 | 686 | if (!empty($modSettings['globalCookies'])) |
| 659 | 687 | { |
| 660 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 661 | - $parsed_url['host'] = $parts[1]; |
|
| 688 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 689 | + $parsed_url['host'] = $parts[1]; |
|
| 690 | + } |
|
| 662 | 691 | |
| 663 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
| 664 | - $referrer['host'] = $parts[1]; |
|
| 692 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
| 693 | + $referrer['host'] = $parts[1]; |
|
| 694 | + } |
|
| 665 | 695 | |
| 666 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
| 667 | - $real_host = $parts[1]; |
|
| 696 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
| 697 | + $real_host = $parts[1]; |
|
| 698 | + } |
|
| 668 | 699 | } |
| 669 | 700 | |
| 670 | 701 | // Okay: referrer must either match parsed_url or real_host. |
@@ -682,12 +713,14 @@ discard block |
||
| 682 | 713 | $log_error = true; |
| 683 | 714 | } |
| 684 | 715 | |
| 685 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
| 686 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
| 716 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
| 717 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
| 718 | + } |
|
| 687 | 719 | |
| 688 | 720 | // Everything is ok, return an empty string. |
| 689 | - if (!isset($error)) |
|
| 690 | - return ''; |
|
| 721 | + if (!isset($error)) { |
|
| 722 | + return ''; |
|
| 723 | + } |
|
| 691 | 724 | // A session error occurred, show the error. |
| 692 | 725 | elseif ($is_fatal) |
| 693 | 726 | { |
@@ -696,13 +729,14 @@ discard block |
||
| 696 | 729 | ob_end_clean(); |
| 697 | 730 | send_http_status(403, 'Forbidden - Session timeout'); |
| 698 | 731 | die; |
| 732 | + } else { |
|
| 733 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
| 699 | 734 | } |
| 700 | - else |
|
| 701 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
| 702 | 735 | } |
| 703 | 736 | // A session error occurred, return the error to the calling function. |
| 704 | - else |
|
| 705 | - return $error; |
|
| 737 | + else { |
|
| 738 | + return $error; |
|
| 739 | + } |
|
| 706 | 740 | |
| 707 | 741 | // We really should never fall through here, for very important reasons. Let's make sure. |
| 708 | 742 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -718,10 +752,9 @@ discard block |
||
| 718 | 752 | { |
| 719 | 753 | global $modSettings; |
| 720 | 754 | |
| 721 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
| 722 | - return true; |
|
| 723 | - |
|
| 724 | - else |
|
| 755 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
| 756 | + return true; |
|
| 757 | + } else |
|
| 725 | 758 | { |
| 726 | 759 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
| 727 | 760 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -772,9 +805,9 @@ discard block |
||
| 772 | 805 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
| 773 | 806 | unset($_SESSION['token'][$type . '-' . $action]); |
| 774 | 807 | return $return; |
| 808 | + } else { |
|
| 809 | + return ''; |
|
| 775 | 810 | } |
| 776 | - else |
|
| 777 | - return ''; |
|
| 778 | 811 | } |
| 779 | 812 | |
| 780 | 813 | // This nasty piece of code validates a token. |
@@ -805,12 +838,14 @@ discard block |
||
| 805 | 838 | fatal_lang_error('token_verify_fail', false); |
| 806 | 839 | } |
| 807 | 840 | // Remove this token as its useless |
| 808 | - else |
|
| 809 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
| 841 | + else { |
|
| 842 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
| 843 | + } |
|
| 810 | 844 | |
| 811 | 845 | // Randomly check if we should remove some older tokens. |
| 812 | - if (mt_rand(0, 138) == 23) |
|
| 813 | - cleanTokens(); |
|
| 846 | + if (mt_rand(0, 138) == 23) { |
|
| 847 | + cleanTokens(); |
|
| 848 | + } |
|
| 814 | 849 | |
| 815 | 850 | return false; |
| 816 | 851 | } |
@@ -825,14 +860,16 @@ discard block |
||
| 825 | 860 | function cleanTokens($complete = false) |
| 826 | 861 | { |
| 827 | 862 | // We appreciate cleaning up after yourselves. |
| 828 | - if (!isset($_SESSION['token'])) |
|
| 829 | - return; |
|
| 863 | + if (!isset($_SESSION['token'])) { |
|
| 864 | + return; |
|
| 865 | + } |
|
| 830 | 866 | |
| 831 | 867 | // Clean up tokens, trying to give enough time still. |
| 832 | - foreach ($_SESSION['token'] as $key => $data) |
|
| 833 | - if ($data[2] + 10800 < time() || $complete) |
|
| 868 | + foreach ($_SESSION['token'] as $key => $data) { |
|
| 869 | + if ($data[2] + 10800 < time() || $complete) |
|
| 834 | 870 | unset($_SESSION['token'][$key]); |
| 835 | -} |
|
| 871 | + } |
|
| 872 | + } |
|
| 836 | 873 | |
| 837 | 874 | /** |
| 838 | 875 | * Check whether a form has been submitted twice. |
@@ -850,37 +887,40 @@ discard block |
||
| 850 | 887 | { |
| 851 | 888 | global $context; |
| 852 | 889 | |
| 853 | - if (!isset($_SESSION['forms'])) |
|
| 854 | - $_SESSION['forms'] = array(); |
|
| 890 | + if (!isset($_SESSION['forms'])) { |
|
| 891 | + $_SESSION['forms'] = array(); |
|
| 892 | + } |
|
| 855 | 893 | |
| 856 | 894 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
| 857 | 895 | if ($action == 'register') |
| 858 | 896 | { |
| 859 | 897 | $context['form_sequence_number'] = 0; |
| 860 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
| 861 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
| 898 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
| 899 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
| 900 | + } |
|
| 862 | 901 | } |
| 863 | 902 | // Check whether the submitted number can be found in the session. |
| 864 | 903 | elseif ($action == 'check') |
| 865 | 904 | { |
| 866 | - if (!isset($_REQUEST['seqnum'])) |
|
| 867 | - return true; |
|
| 868 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 905 | + if (!isset($_REQUEST['seqnum'])) { |
|
| 906 | + return true; |
|
| 907 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 869 | 908 | { |
| 870 | 909 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
| 871 | 910 | return true; |
| 911 | + } elseif ($is_fatal) { |
|
| 912 | + fatal_lang_error('error_form_already_submitted', false); |
|
| 913 | + } else { |
|
| 914 | + return false; |
|
| 872 | 915 | } |
| 873 | - elseif ($is_fatal) |
|
| 874 | - fatal_lang_error('error_form_already_submitted', false); |
|
| 875 | - else |
|
| 876 | - return false; |
|
| 877 | 916 | } |
| 878 | 917 | // Don't check, just free the stack number. |
| 879 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 880 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
| 881 | - elseif ($action != 'free') |
|
| 882 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
| 883 | -} |
|
| 918 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
| 919 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
| 920 | + } elseif ($action != 'free') { |
|
| 921 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
| 922 | + } |
|
| 923 | + } |
|
| 884 | 924 | |
| 885 | 925 | /** |
| 886 | 926 | * Check the user's permissions. |
@@ -899,16 +939,19 @@ discard block |
||
| 899 | 939 | global $user_info, $smcFunc; |
| 900 | 940 | |
| 901 | 941 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
| 902 | - if (empty($permission)) |
|
| 903 | - return true; |
|
| 942 | + if (empty($permission)) { |
|
| 943 | + return true; |
|
| 944 | + } |
|
| 904 | 945 | |
| 905 | 946 | // You're never allowed to do something if your data hasn't been loaded yet! |
| 906 | - if (empty($user_info)) |
|
| 907 | - return false; |
|
| 947 | + if (empty($user_info)) { |
|
| 948 | + return false; |
|
| 949 | + } |
|
| 908 | 950 | |
| 909 | 951 | // Administrators are supermen :P. |
| 910 | - if ($user_info['is_admin']) |
|
| 911 | - return true; |
|
| 952 | + if ($user_info['is_admin']) { |
|
| 953 | + return true; |
|
| 954 | + } |
|
| 912 | 955 | |
| 913 | 956 | // Let's ensure this is an array. |
| 914 | 957 | $permission = (array) $permission; |
@@ -916,14 +959,16 @@ discard block |
||
| 916 | 959 | // Are we checking the _current_ board, or some other boards? |
| 917 | 960 | if ($boards === null) |
| 918 | 961 | { |
| 919 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
| 920 | - return true; |
|
| 962 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
| 963 | + return true; |
|
| 964 | + } |
|
| 921 | 965 | // You aren't allowed, by default. |
| 922 | - else |
|
| 923 | - return false; |
|
| 966 | + else { |
|
| 967 | + return false; |
|
| 968 | + } |
|
| 969 | + } elseif (!is_array($boards)) { |
|
| 970 | + $boards = array($boards); |
|
| 924 | 971 | } |
| 925 | - elseif (!is_array($boards)) |
|
| 926 | - $boards = array($boards); |
|
| 927 | 972 | |
| 928 | 973 | $request = $smcFunc['db_query']('', ' |
| 929 | 974 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -951,20 +996,23 @@ discard block |
||
| 951 | 996 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 952 | 997 | { |
| 953 | 998 | $result = !empty($row['add_deny']); |
| 954 | - if ($result == true) |
|
| 955 | - break; |
|
| 999 | + if ($result == true) { |
|
| 1000 | + break; |
|
| 1001 | + } |
|
| 956 | 1002 | } |
| 957 | 1003 | $smcFunc['db_free_result']($request); |
| 958 | 1004 | return $result; |
| 959 | 1005 | } |
| 960 | 1006 | |
| 961 | 1007 | // Make sure they can do it on all of the boards. |
| 962 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
| 963 | - return false; |
|
| 1008 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
| 1009 | + return false; |
|
| 1010 | + } |
|
| 964 | 1011 | |
| 965 | 1012 | $result = true; |
| 966 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 967 | - $result &= !empty($row['add_deny']); |
|
| 1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1014 | + $result &= !empty($row['add_deny']); |
|
| 1015 | + } |
|
| 968 | 1016 | $smcFunc['db_free_result']($request); |
| 969 | 1017 | |
| 970 | 1018 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1031,9 +1079,10 @@ discard block |
||
| 1031 | 1079 | |
| 1032 | 1080 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
| 1033 | 1081 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
| 1034 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
| 1035 | - validateSession(); |
|
| 1036 | -} |
|
| 1082 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
| 1083 | + validateSession(); |
|
| 1084 | + } |
|
| 1085 | + } |
|
| 1037 | 1086 | |
| 1038 | 1087 | /** |
| 1039 | 1088 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1064,13 +1113,14 @@ discard block |
||
| 1064 | 1113 | // Administrators are all powerful, sorry. |
| 1065 | 1114 | if ($user_info['is_admin']) |
| 1066 | 1115 | { |
| 1067 | - if ($simple) |
|
| 1068 | - return array(0); |
|
| 1069 | - else |
|
| 1116 | + if ($simple) { |
|
| 1117 | + return array(0); |
|
| 1118 | + } else |
|
| 1070 | 1119 | { |
| 1071 | 1120 | $boards = array(); |
| 1072 | - foreach ($permissions as $permission) |
|
| 1073 | - $boards[$permission] = array(0); |
|
| 1121 | + foreach ($permissions as $permission) { |
|
| 1122 | + $boards[$permission] = array(0); |
|
| 1123 | + } |
|
| 1074 | 1124 | |
| 1075 | 1125 | return $boards; |
| 1076 | 1126 | } |
@@ -1102,31 +1152,32 @@ discard block |
||
| 1102 | 1152 | { |
| 1103 | 1153 | if ($simple) |
| 1104 | 1154 | { |
| 1105 | - if (empty($row['add_deny'])) |
|
| 1106 | - $deny_boards[] = $row['id_board']; |
|
| 1107 | - else |
|
| 1108 | - $boards[] = $row['id_board']; |
|
| 1109 | - } |
|
| 1110 | - else |
|
| 1155 | + if (empty($row['add_deny'])) { |
|
| 1156 | + $deny_boards[] = $row['id_board']; |
|
| 1157 | + } else { |
|
| 1158 | + $boards[] = $row['id_board']; |
|
| 1159 | + } |
|
| 1160 | + } else |
|
| 1111 | 1161 | { |
| 1112 | - if (empty($row['add_deny'])) |
|
| 1113 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
| 1114 | - else |
|
| 1115 | - $boards[$row['permission']][] = $row['id_board']; |
|
| 1162 | + if (empty($row['add_deny'])) { |
|
| 1163 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
| 1164 | + } else { |
|
| 1165 | + $boards[$row['permission']][] = $row['id_board']; |
|
| 1166 | + } |
|
| 1116 | 1167 | } |
| 1117 | 1168 | } |
| 1118 | 1169 | $smcFunc['db_free_result']($request); |
| 1119 | 1170 | |
| 1120 | - if ($simple) |
|
| 1121 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
| 1122 | - else |
|
| 1171 | + if ($simple) { |
|
| 1172 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
| 1173 | + } else |
|
| 1123 | 1174 | { |
| 1124 | 1175 | foreach ($permissions as $permission) |
| 1125 | 1176 | { |
| 1126 | 1177 | // never had it to start with |
| 1127 | - if (empty($boards[$permission])) |
|
| 1128 | - $boards[$permission] = array(); |
|
| 1129 | - else |
|
| 1178 | + if (empty($boards[$permission])) { |
|
| 1179 | + $boards[$permission] = array(); |
|
| 1180 | + } else |
|
| 1130 | 1181 | { |
| 1131 | 1182 | // Or it may have been removed |
| 1132 | 1183 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1162,10 +1213,11 @@ discard block |
||
| 1162 | 1213 | |
| 1163 | 1214 | |
| 1164 | 1215 | // Moderators are free... |
| 1165 | - if (!allowedTo('moderate_board')) |
|
| 1166 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
| 1167 | - else |
|
| 1168 | - $timeLimit = 2; |
|
| 1216 | + if (!allowedTo('moderate_board')) { |
|
| 1217 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
| 1218 | + } else { |
|
| 1219 | + $timeLimit = 2; |
|
| 1220 | + } |
|
| 1169 | 1221 | |
| 1170 | 1222 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
| 1171 | 1223 | |
@@ -1192,8 +1244,9 @@ discard block |
||
| 1192 | 1244 | if ($smcFunc['db_affected_rows']() != 1) |
| 1193 | 1245 | { |
| 1194 | 1246 | // Spammer! You only have to wait a *few* seconds! |
| 1195 | - if (!$only_return_result) |
|
| 1196 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
| 1247 | + if (!$only_return_result) { |
|
| 1248 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
| 1249 | + } |
|
| 1197 | 1250 | |
| 1198 | 1251 | return true; |
| 1199 | 1252 | } |
@@ -1211,11 +1264,13 @@ discard block |
||
| 1211 | 1264 | */ |
| 1212 | 1265 | function secureDirectory($path, $attachments = false) |
| 1213 | 1266 | { |
| 1214 | - if (empty($path)) |
|
| 1215 | - return 'empty_path'; |
|
| 1267 | + if (empty($path)) { |
|
| 1268 | + return 'empty_path'; |
|
| 1269 | + } |
|
| 1216 | 1270 | |
| 1217 | - if (!is_writable($path)) |
|
| 1218 | - return 'path_not_writable'; |
|
| 1271 | + if (!is_writable($path)) { |
|
| 1272 | + return 'path_not_writable'; |
|
| 1273 | + } |
|
| 1219 | 1274 | |
| 1220 | 1275 | $directoryname = basename($path); |
| 1221 | 1276 | |
@@ -1227,9 +1282,9 @@ discard block |
||
| 1227 | 1282 | |
| 1228 | 1283 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
| 1229 | 1284 | |
| 1230 | - if (file_exists($path . '/.htaccess')) |
|
| 1231 | - $errors[] = 'htaccess_exists'; |
|
| 1232 | - else |
|
| 1285 | + if (file_exists($path . '/.htaccess')) { |
|
| 1286 | + $errors[] = 'htaccess_exists'; |
|
| 1287 | + } else |
|
| 1233 | 1288 | { |
| 1234 | 1289 | $fh = @fopen($path . '/.htaccess', 'w'); |
| 1235 | 1290 | if ($fh) |
@@ -1242,9 +1297,9 @@ discard block |
||
| 1242 | 1297 | $errors[] = 'htaccess_cannot_create_file'; |
| 1243 | 1298 | } |
| 1244 | 1299 | |
| 1245 | - if (file_exists($path . '/index.php')) |
|
| 1246 | - $errors[] = 'index-php_exists'; |
|
| 1247 | - else |
|
| 1300 | + if (file_exists($path . '/index.php')) { |
|
| 1301 | + $errors[] = 'index-php_exists'; |
|
| 1302 | + } else |
|
| 1248 | 1303 | { |
| 1249 | 1304 | $fh = @fopen($path . '/index.php', 'w'); |
| 1250 | 1305 | if ($fh) |
@@ -1272,11 +1327,12 @@ discard block |
||
| 1272 | 1327 | $errors[] = 'index-php_cannot_create_file'; |
| 1273 | 1328 | } |
| 1274 | 1329 | |
| 1275 | - if (!empty($errors)) |
|
| 1276 | - return $errors; |
|
| 1277 | - else |
|
| 1278 | - return true; |
|
| 1279 | -} |
|
| 1330 | + if (!empty($errors)) { |
|
| 1331 | + return $errors; |
|
| 1332 | + } else { |
|
| 1333 | + return true; |
|
| 1334 | + } |
|
| 1335 | + } |
|
| 1280 | 1336 | |
| 1281 | 1337 | /** |
| 1282 | 1338 | * This sets the X-Frame-Options header. |
@@ -1289,14 +1345,16 @@ discard block |
||
| 1289 | 1345 | global $modSettings; |
| 1290 | 1346 | |
| 1291 | 1347 | $option = 'SAMEORIGIN'; |
| 1292 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
| 1293 | - $option = $modSettings['frame_security']; |
|
| 1294 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
| 1295 | - $option = $override; |
|
| 1348 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
| 1349 | + $option = $modSettings['frame_security']; |
|
| 1350 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
| 1351 | + $option = $override; |
|
| 1352 | + } |
|
| 1296 | 1353 | |
| 1297 | 1354 | // Don't bother setting the header if we have disabled it. |
| 1298 | - if ($option == 'DISABLE') |
|
| 1299 | - return; |
|
| 1355 | + if ($option == 'DISABLE') { |
|
| 1356 | + return; |
|
| 1357 | + } |
|
| 1300 | 1358 | |
| 1301 | 1359 | // Finally set it. |
| 1302 | 1360 | header('x-frame-options: ' . $option); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | global $messages_request, $language, $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // What are you gonna display if these are empty?! |
| 37 | - if (empty($topic)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($topic)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // Load the proper template. |
| 41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
| 52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 53 | 55 | |
| 54 | 56 | // Let's do some work on what to search index. |
| 55 | - if (count($_GET) > 2) |
|
| 56 | - foreach ($_GET as $k => $v) |
|
| 57 | + if (count($_GET) > 2) { |
|
| 58 | + foreach ($_GET as $k => $v) |
|
| 57 | 59 | { |
| 58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
| 59 | 61 | $context['robot_no_index'] = true; |
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | |
| 62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 63 | - $context['robot_no_index'] = true; |
|
| 65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 66 | + $context['robot_no_index'] = true; |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
| 66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
| 172 | 176 | $topic_parameters |
| 173 | 177 | ); |
| 174 | 178 | |
| 175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 176 | - fatal_lang_error('not_a_topic', false, 404); |
|
| 179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 180 | + fatal_lang_error('not_a_topic', false, 404); |
|
| 181 | + } |
|
| 177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
| 178 | 183 | $smcFunc['db_free_result']($request); |
| 179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
| 210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
| 211 | 216 | |
| 212 | 217 | // Add up unapproved replies to get real number of replies... |
| 213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
| 214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
| 219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
| 217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
| 231 | 237 | $smcFunc['db_free_result']($request); |
| 232 | 238 | |
| 233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
| 240 | + } elseif ($user_info['is_guest']) { |
|
| 241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 242 | + } else { |
|
| 243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 234 | 244 | } |
| 235 | - elseif ($user_info['is_guest']) |
|
| 236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 237 | - else |
|
| 238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 239 | 245 | |
| 240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
| 241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
| 248 | 254 | { |
| 249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
| 250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
| 251 | - } |
|
| 252 | - else |
|
| 257 | + } else |
|
| 253 | 258 | { |
| 254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
| 255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
| 277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
| 278 | 283 | { |
| 279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
| 280 | - if ($timestamp === 0) |
|
| 281 | - $_REQUEST['start'] = 0; |
|
| 282 | - else |
|
| 285 | + if ($timestamp === 0) { |
|
| 286 | + $_REQUEST['start'] = 0; |
|
| 287 | + } else |
|
| 283 | 288 | { |
| 284 | 289 | // Find the number of messages posted before said time... |
| 285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
| 307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
| 308 | 313 | { |
| 309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
| 310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
| 311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
| 313 | - $context['start_from'] = 0; |
|
| 314 | - else |
|
| 315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
| 318 | + $context['start_from'] = 0; |
|
| 319 | + } else |
|
| 315 | 320 | { |
| 316 | 321 | // Find the start value for that message...... |
| 317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -365,9 +370,10 @@ discard block |
||
| 365 | 370 | list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']); |
| 366 | 371 | $sig_limits = explode(',', $sig_limits); |
| 367 | 372 | |
| 368 | - if (!empty($sig_limits[5]) || !empty($sig_limits[6])) |
|
| 369 | - addInlineCss(' |
|
| 373 | + if (!empty($sig_limits[5]) || !empty($sig_limits[6])) { |
|
| 374 | + addInlineCss(' |
|
| 370 | 375 | .signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}'); |
| 376 | + } |
|
| 371 | 377 | } |
| 372 | 378 | |
| 373 | 379 | // Censor the title... |
@@ -405,21 +411,25 @@ discard block |
||
| 405 | 411 | ); |
| 406 | 412 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 407 | 413 | { |
| 408 | - if (empty($row['id_member'])) |
|
| 409 | - continue; |
|
| 414 | + if (empty($row['id_member'])) { |
|
| 415 | + continue; |
|
| 416 | + } |
|
| 410 | 417 | |
| 411 | - if (!empty($row['online_color'])) |
|
| 412 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 413 | - else |
|
| 414 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 418 | + if (!empty($row['online_color'])) { |
|
| 419 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 420 | + } else { |
|
| 421 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 422 | + } |
|
| 415 | 423 | |
| 416 | 424 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 417 | - if ($is_buddy) |
|
| 418 | - $link = '<strong>' . $link . '</strong>'; |
|
| 425 | + if ($is_buddy) { |
|
| 426 | + $link = '<strong>' . $link . '</strong>'; |
|
| 427 | + } |
|
| 419 | 428 | |
| 420 | 429 | // Add them both to the list and to the more detailed list. |
| 421 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 422 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 430 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 431 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 432 | + } |
|
| 423 | 433 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 424 | 434 | 'id' => $row['id_member'], |
| 425 | 435 | 'username' => $row['member_name'], |
@@ -431,8 +441,9 @@ discard block |
||
| 431 | 441 | 'hidden' => empty($row['show_online']), |
| 432 | 442 | ); |
| 433 | 443 | |
| 434 | - if (empty($row['show_online'])) |
|
| 435 | - $context['view_num_hidden']++; |
|
| 444 | + if (empty($row['show_online'])) { |
|
| 445 | + $context['view_num_hidden']++; |
|
| 446 | + } |
|
| 436 | 447 | } |
| 437 | 448 | |
| 438 | 449 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -446,11 +457,13 @@ discard block |
||
| 446 | 457 | |
| 447 | 458 | // If all is set, but not allowed... just unset it. |
| 448 | 459 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
| 449 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
| 450 | - unset($_REQUEST['all']); |
|
| 460 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
| 461 | + unset($_REQUEST['all']); |
|
| 462 | + } |
|
| 451 | 463 | // Otherwise, it must be allowed... so pretend start was -1. |
| 452 | - elseif (isset($_REQUEST['all'])) |
|
| 453 | - $_REQUEST['start'] = -1; |
|
| 464 | + elseif (isset($_REQUEST['all'])) { |
|
| 465 | + $_REQUEST['start'] = -1; |
|
| 466 | + } |
|
| 454 | 467 | |
| 455 | 468 | // Construct the page index, allowing for the .START method... |
| 456 | 469 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -487,8 +500,9 @@ discard block |
||
| 487 | 500 | $_REQUEST['start'] = 0; |
| 488 | 501 | } |
| 489 | 502 | // They aren't using it, but the *option* is there, at least. |
| 490 | - else |
|
| 491 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 503 | + else { |
|
| 504 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 505 | + } |
|
| 492 | 506 | } |
| 493 | 507 | |
| 494 | 508 | // Build the link tree. |
@@ -504,14 +518,16 @@ discard block |
||
| 504 | 518 | if (!empty($board_info['moderators'])) |
| 505 | 519 | { |
| 506 | 520 | // Add a link for each moderator... |
| 507 | - foreach ($board_info['moderators'] as $mod) |
|
| 508 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 521 | + foreach ($board_info['moderators'] as $mod) { |
|
| 522 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 523 | + } |
|
| 509 | 524 | } |
| 510 | 525 | if (!empty($board_info['moderator_groups'])) |
| 511 | 526 | { |
| 512 | 527 | // Add a link for each moderator group as well... |
| 513 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 514 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 528 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 529 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 530 | + } |
|
| 515 | 531 | } |
| 516 | 532 | |
| 517 | 533 | if (!empty($context['link_moderators'])) |
@@ -542,9 +558,9 @@ discard block |
||
| 542 | 558 | // For quick reply we need a response prefix in the default forum language. |
| 543 | 559 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
| 544 | 560 | { |
| 545 | - if ($language === $user_info['language']) |
|
| 546 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 547 | - else |
|
| 561 | + if ($language === $user_info['language']) { |
|
| 562 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 563 | + } else |
|
| 548 | 564 | { |
| 549 | 565 | loadLanguage('index', $language, false); |
| 550 | 566 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -576,8 +592,9 @@ discard block |
||
| 576 | 592 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 577 | 593 | |
| 578 | 594 | // Sanity check |
| 579 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 580 | - continue; |
|
| 595 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 596 | + continue; |
|
| 597 | + } |
|
| 581 | 598 | |
| 582 | 599 | $linked_calendar_event = array( |
| 583 | 600 | 'id' => $row['id_event'], |
@@ -626,8 +643,9 @@ discard block |
||
| 626 | 643 | } |
| 627 | 644 | $smcFunc['db_free_result']($request); |
| 628 | 645 | |
| 629 | - if (!empty($context['linked_calendar_events'])) |
|
| 630 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 646 | + if (!empty($context['linked_calendar_events'])) { |
|
| 647 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 648 | + } |
|
| 631 | 649 | } |
| 632 | 650 | |
| 633 | 651 | // Create the poll info if it exists. |
@@ -651,9 +669,9 @@ discard block |
||
| 651 | 669 | } |
| 652 | 670 | |
| 653 | 671 | // Create the poll info if it exists and is valid. |
| 654 | - if ($context['is_poll'] && empty($pollinfo)) |
|
| 655 | - $context['is_poll'] = false; |
|
| 656 | - elseif ($context['is_poll']) |
|
| 672 | + if ($context['is_poll'] && empty($pollinfo)) { |
|
| 673 | + $context['is_poll'] = false; |
|
| 674 | + } elseif ($context['is_poll']) |
|
| 657 | 675 | { |
| 658 | 676 | $request = $smcFunc['db_query']('', ' |
| 659 | 677 | SELECT COUNT(DISTINCT id_member) AS total |
@@ -696,8 +714,9 @@ discard block |
||
| 696 | 714 | $smcFunc['db_free_result']($request); |
| 697 | 715 | |
| 698 | 716 | // Got we multi choice? |
| 699 | - if ($pollinfo['max_votes'] > 1) |
|
| 700 | - $realtotal = $pollinfo['total']; |
|
| 717 | + if ($pollinfo['max_votes'] > 1) { |
|
| 718 | + $realtotal = $pollinfo['total']; |
|
| 719 | + } |
|
| 701 | 720 | |
| 702 | 721 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
| 703 | 722 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -710,20 +729,21 @@ discard block |
||
| 710 | 729 | foreach ($guestinfo as $i => $guestvoted) |
| 711 | 730 | { |
| 712 | 731 | $guestvoted = explode(',', $guestvoted); |
| 713 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
| 714 | - break; |
|
| 732 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
| 733 | + break; |
|
| 734 | + } |
|
| 715 | 735 | } |
| 716 | 736 | // Has the poll been reset since guest voted? |
| 717 | 737 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 718 | 738 | { |
| 719 | 739 | // Remove the poll info from the cookie to allow guest to vote again |
| 720 | 740 | unset($guestinfo[$i]); |
| 721 | - if (!empty($guestinfo)) |
|
| 722 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 723 | - else |
|
| 724 | - unset($_COOKIE['guest_poll_vote']); |
|
| 725 | - } |
|
| 726 | - else |
|
| 741 | + if (!empty($guestinfo)) { |
|
| 742 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 743 | + } else { |
|
| 744 | + unset($_COOKIE['guest_poll_vote']); |
|
| 745 | + } |
|
| 746 | + } else |
|
| 727 | 747 | { |
| 728 | 748 | // What did they vote for? |
| 729 | 749 | unset($guestvoted[0], $guestvoted[1]); |
@@ -837,23 +857,29 @@ discard block |
||
| 837 | 857 | // Build the poll moderation button array. |
| 838 | 858 | $context['poll_buttons'] = array(); |
| 839 | 859 | |
| 840 | - if ($context['allow_return_vote']) |
|
| 841 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 860 | + if ($context['allow_return_vote']) { |
|
| 861 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 862 | + } |
|
| 842 | 863 | |
| 843 | - if ($context['show_view_results_button']) |
|
| 844 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 864 | + if ($context['show_view_results_button']) { |
|
| 865 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 866 | + } |
|
| 845 | 867 | |
| 846 | - if ($context['allow_change_vote']) |
|
| 847 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 868 | + if ($context['allow_change_vote']) { |
|
| 869 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 870 | + } |
|
| 848 | 871 | |
| 849 | - if ($context['allow_lock_poll']) |
|
| 850 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 872 | + if ($context['allow_lock_poll']) { |
|
| 873 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 874 | + } |
|
| 851 | 875 | |
| 852 | - if ($context['allow_edit_poll']) |
|
| 853 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 876 | + if ($context['allow_edit_poll']) { |
|
| 877 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 878 | + } |
|
| 854 | 879 | |
| 855 | - if ($context['can_remove_poll']) |
|
| 856 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 880 | + if ($context['can_remove_poll']) { |
|
| 881 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 882 | + } |
|
| 857 | 883 | |
| 858 | 884 | // Allow mods to add additional buttons here |
| 859 | 885 | call_integration_hook('integrate_poll_buttons'); |
@@ -889,9 +915,9 @@ discard block |
||
| 889 | 915 | { |
| 890 | 916 | $start_char = 'C'; |
| 891 | 917 | $page_id = $ascending ? $context['topicinfo']['id_first_msg'] : $context['topicinfo']['id_last_msg']; |
| 918 | + } else { |
|
| 919 | + $start_char = null; |
|
| 892 | 920 | } |
| 893 | - else |
|
| 894 | - $start_char = null; |
|
| 895 | 921 | |
| 896 | 922 | $limit = $context['messages_per_page']; |
| 897 | 923 | |
@@ -905,17 +931,17 @@ discard block |
||
| 905 | 931 | { |
| 906 | 932 | $ascending_seek = true; |
| 907 | 933 | $page_operator = $ascending ? '>=' : '<='; |
| 908 | - } |
|
| 909 | - else |
|
| 934 | + } else |
|
| 910 | 935 | { |
| 911 | 936 | $ascending_seek = false; |
| 912 | 937 | $page_operator = $ascending ? '<=' : '>='; |
| 913 | 938 | } |
| 914 | 939 | |
| 915 | - if ($start_char === 'C') |
|
| 916 | - $limit_seek = $limit; |
|
| 917 | - else |
|
| 918 | - $limit_seek = $limit + 1; |
|
| 940 | + if ($start_char === 'C') { |
|
| 941 | + $limit_seek = $limit; |
|
| 942 | + } else { |
|
| 943 | + $limit_seek = $limit + 1; |
|
| 944 | + } |
|
| 919 | 945 | |
| 920 | 946 | $request = $smcFunc['db_query']('', ' |
| 921 | 947 | SELECT id_msg, id_member, approved |
@@ -938,21 +964,23 @@ discard block |
||
| 938 | 964 | $found_msg = false; |
| 939 | 965 | |
| 940 | 966 | // Fallback |
| 941 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
| 942 | - unset($start_char); |
|
| 943 | - else |
|
| 967 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
| 968 | + unset($start_char); |
|
| 969 | + } else |
|
| 944 | 970 | { |
| 945 | 971 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 946 | 972 | { |
| 947 | 973 | // Check if the start msg is in our result |
| 948 | - if ($row['id_msg'] == $page_id) |
|
| 949 | - $found_msg = true; |
|
| 974 | + if ($row['id_msg'] == $page_id) { |
|
| 975 | + $found_msg = true; |
|
| 976 | + } |
|
| 950 | 977 | |
| 951 | 978 | // Skip the the start msg if we not in mode C |
| 952 | 979 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
| 953 | 980 | { |
| 954 | - if (!empty($row['id_member'])) |
|
| 955 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 981 | + if (!empty($row['id_member'])) { |
|
| 982 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 983 | + } |
|
| 956 | 984 | |
| 957 | 985 | $messages[] = $row['id_msg']; |
| 958 | 986 | } |
@@ -968,8 +996,9 @@ discard block |
||
| 968 | 996 | } |
| 969 | 997 | |
| 970 | 998 | // Before Page bring in the right order |
| 971 | - if (!empty($start_char) && $start_char === 'L') |
|
| 972 | - krsort($messages); |
|
| 999 | + if (!empty($start_char) && $start_char === 'L') { |
|
| 1000 | + krsort($messages); |
|
| 1001 | + } |
|
| 973 | 1002 | } |
| 974 | 1003 | |
| 975 | 1004 | // Jump to page |
@@ -1004,14 +1033,16 @@ discard block |
||
| 1004 | 1033 | |
| 1005 | 1034 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1006 | 1035 | { |
| 1007 | - if (!empty($row['id_member'])) |
|
| 1008 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1036 | + if (!empty($row['id_member'])) { |
|
| 1037 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 1038 | + } |
|
| 1009 | 1039 | $messages[] = $row['id_msg']; |
| 1010 | 1040 | } |
| 1011 | 1041 | |
| 1012 | 1042 | // Sort the messages into the correct display order |
| 1013 | - if (!$ascending) |
|
| 1014 | - sort($messages); |
|
| 1043 | + if (!$ascending) { |
|
| 1044 | + sort($messages); |
|
| 1045 | + } |
|
| 1015 | 1046 | } |
| 1016 | 1047 | |
| 1017 | 1048 | // Remember the paging data for next time |
@@ -1031,8 +1062,9 @@ discard block |
||
| 1031 | 1062 | if (!$user_info['is_guest'] && !empty($messages)) |
| 1032 | 1063 | { |
| 1033 | 1064 | $mark_at_msg = max($messages); |
| 1034 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
| 1035 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1065 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 1066 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
| 1067 | + } |
|
| 1036 | 1068 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
| 1037 | 1069 | { |
| 1038 | 1070 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1064,8 +1096,9 @@ discard block |
||
| 1064 | 1096 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1065 | 1097 | { |
| 1066 | 1098 | // Find if this topic is marked for notification... |
| 1067 | - if (!empty($row['id_topic'])) |
|
| 1068 | - $context['is_marked_notify'] = true; |
|
| 1099 | + if (!empty($row['id_topic'])) { |
|
| 1100 | + $context['is_marked_notify'] = true; |
|
| 1101 | + } |
|
| 1069 | 1102 | |
| 1070 | 1103 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
| 1071 | 1104 | if (!empty($row['sent']) && $do_once) |
@@ -1087,8 +1120,9 @@ discard block |
||
| 1087 | 1120 | } |
| 1088 | 1121 | |
| 1089 | 1122 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
| 1090 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
| 1091 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1123 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
| 1124 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1125 | + } |
|
| 1092 | 1126 | // Mark board as seen if this is the only new topic. |
| 1093 | 1127 | elseif (isset($_REQUEST['topicseen'])) |
| 1094 | 1128 | { |
@@ -1112,14 +1146,16 @@ discard block |
||
| 1112 | 1146 | $smcFunc['db_free_result']($request); |
| 1113 | 1147 | |
| 1114 | 1148 | // If there're no real new topics in this board, mark the board as seen. |
| 1115 | - if (empty($numNewTopics)) |
|
| 1116 | - $_REQUEST['boardseen'] = true; |
|
| 1117 | - else |
|
| 1118 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1149 | + if (empty($numNewTopics)) { |
|
| 1150 | + $_REQUEST['boardseen'] = true; |
|
| 1151 | + } else { |
|
| 1152 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1153 | + } |
|
| 1119 | 1154 | } |
| 1120 | 1155 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
| 1121 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
| 1122 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1156 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 1157 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1158 | + } |
|
| 1123 | 1159 | |
| 1124 | 1160 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
| 1125 | 1161 | if (isset($_REQUEST['boardseen'])) |
@@ -1176,23 +1212,26 @@ discard block |
||
| 1176 | 1212 | $temp = array(); |
| 1177 | 1213 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1178 | 1214 | { |
| 1179 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
| 1180 | - continue; |
|
| 1215 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
| 1216 | + continue; |
|
| 1217 | + } |
|
| 1181 | 1218 | |
| 1182 | 1219 | $temp[$row['id_attach']] = $row; |
| 1183 | 1220 | $temp[$row['id_attach']]['topic'] = $topic; |
| 1184 | 1221 | $temp[$row['id_attach']]['board'] = $board; |
| 1185 | 1222 | |
| 1186 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
| 1187 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1223 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
| 1224 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1225 | + } |
|
| 1188 | 1226 | } |
| 1189 | 1227 | $smcFunc['db_free_result']($request); |
| 1190 | 1228 | |
| 1191 | 1229 | // This is better than sorting it with the query... |
| 1192 | 1230 | ksort($temp); |
| 1193 | 1231 | |
| 1194 | - foreach ($temp as $row) |
|
| 1195 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1232 | + foreach ($temp as $row) { |
|
| 1233 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1234 | + } |
|
| 1196 | 1235 | } |
| 1197 | 1236 | |
| 1198 | 1237 | $msg_parameters = array( |
@@ -1219,21 +1258,23 @@ discard block |
||
| 1219 | 1258 | ); |
| 1220 | 1259 | |
| 1221 | 1260 | // And the likes |
| 1222 | - if (!empty($modSettings['enable_likes'])) |
|
| 1223 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1261 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1262 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1263 | + } |
|
| 1224 | 1264 | |
| 1225 | 1265 | // Go to the last message if the given time is beyond the time of the last message. |
| 1226 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
| 1227 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1266 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
| 1267 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1268 | + } |
|
| 1228 | 1269 | |
| 1229 | 1270 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
| 1230 | 1271 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
| 1231 | - if (empty($options['view_newest_first'])) |
|
| 1232 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1233 | - else |
|
| 1234 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1235 | - } |
|
| 1236 | - else |
|
| 1272 | + if (empty($options['view_newest_first'])) { |
|
| 1273 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1274 | + } else { |
|
| 1275 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1276 | + } |
|
| 1277 | + } else |
|
| 1237 | 1278 | { |
| 1238 | 1279 | $messages_request = false; |
| 1239 | 1280 | $context['first_message'] = 0; |
@@ -1268,8 +1309,9 @@ discard block |
||
| 1268 | 1309 | 'can_restore_msg' => 'move_any', |
| 1269 | 1310 | 'can_like' => 'likes_like', |
| 1270 | 1311 | ); |
| 1271 | - foreach ($common_permissions as $contextual => $perm) |
|
| 1272 | - $context[$contextual] = allowedTo($perm); |
|
| 1312 | + foreach ($common_permissions as $contextual => $perm) { |
|
| 1313 | + $context[$contextual] = allowedTo($perm); |
|
| 1314 | + } |
|
| 1273 | 1315 | |
| 1274 | 1316 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
| 1275 | 1317 | $anyown_permissions = array( |
@@ -1282,8 +1324,9 @@ discard block |
||
| 1282 | 1324 | 'can_reply_unapproved' => 'post_unapproved_replies', |
| 1283 | 1325 | 'can_view_warning' => 'profile_warning', |
| 1284 | 1326 | ); |
| 1285 | - foreach ($anyown_permissions as $contextual => $perm) |
|
| 1286 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1327 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
| 1328 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1329 | + } |
|
| 1287 | 1330 | |
| 1288 | 1331 | if (!$user_info['is_admin'] && $context['can_move'] && !$modSettings['topic_move_any']) |
| 1289 | 1332 | { |
@@ -1329,8 +1372,9 @@ discard block |
||
| 1329 | 1372 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
| 1330 | 1373 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
| 1331 | 1374 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
| 1332 | - if (!empty($context['drafts_save'])) |
|
| 1333 | - loadLanguage('Drafts'); |
|
| 1375 | + if (!empty($context['drafts_save'])) { |
|
| 1376 | + loadLanguage('Drafts'); |
|
| 1377 | + } |
|
| 1334 | 1378 | |
| 1335 | 1379 | // When was the last time this topic was replied to? Should we warn them about it? |
| 1336 | 1380 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1391,26 +1435,31 @@ discard block |
||
| 1391 | 1435 | // Message icons - customized icons are off? |
| 1392 | 1436 | $context['icons'] = getMessageIcons($board); |
| 1393 | 1437 | |
| 1394 | - if (!empty($context['icons'])) |
|
| 1395 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1438 | + if (!empty($context['icons'])) { |
|
| 1439 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1440 | + } |
|
| 1396 | 1441 | |
| 1397 | 1442 | // Build the normal button array. |
| 1398 | 1443 | $context['normal_buttons'] = array(); |
| 1399 | 1444 | |
| 1400 | - if ($context['can_reply']) |
|
| 1401 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1445 | + if ($context['can_reply']) { |
|
| 1446 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1447 | + } |
|
| 1402 | 1448 | |
| 1403 | - if ($context['can_add_poll']) |
|
| 1404 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1449 | + if ($context['can_add_poll']) { |
|
| 1450 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1451 | + } |
|
| 1405 | 1452 | |
| 1406 | - if ($context['can_mark_unread']) |
|
| 1407 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1453 | + if ($context['can_mark_unread']) { |
|
| 1454 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1455 | + } |
|
| 1408 | 1456 | |
| 1409 | - if ($context['can_print']) |
|
| 1410 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1457 | + if ($context['can_print']) { |
|
| 1458 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1459 | + } |
|
| 1411 | 1460 | |
| 1412 | - if ($context['can_set_notify']) |
|
| 1413 | - $context['normal_buttons']['notify'] = array( |
|
| 1461 | + if ($context['can_set_notify']) { |
|
| 1462 | + $context['normal_buttons']['notify'] = array( |
|
| 1414 | 1463 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
| 1415 | 1464 | 'sub_buttons' => array( |
| 1416 | 1465 | array( |
@@ -1432,38 +1481,47 @@ discard block |
||
| 1432 | 1481 | ), |
| 1433 | 1482 | ), |
| 1434 | 1483 | ); |
| 1484 | + } |
|
| 1435 | 1485 | |
| 1436 | 1486 | // Build the mod button array |
| 1437 | 1487 | $context['mod_buttons'] = array(); |
| 1438 | 1488 | |
| 1439 | - if ($context['can_move']) |
|
| 1440 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1489 | + if ($context['can_move']) { |
|
| 1490 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1491 | + } |
|
| 1441 | 1492 | |
| 1442 | - if ($context['can_delete']) |
|
| 1443 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1493 | + if ($context['can_delete']) { |
|
| 1494 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1495 | + } |
|
| 1444 | 1496 | |
| 1445 | - if ($context['can_lock']) |
|
| 1446 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_locked'] ? 'unlock' : 'lock') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1497 | + if ($context['can_lock']) { |
|
| 1498 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_locked'] ? 'unlock' : 'lock') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1499 | + } |
|
| 1447 | 1500 | |
| 1448 | - if ($context['can_sticky']) |
|
| 1449 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_sticky'] ? 'nonsticky' : 'sticky') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1501 | + if ($context['can_sticky']) { |
|
| 1502 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_sticky'] ? 'nonsticky' : 'sticky') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1503 | + } |
|
| 1450 | 1504 | |
| 1451 | - if ($context['can_merge']) |
|
| 1452 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1505 | + if ($context['can_merge']) { |
|
| 1506 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1507 | + } |
|
| 1453 | 1508 | |
| 1454 | - if ($context['calendar_post']) |
|
| 1455 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1509 | + if ($context['calendar_post']) { |
|
| 1510 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1511 | + } |
|
| 1456 | 1512 | |
| 1457 | 1513 | // Restore topic. eh? No monkey business. |
| 1458 | - if ($context['can_restore_topic']) |
|
| 1459 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1514 | + if ($context['can_restore_topic']) { |
|
| 1515 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1516 | + } |
|
| 1460 | 1517 | |
| 1461 | 1518 | // Show a message in case a recently posted message became unapproved. |
| 1462 | 1519 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 1463 | 1520 | |
| 1464 | 1521 | // Don't want to show this forever... |
| 1465 | - if ($context['becomesUnapproved']) |
|
| 1466 | - unset($_SESSION['becomesUnapproved']); |
|
| 1522 | + if ($context['becomesUnapproved']) { |
|
| 1523 | + unset($_SESSION['becomesUnapproved']); |
|
| 1524 | + } |
|
| 1467 | 1525 | |
| 1468 | 1526 | // Allow adding new mod buttons easily. |
| 1469 | 1527 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1472,12 +1530,14 @@ discard block |
||
| 1472 | 1530 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
| 1473 | 1531 | |
| 1474 | 1532 | // Load the drafts js file |
| 1475 | - if ($context['drafts_autosave']) |
|
| 1476 | - loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts'); |
|
| 1533 | + if ($context['drafts_autosave']) { |
|
| 1534 | + loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts'); |
|
| 1535 | + } |
|
| 1477 | 1536 | |
| 1478 | 1537 | // Spellcheck |
| 1479 | - if ($context['show_spellchecking']) |
|
| 1480 | - loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
| 1538 | + if ($context['show_spellchecking']) { |
|
| 1539 | + loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
| 1540 | + } |
|
| 1481 | 1541 | |
| 1482 | 1542 | // topic.js |
| 1483 | 1543 | loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic'); |
@@ -1511,16 +1571,19 @@ discard block |
||
| 1511 | 1571 | static $counter = null; |
| 1512 | 1572 | |
| 1513 | 1573 | // If the query returned false, bail. |
| 1514 | - if ($messages_request == false) |
|
| 1515 | - return false; |
|
| 1574 | + if ($messages_request == false) { |
|
| 1575 | + return false; |
|
| 1576 | + } |
|
| 1516 | 1577 | |
| 1517 | 1578 | // Remember which message this is. (ie. reply #83) |
| 1518 | - if ($counter === null || $reset) |
|
| 1519 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1579 | + if ($counter === null || $reset) { |
|
| 1580 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1581 | + } |
|
| 1520 | 1582 | |
| 1521 | 1583 | // Start from the beginning... |
| 1522 | - if ($reset) |
|
| 1523 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1584 | + if ($reset) { |
|
| 1585 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1586 | + } |
|
| 1524 | 1587 | |
| 1525 | 1588 | // Attempt to get the next message. |
| 1526 | 1589 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1534,19 +1597,21 @@ discard block |
||
| 1534 | 1597 | if (empty($context['icon_sources'])) |
| 1535 | 1598 | { |
| 1536 | 1599 | $context['icon_sources'] = array(); |
| 1537 | - foreach ($context['stable_icons'] as $icon) |
|
| 1538 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1600 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1601 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1602 | + } |
|
| 1539 | 1603 | } |
| 1540 | 1604 | |
| 1541 | 1605 | // Message Icon Management... check the images exist. |
| 1542 | 1606 | if (empty($modSettings['messageIconChecks_disable'])) |
| 1543 | 1607 | { |
| 1544 | 1608 | // If the current icon isn't known, then we need to do something... |
| 1545 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1546 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1609 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1610 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1611 | + } |
|
| 1612 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1613 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1547 | 1614 | } |
| 1548 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
| 1549 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1550 | 1615 | |
| 1551 | 1616 | // If you're a lazy bum, you probably didn't give a subject... |
| 1552 | 1617 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1571,8 +1636,7 @@ discard block |
||
| 1571 | 1636 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
| 1572 | 1637 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
| 1573 | 1638 | $memberContext[$message['id_member']]['is_guest'] = true; |
| 1574 | - } |
|
| 1575 | - else |
|
| 1639 | + } else |
|
| 1576 | 1640 | { |
| 1577 | 1641 | // Define this here to make things a bit more readable |
| 1578 | 1642 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1595,8 +1659,9 @@ discard block |
||
| 1595 | 1659 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
| 1596 | 1660 | |
| 1597 | 1661 | // If it's in the recycle bin we need to override whatever icon we did have. |
| 1598 | - if (!empty($board_info['recycle'])) |
|
| 1599 | - $message['icon'] = 'recycled'; |
|
| 1662 | + if (!empty($board_info['recycle'])) { |
|
| 1663 | + $message['icon'] = 'recycled'; |
|
| 1664 | + } |
|
| 1600 | 1665 | |
| 1601 | 1666 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1602 | 1667 | |
@@ -1640,32 +1705,36 @@ discard block |
||
| 1640 | 1705 | } |
| 1641 | 1706 | |
| 1642 | 1707 | // Are likes enable? |
| 1643 | - if (!empty($modSettings['enable_likes'])) |
|
| 1644 | - $output['likes'] = array( |
|
| 1708 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1709 | + $output['likes'] = array( |
|
| 1645 | 1710 | 'count' => $message['likes'], |
| 1646 | 1711 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
| 1647 | 1712 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 1648 | 1713 | ); |
| 1714 | + } |
|
| 1649 | 1715 | |
| 1650 | 1716 | // Is this user the message author? |
| 1651 | 1717 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
| 1652 | - if (!empty($output['modified']['name'])) |
|
| 1653 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1718 | + if (!empty($output['modified']['name'])) { |
|
| 1719 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1720 | + } |
|
| 1654 | 1721 | |
| 1655 | 1722 | // Did they give a reason for editing? |
| 1656 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
| 1657 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1723 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
| 1724 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1725 | + } |
|
| 1658 | 1726 | |
| 1659 | 1727 | // Any custom profile fields? |
| 1660 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
| 1661 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1728 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
| 1729 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1662 | 1730 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1731 | + } |
|
| 1663 | 1732 | |
| 1664 | - if (empty($options['view_newest_first'])) |
|
| 1665 | - $counter++; |
|
| 1666 | - |
|
| 1667 | - else |
|
| 1668 | - $counter--; |
|
| 1733 | + if (empty($options['view_newest_first'])) { |
|
| 1734 | + $counter++; |
|
| 1735 | + } else { |
|
| 1736 | + $counter--; |
|
| 1737 | + } |
|
| 1669 | 1738 | |
| 1670 | 1739 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
| 1671 | 1740 | |
@@ -1691,8 +1760,9 @@ discard block |
||
| 1691 | 1760 | */ |
| 1692 | 1761 | function approved_attach_sort($a, $b) |
| 1693 | 1762 | { |
| 1694 | - if ($a['is_approved'] == $b['is_approved']) |
|
| 1695 | - return 0; |
|
| 1763 | + if ($a['is_approved'] == $b['is_approved']) { |
|
| 1764 | + return 0; |
|
| 1765 | + } |
|
| 1696 | 1766 | |
| 1697 | 1767 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
| 1698 | 1768 | } |
@@ -1709,16 +1779,19 @@ discard block |
||
| 1709 | 1779 | |
| 1710 | 1780 | require_once($sourcedir . '/RemoveTopic.php'); |
| 1711 | 1781 | |
| 1712 | - if (empty($_REQUEST['msgs'])) |
|
| 1713 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1782 | + if (empty($_REQUEST['msgs'])) { |
|
| 1783 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1784 | + } |
|
| 1714 | 1785 | |
| 1715 | 1786 | $messages = array(); |
| 1716 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
| 1717 | - $messages[] = (int) $dummy; |
|
| 1787 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
| 1788 | + $messages[] = (int) $dummy; |
|
| 1789 | + } |
|
| 1718 | 1790 | |
| 1719 | 1791 | // We are restoring messages. We handle this in another place. |
| 1720 | - if (isset($_REQUEST['restore_selected'])) |
|
| 1721 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1792 | + if (isset($_REQUEST['restore_selected'])) { |
|
| 1793 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1794 | + } |
|
| 1722 | 1795 | if (isset($_REQUEST['split_selection'])) |
| 1723 | 1796 | { |
| 1724 | 1797 | $request = $smcFunc['db_query']('', ' |
@@ -1737,8 +1810,9 @@ discard block |
||
| 1737 | 1810 | } |
| 1738 | 1811 | |
| 1739 | 1812 | // Allowed to delete any message? |
| 1740 | - if (allowedTo('delete_any')) |
|
| 1741 | - $allowed_all = true; |
|
| 1813 | + if (allowedTo('delete_any')) { |
|
| 1814 | + $allowed_all = true; |
|
| 1815 | + } |
|
| 1742 | 1816 | // Allowed to delete replies to their messages? |
| 1743 | 1817 | elseif (allowedTo('delete_replies')) |
| 1744 | 1818 | { |
@@ -1755,13 +1829,14 @@ discard block |
||
| 1755 | 1829 | $smcFunc['db_free_result']($request); |
| 1756 | 1830 | |
| 1757 | 1831 | $allowed_all = $starter == $user_info['id']; |
| 1832 | + } else { |
|
| 1833 | + $allowed_all = false; |
|
| 1758 | 1834 | } |
| 1759 | - else |
|
| 1760 | - $allowed_all = false; |
|
| 1761 | 1835 | |
| 1762 | 1836 | // Make sure they're allowed to delete their own messages, if not any. |
| 1763 | - if (!$allowed_all) |
|
| 1764 | - isAllowedTo('delete_own'); |
|
| 1837 | + if (!$allowed_all) { |
|
| 1838 | + isAllowedTo('delete_own'); |
|
| 1839 | + } |
|
| 1765 | 1840 | |
| 1766 | 1841 | // Allowed to remove which messages? |
| 1767 | 1842 | $request = $smcFunc['db_query']('', ' |
@@ -1781,8 +1856,9 @@ discard block |
||
| 1781 | 1856 | $messages = array(); |
| 1782 | 1857 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1783 | 1858 | { |
| 1784 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 1785 | - continue; |
|
| 1859 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 1860 | + continue; |
|
| 1861 | + } |
|
| 1786 | 1862 | |
| 1787 | 1863 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
| 1788 | 1864 | } |
@@ -1805,17 +1881,20 @@ discard block |
||
| 1805 | 1881 | foreach ($messages as $message => $info) |
| 1806 | 1882 | { |
| 1807 | 1883 | // Just skip the first message - if it's not the last. |
| 1808 | - if ($message == $first_message && $message != $last_message) |
|
| 1809 | - continue; |
|
| 1884 | + if ($message == $first_message && $message != $last_message) { |
|
| 1885 | + continue; |
|
| 1886 | + } |
|
| 1810 | 1887 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
| 1811 | - elseif ($message == $first_message) |
|
| 1812 | - $topicGone = true; |
|
| 1888 | + elseif ($message == $first_message) { |
|
| 1889 | + $topicGone = true; |
|
| 1890 | + } |
|
| 1813 | 1891 | |
| 1814 | 1892 | removeMessage($message); |
| 1815 | 1893 | |
| 1816 | 1894 | // Log this moderation action ;). |
| 1817 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 1818 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1895 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 1896 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1897 | + } |
|
| 1819 | 1898 | } |
| 1820 | 1899 | |
| 1821 | 1900 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -27,9 +27,10 @@ discard block |
||
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
| 29 | 29 | |
| 30 | - if (!isset($context['old_search'])) |
|
| 31 | - echo ' |
|
| 30 | + if (!isset($context['old_search'])) { |
|
| 31 | + echo ' |
|
| 32 | 32 | <span class="floatright">', $context['letter_links'], '</span>'; |
| 33 | + } |
|
| 33 | 34 | echo ' |
| 34 | 35 | </h3> |
| 35 | 36 | </div>'; |
@@ -44,20 +45,23 @@ discard block |
||
| 44 | 45 | foreach ($context['columns'] as $key => $column) |
| 45 | 46 | { |
| 46 | 47 | // @TODO maybe find something nicer? |
| 47 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
| 48 | - continue; |
|
| 48 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
| 49 | + continue; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // This is a selected column, so underline it or some such. |
| 51 | - if ($column['selected']) |
|
| 52 | - echo ' |
|
| 53 | + if ($column['selected']) { |
|
| 54 | + echo ' |
|
| 53 | 55 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
| 54 | 56 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
| 57 | + } |
|
| 55 | 58 | |
| 56 | 59 | // This is just some column... show the link and be done with it. |
| 57 | - else |
|
| 58 | - echo ' |
|
| 60 | + else { |
|
| 61 | + echo ' |
|
| 59 | 62 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
| 60 | 63 | ', $column['link'], '</th>'; |
| 64 | + } |
|
| 61 | 65 | } |
| 62 | 66 | |
| 63 | 67 | echo ' |
@@ -77,9 +81,10 @@ discard block |
||
| 77 | 81 | </td> |
| 78 | 82 | <td class="real_name lefttext">', $member['link'], '</td>'; |
| 79 | 83 | |
| 80 | - if (!isset($context['disabled_fields']['website'])) |
|
| 81 | - echo ' |
|
| 84 | + if (!isset($context['disabled_fields']['website'])) { |
|
| 85 | + echo ' |
|
| 82 | 86 | <td class="website_url centertext">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
| 87 | + } |
|
| 83 | 88 | |
| 84 | 89 | // Group and date. |
| 85 | 90 | echo ' |
@@ -91,33 +96,36 @@ discard block |
||
| 91 | 96 | echo ' |
| 92 | 97 | <td class="post_count centertext">'; |
| 93 | 98 | |
| 94 | - if (!empty($member['post_percent'])) |
|
| 95 | - echo ' |
|
| 99 | + if (!empty($member['post_percent'])) { |
|
| 100 | + echo ' |
|
| 96 | 101 | <div class="generic_bar"> |
| 97 | 102 | <div class="bar" style="width: ', $member['post_percent'], '%;"></div> |
| 98 | 103 | <span>', $member['posts'], '</span> |
| 99 | 104 | </div>'; |
| 105 | + } |
|
| 100 | 106 | |
| 101 | 107 | echo ' |
| 102 | 108 | </td>'; |
| 103 | 109 | } |
| 104 | 110 | |
| 105 | 111 | // Show custom fields marked to be shown here |
| 106 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 107 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
| 112 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 113 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
| 108 | 114 | echo ' |
| 109 | 115 | <td class="' , $key , ' centertext">', $member['options'][$key], '</td>'; |
| 116 | + } |
|
| 110 | 117 | |
| 111 | 118 | echo ' |
| 112 | 119 | </tr>'; |
| 113 | 120 | } |
| 114 | 121 | } |
| 115 | 122 | // No members? |
| 116 | - else |
|
| 117 | - echo ' |
|
| 123 | + else { |
|
| 124 | + echo ' |
|
| 118 | 125 | <tr> |
| 119 | 126 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
| 120 | 127 | </tr>'; |
| 128 | + } |
|
| 121 | 129 | |
| 122 | 130 | echo ' |
| 123 | 131 | </tbody> |
@@ -130,11 +138,12 @@ discard block |
||
| 130 | 138 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
| 131 | 139 | |
| 132 | 140 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
| 133 | - if (isset($context['old_search'])) |
|
| 134 | - echo ' |
|
| 141 | + if (isset($context['old_search'])) { |
|
| 142 | + echo ' |
|
| 135 | 143 | <div class="buttonlist floatright"> |
| 136 | 144 | <a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a> |
| 137 | 145 | </div>'; |
| 146 | + } |
|
| 138 | 147 | echo ' |
| 139 | 148 | </div> |
| 140 | 149 | </div><!-- #memberlist -->'; |
@@ -174,12 +183,13 @@ discard block |
||
| 174 | 183 | <dd> |
| 175 | 184 | <ul>'; |
| 176 | 185 | |
| 177 | - foreach ($context['search_fields'] as $id => $title) |
|
| 178 | - echo ' |
|
| 186 | + foreach ($context['search_fields'] as $id => $title) { |
|
| 187 | + echo ' |
|
| 179 | 188 | <li> |
| 180 | 189 | <input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '> |
| 181 | 190 | <label for="fields-', $id, '">', $title, '</label> |
| 182 | 191 | </li>'; |
| 192 | + } |
|
| 183 | 193 | |
| 184 | 194 | echo ' |
| 185 | 195 | </ul> |