@@ -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('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 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array The truncated array |
| 25 | 25 | */ |
| 26 | -function truncateArray($arr, $max_length=1900) |
|
| 26 | +function truncateArray($arr, $max_length = 1900) |
|
| 27 | 27 | { |
| 28 | 28 | $curr_length = array_sum(array_map("strlen", $arr)); |
| 29 | 29 | if ($curr_length <= $max_length) |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | else |
| 32 | 32 | { |
| 33 | 33 | // Truncate each element's value to a reasonable length |
| 34 | - $param_max = floor($max_length/count($arr)); |
|
| 34 | + $param_max = floor($max_length / count($arr)); |
|
| 35 | 35 | foreach ($arr as $key => &$value) |
| 36 | 36 | $value = substr($value, 0, $param_max - strlen($key) - 5); |
| 37 | 37 | return $arr; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | if (filemtime($cachedir . '/db_last_error.php') === $last_db_error_change) |
| 198 | 198 | { |
| 199 | 199 | // Write the change |
| 200 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 200 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 201 | 201 | $written_bytes = file_put_contents($cachedir . '/db_last_error.php', $write_db_change, LOCK_EX); |
| 202 | 202 | |
| 203 | 203 | // survey says ... |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
| 271 | 271 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
| 272 | 272 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
| 273 | - ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
|
| 273 | + ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), ' |
|
| 274 | 274 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 275 | 275 | |
| 276 | 276 | if (function_exists('memory_get_peak_usage')) |
@@ -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 | * Truncate the GET array to a specified length |
@@ -26,14 +27,15 @@ discard block |
||
| 26 | 27 | function truncateArray($arr, $max_length=1900) |
| 27 | 28 | { |
| 28 | 29 | $curr_length = array_sum(array_map("strlen", $arr)); |
| 29 | - if ($curr_length <= $max_length) |
|
| 30 | - return $arr; |
|
| 31 | - else |
|
| 30 | + if ($curr_length <= $max_length) { |
|
| 31 | + return $arr; |
|
| 32 | + } else |
|
| 32 | 33 | { |
| 33 | 34 | // Truncate each element's value to a reasonable length |
| 34 | 35 | $param_max = floor($max_length/count($arr)); |
| 35 | - foreach ($arr as $key => &$value) |
|
| 36 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 36 | + foreach ($arr as $key => &$value) { |
|
| 37 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 38 | + } |
|
| 37 | 39 | return $arr; |
| 38 | 40 | } |
| 39 | 41 | } |
@@ -55,8 +57,9 @@ discard block |
||
| 55 | 57 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 56 | 58 | if ($topic) |
| 57 | 59 | { |
| 58 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 59 | - $force = false; |
|
| 60 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 61 | + $force = false; |
|
| 62 | + } |
|
| 60 | 63 | $_SESSION['last_topic_id'] = $topic; |
| 61 | 64 | } |
| 62 | 65 | } |
@@ -69,22 +72,24 @@ discard block |
||
| 69 | 72 | } |
| 70 | 73 | |
| 71 | 74 | // Don't mark them as online more than every so often. |
| 72 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 73 | - return; |
|
| 75 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | if (!empty($modSettings['who_enabled'])) |
| 76 | 80 | { |
| 77 | 81 | $encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 78 | 82 | |
| 79 | 83 | // In the case of a dlattach action, session_var may not be set. |
| 80 | - if (!isset($context['session_var'])) |
|
| 81 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 84 | + if (!isset($context['session_var'])) { |
|
| 85 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 86 | + } |
|
| 82 | 87 | |
| 83 | 88 | unset($encoded_get['sesc'], $encoded_get[$context['session_var']]); |
| 84 | 89 | $encoded_get = $smcFunc['json_encode']($encoded_get); |
| 90 | + } else { |
|
| 91 | + $encoded_get = ''; |
|
| 85 | 92 | } |
| 86 | - else |
|
| 87 | - $encoded_get = ''; |
|
| 88 | 93 | |
| 89 | 94 | // Guests use 0, members use their session ID. |
| 90 | 95 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -124,17 +129,18 @@ discard block |
||
| 124 | 129 | ); |
| 125 | 130 | |
| 126 | 131 | // Guess it got deleted. |
| 127 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 132 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 133 | + $_SESSION['log_time'] = 0; |
|
| 134 | + } |
|
| 135 | + } else { |
|
| 128 | 136 | $_SESSION['log_time'] = 0; |
| 129 | 137 | } |
| 130 | - else |
|
| 131 | - $_SESSION['log_time'] = 0; |
|
| 132 | 138 | |
| 133 | 139 | // Otherwise, we have to delete and insert. |
| 134 | 140 | if (empty($_SESSION['log_time'])) |
| 135 | 141 | { |
| 136 | - if ($do_delete || !empty($user_info['id'])) |
|
| 137 | - $smcFunc['db_query']('', ' |
|
| 142 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 143 | + $smcFunc['db_query']('', ' |
|
| 138 | 144 | DELETE FROM {db_prefix}log_online |
| 139 | 145 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 140 | 146 | array( |
@@ -142,6 +148,7 @@ discard block |
||
| 142 | 148 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 143 | 149 | ) |
| 144 | 150 | ); |
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 147 | 154 | '{db_prefix}log_online', |
@@ -155,21 +162,24 @@ discard block |
||
| 155 | 162 | $_SESSION['log_time'] = time(); |
| 156 | 163 | |
| 157 | 164 | // Well, they are online now. |
| 158 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 159 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 165 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 166 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 167 | + } |
|
| 160 | 168 | |
| 161 | 169 | // Set their login time, if not already done within the last minute. |
| 162 | 170 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 163 | 171 | { |
| 164 | 172 | // Don't count longer than 15 minutes. |
| 165 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 166 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 173 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 174 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 169 | 178 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 170 | 179 | |
| 171 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 172 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 180 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 181 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 182 | + } |
|
| 173 | 183 | |
| 174 | 184 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 175 | 185 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -206,8 +216,7 @@ discard block |
||
| 206 | 216 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 207 | 217 | // Copy the file back and run for your life! |
| 208 | 218 | @copy($cachedir . '/db_last_error_bak.php', $cachedir . '/db_last_error.php'); |
| 209 | - } |
|
| 210 | - else |
|
| 219 | + } else |
|
| 211 | 220 | { |
| 212 | 221 | @touch($boarddir . '/' . 'Settings.php'); |
| 213 | 222 | return true; |
@@ -227,22 +236,27 @@ discard block |
||
| 227 | 236 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 228 | 237 | |
| 229 | 238 | // Add to Settings.php if you want to show the debugging information. |
| 230 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 231 | - return; |
|
| 239 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 240 | + return; |
|
| 241 | + } |
|
| 232 | 242 | |
| 233 | - if (empty($_SESSION['view_queries'])) |
|
| 234 | - $_SESSION['view_queries'] = 0; |
|
| 235 | - if (empty($context['debug']['language_files'])) |
|
| 236 | - $context['debug']['language_files'] = array(); |
|
| 237 | - if (empty($context['debug']['sheets'])) |
|
| 238 | - $context['debug']['sheets'] = array(); |
|
| 243 | + if (empty($_SESSION['view_queries'])) { |
|
| 244 | + $_SESSION['view_queries'] = 0; |
|
| 245 | + } |
|
| 246 | + if (empty($context['debug']['language_files'])) { |
|
| 247 | + $context['debug']['language_files'] = array(); |
|
| 248 | + } |
|
| 249 | + if (empty($context['debug']['sheets'])) { |
|
| 250 | + $context['debug']['sheets'] = array(); |
|
| 251 | + } |
|
| 239 | 252 | |
| 240 | 253 | $files = get_included_files(); |
| 241 | 254 | $total_size = 0; |
| 242 | 255 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 243 | 256 | { |
| 244 | - if (file_exists($files[$i])) |
|
| 245 | - $total_size += filesize($files[$i]); |
|
| 257 | + if (file_exists($files[$i])) { |
|
| 258 | + $total_size += filesize($files[$i]); |
|
| 259 | + } |
|
| 246 | 260 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 247 | 261 | } |
| 248 | 262 | |
@@ -251,8 +265,9 @@ discard block |
||
| 251 | 265 | { |
| 252 | 266 | foreach ($db_cache as $q => $query_data) |
| 253 | 267 | { |
| 254 | - if (!empty($query_data['w'])) |
|
| 255 | - $warnings += count($query_data['w']); |
|
| 268 | + if (!empty($query_data['w'])) { |
|
| 269 | + $warnings += count($query_data['w']); |
|
| 270 | + } |
|
| 256 | 271 | } |
| 257 | 272 | |
| 258 | 273 | $_SESSION['debug'] = &$db_cache; |
@@ -273,12 +288,14 @@ discard block |
||
| 273 | 288 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 274 | 289 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 275 | 290 | |
| 276 | - if (function_exists('memory_get_peak_usage')) |
|
| 277 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 291 | + if (function_exists('memory_get_peak_usage')) { |
|
| 292 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 293 | + } |
|
| 278 | 294 | |
| 279 | 295 | // What tokens are active? |
| 280 | - if (isset($_SESSION['token'])) |
|
| 281 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 296 | + if (isset($_SESSION['token'])) { |
|
| 297 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 298 | + } |
|
| 282 | 299 | |
| 283 | 300 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 284 | 301 | { |
@@ -292,10 +309,12 @@ discard block |
||
| 292 | 309 | $total_t += $cache_hit['t']; |
| 293 | 310 | $total_s += $cache_hit['s']; |
| 294 | 311 | } |
| 295 | - if (!isset($cache_misses)) |
|
| 296 | - $cache_misses = array(); |
|
| 297 | - foreach ($cache_misses as $missed) |
|
| 298 | - $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 312 | + if (!isset($cache_misses)) { |
|
| 313 | + $cache_misses = array(); |
|
| 314 | + } |
|
| 315 | + foreach ($cache_misses as $missed) { |
|
| 316 | + $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 317 | + } |
|
| 299 | 318 | |
| 300 | 319 | echo ' |
| 301 | 320 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -306,38 +325,44 @@ discard block |
||
| 306 | 325 | <a href="', $scripturl, '?action=viewquery" target="_blank" rel="noopener">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 307 | 326 | <br>'; |
| 308 | 327 | |
| 309 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 310 | - foreach ($db_cache as $q => $query_data) |
|
| 328 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 329 | + foreach ($db_cache as $q => $query_data) |
|
| 311 | 330 | { |
| 312 | 331 | $is_select = strpos(trim($query_data['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($query_data['q'])) != 0; |
| 332 | + } |
|
| 313 | 333 | // Temporary tables created in earlier queries are not explainable. |
| 314 | 334 | if ($is_select) |
| 315 | 335 | { |
| 316 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 317 | - if (strpos(trim($query_data['q']), $tmp) !== false) |
|
| 336 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 337 | + if (strpos(trim($query_data['q']), $tmp) !== false) |
|
| 318 | 338 | { |
| 319 | 339 | $is_select = false; |
| 340 | + } |
|
| 320 | 341 | break; |
| 321 | 342 | } |
| 322 | 343 | } |
| 323 | 344 | // But actual creation of the temporary tables are. |
| 324 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) |
|
| 325 | - $is_select = true; |
|
| 345 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) { |
|
| 346 | + $is_select = true; |
|
| 347 | + } |
|
| 326 | 348 | |
| 327 | 349 | // Make the filenames look a bit better. |
| 328 | - if (isset($query_data['f'])) |
|
| 329 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 350 | + if (isset($query_data['f'])) { |
|
| 351 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 352 | + } |
|
| 330 | 353 | |
| 331 | 354 | echo ' |
| 332 | 355 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" rel="noopener" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($query_data['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 333 | 356 | '; |
| 334 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
| 335 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 357 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
| 358 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 359 | + } |
|
| 336 | 360 | |
| 337 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 338 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
| 339 | - elseif (isset($query_data['t'])) |
|
| 340 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
| 361 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 362 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
| 363 | + } elseif (isset($query_data['t'])) { |
|
| 364 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
| 365 | + } |
|
| 341 | 366 | echo ' |
| 342 | 367 | <br>'; |
| 343 | 368 | } |
@@ -362,12 +387,14 @@ discard block |
||
| 362 | 387 | global $modSettings, $smcFunc; |
| 363 | 388 | static $cache_stats = array(); |
| 364 | 389 | |
| 365 | - if (empty($modSettings['trackStats'])) |
|
| 366 | - return false; |
|
| 367 | - if (!empty($stats)) |
|
| 368 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 369 | - elseif (empty($cache_stats)) |
|
| 370 | - return false; |
|
| 390 | + if (empty($modSettings['trackStats'])) { |
|
| 391 | + return false; |
|
| 392 | + } |
|
| 393 | + if (!empty($stats)) { |
|
| 394 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 395 | + } elseif (empty($cache_stats)) { |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 371 | 398 | |
| 372 | 399 | $setStringUpdate = ''; |
| 373 | 400 | $insert_keys = array(); |
@@ -380,10 +407,11 @@ discard block |
||
| 380 | 407 | $setStringUpdate .= ' |
| 381 | 408 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 382 | 409 | |
| 383 | - if ($change === '+') |
|
| 384 | - $cache_stats[$field] = 1; |
|
| 385 | - else |
|
| 386 | - $update_parameters[$field] = $change; |
|
| 410 | + if ($change === '+') { |
|
| 411 | + $cache_stats[$field] = 1; |
|
| 412 | + } else { |
|
| 413 | + $update_parameters[$field] = $change; |
|
| 414 | + } |
|
| 387 | 415 | $insert_keys[$field] = 'int'; |
| 388 | 416 | } |
| 389 | 417 | |
@@ -447,43 +475,50 @@ discard block |
||
| 447 | 475 | ); |
| 448 | 476 | |
| 449 | 477 | // Make sure this particular log is enabled first... |
| 450 | - if (empty($modSettings['modlog_enabled'])) |
|
| 451 | - unset ($log_types['moderate']); |
|
| 452 | - if (empty($modSettings['userlog_enabled'])) |
|
| 453 | - unset ($log_types['user']); |
|
| 454 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 455 | - unset ($log_types['admin']); |
|
| 478 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 479 | + unset ($log_types['moderate']); |
|
| 480 | + } |
|
| 481 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 482 | + unset ($log_types['user']); |
|
| 483 | + } |
|
| 484 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 485 | + unset ($log_types['admin']); |
|
| 486 | + } |
|
| 456 | 487 | |
| 457 | 488 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 458 | 489 | |
| 459 | 490 | foreach ($logs as $log) |
| 460 | 491 | { |
| 461 | - if (!isset($log_types[$log['log_type']])) |
|
| 462 | - return false; |
|
| 492 | + if (!isset($log_types[$log['log_type']])) { |
|
| 493 | + return false; |
|
| 494 | + } |
|
| 463 | 495 | |
| 464 | - if (!is_array($log['extra'])) |
|
| 465 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 496 | + if (!is_array($log['extra'])) { |
|
| 497 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 498 | + } |
|
| 466 | 499 | |
| 467 | 500 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 468 | 501 | if (isset($log['extra']['topic'])) |
| 469 | 502 | { |
| 470 | - if (!is_numeric($log['extra']['topic'])) |
|
| 471 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 503 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 504 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 505 | + } |
|
| 472 | 506 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 473 | 507 | unset($log['extra']['topic']); |
| 508 | + } else { |
|
| 509 | + $topic_id = 0; |
|
| 474 | 510 | } |
| 475 | - else |
|
| 476 | - $topic_id = 0; |
|
| 477 | 511 | |
| 478 | 512 | if (isset($log['extra']['message'])) |
| 479 | 513 | { |
| 480 | - if (!is_numeric($log['extra']['message'])) |
|
| 481 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 514 | + if (!is_numeric($log['extra']['message'])) { |
|
| 515 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 516 | + } |
|
| 482 | 517 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 483 | 518 | unset($log['extra']['message']); |
| 519 | + } else { |
|
| 520 | + $msg_id = 0; |
|
| 484 | 521 | } |
| 485 | - else |
|
| 486 | - $msg_id = 0; |
|
| 487 | 522 | |
| 488 | 523 | // @todo cache this? |
| 489 | 524 | // Is there an associated report on this? |
@@ -510,23 +545,26 @@ discard block |
||
| 510 | 545 | $smcFunc['db_free_result']($request); |
| 511 | 546 | } |
| 512 | 547 | |
| 513 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 514 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 548 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 549 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 550 | + } |
|
| 515 | 551 | |
| 516 | 552 | if (isset($log['extra']['board'])) |
| 517 | 553 | { |
| 518 | - if (!is_numeric($log['extra']['board'])) |
|
| 519 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 554 | + if (!is_numeric($log['extra']['board'])) { |
|
| 555 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 556 | + } |
|
| 520 | 557 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 521 | 558 | unset($log['extra']['board']); |
| 559 | + } else { |
|
| 560 | + $board_id = 0; |
|
| 522 | 561 | } |
| 523 | - else |
|
| 524 | - $board_id = 0; |
|
| 525 | 562 | |
| 526 | 563 | if (isset($log['extra']['board_to'])) |
| 527 | 564 | { |
| 528 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 529 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 565 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 566 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 567 | + } |
|
| 530 | 568 | if (empty($board_id)) |
| 531 | 569 | { |
| 532 | 570 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -534,10 +572,11 @@ discard block |
||
| 534 | 572 | } |
| 535 | 573 | } |
| 536 | 574 | |
| 537 | - if (isset($log['extra']['member_affected'])) |
|
| 538 | - $memID = $log['extra']['member_affected']; |
|
| 539 | - else |
|
| 540 | - $memID = $user_info['id']; |
|
| 575 | + if (isset($log['extra']['member_affected'])) { |
|
| 576 | + $memID = $log['extra']['member_affected']; |
|
| 577 | + } else { |
|
| 578 | + $memID = $user_info['id']; |
|
| 579 | + } |
|
| 541 | 580 | |
| 542 | 581 | $inserts[] = array( |
| 543 | 582 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -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 |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | echo ' |
| 74 | 74 | <div class="main_container"> |
| 75 | - <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '','" id="category_', $category['id'], '"> |
|
| 75 | + <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '', '" id="category_', $category['id'], '"> |
|
| 76 | 76 | <h3 class="catbg">'; |
| 77 | 77 | |
| 78 | 78 | // If this category even can collapse, show a link to collapse it. |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | foreach ($board['children'] as $child) |
| 248 | 248 | { |
| 249 | 249 | if (!$child['is_redirect']) |
| 250 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 250 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 251 | 251 | else |
| 252 | 252 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
| 253 | 253 | |
@@ -31,9 +31,10 @@ discard block |
||
| 31 | 31 | echo ' |
| 32 | 32 | <ul id="smf_slider" class="roundframe">'; |
| 33 | 33 | |
| 34 | - foreach ($context['news_lines'] as $news) |
|
| 35 | - echo ' |
|
| 34 | + foreach ($context['news_lines'] as $news) { |
|
| 35 | + echo ' |
|
| 36 | 36 | <li>', $news, '</li>'; |
| 37 | + } |
|
| 37 | 38 | |
| 38 | 39 | echo ' |
| 39 | 40 | </ul> |
@@ -65,8 +66,9 @@ discard block |
||
| 65 | 66 | foreach ($context['categories'] as $category) |
| 66 | 67 | { |
| 67 | 68 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
| 68 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
| 69 | - continue; |
|
| 69 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | echo ' |
| 72 | 74 | <div class="main_container"> |
@@ -74,9 +76,10 @@ discard block |
||
| 74 | 76 | <h3 class="catbg">'; |
| 75 | 77 | |
| 76 | 78 | // If this category even can collapse, show a link to collapse it. |
| 77 | - if ($category['can_collapse']) |
|
| 78 | - echo ' |
|
| 79 | + if ($category['can_collapse']) { |
|
| 80 | + echo ' |
|
| 79 | 81 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
| 82 | + } |
|
| 80 | 83 | |
| 81 | 84 | echo ' |
| 82 | 85 | ', $category['link'], ' |
@@ -106,10 +109,11 @@ discard block |
||
| 106 | 109 | </div>'; |
| 107 | 110 | |
| 108 | 111 | // Won't somebody think of the children! |
| 109 | - if (function_exists('template_bi_' . $board['type'] . '_children')) |
|
| 110 | - call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
| 111 | - else |
|
| 112 | - template_bi_board_children($board); |
|
| 112 | + if (function_exists('template_bi_' . $board['type'] . '_children')) { |
|
| 113 | + call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
| 114 | + } else { |
|
| 115 | + template_bi_board_children($board); |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | echo ' |
| 115 | 119 | </div><!-- #board_[id] -->'; |
@@ -124,12 +128,13 @@ discard block |
||
| 124 | 128 | </div><!-- #boardindex_table -->'; |
| 125 | 129 | |
| 126 | 130 | // Show the mark all as read button? |
| 127 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
| 128 | - echo ' |
|
| 131 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
| 132 | + echo ' |
|
| 129 | 133 | <div class="mark_read"> |
| 130 | 134 | ', template_button_strip($context['mark_read_button'], 'right'), ' |
| 131 | 135 | </div>'; |
| 132 | -} |
|
| 136 | + } |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | /** |
| 135 | 140 | * Outputs the board icon for a standard board. |
@@ -173,18 +178,20 @@ discard block |
||
| 173 | 178 | </a>'; |
| 174 | 179 | |
| 175 | 180 | // Has it outstanding posts for approval? |
| 176 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 177 | - echo ' |
|
| 181 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 182 | + echo ' |
|
| 178 | 183 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 184 | + } |
|
| 179 | 185 | |
| 180 | 186 | echo ' |
| 181 | 187 | <p class="board_description">', $board['description'], '</p>'; |
| 182 | 188 | |
| 183 | 189 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 184 | - if (!empty($board['link_moderators'])) |
|
| 185 | - echo ' |
|
| 190 | + if (!empty($board['link_moderators'])) { |
|
| 191 | + echo ' |
|
| 186 | 192 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 187 | -} |
|
| 193 | + } |
|
| 194 | + } |
|
| 188 | 195 | |
| 189 | 196 | /** |
| 190 | 197 | * Outputs the board stats for a standard board. |
@@ -225,10 +232,11 @@ discard block |
||
| 225 | 232 | */ |
| 226 | 233 | function template_bi_board_lastpost($board) |
| 227 | 234 | { |
| 228 | - if (!empty($board['last_post']['id'])) |
|
| 229 | - echo ' |
|
| 235 | + if (!empty($board['last_post']['id'])) { |
|
| 236 | + echo ' |
|
| 230 | 237 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 231 | -} |
|
| 238 | + } |
|
| 239 | + } |
|
| 232 | 240 | |
| 233 | 241 | /** |
| 234 | 242 | * Outputs the board children for a standard board. |
@@ -248,14 +256,16 @@ discard block |
||
| 248 | 256 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
| 249 | 257 | foreach ($board['children'] as $child) |
| 250 | 258 | { |
| 251 | - if (!$child['is_redirect']) |
|
| 252 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 253 | - else |
|
| 254 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 259 | + if (!$child['is_redirect']) { |
|
| 260 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 261 | + } else { |
|
| 262 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 263 | + } |
|
| 255 | 264 | |
| 256 | 265 | // Has it posts awaiting approval? |
| 257 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
| 258 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 266 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
| 267 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 268 | + } |
|
| 259 | 269 | |
| 260 | 270 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 261 | 271 | } |
@@ -282,8 +292,9 @@ discard block |
||
| 282 | 292 | { |
| 283 | 293 | global $context, $options, $txt; |
| 284 | 294 | |
| 285 | - if (empty($context['info_center'])) |
|
| 286 | - return; |
|
| 295 | + if (empty($context['info_center'])) { |
|
| 296 | + return; |
|
| 297 | + } |
|
| 287 | 298 | |
| 288 | 299 | // Here's where the "Info Center" starts... |
| 289 | 300 | echo ' |
@@ -383,14 +394,15 @@ discard block |
||
| 383 | 394 | /* Each post in latest_posts has: |
| 384 | 395 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
| 385 | 396 | subject, short_subject (shortened with...), time, link, and href. */ |
| 386 | - foreach ($context['latest_posts'] as $post) |
|
| 387 | - echo ' |
|
| 397 | + foreach ($context['latest_posts'] as $post) { |
|
| 398 | + echo ' |
|
| 388 | 399 | <tr class="windowbg"> |
| 389 | 400 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
| 390 | 401 | <td class="recentposter">', $post['poster']['link'], '</td> |
| 391 | 402 | <td class="recentboard">', $post['board']['link'], '</td> |
| 392 | 403 | <td class="recenttime">', $post['time'], '</td> |
| 393 | 404 | </tr>'; |
| 405 | + } |
|
| 394 | 406 | echo ' |
| 395 | 407 | </table>'; |
| 396 | 408 | } |
@@ -414,11 +426,12 @@ discard block |
||
| 414 | 426 | </div>'; |
| 415 | 427 | |
| 416 | 428 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P |
| 417 | - if (!empty($context['calendar_holidays'])) |
|
| 418 | - echo ' |
|
| 429 | + if (!empty($context['calendar_holidays'])) { |
|
| 430 | + echo ' |
|
| 419 | 431 | <p class="inline holiday"> |
| 420 | 432 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), ' |
| 421 | 433 | </p>'; |
| 434 | + } |
|
| 422 | 435 | |
| 423 | 436 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
| 424 | 437 | if (!empty($context['calendar_birthdays'])) |
@@ -428,9 +441,10 @@ discard block |
||
| 428 | 441 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
| 429 | 442 | |
| 430 | 443 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
| 431 | - foreach ($context['calendar_birthdays'] as $member) |
|
| 432 | - echo ' |
|
| 444 | + foreach ($context['calendar_birthdays'] as $member) { |
|
| 445 | + echo ' |
|
| 433 | 446 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
| 447 | + } |
|
| 434 | 448 | |
| 435 | 449 | echo ' |
| 436 | 450 | </p>'; |
@@ -445,9 +459,10 @@ discard block |
||
| 445 | 459 | |
| 446 | 460 | // Each event in calendar_events should have: |
| 447 | 461 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
| 448 | - foreach ($context['calendar_events'] as $event) |
|
| 449 | - echo ' |
|
| 462 | + foreach ($context['calendar_events'] as $event) { |
|
| 463 | + echo ' |
|
| 450 | 464 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
| 465 | + } |
|
| 451 | 466 | echo ' |
| 452 | 467 | </p>'; |
| 453 | 468 | } |
@@ -493,17 +508,21 @@ discard block |
||
| 493 | 508 | // Handle hidden users and buddies. |
| 494 | 509 | $bracketList = array(); |
| 495 | 510 | |
| 496 | - if ($context['show_buddies']) |
|
| 497 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 511 | + if ($context['show_buddies']) { |
|
| 512 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 513 | + } |
|
| 498 | 514 | |
| 499 | - if (!empty($context['num_spiders'])) |
|
| 500 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 515 | + if (!empty($context['num_spiders'])) { |
|
| 516 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 517 | + } |
|
| 501 | 518 | |
| 502 | - if (!empty($context['num_users_hidden'])) |
|
| 503 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 519 | + if (!empty($context['num_users_hidden'])) { |
|
| 520 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 521 | + } |
|
| 504 | 522 | |
| 505 | - if (!empty($bracketList)) |
|
| 506 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 523 | + if (!empty($bracketList)) { |
|
| 524 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 525 | + } |
|
| 507 | 526 | |
| 508 | 527 | echo $context['show_who'] ? '</a>' : '', ' |
| 509 | 528 | |
@@ -517,9 +536,10 @@ discard block |
||
| 517 | 536 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
| 518 | 537 | |
| 519 | 538 | // Showing membergroups? |
| 520 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
| 521 | - echo ' |
|
| 539 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
| 540 | + echo ' |
|
| 522 | 541 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
| 542 | + } |
|
| 523 | 543 | } |
| 524 | 544 | |
| 525 | 545 | echo ' |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
| 245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 246 | 247 | { |
| 247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
| 248 | - if (!empty($row['private'])) |
|
| 249 | - $row['subject'] = $txt['personal_message']; |
|
| 249 | + if (!empty($row['private'])) { |
|
| 250 | + $row['subject'] = $txt['personal_message']; |
|
| 251 | + } |
|
| 250 | 252 | |
| 251 | 253 | $mails[] = $row; |
| 252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
| 300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
| 301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
| 302 | 304 | } |
| 303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
| 304 | - $emails[$index] = $index; |
|
| 305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
| 306 | + $emails[$index] = $index; |
|
| 307 | + } |
|
| 305 | 308 | |
| 306 | 309 | $config_vars = array( |
| 307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
| 322 | 325 | |
| 323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
| 324 | 327 | |
| 325 | - if ($return_config) |
|
| 326 | - return $config_vars; |
|
| 328 | + if ($return_config) { |
|
| 329 | + return $config_vars; |
|
| 330 | + } |
|
| 327 | 331 | |
| 328 | 332 | // Saving? |
| 329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
| 398 | 402 | ); |
| 399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
| 400 | 404 | $smcFunc['db_free_result']($request); |
| 405 | + } else { |
|
| 406 | + $_GET['te'] = (int) $_GET['te']; |
|
| 401 | 407 | } |
| 402 | - else |
|
| 403 | - $_GET['te'] = (int) $_GET['te']; |
|
| 404 | 408 | |
| 405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
| 406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
| 424 | 428 | |
| 425 | 429 | // Try get more time... |
| 426 | 430 | @set_time_limit(600); |
| 427 | - if (function_exists('apache_reset_timeout')) |
|
| 428 | - @apache_reset_timeout(); |
|
| 431 | + if (function_exists('apache_reset_timeout')) { |
|
| 432 | + @apache_reset_timeout(); |
|
| 433 | + } |
|
| 429 | 434 | |
| 430 | 435 | // Have we already used our maximum time? |
| 431 | - if ((time() - $time_start) < 5) |
|
| 432 | - return; |
|
| 436 | + if ((time() - $time_start) < 5) { |
|
| 437 | + return; |
|
| 438 | + } |
|
| 433 | 439 | |
| 434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
| 459 | 465 | { |
| 460 | 466 | global $txt; |
| 461 | 467 | |
| 462 | - if ($time_diff < 0) |
|
| 463 | - $time_diff = 0; |
|
| 468 | + if ($time_diff < 0) { |
|
| 469 | + $time_diff = 0; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | // Just do a bit of an if fest... |
| 466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
| 481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
| 482 | 489 | } |
| 483 | 490 | // Otherwise must be second |
| 484 | - else |
|
| 485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 486 | -} |
|
| 491 | + else { |
|
| 492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 493 | + } |
|
| 494 | + } |
|
| 487 | 495 | |
| 488 | 496 | ?> |
| 489 | 497 | \ No newline at end of file |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
| 93 | 93 | |
| 94 | - $pg_tables = array('pg_catalog','information_schema'); |
|
| 94 | + $pg_tables = array('pg_catalog', 'information_schema'); |
|
| 95 | 95 | |
| 96 | 96 | $request = $smcFunc['db_query']('', ' |
| 97 | 97 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | global $db_connection; |
| 291 | 291 | static $ver; |
| 292 | 292 | |
| 293 | - if(!empty($ver)) |
|
| 293 | + if (!empty($ver)) |
|
| 294 | 294 | return $ver; |
| 295 | 295 | |
| 296 | 296 | $ver = pg_version($db_connection)['server']; |
@@ -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 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
| 29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
| 30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | 'db_get_version' => 'smf_db_get_version', |
| 33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
| 34 | 35 | ); |
| 35 | -} |
|
| 36 | + } |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Backup $table to $backup_table. |
@@ -48,13 +50,14 @@ discard block |
||
| 48 | 50 | |
| 49 | 51 | // Do we need to drop it first? |
| 50 | 52 | $tables = smf_db_list_tables(false, $backup_table); |
| 51 | - if (!empty($tables)) |
|
| 52 | - $smcFunc['db_query']('', ' |
|
| 53 | + if (!empty($tables)) { |
|
| 54 | + $smcFunc['db_query']('', ' |
|
| 53 | 55 | DROP TABLE {raw:backup_table}', |
| 54 | 56 | array( |
| 55 | 57 | 'backup_table' => $backup_table, |
| 56 | 58 | ) |
| 57 | 59 | ); |
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | /** |
| 60 | 63 | * @todo Should we create backups of sequences as well? |
@@ -117,8 +120,9 @@ discard block |
||
| 117 | 120 | ) |
| 118 | 121 | ); |
| 119 | 122 | |
| 120 | - if (!$request) |
|
| 121 | - return -1; |
|
| 123 | + if (!$request) { |
|
| 124 | + return -1; |
|
| 125 | + } |
|
| 122 | 126 | |
| 123 | 127 | $request = $smcFunc['db_query']('', ' |
| 124 | 128 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -136,11 +140,12 @@ discard block |
||
| 136 | 140 | $row = $smcFunc['db_fetch_assoc']($request); |
| 137 | 141 | $smcFunc['db_free_result']($request); |
| 138 | 142 | |
| 139 | - if (isset($row['size'])) |
|
| 140 | - return ($old_size - $row['size']) / 1024; |
|
| 141 | - else |
|
| 142 | - return 0; |
|
| 143 | -} |
|
| 143 | + if (isset($row['size'])) { |
|
| 144 | + return ($old_size - $row['size']) / 1024; |
|
| 145 | + } else { |
|
| 146 | + return 0; |
|
| 147 | + } |
|
| 148 | + } |
|
| 144 | 149 | |
| 145 | 150 | /** |
| 146 | 151 | * This function lists all tables in the database. |
@@ -167,8 +172,9 @@ discard block |
||
| 167 | 172 | ); |
| 168 | 173 | |
| 169 | 174 | $tables = array(); |
| 170 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 171 | - $tables[] = $row[0]; |
|
| 175 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 176 | + $tables[] = $row[0]; |
|
| 177 | + } |
|
| 172 | 178 | $smcFunc['db_free_result']($request); |
| 173 | 179 | |
| 174 | 180 | return $tables; |
@@ -209,12 +215,14 @@ discard block |
||
| 209 | 215 | ); |
| 210 | 216 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 211 | 217 | { |
| 212 | - if ($row['data_type'] == 'character varying') |
|
| 213 | - $row['data_type'] = 'varchar'; |
|
| 214 | - elseif ($row['data_type'] == 'character') |
|
| 215 | - $row['data_type'] = 'char'; |
|
| 216 | - if ($row['character_maximum_length']) |
|
| 217 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
| 218 | + if ($row['data_type'] == 'character varying') { |
|
| 219 | + $row['data_type'] = 'varchar'; |
|
| 220 | + } elseif ($row['data_type'] == 'character') { |
|
| 221 | + $row['data_type'] = 'char'; |
|
| 222 | + } |
|
| 223 | + if ($row['character_maximum_length']) { |
|
| 224 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
| 225 | + } |
|
| 218 | 226 | |
| 219 | 227 | // Make the CREATE for this column. |
| 220 | 228 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -265,13 +273,14 @@ discard block |
||
| 265 | 273 | { |
| 266 | 274 | if ($row['is_primary']) |
| 267 | 275 | { |
| 268 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
| 269 | - continue; |
|
| 276 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
| 277 | + continue; |
|
| 278 | + } |
|
| 270 | 279 | |
| 271 | 280 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
| 281 | + } else { |
|
| 282 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
| 272 | 283 | } |
| 273 | - else |
|
| 274 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
| 275 | 284 | } |
| 276 | 285 | $smcFunc['db_free_result']($result); |
| 277 | 286 | |
@@ -290,8 +299,9 @@ discard block |
||
| 290 | 299 | global $db_connection; |
| 291 | 300 | static $ver; |
| 292 | 301 | |
| 293 | - if(!empty($ver)) |
|
| 294 | - return $ver; |
|
| 302 | + if(!empty($ver)) { |
|
| 303 | + return $ver; |
|
| 304 | + } |
|
| 295 | 305 | |
| 296 | 306 | $ver = pg_version($db_connection)['server']; |
| 297 | 307 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | 53 | // Start displaying errors without fixing them. |
| 53 | - if (isset($_GET['fixErrors'])) |
|
| 54 | - checkSession('get'); |
|
| 54 | + if (isset($_GET['fixErrors'])) { |
|
| 55 | + checkSession('get'); |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // Will want this. |
| 57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
| 69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
| 70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
| 71 | 73 | |
| 72 | - if (empty($context['repair_errors'])) |
|
| 73 | - $context['repair_errors'][] = '???'; |
|
| 74 | + if (empty($context['repair_errors'])) { |
|
| 75 | + $context['repair_errors'][] = '???'; |
|
| 76 | + } |
|
| 74 | 77 | } |
| 75 | - } |
|
| 76 | - else |
|
| 78 | + } else |
|
| 77 | 79 | { |
| 78 | 80 | $context['error_search'] = false; |
| 79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
| 120 | 122 | |
| 121 | 123 | // More time, I need more time! |
| 122 | 124 | @set_time_limit(600); |
| 123 | - if (function_exists('apache_reset_timeout')) |
|
| 124 | - @apache_reset_timeout(); |
|
| 125 | + if (function_exists('apache_reset_timeout')) { |
|
| 126 | + @apache_reset_timeout(); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | // Errr, wait. How much time has this taken already? |
| 127 | - if (!$force && (time() - $time_start) < 3) |
|
| 128 | - return; |
|
| 130 | + if (!$force && (time() - $time_start) < 3) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | // Restore the query cache if interested. |
| 131 | - if (!empty($db_temp_cache)) |
|
| 132 | - $db_cache = $db_temp_cache; |
|
| 135 | + if (!empty($db_temp_cache)) { |
|
| 136 | + $db_cache = $db_temp_cache; |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
| 138 | 143 | $context['sub_template'] = 'not_done'; |
| 139 | 144 | |
| 140 | 145 | // Change these two if more steps are added! |
| 141 | - if (empty($max_substep)) |
|
| 142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 143 | - else |
|
| 144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 146 | + if (empty($max_substep)) { |
|
| 147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 148 | + } else { |
|
| 149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | // Never more than 100%! |
| 147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
| 612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
| 613 | 619 | |
| 614 | 620 | // Not really a problem? |
| 615 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 616 | - return false; |
|
| 621 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 622 | + return false; |
|
| 623 | + } |
|
| 617 | 624 | |
| 618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
| 619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
| 637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
| 638 | 645 | { |
| 639 | 646 | // A pretend error? |
| 640 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 641 | - return false; |
|
| 647 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 642 | 650 | |
| 643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
| 644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
| 646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
| 648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
| 652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 653 | + } |
|
| 654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
| 655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 656 | + } |
|
| 657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
| 658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 659 | + } |
|
| 649 | 660 | |
| 650 | 661 | return true; |
| 651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
| 675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 676 | 687 | |
| 677 | 688 | // Not really a problem? |
| 678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 679 | - return false; |
|
| 689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 690 | + return false; |
|
| 691 | + } |
|
| 680 | 692 | |
| 681 | 693 | $smcFunc['db_query']('', ' |
| 682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
| 695 | 707 | global $txt, $context; |
| 696 | 708 | |
| 697 | 709 | // Just joking? |
| 698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 699 | - return false; |
|
| 710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 700 | 713 | |
| 701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
| 702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
| 715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 716 | + } |
|
| 703 | 717 | |
| 704 | 718 | return true; |
| 705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
| 1290 | 1304 | $inserts = array(); |
| 1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1292 | 1306 | { |
| 1293 | - foreach (text2words($row['subject']) as $word) |
|
| 1294 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1307 | + foreach (text2words($row['subject']) as $word) { |
|
| 1308 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1309 | + } |
|
| 1295 | 1310 | if (count($inserts) > 500) |
| 1296 | 1311 | { |
| 1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
| 1305 | 1320 | |
| 1306 | 1321 | } |
| 1307 | 1322 | |
| 1308 | - if (!empty($inserts)) |
|
| 1309 | - $smcFunc['db_insert']('ignore', |
|
| 1323 | + if (!empty($inserts)) { |
|
| 1324 | + $smcFunc['db_insert']('ignore', |
|
| 1310 | 1325 | '{db_prefix}log_search_subjects', |
| 1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
| 1312 | 1327 | $inserts, |
| 1313 | 1328 | array('word', 'id_topic') |
| 1314 | 1329 | ); |
| 1330 | + } |
|
| 1315 | 1331 | |
| 1316 | 1332 | }, |
| 1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
| 1581 | 1597 | $current_step++; |
| 1582 | 1598 | |
| 1583 | 1599 | // Already done this? |
| 1584 | - if ($_GET['step'] > $current_step) |
|
| 1585 | - continue; |
|
| 1600 | + if ($_GET['step'] > $current_step) { |
|
| 1601 | + continue; |
|
| 1602 | + } |
|
| 1586 | 1603 | |
| 1587 | 1604 | // If we're fixing it but it ain't broke why try? |
| 1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
| 1611 | 1628 | while (!$done) |
| 1612 | 1629 | { |
| 1613 | 1630 | // Make sure there's at least one ID to test. |
| 1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
| 1615 | - break; |
|
| 1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
| 1632 | + break; |
|
| 1633 | + } |
|
| 1616 | 1634 | |
| 1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
| 1618 | - if (!$do_fix) |
|
| 1619 | - $test_query = 'check_query'; |
|
| 1620 | - else |
|
| 1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1636 | + if (!$do_fix) { |
|
| 1637 | + $test_query = 'check_query'; |
|
| 1638 | + } else { |
|
| 1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1640 | + } |
|
| 1622 | 1641 | |
| 1623 | 1642 | // Do the test... |
| 1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
| 1628 | 1647 | ); |
| 1629 | 1648 | |
| 1630 | 1649 | // Does it need a fix? |
| 1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
| 1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1633 | - else |
|
| 1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
| 1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1652 | + } else { |
|
| 1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1654 | + } |
|
| 1635 | 1655 | |
| 1636 | 1656 | $total_queries++; |
| 1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
| 1643 | 1663 | // Assume need to fix. |
| 1644 | 1664 | $found_errors = true; |
| 1645 | 1665 | |
| 1646 | - if (isset($test['message'])) |
|
| 1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1666 | + if (isset($test['message'])) { |
|
| 1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1668 | + } |
|
| 1648 | 1669 | |
| 1649 | 1670 | // One per row! |
| 1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
| 1654 | 1675 | $variables = $test['messages']; |
| 1655 | 1676 | foreach ($variables as $k => $v) |
| 1656 | 1677 | { |
| 1657 | - if ($k == 0 && isset($txt[$v])) |
|
| 1658 | - $variables[$k] = $txt[$v]; |
|
| 1659 | - elseif ($k > 0 && isset($row[$v])) |
|
| 1660 | - $variables[$k] = $row[$v]; |
|
| 1678 | + if ($k == 0 && isset($txt[$v])) { |
|
| 1679 | + $variables[$k] = $txt[$v]; |
|
| 1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
| 1681 | + $variables[$k] = $row[$v]; |
|
| 1682 | + } |
|
| 1661 | 1683 | } |
| 1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
| 1668 | 1690 | { |
| 1669 | 1691 | // Find out if there are actually errors. |
| 1670 | 1692 | $found_errors = false; |
| 1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1672 | - $found_errors |= $test['message_function']($row); |
|
| 1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1694 | + $found_errors |= $test['message_function']($row); |
|
| 1695 | + } |
|
| 1673 | 1696 | } |
| 1674 | 1697 | |
| 1675 | 1698 | // Actually have something to fix? |
| 1676 | - if ($found_errors) |
|
| 1677 | - $to_fix[] = $error_type; |
|
| 1699 | + if ($found_errors) { |
|
| 1700 | + $to_fix[] = $error_type; |
|
| 1701 | + } |
|
| 1678 | 1702 | } |
| 1679 | 1703 | |
| 1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
| 1684 | 1708 | if (isset($test['fix_collect'])) |
| 1685 | 1709 | { |
| 1686 | 1710 | $ids = array(); |
| 1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1713 | + } |
|
| 1689 | 1714 | if (!empty($ids)) |
| 1690 | 1715 | { |
| 1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
| 1694 | 1719 | } |
| 1695 | 1720 | |
| 1696 | 1721 | // Simply executing a fix it query? |
| 1697 | - elseif (isset($test['fix_it_query'])) |
|
| 1698 | - $smcFunc['db_query']('', |
|
| 1722 | + elseif (isset($test['fix_it_query'])) { |
|
| 1723 | + $smcFunc['db_query']('', |
|
| 1699 | 1724 | $test['fix_it_query'], |
| 1700 | 1725 | array( |
| 1701 | 1726 | ) |
| 1702 | 1727 | ); |
| 1728 | + } |
|
| 1703 | 1729 | |
| 1704 | 1730 | // Do we have some processing to do? |
| 1705 | 1731 | elseif (isset($test['fix_processing'])) |
| 1706 | 1732 | { |
| 1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1708 | - $test['fix_processing']($row); |
|
| 1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1734 | + $test['fix_processing']($row); |
|
| 1735 | + } |
|
| 1709 | 1736 | } |
| 1710 | 1737 | |
| 1711 | 1738 | // What about the full set of processing? |
| 1712 | - elseif (isset($test['fix_full_processing'])) |
|
| 1713 | - $test['fix_full_processing']($request); |
|
| 1739 | + elseif (isset($test['fix_full_processing'])) { |
|
| 1740 | + $test['fix_full_processing']($request); |
|
| 1741 | + } |
|
| 1714 | 1742 | |
| 1715 | 1743 | // Do we have other things we need to fix as a result? |
| 1716 | 1744 | if (!empty($test['force_fix'])) |
| 1717 | 1745 | { |
| 1718 | - foreach ($test['force_fix'] as $item) |
|
| 1719 | - if (!in_array($item, $to_fix)) |
|
| 1746 | + foreach ($test['force_fix'] as $item) { |
|
| 1747 | + if (!in_array($item, $to_fix)) |
|
| 1720 | 1748 | $to_fix[] = $item; |
| 1749 | + } |
|
| 1721 | 1750 | } |
| 1722 | 1751 | } |
| 1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
| 1735 | 1764 | if ($_GET['substep'] <= $step_max) |
| 1736 | 1765 | { |
| 1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1767 | + } else { |
|
| 1768 | + $done = true; |
|
| 1738 | 1769 | } |
| 1739 | - else |
|
| 1740 | - $done = true; |
|
| 1770 | + } else { |
|
| 1771 | + $done = true; |
|
| 1741 | 1772 | } |
| 1742 | - else |
|
| 1743 | - $done = true; |
|
| 1744 | 1773 | |
| 1745 | 1774 | // Don't allow more than 1000 queries at a time. |
| 1746 | - if ($total_queries >= 1000) |
|
| 1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1775 | + if ($total_queries >= 1000) { |
|
| 1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1777 | + } |
|
| 1748 | 1778 | } |
| 1749 | 1779 | |
| 1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
| 1757 | 1787 | if ($do_fix) |
| 1758 | 1788 | { |
| 1759 | 1789 | $key = array_search($error_type, $to_fix); |
| 1760 | - if ($key !== false && isset($to_fix[$key])) |
|
| 1761 | - unset($to_fix[$key]); |
|
| 1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
| 1791 | + unset($to_fix[$key]); |
|
| 1792 | + } |
|
| 1762 | 1793 | } |
| 1763 | 1794 | |
| 1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
| 1781 | 1812 | static $createOnce = false; |
| 1782 | 1813 | |
| 1783 | 1814 | // Have we already created it? |
| 1784 | - if ($createOnce) |
|
| 1785 | - return; |
|
| 1786 | - else |
|
| 1787 | - $createOnce = true; |
|
| 1815 | + if ($createOnce) { |
|
| 1816 | + return; |
|
| 1817 | + } else { |
|
| 1818 | + $createOnce = true; |
|
| 1819 | + } |
|
| 1788 | 1820 | |
| 1789 | 1821 | // Back to the forum's default language. |
| 1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
| 1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
| 1800 | 1832 | ) |
| 1801 | 1833 | ); |
| 1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1836 | + } |
|
| 1804 | 1837 | $smcFunc['db_free_result']($result); |
| 1805 | 1838 | |
| 1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
| 1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
| 1833 | 1866 | ) |
| 1834 | 1867 | ); |
| 1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1870 | + } |
|
| 1837 | 1871 | $smcFunc['db_free_result']($result); |
| 1838 | 1872 | |
| 1839 | 1873 | if (empty($salvageBoardID)) |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) |
| 233 | 233 | WHERE t.id_topic IS NULL |
| 234 | 234 | GROUP BY m.id_topic, m.id_board', |
| 235 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
| 235 | + 'fix_processing' => function($row) use ($smcFunc) |
|
| 236 | 236 | { |
| 237 | 237 | global $salvageBoardID; |
| 238 | 238 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | // Remove all topics that have zero messages in the messages table. |
| 319 | 319 | 'fix_collect' => array( |
| 320 | 320 | 'index' => 'id_topic', |
| 321 | - 'process' => function ($topics) use ($smcFunc) |
|
| 321 | + 'process' => function($topics) use ($smcFunc) |
|
| 322 | 322 | { |
| 323 | 323 | $smcFunc['db_query']('', ' |
| 324 | 324 | DELETE FROM {db_prefix}topics |
@@ -356,21 +356,21 @@ discard block |
||
| 356 | 356 | AND p.id_poll IS NULL |
| 357 | 357 | GROUP BY o.id_poll, t.id_topic, t.id_board, t.id_member_started, m.member_name |
| 358 | 358 | ', |
| 359 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
| 359 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
| 360 | 360 | { |
| 361 | 361 | global $salvageBoardID; |
| 362 | 362 | |
| 363 | 363 | $row['poster_name'] = !empty($row['poster_name']) ? $row['poster_name'] : $txt['guest']; |
| 364 | 364 | $row['id_poster'] = !empty($row['id_poster']) ? $row['id_poster'] : 0; |
| 365 | 365 | |
| 366 | - if(empty($row['id_board'])) |
|
| 366 | + if (empty($row['id_board'])) |
|
| 367 | 367 | { |
| 368 | 368 | // Only if we don't have a reasonable idea of where to put it. |
| 369 | 369 | createSalvageArea(); |
| 370 | - $row['id_board'] = (int)$salvageBoardID; |
|
| 370 | + $row['id_board'] = (int) $salvageBoardID; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if(empty($row['id_topic'])) { |
|
| 373 | + if (empty($row['id_topic'])) { |
|
| 374 | 374 | $newMessageID = $smcFunc['db_insert']('', |
| 375 | 375 | '{db_prefix}messages', |
| 376 | 376 | array( |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll) |
| 493 | 493 | WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 494 | 494 | AND t.id_poll IS NULL', |
| 495 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
| 495 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
| 496 | 496 | { |
| 497 | 497 | global $salvageBoardID; |
| 498 | 498 | |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 606 | 606 | GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved |
| 607 | 607 | ORDER BY t.id_topic', |
| 608 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
| 608 | + 'fix_processing' => function($row) use ($smcFunc) |
|
| 609 | 609 | { |
| 610 | 610 | $row['firstmsg_approved'] = (int) $row['firstmsg_approved']; |
| 611 | 611 | $row['myid_first_msg'] = (int) $row['myid_first_msg']; |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | ) |
| 635 | 635 | ); |
| 636 | 636 | }, |
| 637 | - 'message_function' => function ($row) use ($txt, &$context) |
|
| 637 | + 'message_function' => function($row) use ($txt, &$context) |
|
| 638 | 638 | { |
| 639 | 639 | // A pretend error? |
| 640 | 640 | if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 669 | 669 | GROUP BY t.id_topic, t.num_replies, mf.approved |
| 670 | 670 | ORDER BY t.id_topic', |
| 671 | - 'fix_processing' => function ($row) |
|
| 671 | + 'fix_processing' => function($row) |
|
| 672 | 672 | { |
| 673 | 673 | |
| 674 | 674 | global $smcFunc; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | ); |
| 690 | 690 | |
| 691 | 691 | }, |
| 692 | - 'message_function' => function ($row) |
|
| 692 | + 'message_function' => function($row) |
|
| 693 | 693 | { |
| 694 | 694 | |
| 695 | 695 | global $txt, $context; |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | GROUP BY t.id_topic, t.unapproved_posts |
| 723 | 723 | HAVING unapproved_posts != COUNT(mu.id_msg) |
| 724 | 724 | ORDER BY t.id_topic', |
| 725 | - 'fix_processing' => function ($row) |
|
| 725 | + 'fix_processing' => function($row) |
|
| 726 | 726 | { |
| 727 | 727 | |
| 728 | 728 | global $smcFunc; |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | WHERE b.id_board IS NULL |
| 765 | 765 | AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 766 | 766 | GROUP BY t.id_board', |
| 767 | - 'fix_processing' => function ($row) |
|
| 767 | + 'fix_processing' => function($row) |
|
| 768 | 768 | { |
| 769 | 769 | |
| 770 | 770 | global $smcFunc, $salvageCatID, $txt; |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | ORDER BY b.id_cat, b.id_board', |
| 814 | 814 | 'fix_collect' => array( |
| 815 | 815 | 'index' => 'id_cat', |
| 816 | - 'process' => function ($cats) |
|
| 816 | + 'process' => function($cats) |
|
| 817 | 817 | { |
| 818 | 818 | global $smcFunc, $salvageCatID; |
| 819 | 819 | createSalvageArea(); |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | // Last step-make sure all non-guest posters still exist. |
| 850 | 850 | 'fix_collect' => array( |
| 851 | 851 | 'index' => 'id_msg', |
| 852 | - 'process' => function ($msgs) |
|
| 852 | + 'process' => function($msgs) |
|
| 853 | 853 | { |
| 854 | 854 | |
| 855 | 855 | global $smcFunc; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | ORDER BY b.id_parent, b.id_board', |
| 879 | 879 | 'fix_collect' => array( |
| 880 | 880 | 'index' => 'id_parent', |
| 881 | - 'process' => function ($parents) |
|
| 881 | + 'process' => function($parents) |
|
| 882 | 882 | { |
| 883 | 883 | global $smcFunc, $salvageBoardID, $salvageCatID; |
| 884 | 884 | createSalvageArea(); |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | AND p.id_poll IS NULL', |
| 913 | 913 | 'fix_collect' => array( |
| 914 | 914 | 'index' => 'id_poll', |
| 915 | - 'process' => function ($polls) |
|
| 915 | + 'process' => function($polls) |
|
| 916 | 916 | { |
| 917 | 917 | |
| 918 | 918 | global $smcFunc; |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | ORDER BY cal.id_topic', |
| 947 | 947 | 'fix_collect' => array( |
| 948 | 948 | 'index' => 'id_topic', |
| 949 | - 'process' => function ($events) |
|
| 949 | + 'process' => function($events) |
|
| 950 | 950 | { |
| 951 | 951 | |
| 952 | 952 | global $smcFunc; |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
| 979 | 979 | 'fix_collect' => array( |
| 980 | 980 | 'index' => 'id_topic', |
| 981 | - 'process' => function ($topics) |
|
| 981 | + 'process' => function($topics) |
|
| 982 | 982 | { |
| 983 | 983 | |
| 984 | 984 | global $smcFunc; |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | GROUP BY lt.id_member', |
| 1011 | 1011 | 'fix_collect' => array( |
| 1012 | 1012 | 'index' => 'id_member', |
| 1013 | - 'process' => function ($members) |
|
| 1013 | + 'process' => function($members) |
|
| 1014 | 1014 | { |
| 1015 | 1015 | |
| 1016 | 1016 | global $smcFunc; |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | GROUP BY lb.id_board', |
| 1043 | 1043 | 'fix_collect' => array( |
| 1044 | 1044 | 'index' => 'id_board', |
| 1045 | - 'process' => function ($boards) |
|
| 1045 | + 'process' => function($boards) |
|
| 1046 | 1046 | { |
| 1047 | 1047 | |
| 1048 | 1048 | global $smcFunc; |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | GROUP BY lb.id_member', |
| 1075 | 1075 | 'fix_collect' => array( |
| 1076 | 1076 | 'index' => 'id_member', |
| 1077 | - 'process' => function ($members) use ($smcFunc) |
|
| 1077 | + 'process' => function($members) use ($smcFunc) |
|
| 1078 | 1078 | { |
| 1079 | 1079 | $smcFunc['db_query']('', ' |
| 1080 | 1080 | DELETE FROM {db_prefix}log_boards |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | GROUP BY lmr.id_board', |
| 1104 | 1104 | 'fix_collect' => array( |
| 1105 | 1105 | 'index' => 'id_board', |
| 1106 | - 'process' => function ($boards) use ($smcFunc) |
|
| 1106 | + 'process' => function($boards) use ($smcFunc) |
|
| 1107 | 1107 | { |
| 1108 | 1108 | $smcFunc['db_query']('', ' |
| 1109 | 1109 | DELETE FROM {db_prefix}log_mark_read |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | GROUP BY lmr.id_member', |
| 1133 | 1133 | 'fix_collect' => array( |
| 1134 | 1134 | 'index' => 'id_member', |
| 1135 | - 'process' => function ($members) use ($smcFunc) |
|
| 1135 | + 'process' => function($members) use ($smcFunc) |
|
| 1136 | 1136 | { |
| 1137 | 1137 | $smcFunc['db_query']('', ' |
| 1138 | 1138 | DELETE FROM {db_prefix}log_mark_read |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | GROUP BY pmr.id_pm', |
| 1162 | 1162 | 'fix_collect' => array( |
| 1163 | 1163 | 'index' => 'id_pm', |
| 1164 | - 'process' => function ($pms) use ($smcFunc) |
|
| 1164 | + 'process' => function($pms) use ($smcFunc) |
|
| 1165 | 1165 | { |
| 1166 | 1166 | $smcFunc['db_query']('', ' |
| 1167 | 1167 | DELETE FROM {db_prefix}pm_recipients |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | GROUP BY pmr.id_member', |
| 1192 | 1192 | 'fix_collect' => array( |
| 1193 | 1193 | 'index' => 'id_member', |
| 1194 | - 'process' => function ($members) |
|
| 1194 | + 'process' => function($members) |
|
| 1195 | 1195 | { |
| 1196 | 1196 | |
| 1197 | 1197 | global $smcFunc; |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | AND mem.id_member IS NULL', |
| 1224 | 1224 | 'fix_collect' => array( |
| 1225 | 1225 | 'index' => 'id_pm', |
| 1226 | - 'process' => function ($guestMessages) |
|
| 1226 | + 'process' => function($guestMessages) |
|
| 1227 | 1227 | { |
| 1228 | 1228 | |
| 1229 | 1229 | global $smcFunc; |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | GROUP BY ln.id_member', |
| 1256 | 1256 | 'fix_collect' => array( |
| 1257 | 1257 | 'index' => 'id_member', |
| 1258 | - 'process' => function ($members) use ($smcFunc) |
|
| 1258 | + 'process' => function($members) use ($smcFunc) |
|
| 1259 | 1259 | { |
| 1260 | 1260 | $smcFunc['db_query']('', ' |
| 1261 | 1261 | DELETE FROM {db_prefix}log_notify |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic) |
| 1283 | 1283 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 1284 | 1284 | AND lss.id_topic IS NULL', |
| 1285 | - 'fix_full_processing' => function ($result) |
|
| 1285 | + 'fix_full_processing' => function($result) |
|
| 1286 | 1286 | { |
| 1287 | 1287 | |
| 1288 | 1288 | global $smcFunc; |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | ); |
| 1315 | 1315 | |
| 1316 | 1316 | }, |
| 1317 | - 'message_function' => function ($row) |
|
| 1317 | + 'message_function' => function($row) |
|
| 1318 | 1318 | { |
| 1319 | 1319 | |
| 1320 | 1320 | global $txt, $context; |
@@ -1344,7 +1344,7 @@ discard block |
||
| 1344 | 1344 | AND t.id_topic IS NULL', |
| 1345 | 1345 | 'fix_collect' => array( |
| 1346 | 1346 | 'index' => 'id_topic', |
| 1347 | - 'process' => function ($deleteTopics) |
|
| 1347 | + 'process' => function($deleteTopics) |
|
| 1348 | 1348 | { |
| 1349 | 1349 | |
| 1350 | 1350 | global $smcFunc; |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | AND mem.id_member IS NULL', |
| 1377 | 1377 | 'fix_collect' => array( |
| 1378 | 1378 | 'index' => 'id_member', |
| 1379 | - 'process' => function ($members) |
|
| 1379 | + 'process' => function($members) |
|
| 1380 | 1380 | { |
| 1381 | 1381 | |
| 1382 | 1382 | global $smcFunc; |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | AND p.id_poll IS NULL', |
| 1408 | 1408 | 'fix_collect' => array( |
| 1409 | 1409 | 'index' => 'id_poll', |
| 1410 | - 'process' => function ($polls) |
|
| 1410 | + 'process' => function($polls) |
|
| 1411 | 1411 | { |
| 1412 | 1412 | |
| 1413 | 1413 | global $smcFunc; |
@@ -1438,7 +1438,7 @@ discard block |
||
| 1438 | 1438 | AND lrc.id_report IS NULL', |
| 1439 | 1439 | 'fix_collect' => array( |
| 1440 | 1440 | 'index' => 'id_report', |
| 1441 | - 'process' => function ($reports) |
|
| 1441 | + 'process' => function($reports) |
|
| 1442 | 1442 | { |
| 1443 | 1443 | |
| 1444 | 1444 | global $smcFunc; |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | AND lr.id_report IS NULL', |
| 1470 | 1470 | 'fix_collect' => array( |
| 1471 | 1471 | 'index' => 'id_report', |
| 1472 | - 'process' => function ($reports) |
|
| 1472 | + 'process' => function($reports) |
|
| 1473 | 1473 | { |
| 1474 | 1474 | global $smcFunc; |
| 1475 | 1475 | $smcFunc['db_query']('', ' |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | GROUP BY lgr.id_member', |
| 1500 | 1500 | 'fix_collect' => array( |
| 1501 | 1501 | 'index' => 'id_member', |
| 1502 | - 'process' => function ($members) |
|
| 1502 | + 'process' => function($members) |
|
| 1503 | 1503 | { |
| 1504 | 1504 | global $smcFunc; |
| 1505 | 1505 | $smcFunc['db_query']('', ' |
@@ -1529,7 +1529,7 @@ discard block |
||
| 1529 | 1529 | GROUP BY lgr.id_group', |
| 1530 | 1530 | 'fix_collect' => array( |
| 1531 | 1531 | 'index' => 'id_group', |
| 1532 | - 'process' => function ($groups) |
|
| 1532 | + 'process' => function($groups) |
|
| 1533 | 1533 | { |
| 1534 | 1534 | global $smcFunc; |
| 1535 | 1535 | $smcFunc['db_query']('', ' |