@@ -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 | * Class Likes |
@@ -106,8 +107,9 @@ discard block |
||
| 106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
| 107 | 108 | |
| 108 | 109 | // We do not want to output debug information here. |
| 109 | - if ($this->_js) |
|
| 110 | - $db_show_debug = false; |
|
| 110 | + if ($this->_js) { |
|
| 111 | + $db_show_debug = false; |
|
| 112 | + } |
|
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
| 141 | 143 | $call = $this->_sa; |
| 142 | 144 | |
| 143 | 145 | // Guest can only view likes. |
| 144 | - if ($call != 'view') |
|
| 145 | - is_not_guest(); |
|
| 146 | + if ($call != 'view') { |
|
| 147 | + is_not_guest(); |
|
| 148 | + } |
|
| 146 | 149 | |
| 147 | 150 | checkSession('get'); |
| 148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
| 180 | 183 | global $smcFunc, $modSettings; |
| 181 | 184 | |
| 182 | 185 | // This feature is currently disable. |
| 183 | - if (empty($modSettings['enable_likes'])) |
|
| 184 | - return $this->_error = 'like_disable'; |
|
| 186 | + if (empty($modSettings['enable_likes'])) { |
|
| 187 | + return $this->_error = 'like_disable'; |
|
| 188 | + } |
|
| 185 | 189 | |
| 186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
| 187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
| 188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
| 189 | 193 | |
| 190 | - if ($this->_type == '' || $this->_content <= 0) |
|
| 191 | - return $this->_error = 'cannot_'; |
|
| 194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
| 195 | + return $this->_error = 'cannot_'; |
|
| 196 | + } |
|
| 192 | 197 | |
| 193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
| 194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
| 207 | 212 | 'msg' => $this->_content, |
| 208 | 213 | ) |
| 209 | 214 | ); |
| 210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 217 | + } |
|
| 212 | 218 | |
| 213 | 219 | $smcFunc['db_free_result']($request); |
| 214 | - if (empty($this->_idTopic)) |
|
| 215 | - return $this->_error = 'cannot_'; |
|
| 220 | + if (empty($this->_idTopic)) { |
|
| 221 | + return $this->_error = 'cannot_'; |
|
| 222 | + } |
|
| 216 | 223 | |
| 217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
| 218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
| 221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
| 222 | 229 | |
| 223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
| 224 | - } |
|
| 225 | - |
|
| 226 | - else |
|
| 231 | + } else |
|
| 227 | 232 | { |
| 228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
| 229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
| 241 | 246 | if ($result !== false) |
| 242 | 247 | { |
| 243 | 248 | // Match the type with what we already have. |
| 244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
| 245 | - return $this->_error = 'not_valid_like_type'; |
|
| 249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
| 250 | + return $this->_error = 'not_valid_like_type'; |
|
| 251 | + } |
|
| 246 | 252 | |
| 247 | 253 | // Fill out the rest. |
| 248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
| 253 | 259 | } |
| 254 | 260 | } |
| 255 | 261 | |
| 256 | - if (!$found) |
|
| 257 | - return $this->_error = 'cannot_'; |
|
| 262 | + if (!$found) { |
|
| 263 | + return $this->_error = 'cannot_'; |
|
| 264 | + } |
|
| 258 | 265 | } |
| 259 | 266 | |
| 260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
| 261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
| 262 | - return $this->_error = $this->_validLikes['can_like']; |
|
| 268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
| 269 | + return $this->_error = $this->_validLikes['can_like']; |
|
| 270 | + } |
|
| 263 | 271 | } |
| 264 | 272 | |
| 265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
| 284 | 292 | ); |
| 285 | 293 | |
| 286 | 294 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 287 | - if ($this->_sa == __FUNCTION__) |
|
| 288 | - $this->_data = __FUNCTION__; |
|
| 295 | + if ($this->_sa == __FUNCTION__) { |
|
| 296 | + $this->_data = __FUNCTION__; |
|
| 297 | + } |
|
| 289 | 298 | } |
| 290 | 299 | |
| 291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
| 315 | 324 | |
| 316 | 325 | // Add a background task to process sending alerts. |
| 317 | 326 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
| 318 | - if ($this->_type == 'msg') |
|
| 319 | - $smcFunc['db_insert']('insert', |
|
| 327 | + if ($this->_type == 'msg') { |
|
| 328 | + $smcFunc['db_insert']('insert', |
|
| 320 | 329 | '{db_prefix}background_tasks', |
| 321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
| 328 | 337 | )), 0), |
| 329 | 338 | array('id_task') |
| 330 | 339 | ); |
| 340 | + } |
|
| 331 | 341 | |
| 332 | 342 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 333 | - if ($this->_sa == __FUNCTION__) |
|
| 334 | - $this->_data = __FUNCTION__; |
|
| 343 | + if ($this->_sa == __FUNCTION__) { |
|
| 344 | + $this->_data = __FUNCTION__; |
|
| 345 | + } |
|
| 335 | 346 | } |
| 336 | 347 | |
| 337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
| 357 | 368 | $smcFunc['db_free_result']($request); |
| 358 | 369 | |
| 359 | 370 | // If you want to call this directly, fill out _data property too. |
| 360 | - if ($this->_sa == __FUNCTION__) |
|
| 361 | - $this->_data = $this->_numLikes; |
|
| 371 | + if ($this->_sa == __FUNCTION__) { |
|
| 372 | + $this->_data = $this->_numLikes; |
|
| 373 | + } |
|
| 362 | 374 | } |
| 363 | 375 | |
| 364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
| 371 | 383 | global $smcFunc; |
| 372 | 384 | |
| 373 | 385 | // Safety first! |
| 374 | - if (empty($this->_type) || empty($this->_content)) |
|
| 375 | - return $this->_error = 'cannot_'; |
|
| 386 | + if (empty($this->_type) || empty($this->_content)) { |
|
| 387 | + return $this->_error = 'cannot_'; |
|
| 388 | + } |
|
| 376 | 389 | |
| 377 | 390 | // Do we already like this? |
| 378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
| 390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
| 391 | 404 | $smcFunc['db_free_result']($request); |
| 392 | 405 | |
| 393 | - if ($this->_alreadyLiked) |
|
| 394 | - $this->delete(); |
|
| 395 | - |
|
| 396 | - else |
|
| 397 | - $this->insert(); |
|
| 406 | + if ($this->_alreadyLiked) { |
|
| 407 | + $this->delete(); |
|
| 408 | + } else { |
|
| 409 | + $this->insert(); |
|
| 410 | + } |
|
| 398 | 411 | |
| 399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
| 400 | 413 | $this->_count(); |
| 401 | 414 | |
| 402 | 415 | // Update the likes count for messages. |
| 403 | - if ($this->_type == 'msg') |
|
| 404 | - $this->msgIssueLike(); |
|
| 416 | + if ($this->_type == 'msg') { |
|
| 417 | + $this->msgIssueLike(); |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Any callbacks? |
| 407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
| 408 | 422 | { |
| 409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
| 410 | 424 | |
| 411 | - if (!empty($call)) |
|
| 412 | - call_user_func_array($call, array($this)); |
|
| 425 | + if (!empty($call)) { |
|
| 426 | + call_user_func_array($call, array($this)); |
|
| 427 | + } |
|
| 413 | 428 | } |
| 414 | 429 | |
| 415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
| 418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
| 419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
| 420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
| 421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
| 422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
| 437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 438 | + } |
|
| 423 | 439 | |
| 424 | 440 | // All done, start building the data to pass as response. |
| 425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
| 442 | 458 | { |
| 443 | 459 | global $smcFunc; |
| 444 | 460 | |
| 445 | - if ($this->_type !== 'msg') |
|
| 446 | - return; |
|
| 461 | + if ($this->_type !== 'msg') { |
|
| 462 | + return; |
|
| 463 | + } |
|
| 447 | 464 | |
| 448 | 465 | $smcFunc['db_query']('', ' |
| 449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
| 484 | 501 | 'like_type' => $this->_type, |
| 485 | 502 | ) |
| 486 | 503 | ); |
| 487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 506 | + } |
|
| 489 | 507 | |
| 490 | 508 | // Now to get member data, including avatars and so on. |
| 491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
| 493 | 511 | if (count($loaded) != count($members)) |
| 494 | 512 | { |
| 495 | 513 | $members = array_diff($members, $loaded); |
| 496 | - foreach ($members as $not_loaded) |
|
| 497 | - unset ($context['likers'][$not_loaded]); |
|
| 514 | + foreach ($members as $not_loaded) { |
|
| 515 | + unset ($context['likers'][$not_loaded]); |
|
| 516 | + } |
|
| 498 | 517 | } |
| 499 | 518 | |
| 500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
| 536 | 555 | global $context, $txt; |
| 537 | 556 | |
| 538 | 557 | // Don't do anything if someone else has already take care of the response. |
| 539 | - if (!$this->_setResponse) |
|
| 540 | - return; |
|
| 558 | + if (!$this->_setResponse) { |
|
| 559 | + return; |
|
| 560 | + } |
|
| 541 | 561 | |
| 542 | 562 | // Want a json response huh? |
| 543 | - if ($this->_validLikes['json']) |
|
| 544 | - return $this->jsonResponse(); |
|
| 563 | + if ($this->_validLikes['json']) { |
|
| 564 | + return $this->jsonResponse(); |
|
| 565 | + } |
|
| 545 | 566 | |
| 546 | 567 | // Set everything up for display. |
| 547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
| 551 | 572 | if ($this->_error) |
| 552 | 573 | { |
| 553 | 574 | // If this is a generic error, set it up good. |
| 554 | - if ($this->_error == 'cannot_') |
|
| 555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 575 | + if ($this->_error == 'cannot_') { |
|
| 576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 577 | + } |
|
| 556 | 578 | |
| 557 | 579 | // Is this request coming from an ajax call? |
| 558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
| 562 | 584 | } |
| 563 | 585 | |
| 564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
| 565 | - else |
|
| 566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 587 | + else { |
|
| 588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 589 | + } |
|
| 567 | 590 | |
| 568 | 591 | return; |
| 569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
| 572 | 595 | else |
| 573 | 596 | { |
| 574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
| 575 | - if (!$this->_js) |
|
| 576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 598 | + if (!$this->_js) { |
|
| 599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 600 | + } |
|
| 577 | 601 | |
| 578 | 602 | // These fine gentlemen all share the same template. |
| 579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
| 606 | 630 | // If there is an error, send it. |
| 607 | 631 | if ($this->_error) |
| 608 | 632 | { |
| 609 | - if ($this->_error == 'cannot_') |
|
| 610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 633 | + if ($this->_error == 'cannot_') { |
|
| 634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 635 | + } |
|
| 611 | 636 | |
| 612 | 637 | $print['error'] = $this->_error; |
| 613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
| 643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
| 644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
| 645 | 670 | |
| 646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
| 647 | - $_GET['verse'] = '4:16'; |
|
| 671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
| 672 | + $_GET['verse'] = '4:16'; |
|
| 673 | + } |
|
| 648 | 674 | |
| 649 | - if ($_GET['verse'] == '2:18') |
|
| 650 | - echo ' |
|
| 675 | + if ($_GET['verse'] == '2:18') { |
|
| 676 | + echo ' |
|
| 651 | 677 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
| 652 | - elseif ($_GET['verse'] == '4:16') |
|
| 653 | - echo ' |
|
| 678 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 679 | + echo ' |
|
| 654 | 680 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
| 655 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 656 | - echo ' |
|
| 681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 682 | + echo ' |
|
| 657 | 683 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
| 658 | 684 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
| 685 | + } |
|
| 659 | 686 | |
| 660 | 687 | echo ' |
| 661 | 688 | </div> |
| 662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
| 663 | 690 | |
| 664 | - if ($_GET['verse'] == '2:18') |
|
| 665 | - echo ' |
|
| 691 | + if ($_GET['verse'] == '2:18') { |
|
| 692 | + echo ' |
|
| 666 | 693 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
| 667 | - elseif ($_GET['verse'] == '4:16') |
|
| 668 | - echo ' |
|
| 694 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 695 | + echo ' |
|
| 669 | 696 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
| 670 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 671 | - echo ' |
|
| 697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 698 | + echo ' |
|
| 672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
| 700 | + } |
|
| 673 | 701 | |
| 674 | 702 | echo ' |
| 675 | 703 | </div> |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
| 60 | 61 | 'max_year' => $year_high, |
| 61 | 62 | ) |
| 62 | 63 | ); |
| 63 | - } |
|
| 64 | - else |
|
| 64 | + } else |
|
| 65 | 65 | { |
| 66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
| 67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
| 91 | 91 | $bday = array(); |
| 92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 93 | 93 | { |
| 94 | - if ($year_low != $year_high) |
|
| 95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | - else |
|
| 97 | - $age_year = $year_low; |
|
| 94 | + if ($year_low != $year_high) { |
|
| 95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | + } else { |
|
| 97 | + $age_year = $year_low; |
|
| 98 | + } |
|
| 98 | 99 | |
| 99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | ksort($bday); |
| 109 | 110 | |
| 110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
| 111 | - foreach ($bday as $mday => $array) |
|
| 112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 112 | + foreach ($bday as $mday => $array) { |
|
| 113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 114 | + } |
|
| 113 | 115 | |
| 114 | 116 | return $bday; |
| 115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
| 133 | 135 | static $timezone_array = array(); |
| 134 | 136 | require_once($sourcedir . '/Subs.php'); |
| 135 | 137 | |
| 136 | - if (empty($timezone_array['default'])) |
|
| 137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 138 | + if (empty($timezone_array['default'])) { |
|
| 139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 140 | + } |
|
| 138 | 141 | |
| 139 | 142 | $low_object = date_create($low_date); |
| 140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
| 161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 162 | 165 | { |
| 163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 165 | - continue; |
|
| 167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 168 | + continue; |
|
| 169 | + } |
|
| 166 | 170 | |
| 167 | 171 | // Force a censor of the title - as often these are used by others. |
| 168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
| 170 | 174 | // Get the various time and date properties for this event |
| 171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 172 | 176 | |
| 173 | - if (empty($timezone_array[$tz])) |
|
| 174 | - $timezone_array[$tz] = timezone_open($tz); |
|
| 177 | + if (empty($timezone_array[$tz])) { |
|
| 178 | + $timezone_array[$tz] = timezone_open($tz); |
|
| 179 | + } |
|
| 175 | 180 | |
| 176 | 181 | // Sanity check |
| 177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 178 | - continue; |
|
| 182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 179 | 185 | |
| 180 | 186 | // Get set up for the loop |
| 181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
| 239 | 245 | ); |
| 240 | 246 | |
| 241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 242 | - if ($use_permissions) |
|
| 243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 248 | + if ($use_permissions) { |
|
| 249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
| 248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 250 | 256 | )); |
| 257 | + } |
|
| 251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 252 | - else |
|
| 253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 259 | + else { |
|
| 260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
| 260 | 267 | 'poster' => $row['id_member'], |
| 261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 262 | 269 | )); |
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
| 265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
| 269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 270 | 278 | if ($use_permissions) |
| 271 | 279 | { |
| 272 | - foreach ($events as $mday => $array) |
|
| 273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 280 | + foreach ($events as $mday => $array) { |
|
| 281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 282 | + } |
|
| 274 | 283 | } |
| 275 | 284 | |
| 276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
| 290 | 299 | global $smcFunc; |
| 291 | 300 | |
| 292 | 301 | // Get the lowest and highest dates for "all years". |
| 293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 296 | - else |
|
| 297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 305 | + } else { |
|
| 306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 307 | + } |
|
| 298 | 308 | |
| 299 | 309 | // Find some holidays... ;). |
| 300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
| 314 | 324 | $holidays = array(); |
| 315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 316 | 326 | { |
| 317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 319 | - else |
|
| 320 | - $event_year = substr($low_date, 0, 4); |
|
| 327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 329 | + } else { |
|
| 330 | + $event_year = substr($low_date, 0, 4); |
|
| 331 | + } |
|
| 321 | 332 | |
| 322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
| 343 | 354 | isAllowedTo('calendar_post'); |
| 344 | 355 | |
| 345 | 356 | // No board? No topic?!? |
| 346 | - if (empty($board)) |
|
| 347 | - fatal_lang_error('missing_board_id', false); |
|
| 348 | - if (empty($topic)) |
|
| 349 | - fatal_lang_error('missing_topic_id', false); |
|
| 357 | + if (empty($board)) { |
|
| 358 | + fatal_lang_error('missing_board_id', false); |
|
| 359 | + } |
|
| 360 | + if (empty($topic)) { |
|
| 361 | + fatal_lang_error('missing_topic_id', false); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Administrator, Moderator, or owner. Period. |
| 352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
| 364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 378 | { |
| 366 | 379 | // Not the owner of the topic. |
| 367 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 368 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 381 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 382 | + } |
|
| 369 | 383 | } |
| 370 | 384 | // Topic/Board doesn't exist..... |
| 371 | - else |
|
| 372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 385 | + else { |
|
| 386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 387 | + } |
|
| 373 | 388 | $smcFunc['db_free_result']($result); |
| 374 | 389 | } |
| 375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
| 457 | 472 | if (!empty($calendarOptions['start_day'])) |
| 458 | 473 | { |
| 459 | 474 | $nShift -= $calendarOptions['start_day']; |
| 460 | - if ($nShift < 0) |
|
| 461 | - $nShift = 7 + $nShift; |
|
| 475 | + if ($nShift < 0) { |
|
| 476 | + $nShift = 7 + $nShift; |
|
| 477 | + } |
|
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | // Number of rows required to fit the month. |
| 465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 467 | - $nRows++; |
|
| 482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 483 | + $nRows++; |
|
| 484 | + } |
|
| 468 | 485 | |
| 469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
| 477 | 494 | { |
| 478 | 495 | $calendarGrid['week_days'][] = $count; |
| 479 | 496 | $count++; |
| 480 | - if ($count == 7) |
|
| 481 | - $count = 0; |
|
| 497 | + if ($count == 7) { |
|
| 498 | + $count = 0; |
|
| 499 | + } |
|
| 482 | 500 | } |
| 483 | 501 | |
| 484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
| 495 | 513 | { |
| 496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 497 | 515 | |
| 498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 499 | - $nDay = 0; |
|
| 516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 517 | + $nDay = 0; |
|
| 518 | + } |
|
| 500 | 519 | |
| 501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
| 514 | 533 | } |
| 515 | 534 | |
| 516 | 535 | // What is the last day of the month? |
| 517 | - if ($is_previous === true) |
|
| 518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 536 | + if ($is_previous === true) { |
|
| 537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 538 | + } |
|
| 519 | 539 | |
| 520 | 540 | // We'll use the shift in the template. |
| 521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
| 549 | 569 | { |
| 550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
| 551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 552 | - if ($date_diff < 0) |
|
| 553 | - $date_diff += 7; |
|
| 572 | + if ($date_diff < 0) { |
|
| 573 | + $date_diff += 7; |
|
| 574 | + } |
|
| 554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
| 556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
| 680 | 701 | { |
| 681 | 702 | foreach ($date_events as $event_key => $event_val) |
| 682 | 703 | { |
| 683 | - if (in_array($event_val['id'], $temp)) |
|
| 684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
| 685 | - else |
|
| 686 | - $temp[] = $event_val['id']; |
|
| 704 | + if (in_array($event_val['id'], $temp)) { |
|
| 705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
| 706 | + } else { |
|
| 707 | + $temp[] = $event_val['id']; |
|
| 708 | + } |
|
| 687 | 709 | } |
| 688 | 710 | } |
| 689 | 711 | |
| 690 | 712 | // Give birthdays and holidays a friendly format, without the year |
| 691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 692 | - $date_format = '%b %d'; |
|
| 693 | - else |
|
| 694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 714 | + $date_format = '%b %d'; |
|
| 715 | + } else { |
|
| 716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 717 | + } |
|
| 695 | 718 | |
| 696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
| 697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
| 790 | 813 | // Holidays between now and now + days. |
| 791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 792 | 815 | { |
| 793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 818 | + } |
|
| 795 | 819 | } |
| 796 | 820 | } |
| 797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
| 803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
| 804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
| 805 | 829 | { |
| 806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 832 | + } |
|
| 808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 809 | 834 | } |
| 810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
| 819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
| 820 | 845 | |
| 821 | 846 | // No events today? Check the next day. |
| 822 | - if (empty($cached_data['events'][$loop_date])) |
|
| 823 | - continue; |
|
| 847 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 848 | + continue; |
|
| 849 | + } |
|
| 824 | 850 | |
| 825 | 851 | // Loop through all events to add a few last-minute values. |
| 826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
| 833 | 859 | { |
| 834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
| 835 | 861 | continue; |
| 862 | + } else { |
|
| 863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 836 | 864 | } |
| 837 | - else |
|
| 838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 839 | 865 | |
| 840 | 866 | // Might be set to true afterwards, depending on the permissions. |
| 841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
| 843 | 869 | $this_event['date'] = $loop_date; |
| 844 | 870 | } |
| 845 | 871 | |
| 846 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 874 | + } |
|
| 848 | 875 | } |
| 849 | 876 | } |
| 850 | 877 | |
| 851 | 878 | // Mark the last item so that a list separator can be used in the template. |
| 852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 881 | + } |
|
| 882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 884 | + } |
|
| 856 | 885 | |
| 857 | 886 | return array( |
| 858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
| 900 | 929 | if (isset($_POST['start_date'])) |
| 901 | 930 | { |
| 902 | 931 | $d = date_parse($_POST['start_date']); |
| 903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 904 | - fatal_lang_error('invalid_date', false); |
|
| 905 | - if (empty($d['year'])) |
|
| 906 | - fatal_lang_error('event_year_missing', false); |
|
| 907 | - if (empty($d['month'])) |
|
| 908 | - fatal_lang_error('event_month_missing', false); |
|
| 909 | - } |
|
| 910 | - elseif (isset($_POST['start_datetime'])) |
|
| 932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 933 | + fatal_lang_error('invalid_date', false); |
|
| 934 | + } |
|
| 935 | + if (empty($d['year'])) { |
|
| 936 | + fatal_lang_error('event_year_missing', false); |
|
| 937 | + } |
|
| 938 | + if (empty($d['month'])) { |
|
| 939 | + fatal_lang_error('event_month_missing', false); |
|
| 940 | + } |
|
| 941 | + } elseif (isset($_POST['start_datetime'])) |
|
| 911 | 942 | { |
| 912 | 943 | $d = date_parse($_POST['start_datetime']); |
| 913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 914 | - fatal_lang_error('invalid_date', false); |
|
| 915 | - if (empty($d['year'])) |
|
| 916 | - fatal_lang_error('event_year_missing', false); |
|
| 917 | - if (empty($d['month'])) |
|
| 918 | - fatal_lang_error('event_month_missing', false); |
|
| 944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 945 | + fatal_lang_error('invalid_date', false); |
|
| 946 | + } |
|
| 947 | + if (empty($d['year'])) { |
|
| 948 | + fatal_lang_error('event_year_missing', false); |
|
| 949 | + } |
|
| 950 | + if (empty($d['month'])) { |
|
| 951 | + fatal_lang_error('event_month_missing', false); |
|
| 952 | + } |
|
| 919 | 953 | } |
| 920 | 954 | // The 2.0 way |
| 921 | 955 | else |
| 922 | 956 | { |
| 923 | 957 | // No month? No year? |
| 924 | - if (!isset($_POST['month'])) |
|
| 925 | - fatal_lang_error('event_month_missing', false); |
|
| 926 | - if (!isset($_POST['year'])) |
|
| 927 | - fatal_lang_error('event_year_missing', false); |
|
| 958 | + if (!isset($_POST['month'])) { |
|
| 959 | + fatal_lang_error('event_month_missing', false); |
|
| 960 | + } |
|
| 961 | + if (!isset($_POST['year'])) { |
|
| 962 | + fatal_lang_error('event_year_missing', false); |
|
| 963 | + } |
|
| 928 | 964 | |
| 929 | 965 | // Check the month and year... |
| 930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 931 | - fatal_lang_error('invalid_month', false); |
|
| 932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 933 | - fatal_lang_error('invalid_year', false); |
|
| 966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 967 | + fatal_lang_error('invalid_month', false); |
|
| 968 | + } |
|
| 969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 970 | + fatal_lang_error('invalid_year', false); |
|
| 971 | + } |
|
| 934 | 972 | } |
| 935 | 973 | } |
| 936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
| 940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
| 941 | 979 | if (isset($_POST['span'])) |
| 942 | 980 | { |
| 943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
| 944 | - fatal_lang_error('invalid_days_numb', false); |
|
| 981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
| 982 | + fatal_lang_error('invalid_days_numb', false); |
|
| 983 | + } |
|
| 945 | 984 | } |
| 946 | 985 | |
| 947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
| 951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
| 952 | 991 | { |
| 953 | 992 | // No day? |
| 954 | - if (!isset($_POST['day'])) |
|
| 955 | - fatal_lang_error('event_day_missing', false); |
|
| 993 | + if (!isset($_POST['day'])) { |
|
| 994 | + fatal_lang_error('event_day_missing', false); |
|
| 995 | + } |
|
| 956 | 996 | |
| 957 | 997 | // Bad day? |
| 958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 959 | - fatal_lang_error('invalid_date', false); |
|
| 998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 999 | + fatal_lang_error('invalid_date', false); |
|
| 1000 | + } |
|
| 960 | 1001 | } |
| 961 | 1002 | |
| 962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 963 | - fatal_lang_error('event_title_missing', false); |
|
| 964 | - elseif (!isset($_POST['evtitle'])) |
|
| 965 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 1004 | + fatal_lang_error('event_title_missing', false); |
|
| 1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 1007 | + } |
|
| 966 | 1008 | |
| 967 | 1009 | // No title? |
| 968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 969 | - fatal_lang_error('no_event_title', false); |
|
| 970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1011 | + fatal_lang_error('no_event_title', false); |
|
| 1012 | + } |
|
| 1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1015 | + } |
|
| 972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 973 | 1017 | } |
| 974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
| 995 | 1039 | ); |
| 996 | 1040 | |
| 997 | 1041 | // No results, return false. |
| 998 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 999 | - return false; |
|
| 1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1000 | 1045 | |
| 1001 | 1046 | // Grab the results and return. |
| 1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
| 1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 1131 | 1176 | |
| 1132 | 1177 | $column_clauses = array(); |
| 1133 | - foreach ($event_columns as $col => $crit) |
|
| 1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 1178 | + foreach ($event_columns as $col => $crit) { |
|
| 1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 1180 | + } |
|
| 1135 | 1181 | |
| 1136 | 1182 | $smcFunc['db_query']('', ' |
| 1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
| 1216 | 1262 | ); |
| 1217 | 1263 | |
| 1218 | 1264 | // If nothing returned, we are in poo, poo. |
| 1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1220 | - return false; |
|
| 1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1266 | + return false; |
|
| 1267 | + } |
|
| 1221 | 1268 | |
| 1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
| 1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 1226 | 1273 | |
| 1227 | 1274 | // Sanity check |
| 1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 1229 | - return false; |
|
| 1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 1276 | + return false; |
|
| 1277 | + } |
|
| 1230 | 1278 | |
| 1231 | 1279 | $return_value = array( |
| 1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
| 1363 | 1411 | |
| 1364 | 1412 | // Set $span, in case we need it |
| 1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
| 1366 | - if ($span > 0) |
|
| 1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1414 | + if ($span > 0) { |
|
| 1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1416 | + } |
|
| 1368 | 1417 | |
| 1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
| 1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1371 | - $tz = $eventOptions['tz']; |
|
| 1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1373 | - $tz = $_POST['tz']; |
|
| 1374 | - else |
|
| 1375 | - $tz = getUserTimezone(); |
|
| 1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1420 | + $tz = $eventOptions['tz']; |
|
| 1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1422 | + $tz = $_POST['tz']; |
|
| 1423 | + } else { |
|
| 1424 | + $tz = getUserTimezone(); |
|
| 1425 | + } |
|
| 1376 | 1426 | |
| 1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
| 1378 | - if (isset($eventOptions['allday'])) |
|
| 1379 | - $allday = $eventOptions['allday']; |
|
| 1380 | - elseif (empty($_POST['allday'])) |
|
| 1381 | - $allday = false; |
|
| 1382 | - else |
|
| 1383 | - $allday = true; |
|
| 1428 | + if (isset($eventOptions['allday'])) { |
|
| 1429 | + $allday = $eventOptions['allday']; |
|
| 1430 | + } elseif (empty($_POST['allday'])) { |
|
| 1431 | + $allday = false; |
|
| 1432 | + } else { |
|
| 1433 | + $allday = true; |
|
| 1434 | + } |
|
| 1384 | 1435 | |
| 1385 | 1436 | // Input might come as individual parameters... |
| 1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
| 1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
| 1408 | 1459 | |
| 1409 | 1460 | // If the date and time were given in separate strings, combine them |
| 1410 | - if (empty($start_string) && isset($start_date_string)) |
|
| 1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1412 | - if (empty($end_string) && isset($end_date_string)) |
|
| 1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
| 1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1463 | + } |
|
| 1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
| 1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1466 | + } |
|
| 1414 | 1467 | |
| 1415 | 1468 | // If some form of string input was given, override individually defined options with it |
| 1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
| 1501 | 1554 | if ($start_object >= $end_object) |
| 1502 | 1555 | { |
| 1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1504 | - if ($span > 0) |
|
| 1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1506 | - else |
|
| 1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1557 | + if ($span > 0) { |
|
| 1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1559 | + } else { |
|
| 1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1561 | + } |
|
| 1508 | 1562 | } |
| 1509 | 1563 | |
| 1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
| 1517 | 1571 | { |
| 1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
| 1574 | + } else { |
|
| 1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1520 | 1576 | } |
| 1521 | - else |
|
| 1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1523 | 1577 | } |
| 1524 | 1578 | } |
| 1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
| 1532 | 1586 | $start_time = null; |
| 1533 | 1587 | $end_time = null; |
| 1534 | 1588 | $tz = null; |
| 1535 | - } |
|
| 1536 | - else |
|
| 1589 | + } else |
|
| 1537 | 1590 | { |
| 1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
| 1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
| 1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
| 1560 | 1613 | if (empty($date_format)) |
| 1561 | 1614 | { |
| 1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1563 | - $date_format = '%F'; |
|
| 1564 | - else |
|
| 1565 | - $date_format = $matches[0]; |
|
| 1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1616 | + $date_format = '%F'; |
|
| 1617 | + } else { |
|
| 1618 | + $date_format = $matches[0]; |
|
| 1619 | + } |
|
| 1566 | 1620 | } |
| 1567 | 1621 | |
| 1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 1569 | 1623 | if (empty($time_format)) |
| 1570 | 1624 | { |
| 1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1572 | - $time_format = '%k:%M'; |
|
| 1573 | - else |
|
| 1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1626 | + $time_format = '%k:%M'; |
|
| 1627 | + } else { |
|
| 1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1629 | + } |
|
| 1575 | 1630 | } |
| 1576 | 1631 | |
| 1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
| 1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
| 1582 | 1637 | |
| 1583 | 1638 | // We need to have a defined timezone in the steps below |
| 1584 | - if (empty($row['timezone'])) |
|
| 1585 | - $row['timezone'] = getUserTimezone(); |
|
| 1639 | + if (empty($row['timezone'])) { |
|
| 1640 | + $row['timezone'] = getUserTimezone(); |
|
| 1641 | + } |
|
| 1586 | 1642 | |
| 1587 | - if (empty($timezone_array[$row['timezone']])) |
|
| 1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
| 1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1645 | + } |
|
| 1589 | 1646 | |
| 1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
| 1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
| 1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
| 1634 | 1691 | static $member_cache = array(); |
| 1635 | 1692 | |
| 1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
| 1637 | - $id_member = $context['user']['id']; |
|
| 1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
| 1694 | + $id_member = $context['user']['id']; |
|
| 1695 | + } |
|
| 1638 | 1696 | |
| 1639 | 1697 | //check if the cache got the data |
| 1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
| 1663 | 1721 | $smcFunc['db_free_result']($request); |
| 1664 | 1722 | } |
| 1665 | 1723 | |
| 1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1726 | + } |
|
| 1668 | 1727 | |
| 1669 | - if (isset($id_member)) |
|
| 1670 | - $member_cache[$id_member] = $timezone; |
|
| 1728 | + if (isset($id_member)) { |
|
| 1729 | + $member_cache[$id_member] = $timezone; |
|
| 1730 | + } |
|
| 1671 | 1731 | |
| 1672 | 1732 | return $timezone; |
| 1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
| 1696 | 1756 | ) |
| 1697 | 1757 | ); |
| 1698 | 1758 | $holidays = array(); |
| 1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1700 | - $holidays[] = $row; |
|
| 1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1760 | + $holidays[] = $row; |
|
| 1761 | + } |
|
| 1701 | 1762 | $smcFunc['db_free_result']($request); |
| 1702 | 1763 | |
| 1703 | 1764 | return $holidays; |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
| 23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
| 24 | 25 | |
| 25 | 26 | // Attempt to load the member's profile data. |
| 26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
| 27 | - fatal_lang_error('not_a_user', false, 404); |
|
| 27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
| 28 | + fatal_lang_error('not_a_user', false, 404); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | // Set up the stuff and load the user. |
| 30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | // See if they have broken any warning levels... |
| 51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
| 52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
| 53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
| 55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
| 57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
| 55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
| 57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
| 59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | // They haven't even been registered for a full day!? |
| 60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
| 61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
| 62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 63 | - else |
|
| 64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
| 65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 66 | + } else { |
|
| 67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // Set the age... |
| 67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
| 70 | 74 | 'age' => $txt['not_applicable'], |
| 71 | 75 | 'today_is_birthday' => false |
| 72 | 76 | ); |
| 73 | - } |
|
| 74 | - else |
|
| 77 | + } else |
|
| 75 | 78 | { |
| 76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
| 77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
| 84 | 87 | if (allowedTo('moderate_forum')) |
| 85 | 88 | { |
| 86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
| 87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
| 88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 89 | - else |
|
| 90 | - $context['member']['hostname'] = ''; |
|
| 90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
| 91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 92 | + } else { |
|
| 93 | + $context['member']['hostname'] = ''; |
|
| 94 | + } |
|
| 91 | 95 | |
| 92 | 96 | $context['can_see_ip'] = true; |
| 97 | + } else { |
|
| 98 | + $context['can_see_ip'] = false; |
|
| 93 | 99 | } |
| 94 | - else |
|
| 95 | - $context['can_see_ip'] = false; |
|
| 96 | 100 | |
| 97 | 101 | // Are they hidden? |
| 98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
| 103 | 107 | include_once($sourcedir . '/Who.php'); |
| 104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
| 105 | 109 | |
| 106 | - if ($action !== false) |
|
| 107 | - $context['member']['action'] = $action; |
|
| 110 | + if ($action !== false) { |
|
| 111 | + $context['member']['action'] = $action; |
|
| 112 | + } |
|
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
| 167 | 172 | { |
| 168 | 173 | // Work out what restrictions we actually have. |
| 169 | 174 | $ban_restrictions = array(); |
| 170 | - foreach (array('access', 'login', 'post') as $type) |
|
| 171 | - if ($row['cannot_' . $type]) |
|
| 175 | + foreach (array('access', 'login', 'post') as $type) { |
|
| 176 | + if ($row['cannot_' . $type]) |
|
| 172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | // No actual ban in place? |
| 175 | - if (empty($ban_restrictions)) |
|
| 176 | - continue; |
|
| 181 | + if (empty($ban_restrictions)) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 177 | 184 | |
| 178 | 185 | // Prepare the link for context. |
| 179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
| 195 | 202 | $context['print_custom_fields'] = array(); |
| 196 | 203 | |
| 197 | 204 | // Any custom profile fields? |
| 198 | - if (!empty($context['custom_fields'])) |
|
| 199 | - foreach ($context['custom_fields'] as $custom) |
|
| 205 | + if (!empty($context['custom_fields'])) { |
|
| 206 | + foreach ($context['custom_fields'] as $custom) |
|
| 200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 208 | + } |
|
| 201 | 209 | |
| 202 | 210 | } |
| 203 | 211 | |
@@ -242,16 +250,18 @@ discard block |
||
| 242 | 250 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
| 243 | 251 | $alerts[$id_alert] = $row; |
| 244 | 252 | |
| 245 | - if (!empty($row['sender_id'])) |
|
| 246 | - $senders[] = $row['sender_id']; |
|
| 253 | + if (!empty($row['sender_id'])) { |
|
| 254 | + $senders[] = $row['sender_id']; |
|
| 255 | + } |
|
| 247 | 256 | } |
| 248 | 257 | $smcFunc['db_free_result']($request); |
| 249 | 258 | |
| 250 | 259 | if($withSender) |
| 251 | 260 | { |
| 252 | 261 | $senders = loadMemberData($senders); |
| 253 | - foreach ($senders as $member) |
|
| 254 | - loadMemberContext($member); |
|
| 262 | + foreach ($senders as $member) { |
|
| 263 | + loadMemberContext($member); |
|
| 264 | + } |
|
| 255 | 265 | } |
| 256 | 266 | |
| 257 | 267 | // Now go through and actually make with the text. |
@@ -266,12 +276,15 @@ discard block |
||
| 266 | 276 | $msgs = array(); |
| 267 | 277 | foreach ($alerts as $id_alert => $alert) |
| 268 | 278 | { |
| 269 | - if (isset($alert['extra']['board'])) |
|
| 270 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 271 | - if (isset($alert['extra']['topic'])) |
|
| 272 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 273 | - if ($alert['content_type'] == 'msg') |
|
| 274 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 279 | + if (isset($alert['extra']['board'])) { |
|
| 280 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 281 | + } |
|
| 282 | + if (isset($alert['extra']['topic'])) { |
|
| 283 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 284 | + } |
|
| 285 | + if ($alert['content_type'] == 'msg') { |
|
| 286 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 287 | + } |
|
| 275 | 288 | } |
| 276 | 289 | |
| 277 | 290 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -286,8 +299,9 @@ discard block |
||
| 286 | 299 | 'boards' => array_keys($boards), |
| 287 | 300 | ) |
| 288 | 301 | ); |
| 289 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 290 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 303 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 304 | + } |
|
| 291 | 305 | } |
| 292 | 306 | if (!empty($topics)) |
| 293 | 307 | { |
@@ -302,8 +316,9 @@ discard block |
||
| 302 | 316 | 'topics' => array_keys($topics), |
| 303 | 317 | ) |
| 304 | 318 | ); |
| 305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 306 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 319 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 320 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 321 | + } |
|
| 307 | 322 | } |
| 308 | 323 | if (!empty($msgs)) |
| 309 | 324 | { |
@@ -318,44 +333,51 @@ discard block |
||
| 318 | 333 | 'msgs' => array_keys($msgs), |
| 319 | 334 | ) |
| 320 | 335 | ); |
| 321 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 322 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 336 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 337 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 338 | + } |
|
| 323 | 339 | } |
| 324 | 340 | |
| 325 | 341 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
| 326 | 342 | foreach ($alerts as $id_alert => $alert) |
| 327 | 343 | { |
| 328 | - if (!empty($alert['text'])) |
|
| 329 | - continue; |
|
| 330 | - if (isset($alert['extra']['board'])) |
|
| 331 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 344 | + if (!empty($alert['text'])) { |
|
| 345 | + continue; |
|
| 346 | + } |
|
| 347 | + if (isset($alert['extra']['board'])) { |
|
| 348 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 332 | 349 | { |
| 333 | 350 | unset($alerts[$id_alert]); |
| 351 | + } |
|
| 334 | 352 | continue; |
| 353 | + } else { |
|
| 354 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 335 | 355 | } |
| 336 | - else |
|
| 337 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 338 | - if (isset($alert['extra']['topic'])) |
|
| 339 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 356 | + if (isset($alert['extra']['topic'])) { |
|
| 357 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 340 | 358 | { |
| 341 | 359 | unset($alerts[$id_alert]); |
| 360 | + } |
|
| 342 | 361 | continue; |
| 362 | + } else { |
|
| 363 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 343 | 364 | } |
| 344 | - else |
|
| 345 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 346 | - if ($alert['content_type'] == 'msg') |
|
| 347 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 365 | + if ($alert['content_type'] == 'msg') { |
|
| 366 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 348 | 367 | { |
| 349 | 368 | unset($alerts[$id_alert]); |
| 369 | + } |
|
| 350 | 370 | continue; |
| 351 | - } |
|
| 352 | - else |
|
| 353 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 354 | - if ($alert['content_type'] == 'profile') |
|
| 355 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 371 | + } else { |
|
| 372 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 373 | + } |
|
| 374 | + if ($alert['content_type'] == 'profile') { |
|
| 375 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 376 | + } |
|
| 356 | 377 | |
| 357 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 358 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 378 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 379 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 380 | + } |
|
| 359 | 381 | |
| 360 | 382 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 361 | 383 | if (isset($txt[$string])) |
@@ -443,11 +465,11 @@ discard block |
||
| 443 | 465 | checkSession('request'); |
| 444 | 466 | |
| 445 | 467 | // Call it! |
| 446 | - if ($action == 'remove') |
|
| 447 | - alert_delete($toMark, $memID); |
|
| 448 | - |
|
| 449 | - else |
|
| 450 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 468 | + if ($action == 'remove') { |
|
| 469 | + alert_delete($toMark, $memID); |
|
| 470 | + } else { |
|
| 471 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 472 | + } |
|
| 451 | 473 | |
| 452 | 474 | // Set a nice update message. |
| 453 | 475 | $_SESSION['update_message'] = true; |
@@ -497,23 +519,27 @@ discard block |
||
| 497 | 519 | ); |
| 498 | 520 | |
| 499 | 521 | // Set the page title |
| 500 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 501 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 502 | - else |
|
| 503 | - $context['page_title'] = $txt['showPosts']; |
|
| 522 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 523 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 524 | + } else { |
|
| 525 | + $context['page_title'] = $txt['showPosts']; |
|
| 526 | + } |
|
| 504 | 527 | |
| 505 | 528 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 506 | 529 | |
| 507 | 530 | // Is the load average too high to allow searching just now? |
| 508 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 509 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 531 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 532 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 533 | + } |
|
| 510 | 534 | |
| 511 | 535 | // If we're specifically dealing with attachments use that function! |
| 512 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 513 | - return showAttachments($memID); |
|
| 536 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 537 | + return showAttachments($memID); |
|
| 538 | + } |
|
| 514 | 539 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 515 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 516 | - return showUnwatched($memID); |
|
| 540 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 541 | + return showUnwatched($memID); |
|
| 542 | + } |
|
| 517 | 543 | |
| 518 | 544 | // Are we just viewing topics? |
| 519 | 545 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -536,27 +562,30 @@ discard block |
||
| 536 | 562 | $smcFunc['db_free_result']($request); |
| 537 | 563 | |
| 538 | 564 | // Trying to remove a message that doesn't exist. |
| 539 | - if (empty($info)) |
|
| 540 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 565 | + if (empty($info)) { |
|
| 566 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 567 | + } |
|
| 541 | 568 | |
| 542 | 569 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 543 | 570 | require_once($sourcedir . '/RemoveTopic.php'); |
| 544 | 571 | removeMessage((int) $_GET['delete']); |
| 545 | 572 | |
| 546 | 573 | // Add it to the mod log. |
| 547 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 548 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 574 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 575 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 576 | + } |
|
| 549 | 577 | |
| 550 | 578 | // Back to... where we are now ;). |
| 551 | 579 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 552 | 580 | } |
| 553 | 581 | |
| 554 | 582 | // Default to 10. |
| 555 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 556 | - $_REQUEST['viewscount'] = '10'; |
|
| 583 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 584 | + $_REQUEST['viewscount'] = '10'; |
|
| 585 | + } |
|
| 557 | 586 | |
| 558 | - if ($context['is_topics']) |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 587 | + if ($context['is_topics']) { |
|
| 588 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 589 | SELECT COUNT(*) |
| 561 | 590 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 562 | 591 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -569,8 +598,8 @@ discard block |
||
| 569 | 598 | 'board' => $board, |
| 570 | 599 | ) |
| 571 | 600 | ); |
| 572 | - else |
|
| 573 | - $request = $smcFunc['db_query']('', ' |
|
| 601 | + } else { |
|
| 602 | + $request = $smcFunc['db_query']('', ' |
|
| 574 | 603 | SELECT COUNT(*) |
| 575 | 604 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 576 | 605 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -583,6 +612,7 @@ discard block |
||
| 583 | 612 | 'board' => $board, |
| 584 | 613 | ) |
| 585 | 614 | ); |
| 615 | + } |
|
| 586 | 616 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 587 | 617 | $smcFunc['db_free_result']($request); |
| 588 | 618 | |
@@ -603,10 +633,11 @@ discard block |
||
| 603 | 633 | |
| 604 | 634 | $range_limit = ''; |
| 605 | 635 | |
| 606 | - if ($context['is_topics']) |
|
| 607 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 608 | - else |
|
| 609 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 636 | + if ($context['is_topics']) { |
|
| 637 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 638 | + } else { |
|
| 639 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 640 | + } |
|
| 610 | 641 | |
| 611 | 642 | $maxIndex = $maxPerPage; |
| 612 | 643 | |
@@ -632,9 +663,9 @@ discard block |
||
| 632 | 663 | { |
| 633 | 664 | $margin *= 5; |
| 634 | 665 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 666 | + } else { |
|
| 667 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 635 | 668 | } |
| 636 | - else |
|
| 637 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 638 | 669 | } |
| 639 | 670 | |
| 640 | 671 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -666,8 +697,7 @@ discard block |
||
| 666 | 697 | 'max' => $maxIndex, |
| 667 | 698 | ) |
| 668 | 699 | ); |
| 669 | - } |
|
| 670 | - else |
|
| 700 | + } else |
|
| 671 | 701 | { |
| 672 | 702 | $request = $smcFunc['db_query']('', ' |
| 673 | 703 | SELECT |
@@ -696,8 +726,9 @@ discard block |
||
| 696 | 726 | } |
| 697 | 727 | |
| 698 | 728 | // Make sure we quit this loop. |
| 699 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
| 700 | - break; |
|
| 729 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
| 730 | + break; |
|
| 731 | + } |
|
| 701 | 732 | $looped = true; |
| 702 | 733 | $range_limit = ''; |
| 703 | 734 | } |
@@ -741,19 +772,21 @@ discard block |
||
| 741 | 772 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 742 | 773 | ); |
| 743 | 774 | |
| 744 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 745 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 775 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 776 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 777 | + } |
|
| 746 | 778 | $board_ids['any'][$row['id_board']][] = $counter; |
| 747 | 779 | } |
| 748 | 780 | $smcFunc['db_free_result']($request); |
| 749 | 781 | |
| 750 | 782 | // All posts were retrieved in reverse order, get them right again. |
| 751 | - if ($reverse) |
|
| 752 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 783 | + if ($reverse) { |
|
| 784 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 785 | + } |
|
| 753 | 786 | |
| 754 | 787 | // These are all the permissions that are different from board to board.. |
| 755 | - if ($context['is_topics']) |
|
| 756 | - $permissions = array( |
|
| 788 | + if ($context['is_topics']) { |
|
| 789 | + $permissions = array( |
|
| 757 | 790 | 'own' => array( |
| 758 | 791 | 'post_reply_own' => 'can_reply', |
| 759 | 792 | ), |
@@ -761,8 +794,8 @@ discard block |
||
| 761 | 794 | 'post_reply_any' => 'can_reply', |
| 762 | 795 | ) |
| 763 | 796 | ); |
| 764 | - else |
|
| 765 | - $permissions = array( |
|
| 797 | + } else { |
|
| 798 | + $permissions = array( |
|
| 766 | 799 | 'own' => array( |
| 767 | 800 | 'post_reply_own' => 'can_reply', |
| 768 | 801 | 'delete_own' => 'can_delete', |
@@ -772,6 +805,7 @@ discard block |
||
| 772 | 805 | 'delete_any' => 'can_delete', |
| 773 | 806 | ) |
| 774 | 807 | ); |
| 808 | + } |
|
| 775 | 809 | |
| 776 | 810 | // For every permission in the own/any lists... |
| 777 | 811 | foreach ($permissions as $type => $list) |
@@ -782,19 +816,22 @@ discard block |
||
| 782 | 816 | $boards = boardsAllowedTo($permission); |
| 783 | 817 | |
| 784 | 818 | // Hmm, they can do it on all boards, can they? |
| 785 | - if (!empty($boards) && $boards[0] == 0) |
|
| 786 | - $boards = array_keys($board_ids[$type]); |
|
| 819 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 820 | + $boards = array_keys($board_ids[$type]); |
|
| 821 | + } |
|
| 787 | 822 | |
| 788 | 823 | // Now go through each board they can do the permission on. |
| 789 | 824 | foreach ($boards as $board_id) |
| 790 | 825 | { |
| 791 | 826 | // There aren't any posts displayed from this board. |
| 792 | - if (!isset($board_ids[$type][$board_id])) |
|
| 793 | - continue; |
|
| 827 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 828 | + continue; |
|
| 829 | + } |
|
| 794 | 830 | |
| 795 | 831 | // Set the permission to true ;). |
| 796 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 797 | - $context['posts'][$counter][$allowed] = true; |
|
| 832 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 833 | + $context['posts'][$counter][$allowed] = true; |
|
| 834 | + } |
|
| 798 | 835 | } |
| 799 | 836 | } |
| 800 | 837 | } |
@@ -825,8 +862,9 @@ discard block |
||
| 825 | 862 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 826 | 863 | |
| 827 | 864 | // Make sure we can't actually see anything... |
| 828 | - if (empty($boardsAllowed)) |
|
| 829 | - $boardsAllowed = array(-1); |
|
| 865 | + if (empty($boardsAllowed)) { |
|
| 866 | + $boardsAllowed = array(-1); |
|
| 867 | + } |
|
| 830 | 868 | |
| 831 | 869 | require_once($sourcedir . '/Subs-List.php'); |
| 832 | 870 | |
@@ -977,8 +1015,8 @@ discard block |
||
| 977 | 1015 | ) |
| 978 | 1016 | ); |
| 979 | 1017 | $attachments = array(); |
| 980 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 981 | - $attachments[] = array( |
|
| 1018 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1019 | + $attachments[] = array( |
|
| 982 | 1020 | 'id' => $row['id_attach'], |
| 983 | 1021 | 'filename' => $row['filename'], |
| 984 | 1022 | 'downloads' => $row['downloads'], |
@@ -990,6 +1028,7 @@ discard block |
||
| 990 | 1028 | 'board_name' => $row['name'], |
| 991 | 1029 | 'approved' => $row['approved'], |
| 992 | 1030 | ); |
| 1031 | + } |
|
| 993 | 1032 | |
| 994 | 1033 | $smcFunc['db_free_result']($request); |
| 995 | 1034 | |
@@ -1044,8 +1083,9 @@ discard block |
||
| 1044 | 1083 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1045 | 1084 | |
| 1046 | 1085 | // Only the owner can see the list (if the function is enabled of course) |
| 1047 | - if ($user_info['id'] != $memID) |
|
| 1048 | - return; |
|
| 1086 | + if ($user_info['id'] != $memID) { |
|
| 1087 | + return; |
|
| 1088 | + } |
|
| 1049 | 1089 | |
| 1050 | 1090 | require_once($sourcedir . '/Subs-List.php'); |
| 1051 | 1091 | |
@@ -1191,8 +1231,9 @@ discard block |
||
| 1191 | 1231 | ); |
| 1192 | 1232 | |
| 1193 | 1233 | $topics = array(); |
| 1194 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1195 | - $topics[] = $row['id_topic']; |
|
| 1234 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1235 | + $topics[] = $row['id_topic']; |
|
| 1236 | + } |
|
| 1196 | 1237 | |
| 1197 | 1238 | $smcFunc['db_free_result']($request); |
| 1198 | 1239 | |
@@ -1212,8 +1253,9 @@ discard block |
||
| 1212 | 1253 | 'topics' => $topics, |
| 1213 | 1254 | ) |
| 1214 | 1255 | ); |
| 1215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1216 | - $topicsInfo[] = $row; |
|
| 1256 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1257 | + $topicsInfo[] = $row; |
|
| 1258 | + } |
|
| 1217 | 1259 | $smcFunc['db_free_result']($request); |
| 1218 | 1260 | } |
| 1219 | 1261 | |
@@ -1261,8 +1303,9 @@ discard block |
||
| 1261 | 1303 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1262 | 1304 | |
| 1263 | 1305 | // Is the load average too high to allow searching just now? |
| 1264 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1265 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1306 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1307 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1308 | + } |
|
| 1266 | 1309 | |
| 1267 | 1310 | // General user statistics. |
| 1268 | 1311 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1405,11 +1448,13 @@ discard block |
||
| 1405 | 1448 | } |
| 1406 | 1449 | $smcFunc['db_free_result']($result); |
| 1407 | 1450 | |
| 1408 | - if ($maxPosts > 0) |
|
| 1409 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1451 | + if ($maxPosts > 0) { |
|
| 1452 | + for ($hour = 0; |
|
| 1453 | + } |
|
| 1454 | + $hour < 24; $hour++) |
|
| 1410 | 1455 | { |
| 1411 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1412 | - $context['posts_by_time'][$hour] = array( |
|
| 1456 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1457 | + $context['posts_by_time'][$hour] = array( |
|
| 1413 | 1458 | 'hour' => $hour, |
| 1414 | 1459 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1415 | 1460 | 'posts' => 0, |
@@ -1417,7 +1462,7 @@ discard block |
||
| 1417 | 1462 | 'relative_percent' => 0, |
| 1418 | 1463 | 'is_last' => $hour == 23, |
| 1419 | 1464 | ); |
| 1420 | - else |
|
| 1465 | + } else |
|
| 1421 | 1466 | { |
| 1422 | 1467 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1423 | 1468 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1450,8 +1495,9 @@ discard block |
||
| 1450 | 1495 | |
| 1451 | 1496 | foreach ($subActions as $sa => $action) |
| 1452 | 1497 | { |
| 1453 | - if (!allowedTo($action[2])) |
|
| 1454 | - unset($subActions[$sa]); |
|
| 1498 | + if (!allowedTo($action[2])) { |
|
| 1499 | + unset($subActions[$sa]); |
|
| 1500 | + } |
|
| 1455 | 1501 | } |
| 1456 | 1502 | |
| 1457 | 1503 | // Create the tabs for the template. |
@@ -1469,15 +1515,18 @@ discard block |
||
| 1469 | 1515 | ); |
| 1470 | 1516 | |
| 1471 | 1517 | // Moderation must be on to track edits. |
| 1472 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1473 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1518 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1519 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1520 | + } |
|
| 1474 | 1521 | |
| 1475 | 1522 | // Group requests must be active to show it... |
| 1476 | - if (empty($modSettings['show_group_membership'])) |
|
| 1477 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1523 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1524 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1525 | + } |
|
| 1478 | 1526 | |
| 1479 | - if (empty($subActions)) |
|
| 1480 | - fatal_lang_error('no_access', false); |
|
| 1527 | + if (empty($subActions)) { |
|
| 1528 | + fatal_lang_error('no_access', false); |
|
| 1529 | + } |
|
| 1481 | 1530 | |
| 1482 | 1531 | $keys = array_keys($subActions); |
| 1483 | 1532 | $default = array_shift($keys); |
@@ -1490,9 +1539,10 @@ discard block |
||
| 1490 | 1539 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1491 | 1540 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1492 | 1541 | |
| 1493 | - if (!empty($call)) |
|
| 1494 | - call_user_func($call, $memID); |
|
| 1495 | -} |
|
| 1542 | + if (!empty($call)) { |
|
| 1543 | + call_user_func($call, $memID); |
|
| 1544 | + } |
|
| 1545 | + } |
|
| 1496 | 1546 | |
| 1497 | 1547 | /** |
| 1498 | 1548 | * Handles tracking a user's activity |
@@ -1508,8 +1558,9 @@ discard block |
||
| 1508 | 1558 | isAllowedTo('moderate_forum'); |
| 1509 | 1559 | |
| 1510 | 1560 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1511 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1512 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1561 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1562 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1563 | + } |
|
| 1513 | 1564 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1514 | 1565 | |
| 1515 | 1566 | // Set the options for the list component. |
@@ -1675,8 +1726,9 @@ discard block |
||
| 1675 | 1726 | ) |
| 1676 | 1727 | ); |
| 1677 | 1728 | $message_members = array(); |
| 1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1679 | - $message_members[] = $row['id_member']; |
|
| 1729 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1730 | + $message_members[] = $row['id_member']; |
|
| 1731 | + } |
|
| 1680 | 1732 | $smcFunc['db_free_result']($request); |
| 1681 | 1733 | |
| 1682 | 1734 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1691,8 +1743,9 @@ discard block |
||
| 1691 | 1743 | 'ip_list' => $ips, |
| 1692 | 1744 | ) |
| 1693 | 1745 | ); |
| 1694 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1695 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1746 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1747 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1748 | + } |
|
| 1696 | 1749 | $smcFunc['db_free_result']($request); |
| 1697 | 1750 | } |
| 1698 | 1751 | |
@@ -1706,8 +1759,9 @@ discard block |
||
| 1706 | 1759 | 'ip_list' => $ips, |
| 1707 | 1760 | ) |
| 1708 | 1761 | ); |
| 1709 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1710 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1762 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1763 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1764 | + } |
|
| 1711 | 1765 | $smcFunc['db_free_result']($request); |
| 1712 | 1766 | } |
| 1713 | 1767 | } |
@@ -1767,8 +1821,8 @@ discard block |
||
| 1767 | 1821 | )) |
| 1768 | 1822 | ); |
| 1769 | 1823 | $error_messages = array(); |
| 1770 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1771 | - $error_messages[] = array( |
|
| 1824 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1825 | + $error_messages[] = array( |
|
| 1772 | 1826 | 'ip' => inet_dtop($row['ip']), |
| 1773 | 1827 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1774 | 1828 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1776,6 +1830,7 @@ discard block |
||
| 1776 | 1830 | 'time' => timeformat($row['log_time']), |
| 1777 | 1831 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1778 | 1832 | ); |
| 1833 | + } |
|
| 1779 | 1834 | $smcFunc['db_free_result']($request); |
| 1780 | 1835 | |
| 1781 | 1836 | return $error_messages; |
@@ -1838,8 +1893,8 @@ discard block |
||
| 1838 | 1893 | )) |
| 1839 | 1894 | ); |
| 1840 | 1895 | $messages = array(); |
| 1841 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1842 | - $messages[] = array( |
|
| 1896 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1897 | + $messages[] = array( |
|
| 1843 | 1898 | 'ip' => inet_dtop($row['poster_ip']), |
| 1844 | 1899 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1845 | 1900 | 'board' => array( |
@@ -1852,6 +1907,7 @@ discard block |
||
| 1852 | 1907 | 'time' => timeformat($row['poster_time']), |
| 1853 | 1908 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1854 | 1909 | ); |
| 1910 | + } |
|
| 1855 | 1911 | $smcFunc['db_free_result']($request); |
| 1856 | 1912 | |
| 1857 | 1913 | return $messages; |
@@ -1878,19 +1934,20 @@ discard block |
||
| 1878 | 1934 | $context['sub_template'] = 'trackIP'; |
| 1879 | 1935 | $context['page_title'] = $txt['profile']; |
| 1880 | 1936 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1881 | - } |
|
| 1882 | - else |
|
| 1937 | + } else |
|
| 1883 | 1938 | { |
| 1884 | 1939 | $context['ip'] = $user_profile[$memID]['member_ip']; |
| 1885 | 1940 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1886 | 1941 | } |
| 1887 | 1942 | |
| 1888 | 1943 | // Searching? |
| 1889 | - if (isset($_REQUEST['searchip'])) |
|
| 1890 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1944 | + if (isset($_REQUEST['searchip'])) { |
|
| 1945 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1946 | + } |
|
| 1891 | 1947 | |
| 1892 | - if (isValidIP($context['ip']) === false) |
|
| 1893 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1948 | + if (isValidIP($context['ip']) === false) { |
|
| 1949 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1950 | + } |
|
| 1894 | 1951 | |
| 1895 | 1952 | //mysql didn't support like search with varbinary |
| 1896 | 1953 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1898,8 +1955,9 @@ discard block |
||
| 1898 | 1955 | $ip_var = $context['ip']; |
| 1899 | 1956 | $ip_string = '= {inet:ip_address}'; |
| 1900 | 1957 | |
| 1901 | - if (empty($context['tracking_area'])) |
|
| 1902 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1958 | + if (empty($context['tracking_area'])) { |
|
| 1959 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1960 | + } |
|
| 1903 | 1961 | |
| 1904 | 1962 | $request = $smcFunc['db_query']('', ' |
| 1905 | 1963 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1910,8 +1968,9 @@ discard block |
||
| 1910 | 1968 | ) |
| 1911 | 1969 | ); |
| 1912 | 1970 | $context['ips'] = array(); |
| 1913 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1914 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1971 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1972 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1973 | + } |
|
| 1915 | 1974 | $smcFunc['db_free_result']($request); |
| 1916 | 1975 | |
| 1917 | 1976 | ksort($context['ips']); |
@@ -2140,8 +2199,9 @@ discard block |
||
| 2140 | 2199 | foreach ($context['whois_servers'] as $whois) |
| 2141 | 2200 | { |
| 2142 | 2201 | // Strip off the "decimal point" and anything following... |
| 2143 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
| 2144 | - $context['auto_whois_server'] = $whois; |
|
| 2202 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
| 2203 | + $context['auto_whois_server'] = $whois; |
|
| 2204 | + } |
|
| 2145 | 2205 | } |
| 2146 | 2206 | } |
| 2147 | 2207 | } |
@@ -2158,10 +2218,11 @@ discard block |
||
| 2158 | 2218 | // Gonna want this for the list. |
| 2159 | 2219 | require_once($sourcedir . '/Subs-List.php'); |
| 2160 | 2220 | |
| 2161 | - if ($memID == 0) |
|
| 2162 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2163 | - else |
|
| 2164 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2221 | + if ($memID == 0) { |
|
| 2222 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2223 | + } else { |
|
| 2224 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2225 | + } |
|
| 2165 | 2226 | |
| 2166 | 2227 | // Start with the user messages. |
| 2167 | 2228 | $listOptions = array( |
@@ -2271,12 +2332,13 @@ discard block |
||
| 2271 | 2332 | ) |
| 2272 | 2333 | ); |
| 2273 | 2334 | $logins = array(); |
| 2274 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2275 | - $logins[] = array( |
|
| 2335 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2336 | + $logins[] = array( |
|
| 2276 | 2337 | 'time' => timeformat($row['time']), |
| 2277 | 2338 | 'ip' => inet_dtop($row['ip']), |
| 2278 | 2339 | 'ip2' => inet_dtop($row['ip2']), |
| 2279 | 2340 | ); |
| 2341 | + } |
|
| 2280 | 2342 | $smcFunc['db_free_result']($request); |
| 2281 | 2343 | |
| 2282 | 2344 | return $logins; |
@@ -2301,11 +2363,12 @@ discard block |
||
| 2301 | 2363 | ) |
| 2302 | 2364 | ); |
| 2303 | 2365 | $context['custom_field_titles'] = array(); |
| 2304 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2305 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2367 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2306 | 2368 | 'title' => $row['field_name'], |
| 2307 | 2369 | 'parse_bbc' => $row['bbc'], |
| 2308 | 2370 | ); |
| 2371 | + } |
|
| 2309 | 2372 | $smcFunc['db_free_result']($request); |
| 2310 | 2373 | |
| 2311 | 2374 | // Set the options for the error lists. |
@@ -2444,19 +2507,22 @@ discard block |
||
| 2444 | 2507 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2445 | 2508 | { |
| 2446 | 2509 | $extra = $smcFunc['json_decode']($row['extra'], true); |
| 2447 | - if (!empty($extra['applicator'])) |
|
| 2448 | - $members[] = $extra['applicator']; |
|
| 2510 | + if (!empty($extra['applicator'])) { |
|
| 2511 | + $members[] = $extra['applicator']; |
|
| 2512 | + } |
|
| 2449 | 2513 | |
| 2450 | 2514 | // Work out what the name of the action is. |
| 2451 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2452 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2453 | - elseif (isset($txt[$row['action']])) |
|
| 2454 | - $action_text = $txt[$row['action']]; |
|
| 2515 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2516 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2517 | + } elseif (isset($txt[$row['action']])) { |
|
| 2518 | + $action_text = $txt[$row['action']]; |
|
| 2519 | + } |
|
| 2455 | 2520 | // Custom field? |
| 2456 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2457 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2458 | - else |
|
| 2459 | - $action_text = $row['action']; |
|
| 2521 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2522 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2523 | + } else { |
|
| 2524 | + $action_text = $row['action']; |
|
| 2525 | + } |
|
| 2460 | 2526 | |
| 2461 | 2527 | // Parse BBC? |
| 2462 | 2528 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2488,13 +2554,15 @@ discard block |
||
| 2488 | 2554 | ) |
| 2489 | 2555 | ); |
| 2490 | 2556 | $members = array(); |
| 2491 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2492 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2557 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2558 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2559 | + } |
|
| 2493 | 2560 | $smcFunc['db_free_result']($request); |
| 2494 | 2561 | |
| 2495 | - foreach ($edits as $key => $value) |
|
| 2496 | - if (isset($members[$value['id_member']])) |
|
| 2562 | + foreach ($edits as $key => $value) { |
|
| 2563 | + if (isset($members[$value['id_member']])) |
|
| 2497 | 2564 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2565 | + } |
|
| 2498 | 2566 | } |
| 2499 | 2567 | |
| 2500 | 2568 | return $edits; |
@@ -2695,10 +2763,11 @@ discard block |
||
| 2695 | 2763 | $context['board'] = $board; |
| 2696 | 2764 | |
| 2697 | 2765 | // Determine which groups this user is in. |
| 2698 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2699 | - $curGroups = array(); |
|
| 2700 | - else |
|
| 2701 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2766 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2767 | + $curGroups = array(); |
|
| 2768 | + } else { |
|
| 2769 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2770 | + } |
|
| 2702 | 2771 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2703 | 2772 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2704 | 2773 | |
@@ -2718,28 +2787,30 @@ discard block |
||
| 2718 | 2787 | $context['no_access_boards'] = array(); |
| 2719 | 2788 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2720 | 2789 | { |
| 2721 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2722 | - $context['no_access_boards'][] = array( |
|
| 2790 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2791 | + $context['no_access_boards'][] = array( |
|
| 2723 | 2792 | 'id' => $row['id_board'], |
| 2724 | 2793 | 'name' => $row['name'], |
| 2725 | 2794 | 'is_last' => false, |
| 2726 | 2795 | ); |
| 2727 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2728 | - $context['boards'][$row['id_board']] = array( |
|
| 2796 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2797 | + $context['boards'][$row['id_board']] = array( |
|
| 2729 | 2798 | 'id' => $row['id_board'], |
| 2730 | 2799 | 'name' => $row['name'], |
| 2731 | 2800 | 'selected' => $board == $row['id_board'], |
| 2732 | 2801 | 'profile' => $row['id_profile'], |
| 2733 | 2802 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2734 | 2803 | ); |
| 2804 | + } |
|
| 2735 | 2805 | } |
| 2736 | 2806 | $smcFunc['db_free_result']($request); |
| 2737 | 2807 | |
| 2738 | 2808 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2739 | 2809 | sortBoards($context['boards']); |
| 2740 | 2810 | |
| 2741 | - if (!empty($context['no_access_boards'])) |
|
| 2742 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2811 | + if (!empty($context['no_access_boards'])) { |
|
| 2812 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2813 | + } |
|
| 2743 | 2814 | |
| 2744 | 2815 | $context['member']['permissions'] = array( |
| 2745 | 2816 | 'general' => array(), |
@@ -2748,8 +2819,9 @@ discard block |
||
| 2748 | 2819 | |
| 2749 | 2820 | // If you're an admin we know you can do everything, we might as well leave. |
| 2750 | 2821 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2751 | - if ($context['member']['has_all_permissions']) |
|
| 2752 | - return; |
|
| 2822 | + if ($context['member']['has_all_permissions']) { |
|
| 2823 | + return; |
|
| 2824 | + } |
|
| 2753 | 2825 | |
| 2754 | 2826 | $denied = array(); |
| 2755 | 2827 | |
@@ -2768,21 +2840,24 @@ discard block |
||
| 2768 | 2840 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2769 | 2841 | { |
| 2770 | 2842 | // We don't know about this permission, it doesn't exist :P. |
| 2771 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2772 | - continue; |
|
| 2843 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2844 | + continue; |
|
| 2845 | + } |
|
| 2773 | 2846 | |
| 2774 | - if (empty($row['add_deny'])) |
|
| 2775 | - $denied[] = $row['permission']; |
|
| 2847 | + if (empty($row['add_deny'])) { |
|
| 2848 | + $denied[] = $row['permission']; |
|
| 2849 | + } |
|
| 2776 | 2850 | |
| 2777 | 2851 | // Permissions that end with _own or _any consist of two parts. |
| 2778 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2779 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2780 | - else |
|
| 2781 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2852 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2853 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2854 | + } else { |
|
| 2855 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2856 | + } |
|
| 2782 | 2857 | |
| 2783 | 2858 | // Add this permission if it doesn't exist yet. |
| 2784 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2785 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2859 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2860 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2786 | 2861 | 'id' => $row['permission'], |
| 2787 | 2862 | 'groups' => array( |
| 2788 | 2863 | 'allowed' => array(), |
@@ -2792,6 +2867,7 @@ discard block |
||
| 2792 | 2867 | 'is_denied' => false, |
| 2793 | 2868 | 'is_global' => true, |
| 2794 | 2869 | ); |
| 2870 | + } |
|
| 2795 | 2871 | |
| 2796 | 2872 | // Add the membergroup to either the denied or the allowed groups. |
| 2797 | 2873 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2825,18 +2901,20 @@ discard block |
||
| 2825 | 2901 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2826 | 2902 | { |
| 2827 | 2903 | // We don't know about this permission, it doesn't exist :P. |
| 2828 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2829 | - continue; |
|
| 2904 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2905 | + continue; |
|
| 2906 | + } |
|
| 2830 | 2907 | |
| 2831 | 2908 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2832 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2833 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2834 | - else |
|
| 2835 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2909 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2910 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2911 | + } else { |
|
| 2912 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2913 | + } |
|
| 2836 | 2914 | |
| 2837 | 2915 | // Create the structure for this permission. |
| 2838 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2839 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2916 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2917 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2840 | 2918 | 'id' => $row['permission'], |
| 2841 | 2919 | 'groups' => array( |
| 2842 | 2920 | 'allowed' => array(), |
@@ -2846,6 +2924,7 @@ discard block |
||
| 2846 | 2924 | 'is_denied' => false, |
| 2847 | 2925 | 'is_global' => empty($board), |
| 2848 | 2926 | ); |
| 2927 | + } |
|
| 2849 | 2928 | |
| 2850 | 2929 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
| 2851 | 2930 | |
@@ -2864,8 +2943,9 @@ discard block |
||
| 2864 | 2943 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2865 | 2944 | |
| 2866 | 2945 | // Firstly, can we actually even be here? |
| 2867 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2868 | - fatal_lang_error('no_access', false); |
|
| 2946 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2947 | + fatal_lang_error('no_access', false); |
|
| 2948 | + } |
|
| 2869 | 2949 | |
| 2870 | 2950 | // Make sure things which are disabled stay disabled. |
| 2871 | 2951 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2952,9 +3032,10 @@ discard block |
||
| 2952 | 3032 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2953 | 3033 | ); |
| 2954 | 3034 | $context['current_level'] = 0; |
| 2955 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2956 | - if ($context['member']['warning'] >= $limit) |
|
| 3035 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3036 | + if ($context['member']['warning'] >= $limit) |
|
| 2957 | 3037 | $context['current_level'] = $limit; |
| 2958 | -} |
|
| 3038 | + } |
|
| 3039 | + } |
|
| 2959 | 3040 | |
| 2960 | 3041 | ?> |
| 2961 | 3042 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Interface cache_api_interface |
@@ -182,8 +183,9 @@ discard block |
||
| 182 | 183 | { |
| 183 | 184 | global $cache_enable; |
| 184 | 185 | |
| 185 | - if ($test) |
|
| 186 | - return true; |
|
| 186 | + if ($test) { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 187 | 189 | return !empty($cache_enable); |
| 188 | 190 | } |
| 189 | 191 | |
@@ -202,18 +204,20 @@ discard block |
||
| 202 | 204 | global $boardurl, $cachedir; |
| 203 | 205 | |
| 204 | 206 | // Find a valid good file to do mtime checks on. |
| 205 | - if (file_exists($cachedir . '/' . 'index.php')) |
|
| 206 | - $filemtime = $cachedir . '/' . 'index.php'; |
|
| 207 | - elseif (is_dir($cachedir . '/')) |
|
| 208 | - $filemtime = $cachedir . '/'; |
|
| 209 | - else |
|
| 210 | - $filemtime = $boardurl . '/index.php'; |
|
| 207 | + if (file_exists($cachedir . '/' . 'index.php')) { |
|
| 208 | + $filemtime = $cachedir . '/' . 'index.php'; |
|
| 209 | + } elseif (is_dir($cachedir . '/')) { |
|
| 210 | + $filemtime = $cachedir . '/'; |
|
| 211 | + } else { |
|
| 212 | + $filemtime = $boardurl . '/index.php'; |
|
| 213 | + } |
|
| 211 | 214 | |
| 212 | 215 | // Set the default if no prefix was specified. |
| 213 | - if (empty($prefix)) |
|
| 214 | - $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 215 | - else |
|
| 216 | - $this->prefix = $prefix; |
|
| 216 | + if (empty($prefix)) { |
|
| 217 | + $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 218 | + } else { |
|
| 219 | + $this->prefix = $prefix; |
|
| 220 | + } |
|
| 217 | 221 | |
| 218 | 222 | return true; |
| 219 | 223 | } |
@@ -276,8 +280,9 @@ discard block |
||
| 276 | 280 | |
| 277 | 281 | // Invalidate cache, to be sure! |
| 278 | 282 | // ... as long as index.php can be modified, anyway. |
| 279 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
| 280 | - @touch($cachedir . '/' . 'index.php'); |
|
| 283 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
| 284 | + @touch($cachedir . '/' . 'index.php'); |
|
| 285 | + } |
|
| 281 | 286 | |
| 282 | 287 | return true; |
| 283 | 288 | } |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * SQLite Cache API class |
@@ -68,8 +69,9 @@ discard block |
||
| 68 | 69 | { |
| 69 | 70 | $supported = class_exists("SQLite3") && is_writable($this->cachedir); |
| 70 | 71 | |
| 71 | - if ($test) |
|
| 72 | - return $supported; |
|
| 72 | + if ($test) { |
|
| 73 | + return $supported; |
|
| 74 | + } |
|
| 73 | 75 | |
| 74 | 76 | return parent::isSupported() && $supported; |
| 75 | 77 | } |
@@ -84,8 +86,9 @@ discard block |
||
| 84 | 86 | $result = $this->cacheDB->query($query); |
| 85 | 87 | |
| 86 | 88 | $value = null; |
| 87 | - while ($res = $result->fetchArray(SQLITE3_ASSOC)) |
|
| 88 | - $value = $res['value']; |
|
| 89 | + while ($res = $result->fetchArray(SQLITE3_ASSOC)) { |
|
| 90 | + $value = $res['value']; |
|
| 91 | + } |
|
| 89 | 92 | |
| 90 | 93 | return !empty($value) ? $value : null; |
| 91 | 94 | } |
@@ -125,8 +128,9 @@ discard block |
||
| 125 | 128 | $config_vars[] = $txt['cache_sqlite_settings']; |
| 126 | 129 | $config_vars[] = array('cachedir_sqlite', $txt['cachedir_sqlite'], 'file', 'text', 36, 'cache_sqlite_cachedir'); |
| 127 | 130 | |
| 128 | - if (!isset($context['settings_post_javascript'])) |
|
| 129 | - $context['settings_post_javascript'] = ''; |
|
| 131 | + if (!isset($context['settings_post_javascript'])) { |
|
| 132 | + $context['settings_post_javascript'] = ''; |
|
| 133 | + } |
|
| 130 | 134 | |
| 131 | 135 | $context['settings_post_javascript'] .= ' |
| 132 | 136 | $("#cache_accelerator").change(function (e) { |
@@ -149,10 +153,11 @@ discard block |
||
| 149 | 153 | global $cachedir_sqlite; |
| 150 | 154 | |
| 151 | 155 | // If its invalid, use SMF's. |
| 152 | - if (is_null($dir) || !is_writable($dir)) |
|
| 153 | - $this->cachedir = $cachedir_sqlite; |
|
| 154 | - else |
|
| 155 | - $this->cachedir = $dir; |
|
| 156 | + if (is_null($dir) || !is_writable($dir)) { |
|
| 157 | + $this->cachedir = $cachedir_sqlite; |
|
| 158 | + } else { |
|
| 159 | + $this->cachedir = $dir; |
|
| 160 | + } |
|
| 156 | 161 | } |
| 157 | 162 | |
| 158 | 163 | /** |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
| 51 | 52 | |
| 52 | - if (pg_affected_rows($result) === 0) |
|
| 53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 53 | + if (pg_affected_rows($result) === 0) { |
|
| 54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 55 | + } |
|
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
| 60 | 62 | { |
| 61 | 63 | global $smcFunc, $db_connection; |
| 62 | 64 | |
| 63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
| 64 | - return false; |
|
| 65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 65 | 68 | |
| 66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
| 67 | 70 | $res = pg_fetch_assoc($result); |
| 68 | 71 | |
| 69 | - if ($res['server_version_num'] < 90500) |
|
| 70 | - return false; |
|
| 72 | + if ($res['server_version_num'] < 90500) { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | return $test ? true : parent::isSupported(); |
| 73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
| 81 | 85 | |
| 82 | 86 | $ttl = time() - $ttl; |
| 83 | 87 | |
| 84 | - if (empty($this->pg_get_data_prep)) |
|
| 85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 88 | + if (empty($this->pg_get_data_prep)) { |
|
| 89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
| 88 | 93 | |
| 89 | - if (pg_affected_rows($result) === 0) |
|
| 90 | - return null; |
|
| 94 | + if (pg_affected_rows($result) === 0) { |
|
| 95 | + return null; |
|
| 96 | + } |
|
| 91 | 97 | |
| 92 | 98 | $res = pg_fetch_assoc($result); |
| 93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
| 101 | 107 | { |
| 102 | 108 | global $db_prefix, $db_connection; |
| 103 | 109 | |
| 104 | - if (!isset($value)) |
|
| 105 | - $value = ''; |
|
| 110 | + if (!isset($value)) { |
|
| 111 | + $value = ''; |
|
| 112 | + } |
|
| 106 | 113 | |
| 107 | 114 | $ttl = time() + $ttl; |
| 108 | 115 | |
| 109 | - if (empty($this->pg_put_data_prep)) |
|
| 110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 116 | + if (empty($this->pg_put_data_prep)) { |
|
| 117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
| 112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
| 113 | 120 | ); |
| 121 | + } |
|
| 114 | 122 | |
| 115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
| 116 | 124 | |
| 117 | - if (pg_affected_rows($result) > 0) |
|
| 118 | - return true; |
|
| 119 | - else |
|
| 120 | - return false; |
|
| 125 | + if (pg_affected_rows($result) > 0) { |
|
| 126 | + return true; |
|
| 127 | + } else { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 121 | 130 | } |
| 122 | 131 | |
| 123 | 132 | /** |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
| 45 | 46 | $temp2 = $temp->getVersion(); |
| 46 | 47 | $im_version = $temp2['versionString']; |
| 47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
| 48 | - } |
|
| 49 | - else |
|
| 49 | + } else |
|
| 50 | 50 | { |
| 51 | 51 | $im_version = MagickGetVersionString(); |
| 52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (in_array('db_server', $checkFor)) |
| 62 | 62 | { |
| 63 | 63 | db_extend(); |
| 64 | - if (!isset($db_connection) || $db_connection === false) |
|
| 65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | - else |
|
| 64 | + if (!isset($db_connection) || $db_connection === false) { |
|
| 65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
| 66 | + } else |
|
| 67 | 67 | { |
| 68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
| 69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_engine'](); |
@@ -75,24 +75,31 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | // If we're using memcache we need the server info. |
| 77 | 77 | $memcache_version = '???'; |
| 78 | - if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) |
|
| 79 | - $memcache_version = $cacheAPI->getVersion(); |
|
| 78 | + if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) { |
|
| 79 | + $memcache_version = $cacheAPI->getVersion(); |
|
| 80 | + } |
|
| 80 | 81 | |
| 81 | 82 | // Check to see if we have any accelerators installed... |
| 82 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
| 83 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 84 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
| 85 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 86 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
| 87 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 88 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
| 89 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 83 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
| 84 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
| 85 | + } |
|
| 86 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
| 87 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
| 88 | + } |
|
| 89 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
| 90 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
| 91 | + } |
|
| 92 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
| 93 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | - if (in_array('php', $checkFor)) |
|
| 92 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 96 | + if (in_array('php', $checkFor)) { |
|
| 97 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | - if (in_array('server', $checkFor)) |
|
| 95 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 100 | + if (in_array('server', $checkFor)) { |
|
| 101 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
| 102 | + } |
|
| 96 | 103 | |
| 97 | 104 | return $versions; |
| 98 | 105 | } |
@@ -132,11 +139,13 @@ discard block |
||
| 132 | 139 | fclose($fp); |
| 133 | 140 | |
| 134 | 141 | // The comment looks rougly like... that. |
| 135 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 136 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 142 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 143 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
| 144 | + } |
|
| 137 | 145 | // Not found! This is bad. |
| 138 | - else |
|
| 139 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
| 146 | + else { |
|
| 147 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
| 148 | + } |
|
| 140 | 149 | } |
| 141 | 150 | |
| 142 | 151 | // Do the paid subscriptions handler? |
@@ -147,11 +156,13 @@ discard block |
||
| 147 | 156 | fclose($fp); |
| 148 | 157 | |
| 149 | 158 | // Found it? |
| 150 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 151 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 159 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 160 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
| 161 | + } |
|
| 152 | 162 | // If we haven't how do we all get paid? |
| 153 | - else |
|
| 154 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 163 | + else { |
|
| 164 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
| 165 | + } |
|
| 155 | 166 | } |
| 156 | 167 | |
| 157 | 168 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -166,11 +177,13 @@ discard block |
||
| 166 | 177 | fclose($fp); |
| 167 | 178 | |
| 168 | 179 | // Look for the version comment in the file header. |
| 169 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 170 | - $version_info['file_versions'][$entry] = $match[1]; |
|
| 180 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 181 | + $version_info['file_versions'][$entry] = $match[1]; |
|
| 182 | + } |
|
| 171 | 183 | // It wasn't found, but the file was... show a '??'. |
| 172 | - else |
|
| 173 | - $version_info['file_versions'][$entry] = '??'; |
|
| 184 | + else { |
|
| 185 | + $version_info['file_versions'][$entry] = '??'; |
|
| 186 | + } |
|
| 174 | 187 | } |
| 175 | 188 | } |
| 176 | 189 | $sources_dir->close(); |
@@ -189,11 +202,13 @@ discard block |
||
| 189 | 202 | fclose($fp); |
| 190 | 203 | |
| 191 | 204 | // Look for the version comment in the file header. |
| 192 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 193 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 205 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 206 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
| 207 | + } |
|
| 194 | 208 | // It wasn't found, but the file was... show a '??'. |
| 195 | - else |
|
| 196 | - $version_info['tasks_versions'][$entry] = '??'; |
|
| 209 | + else { |
|
| 210 | + $version_info['tasks_versions'][$entry] = '??'; |
|
| 211 | + } |
|
| 197 | 212 | } |
| 198 | 213 | } |
| 199 | 214 | $tasks_dir->close(); |
@@ -201,8 +216,9 @@ discard block |
||
| 201 | 216 | |
| 202 | 217 | // Load all the files in the default template directory - and the current theme if applicable. |
| 203 | 218 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
| 204 | - if ($settings['theme_id'] != 1) |
|
| 205 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
| 219 | + if ($settings['theme_id'] != 1) { |
|
| 220 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
| 221 | + } |
|
| 206 | 222 | |
| 207 | 223 | foreach ($directories as $type => $dirname) |
| 208 | 224 | { |
@@ -217,11 +233,13 @@ discard block |
||
| 217 | 233 | fclose($fp); |
| 218 | 234 | |
| 219 | 235 | // Look for the version comment in the file header. |
| 220 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
| 221 | - $version_info[$type][$entry] = $match[1]; |
|
| 236 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
| 237 | + $version_info[$type][$entry] = $match[1]; |
|
| 238 | + } |
|
| 222 | 239 | // It wasn't found, but the file was... show a '??'. |
| 223 | - else |
|
| 224 | - $version_info[$type][$entry] = '??'; |
|
| 240 | + else { |
|
| 241 | + $version_info[$type][$entry] = '??'; |
|
| 242 | + } |
|
| 225 | 243 | } |
| 226 | 244 | } |
| 227 | 245 | $this_dir->close(); |
@@ -242,11 +260,13 @@ discard block |
||
| 242 | 260 | list ($name, $language) = explode('.', $entry); |
| 243 | 261 | |
| 244 | 262 | // Look for the version comment in the file header. |
| 245 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
| 246 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 263 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
| 264 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
| 265 | + } |
|
| 247 | 266 | // It wasn't found, but the file was... show a '??'. |
| 248 | - else |
|
| 249 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 267 | + else { |
|
| 268 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
| 269 | + } |
|
| 250 | 270 | } |
| 251 | 271 | } |
| 252 | 272 | $this_dir->close(); |
@@ -261,8 +281,9 @@ discard block |
||
| 261 | 281 | ksort($version_info['tasks_versions']); |
| 262 | 282 | |
| 263 | 283 | // For languages sort each language too. |
| 264 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
| 265 | - ksort($version_info['default_language_versions'][$language]); |
|
| 284 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
| 285 | + ksort($version_info['default_language_versions'][$language]); |
|
| 286 | + } |
|
| 266 | 287 | } |
| 267 | 288 | return $version_info; |
| 268 | 289 | } |
@@ -304,27 +325,31 @@ discard block |
||
| 304 | 325 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
| 305 | 326 | |
| 306 | 327 | // Break it up based on \r or \n, and then clean out extra characters. |
| 307 | - if (strpos($settingsArray, "\n") !== false) |
|
| 308 | - $settingsArray = explode("\n", $settingsArray); |
|
| 309 | - elseif (strpos($settingsArray, "\r") !== false) |
|
| 310 | - $settingsArray = explode("\r", $settingsArray); |
|
| 311 | - else |
|
| 312 | - return; |
|
| 328 | + if (strpos($settingsArray, "\n") !== false) { |
|
| 329 | + $settingsArray = explode("\n", $settingsArray); |
|
| 330 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
| 331 | + $settingsArray = explode("\r", $settingsArray); |
|
| 332 | + } else { |
|
| 333 | + return; |
|
| 334 | + } |
|
| 313 | 335 | |
| 314 | 336 | // Presumably, the file has to have stuff in it for this function to be called :P. |
| 315 | - if (count($settingsArray) < 10) |
|
| 316 | - return; |
|
| 337 | + if (count($settingsArray) < 10) { |
|
| 338 | + return; |
|
| 339 | + } |
|
| 317 | 340 | |
| 318 | 341 | // remove any /r's that made there way in here |
| 319 | - foreach ($settingsArray as $k => $dummy) |
|
| 320 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 342 | + foreach ($settingsArray as $k => $dummy) { |
|
| 343 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 344 | + } |
|
| 321 | 345 | |
| 322 | 346 | // go line by line and see whats changing |
| 323 | 347 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 324 | 348 | { |
| 325 | 349 | // Don't trim or bother with it if it's not a variable. |
| 326 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 327 | - continue; |
|
| 350 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 351 | + continue; |
|
| 352 | + } |
|
| 328 | 353 | |
| 329 | 354 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 330 | 355 | |
@@ -336,8 +361,7 @@ discard block |
||
| 336 | 361 | { |
| 337 | 362 | updateDbLastError($val); |
| 338 | 363 | unset($config_vars[$var]); |
| 339 | - } |
|
| 340 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 364 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 341 | 365 | { |
| 342 | 366 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 343 | 367 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -348,34 +372,39 @@ discard block |
||
| 348 | 372 | } |
| 349 | 373 | |
| 350 | 374 | // End of the file ... maybe |
| 351 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 352 | - $end = $i; |
|
| 375 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 376 | + $end = $i; |
|
| 377 | + } |
|
| 353 | 378 | } |
| 354 | 379 | |
| 355 | 380 | // This should never happen, but apparently it is happening. |
| 356 | - if (empty($end) || $end < 10) |
|
| 357 | - $end = count($settingsArray) - 1; |
|
| 381 | + if (empty($end) || $end < 10) { |
|
| 382 | + $end = count($settingsArray) - 1; |
|
| 383 | + } |
|
| 358 | 384 | |
| 359 | 385 | // Still more variables to go? Then lets add them at the end. |
| 360 | 386 | if (!empty($config_vars)) |
| 361 | 387 | { |
| 362 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 363 | - $settingsArray[$end++] = ''; |
|
| 364 | - else |
|
| 365 | - $end++; |
|
| 388 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 389 | + $settingsArray[$end++] = ''; |
|
| 390 | + } else { |
|
| 391 | + $end++; |
|
| 392 | + } |
|
| 366 | 393 | |
| 367 | 394 | // Add in any newly defined vars that were passed |
| 368 | - foreach ($config_vars as $var => $val) |
|
| 369 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 395 | + foreach ($config_vars as $var => $val) { |
|
| 396 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 397 | + } |
|
| 370 | 398 | |
| 371 | 399 | $settingsArray[$end] = '?' . '>'; |
| 400 | + } else { |
|
| 401 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 372 | 402 | } |
| 373 | - else |
|
| 374 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 375 | 403 | |
| 376 | 404 | // Sanity error checking: the file needs to be at least 12 lines. |
| 377 | - if (count($settingsArray) < 12) |
|
| 378 | - return; |
|
| 405 | + if (count($settingsArray) < 12) { |
|
| 406 | + return; |
|
| 407 | + } |
|
| 379 | 408 | |
| 380 | 409 | // Try to avoid a few pitfalls: |
| 381 | 410 | // - like a possible race condition, |
@@ -383,8 +412,9 @@ discard block |
||
| 383 | 412 | // |
| 384 | 413 | // Check before you act: if cache is enabled, we can do a simple write test |
| 385 | 414 | // to validate that we even write things on this filesystem. |
| 386 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 387 | - $cachedir = $boarddir . '/cache'; |
|
| 415 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 416 | + $cachedir = $boarddir . '/cache'; |
|
| 417 | + } |
|
| 388 | 418 | |
| 389 | 419 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 390 | 420 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
| 419 | 449 | // Well this is not good at all, lets see if we can save this |
| 420 | 450 | $context['settings_message'] = 'settings_error'; |
| 421 | 451 | |
| 422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 454 | + } |
|
| 424 | 455 | } |
| 425 | 456 | } |
| 426 | 457 | |
| 427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 429 | - if (function_exists('opcache_invalidate')) |
|
| 430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 431 | -} |
|
| 460 | + if (function_exists('opcache_invalidate')) { |
|
| 461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 462 | + } |
|
| 463 | + } |
|
| 432 | 464 | |
| 433 | 465 | /** |
| 434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
| 454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
| 455 | 487 | |
| 456 | 488 | // This must exist! |
| 457 | - if (!isset($context['admin_preferences'])) |
|
| 458 | - return false; |
|
| 489 | + if (!isset($context['admin_preferences'])) { |
|
| 490 | + return false; |
|
| 491 | + } |
|
| 459 | 492 | |
| 460 | 493 | // This is what we'll be saving. |
| 461 | 494 | $options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
| 519 | 552 | $emails_sent = array(); |
| 520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 521 | 554 | { |
| 522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 523 | - continue; |
|
| 555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 524 | 558 | |
| 525 | 559 | // Stick their particulars in the replacement data. |
| 526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
| 539 | 573 | $smcFunc['db_free_result']($request); |
| 540 | 574 | |
| 541 | 575 | // Any additional users we must email this to? |
| 542 | - if (!empty($additional_recipients)) |
|
| 543 | - foreach ($additional_recipients as $recipient) |
|
| 576 | + if (!empty($additional_recipients)) { |
|
| 577 | + foreach ($additional_recipients as $recipient) |
|
| 544 | 578 | { |
| 545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
| 546 | 580 | continue; |
| 581 | + } |
|
| 547 | 582 | |
| 548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
| 549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
| 301 | 305 | $context['default_list'] = 'moderation_log_list'; |
| 302 | 306 | |
| 303 | 307 | // If a hook has changed this, respect it. |
| 304 | - if (!empty($moderation_menu_name)) |
|
| 305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 306 | - elseif (isset($context['moderation_menu_name'])) |
|
| 307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | + if (!empty($moderation_menu_name)) { |
|
| 309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
| 311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 311 | 315 | ); |
| 312 | -} |
|
| 316 | + } |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | /** |
| 315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
| 413 | 418 | // Add on some of the column stuff info |
| 414 | 419 | if (!empty($row['id_board'])) |
| 415 | 420 | { |
| 416 | - if ($row['action'] == 'move') |
|
| 417 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 418 | - else |
|
| 419 | - $row['extra']['board'] = $row['id_board']; |
|
| 421 | + if ($row['action'] == 'move') { |
|
| 422 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 423 | + } else { |
|
| 424 | + $row['extra']['board'] = $row['id_board']; |
|
| 425 | + } |
|
| 420 | 426 | } |
| 421 | 427 | |
| 422 | - if (!empty($row['id_topic'])) |
|
| 423 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | - if (!empty($row['id_msg'])) |
|
| 425 | - $row['extra']['message'] = $row['id_msg']; |
|
| 428 | + if (!empty($row['id_topic'])) { |
|
| 429 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 430 | + } |
|
| 431 | + if (!empty($row['id_msg'])) { |
|
| 432 | + $row['extra']['message'] = $row['id_msg']; |
|
| 433 | + } |
|
| 426 | 434 | |
| 427 | 435 | // Is this associated with a topic? |
| 428 | - if (isset($row['extra']['topic'])) |
|
| 429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 430 | - if (isset($row['extra']['new_topic'])) |
|
| 431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 436 | + if (isset($row['extra']['topic'])) { |
|
| 437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 438 | + } |
|
| 439 | + if (isset($row['extra']['new_topic'])) { |
|
| 440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 441 | + } |
|
| 432 | 442 | |
| 433 | 443 | // How about a member? |
| 434 | 444 | if (isset($row['extra']['member'])) |
| 435 | 445 | { |
| 436 | 446 | // Guests don't have names! |
| 437 | - if (empty($row['extra']['member'])) |
|
| 438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 439 | - else |
|
| 447 | + if (empty($row['extra']['member'])) { |
|
| 448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 449 | + } else |
|
| 440 | 450 | { |
| 441 | 451 | // Try to find it... |
| 442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
| 444 | 454 | } |
| 445 | 455 | |
| 446 | 456 | // Associated with a board? |
| 447 | - if (isset($row['extra']['board_to'])) |
|
| 448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 449 | - if (isset($row['extra']['board_from'])) |
|
| 450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 451 | - if (isset($row['extra']['board'])) |
|
| 452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 457 | + if (isset($row['extra']['board_to'])) { |
|
| 458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 459 | + } |
|
| 460 | + if (isset($row['extra']['board_from'])) { |
|
| 461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 462 | + } |
|
| 463 | + if (isset($row['extra']['board'])) { |
|
| 464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 465 | + } |
|
| 453 | 466 | |
| 454 | 467 | // A message? |
| 455 | - if (isset($row['extra']['message'])) |
|
| 456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 468 | + if (isset($row['extra']['message'])) { |
|
| 469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 470 | + } |
|
| 457 | 471 | |
| 458 | 472 | // IP Info? |
| 459 | - if (isset($row['extra']['ip_range'])) |
|
| 460 | - if ($seeIP) |
|
| 473 | + if (isset($row['extra']['ip_range'])) { |
|
| 474 | + if ($seeIP) |
|
| 461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 462 | - else |
|
| 463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 476 | + } else { |
|
| 477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 478 | + } |
|
| 464 | 479 | |
| 465 | 480 | // Email? |
| 466 | - if (isset($row['extra']['email'])) |
|
| 467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 481 | + if (isset($row['extra']['email'])) { |
|
| 482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 483 | + } |
|
| 468 | 484 | |
| 469 | 485 | // Bans are complex. |
| 470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 471 | 487 | { |
| 472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 474 | - if (isset($row['extra'][$type])) |
|
| 489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 490 | + if (isset($row['extra'][$type])) |
|
| 475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 492 | + } |
|
| 476 | 493 | } |
| 477 | 494 | |
| 478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
| 508 | 525 | foreach ($boards[$row['id_board']] as $action) |
| 509 | 526 | { |
| 510 | 527 | // Make the board number into a link - dealing with moving too. |
| 511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | } |
| 519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
| 547 | 565 | ); |
| 548 | 566 | |
| 549 | 567 | // Make the topic number into a link - dealing with splitting too. |
| 550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 572 | + } |
|
| 554 | 573 | } |
| 555 | 574 | } |
| 556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
| 583 | 602 | ); |
| 584 | 603 | |
| 585 | 604 | // Make the message number into a link. |
| 586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 607 | + } |
|
| 588 | 608 | } |
| 589 | 609 | } |
| 590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
| 624 | 644 | foreach ($entries as $k => $entry) |
| 625 | 645 | { |
| 626 | 646 | // Make any message info links so its easier to go find that message. |
| 627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 649 | + } |
|
| 629 | 650 | |
| 630 | 651 | // Mark up any deleted members, topics and boards. |
| 631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 655 | + } |
|
| 634 | 656 | |
| 635 | 657 | if (isset($entry['extra']['report'])) |
| 636 | 658 | { |
| 637 | 659 | // Member profile reports go in a different area |
| 638 | - if (stristr($entry['action'], 'user_report')) |
|
| 639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 640 | - else |
|
| 641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 660 | + if (stristr($entry['action'], 'user_report')) { |
|
| 661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 662 | + } else { |
|
| 663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 664 | + } |
|
| 642 | 665 | } |
| 643 | 666 | |
| 644 | - if (empty($entries[$k]['action_text'])) |
|
| 645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 667 | + if (empty($entries[$k]['action_text'])) { |
|
| 668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 669 | + } |
|
| 646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 647 | 671 | function ($matches) use ($entries, $k) |
| 648 | 672 | { |
@@ -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 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Initialize the array that'll be returned later on. |
| 52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
| 63 | 65 | // Get any spiders if enabled. |
| 64 | 66 | $spiders = array(); |
| 65 | 67 | $spider_finds = array(); |
| 66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 67 | - $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 69 | + $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Load the users online right now. |
| 70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
| 92 | 95 | $membersOnlineStats['num_guests']++; |
| 93 | 96 | |
| 94 | 97 | continue; |
| 95 | - } |
|
| 96 | - |
|
| 97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | 99 | { |
| 99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
| 100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | // Some basic color coding... |
| 105 | - if (!empty($row['online_color'])) |
|
| 106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 107 | - else |
|
| 108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 106 | + if (!empty($row['online_color'])) { |
|
| 107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 108 | + } else { |
|
| 109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | // Buddies get counted and highlighted. |
| 111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,8 +134,8 @@ discard block |
||
| 132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 133 | 135 | |
| 134 | 136 | // Store all distinct (primary) membergroups that are shown. |
| 135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | 139 | 'id' => $row['id_group'], |
| 138 | 140 | 'name' => $row['group_name'], |
| 139 | 141 | 'color' => $row['online_color'], |
@@ -141,6 +143,7 @@ discard block |
||
| 141 | 143 | 'type' => $row['group_type'], |
| 142 | 144 | 'parent' => $row['id_parent'], |
| 143 | 145 | ); |
| 146 | + } |
|
| 144 | 147 | } |
| 145 | 148 | $smcFunc['db_free_result']($request); |
| 146 | 149 | |
@@ -201,11 +204,12 @@ discard block |
||
| 201 | 204 | $settingsToUpdate = array(); |
| 202 | 205 | |
| 203 | 206 | // More members on now than ever were? Update it! |
| 204 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 205 | - $settingsToUpdate = array( |
|
| 207 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 208 | + $settingsToUpdate = array( |
|
| 206 | 209 | 'mostOnline' => $total_users_online, |
| 207 | 210 | 'mostDate' => time() |
| 208 | 211 | ); |
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 211 | 215 | |
@@ -237,8 +241,9 @@ discard block |
||
| 237 | 241 | { |
| 238 | 242 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 239 | 243 | |
| 240 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 241 | - trackStats(array('most_on' => $total_users_online)); |
|
| 244 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 245 | + trackStats(array('most_on' => $total_users_online)); |
|
| 246 | + } |
|
| 242 | 247 | |
| 243 | 248 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 244 | 249 | } |
@@ -255,8 +260,9 @@ discard block |
||
| 255 | 260 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 256 | 261 | } |
| 257 | 262 | |
| 258 | - if (!empty($settingsToUpdate)) |
|
| 259 | - updateSettings($settingsToUpdate); |
|
| 260 | -} |
|
| 263 | + if (!empty($settingsToUpdate)) { |
|
| 264 | + updateSettings($settingsToUpdate); |
|
| 265 | + } |
|
| 266 | + } |
|
| 261 | 267 | |
| 262 | 268 | ?> |
| 263 | 269 | \ No newline at end of file |