@@ -164,8 +164,9 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | // Could not find the files you claimed to have sent |
| 167 | - else |
|
| 168 | - $context['json_data'] = array('result' => false, 'data' => $txt['no_files_uploaded']); |
|
| 167 | + else { |
|
| 168 | + $context['json_data'] = array('result' => false, 'data' => $txt['no_files_uploaded']); |
|
| 169 | + } |
|
| 169 | 170 | } |
| 170 | 171 | |
| 171 | 172 | /** |
@@ -298,7 +299,9 @@ discard block |
||
| 298 | 299 | if (!isset($this->_req->query->attach)) |
| 299 | 300 | { |
| 300 | 301 | if (!isset($this->_req->query->id)) |
| 301 | - $this->action_no_attach(); |
|
| 302 | + { |
|
| 303 | + $this->action_no_attach(); |
|
| 304 | + } |
|
| 302 | 305 | |
| 303 | 306 | if ($this->_req->query->id === 'ila') |
| 304 | 307 | { |
@@ -413,7 +416,9 @@ discard block |
||
| 413 | 416 | |
| 414 | 417 | // If it isn't yet approved, do they have permission to view it? |
| 415 | 418 | if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
| 416 | - isAllowedTo('approve_posts', $id_board); |
|
| 419 | + { |
|
| 420 | + isAllowedTo('approve_posts', $id_board); |
|
| 421 | + } |
|
| 417 | 422 | |
| 418 | 423 | // Update the download counter (unless it's a thumbnail or an avatar). |
| 419 | 424 | if (!empty($id_attach) && empty($is_avatar) || $attachment_type != 3) |
@@ -442,7 +447,9 @@ discard block |
||
| 442 | 447 | { |
| 443 | 448 | $mime_type = ''; |
| 444 | 449 | if (isset($this->_req->query->image)) |
| 445 | - unset($this->_req->query->image); |
|
| 450 | + { |
|
| 451 | + unset($this->_req->query->image); |
|
| 452 | + } |
|
| 446 | 453 | } |
| 447 | 454 | |
| 448 | 455 | $this->_send_headers($filename, $eTag, $mime_type, $use_compression, $disposition, $real_filename, $do_cache); |
@@ -548,7 +555,9 @@ discard block |
||
| 548 | 555 | |
| 549 | 556 | // If it isn't yet approved, do they have permission to view it? |
| 550 | 557 | if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
| 551 | - isAllowedTo('approve_posts'); |
|
| 558 | + { |
|
| 559 | + isAllowedTo('approve_posts'); |
|
| 560 | + } |
|
| 552 | 561 | |
| 553 | 562 | $filename = getAttachmentFilename($real_filename, $id_attach, $id_folder, false, $file_hash); |
| 554 | 563 | } |
@@ -663,7 +672,9 @@ discard block |
||
| 663 | 672 | // Send as UTF-8 if the name requires that |
| 664 | 673 | $altName = ''; |
| 665 | 674 | if (preg_match('~[\x80-\xFF]~', $filename)) |
| 666 | - $altName = "; filename*=UTF-8''" . rawurlencode($filename); |
|
| 675 | + { |
|
| 676 | + $altName = "; filename*=UTF-8''" . rawurlencode($filename); |
|
| 677 | + } |
|
| 667 | 678 | |
| 668 | 679 | header('Content-Disposition: ' . $disposition . '; filename="' . $filename . '"' . $altName); |
| 669 | 680 | |
@@ -88,7 +88,9 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | // If it's not enabled, die. |
| 90 | 90 | if (empty($modSettings['xmlnews_enable'])) |
| 91 | - obExit(false); |
|
| 91 | + { |
|
| 92 | + obExit(false); |
|
| 93 | + } |
|
| 92 | 94 | |
| 93 | 95 | loadLanguage('Stats'); |
| 94 | 96 | $txt['xml_rss_desc'] = replaceBasicActionUrl($txt['xml_rss_desc']); |
@@ -121,11 +123,15 @@ discard block |
||
| 121 | 123 | $boards = array_keys($boards_posts); |
| 122 | 124 | |
| 123 | 125 | if (!empty($boards)) |
| 124 | - $this->_query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
| 126 | + { |
|
| 127 | + $this->_query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
| 128 | + } |
|
| 125 | 129 | |
| 126 | 130 | // Try to limit the number of messages we look through. |
| 127 | 131 | if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
| 128 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $this->_limit * 5); |
|
| 132 | + { |
|
| 133 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $this->_limit * 5); |
|
| 134 | + } |
|
| 129 | 135 | } |
| 130 | 136 | // Maybe they only want to see feeds form some certain boards? |
| 131 | 137 | elseif (!empty($this->_req->query->boards)) |
@@ -138,14 +144,18 @@ discard block |
||
| 138 | 144 | // Either the board specified doesn't exist or you have no access. |
| 139 | 145 | $num_boards = count($boards_data); |
| 140 | 146 | if ($num_boards == 0) |
| 141 | - throw new Elk_Exception('no_board'); |
|
| 147 | + { |
|
| 148 | + throw new Elk_Exception('no_board'); |
|
| 149 | + } |
|
| 142 | 150 | |
| 143 | 151 | $total_posts = 0; |
| 144 | 152 | $boards = array_keys($boards_data); |
| 145 | 153 | foreach ($boards_data as $row) |
| 146 | 154 | { |
| 147 | 155 | if ($num_boards == 1) |
| 148 | - $feed_title = ' - ' . strip_tags($row['name']); |
|
| 156 | + { |
|
| 157 | + $feed_title = ' - ' . strip_tags($row['name']); |
|
| 158 | + } |
|
| 149 | 159 | |
| 150 | 160 | $total_posts += $row['num_posts']; |
| 151 | 161 | } |
@@ -154,7 +164,9 @@ discard block |
||
| 154 | 164 | |
| 155 | 165 | // The more boards, the more we're going to look through... |
| 156 | 166 | if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
| 157 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $this->_limit * 5); |
|
| 167 | + { |
|
| 168 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $this->_limit * 5); |
|
| 169 | + } |
|
| 158 | 170 | } |
| 159 | 171 | // Just a single board |
| 160 | 172 | elseif (!empty($board)) |
@@ -168,7 +180,9 @@ discard block |
||
| 168 | 180 | |
| 169 | 181 | // Try to look through just a few messages, if at all possible. |
| 170 | 182 | if ($boards_data[(int) $board]['num_posts'] > 80 && $boards_data[(int) $board]['num_posts'] > $modSettings['totalMessages'] / 10) |
| 171 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $this->_limit * 5); |
|
| 183 | + { |
|
| 184 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $this->_limit * 5); |
|
| 185 | + } |
|
| 172 | 186 | } |
| 173 | 187 | else |
| 174 | 188 | { |
@@ -180,7 +194,9 @@ discard block |
||
| 180 | 194 | // If format isn't set, or is wrong, rss2 is default |
| 181 | 195 | $xml_format = $this->_req->getQuery('type', 'trim', 'rss2'); |
| 182 | 196 | if (!in_array($xml_format, array('rss', 'rss2', 'atom', 'rdf'))) |
| 183 | - $xml_format = 'rss2'; |
|
| 197 | + { |
|
| 198 | + $xml_format = 'rss2'; |
|
| 199 | + } |
|
| 184 | 200 | |
| 185 | 201 | // List all the different types of data they can pull. |
| 186 | 202 | $subActions = array( |
@@ -201,7 +217,9 @@ discard block |
||
| 201 | 217 | foreach (array('board', 'boards', 'c') as $var) |
| 202 | 218 | { |
| 203 | 219 | if (isset($this->_req->query->{$var})) |
| 204 | - $cachekey[] = $this->_req->query->{$var}; |
|
| 220 | + { |
|
| 221 | + $cachekey[] = $this->_req->query->{$var}; |
|
| 222 | + } |
|
| 205 | 223 | } |
| 206 | 224 | |
| 207 | 225 | $cachekey = md5(serialize($cachekey) . (!empty($this->_query_this_board) ? $this->_query_this_board : '')); |
@@ -210,14 +228,18 @@ discard block |
||
| 210 | 228 | |
| 211 | 229 | // Get the associative array representing the xml. |
| 212 | 230 | if (!$user_info['is_guest'] || $cache->levelHigherThan(2)) |
| 213 | - $xml = $cache->get('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
| 231 | + { |
|
| 232 | + $xml = $cache->get('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
| 233 | + } |
|
| 214 | 234 | |
| 215 | 235 | if (empty($xml)) |
| 216 | 236 | { |
| 217 | 237 | $xml = $this->{$subActions[$subAction][0]}($xml_format); |
| 218 | 238 | |
| 219 | 239 | if ($cache->isEnabled() && (($user_info['is_guest'] && $cache->levelHigherThan(2)) || (!$user_info['is_guest'] && (microtime(true) - $cache_t > 0.2)))) |
| 220 | - $cache->put('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
| 240 | + { |
|
| 241 | + $cache->put('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
| 242 | + } |
|
| 221 | 243 | } |
| 222 | 244 | |
| 223 | 245 | $context['feed_title'] = encode_special(strip_tags(un_htmlspecialchars($context['forum_name']) . (isset($feed_title) ? $feed_title : ''))); |
@@ -230,13 +252,21 @@ discard block |
||
| 230 | 252 | |
| 231 | 253 | // This is an xml file.... |
| 232 | 254 | if (isset($this->_req->query->debug)) |
| 233 | - header('Content-Type: text/xml; charset=UTF-8'); |
|
| 255 | + { |
|
| 256 | + header('Content-Type: text/xml; charset=UTF-8'); |
|
| 257 | + } |
|
| 234 | 258 | elseif ($xml_format === 'rss' || $xml_format === 'rss2') |
| 235 | - header('Content-Type: application/rss+xml; charset=UTF-8'); |
|
| 259 | + { |
|
| 260 | + header('Content-Type: application/rss+xml; charset=UTF-8'); |
|
| 261 | + } |
|
| 236 | 262 | elseif ($xml_format === 'atom') |
| 237 | - header('Content-Type: application/atom+xml; charset=UTF-8'); |
|
| 263 | + { |
|
| 264 | + header('Content-Type: application/atom+xml; charset=UTF-8'); |
|
| 265 | + } |
|
| 238 | 266 | elseif ($xml_format === 'rdf') |
| 239 | - header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=UTF-8'); |
|
| 267 | + { |
|
| 268 | + header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=UTF-8'); |
|
| 269 | + } |
|
| 240 | 270 | |
| 241 | 271 | loadTemplate('Xml'); |
| 242 | 272 | Template_Layers::instance()->removeAll(); |
@@ -280,7 +310,9 @@ discard block |
||
| 280 | 310 | |
| 281 | 311 | // Not allowed, then you get nothing |
| 282 | 312 | if (!allowedTo('view_mlist')) |
| 283 | - return array(); |
|
| 313 | + { |
|
| 314 | + return array(); |
|
| 315 | + } |
|
| 284 | 316 | |
| 285 | 317 | // Find the most recent members. |
| 286 | 318 | require_once(SUBSDIR . '/Members.subs.php'); |
@@ -293,34 +325,41 @@ discard block |
||
| 293 | 325 | { |
| 294 | 326 | // Make the data look rss-ish. |
| 295 | 327 | if ($xml_format === 'rss' || $xml_format === 'rss2') |
| 296 | - $data[] = array( |
|
| 328 | + { |
|
| 329 | + $data[] = array( |
|
| 297 | 330 | 'title' => cdata_parse($member['real_name']), |
| 298 | 331 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'], |
| 299 | 332 | 'comments' => $scripturl . '?action=pm;sa=send;u=' . $member['id_member'], |
| 300 | 333 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $member['date_registered']), |
| 301 | 334 | 'guid' => $scripturl . '?action=profile;u=' . $member['id_member'], |
| 302 | 335 | ); |
| 336 | + } |
|
| 303 | 337 | elseif ($xml_format === 'rdf') |
| 304 | - $data[] = array( |
|
| 338 | + { |
|
| 339 | + $data[] = array( |
|
| 305 | 340 | 'title' => cdata_parse($member['real_name']), |
| 306 | 341 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'], |
| 307 | 342 | ); |
| 343 | + } |
|
| 308 | 344 | elseif ($xml_format === 'atom') |
| 309 | - $data[] = array( |
|
| 345 | + { |
|
| 346 | + $data[] = array( |
|
| 310 | 347 | 'title' => cdata_parse($member['real_name']), |
| 311 | 348 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'], |
| 312 | 349 | 'published' => Util::gmstrftime('%Y-%m-%dT%H:%M:%SZ', $member['date_registered']), |
| 313 | 350 | 'updated' => Util::gmstrftime('%Y-%m-%dT%H:%M:%SZ', $member['last_login']), |
| 314 | 351 | 'id' => $scripturl . '?action=profile;u=' . $member['id_member'], |
| 315 | 352 | ); |
| 353 | + } |
|
| 316 | 354 | // More logical format for the data, but harder to apply. |
| 317 | - else |
|
| 318 | - $data[] = array( |
|
| 355 | + else { |
|
| 356 | + $data[] = array( |
|
| 319 | 357 | 'name' => cdata_parse($member['real_name']), |
| 320 | 358 | 'time' => htmlspecialchars(strip_tags(standardTime($member['date_registered'])), ENT_COMPAT, 'UTF-8'), |
| 321 | 359 | 'id' => $member['id_member'], |
| 322 | 360 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'] |
| 323 | 361 | ); |
| 362 | + } |
|
| 324 | 363 | } |
| 325 | 364 | |
| 326 | 365 | return $data; |
@@ -349,7 +388,9 @@ discard block |
||
| 349 | 388 | { |
| 350 | 389 | // Limit the length of the message, if the option is set. |
| 351 | 390 | if (!empty($modSettings['xmlnews_maxlen']) && Util::strlen(str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
| 352 | - $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
| 391 | + { |
|
| 392 | + $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
| 393 | + } |
|
| 353 | 394 | |
| 354 | 395 | $row['body'] = $bbc_parser->parseMessage($row['body'], $row['smileys_enabled']); |
| 355 | 396 | |
@@ -455,7 +496,9 @@ discard block |
||
| 455 | 496 | { |
| 456 | 497 | // Limit the length of the message, if the option is set. |
| 457 | 498 | if (!empty($modSettings['xmlnews_maxlen']) && Util::strlen(str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
| 458 | - $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
| 499 | + { |
|
| 500 | + $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
| 501 | + } |
|
| 459 | 502 | |
| 460 | 503 | $row['body'] = $bbc_parser->parseMessage($row['body'], $row['smileys_enabled']); |
| 461 | 504 | |
@@ -558,14 +601,18 @@ discard block |
||
| 558 | 601 | |
| 559 | 602 | // You must input a valid user.... |
| 560 | 603 | if (empty($this->_req->query->u) || loadMemberData((int) $this->_req->query->u) === false) |
| 561 | - return array(); |
|
| 604 | + { |
|
| 605 | + return array(); |
|
| 606 | + } |
|
| 562 | 607 | |
| 563 | 608 | // Make sure the id is a number and not "I like trying to hack the database". |
| 564 | 609 | $uid = (int) $this->_req->query->u; |
| 565 | 610 | |
| 566 | 611 | // Load the member's contextual information! |
| 567 | 612 | if (!loadMemberContext($uid) || !allowedTo('profile_view_any')) |
| 568 | - return array(); |
|
| 613 | + { |
|
| 614 | + return array(); |
|
| 615 | + } |
|
| 569 | 616 | |
| 570 | 617 | $profile = &$memberContext[$uid]; |
| 571 | 618 | |
@@ -623,35 +670,51 @@ discard block |
||
| 623 | 670 | |
| 624 | 671 | // Everything below here might not be set, and thus maybe shouldn't be displayed. |
| 625 | 672 | if ($profile['avatar']['name'] != '') |
| 626 | - $data['avatar'] = $profile['avatar']['url']; |
|
| 673 | + { |
|
| 674 | + $data['avatar'] = $profile['avatar']['url']; |
|
| 675 | + } |
|
| 627 | 676 | |
| 628 | 677 | // If they are online, show an empty tag... no reason to put anything inside it. |
| 629 | 678 | if ($profile['online']['is_online']) |
| 630 | - $data['online'] = ''; |
|
| 679 | + { |
|
| 680 | + $data['online'] = ''; |
|
| 681 | + } |
|
| 631 | 682 | |
| 632 | 683 | if ($profile['signature'] != '') |
| 633 | - $data['signature'] = cdata_parse($profile['signature']); |
|
| 684 | + { |
|
| 685 | + $data['signature'] = cdata_parse($profile['signature']); |
|
| 686 | + } |
|
| 634 | 687 | |
| 635 | 688 | if ($profile['title'] != '') |
| 636 | - $data['title'] = cdata_parse($profile['title']); |
|
| 689 | + { |
|
| 690 | + $data['title'] = cdata_parse($profile['title']); |
|
| 691 | + } |
|
| 637 | 692 | |
| 638 | 693 | if ($profile['website']['title'] != '') |
| 639 | - $data['website'] = array( |
|
| 694 | + { |
|
| 695 | + $data['website'] = array( |
|
| 640 | 696 | 'title' => cdata_parse($profile['website']['title']), |
| 641 | 697 | 'link' => $profile['website']['url'] |
| 642 | 698 | ); |
| 699 | + } |
|
| 643 | 700 | |
| 644 | 701 | if ($profile['group'] != '') |
| 645 | - $data['position'] = cdata_parse($profile['group']); |
|
| 702 | + { |
|
| 703 | + $data['position'] = cdata_parse($profile['group']); |
|
| 704 | + } |
|
| 646 | 705 | |
| 647 | 706 | if (!empty($modSettings['karmaMode'])) |
| 648 | - $data['karma'] = array( |
|
| 707 | + { |
|
| 708 | + $data['karma'] = array( |
|
| 649 | 709 | 'good' => $profile['karma']['good'], |
| 650 | 710 | 'bad' => $profile['karma']['bad'] |
| 651 | 711 | ); |
| 712 | + } |
|
| 652 | 713 | |
| 653 | 714 | if (in_array($profile['show_email'], array('yes', 'yes_permission_override'))) |
| 654 | - $data['email'] = $profile['email']; |
|
| 715 | + { |
|
| 716 | + $data['email'] = $profile['email']; |
|
| 717 | + } |
|
| 655 | 718 | |
| 656 | 719 | if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') |
| 657 | 720 | { |
@@ -679,7 +742,9 @@ discard block |
||
| 679 | 742 | global $modSettings, $scripturl; |
| 680 | 743 | |
| 681 | 744 | if (substr($val, 0, strlen($scripturl)) != $scripturl) |
| 682 | - return $val; |
|
| 745 | + { |
|
| 746 | + return $val; |
|
| 747 | + } |
|
| 683 | 748 | |
| 684 | 749 | call_integration_hook('integrate_fix_url', array(&$val)); |
| 685 | 750 | |
@@ -730,7 +795,9 @@ discard block |
||
| 730 | 795 | |
| 731 | 796 | // Are we not doing it? |
| 732 | 797 | if (!empty($cdata_override)) |
| 733 | - return $data; |
|
| 798 | + { |
|
| 799 | + return $data; |
|
| 800 | + } |
|
| 734 | 801 | |
| 735 | 802 | $cdata = '<![CDATA['; |
| 736 | 803 | |
@@ -742,33 +809,46 @@ discard block |
||
| 742 | 809 | ); |
| 743 | 810 | |
| 744 | 811 | if ($ns != '') |
| 745 | - $positions[] = Util::strpos($data, '<', $pos); |
|
| 812 | + { |
|
| 813 | + $positions[] = Util::strpos($data, '<', $pos); |
|
| 814 | + } |
|
| 746 | 815 | |
| 747 | 816 | foreach ($positions as $k => $dummy) |
| 748 | 817 | { |
| 749 | 818 | if ($dummy === false) |
| 750 | - unset($positions[$k]); |
|
| 819 | + { |
|
| 820 | + unset($positions[$k]); |
|
| 821 | + } |
|
| 751 | 822 | } |
| 752 | 823 | |
| 753 | 824 | $old = $pos; |
| 754 | 825 | $pos = empty($positions) ? $n : min($positions); |
| 755 | 826 | |
| 756 | 827 | if ($pos - $old > 0) |
| 757 | - $cdata .= Util::substr($data, $old, $pos - $old); |
|
| 828 | + { |
|
| 829 | + $cdata .= Util::substr($data, $old, $pos - $old); |
|
| 830 | + } |
|
| 758 | 831 | |
| 759 | 832 | if ($pos >= $n) |
| 760 | - break; |
|
| 833 | + { |
|
| 834 | + break; |
|
| 835 | + } |
|
| 761 | 836 | |
| 762 | 837 | if (Util::substr($data, $pos, 1) === '<') |
| 763 | 838 | { |
| 764 | 839 | $pos2 = Util::strpos($data, '>', $pos); |
| 765 | 840 | if ($pos2 === false) |
| 766 | - $pos2 = $n; |
|
| 841 | + { |
|
| 842 | + $pos2 = $n; |
|
| 843 | + } |
|
| 767 | 844 | |
| 768 | 845 | if (Util::substr($data, $pos + 1, 1) === '/') |
| 769 | - $cdata .= ']]></' . $ns . ':' . Util::substr($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
| 770 | - else |
|
| 771 | - $cdata .= ']]><' . $ns . ':' . Util::substr($data, $pos + 1, $pos2 - $pos) . '<![CDATA['; |
|
| 846 | + { |
|
| 847 | + $cdata .= ']]></' . $ns . ':' . Util::substr($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
| 848 | + } |
|
| 849 | + else { |
|
| 850 | + $cdata .= ']]><' . $ns . ':' . Util::substr($data, $pos + 1, $pos2 - $pos) . '<![CDATA['; |
|
| 851 | + } |
|
| 772 | 852 | |
| 773 | 853 | $pos = $pos2 + 1; |
| 774 | 854 | } |
@@ -782,14 +862,20 @@ discard block |
||
| 782 | 862 | $pos2 = Util::strpos($data, ';', $pos); |
| 783 | 863 | |
| 784 | 864 | if ($pos2 === false) |
| 785 | - $pos2 = $n; |
|
| 865 | + { |
|
| 866 | + $pos2 = $n; |
|
| 867 | + } |
|
| 786 | 868 | |
| 787 | 869 | $ent = Util::substr($data, $pos + 1, $pos2 - $pos - 1); |
| 788 | 870 | |
| 789 | 871 | if (Util::substr($data, $pos + 1, 1) === '#') |
| 790 | - $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
| 872 | + { |
|
| 873 | + $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
| 874 | + } |
|
| 791 | 875 | elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
| 792 | - $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
| 876 | + { |
|
| 877 | + $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
| 878 | + } |
|
| 793 | 879 | |
| 794 | 880 | $pos = $pos2 + 1; |
| 795 | 881 | } |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | // Page disabled - redirect them out |
| 57 | 57 | if (empty($modSettings['trackStats'])) |
| 58 | - throw new Elk_Exception('feature_disabled', true); |
|
| 58 | + { |
|
| 59 | + throw new Elk_Exception('feature_disabled', true); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | // Expanding out the history summary |
| 61 | 63 | list($year, $month) = $this->_expandedStats(); |
@@ -73,7 +75,9 @@ discard block |
||
| 73 | 75 | |
| 74 | 76 | // Collapsing stats only needs adjustments of the session variables. |
| 75 | 77 | if (!empty($this->_req->query->collapse)) |
| 76 | - obExit(false); |
|
| 78 | + { |
|
| 79 | + obExit(false); |
|
| 80 | + } |
|
| 77 | 81 | |
| 78 | 82 | $context['sub_template'] = 'stats'; |
| 79 | 83 | getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month)); |
@@ -148,9 +152,11 @@ discard block |
||
| 148 | 152 | ); |
| 149 | 153 | |
| 150 | 154 | if (!empty($modSettings['hitStats'])) |
| 151 | - $context['general_statistics']['left'] += array( |
|
| 155 | + { |
|
| 156 | + $context['general_statistics']['left'] += array( |
|
| 152 | 157 | 'num_hits' => comma_format($averages['hits'], 0) |
| 153 | 158 | ); |
| 159 | + } |
|
| 154 | 160 | |
| 155 | 161 | $context['general_statistics']['right'] = array( |
| 156 | 162 | 'average_members' => comma_format(round($averages['registers'] / $total_days_up, 2)), |
@@ -164,9 +170,11 @@ discard block |
||
| 164 | 170 | ); |
| 165 | 171 | |
| 166 | 172 | if (!empty($modSettings['hitStats'])) |
| 167 | - $context['general_statistics']['right'] += array( |
|
| 173 | + { |
|
| 174 | + $context['general_statistics']['right'] += array( |
|
| 168 | 175 | 'average_hits' => comma_format(round($averages['hits'] / $total_days_up, 2)), |
| 169 | 176 | ); |
| 177 | + } |
|
| 170 | 178 | } |
| 171 | 179 | |
| 172 | 180 | /** |
@@ -226,12 +234,16 @@ discard block |
||
| 226 | 234 | |
| 227 | 235 | // Keep a list of collapsed years. |
| 228 | 236 | if (!$data['expanded'] && !$data['current_year']) |
| 229 | - $context['collapsed_years'][] = $year; |
|
| 237 | + { |
|
| 238 | + $context['collapsed_years'][] = $year; |
|
| 239 | + } |
|
| 230 | 240 | } |
| 231 | 241 | |
| 232 | 242 | // Want to expand out the yearly stats |
| 233 | 243 | if (empty($_SESSION['expanded_stats'])) |
| 234 | - return false; |
|
| 244 | + { |
|
| 245 | + return false; |
|
| 246 | + } |
|
| 235 | 247 | |
| 236 | 248 | $condition_text = array(); |
| 237 | 249 | $condition_params = array(); |
@@ -247,7 +259,9 @@ discard block |
||
| 247 | 259 | |
| 248 | 260 | // No daily stats to even look at? |
| 249 | 261 | if (empty($condition_text)) |
| 250 | - return false; |
|
| 262 | + { |
|
| 263 | + return false; |
|
| 264 | + } |
|
| 251 | 265 | |
| 252 | 266 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
| 253 | 267 | |
@@ -273,7 +287,9 @@ discard block |
||
| 273 | 287 | $month = (int) substr($this->_req->query->expand, 4); |
| 274 | 288 | $year = (int) substr($this->_req->query->expand, 0, 4); |
| 275 | 289 | if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) |
| 276 | - $_SESSION['expanded_stats'][$year][] = $month; |
|
| 290 | + { |
|
| 291 | + $_SESSION['expanded_stats'][$year][] = $month; |
|
| 292 | + } |
|
| 277 | 293 | } |
| 278 | 294 | // Done looking at the details and want to fold it back up |
| 279 | 295 | elseif (!empty($this->_req->query->collapse)) |
@@ -283,7 +299,9 @@ discard block |
||
| 283 | 299 | $month = (int) substr($this->_req->query->collapse, 4); |
| 284 | 300 | $year = (int) substr($this->_req->query->collapse, 0, 4); |
| 285 | 301 | if (!empty($_SESSION['expanded_stats'][$year])) |
| 286 | - $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
| 302 | + { |
|
| 303 | + $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
| 304 | + } |
|
| 287 | 305 | } |
| 288 | 306 | |
| 289 | 307 | return array($year, $month); |
@@ -57,7 +57,9 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // You can't do anything if the calendar is off. |
| 59 | 59 | if (empty($modSettings['cal_enabled'])) |
| 60 | - throw new Elk_Exception('calendar_off', false); |
|
| 60 | + { |
|
| 61 | + throw new Elk_Exception('calendar_off', false); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // Set the page title to mention the calendar ;). |
| 63 | 65 | $context['page_title'] = $txt['calendar']; |
@@ -70,7 +72,9 @@ discard block |
||
| 70 | 72 | |
| 71 | 73 | // Don't let search engines index weekly calendar pages. |
| 72 | 74 | if ($context['view_week']) |
| 73 | - $context['robot_no_index'] = true; |
|
| 75 | + { |
|
| 76 | + $context['robot_no_index'] = true; |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | // Get the current day of month... |
| 76 | 80 | require_once(SUBSDIR . '/Calendar.subs.php'); |
@@ -85,16 +89,22 @@ discard block |
||
| 85 | 89 | |
| 86 | 90 | // Make sure the year and month are in valid ranges. |
| 87 | 91 | if ($curPage['month'] < 1 || $curPage['month'] > 12) |
| 88 | - throw new Elk_Exception('invalid_month', false); |
|
| 92 | + { |
|
| 93 | + throw new Elk_Exception('invalid_month', false); |
|
| 94 | + } |
|
| 89 | 95 | |
| 90 | 96 | if ($curPage['year'] < $context['cal_minyear'] || $curPage['year'] > $context['cal_maxyear']) |
| 91 | - throw new Elk_Exception('invalid_year', false); |
|
| 97 | + { |
|
| 98 | + throw new Elk_Exception('invalid_year', false); |
|
| 99 | + } |
|
| 92 | 100 | |
| 93 | 101 | // If we have a day clean that too. |
| 94 | 102 | if ($context['view_week']) |
| 95 | 103 | { |
| 96 | 104 | if ($curPage['day'] > 31 || !mktime(0, 0, 0, $curPage['month'], $curPage['day'], $curPage['year'])) |
| 97 | - throw new Elk_Exception('invalid_day', false); |
|
| 105 | + { |
|
| 106 | + throw new Elk_Exception('invalid_day', false); |
|
| 107 | + } |
|
| 98 | 108 | } |
| 99 | 109 | |
| 100 | 110 | // Load all the context information needed to show the calendar grid. |
@@ -112,9 +122,12 @@ discard block |
||
| 112 | 122 | |
| 113 | 123 | // Load up the main view. |
| 114 | 124 | if ($context['view_week']) |
| 115 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 116 | - else |
|
| 117 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 125 | + { |
|
| 126 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 127 | + } |
|
| 128 | + else { |
|
| 129 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 130 | + } |
|
| 118 | 131 | |
| 119 | 132 | // Load up the previous and next months. |
| 120 | 133 | $calendarOptions['show_birthdays'] = $calendarOptions['show_events'] = $calendarOptions['show_holidays'] = false; |
@@ -126,11 +139,15 @@ discard block |
||
| 126 | 139 | |
| 127 | 140 | // Only show previous month if it isn't pre-January of the min-year |
| 128 | 141 | if ($context['calendar_grid_current']['previous_calendar']['year'] > $context['cal_minyear'] || $curPage['month'] != 1) |
| 129 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions); |
|
| 142 | + { |
|
| 143 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions); |
|
| 144 | + } |
|
| 130 | 145 | |
| 131 | 146 | // Only show next month if it isn't post-December of the max-year |
| 132 | 147 | if ($context['calendar_grid_current']['next_calendar']['year'] < $context['cal_maxyear'] || $curPage['month'] != 12) |
| 133 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 148 | + { |
|
| 149 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 150 | + } |
|
| 134 | 151 | |
| 135 | 152 | // Basic template stuff. |
| 136 | 153 | $context['can_post'] = allowedTo('calendar_post'); |
@@ -156,10 +173,12 @@ discard block |
||
| 156 | 173 | |
| 157 | 174 | // If applicable, add the current week to the linktree. |
| 158 | 175 | if ($context['view_week']) |
| 159 | - $context['linktree'][] = array( |
|
| 176 | + { |
|
| 177 | + $context['linktree'][] = array( |
|
| 160 | 178 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
| 161 | 179 | 'name' => $txt['calendar_week'] . ' ' . $context['calendar_grid_main']['week_number'] |
| 162 | 180 | ); |
| 181 | + } |
|
| 163 | 182 | |
| 164 | 183 | // Build the calendar button array. |
| 165 | 184 | $context['calendar_buttons'] = array( |
@@ -220,7 +239,9 @@ discard block |
||
| 220 | 239 | // Get list of boards that can be posted in. |
| 221 | 240 | $boards = boardsAllowedTo('post_new'); |
| 222 | 241 | if (empty($boards)) |
| 223 | - throw new Elk_Exception('cannot_post_new', 'permission'); |
|
| 242 | + { |
|
| 243 | + throw new Elk_Exception('cannot_post_new', 'permission'); |
|
| 244 | + } |
|
| 224 | 245 | |
| 225 | 246 | // Load the list of boards and categories in the context. |
| 226 | 247 | require_once(SUBSDIR . '/Boards.subs.php'); |
@@ -275,7 +296,9 @@ discard block |
||
| 275 | 296 | |
| 276 | 297 | // If you're not allowed to edit any events, you have to be the poster. |
| 277 | 298 | if (!$event->isNew() && !allowedTo('calendar_edit_any')) |
| 278 | - isAllowedTo('calendar_edit_' . ($event->isStarter($user_info['id']) ? 'own' : 'any')); |
|
| 299 | + { |
|
| 300 | + isAllowedTo('calendar_edit_' . ($event->isStarter($user_info['id']) ? 'own' : 'any')); |
|
| 301 | + } |
|
| 279 | 302 | |
| 280 | 303 | // New - and directing? |
| 281 | 304 | if ($event->isNew() && isset($_POST['link_to_board'])) |
@@ -351,11 +374,15 @@ discard block |
||
| 351 | 374 | |
| 352 | 375 | // You can't export if the calendar export feature is off. |
| 353 | 376 | if (empty($modSettings['cal_export'])) |
| 354 | - throw new Elk_Exception('calendar_export_off', false); |
|
| 377 | + { |
|
| 378 | + throw new Elk_Exception('calendar_export_off', false); |
|
| 379 | + } |
|
| 355 | 380 | |
| 356 | 381 | // Goes without saying that this is required. |
| 357 | 382 | if (!isset($_REQUEST['eventid'])) |
| 358 | - throw new Elk_Exception('no_access', false); |
|
| 383 | + { |
|
| 384 | + throw new Elk_Exception('no_access', false); |
|
| 385 | + } |
|
| 359 | 386 | |
| 360 | 387 | // This is kinda wanted. |
| 361 | 388 | require_once(SUBSDIR . '/Calendar.subs.php'); |
@@ -364,7 +391,9 @@ discard block |
||
| 364 | 391 | $event = getEventProperties($_REQUEST['eventid']); |
| 365 | 392 | |
| 366 | 393 | if ($event === false) |
| 367 | - throw new Elk_Exception('no_access', false); |
|
| 394 | + { |
|
| 395 | + throw new Elk_Exception('no_access', false); |
|
| 396 | + } |
|
| 368 | 397 | |
| 369 | 398 | $filecontents = build_ical_content($event); |
| 370 | 399 | |
@@ -380,7 +409,9 @@ discard block |
||
| 380 | 409 | header('Connection: close'); |
| 381 | 410 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
| 382 | 411 | if (empty($modSettings['enableCompressedOutput'])) |
| 383 | - header('Content-Length: ' . Util::strlen($filecontents)); |
|
| 412 | + { |
|
| 413 | + header('Content-Length: ' . Util::strlen($filecontents)); |
|
| 414 | + } |
|
| 384 | 415 | |
| 385 | 416 | // This is a calendar item! |
| 386 | 417 | header('Content-Type: text/calendar'); |
@@ -121,7 +121,9 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | // Is the load average too high to allow searching just now? |
| 123 | 123 | if (!empty($modSettings['loadavg_search']) && $modSettings['current_load'] >= $modSettings['loadavg_search']) |
| 124 | - throw new Elk_Exception('loadavg_search_disabled', false); |
|
| 124 | + { |
|
| 125 | + throw new Elk_Exception('loadavg_search_disabled', false); |
|
| 126 | + } |
|
| 125 | 127 | |
| 126 | 128 | loadLanguage('Search'); |
| 127 | 129 | |
@@ -169,17 +171,29 @@ discard block |
||
| 169 | 171 | } |
| 170 | 172 | |
| 171 | 173 | if (isset($_REQUEST['search'])) |
| 172 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 174 | + { |
|
| 175 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 176 | + } |
|
| 173 | 177 | if (isset($context['search_params']['search'])) |
| 174 | - $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
| 178 | + { |
|
| 179 | + $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
| 180 | + } |
|
| 175 | 181 | if (isset($context['search_params']['userspec'])) |
| 176 | - $context['search_params']['userspec'] = htmlspecialchars($context['search_params']['userspec'], ENT_COMPAT, 'UTF-8'); |
|
| 182 | + { |
|
| 183 | + $context['search_params']['userspec'] = htmlspecialchars($context['search_params']['userspec'], ENT_COMPAT, 'UTF-8'); |
|
| 184 | + } |
|
| 177 | 185 | if (!empty($context['search_params']['searchtype'])) |
| 178 | - $context['search_params']['searchtype'] = 2; |
|
| 186 | + { |
|
| 187 | + $context['search_params']['searchtype'] = 2; |
|
| 188 | + } |
|
| 179 | 189 | if (!empty($context['search_params']['minage'])) |
| 180 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 190 | + { |
|
| 191 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 192 | + } |
|
| 181 | 193 | if (!empty($context['search_params']['maxage'])) |
| 182 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 194 | + { |
|
| 195 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 196 | + } |
|
| 183 | 197 | |
| 184 | 198 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
| 185 | 199 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -192,10 +206,14 @@ discard block |
||
| 192 | 206 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 193 | 207 | { |
| 194 | 208 | if ($search_error === 'messages') |
| 195 | - continue; |
|
| 209 | + { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 196 | 212 | |
| 197 | 213 | if ($search_error === 'string_too_long') |
| 198 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
| 214 | + { |
|
| 215 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
| 216 | + } |
|
| 199 | 217 | |
| 200 | 218 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 201 | 219 | } |
@@ -210,7 +228,9 @@ discard block |
||
| 210 | 228 | $context['boards_in_category'][$cat] = count($category['boards']); |
| 211 | 229 | $category['child_ids'] = array_keys($category['boards']); |
| 212 | 230 | foreach ($category['boards'] as &$board) |
| 213 | - $board['selected'] = (empty($context['search_params']['brd']) && (empty($modSettings['recycle_enable']) || $board['id'] != $modSettings['recycle_board']) && !in_array($board['id'], $user_info['ignoreboards'])) || (!empty($context['search_params']['brd']) && in_array($board['id'], $context['search_params']['brd'])); |
|
| 231 | + { |
|
| 232 | + $board['selected'] = (empty($context['search_params']['brd']) && (empty($modSettings['recycle_enable']) || $board['id'] != $modSettings['recycle_board']) && !in_array($board['id'], $user_info['ignoreboards'])) || (!empty($context['search_params']['brd']) && in_array($board['id'], $context['search_params']['brd'])); |
|
| 233 | + } |
|
| 214 | 234 | } |
| 215 | 235 | |
| 216 | 236 | if (!empty($_REQUEST['topic'])) |
@@ -238,7 +258,9 @@ discard block |
||
| 238 | 258 | |
| 239 | 259 | // Start guest off collapsed |
| 240 | 260 | if ($context['user']['is_guest'] && !isset($context['minmax_preferences']['asearch'])) |
| 241 | - $context['minmax_preferences']['asearch'] = 1; |
|
| 261 | + { |
|
| 262 | + $context['minmax_preferences']['asearch'] = 1; |
|
| 263 | + } |
|
| 242 | 264 | |
| 243 | 265 | call_integration_hook('integrate_search'); |
| 244 | 266 | } |
@@ -284,10 +306,13 @@ discard block |
||
| 284 | 306 | |
| 285 | 307 | loadLanguage('Search'); |
| 286 | 308 | if (!isset($_REQUEST['xml'])) |
| 287 | - loadTemplate('Search'); |
|
| 309 | + { |
|
| 310 | + loadTemplate('Search'); |
|
| 311 | + } |
|
| 288 | 312 | // If we're doing XML we need to use the results template regardless really. |
| 289 | - else |
|
| 290 | - $context['sub_template'] = 'results'; |
|
| 313 | + else { |
|
| 314 | + $context['sub_template'] = 'results'; |
|
| 315 | + } |
|
| 291 | 316 | |
| 292 | 317 | // Are you allowed? |
| 293 | 318 | isAllowedTo('search_posts'); |
@@ -299,17 +324,23 @@ discard block |
||
| 299 | 324 | $searchAPI = $this->_search->findSearchAPI(); |
| 300 | 325 | |
| 301 | 326 | if (isset($_REQUEST['params'])) |
| 302 | - $this->_search->searchParamsFromString($_REQUEST['params']); |
|
| 327 | + { |
|
| 328 | + $this->_search->searchParamsFromString($_REQUEST['params']); |
|
| 329 | + } |
|
| 303 | 330 | |
| 304 | 331 | $this->_search->mergeSearchParams($_REQUEST, $recentPercentage, $maxMembersToSearch); |
| 305 | 332 | $context['compact'] = $this->_search->isCompact(); |
| 306 | 333 | |
| 307 | 334 | // Nothing?? |
| 308 | 335 | if ($this->_search->param('search') === false || $this->_search->param('search') === '') |
| 309 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 336 | + { |
|
| 337 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 338 | + } |
|
| 310 | 339 | // Too long? |
| 311 | 340 | elseif (Util::strlen($this->_search->param('search')) > $context['search_string_limit']) |
| 312 | - $context['search_errors']['string_too_long'] = true; |
|
| 341 | + { |
|
| 342 | + $context['search_errors']['string_too_long'] = true; |
|
| 343 | + } |
|
| 313 | 344 | |
| 314 | 345 | // Build the search array |
| 315 | 346 | // $modSettings ['search_simple_fulltext'] is an hidden setting that will |
@@ -323,13 +354,18 @@ discard block |
||
| 323 | 354 | if (empty($searchArray)) |
| 324 | 355 | { |
| 325 | 356 | if (!empty($context['search_ignored'])) |
| 326 | - $context['search_errors']['search_string_small_words'] = true; |
|
| 327 | - else |
|
| 328 | - $context['search_errors']['invalid_search_string' . ($this->_search->foundBlackListedWords() ? '_blacklist' : '')] = true; |
|
| 357 | + { |
|
| 358 | + $context['search_errors']['search_string_small_words'] = true; |
|
| 359 | + } |
|
| 360 | + else { |
|
| 361 | + $context['search_errors']['invalid_search_string' . ($this->_search->foundBlackListedWords() ? '_blacklist' : '')] = true; |
|
| 362 | + } |
|
| 329 | 363 | |
| 330 | 364 | // Don't allow duplicate error messages if one string is too short. |
| 331 | 365 | if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
| 332 | - unset($context['search_errors']['invalid_search_string']); |
|
| 366 | + { |
|
| 367 | + unset($context['search_errors']['invalid_search_string']); |
|
| 368 | + } |
|
| 333 | 369 | } |
| 334 | 370 | |
| 335 | 371 | $searchWords = $this->_search->searchWords(); |
@@ -346,13 +382,21 @@ discard block |
||
| 346 | 382 | // Let the user adjust the search query, should they wish? |
| 347 | 383 | $context['search_params'] = $this->_search->getParams(); |
| 348 | 384 | if (isset($context['search_params']['search'])) |
| 349 | - $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
| 385 | + { |
|
| 386 | + $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
| 387 | + } |
|
| 350 | 388 | if (isset($context['search_params']['userspec'])) |
| 351 | - $context['search_params']['userspec'] = Util::htmlspecialchars($context['search_params']['userspec']); |
|
| 389 | + { |
|
| 390 | + $context['search_params']['userspec'] = Util::htmlspecialchars($context['search_params']['userspec']); |
|
| 391 | + } |
|
| 352 | 392 | if (empty($context['search_params']['minage'])) |
| 353 | - $context['search_params']['minage'] = 0; |
|
| 393 | + { |
|
| 394 | + $context['search_params']['minage'] = 0; |
|
| 395 | + } |
|
| 354 | 396 | if (empty($context['search_params']['maxage'])) |
| 355 | - $context['search_params']['maxage'] = 9999; |
|
| 397 | + { |
|
| 398 | + $context['search_params']['maxage'] = 9999; |
|
| 399 | + } |
|
| 356 | 400 | |
| 357 | 401 | $context['search_params'] = $this->_fill_default_search_params($context['search_params']); |
| 358 | 402 | |
@@ -361,7 +405,9 @@ discard block |
||
| 361 | 405 | { |
| 362 | 406 | // If we come from another search box tone down the error... |
| 363 | 407 | if (!isset($_REQUEST['search_vv'])) |
| 364 | - $context['search_errors']['need_verification_code'] = true; |
|
| 408 | + { |
|
| 409 | + $context['search_errors']['need_verification_code'] = true; |
|
| 410 | + } |
|
| 365 | 411 | else |
| 366 | 412 | { |
| 367 | 413 | require_once(SUBSDIR . '/VerificationControls.class.php'); |
@@ -373,11 +419,14 @@ discard block |
||
| 373 | 419 | if (is_array($context['require_verification'])) |
| 374 | 420 | { |
| 375 | 421 | foreach ($context['require_verification'] as $error) |
| 376 | - $context['search_errors'][$error] = true; |
|
| 422 | + { |
|
| 423 | + $context['search_errors'][$error] = true; |
|
| 424 | + } |
|
| 377 | 425 | } |
| 378 | 426 | // Don't keep asking for it - they've proven themselves worthy. |
| 379 | - else |
|
| 380 | - $_SESSION['ss_vv_passed'] = true; |
|
| 427 | + else { |
|
| 428 | + $_SESSION['ss_vv_passed'] = true; |
|
| 429 | + } |
|
| 381 | 430 | } |
| 382 | 431 | } |
| 383 | 432 | |
@@ -396,18 +445,24 @@ discard block |
||
| 396 | 445 | |
| 397 | 446 | // Start guest off collapsed |
| 398 | 447 | if ($context['user']['is_guest'] && !isset($context['minmax_preferences']['asearch'])) |
| 399 | - $context['minmax_preferences']['asearch'] = 1; |
|
| 448 | + { |
|
| 449 | + $context['minmax_preferences']['asearch'] = 1; |
|
| 450 | + } |
|
| 400 | 451 | |
| 401 | 452 | // *** A last error check |
| 402 | 453 | call_integration_hook('integrate_search_errors'); |
| 403 | 454 | |
| 404 | 455 | // One or more search errors? Go back to the first search screen. |
| 405 | 456 | if (!empty($context['search_errors'])) |
| 406 | - return $this->action_search(); |
|
| 457 | + { |
|
| 458 | + return $this->action_search(); |
|
| 459 | + } |
|
| 407 | 460 | |
| 408 | 461 | // Spam me not, Spam-a-lot? |
| 409 | 462 | if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $this->_search->param('search')) |
| 410 | - spamProtection('search'); |
|
| 463 | + { |
|
| 464 | + spamProtection('search'); |
|
| 465 | + } |
|
| 411 | 466 | |
| 412 | 467 | // Store the last search string to allow pages of results to be browsed. |
| 413 | 468 | $_SESSION['last_ss'] = $this->_search->param('search'); |
@@ -434,7 +489,9 @@ discard block |
||
| 434 | 489 | $this->_search->clearCacheResults($_SESSION['search_cache']['id_search']); |
| 435 | 490 | |
| 436 | 491 | if ($this->_search->param('subject_only')) |
| 437 | - $_SESSION['search_cache']['num_results'] = $this->_search->getSubjectResults($_SESSION['search_cache']['id_search'], $humungousTopicPosts, $maxMessageResults); |
|
| 492 | + { |
|
| 493 | + $_SESSION['search_cache']['num_results'] = $this->_search->getSubjectResults($_SESSION['search_cache']['id_search'], $humungousTopicPosts, $maxMessageResults); |
|
| 494 | + } |
|
| 438 | 495 | else |
| 439 | 496 | { |
| 440 | 497 | $num_res = $this->_search->getResults($_SESSION['search_cache']['id_search'], $humungousTopicPosts, $maxMessageResults); |
@@ -478,14 +535,18 @@ discard block |
||
| 478 | 535 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
| 479 | 536 | |
| 480 | 537 | if (!empty($posters)) |
| 481 | - loadMemberData(array_unique($posters)); |
|
| 538 | + { |
|
| 539 | + loadMemberData(array_unique($posters)); |
|
| 540 | + } |
|
| 482 | 541 | |
| 483 | 542 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
| 484 | 543 | $messages_request = $this->_search->loadMessagesRequest($msg_list, count($context['topics'])); |
| 485 | 544 | |
| 486 | 545 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
| 487 | 546 | if ($this->_search->noMessages($messages_request)) |
| 488 | - $context['topics'] = array(); |
|
| 547 | + { |
|
| 548 | + $context['topics'] = array(); |
|
| 549 | + } |
|
| 489 | 550 | |
| 490 | 551 | // If we want to know who participated in what then load this now. |
| 491 | 552 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -494,7 +555,9 @@ discard block |
||
| 494 | 555 | $topics_participated_in = topicsParticipation($user_info['id'], array_keys($participants)); |
| 495 | 556 | |
| 496 | 557 | foreach ($topics_participated_in as $topic) |
| 497 | - $participants[$topic['id_topic']] = true; |
|
| 558 | + { |
|
| 559 | + $participants[$topic['id_topic']] = true; |
|
| 560 | + } |
|
| 498 | 561 | } |
| 499 | 562 | } |
| 500 | 563 | |
@@ -541,16 +604,22 @@ discard block |
||
| 541 | 604 | // Remember which message this is. (ie. reply #83) |
| 542 | 605 | static $counter = null; |
| 543 | 606 | if ($counter === null || $reset) |
| 544 | - $counter = $_REQUEST['start'] + 1; |
|
| 607 | + { |
|
| 608 | + $counter = $_REQUEST['start'] + 1; |
|
| 609 | + } |
|
| 545 | 610 | |
| 546 | 611 | // Start from the beginning... |
| 547 | 612 | if ($reset) |
| 548 | - return currentContext($messages_request, $reset); |
|
| 613 | + { |
|
| 614 | + return currentContext($messages_request, $reset); |
|
| 615 | + } |
|
| 549 | 616 | |
| 550 | 617 | // Attempt to get the next in line |
| 551 | 618 | $message = currentContext($messages_request); |
| 552 | 619 | if (!$message) |
| 553 | - return false; |
|
| 620 | + { |
|
| 621 | + return false; |
|
| 622 | + } |
|
| 554 | 623 | |
| 555 | 624 | // Can't have an empty subject can we? |
| 556 | 625 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -590,7 +659,9 @@ discard block |
||
| 590 | 659 | if (Util::strlen($message['body']) > $charLimit) |
| 591 | 660 | { |
| 592 | 661 | if (empty($context['key_words'])) |
| 593 | - $message['body'] = Util::substr($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
| 662 | + { |
|
| 663 | + $message['body'] = Util::substr($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
| 664 | + } |
|
| 594 | 665 | else |
| 595 | 666 | { |
| 596 | 667 | $matchString = ''; |
@@ -600,7 +671,9 @@ discard block |
||
| 600 | 671 | $keyword = un_htmlspecialchars($keyword); |
| 601 | 672 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
| 602 | 673 | if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
| 603 | - $force_partial_word = true; |
|
| 674 | + { |
|
| 675 | + $force_partial_word = true; |
|
| 676 | + } |
|
| 604 | 677 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
| 605 | 678 | } |
| 606 | 679 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
@@ -608,9 +681,12 @@ discard block |
||
| 608 | 681 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br />' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
| 609 | 682 | |
| 610 | 683 | if (empty($modSettings['search_method']) || $force_partial_word) |
| 611 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
| 612 | - else |
|
| 613 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
| 684 | + { |
|
| 685 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
| 686 | + } |
|
| 687 | + else { |
|
| 688 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
| 689 | + } |
|
| 614 | 690 | |
| 615 | 691 | $message['body'] = ''; |
| 616 | 692 | foreach ($matches[0] as $match) |
@@ -703,7 +779,9 @@ discard block |
||
| 703 | 779 | determineTopicClass($output); |
| 704 | 780 | |
| 705 | 781 | if ($output['posted_in']) |
| 706 | - $output['class'] = 'my_' . $output['class']; |
|
| 782 | + { |
|
| 783 | + $output['class'] = 'my_' . $output['class']; |
|
| 784 | + } |
|
| 707 | 785 | |
| 708 | 786 | $body_highlighted = $message['body']; |
| 709 | 787 | $subject_highlighted = $message['subject']; |
@@ -878,7 +956,9 @@ discard block |
||
| 878 | 956 | { |
| 879 | 957 | // Admins can be bothered with a failure |
| 880 | 958 | if ($user_info['is_admin']) |
| 881 | - throw new Elk_Exception('search_invalid_weights'); |
|
| 959 | + { |
|
| 960 | + throw new Elk_Exception('search_invalid_weights'); |
|
| 961 | + } |
|
| 882 | 962 | |
| 883 | 963 | // Even if users will get an answer, the admin should know something is broken |
| 884 | 964 | Errors::instance()->log_lang_error('search_invalid_weights'); |
@@ -917,28 +997,46 @@ discard block |
||
| 917 | 997 | private function _fill_default_search_params($array) |
| 918 | 998 | { |
| 919 | 999 | if (empty($array['search'])) |
| 920 | - $array['search'] = ''; |
|
| 1000 | + { |
|
| 1001 | + $array['search'] = ''; |
|
| 1002 | + } |
|
| 921 | 1003 | if (empty($array['userspec'])) |
| 922 | - $array['userspec'] = '*'; |
|
| 1004 | + { |
|
| 1005 | + $array['userspec'] = '*'; |
|
| 1006 | + } |
|
| 923 | 1007 | if (empty($array['searchtype'])) |
| 924 | - $array['searchtype'] = 0; |
|
| 1008 | + { |
|
| 1009 | + $array['searchtype'] = 0; |
|
| 1010 | + } |
|
| 925 | 1011 | |
| 926 | 1012 | if (!isset($array['show_complete'])) |
| 927 | - $array['show_complete'] = 0; |
|
| 928 | - else |
|
| 929 | - $array['show_complete'] = (int) $array['show_complete']; |
|
| 1013 | + { |
|
| 1014 | + $array['show_complete'] = 0; |
|
| 1015 | + } |
|
| 1016 | + else { |
|
| 1017 | + $array['show_complete'] = (int) $array['show_complete']; |
|
| 1018 | + } |
|
| 930 | 1019 | |
| 931 | 1020 | if (!isset($array['subject_only'])) |
| 932 | - $array['subject_only'] = 0; |
|
| 933 | - else |
|
| 934 | - $array['subject_only'] = (int) $array['subject_only']; |
|
| 1021 | + { |
|
| 1022 | + $array['subject_only'] = 0; |
|
| 1023 | + } |
|
| 1024 | + else { |
|
| 1025 | + $array['subject_only'] = (int) $array['subject_only']; |
|
| 1026 | + } |
|
| 935 | 1027 | |
| 936 | 1028 | if (empty($array['minage'])) |
| 937 | - $array['minage'] = 0; |
|
| 1029 | + { |
|
| 1030 | + $array['minage'] = 0; |
|
| 1031 | + } |
|
| 938 | 1032 | if (empty($array['maxage'])) |
| 939 | - $array['maxage'] = 9999; |
|
| 1033 | + { |
|
| 1034 | + $array['maxage'] = 9999; |
|
| 1035 | + } |
|
| 940 | 1036 | if (empty($array['sort'])) |
| 941 | - $array['sort'] = 'relevance'; |
|
| 1037 | + { |
|
| 1038 | + $array['sort'] = 'relevance'; |
|
| 1039 | + } |
|
| 942 | 1040 | |
| 943 | 1041 | return $array; |
| 944 | 1042 | } |
@@ -738,7 +738,7 @@ |
||
| 738 | 738 | $query = strtr(Util::htmlspecialchars($query), array('\\\'' => '\'')); |
| 739 | 739 | |
| 740 | 740 | $search_highlight = preg_quote(strtr($query, array('\'' => ''')), '/'); |
| 741 | - $body_highlighted = preg_replace_callback('/((<[^>]*)|(\b' . $search_highlight . '\b)|'. $search_highlight . ')/iu', array($this, '_highlighted_callback'), $body_highlighted); |
|
| 741 | + $body_highlighted = preg_replace_callback('/((<[^>]*)|(\b' . $search_highlight . '\b)|' . $search_highlight . ')/iu', array($this, '_highlighted_callback'), $body_highlighted); |
|
| 742 | 742 | $subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/iu', '<strong class="highlight">$1</strong>', $subject_highlighted); |
| 743 | 743 | } |
| 744 | 744 | |
@@ -171,7 +171,9 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | // You must be posting to *some* board. |
| 173 | 173 | if (empty($board) && !$context['make_event']) |
| 174 | - throw new Elk_Exception('no_board', false); |
|
| 174 | + { |
|
| 175 | + throw new Elk_Exception('no_board', false); |
|
| 176 | + } |
|
| 175 | 177 | |
| 176 | 178 | // All those wonderful modifiers and attachments |
| 177 | 179 | $this->_template_layers->add('additional_options', 200); |
@@ -190,7 +192,9 @@ discard block |
||
| 190 | 192 | { |
| 191 | 193 | $topic = associatedTopic((int) $_REQUEST['msg']); |
| 192 | 194 | if (empty($topic)) |
| 193 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 195 | + { |
|
| 196 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 197 | + } |
|
| 194 | 198 | } |
| 195 | 199 | |
| 196 | 200 | // Check if it's locked. It isn't locked if no topic is specified. |
@@ -203,35 +207,47 @@ discard block |
||
| 203 | 207 | if (empty($_REQUEST['msg'])) |
| 204 | 208 | { |
| 205 | 209 | if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
| 206 | - is_not_guest(); |
|
| 210 | + { |
|
| 211 | + is_not_guest(); |
|
| 212 | + } |
|
| 207 | 213 | |
| 208 | 214 | // By default the reply will be approved... |
| 209 | 215 | $context['becomes_approved'] = true; |
| 210 | 216 | if ($this->_topic_attributes['id_member'] != $user_info['id']) |
| 211 | 217 | { |
| 212 | 218 | if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
| 213 | - $context['becomes_approved'] = false; |
|
| 214 | - else |
|
| 215 | - isAllowedTo('post_reply_any'); |
|
| 219 | + { |
|
| 220 | + $context['becomes_approved'] = false; |
|
| 221 | + } |
|
| 222 | + else { |
|
| 223 | + isAllowedTo('post_reply_any'); |
|
| 224 | + } |
|
| 216 | 225 | } |
| 217 | 226 | elseif (!allowedTo('post_reply_any')) |
| 218 | 227 | { |
| 219 | 228 | if ($modSettings['postmod_active']) |
| 220 | 229 | { |
| 221 | 230 | if (allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
| 222 | - $context['becomes_approved'] = false; |
|
| 231 | + { |
|
| 232 | + $context['becomes_approved'] = false; |
|
| 233 | + } |
|
| 223 | 234 | // Guests do not have post_unapproved_replies_own permission, so it's always post_unapproved_replies_any |
| 224 | 235 | elseif ($user_info['is_guest'] && allowedTo('post_unapproved_replies_any')) |
| 225 | - $context['becomes_approved'] = false; |
|
| 226 | - else |
|
| 227 | - isAllowedTo('post_reply_own'); |
|
| 236 | + { |
|
| 237 | + $context['becomes_approved'] = false; |
|
| 238 | + } |
|
| 239 | + else { |
|
| 240 | + isAllowedTo('post_reply_own'); |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + else { |
|
| 244 | + isAllowedTo('post_reply_own'); |
|
| 228 | 245 | } |
| 229 | - else |
|
| 230 | - isAllowedTo('post_reply_own'); |
|
| 231 | 246 | } |
| 232 | 247 | } |
| 233 | - else |
|
| 234 | - $context['becomes_approved'] = true; |
|
| 248 | + else { |
|
| 249 | + $context['becomes_approved'] = true; |
|
| 250 | + } |
|
| 235 | 251 | |
| 236 | 252 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $this->_topic_attributes['id_member'] && allowedTo('lock_own')); |
| 237 | 253 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -245,9 +261,12 @@ discard block |
||
| 245 | 261 | if (empty($context['make_event']) || !empty($board)) |
| 246 | 262 | { |
| 247 | 263 | if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
| 248 | - $context['becomes_approved'] = false; |
|
| 249 | - else |
|
| 250 | - isAllowedTo('post_new'); |
|
| 264 | + { |
|
| 265 | + $context['becomes_approved'] = false; |
|
| 266 | + } |
|
| 267 | + else { |
|
| 268 | + isAllowedTo('post_new'); |
|
| 269 | + } |
|
| 251 | 270 | } |
| 252 | 271 | |
| 253 | 272 | $this->_topic_attributes['locked'] = 0; |
@@ -277,7 +296,9 @@ discard block |
||
| 277 | 296 | |
| 278 | 297 | // Don't allow a post if it's locked and you aren't all powerful. |
| 279 | 298 | if ($this->_topic_attributes['locked'] && !allowedTo('moderate_board')) |
| 280 | - throw new Elk_Exception('topic_locked', false); |
|
| 299 | + { |
|
| 300 | + throw new Elk_Exception('topic_locked', false); |
|
| 301 | + } |
|
| 281 | 302 | } |
| 282 | 303 | |
| 283 | 304 | protected function _generating_message() |
@@ -294,9 +315,12 @@ discard block |
||
| 294 | 315 | if (!empty($context['new_replies'])) |
| 295 | 316 | { |
| 296 | 317 | if ($context['new_replies'] == 1) |
| 297 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 298 | - else |
|
| 299 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 318 | + { |
|
| 319 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 320 | + } |
|
| 321 | + else { |
|
| 322 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 323 | + } |
|
| 300 | 324 | |
| 301 | 325 | $this->_post_errors->addError('new_replies', 0); |
| 302 | 326 | |
@@ -322,13 +346,19 @@ discard block |
||
| 322 | 346 | else |
| 323 | 347 | { |
| 324 | 348 | if (!isset($_REQUEST['subject'])) |
| 325 | - $_REQUEST['subject'] = ''; |
|
| 349 | + { |
|
| 350 | + $_REQUEST['subject'] = ''; |
|
| 351 | + } |
|
| 326 | 352 | |
| 327 | 353 | if (!isset($_REQUEST['message'])) |
| 328 | - $_REQUEST['message'] = ''; |
|
| 354 | + { |
|
| 355 | + $_REQUEST['message'] = ''; |
|
| 356 | + } |
|
| 329 | 357 | |
| 330 | 358 | if (!isset($_REQUEST['icon'])) |
| 331 | - $_REQUEST['icon'] = 'xx'; |
|
| 359 | + { |
|
| 360 | + $_REQUEST['icon'] = 'xx'; |
|
| 361 | + } |
|
| 332 | 362 | |
| 333 | 363 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 334 | 364 | $really_previewing = !empty($_REQUEST['preview']) || isset($_REQUEST['xml']); |
@@ -348,7 +378,9 @@ discard block |
||
| 348 | 378 | |
| 349 | 379 | // Make sure the subject isn't too long - taking into account special characters. |
| 350 | 380 | if (Util::strlen($this->_form_subject) > 100) |
| 351 | - $this->_form_subject = Util::substr($this->_form_subject, 0, 100); |
|
| 381 | + { |
|
| 382 | + $this->_form_subject = Util::substr($this->_form_subject, 0, 100); |
|
| 383 | + } |
|
| 352 | 384 | |
| 353 | 385 | // Are you... a guest? |
| 354 | 386 | if ($user_info['is_guest']) |
@@ -382,13 +414,19 @@ discard block |
||
| 382 | 414 | } |
| 383 | 415 | |
| 384 | 416 | if ($context['preview_message'] === '') |
| 385 | - $this->_post_errors->addError('no_message'); |
|
| 417 | + { |
|
| 418 | + $this->_post_errors->addError('no_message'); |
|
| 419 | + } |
|
| 386 | 420 | elseif (!empty($modSettings['max_messageLength']) && Util::strlen($this->_form_message) > $modSettings['max_messageLength']) |
| 387 | - $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
| 421 | + { |
|
| 422 | + $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
| 423 | + } |
|
| 388 | 424 | |
| 389 | 425 | // Protect any CDATA blocks. |
| 390 | 426 | if (isset($_REQUEST['xml'])) |
| 391 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 427 | + { |
|
| 428 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 429 | + } |
|
| 392 | 430 | } |
| 393 | 431 | |
| 394 | 432 | // Set up the checkboxes. |
@@ -411,12 +449,16 @@ discard block |
||
| 411 | 449 | // The message they were trying to edit was most likely deleted. |
| 412 | 450 | // @todo Change this error message? |
| 413 | 451 | if ($message === false) |
| 414 | - throw new Elk_Exception('no_board', false); |
|
| 452 | + { |
|
| 453 | + throw new Elk_Exception('no_board', false); |
|
| 454 | + } |
|
| 415 | 455 | |
| 416 | 456 | $errors = checkMessagePermissions($message['message']); |
| 417 | 457 | if (!empty($errors)) |
| 418 | - foreach ($errors as $error) |
|
| 458 | + { |
|
| 459 | + foreach ($errors as $error) |
|
| 419 | 460 | $this->_post_errors->addError($error); |
| 461 | + } |
|
| 420 | 462 | |
| 421 | 463 | prepareMessageContext($message); |
| 422 | 464 | } |
@@ -425,12 +467,17 @@ discard block |
||
| 425 | 467 | // @todo: sort out what kind of combinations are actually possible |
| 426 | 468 | // Posting a quoted reply? |
| 427 | 469 | if ((!empty($topic) && !empty($_REQUEST['quote'])) || (!empty($modSettings['enableFollowup']) && !empty($_REQUEST['followup']))) |
| 428 | - $case = 2; |
|
| 470 | + { |
|
| 471 | + $case = 2; |
|
| 472 | + } |
|
| 429 | 473 | // Posting a reply without a quote? |
| 430 | 474 | elseif (!empty($topic) && empty($_REQUEST['quote'])) |
| 431 | - $case = 3; |
|
| 432 | - else |
|
| 433 | - $case = 4; |
|
| 475 | + { |
|
| 476 | + $case = 3; |
|
| 477 | + } |
|
| 478 | + else { |
|
| 479 | + $case = 4; |
|
| 480 | + } |
|
| 434 | 481 | |
| 435 | 482 | list ($this->_form_subject,) = getFormMsgSubject($case, $topic, $this->_topic_attributes['subject']); |
| 436 | 483 | } |
@@ -447,14 +494,18 @@ discard block |
||
| 447 | 494 | |
| 448 | 495 | // The message they were trying to edit was most likely deleted. |
| 449 | 496 | if ($message === false) |
| 450 | - throw new Elk_Exception('no_message', false); |
|
| 497 | + { |
|
| 498 | + throw new Elk_Exception('no_message', false); |
|
| 499 | + } |
|
| 451 | 500 | |
| 452 | 501 | // Trigger the prepare_editing event |
| 453 | 502 | $this->_events->trigger('prepare_editing', array('topic' => $topic, 'message' => &$message)); |
| 454 | 503 | |
| 455 | 504 | if (!empty($message['errors'])) |
| 456 | - foreach ($message['errors'] as $error) |
|
| 505 | + { |
|
| 506 | + foreach ($message['errors'] as $error) |
|
| 457 | 507 | $this->_post_errors->addError($error); |
| 508 | + } |
|
| 458 | 509 | |
| 459 | 510 | // Get the stuff ready for the form. |
| 460 | 511 | $this->_form_subject = $message['message']['subject']; |
@@ -492,19 +543,26 @@ discard block |
||
| 492 | 543 | // @todo: sort out what kind of combinations are actually possible |
| 493 | 544 | // Posting a quoted reply? |
| 494 | 545 | if ((!empty($topic) && !empty($_REQUEST['quote'])) || (!empty($modSettings['enableFollowup']) && !empty($_REQUEST['followup']))) |
| 495 | - $case = 2; |
|
| 546 | + { |
|
| 547 | + $case = 2; |
|
| 548 | + } |
|
| 496 | 549 | // Posting a reply without a quote? |
| 497 | 550 | elseif (!empty($topic) && empty($_REQUEST['quote'])) |
| 498 | - $case = 3; |
|
| 499 | - else |
|
| 500 | - $case = 4; |
|
| 551 | + { |
|
| 552 | + $case = 3; |
|
| 553 | + } |
|
| 554 | + else { |
|
| 555 | + $case = 4; |
|
| 556 | + } |
|
| 501 | 557 | |
| 502 | 558 | list ($this->_form_subject, $this->_form_message) = getFormMsgSubject($case, $topic, $this->_topic_attributes['subject']); |
| 503 | 559 | } |
| 504 | 560 | |
| 505 | 561 | // Check whether this is a really old post being bumped... |
| 506 | 562 | if (!empty($topic) && !empty($modSettings['oldTopicDays']) && $this->_topic_attributes['last_post_time'] + $modSettings['oldTopicDays'] * 86400 < time() && empty($this->_topic_attributes['is_sticky']) && !isset($_REQUEST['subject'])) |
| 507 | - $this->_post_errors->addError(array('old_topic', array($modSettings['oldTopicDays'])), 0); |
|
| 563 | + { |
|
| 564 | + $this->_post_errors->addError(array('old_topic', array($modSettings['oldTopicDays'])), 0); |
|
| 565 | + } |
|
| 508 | 566 | } |
| 509 | 567 | |
| 510 | 568 | protected function _preparing_page() |
@@ -522,13 +580,20 @@ discard block |
||
| 522 | 580 | if (empty($context['page_title'])) |
| 523 | 581 | { |
| 524 | 582 | if (isset($_REQUEST['msg'])) |
| 525 | - $context['page_title'] = $txt['modify_msg']; |
|
| 583 | + { |
|
| 584 | + $context['page_title'] = $txt['modify_msg']; |
|
| 585 | + } |
|
| 526 | 586 | elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
| 527 | - $context['page_title'] = $txt['post_reply']; |
|
| 587 | + { |
|
| 588 | + $context['page_title'] = $txt['post_reply']; |
|
| 589 | + } |
|
| 528 | 590 | elseif (empty($topic)) |
| 529 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 530 | - else |
|
| 531 | - $context['page_title'] = $txt['post_reply']; |
|
| 591 | + { |
|
| 592 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 593 | + } |
|
| 594 | + else { |
|
| 595 | + $context['page_title'] = $txt['post_reply']; |
|
| 596 | + } |
|
| 532 | 597 | } |
| 533 | 598 | |
| 534 | 599 | // Update the topic summary, needed to show new posts in a preview |
@@ -537,9 +602,12 @@ discard block |
||
| 537 | 602 | $only_approved = $modSettings['postmod_active'] && !allowedTo('approve_posts'); |
| 538 | 603 | |
| 539 | 604 | if (isset($_REQUEST['xml'])) |
| 540 | - $limit = empty($context['new_replies']) ? 0 : (int) $context['new_replies']; |
|
| 541 | - else |
|
| 542 | - $limit = $modSettings['topicSummaryPosts']; |
|
| 605 | + { |
|
| 606 | + $limit = empty($context['new_replies']) ? 0 : (int) $context['new_replies']; |
|
| 607 | + } |
|
| 608 | + else { |
|
| 609 | + $limit = $modSettings['topicSummaryPosts']; |
|
| 610 | + } |
|
| 543 | 611 | |
| 544 | 612 | $before = isset($_REQUEST['msg']) ? array('before' => (int) $_REQUEST['msg']) : array(); |
| 545 | 613 | |
@@ -552,13 +620,17 @@ discard block |
||
| 552 | 620 | $post['is_ignored'] = !empty($modSettings['enable_buddylist']) && in_array($post['id_poster'], $user_info['ignoreusers']); |
| 553 | 621 | |
| 554 | 622 | if (!empty($context['new_replies'])) |
| 555 | - $context['new_replies']--; |
|
| 623 | + { |
|
| 624 | + $context['new_replies']--; |
|
| 625 | + } |
|
| 556 | 626 | } |
| 557 | 627 | } |
| 558 | 628 | |
| 559 | 629 | // Just ajax previewing then lets stop now |
| 560 | 630 | if (isset($_REQUEST['xml'])) |
| 561 | - obExit(); |
|
| 631 | + { |
|
| 632 | + obExit(); |
|
| 633 | + } |
|
| 562 | 634 | |
| 563 | 635 | $context['subject'] = addcslashes($this->_form_subject, '"'); |
| 564 | 636 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $this->_form_message); |
@@ -576,7 +648,9 @@ discard block |
||
| 576 | 648 | |
| 577 | 649 | // $context['icon'] is set when editing a message |
| 578 | 650 | if (!isset($context['icon'])) |
| 579 | - $context['icon'] = $context['icons'][0]['value']; |
|
| 651 | + { |
|
| 652 | + $context['icon'] = $context['icons'][0]['value']; |
|
| 653 | + } |
|
| 580 | 654 | $found = false; |
| 581 | 655 | foreach ($context['icons'] as $icon) |
| 582 | 656 | { |
@@ -658,12 +732,17 @@ discard block |
||
| 658 | 732 | if (empty($_POST) && empty($topic)) |
| 659 | 733 | { |
| 660 | 734 | if (empty($_SERVER['CONTENT_LENGTH'])) |
| 661 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 662 | - else |
|
| 663 | - throw new Elk_Exception('post_upload_error', false); |
|
| 735 | + { |
|
| 736 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 737 | + } |
|
| 738 | + else { |
|
| 739 | + throw new Elk_Exception('post_upload_error', false); |
|
| 740 | + } |
|
| 664 | 741 | } |
| 665 | 742 | elseif (empty($_POST) && !empty($topic)) |
| 666 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 743 | + { |
|
| 744 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 745 | + } |
|
| 667 | 746 | |
| 668 | 747 | // No need! |
| 669 | 748 | $context['robot_no_index'] = true; |
@@ -686,7 +765,9 @@ discard block |
||
| 686 | 765 | |
| 687 | 766 | // Previewing? Go back to start. |
| 688 | 767 | if (isset($_REQUEST['preview'])) |
| 689 | - return $this->action_post(); |
|
| 768 | + { |
|
| 769 | + return $this->action_post(); |
|
| 770 | + } |
|
| 690 | 771 | |
| 691 | 772 | require_once(SUBSDIR . '/Boards.subs.php'); |
| 692 | 773 | loadLanguage('Post'); |
@@ -704,11 +785,15 @@ discard block |
||
| 704 | 785 | |
| 705 | 786 | // Though the topic should be there, it might have vanished. |
| 706 | 787 | if (empty($topic_info)) |
| 707 | - throw new Elk_Exception('topic_doesnt_exist'); |
|
| 788 | + { |
|
| 789 | + throw new Elk_Exception('topic_doesnt_exist'); |
|
| 790 | + } |
|
| 708 | 791 | |
| 709 | 792 | // Did this topic suddenly move? Just checking... |
| 710 | 793 | if ($topic_info['id_board'] != $board) |
| 711 | - throw new Elk_Exception('not_a_topic'); |
|
| 794 | + { |
|
| 795 | + throw new Elk_Exception('not_a_topic'); |
|
| 796 | + } |
|
| 712 | 797 | } |
| 713 | 798 | |
| 714 | 799 | // Replying to a topic? |
@@ -716,28 +801,38 @@ discard block |
||
| 716 | 801 | { |
| 717 | 802 | // Don't allow a post if it's locked. |
| 718 | 803 | if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
| 719 | - throw new Elk_Exception('topic_locked', false); |
|
| 804 | + { |
|
| 805 | + throw new Elk_Exception('topic_locked', false); |
|
| 806 | + } |
|
| 720 | 807 | |
| 721 | 808 | // Do the permissions and approval stuff... |
| 722 | 809 | $becomesApproved = true; |
| 723 | 810 | if ($topic_info['id_member_started'] != $user_info['id']) |
| 724 | 811 | { |
| 725 | 812 | if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
| 726 | - $becomesApproved = false; |
|
| 727 | - else |
|
| 728 | - isAllowedTo('post_reply_any'); |
|
| 813 | + { |
|
| 814 | + $becomesApproved = false; |
|
| 815 | + } |
|
| 816 | + else { |
|
| 817 | + isAllowedTo('post_reply_any'); |
|
| 818 | + } |
|
| 729 | 819 | } |
| 730 | 820 | elseif (!allowedTo('post_reply_any')) |
| 731 | 821 | { |
| 732 | 822 | if ($modSettings['postmod_active']) |
| 733 | 823 | { |
| 734 | 824 | if (allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
| 735 | - $becomesApproved = false; |
|
| 825 | + { |
|
| 826 | + $becomesApproved = false; |
|
| 827 | + } |
|
| 736 | 828 | // Guests do not have post_unapproved_replies_own permission, so it's always post_unapproved_replies_any |
| 737 | 829 | elseif ($user_info['is_guest'] && allowedTo('post_unapproved_replies_any')) |
| 738 | - $becomesApproved = false; |
|
| 739 | - else |
|
| 740 | - isAllowedTo('post_reply_own'); |
|
| 830 | + { |
|
| 831 | + $becomesApproved = false; |
|
| 832 | + } |
|
| 833 | + else { |
|
| 834 | + isAllowedTo('post_reply_own'); |
|
| 835 | + } |
|
| 741 | 836 | } |
| 742 | 837 | } |
| 743 | 838 | |
@@ -748,7 +843,9 @@ discard block |
||
| 748 | 843 | |
| 749 | 844 | // So you wanna (un)sticky this...let's see. |
| 750 | 845 | if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
| 751 | - unset($_POST['sticky']); |
|
| 846 | + { |
|
| 847 | + unset($_POST['sticky']); |
|
| 848 | + } |
|
| 752 | 849 | |
| 753 | 850 | // Trigger the save_replying event |
| 754 | 851 | $this->_events->trigger('save_replying', array('topic_info' => &$topic_info)); |
@@ -776,9 +873,12 @@ discard block |
||
| 776 | 873 | // Do like, the permissions, for safety and stuff... |
| 777 | 874 | $becomesApproved = true; |
| 778 | 875 | if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
| 779 | - $becomesApproved = false; |
|
| 780 | - else |
|
| 781 | - isAllowedTo('post_new'); |
|
| 876 | + { |
|
| 877 | + $becomesApproved = false; |
|
| 878 | + } |
|
| 879 | + else { |
|
| 880 | + isAllowedTo('post_new'); |
|
| 881 | + } |
|
| 782 | 882 | |
| 783 | 883 | // Trigger teh save new topic event |
| 784 | 884 | $this->_events->trigger('save_new_topic', array('becomesApproved' => &$becomesApproved)); |
@@ -789,7 +889,9 @@ discard block |
||
| 789 | 889 | } |
| 790 | 890 | |
| 791 | 891 | if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
| 792 | - unset($_POST['sticky']); |
|
| 892 | + { |
|
| 893 | + unset($_POST['sticky']); |
|
| 894 | + } |
|
| 793 | 895 | |
| 794 | 896 | $posterIsGuest = $user_info['is_guest']; |
| 795 | 897 | } |
@@ -801,13 +903,17 @@ discard block |
||
| 801 | 903 | $msgInfo = basicMessageInfo($_REQUEST['msg'], true); |
| 802 | 904 | |
| 803 | 905 | if (empty($msgInfo)) |
| 804 | - throw new Elk_Exception('cant_find_messages', false); |
|
| 906 | + { |
|
| 907 | + throw new Elk_Exception('cant_find_messages', false); |
|
| 908 | + } |
|
| 805 | 909 | |
| 806 | 910 | // Trigger teh save_modify event |
| 807 | 911 | $this->_events->trigger('save_modify', array('msgInfo' => &$msgInfo)); |
| 808 | 912 | |
| 809 | 913 | if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
| 810 | - throw new Elk_Exception('topic_locked', false); |
|
| 914 | + { |
|
| 915 | + throw new Elk_Exception('topic_locked', false); |
|
| 916 | + } |
|
| 811 | 917 | |
| 812 | 918 | if (isset($_POST['lock'])) |
| 813 | 919 | { |
@@ -816,16 +922,23 @@ discard block |
||
| 816 | 922 | |
| 817 | 923 | // Change the sticky status of this topic? |
| 818 | 924 | if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
| 819 | - unset($_POST['sticky']); |
|
| 925 | + { |
|
| 926 | + unset($_POST['sticky']); |
|
| 927 | + } |
|
| 820 | 928 | |
| 821 | 929 | if ($msgInfo['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 822 | 930 | { |
| 823 | 931 | if ((!$modSettings['postmod_active'] || $msgInfo['approved']) && !empty($modSettings['edit_disable_time']) && $msgInfo['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
| 824 | - throw new Elk_Exception('modify_post_time_passed', false); |
|
| 932 | + { |
|
| 933 | + throw new Elk_Exception('modify_post_time_passed', false); |
|
| 934 | + } |
|
| 825 | 935 | elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
| 826 | - isAllowedTo('modify_replies'); |
|
| 827 | - else |
|
| 828 | - isAllowedTo('modify_own'); |
|
| 936 | + { |
|
| 937 | + isAllowedTo('modify_replies'); |
|
| 938 | + } |
|
| 939 | + else { |
|
| 940 | + isAllowedTo('modify_own'); |
|
| 941 | + } |
|
| 829 | 942 | } |
| 830 | 943 | elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
| 831 | 944 | { |
@@ -840,7 +953,9 @@ discard block |
||
| 840 | 953 | |
| 841 | 954 | // Log it, assuming you're not modifying your own post. |
| 842 | 955 | if ($msgInfo['id_member'] != $user_info['id']) |
| 843 | - $moderationAction = true; |
|
| 956 | + { |
|
| 957 | + $moderationAction = true; |
|
| 958 | + } |
|
| 844 | 959 | } |
| 845 | 960 | |
| 846 | 961 | $posterIsGuest = empty($msgInfo['id_member']); |
@@ -871,10 +986,14 @@ discard block |
||
| 871 | 986 | $_POST['email'] = !isset($_POST['email']) ? '' : Util::htmlspecialchars(trim($_POST['email'])); |
| 872 | 987 | |
| 873 | 988 | if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
| 874 | - $this->_post_errors->addError('no_name'); |
|
| 989 | + { |
|
| 990 | + $this->_post_errors->addError('no_name'); |
|
| 991 | + } |
|
| 875 | 992 | |
| 876 | 993 | if (Util::strlen($_POST['guestname']) > 25) |
| 877 | - $this->_post_errors->addError('long_name'); |
|
| 994 | + { |
|
| 995 | + $this->_post_errors->addError('long_name'); |
|
| 996 | + } |
|
| 878 | 997 | |
| 879 | 998 | if (empty($modSettings['guest_post_no_email'])) |
| 880 | 999 | { |
@@ -882,7 +1001,9 @@ discard block |
||
| 882 | 1001 | if (!isset($msgInfo) || $msgInfo['poster_email'] != $_POST['email']) |
| 883 | 1002 | { |
| 884 | 1003 | if (!allowedTo('moderate_forum') && !Data_Validator::is_valid($_POST, array('email' => 'valid_email|required'), array('email' => 'trim'))) |
| 885 | - empty($_POST['email']) ? $this->_post_errors->addError('no_email') : $this->_post_errors->addError('bad_email'); |
|
| 1004 | + { |
|
| 1005 | + empty($_POST['email']) ? $this->_post_errors->addError('no_email') : $this->_post_errors->addError('bad_email'); |
|
| 1006 | + } |
|
| 886 | 1007 | } |
| 887 | 1008 | |
| 888 | 1009 | // Now make sure this email address is not banned from posting. |
@@ -909,12 +1030,18 @@ discard block |
||
| 909 | 1030 | |
| 910 | 1031 | // Check the subject and message. |
| 911 | 1032 | if (!isset($_POST['subject']) || Util::htmltrim(Util::htmlspecialchars($_POST['subject'])) === '') |
| 912 | - $this->_post_errors->addError('no_subject'); |
|
| 1033 | + { |
|
| 1034 | + $this->_post_errors->addError('no_subject'); |
|
| 1035 | + } |
|
| 913 | 1036 | |
| 914 | 1037 | if (!isset($_POST['message']) || Util::htmltrim(Util::htmlspecialchars($_POST['message'], ENT_QUOTES)) === '') |
| 915 | - $this->_post_errors->addError('no_message'); |
|
| 1038 | + { |
|
| 1039 | + $this->_post_errors->addError('no_message'); |
|
| 1040 | + } |
|
| 916 | 1041 | elseif (!empty($modSettings['max_messageLength']) && Util::strlen($_POST['message']) > $modSettings['max_messageLength']) |
| 917 | - $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
| 1042 | + { |
|
| 1043 | + $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
| 1044 | + } |
|
| 918 | 1045 | else |
| 919 | 1046 | { |
| 920 | 1047 | // Prepare the message a bit for some additional testing. |
@@ -922,7 +1049,9 @@ discard block |
||
| 922 | 1049 | |
| 923 | 1050 | // Preparse code. (Zef) |
| 924 | 1051 | if ($user_info['is_guest']) |
| 925 | - $user_info['name'] = $_POST['guestname']; |
|
| 1052 | + { |
|
| 1053 | + $user_info['name'] = $_POST['guestname']; |
|
| 1054 | + } |
|
| 926 | 1055 | |
| 927 | 1056 | $this->preparse->preparsecode($_POST['message']); |
| 928 | 1057 | |
@@ -930,7 +1059,9 @@ discard block |
||
| 930 | 1059 | |
| 931 | 1060 | // Let's see if there's still some content left without the tags. |
| 932 | 1061 | if (Util::htmltrim(strip_tags($bbc_parser->parseMessage($_POST['message'], false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
| 933 | - $this->_post_errors->addError('no_message'); |
|
| 1062 | + { |
|
| 1063 | + $this->_post_errors->addError('no_message'); |
|
| 1064 | + } |
|
| 934 | 1065 | } |
| 935 | 1066 | |
| 936 | 1067 | if ($posterIsGuest) |
@@ -938,7 +1069,9 @@ discard block |
||
| 938 | 1069 | // If user is a guest, make sure the chosen name isn't taken. |
| 939 | 1070 | require_once(SUBSDIR . '/Members.subs.php'); |
| 940 | 1071 | if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($msgInfo['poster_name']) || $_POST['guestname'] != $msgInfo['poster_name'])) |
| 941 | - $this->_post_errors->addError('bad_name'); |
|
| 1072 | + { |
|
| 1073 | + $this->_post_errors->addError('bad_name'); |
|
| 1074 | + } |
|
| 942 | 1075 | } |
| 943 | 1076 | // If the user isn't a guest, get his or her name and email. |
| 944 | 1077 | elseif (!isset($_REQUEST['msg'])) |
@@ -956,9 +1089,12 @@ discard block |
||
| 956 | 1089 | $post_in_board = boardInfo($new_board); |
| 957 | 1090 | |
| 958 | 1091 | if (!empty($post_in_board)) |
| 959 | - $this->_post_errors->addError(array('post_new_board', array($post_in_board['name']))); |
|
| 960 | - else |
|
| 961 | - $this->_post_errors->addError('post_new'); |
|
| 1092 | + { |
|
| 1093 | + $this->_post_errors->addError(array('post_new_board', array($post_in_board['name']))); |
|
| 1094 | + } |
|
| 1095 | + else { |
|
| 1096 | + $this->_post_errors->addError('post_new'); |
|
| 1097 | + } |
|
| 962 | 1098 | } |
| 963 | 1099 | } |
| 964 | 1100 | |
@@ -977,7 +1113,9 @@ discard block |
||
| 977 | 1113 | |
| 978 | 1114 | // Make sure the user isn't spamming the board. |
| 979 | 1115 | if (!isset($_REQUEST['msg'])) |
| 980 | - spamProtection('post'); |
|
| 1116 | + { |
|
| 1117 | + spamProtection('post'); |
|
| 1118 | + } |
|
| 981 | 1119 | |
| 982 | 1120 | // At about this point, we're posting and that's that. |
| 983 | 1121 | ignore_user_abort(true); |
@@ -990,7 +1128,9 @@ discard block |
||
| 990 | 1128 | |
| 991 | 1129 | // At this point, we want to make sure the subject isn't too long. |
| 992 | 1130 | if (Util::strlen($_POST['subject']) > 100) |
| 993 | - $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
| 1131 | + { |
|
| 1132 | + $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
| 1133 | + } |
|
| 994 | 1134 | |
| 995 | 1135 | // Creating a new topic? |
| 996 | 1136 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
@@ -1038,7 +1178,9 @@ discard block |
||
| 1038 | 1178 | |
| 1039 | 1179 | // This will save some time... |
| 1040 | 1180 | if (empty($approve_has_changed)) |
| 1041 | - unset($msgOptions['approved']); |
|
| 1181 | + { |
|
| 1182 | + unset($msgOptions['approved']); |
|
| 1183 | + } |
|
| 1042 | 1184 | |
| 1043 | 1185 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 1044 | 1186 | } |
@@ -1061,7 +1203,9 @@ discard block |
||
| 1061 | 1203 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 1062 | 1204 | |
| 1063 | 1205 | if (isset($topicOptions['id'])) |
| 1064 | - $topic = $topicOptions['id']; |
|
| 1206 | + { |
|
| 1207 | + $topic = $topicOptions['id']; |
|
| 1208 | + } |
|
| 1065 | 1209 | } |
| 1066 | 1210 | |
| 1067 | 1211 | // Trigger the after_save_post event |
@@ -1075,27 +1219,41 @@ discard block |
||
| 1075 | 1219 | |
| 1076 | 1220 | // Returning to the topic? |
| 1077 | 1221 | if (!empty($_REQUEST['goback'])) |
| 1078 | - $board_list[] = $board; |
|
| 1222 | + { |
|
| 1223 | + $board_list[] = $board; |
|
| 1224 | + } |
|
| 1079 | 1225 | |
| 1080 | 1226 | if (!empty($board_list)) |
| 1081 | - markBoardsRead($board_list, false, false); |
|
| 1227 | + { |
|
| 1228 | + markBoardsRead($board_list, false, false); |
|
| 1229 | + } |
|
| 1082 | 1230 | } |
| 1083 | 1231 | |
| 1084 | 1232 | // Turn notification on or off. |
| 1085 | 1233 | if (!empty($_POST['notify']) && allowedTo('mark_any_notify')) |
| 1086 | - setTopicNotification($user_info['id'], $topic, true); |
|
| 1234 | + { |
|
| 1235 | + setTopicNotification($user_info['id'], $topic, true); |
|
| 1236 | + } |
|
| 1087 | 1237 | elseif (!$newTopic) |
| 1088 | - setTopicNotification($user_info['id'], $topic, false); |
|
| 1238 | + { |
|
| 1239 | + setTopicNotification($user_info['id'], $topic, false); |
|
| 1240 | + } |
|
| 1089 | 1241 | |
| 1090 | 1242 | // Log an act of moderation - modifying. |
| 1091 | 1243 | if (!empty($moderationAction)) |
| 1092 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $msgInfo['id_member'], 'board' => $board)); |
|
| 1244 | + { |
|
| 1245 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $msgInfo['id_member'], 'board' => $board)); |
|
| 1246 | + } |
|
| 1093 | 1247 | |
| 1094 | 1248 | if (isset($_POST['lock']) && $_POST['lock'] != 2) |
| 1095 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 1249 | + { |
|
| 1250 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 1251 | + } |
|
| 1096 | 1252 | |
| 1097 | 1253 | if (isset($_POST['sticky'])) |
| 1098 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 1254 | + { |
|
| 1255 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 1256 | + } |
|
| 1099 | 1257 | |
| 1100 | 1258 | // Notify any members who have notification turned on for this topic/board - only do this if it's going to be approved(!) |
| 1101 | 1259 | if ($becomesApproved) |
@@ -1119,29 +1277,43 @@ discard block |
||
| 1119 | 1277 | { |
| 1120 | 1278 | // Only send it to everyone if the topic is approved, otherwise just to the topic starter if they want it. |
| 1121 | 1279 | if ($topic_info['approved']) |
| 1122 | - sendNotifications($topic, 'reply'); |
|
| 1123 | - else |
|
| 1124 | - sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']); |
|
| 1280 | + { |
|
| 1281 | + sendNotifications($topic, 'reply'); |
|
| 1282 | + } |
|
| 1283 | + else { |
|
| 1284 | + sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']); |
|
| 1285 | + } |
|
| 1125 | 1286 | } |
| 1126 | 1287 | } |
| 1127 | 1288 | |
| 1128 | 1289 | if ($board_info['num_topics'] == 0) |
| 1129 | - Cache::instance()->remove('board-' . $board); |
|
| 1290 | + { |
|
| 1291 | + Cache::instance()->remove('board-' . $board); |
|
| 1292 | + } |
|
| 1130 | 1293 | |
| 1131 | 1294 | if (!empty($_POST['announce_topic'])) |
| 1132 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 1295 | + { |
|
| 1296 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 1297 | + } |
|
| 1133 | 1298 | |
| 1134 | 1299 | if (!empty($_POST['move']) && allowedTo('move_any')) |
| 1135 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 1300 | + { |
|
| 1301 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 1302 | + } |
|
| 1136 | 1303 | |
| 1137 | 1304 | // Return to post if the mod is on. |
| 1138 | 1305 | if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
| 1139 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 1306 | + { |
|
| 1307 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 1308 | + } |
|
| 1140 | 1309 | elseif (!empty($_REQUEST['goback'])) |
| 1141 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 1310 | + { |
|
| 1311 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 1312 | + } |
|
| 1142 | 1313 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 1143 | - else |
|
| 1144 | - redirectexit('board=' . $board . '.0'); |
|
| 1314 | + else { |
|
| 1315 | + redirectexit('board=' . $board . '.0'); |
|
| 1316 | + } |
|
| 1145 | 1317 | } |
| 1146 | 1318 | |
| 1147 | 1319 | /** |
@@ -1166,7 +1338,9 @@ discard block |
||
| 1166 | 1338 | |
| 1167 | 1339 | $context['sub_template'] = 'quotefast'; |
| 1168 | 1340 | if (!empty($row)) |
| 1169 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 1341 | + { |
|
| 1342 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 1343 | + } |
|
| 1170 | 1344 | |
| 1171 | 1345 | if (!empty($can_view_post)) |
| 1172 | 1346 | { |
@@ -1214,12 +1388,13 @@ discard block |
||
| 1214 | 1388 | 'subject' => '', |
| 1215 | 1389 | ); |
| 1216 | 1390 | } |
| 1217 | - else |
|
| 1218 | - $context['quote'] = array( |
|
| 1391 | + else { |
|
| 1392 | + $context['quote'] = array( |
|
| 1219 | 1393 | 'xml' => '', |
| 1220 | 1394 | 'mozilla' => '', |
| 1221 | 1395 | 'text' => '', |
| 1222 | 1396 | ); |
| 1397 | + } |
|
| 1223 | 1398 | } |
| 1224 | 1399 | |
| 1225 | 1400 | /** |
@@ -1233,35 +1408,49 @@ discard block |
||
| 1233 | 1408 | |
| 1234 | 1409 | // We have to have a topic! |
| 1235 | 1410 | if (empty($topic)) |
| 1236 | - obExit(false); |
|
| 1411 | + { |
|
| 1412 | + obExit(false); |
|
| 1413 | + } |
|
| 1237 | 1414 | |
| 1238 | 1415 | checkSession('get'); |
| 1239 | 1416 | |
| 1240 | 1417 | $row = getTopicInfoByMsg($topic, empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg']); |
| 1241 | 1418 | |
| 1242 | 1419 | if (empty($row)) |
| 1243 | - throw new Elk_Exception('no_board', false); |
|
| 1420 | + { |
|
| 1421 | + throw new Elk_Exception('no_board', false); |
|
| 1422 | + } |
|
| 1244 | 1423 | |
| 1245 | 1424 | // Change either body or subject requires permissions to modify messages. |
| 1246 | 1425 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 1247 | 1426 | { |
| 1248 | 1427 | if (!empty($row['locked'])) |
| 1249 | - isAllowedTo('moderate_board'); |
|
| 1428 | + { |
|
| 1429 | + isAllowedTo('moderate_board'); |
|
| 1430 | + } |
|
| 1250 | 1431 | |
| 1251 | 1432 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1252 | 1433 | { |
| 1253 | 1434 | if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
| 1254 | - throw new Elk_Exception('modify_post_time_passed', false); |
|
| 1435 | + { |
|
| 1436 | + throw new Elk_Exception('modify_post_time_passed', false); |
|
| 1437 | + } |
|
| 1255 | 1438 | elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
| 1256 | - isAllowedTo('modify_replies'); |
|
| 1257 | - else |
|
| 1258 | - isAllowedTo('modify_own'); |
|
| 1439 | + { |
|
| 1440 | + isAllowedTo('modify_replies'); |
|
| 1441 | + } |
|
| 1442 | + else { |
|
| 1443 | + isAllowedTo('modify_own'); |
|
| 1444 | + } |
|
| 1259 | 1445 | } |
| 1260 | 1446 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 1261 | 1447 | elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1262 | - isAllowedTo('modify_replies'); |
|
| 1263 | - else |
|
| 1264 | - isAllowedTo('modify_any'); |
|
| 1448 | + { |
|
| 1449 | + isAllowedTo('modify_replies'); |
|
| 1450 | + } |
|
| 1451 | + else { |
|
| 1452 | + isAllowedTo('modify_any'); |
|
| 1453 | + } |
|
| 1265 | 1454 | |
| 1266 | 1455 | // Only log this action if it wasn't your message. |
| 1267 | 1456 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -1273,7 +1462,9 @@ discard block |
||
| 1273 | 1462 | |
| 1274 | 1463 | // Maximum number of characters. |
| 1275 | 1464 | if (Util::strlen($_POST['subject']) > 100) |
| 1276 | - $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
| 1465 | + { |
|
| 1466 | + $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
| 1467 | + } |
|
| 1277 | 1468 | } |
| 1278 | 1469 | elseif (isset($_POST['subject'])) |
| 1279 | 1470 | { |
@@ -1314,7 +1505,9 @@ discard block |
||
| 1314 | 1505 | } |
| 1315 | 1506 | |
| 1316 | 1507 | if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
| 1317 | - unset($_POST['sticky']); |
|
| 1508 | + { |
|
| 1509 | + unset($_POST['sticky']); |
|
| 1510 | + } |
|
| 1318 | 1511 | |
| 1319 | 1512 | if (!$this->_post_errors->hasErrors()) |
| 1320 | 1513 | { |
@@ -1332,7 +1525,9 @@ discard block |
||
| 1332 | 1525 | { |
| 1333 | 1526 | $_POST['message'] = str_replace('@' . $member['real_name'], '[member=' . $member['id_member'] . ']' . $member['real_name'] . '[/member]', $_POST['message'], $replacements); |
| 1334 | 1527 | if ($replacements > 0) |
| 1335 | - $actually_mentioned[] = $member['id_member']; |
|
| 1528 | + { |
|
| 1529 | + $actually_mentioned[] = $member['id_member']; |
|
| 1530 | + } |
|
| 1336 | 1531 | } |
| 1337 | 1532 | } |
| 1338 | 1533 | |
@@ -1376,8 +1571,9 @@ discard block |
||
| 1376 | 1571 | } |
| 1377 | 1572 | } |
| 1378 | 1573 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 1379 | - else |
|
| 1380 | - $moderationAction = false; |
|
| 1574 | + else { |
|
| 1575 | + $moderationAction = false; |
|
| 1576 | + } |
|
| 1381 | 1577 | |
| 1382 | 1578 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 1383 | 1579 | |
@@ -1398,7 +1594,9 @@ discard block |
||
| 1398 | 1594 | } |
| 1399 | 1595 | |
| 1400 | 1596 | if (!empty($moderationAction)) |
| 1401 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 1597 | + { |
|
| 1598 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 1599 | + } |
|
| 1402 | 1600 | } |
| 1403 | 1601 | |
| 1404 | 1602 | if (isset($_REQUEST['xml'])) |
@@ -1454,8 +1652,9 @@ discard block |
||
| 1454 | 1652 | $context['message']['errors'] = $this->_post_errors->prepareErrors(); |
| 1455 | 1653 | } |
| 1456 | 1654 | } |
| 1457 | - else |
|
| 1458 | - obExit(false); |
|
| 1655 | + else { |
|
| 1656 | + obExit(false); |
|
| 1657 | + } |
|
| 1459 | 1658 | } |
| 1460 | 1659 | |
| 1461 | 1660 | /** |
@@ -1475,34 +1674,47 @@ discard block |
||
| 1475 | 1674 | { |
| 1476 | 1675 | // New topics are by default not locked. |
| 1477 | 1676 | if (empty($lock)) |
| 1478 | - return null; |
|
| 1677 | + { |
|
| 1678 | + return null; |
|
| 1679 | + } |
|
| 1479 | 1680 | // Besides, you need permission. |
| 1480 | 1681 | elseif (!allowedTo(array('lock_any', 'lock_own'))) |
| 1481 | - return null; |
|
| 1682 | + { |
|
| 1683 | + return null; |
|
| 1684 | + } |
|
| 1482 | 1685 | // A moderator-lock (1) can override a user-lock (2). |
| 1483 | - else |
|
| 1484 | - return allowedTo('lock_any') ? 1 : 2; |
|
| 1686 | + else { |
|
| 1687 | + return allowedTo('lock_any') ? 1 : 2; |
|
| 1688 | + } |
|
| 1485 | 1689 | } |
| 1486 | 1690 | |
| 1487 | 1691 | // Nothing changes to the lock status. |
| 1488 | 1692 | if ((empty($lock) && empty($topic_info['locked'])) || (!empty($lock) && !empty($topic_info['locked']))) |
| 1489 | - return null; |
|
| 1693 | + { |
|
| 1694 | + return null; |
|
| 1695 | + } |
|
| 1490 | 1696 | // You're simply not allowed to (un)lock this. |
| 1491 | 1697 | elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
| 1492 | - return null; |
|
| 1698 | + { |
|
| 1699 | + return null; |
|
| 1700 | + } |
|
| 1493 | 1701 | // You're only allowed to lock your own topics. |
| 1494 | 1702 | elseif (!allowedTo('lock_any')) |
| 1495 | 1703 | { |
| 1496 | 1704 | // You're not allowed to break a moderator's lock. |
| 1497 | 1705 | if ($topic_info['locked'] == 1) |
| 1498 | - return null; |
|
| 1706 | + { |
|
| 1707 | + return null; |
|
| 1708 | + } |
|
| 1499 | 1709 | // Lock it with a soft lock or unlock it. |
| 1500 | - else |
|
| 1501 | - $lock = empty($lock) ? 0 : 2; |
|
| 1710 | + else { |
|
| 1711 | + $lock = empty($lock) ? 0 : 2; |
|
| 1712 | + } |
|
| 1502 | 1713 | } |
| 1503 | 1714 | // You must be the moderator. |
| 1504 | - else |
|
| 1505 | - $lock = empty($lock) ? 0 : 1; |
|
| 1715 | + else { |
|
| 1716 | + $lock = empty($lock) ? 0 : 1; |
|
| 1717 | + } |
|
| 1506 | 1718 | |
| 1507 | 1719 | return $lock; |
| 1508 | 1720 | } |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | // Let's define the name of the class so that we will be able to use it in the instantiations |
| 22 | 22 | if (!defined('DB_TYPE')) |
| 23 | +{ |
|
| 23 | 24 | define('DB_TYPE', 'MySQL'); |
| 25 | +} |
|
| 24 | 26 | |
| 25 | 27 | /** |
| 26 | 28 | * SQL database class, implements database class to control mysql functions |
@@ -54,30 +56,41 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | // Initialize the instance... if not done already! |
| 56 | 58 | if (self::$_db === null) |
| 57 | - self::$_db = new self(); |
|
| 59 | + { |
|
| 60 | + self::$_db = new self(); |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | // Non-standard port |
| 60 | 64 | if (!empty($db_options['port'])) |
| 61 | - $db_port = (int) $db_options['port']; |
|
| 62 | - else |
|
| 63 | - $db_port = 0; |
|
| 65 | + { |
|
| 66 | + $db_port = (int) $db_options['port']; |
|
| 67 | + } |
|
| 68 | + else { |
|
| 69 | + $db_port = 0; |
|
| 70 | + } |
|
| 64 | 71 | |
| 65 | 72 | // PHP 8.1 default is to throw exceptions, this reverts it to the <=php8 semantics |
| 66 | 73 | mysqli_report(MYSQLI_REPORT_OFF); |
| 67 | 74 | |
| 68 | 75 | // Select the database. Maybe. |
| 69 | 76 | if (empty($db_options['dont_select_db'])) |
| 70 | - $connection = @mysqli_connect((!empty($db_options['persist']) ? 'p:' : '') . $db_server, $db_user, $db_passwd, $db_name, $db_port); |
|
| 71 | - else |
|
| 72 | - $connection = @mysqli_connect((!empty($db_options['persist']) ? 'p:' : '') . $db_server, $db_user, $db_passwd, '', $db_port); |
|
| 77 | + { |
|
| 78 | + $connection = @mysqli_connect((!empty($db_options['persist']) ? 'p:' : '') . $db_server, $db_user, $db_passwd, $db_name, $db_port); |
|
| 79 | + } |
|
| 80 | + else { |
|
| 81 | + $connection = @mysqli_connect((!empty($db_options['persist']) ? 'p:' : '') . $db_server, $db_user, $db_passwd, '', $db_port); |
|
| 82 | + } |
|
| 73 | 83 | |
| 74 | 84 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 75 | 85 | if (!$connection) |
| 76 | 86 | { |
| 77 | 87 | if (!empty($db_options['non_fatal'])) |
| 78 | - return null; |
|
| 79 | - else |
|
| 80 | - Errors::instance()->display_db_error(); |
|
| 88 | + { |
|
| 89 | + return null; |
|
| 90 | + } |
|
| 91 | + else { |
|
| 92 | + Errors::instance()->display_db_error(); |
|
| 93 | + } |
|
| 81 | 94 | } |
| 82 | 95 | |
| 83 | 96 | self::$_db->_connection = $connection; |
@@ -160,17 +173,22 @@ discard block |
||
| 160 | 173 | $this->_query_count++; |
| 161 | 174 | |
| 162 | 175 | if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
| 163 | - $this->error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 176 | + { |
|
| 177 | + $this->error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 178 | + } |
|
| 164 | 179 | |
| 165 | 180 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 166 | 181 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && strpos($db_string, 'INSERT INTO') === false) |
| 167 | 182 | { |
| 168 | 183 | // Add before LIMIT |
| 169 | 184 | if ($pos = strpos($db_string, 'LIMIT ')) |
| 170 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 171 | - else |
|
| 172 | - // Append it. |
|
| 185 | + { |
|
| 186 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 187 | + } |
|
| 188 | + else { |
|
| 189 | + // Append it. |
|
| 173 | 190 | $db_string .= "\n\t\t\tORDER BY null"; |
| 191 | + } |
|
| 174 | 192 | } |
| 175 | 193 | |
| 176 | 194 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -222,7 +240,9 @@ discard block |
||
| 222 | 240 | { |
| 223 | 241 | $pos = strpos($db_string, '\'', $pos + 1); |
| 224 | 242 | if ($pos === false) |
| 225 | - break; |
|
| 243 | + { |
|
| 244 | + break; |
|
| 245 | + } |
|
| 226 | 246 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 227 | 247 | |
| 228 | 248 | while (true) |
@@ -230,7 +250,9 @@ discard block |
||
| 230 | 250 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 231 | 251 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 232 | 252 | if ($pos1 === false) |
| 233 | - break; |
|
| 253 | + { |
|
| 254 | + break; |
|
| 255 | + } |
|
| 234 | 256 | elseif ($pos2 === false || $pos2 > $pos1) |
| 235 | 257 | { |
| 236 | 258 | $pos = $pos1; |
@@ -249,21 +271,32 @@ discard block |
||
| 249 | 271 | |
| 250 | 272 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 251 | 273 | if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
| 252 | - $fail = true; |
|
| 274 | + { |
|
| 275 | + $fail = true; |
|
| 276 | + } |
|
| 253 | 277 | // Trying to change passwords, slow us down, or something? |
| 254 | 278 | elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
| 255 | - $fail = true; |
|
| 279 | + { |
|
| 280 | + $fail = true; |
|
| 281 | + } |
|
| 256 | 282 | elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
| 257 | - $fail = true; |
|
| 283 | + { |
|
| 284 | + $fail = true; |
|
| 285 | + } |
|
| 258 | 286 | |
| 259 | 287 | if (!empty($fail) && function_exists('log_error')) |
| 260 | - $this->error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 288 | + { |
|
| 289 | + $this->error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 290 | + } |
|
| 261 | 291 | } |
| 262 | 292 | |
| 263 | 293 | if ($this->_unbuffered === false) |
| 264 | - $ret = @mysqli_query($connection, $db_string); |
|
| 265 | - else |
|
| 266 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 294 | + { |
|
| 295 | + $ret = @mysqli_query($connection, $db_string); |
|
| 296 | + } |
|
| 297 | + else { |
|
| 298 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 299 | + } |
|
| 267 | 300 | |
| 268 | 301 | // @deprecated since 1.1 - use skip_next_error method |
| 269 | 302 | if (!empty($db_values['db_error_skip'])) |
@@ -384,11 +417,17 @@ discard block |
||
| 384 | 417 | $connection = $connection === null ? $this->_connection : $connection; |
| 385 | 418 | |
| 386 | 419 | if ($type == 'begin') |
| 387 | - return @mysqli_query($connection, 'BEGIN'); |
|
| 420 | + { |
|
| 421 | + return @mysqli_query($connection, 'BEGIN'); |
|
| 422 | + } |
|
| 388 | 423 | elseif ($type == 'rollback') |
| 389 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
| 424 | + { |
|
| 425 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
| 426 | + } |
|
| 390 | 427 | elseif ($type == 'commit') |
| 391 | - return @mysqli_query($connection, 'COMMIT'); |
|
| 428 | + { |
|
| 429 | + return @mysqli_query($connection, 'COMMIT'); |
|
| 430 | + } |
|
| 392 | 431 | |
| 393 | 432 | return false; |
| 394 | 433 | } |
@@ -404,7 +443,9 @@ discard block |
||
| 404 | 443 | $connection = $connection === null ? $this->_connection : $connection; |
| 405 | 444 | |
| 406 | 445 | if (is_object($connection)) |
| 407 | - return mysqli_error($connection); |
|
| 446 | + { |
|
| 447 | + return mysqli_error($connection); |
|
| 448 | + } |
|
| 408 | 449 | } |
| 409 | 450 | |
| 410 | 451 | /** |
@@ -479,7 +520,9 @@ discard block |
||
| 479 | 520 | $modSettings['cache_enable'] = '1'; |
| 480 | 521 | |
| 481 | 522 | if (Cache::instance()->getVar($temp, 'db_last_error', 600)) |
| 482 | - $db_last_error = max($db_last_error, $temp); |
|
| 523 | + { |
|
| 524 | + $db_last_error = max($db_last_error, $temp); |
|
| 525 | + } |
|
| 483 | 526 | |
| 484 | 527 | if ($db_last_error < time() - 3600 * 24 * 3) |
| 485 | 528 | { |
@@ -496,7 +539,9 @@ discard block |
||
| 496 | 539 | { |
| 497 | 540 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 498 | 541 | if (trim($table) != '') |
| 499 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 542 | + { |
|
| 543 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 544 | + } |
|
| 500 | 545 | } |
| 501 | 546 | } |
| 502 | 547 | |
@@ -506,7 +551,9 @@ discard block |
||
| 506 | 551 | elseif ($query_errno == 1016) |
| 507 | 552 | { |
| 508 | 553 | if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
| 509 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 554 | + { |
|
| 555 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 556 | + } |
|
| 510 | 557 | } |
| 511 | 558 | // Indexes crashed. Should be easy to fix! |
| 512 | 559 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -527,7 +574,9 @@ discard block |
||
| 527 | 574 | // Make a note of the REPAIR... |
| 528 | 575 | Cache::instance()->put('db_last_error', time(), 600); |
| 529 | 576 | if (!Cache::instance()->getVar($temp, 'db_last_error', 600)) |
| 530 | - updateDbLastError(time()); |
|
| 577 | + { |
|
| 578 | + updateDbLastError(time()); |
|
| 579 | + } |
|
| 531 | 580 | |
| 532 | 581 | // Attempt to find and repair the broken table. |
| 533 | 582 | foreach ($fix_tables as $table) |
@@ -544,10 +593,13 @@ discard block |
||
| 544 | 593 | // Try the query again...? |
| 545 | 594 | $ret = $this->query('', $db_string, false, false); |
| 546 | 595 | if ($ret !== false) |
| 547 | - return $ret; |
|
| 596 | + { |
|
| 597 | + return $ret; |
|
| 598 | + } |
|
| 599 | + } |
|
| 600 | + else { |
|
| 601 | + $modSettings['cache_enable'] = $old_cache; |
|
| 548 | 602 | } |
| 549 | - else |
|
| 550 | - $modSettings['cache_enable'] = $old_cache; |
|
| 551 | 603 | |
| 552 | 604 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 553 | 605 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -557,11 +609,15 @@ discard block |
||
| 557 | 609 | { |
| 558 | 610 | // Are we in SSI mode? If so try that username and password first |
| 559 | 611 | if (ELK == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 560 | - $new_connection = @mysqli_connect((!empty($db_persist) ? 'p:' : '') . $db_server, $ssi_db_user, $ssi_db_passwd, $db_name); |
|
| 612 | + { |
|
| 613 | + $new_connection = @mysqli_connect((!empty($db_persist) ? 'p:' : '') . $db_server, $ssi_db_user, $ssi_db_passwd, $db_name); |
|
| 614 | + } |
|
| 561 | 615 | |
| 562 | 616 | // Fall back to the regular username and password if need be |
| 563 | 617 | if (!$new_connection) |
| 564 | - $new_connection = @mysqli_connect((!empty($db_persist) ? 'p:' : '') . $db_server, $db_user, $db_passwd, $db_name); |
|
| 618 | + { |
|
| 619 | + $new_connection = @mysqli_connect((!empty($db_persist) ? 'p:' : '') . $db_server, $db_user, $db_passwd, $db_name); |
|
| 620 | + } |
|
| 565 | 621 | } |
| 566 | 622 | |
| 567 | 623 | if ($new_connection) |
@@ -575,23 +631,31 @@ discard block |
||
| 575 | 631 | |
| 576 | 632 | $new_errno = mysqli_errno($new_connection); |
| 577 | 633 | if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
| 578 | - break; |
|
| 634 | + { |
|
| 635 | + break; |
|
| 636 | + } |
|
| 579 | 637 | } |
| 580 | 638 | |
| 581 | 639 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 582 | 640 | if ($ret !== false) |
| 583 | - return $ret; |
|
| 641 | + { |
|
| 642 | + return $ret; |
|
| 643 | + } |
|
| 584 | 644 | } |
| 585 | 645 | } |
| 586 | 646 | // Are they out of space, perhaps? |
| 587 | 647 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 588 | 648 | { |
| 589 | 649 | if (!isset($txt)) |
| 590 | - $query_error .= ' - check database storage space.'; |
|
| 650 | + { |
|
| 651 | + $query_error .= ' - check database storage space.'; |
|
| 652 | + } |
|
| 591 | 653 | else |
| 592 | 654 | { |
| 593 | 655 | if (!isset($txt['mysql_error_space'])) |
| 594 | - loadLanguage('Errors'); |
|
| 656 | + { |
|
| 657 | + loadLanguage('Errors'); |
|
| 658 | + } |
|
| 595 | 659 | |
| 596 | 660 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 597 | 661 | } |
@@ -600,21 +664,30 @@ discard block |
||
| 600 | 664 | |
| 601 | 665 | // Nothing's defined yet... just die with it. |
| 602 | 666 | if (empty($context) || empty($txt)) |
| 603 | - die($query_error); |
|
| 667 | + { |
|
| 668 | + die($query_error); |
|
| 669 | + } |
|
| 604 | 670 | |
| 605 | 671 | // Show an error message, if possible. |
| 606 | 672 | $context['error_title'] = $txt['database_error']; |
| 607 | 673 | if (allowedTo('admin_forum')) |
| 608 | - $context['error_message'] = nl2br($query_error) . '<br />' . $txt['file'] . ': ' . $file . '<br />' . $txt['line'] . ': ' . $line; |
|
| 609 | - else |
|
| 610 | - $context['error_message'] = $txt['try_again']; |
|
| 674 | + { |
|
| 675 | + $context['error_message'] = nl2br($query_error) . '<br />' . $txt['file'] . ': ' . $file . '<br />' . $txt['line'] . ': ' . $line; |
|
| 676 | + } |
|
| 677 | + else { |
|
| 678 | + $context['error_message'] = $txt['try_again']; |
|
| 679 | + } |
|
| 611 | 680 | |
| 612 | 681 | // Add database version that we know of, for the admin to know. (and ask for support) |
| 613 | 682 | if (allowedTo('admin_forum')) |
| 614 | - $context['error_message'] .= '<br /><br />' . sprintf($txt['database_error_versions'], $modSettings['elkVersion']); |
|
| 683 | + { |
|
| 684 | + $context['error_message'] .= '<br /><br />' . sprintf($txt['database_error_versions'], $modSettings['elkVersion']); |
|
| 685 | + } |
|
| 615 | 686 | |
| 616 | 687 | if (allowedTo('admin_forum') && $db_show_debug === true) |
| 617 | - $context['error_message'] .= '<br /><br />' . nl2br($db_string); |
|
| 688 | + { |
|
| 689 | + $context['error_message'] .= '<br /><br />' . nl2br($db_string); |
|
| 690 | + } |
|
| 618 | 691 | |
| 619 | 692 | // It's already been logged... don't log it again. |
| 620 | 693 | throw new Elk_Exception($context['error_message'], false); |
@@ -640,11 +713,15 @@ discard block |
||
| 640 | 713 | |
| 641 | 714 | // With nothing to insert, simply return. |
| 642 | 715 | if (empty($data)) |
| 643 | - return; |
|
| 716 | + { |
|
| 717 | + return; |
|
| 718 | + } |
|
| 644 | 719 | |
| 645 | 720 | // Inserting data as a single row can be done as a single array. |
| 646 | 721 | if (!is_array($data[array_rand($data)])) |
| 647 | - $data = array($data); |
|
| 722 | + { |
|
| 723 | + $data = array($data); |
|
| 724 | + } |
|
| 648 | 725 | |
| 649 | 726 | // Replace the prefix holder with the actual prefix. |
| 650 | 727 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -655,9 +732,12 @@ discard block |
||
| 655 | 732 | { |
| 656 | 733 | // Are we restricting the length? |
| 657 | 734 | if (strpos($type, 'string-') !== false) |
| 658 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 659 | - else |
|
| 660 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 735 | + { |
|
| 736 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 737 | + } |
|
| 738 | + else { |
|
| 739 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 740 | + } |
|
| 661 | 741 | } |
| 662 | 742 | $insertData = substr($insertData, 0, -2) . ')'; |
| 663 | 743 | |
@@ -749,7 +829,9 @@ discard block |
||
| 749 | 829 | $num_rows = $this->num_rows($result); |
| 750 | 830 | |
| 751 | 831 | if ($num_rows == 0) |
| 752 | - return ''; |
|
| 832 | + { |
|
| 833 | + return ''; |
|
| 834 | + } |
|
| 753 | 835 | |
| 754 | 836 | if ($new_table) |
| 755 | 837 | { |
@@ -770,11 +852,16 @@ discard block |
||
| 770 | 852 | { |
| 771 | 853 | // Try to figure out the type of each field. (NULL, number, or 'string'.) |
| 772 | 854 | if (!isset($item)) |
| 773 | - $field_list[] = 'NULL'; |
|
| 855 | + { |
|
| 856 | + $field_list[] = 'NULL'; |
|
| 857 | + } |
|
| 774 | 858 | elseif (is_numeric($item) && (int) $item == $item) |
| 775 | - $field_list[] = $item; |
|
| 776 | - else |
|
| 777 | - $field_list[] = '\'' . $this->escape_string($item) . '\''; |
|
| 859 | + { |
|
| 860 | + $field_list[] = $item; |
|
| 861 | + } |
|
| 862 | + else { |
|
| 863 | + $field_list[] = '\'' . $this->escape_string($item) . '\''; |
|
| 864 | + } |
|
| 778 | 865 | } |
| 779 | 866 | |
| 780 | 867 | $data .= '(' . implode(', ', $field_list) . '),' . $crlf . "\t"; |
@@ -829,7 +916,9 @@ discard block |
||
| 829 | 916 | { |
| 830 | 917 | // Make a special case of auto-timestamp. |
| 831 | 918 | if ($row['Default'] == 'CURRENT_TIMESTAMP') |
| 832 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 919 | + { |
|
| 920 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 921 | + } |
|
| 833 | 922 | // Text shouldn't have a default. |
| 834 | 923 | elseif ($row['Default'] !== null) |
| 835 | 924 | { |
@@ -865,13 +954,18 @@ discard block |
||
| 865 | 954 | |
| 866 | 955 | // Is this the first column in the index? |
| 867 | 956 | if (empty($indexes[$row['Key_name']])) |
| 868 | - $indexes[$row['Key_name']] = array(); |
|
| 957 | + { |
|
| 958 | + $indexes[$row['Key_name']] = array(); |
|
| 959 | + } |
|
| 869 | 960 | |
| 870 | 961 | // A sub part, like only indexing 15 characters of a varchar. |
| 871 | 962 | if (!empty($row['Sub_part'])) |
| 872 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 873 | - else |
|
| 874 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 963 | + { |
|
| 964 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 965 | + } |
|
| 966 | + else { |
|
| 967 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 968 | + } |
|
| 875 | 969 | } |
| 876 | 970 | $this->free_result($result); |
| 877 | 971 | |
@@ -971,7 +1065,9 @@ discard block |
||
| 971 | 1065 | |
| 972 | 1066 | // Old school or no school? |
| 973 | 1067 | if ($request) |
| 974 | - return $request; |
|
| 1068 | + { |
|
| 1069 | + return $request; |
|
| 1070 | + } |
|
| 975 | 1071 | } |
| 976 | 1072 | |
| 977 | 1073 | // At this point, the quick method failed. |
@@ -997,7 +1093,9 @@ discard block |
||
| 997 | 1093 | { |
| 998 | 1094 | // Get the name of the auto_increment column. |
| 999 | 1095 | if (strpos($l, 'auto_increment')) |
| 1000 | - $auto_inc = trim($l); |
|
| 1096 | + { |
|
| 1097 | + $auto_inc = trim($l); |
|
| 1098 | + } |
|
| 1001 | 1099 | |
| 1002 | 1100 | // For the engine type, see if we can work out what it is. |
| 1003 | 1101 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -1006,29 +1104,42 @@ discard block |
||
| 1006 | 1104 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
| 1007 | 1105 | |
| 1008 | 1106 | if (!empty($match[1])) |
| 1009 | - $engine = $match[1]; |
|
| 1107 | + { |
|
| 1108 | + $engine = $match[1]; |
|
| 1109 | + } |
|
| 1010 | 1110 | |
| 1011 | 1111 | if (!empty($match[2])) |
| 1012 | - $engine = $match[2]; |
|
| 1112 | + { |
|
| 1113 | + $engine = $match[2]; |
|
| 1114 | + } |
|
| 1013 | 1115 | |
| 1014 | 1116 | if (!empty($match[5])) |
| 1015 | - $charset = $match[5]; |
|
| 1117 | + { |
|
| 1118 | + $charset = $match[5]; |
|
| 1119 | + } |
|
| 1016 | 1120 | |
| 1017 | 1121 | if (!empty($match[7])) |
| 1018 | - $collate = $match[7]; |
|
| 1122 | + { |
|
| 1123 | + $collate = $match[7]; |
|
| 1124 | + } |
|
| 1019 | 1125 | } |
| 1020 | 1126 | |
| 1021 | 1127 | // Skip everything but keys... |
| 1022 | 1128 | if (strpos($l, 'KEY') === false) |
| 1023 | - unset($create[$k]); |
|
| 1129 | + { |
|
| 1130 | + unset($create[$k]); |
|
| 1131 | + } |
|
| 1024 | 1132 | } |
| 1025 | 1133 | |
| 1026 | 1134 | if (!empty($create)) |
| 1027 | - $create = '( |
|
| 1135 | + { |
|
| 1136 | + $create = '( |
|
| 1028 | 1137 | ' . implode(' |
| 1029 | 1138 | ', $create) . ')'; |
| 1030 | - else |
|
| 1031 | - $create = ''; |
|
| 1139 | + } |
|
| 1140 | + else { |
|
| 1141 | + $create = ''; |
|
| 1142 | + } |
|
| 1032 | 1143 | |
| 1033 | 1144 | $request = $this->query('', ' |
| 1034 | 1145 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -1048,7 +1159,9 @@ discard block |
||
| 1048 | 1159 | if ($auto_inc != '') |
| 1049 | 1160 | { |
| 1050 | 1161 | if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
| 1051 | - $auto_inc = substr($auto_inc, 0, -1); |
|
| 1162 | + { |
|
| 1163 | + $auto_inc = substr($auto_inc, 0, -1); |
|
| 1164 | + } |
|
| 1052 | 1165 | |
| 1053 | 1166 | $this->query('', ' |
| 1054 | 1167 | ALTER TABLE {raw:backup_table} |
@@ -84,22 +84,34 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // Connection gone??? This should *never* happen at this point, yet it does :'( |
| 86 | 86 | if (!$this->validConnection($this->_db_callback_connection)) |
| 87 | - Errors::instance()->display_db_error(); |
|
| 87 | + { |
|
| 88 | + Errors::instance()->display_db_error(); |
|
| 89 | + } |
|
| 88 | 90 | |
| 89 | 91 | if ($matches[1] === 'db_prefix') |
| 90 | - return $db_prefix; |
|
| 92 | + { |
|
| 93 | + return $db_prefix; |
|
| 94 | + } |
|
| 91 | 95 | |
| 92 | 96 | if ($matches[1] === 'query_see_board') |
| 93 | - return $user_info['query_see_board']; |
|
| 97 | + { |
|
| 98 | + return $user_info['query_see_board']; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | if ($matches[1] === 'query_wanna_see_board') |
| 96 | - return $user_info['query_wanna_see_board']; |
|
| 102 | + { |
|
| 103 | + return $user_info['query_wanna_see_board']; |
|
| 104 | + } |
|
| 97 | 105 | |
| 98 | 106 | if (!isset($matches[2])) |
| 99 | - $this->error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 107 | + { |
|
| 108 | + $this->error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 109 | + } |
|
| 100 | 110 | |
| 101 | 111 | if (!isset($this->_db_callback_values[$matches[2]])) |
| 102 | - $this->error_backtrace('The database value you\'re trying to insert does not exist: ' . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8'), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 112 | + { |
|
| 113 | + $this->error_backtrace('The database value you\'re trying to insert does not exist: ' . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8'), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 114 | + } |
|
| 103 | 115 | |
| 104 | 116 | $replacement = $this->_db_callback_values[$matches[2]]; |
| 105 | 117 | |
@@ -174,7 +186,9 @@ discard block |
||
| 174 | 186 | |
| 175 | 187 | $results = $seeds !== null ? $seeds : array(); |
| 176 | 188 | while ($row = $this->fetch_assoc($request)) |
| 177 | - $results[] = $row; |
|
| 189 | + { |
|
| 190 | + $results[] = $row; |
|
| 191 | + } |
|
| 178 | 192 | $this->free_result($request); |
| 179 | 193 | |
| 180 | 194 | return $results; |
@@ -186,13 +200,17 @@ discard block |
||
| 186 | 200 | public function fetchQueryCallback($db_string, $db_values = array(), $callback = '', $seeds = null) |
| 187 | 201 | { |
| 188 | 202 | if ($callback === '') |
| 189 | - return $this->fetchQuery($db_string, $db_values); |
|
| 203 | + { |
|
| 204 | + return $this->fetchQuery($db_string, $db_values); |
|
| 205 | + } |
|
| 190 | 206 | |
| 191 | 207 | $request = $this->query('', $db_string, $db_values); |
| 192 | 208 | |
| 193 | 209 | $results = $seeds !== null ? $seeds : array(); |
| 194 | 210 | while ($row = $this->fetch_assoc($request)) |
| 195 | - $results[] = $callback($row); |
|
| 211 | + { |
|
| 212 | + $results[] = $callback($row); |
|
| 213 | + } |
|
| 196 | 214 | $this->free_result($request); |
| 197 | 215 | |
| 198 | 216 | return $results; |
@@ -210,14 +228,18 @@ discard block |
||
| 210 | 228 | $is_numeric = array_filter(array_keys($values), 'is_numeric'); |
| 211 | 229 | |
| 212 | 230 | if (!empty($is_numeric)) |
| 213 | - return array_combine($keys, $values); |
|
| 231 | + { |
|
| 232 | + return array_combine($keys, $values); |
|
| 233 | + } |
|
| 214 | 234 | else |
| 215 | 235 | { |
| 216 | 236 | $combined = array(); |
| 217 | 237 | foreach ($keys as $key) |
| 218 | 238 | { |
| 219 | 239 | if (isset($values[$key])) |
| 220 | - $combined[$key] = $values[$key]; |
|
| 240 | + { |
|
| 241 | + $combined[$key] = $values[$key]; |
|
| 242 | + } |
|
| 221 | 243 | } |
| 222 | 244 | |
| 223 | 245 | // @todo should throw an E_WARNING if count($combined) != count($keys) |
@@ -236,7 +258,9 @@ discard block |
||
| 236 | 258 | protected function _replaceInt($identifier, $replacement) |
| 237 | 259 | { |
| 238 | 260 | if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
| 239 | - $this->error_backtrace('Wrong value type sent to the database. Integer expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 261 | + { |
|
| 262 | + $this->error_backtrace('Wrong value type sent to the database. Integer expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 263 | + } |
|
| 240 | 264 | return (string) (int) $replacement; |
| 241 | 265 | } |
| 242 | 266 | |
@@ -253,12 +277,16 @@ discard block |
||
| 253 | 277 | if (is_array($replacement)) |
| 254 | 278 | { |
| 255 | 279 | if (empty($replacement)) |
| 256 | - $this->error_backtrace('Database error, given array of integer values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 280 | + { |
|
| 281 | + $this->error_backtrace('Database error, given array of integer values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 282 | + } |
|
| 257 | 283 | |
| 258 | 284 | foreach ($replacement as $key => $value) |
| 259 | 285 | { |
| 260 | 286 | if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
| 261 | - $this->error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 287 | + { |
|
| 288 | + $this->error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 289 | + } |
|
| 262 | 290 | |
| 263 | 291 | $replacement[$key] = (string) (int) $value; |
| 264 | 292 | } |
@@ -295,10 +323,14 @@ discard block |
||
| 295 | 323 | if (is_array($replacement)) |
| 296 | 324 | { |
| 297 | 325 | if (empty($replacement)) |
| 298 | - $this->error_backtrace('Database error, given array of string values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 326 | + { |
|
| 327 | + $this->error_backtrace('Database error, given array of string values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 328 | + } |
|
| 299 | 329 | |
| 300 | 330 | foreach ($replacement as $key => $value) |
| 301 | - $replacement[$key] = sprintf('\'%1$s\'', $this->escape_string($value)); |
|
| 331 | + { |
|
| 332 | + $replacement[$key] = sprintf('\'%1$s\'', $this->escape_string($value)); |
|
| 333 | + } |
|
| 302 | 334 | |
| 303 | 335 | return implode(', ', $replacement); |
| 304 | 336 | } |
@@ -319,9 +351,12 @@ discard block |
||
| 319 | 351 | protected function _replaceDate($identifier, $replacement) |
| 320 | 352 | { |
| 321 | 353 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
| 322 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 323 | - else |
|
| 324 | - $this->error_backtrace('Wrong value type sent to the database. Date expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 354 | + { |
|
| 355 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 356 | + } |
|
| 357 | + else { |
|
| 358 | + $this->error_backtrace('Wrong value type sent to the database. Date expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 359 | + } |
|
| 325 | 360 | } |
| 326 | 361 | |
| 327 | 362 | /** |
@@ -335,7 +370,9 @@ discard block |
||
| 335 | 370 | protected function _replaceFloat($identifier, $replacement) |
| 336 | 371 | { |
| 337 | 372 | if (!is_numeric($replacement)) |
| 338 | - $this->error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 373 | + { |
|
| 374 | + $this->error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 375 | + } |
|
| 339 | 376 | return (string) (float) $replacement; |
| 340 | 377 | } |
| 341 | 378 | |
@@ -371,7 +408,9 @@ discard block |
||
| 371 | 408 | public function error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 372 | 409 | { |
| 373 | 410 | if (empty($log_message)) |
| 374 | - $log_message = $error_message; |
|
| 411 | + { |
|
| 412 | + $log_message = $error_message; |
|
| 413 | + } |
|
| 375 | 414 | |
| 376 | 415 | foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $step) |
| 377 | 416 | { |
@@ -391,7 +430,9 @@ discard block |
||
| 391 | 430 | |
| 392 | 431 | // A special case - we want the file and line numbers for debugging. |
| 393 | 432 | if ($error_type === 'return') |
| 394 | - return array($file, $line); |
|
| 433 | + { |
|
| 434 | + return array($file, $line); |
|
| 435 | + } |
|
| 395 | 436 | |
| 396 | 437 | // Is always a critical error. |
| 397 | 438 | if (class_exists('Errors')) |
@@ -404,9 +445,12 @@ discard block |
||
| 404 | 445 | throw new Elk_Exception($error_message, false); |
| 405 | 446 | } |
| 406 | 447 | elseif ($error_type) |
| 407 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 408 | - else |
|
| 409 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 448 | + { |
|
| 449 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 450 | + } |
|
| 451 | + else { |
|
| 452 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 453 | + } |
|
| 410 | 454 | |
| 411 | 455 | return array('', ''); |
| 412 | 456 | } |
@@ -426,9 +470,11 @@ discard block |
||
| 426 | 470 | ); |
| 427 | 471 | |
| 428 | 472 | if ($translate_human_wildcards) |
| 429 | - $replacements += array( |
|
| 473 | + { |
|
| 474 | + $replacements += array( |
|
| 430 | 475 | '*' => '%', |
| 431 | 476 | ); |
| 477 | + } |
|
| 432 | 478 | |
| 433 | 479 | return strtr($string, $replacements); |
| 434 | 480 | } |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // You can't dump nothing! |
| 41 | 41 | if (!isset($_REQUEST['struct']) && !isset($_REQUEST['data'])) |
| 42 | - $_REQUEST['data'] = true; |
|
| 42 | + { |
|
| 43 | + $_REQUEST['data'] = true; |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | // Attempt to stop from dying... |
| 45 | 47 | detectServer()->setTimeLimit(600); |
@@ -72,10 +74,14 @@ discard block |
||
| 72 | 74 | { |
| 73 | 75 | // Get rid of the gzipping already being done. |
| 74 | 76 | if (!empty($modSettings['enableCompressedOutput'])) |
| 75 | - @ob_end_clean(); |
|
| 77 | + { |
|
| 78 | + @ob_end_clean(); |
|
| 79 | + } |
|
| 76 | 80 | // If we can, clean anything already sent from the output buffer... |
| 77 | 81 | elseif (ob_get_length() != 0) |
| 78 | - ob_clean(); |
|
| 82 | + { |
|
| 83 | + ob_clean(); |
|
| 84 | + } |
|
| 79 | 85 | |
| 80 | 86 | // Tell the client to save this file, even though it's text. |
| 81 | 87 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
@@ -124,13 +130,16 @@ discard block |
||
| 124 | 130 | $crlf . |
| 125 | 131 | $database->db_table_sql($tableName) . ';' . $crlf; |
| 126 | 132 | } |
| 127 | - else |
|
| 128 | - // This is needed to speedup things later |
|
| 133 | + else { |
|
| 134 | + // This is needed to speedup things later |
|
| 129 | 135 | $database->db_table_sql($tableName); |
| 136 | + } |
|
| 130 | 137 | |
| 131 | 138 | // How about the data? |
| 132 | 139 | if (!isset($_REQUEST['data']) || substr($tableName, -10) == 'log_errors') |
| 133 | - continue; |
|
| 140 | + { |
|
| 141 | + continue; |
|
| 142 | + } |
|
| 134 | 143 | |
| 135 | 144 | $first_round = true; |
| 136 | 145 | $close_table = false; |
@@ -139,11 +148,15 @@ discard block |
||
| 139 | 148 | while ($get_rows = $database->insert_sql($tableName, $first_round)) |
| 140 | 149 | { |
| 141 | 150 | if (empty($get_rows)) |
| 142 | - break; |
|
| 151 | + { |
|
| 152 | + break; |
|
| 153 | + } |
|
| 143 | 154 | |
| 144 | 155 | // Time is what we need here! |
| 145 | 156 | if (function_exists('apache_reset_timeout')) |
| 146 | - @apache_reset_timeout(); |
|
| 157 | + { |
|
| 158 | + @apache_reset_timeout(); |
|
| 159 | + } |
|
| 147 | 160 | elseif (!empty($time_limit) && (((int) $start_time + (int) $time_limit - 20) > time())) |
| 148 | 161 | { |
| 149 | 162 | $start_time = time(); |
@@ -182,8 +195,10 @@ discard block |
||
| 182 | 195 | |
| 183 | 196 | // No rows to get - skip it. |
| 184 | 197 | if ($close_table) |
| 185 | - $db_backup .= |
|
| 198 | + { |
|
| 199 | + $db_backup .= |
|
| 186 | 200 | '-- --------------------------------------------------------' . $crlf; |
| 201 | + } |
|
| 187 | 202 | } |
| 188 | 203 | |
| 189 | 204 | // write the last line |