@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | <meta charset="', $context['character_set'], '"> |
| 25 | 25 | <meta name="robots" content="noindex"> |
| 26 | 26 | <title>', $context['page_title'], '</title> |
| 27 | - <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'"> |
|
| 28 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
| 27 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '"> |
|
| 28 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
| 29 | 29 | </head> |
| 30 | 30 | <body id="help_popup"> |
| 31 | 31 | <div class="windowbg description"> |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | <title>', $txt['find_members'], '</title> |
| 51 | 51 | <meta charset="', $context['character_set'], '"> |
| 52 | 52 | <meta name="robots" content="noindex"> |
| 53 | - <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'"> |
|
| 54 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
| 53 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '"> |
|
| 54 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
| 55 | 55 | <script> |
| 56 | 56 | var membersAdded = []; |
| 57 | 57 | function addMember(name) |
@@ -86,11 +86,12 @@ discard block |
||
| 86 | 86 | <span class="smalltext"><em>', $txt['find_wildcards'], '</em></span><br>'; |
| 87 | 87 | |
| 88 | 88 | // Only offer to search for buddies if we have some! |
| 89 | - if (!empty($context['show_buddies'])) |
|
| 90 | - echo ' |
|
| 89 | + if (!empty($context['show_buddies'])) { |
|
| 90 | + echo ' |
|
| 91 | 91 | <span class="smalltext"> |
| 92 | 92 | <label for="buddies"><input type="checkbox" name="buddies" id="buddies"', !empty($context['buddy_search']) ? ' checked' : '', '> ', $txt['find_buddies'], '</label> |
| 93 | 93 | </span><br>'; |
| 94 | + } |
|
| 94 | 95 | |
| 95 | 96 | echo ' |
| 96 | 97 | <div class="padding righttext"> |
@@ -105,20 +106,21 @@ discard block |
||
| 105 | 106 | <h3 class="catbg">', $txt['find_results'], '</h3> |
| 106 | 107 | </div>'; |
| 107 | 108 | |
| 108 | - if (empty($context['results'])) |
|
| 109 | - echo ' |
|
| 109 | + if (empty($context['results'])) { |
|
| 110 | + echo ' |
|
| 110 | 111 | <p class="error">', $txt['find_no_results'], '</p>'; |
| 111 | - else |
|
| 112 | + } else |
|
| 112 | 113 | { |
| 113 | 114 | echo ' |
| 114 | 115 | <ul class="padding">'; |
| 115 | 116 | |
| 116 | - foreach ($context['results'] as $result) |
|
| 117 | - echo ' |
|
| 117 | + foreach ($context['results'] as $result) { |
|
| 118 | + echo ' |
|
| 118 | 119 | <li class="windowbg"> |
| 119 | 120 | <a href="', $result['href'], '" target="_blank" rel="noopener"> <span class="generic_icons profile_sm"></span> |
| 120 | 121 | <a href="javascript:void(0);" onclick="addMember(this.innerHTML); return false;">', $result['name'], '</a> |
| 121 | 122 | </li>'; |
| 123 | + } |
|
| 122 | 124 | |
| 123 | 125 | echo ' |
| 124 | 126 | </ul> |
@@ -134,11 +136,12 @@ discard block |
||
| 134 | 136 | <input type="hidden" name="quote" value="', $context['quote_results'] ? '1' : '0', '"> |
| 135 | 137 | </form>'; |
| 136 | 138 | |
| 137 | - if (empty($context['results'])) |
|
| 138 | - echo ' |
|
| 139 | + if (empty($context['results'])) { |
|
| 140 | + echo ' |
|
| 139 | 141 | <script> |
| 140 | 142 | document.getElementById("search").focus(); |
| 141 | 143 | </script>'; |
| 144 | + } |
|
| 142 | 145 | |
| 143 | 146 | echo ' |
| 144 | 147 | </body> |
@@ -162,9 +165,10 @@ discard block |
||
| 162 | 165 | <p>', $txt['manual_introduction'], '</p> |
| 163 | 166 | <ul>'; |
| 164 | 167 | |
| 165 | - foreach ($context['manual_sections'] as $section_id => $wiki_id) |
|
| 166 | - echo ' |
|
| 168 | + foreach ($context['manual_sections'] as $section_id => $wiki_id) { |
|
| 169 | + echo ' |
|
| 167 | 170 | <li><a href="', $context['wiki_url'], '/', $context['wiki_prefix'], $wiki_id, ($txt['lang_dictionary'] != 'en' ? '/' . $txt['lang_dictionary'] : ''), '" target="_blank" rel="noopener">', $txt['manual_section_' . $section_id . '_title'], '</a> - ', $txt['manual_section_' . $section_id . '_desc'], '</li>'; |
| 171 | + } |
|
| 168 | 172 | |
| 169 | 173 | echo ' |
| 170 | 174 | </ul> |
@@ -180,8 +184,8 @@ discard block |
||
| 180 | 184 | { |
| 181 | 185 | global $txt, $context, $modSettings; |
| 182 | 186 | |
| 183 | - if (!empty($modSettings['requireAgreement'])) |
|
| 184 | - echo ' |
|
| 187 | + if (!empty($modSettings['requireAgreement'])) { |
|
| 188 | + echo ' |
|
| 185 | 189 | <div class="cat_bar"> |
| 186 | 190 | <h3 class="catbg"> |
| 187 | 191 | ', $txt['terms_and_rules'], ' - ', $context['forum_name_html_safe'], ' |
@@ -190,11 +194,12 @@ discard block |
||
| 190 | 194 | <div class="roundframe"> |
| 191 | 195 | ', $context['agreement'], ' |
| 192 | 196 | </div>'; |
| 193 | - else |
|
| 194 | - echo ' |
|
| 197 | + } else { |
|
| 198 | + echo ' |
|
| 195 | 199 | <div class="noticebox"> |
| 196 | 200 | ', $txt['agreement_disabled'], ' |
| 197 | 201 | </div>'; |
| 198 | -} |
|
| 202 | + } |
|
| 203 | + } |
|
| 199 | 204 | |
| 200 | 205 | ?> |
| 201 | 206 | \ No newline at end of file |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | </div> |
| 102 | 102 | <ul id="messages_not_selected" class="split_messages smalltext">'; |
| 103 | 103 | |
| 104 | - foreach ($context['not_selected']['messages'] as $message) |
|
| 105 | - echo ' |
|
| 104 | + foreach ($context['not_selected']['messages'] as $message) { |
|
| 105 | + echo ' |
|
| 106 | 106 | <li class="windowbg" id="not_selected_', $message['id'], '"> |
| 107 | 107 | <div class="message_header"> |
| 108 | 108 | <a class="split_icon floatright" href="', $scripturl, '?action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '.', $context['not_selected']['start'], ';start2=', $context['selected']['start'], ';move=down;msg=', $message['id'], '" onclick="return select(\'down\', ', $message['id'], ');"><span class="generic_icons split_sel" title="->"></span></a> |
@@ -111,6 +111,7 @@ discard block |
||
| 111 | 111 | </div> |
| 112 | 112 | <div class="post">', $message['body'], '</div> |
| 113 | 113 | </li>'; |
| 114 | + } |
|
| 114 | 115 | |
| 115 | 116 | echo ' |
| 116 | 117 | <li class="dummy"> |
@@ -130,8 +131,8 @@ discard block |
||
| 130 | 131 | </div> |
| 131 | 132 | <ul id="messages_selected" class="split_messages smalltext">'; |
| 132 | 133 | |
| 133 | - if (!empty($context['selected']['messages'])) |
|
| 134 | - foreach ($context['selected']['messages'] as $message) |
|
| 134 | + if (!empty($context['selected']['messages'])) { |
|
| 135 | + foreach ($context['selected']['messages'] as $message) |
|
| 135 | 136 | echo ' |
| 136 | 137 | <li class="windowbg" id="selected_', $message['id'], '"> |
| 137 | 138 | <div class="message_header"> |
@@ -141,6 +142,7 @@ discard block |
||
| 141 | 142 | </div> |
| 142 | 143 | <div class="post">', $message['body'], '</div> |
| 143 | 144 | </li>'; |
| 145 | + } |
|
| 144 | 146 | |
| 145 | 147 | echo ' |
| 146 | 148 | <li class="dummy"> |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | if (!$this->connection) |
| 794 | 794 | { |
| 795 | 795 | $this->error = 'bad_server'; |
| 796 | - $this->last_message = 'Invalid Server'; |
|
| 796 | + $this->last_message = 'Invalid Server'; |
|
| 797 | 797 | return; |
| 798 | 798 | } |
| 799 | 799 | |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | if (!$this->check_response(220)) |
| 802 | 802 | { |
| 803 | 803 | $this->error = 'bad_response'; |
| 804 | - $this->last_message = 'Bad Response'; |
|
| 804 | + $this->last_message = 'Bad Response'; |
|
| 805 | 805 | return; |
| 806 | 806 | } |
| 807 | 807 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * of elements, an array of xmlArray's is returned for use with foreach. |
| 258 | 258 | * Example use: |
| 259 | 259 | * foreach ($xml->set('html/body/p') as $p) |
| 260 | - * @param $path string The path to search for. |
|
| 260 | + * @param string $path string The path to search for. |
|
| 261 | 261 | * @return xmlArray[] An array of xmlArray objects |
| 262 | 262 | */ |
| 263 | 263 | public function set($path) |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | * Changes a files atrributes (chmod) |
| 856 | 856 | * |
| 857 | 857 | * @param string $ftp_file The file to CHMOD |
| 858 | - * @param int|string $chmod The value for the CHMOD operation |
|
| 858 | + * @param integer $chmod The value for the CHMOD operation |
|
| 859 | 859 | * @return boolean Whether or not the operation was successful |
| 860 | 860 | */ |
| 861 | 861 | public function chmod($ftp_file, $chmod) |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | * |
| 1026 | 1026 | * @param string $ftp_path The path to the directory |
| 1027 | 1027 | * @param bool $search Whether or not to get a recursive directory listing |
| 1028 | - * @return string|boolean The results of the command or false if unsuccessful |
|
| 1028 | + * @return false|string The results of the command or false if unsuccessful |
|
| 1029 | 1029 | */ |
| 1030 | 1030 | public function list_dir($ftp_path = '', $search = false) |
| 1031 | 1031 | { |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | * |
| 1071 | 1071 | * @param string $file The name of a file |
| 1072 | 1072 | * @param string $listing A directory listing or null to generate one |
| 1073 | - * @return string|boolean The name of the file or false if it wasn't found |
|
| 1073 | + * @return string|false The name of the file or false if it wasn't found |
|
| 1074 | 1074 | */ |
| 1075 | 1075 | public function locate($file, $listing = null) |
| 1076 | 1076 | { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Class xmlArray |
@@ -65,8 +66,9 @@ discard block |
||
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | // Is the input an array? (ie. passed from file()?) |
| 68 | - if (is_array($data)) |
|
| 69 | - $data = implode('', $data); |
|
| 69 | + if (is_array($data)) { |
|
| 70 | + $data = implode('', $data); |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | // Remove any xml declaration or doctype, and parse out comments and CDATA. |
| 72 | 74 | $data = preg_replace('/<!--.*?-->/s', '', $this->_to_cdata(preg_replace(array('/^<\?xml.+?\?' . '>/is', '/<!DOCTYPE[^>]+?' . '>/s'), '', $data))); |
@@ -101,8 +103,9 @@ discard block |
||
| 101 | 103 | // Get the element, in array form. |
| 102 | 104 | $array = $this->path($path); |
| 103 | 105 | |
| 104 | - if ($array === false) |
|
| 105 | - return false; |
|
| 106 | + if ($array === false) { |
|
| 107 | + return false; |
|
| 108 | + } |
|
| 106 | 109 | |
| 107 | 110 | // Getting elements into this is a bit complicated... |
| 108 | 111 | if ($get_elements && !is_string($array)) |
@@ -113,8 +116,9 @@ discard block |
||
| 113 | 116 | foreach ($array->array as $val) |
| 114 | 117 | { |
| 115 | 118 | // Skip the name and any attributes. |
| 116 | - if (is_array($val)) |
|
| 117 | - $temp .= $this->_xml($val, null); |
|
| 119 | + if (is_array($val)) { |
|
| 120 | + $temp .= $this->_xml($val, null); |
|
| 121 | + } |
|
| 118 | 122 | } |
| 119 | 123 | |
| 120 | 124 | // Just get the XML data and then take out the CDATAs. |
@@ -156,32 +160,35 @@ discard block |
||
| 156 | 160 | elseif (substr($el, 0, 1) == '@') |
| 157 | 161 | { |
| 158 | 162 | // It simplifies things if the attribute is already there ;). |
| 159 | - if (isset($array[$el])) |
|
| 160 | - return $array[$el]; |
|
| 161 | - else |
|
| 163 | + if (isset($array[$el])) { |
|
| 164 | + return $array[$el]; |
|
| 165 | + } else |
|
| 162 | 166 | { |
| 163 | 167 | $trace = debug_backtrace(); |
| 164 | 168 | $i = 0; |
| 165 | - while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) |
|
| 166 | - $i++; |
|
| 169 | + while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) { |
|
| 170 | + $i++; |
|
| 171 | + } |
|
| 167 | 172 | $debug = ' (from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'] . ')'; |
| 168 | 173 | |
| 169 | 174 | // Cause an error. |
| 170 | - if ($this->debug_level & E_NOTICE) |
|
| 171 | - trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE); |
|
| 175 | + if ($this->debug_level & E_NOTICE) { |
|
| 176 | + trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE); |
|
| 177 | + } |
|
| 172 | 178 | return false; |
| 173 | 179 | } |
| 180 | + } else { |
|
| 181 | + $lvl = null; |
|
| 174 | 182 | } |
| 175 | - else |
|
| 176 | - $lvl = null; |
|
| 177 | 183 | |
| 178 | 184 | // Find this element. |
| 179 | 185 | $array = $this->_path($array, $el, $lvl); |
| 180 | 186 | } |
| 181 | 187 | |
| 182 | 188 | // Clean up after $lvl, for $return_full. |
| 183 | - if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) |
|
| 184 | - $array = array('name' => $el . '[]', $array); |
|
| 189 | + if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) { |
|
| 190 | + $array = array('name' => $el . '[]', $array); |
|
| 191 | + } |
|
| 185 | 192 | |
| 186 | 193 | // Create the right type of class... |
| 187 | 194 | $newClass = get_class($this); |
@@ -216,10 +223,11 @@ discard block |
||
| 216 | 223 | $el = substr($el, 0, strpos($el, '[')); |
| 217 | 224 | } |
| 218 | 225 | // Find an attribute. |
| 219 | - elseif (substr($el, 0, 1) == '@') |
|
| 220 | - return isset($array[$el]); |
|
| 221 | - else |
|
| 222 | - $lvl = null; |
|
| 226 | + elseif (substr($el, 0, 1) == '@') { |
|
| 227 | + return isset($array[$el]); |
|
| 228 | + } else { |
|
| 229 | + $lvl = null; |
|
| 230 | + } |
|
| 223 | 231 | |
| 224 | 232 | // Find this element. |
| 225 | 233 | $array = $this->_path($array, $el, $lvl, true); |
@@ -244,8 +252,9 @@ discard block |
||
| 244 | 252 | $i = 0; |
| 245 | 253 | foreach ($temp->array as $item) |
| 246 | 254 | { |
| 247 | - if (is_array($item)) |
|
| 248 | - $i++; |
|
| 255 | + if (is_array($item)) { |
|
| 256 | + $i++; |
|
| 257 | + } |
|
| 249 | 258 | } |
| 250 | 259 | |
| 251 | 260 | return $i; |
@@ -269,8 +278,9 @@ discard block |
||
| 269 | 278 | foreach ($xml->array as $val) |
| 270 | 279 | { |
| 271 | 280 | // Skip these, they aren't elements. |
| 272 | - if (!is_array($val) || $val['name'] == '!') |
|
| 273 | - continue; |
|
| 281 | + if (!is_array($val) || $val['name'] == '!') { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 274 | 284 | |
| 275 | 285 | // Create the right type of class... |
| 276 | 286 | $newClass = get_class($this); |
@@ -297,14 +307,16 @@ discard block |
||
| 297 | 307 | $path = $this->path($path); |
| 298 | 308 | |
| 299 | 309 | // The path was not found |
| 300 | - if ($path === false) |
|
| 301 | - return false; |
|
| 310 | + if ($path === false) { |
|
| 311 | + return false; |
|
| 312 | + } |
|
| 302 | 313 | |
| 303 | 314 | $path = $path->array; |
| 304 | 315 | } |
| 305 | 316 | // Just use the current array. |
| 306 | - else |
|
| 307 | - $path = $this->array; |
|
| 317 | + else { |
|
| 318 | + $path = $this->array; |
|
| 319 | + } |
|
| 308 | 320 | |
| 309 | 321 | // Add the xml declaration to the front. |
| 310 | 322 | return '<?xml version="1.0"?' . '>' . $this->_xml($path, 0); |
@@ -326,14 +338,16 @@ discard block |
||
| 326 | 338 | $path = $this->path($path); |
| 327 | 339 | |
| 328 | 340 | // The path was not found |
| 329 | - if ($path === false) |
|
| 330 | - return false; |
|
| 341 | + if ($path === false) { |
|
| 342 | + return false; |
|
| 343 | + } |
|
| 331 | 344 | |
| 332 | 345 | $path = $path->array; |
| 333 | 346 | } |
| 334 | 347 | // No, so just use the current array. |
| 335 | - else |
|
| 336 | - $path = $this->array; |
|
| 348 | + else { |
|
| 349 | + $path = $this->array; |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | return $this->_array($path); |
| 339 | 353 | } |
@@ -355,8 +369,9 @@ discard block |
||
| 355 | 369 | { |
| 356 | 370 | // Find and remove the next tag. |
| 357 | 371 | preg_match('/\A<([\w\-:]+)((?:\s+.+?)?)([\s]?\/)?' . '>/', $data, $match); |
| 358 | - if (isset($match[0])) |
|
| 359 | - $data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1); |
|
| 372 | + if (isset($match[0])) { |
|
| 373 | + $data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1); |
|
| 374 | + } |
|
| 360 | 375 | |
| 361 | 376 | // Didn't find a tag? Keep looping.... |
| 362 | 377 | if (!isset($match[1]) || $match[1] == '') |
@@ -367,11 +382,12 @@ discard block |
||
| 367 | 382 | $text_value = $this->_from_cdata($data); |
| 368 | 383 | $data = ''; |
| 369 | 384 | |
| 370 | - if ($text_value != '') |
|
| 371 | - $current[] = array( |
|
| 385 | + if ($text_value != '') { |
|
| 386 | + $current[] = array( |
|
| 372 | 387 | 'name' => '!', |
| 373 | 388 | 'value' => $text_value |
| 374 | 389 | ); |
| 390 | + } |
|
| 375 | 391 | } |
| 376 | 392 | // If the < isn't immediately next to the current position... more data. |
| 377 | 393 | elseif (strpos($data, '<') > 0) |
@@ -379,11 +395,12 @@ discard block |
||
| 379 | 395 | $text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<'))); |
| 380 | 396 | $data = substr($data, strpos($data, '<')); |
| 381 | 397 | |
| 382 | - if ($text_value != '') |
|
| 383 | - $current[] = array( |
|
| 398 | + if ($text_value != '') { |
|
| 399 | + $current[] = array( |
|
| 384 | 400 | 'name' => '!', |
| 385 | 401 | 'value' => $text_value |
| 386 | 402 | ); |
| 403 | + } |
|
| 387 | 404 | } |
| 388 | 405 | // If we're looking at a </something> with no start, kill it. |
| 389 | 406 | elseif (strpos($data, '<') !== false && strpos($data, '<') == 0) |
@@ -393,22 +410,23 @@ discard block |
||
| 393 | 410 | $text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<', 1))); |
| 394 | 411 | $data = substr($data, strpos($data, '<', 1)); |
| 395 | 412 | |
| 396 | - if ($text_value != '') |
|
| 397 | - $current[] = array( |
|
| 413 | + if ($text_value != '') { |
|
| 414 | + $current[] = array( |
|
| 398 | 415 | 'name' => '!', |
| 399 | 416 | 'value' => $text_value |
| 400 | 417 | ); |
| 401 | - } |
|
| 402 | - else |
|
| 418 | + } |
|
| 419 | + } else |
|
| 403 | 420 | { |
| 404 | 421 | $text_value = $this->_from_cdata($data); |
| 405 | 422 | $data = ''; |
| 406 | 423 | |
| 407 | - if ($text_value != '') |
|
| 408 | - $current[] = array( |
|
| 424 | + if ($text_value != '') { |
|
| 425 | + $current[] = array( |
|
| 409 | 426 | 'name' => '!', |
| 410 | 427 | 'value' => $text_value |
| 411 | 428 | ); |
| 429 | + } |
|
| 412 | 430 | } |
| 413 | 431 | } |
| 414 | 432 | |
@@ -425,8 +443,9 @@ discard block |
||
| 425 | 443 | { |
| 426 | 444 | // Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way. |
| 427 | 445 | $last_tag_end = strpos($data, '</' . $match[1] . '>'); |
| 428 | - if ($last_tag_end === false) |
|
| 429 | - continue; |
|
| 446 | + if ($last_tag_end === false) { |
|
| 447 | + continue; |
|
| 448 | + } |
|
| 430 | 449 | |
| 431 | 450 | $offset = 0; |
| 432 | 451 | while (1 == 1) |
@@ -434,16 +453,17 @@ discard block |
||
| 434 | 453 | // Where is the next start tag? |
| 435 | 454 | $next_tag_start = strpos($data, '<' . $match[1], $offset); |
| 436 | 455 | // If the next start tag is after the last end tag then we've found the right close. |
| 437 | - if ($next_tag_start === false || $next_tag_start > $last_tag_end) |
|
| 438 | - break; |
|
| 456 | + if ($next_tag_start === false || $next_tag_start > $last_tag_end) { |
|
| 457 | + break; |
|
| 458 | + } |
|
| 439 | 459 | |
| 440 | 460 | // If not then find the next ending tag. |
| 441 | 461 | $next_tag_end = strpos($data, '</' . $match[1] . '>', $offset); |
| 442 | 462 | |
| 443 | 463 | // Didn't find one? Then just use the last and sod it. |
| 444 | - if ($next_tag_end === false) |
|
| 445 | - break; |
|
| 446 | - else |
|
| 464 | + if ($next_tag_end === false) { |
|
| 465 | + break; |
|
| 466 | + } else |
|
| 447 | 467 | { |
| 448 | 468 | $last_tag_end = $next_tag_end; |
| 449 | 469 | $offset = $next_tag_start + 1; |
@@ -457,16 +477,17 @@ discard block |
||
| 457 | 477 | if (!empty($inner_match)) |
| 458 | 478 | { |
| 459 | 479 | // Parse the inner data. |
| 460 | - if (strpos($inner_match, '<') !== false) |
|
| 461 | - $el += $this->_parse($inner_match); |
|
| 462 | - elseif (trim($inner_match) != '') |
|
| 480 | + if (strpos($inner_match, '<') !== false) { |
|
| 481 | + $el += $this->_parse($inner_match); |
|
| 482 | + } elseif (trim($inner_match) != '') |
|
| 463 | 483 | { |
| 464 | 484 | $text_value = $this->_from_cdata($inner_match); |
| 465 | - if ($text_value != '') |
|
| 466 | - $el[] = array( |
|
| 485 | + if ($text_value != '') { |
|
| 486 | + $el[] = array( |
|
| 467 | 487 | 'name' => '!', |
| 468 | 488 | 'value' => $text_value |
| 469 | 489 | ); |
| 490 | + } |
|
| 470 | 491 | } |
| 471 | 492 | } |
| 472 | 493 | } |
@@ -478,8 +499,9 @@ discard block |
||
| 478 | 499 | preg_match_all('/([\w:]+)="(.+?)"/', $match[2], $attr, PREG_SET_ORDER); |
| 479 | 500 | |
| 480 | 501 | // Set them as @attribute-name. |
| 481 | - foreach ($attr as $match_attr) |
|
| 482 | - $el['@' . $match_attr[1]] = $match_attr[2]; |
|
| 502 | + foreach ($attr as $match_attr) { |
|
| 503 | + $el['@' . $match_attr[1]] = $match_attr[2]; |
|
| 504 | + } |
|
| 483 | 505 | } |
| 484 | 506 | } |
| 485 | 507 | |
@@ -503,16 +525,18 @@ discard block |
||
| 503 | 525 | if (is_array($array) && !isset($array['name'])) |
| 504 | 526 | { |
| 505 | 527 | $temp = ''; |
| 506 | - foreach ($array as $val) |
|
| 507 | - $temp .= $this->_xml($val, $indent); |
|
| 528 | + foreach ($array as $val) { |
|
| 529 | + $temp .= $this->_xml($val, $indent); |
|
| 530 | + } |
|
| 508 | 531 | return $temp; |
| 509 | 532 | } |
| 510 | 533 | |
| 511 | 534 | // This is just text! |
| 512 | - if ($array['name'] == '!') |
|
| 513 | - return $indentation . '<![CDATA[' . $array['value'] . ']]>'; |
|
| 514 | - elseif (substr($array['name'], -2) == '[]') |
|
| 515 | - $array['name'] = substr($array['name'], 0, -2); |
|
| 535 | + if ($array['name'] == '!') { |
|
| 536 | + return $indentation . '<![CDATA[' . $array['value'] . ']]>'; |
|
| 537 | + } elseif (substr($array['name'], -2) == '[]') { |
|
| 538 | + $array['name'] = substr($array['name'], 0, -2); |
|
| 539 | + } |
|
| 516 | 540 | |
| 517 | 541 | // Start the element. |
| 518 | 542 | $output = $indentation . '<' . $array['name']; |
@@ -523,9 +547,9 @@ discard block |
||
| 523 | 547 | // Run through and recursively output all the elements or attrbutes inside this. |
| 524 | 548 | foreach ($array as $k => $v) |
| 525 | 549 | { |
| 526 | - if (substr($k, 0, 1) == '@') |
|
| 527 | - $output .= ' ' . substr($k, 1) . '="' . $v . '"'; |
|
| 528 | - elseif (is_array($v)) |
|
| 550 | + if (substr($k, 0, 1) == '@') { |
|
| 551 | + $output .= ' ' . substr($k, 1) . '="' . $v . '"'; |
|
| 552 | + } elseif (is_array($v)) |
|
| 529 | 553 | { |
| 530 | 554 | $output_el .= $this->_xml($v, $indent === null ? null : $indent + 1); |
| 531 | 555 | $inside_elements = true; |
@@ -533,10 +557,11 @@ discard block |
||
| 533 | 557 | } |
| 534 | 558 | |
| 535 | 559 | // Indent, if necessary.... then close the tag. |
| 536 | - if ($inside_elements) |
|
| 537 | - $output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>'; |
|
| 538 | - else |
|
| 539 | - $output .= ' />'; |
|
| 560 | + if ($inside_elements) { |
|
| 561 | + $output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>'; |
|
| 562 | + } else { |
|
| 563 | + $output .= ' />'; |
|
| 564 | + } |
|
| 540 | 565 | |
| 541 | 566 | return $output; |
| 542 | 567 | } |
@@ -553,19 +578,22 @@ discard block |
||
| 553 | 578 | $text = ''; |
| 554 | 579 | foreach ($array as $value) |
| 555 | 580 | { |
| 556 | - if (!is_array($value) || !isset($value['name'])) |
|
| 557 | - continue; |
|
| 581 | + if (!is_array($value) || !isset($value['name'])) { |
|
| 582 | + continue; |
|
| 583 | + } |
|
| 558 | 584 | |
| 559 | - if ($value['name'] == '!') |
|
| 560 | - $text .= $value['value']; |
|
| 561 | - else |
|
| 562 | - $return[$value['name']] = $this->_array($value); |
|
| 585 | + if ($value['name'] == '!') { |
|
| 586 | + $text .= $value['value']; |
|
| 587 | + } else { |
|
| 588 | + $return[$value['name']] = $this->_array($value); |
|
| 589 | + } |
|
| 563 | 590 | } |
| 564 | 591 | |
| 565 | - if (empty($return)) |
|
| 566 | - return $text; |
|
| 567 | - else |
|
| 568 | - return $return; |
|
| 592 | + if (empty($return)) { |
|
| 593 | + return $text; |
|
| 594 | + } else { |
|
| 595 | + return $return; |
|
| 596 | + } |
|
| 569 | 597 | } |
| 570 | 598 | |
| 571 | 599 | /** |
@@ -583,24 +611,28 @@ discard block |
||
| 583 | 611 | foreach ($parts as $part) |
| 584 | 612 | { |
| 585 | 613 | // Handle XML comments. |
| 586 | - if (!$inCdata && $part === '<!--') |
|
| 587 | - $inComment = true; |
|
| 588 | - if ($inComment && $part === '-->') |
|
| 589 | - $inComment = false; |
|
| 590 | - elseif ($inComment) |
|
| 591 | - continue; |
|
| 614 | + if (!$inCdata && $part === '<!--') { |
|
| 615 | + $inComment = true; |
|
| 616 | + } |
|
| 617 | + if ($inComment && $part === '-->') { |
|
| 618 | + $inComment = false; |
|
| 619 | + } elseif ($inComment) { |
|
| 620 | + continue; |
|
| 621 | + } |
|
| 592 | 622 | |
| 593 | 623 | // Handle Cdata blocks. |
| 594 | - elseif (!$inComment && $part === '<![CDATA[') |
|
| 595 | - $inCdata = true; |
|
| 596 | - elseif ($inCdata && $part === ']]>') |
|
| 597 | - $inCdata = false; |
|
| 598 | - elseif ($inCdata) |
|
| 599 | - $output .= htmlentities($part, ENT_QUOTES); |
|
| 624 | + elseif (!$inComment && $part === '<![CDATA[') { |
|
| 625 | + $inCdata = true; |
|
| 626 | + } elseif ($inCdata && $part === ']]>') { |
|
| 627 | + $inCdata = false; |
|
| 628 | + } elseif ($inCdata) { |
|
| 629 | + $output .= htmlentities($part, ENT_QUOTES); |
|
| 630 | + } |
|
| 600 | 631 | |
| 601 | 632 | // Everything else is kept as is. |
| 602 | - else |
|
| 603 | - $output .= $part; |
|
| 633 | + else { |
|
| 634 | + $output .= $part; |
|
| 635 | + } |
|
| 604 | 636 | } |
| 605 | 637 | |
| 606 | 638 | return $output; |
@@ -635,22 +667,26 @@ discard block |
||
| 635 | 667 | protected function _fetch($array) |
| 636 | 668 | { |
| 637 | 669 | // Don't return anything if this is just a string. |
| 638 | - if (is_string($array)) |
|
| 639 | - return ''; |
|
| 670 | + if (is_string($array)) { |
|
| 671 | + return ''; |
|
| 672 | + } |
|
| 640 | 673 | |
| 641 | 674 | $temp = ''; |
| 642 | 675 | foreach ($array as $text) |
| 643 | 676 | { |
| 644 | 677 | // This means it's most likely an attribute or the name itself. |
| 645 | - if (!isset($text['name'])) |
|
| 646 | - continue; |
|
| 678 | + if (!isset($text['name'])) { |
|
| 679 | + continue; |
|
| 680 | + } |
|
| 647 | 681 | |
| 648 | 682 | // This is text! |
| 649 | - if ($text['name'] == '!') |
|
| 650 | - $temp .= $text['value']; |
|
| 683 | + if ($text['name'] == '!') { |
|
| 684 | + $temp .= $text['value']; |
|
| 685 | + } |
|
| 651 | 686 | // Another element - dive in ;). |
| 652 | - else |
|
| 653 | - $temp .= $this->_fetch($text); |
|
| 687 | + else { |
|
| 688 | + $temp .= $this->_fetch($text); |
|
| 689 | + } |
|
| 654 | 690 | } |
| 655 | 691 | |
| 656 | 692 | // Return all the bits and pieces we've put together. |
@@ -669,12 +705,14 @@ discard block |
||
| 669 | 705 | protected function _path($array, $path, $level, $no_error = false) |
| 670 | 706 | { |
| 671 | 707 | // Is $array even an array? It might be false! |
| 672 | - if (!is_array($array)) |
|
| 673 | - return false; |
|
| 708 | + if (!is_array($array)) { |
|
| 709 | + return false; |
|
| 710 | + } |
|
| 674 | 711 | |
| 675 | 712 | // Asking for *no* path? |
| 676 | - if ($path == '' || $path == '.') |
|
| 677 | - return $array; |
|
| 713 | + if ($path == '' || $path == '.') { |
|
| 714 | + return $array; |
|
| 715 | + } |
|
| 678 | 716 | $paths = explode('|', $path); |
| 679 | 717 | |
| 680 | 718 | // A * means all elements of any name. |
@@ -685,16 +723,18 @@ discard block |
||
| 685 | 723 | // Check each element. |
| 686 | 724 | foreach ($array as $value) |
| 687 | 725 | { |
| 688 | - if (!is_array($value) || $value['name'] === '!') |
|
| 689 | - continue; |
|
| 726 | + if (!is_array($value) || $value['name'] === '!') { |
|
| 727 | + continue; |
|
| 728 | + } |
|
| 690 | 729 | |
| 691 | 730 | if ($show_all || in_array($value['name'], $paths)) |
| 692 | 731 | { |
| 693 | 732 | // Skip elements before "the one". |
| 694 | - if ($level !== null && $level > 0) |
|
| 695 | - $level--; |
|
| 696 | - else |
|
| 697 | - $results[] = $value; |
|
| 733 | + if ($level !== null && $level > 0) { |
|
| 734 | + $level--; |
|
| 735 | + } else { |
|
| 736 | + $results[] = $value; |
|
| 737 | + } |
|
| 698 | 738 | } |
| 699 | 739 | } |
| 700 | 740 | |
@@ -703,21 +743,25 @@ discard block |
||
| 703 | 743 | { |
| 704 | 744 | $trace = debug_backtrace(); |
| 705 | 745 | $i = 0; |
| 706 | - while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) |
|
| 707 | - $i++; |
|
| 746 | + while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) { |
|
| 747 | + $i++; |
|
| 748 | + } |
|
| 708 | 749 | $debug = ' from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line']; |
| 709 | 750 | |
| 710 | 751 | // Cause an error. |
| 711 | - if ($this->debug_level & E_NOTICE && !$no_error) |
|
| 712 | - trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE); |
|
| 752 | + if ($this->debug_level & E_NOTICE && !$no_error) { |
|
| 753 | + trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE); |
|
| 754 | + } |
|
| 713 | 755 | return false; |
| 714 | 756 | } |
| 715 | 757 | // Only one result. |
| 716 | - elseif (count($results) == 1 || $level !== null) |
|
| 717 | - return $results[0]; |
|
| 758 | + elseif (count($results) == 1 || $level !== null) { |
|
| 759 | + return $results[0]; |
|
| 760 | + } |
|
| 718 | 761 | // Return the result set. |
| 719 | - else |
|
| 720 | - return $results + array('name' => $path . '[]'); |
|
| 762 | + else { |
|
| 763 | + return $results + array('name' => $path . '[]'); |
|
| 764 | + } |
|
| 721 | 765 | } |
| 722 | 766 | } |
| 723 | 767 | |
@@ -764,8 +808,9 @@ discard block |
||
| 764 | 808 | $this->error = false; |
| 765 | 809 | $this->pasv = array(); |
| 766 | 810 | |
| 767 | - if ($ftp_server !== null) |
|
| 768 | - $this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass); |
|
| 811 | + if ($ftp_server !== null) { |
|
| 812 | + $this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass); |
|
| 813 | + } |
|
| 769 | 814 | } |
| 770 | 815 | |
| 771 | 816 | /** |
@@ -778,14 +823,16 @@ discard block |
||
| 778 | 823 | */ |
| 779 | 824 | public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]') |
| 780 | 825 | { |
| 781 | - if (strpos($ftp_server, 'ftp://') === 0) |
|
| 782 | - $ftp_server = substr($ftp_server, 6); |
|
| 783 | - elseif (strpos($ftp_server, 'ftps://') === 0) |
|
| 784 | - $ftp_server = 'ssl://' . substr($ftp_server, 7); |
|
| 785 | - if (strpos($ftp_server, 'http://') === 0) |
|
| 786 | - $ftp_server = substr($ftp_server, 7); |
|
| 787 | - elseif (strpos($ftp_server, 'https://') === 0) |
|
| 788 | - $ftp_server = substr($ftp_server, 8); |
|
| 826 | + if (strpos($ftp_server, 'ftp://') === 0) { |
|
| 827 | + $ftp_server = substr($ftp_server, 6); |
|
| 828 | + } elseif (strpos($ftp_server, 'ftps://') === 0) { |
|
| 829 | + $ftp_server = 'ssl://' . substr($ftp_server, 7); |
|
| 830 | + } |
|
| 831 | + if (strpos($ftp_server, 'http://') === 0) { |
|
| 832 | + $ftp_server = substr($ftp_server, 7); |
|
| 833 | + } elseif (strpos($ftp_server, 'https://') === 0) { |
|
| 834 | + $ftp_server = substr($ftp_server, 8); |
|
| 835 | + } |
|
| 789 | 836 | $ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => '')); |
| 790 | 837 | |
| 791 | 838 | // Connect to the FTP server. |
@@ -834,12 +881,14 @@ discard block |
||
| 834 | 881 | */ |
| 835 | 882 | public function chdir($ftp_path) |
| 836 | 883 | { |
| 837 | - if (!is_resource($this->connection)) |
|
| 838 | - return false; |
|
| 884 | + if (!is_resource($this->connection)) { |
|
| 885 | + return false; |
|
| 886 | + } |
|
| 839 | 887 | |
| 840 | 888 | // No slash on the end, please... |
| 841 | - if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') |
|
| 842 | - $ftp_path = substr($ftp_path, 0, -1); |
|
| 889 | + if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') { |
|
| 890 | + $ftp_path = substr($ftp_path, 0, -1); |
|
| 891 | + } |
|
| 843 | 892 | |
| 844 | 893 | fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n"); |
| 845 | 894 | if (!$this->check_response(250)) |
@@ -860,11 +909,13 @@ discard block |
||
| 860 | 909 | */ |
| 861 | 910 | public function chmod($ftp_file, $chmod) |
| 862 | 911 | { |
| 863 | - if (!is_resource($this->connection)) |
|
| 864 | - return false; |
|
| 912 | + if (!is_resource($this->connection)) { |
|
| 913 | + return false; |
|
| 914 | + } |
|
| 865 | 915 | |
| 866 | - if ($ftp_file == '') |
|
| 867 | - $ftp_file = '.'; |
|
| 916 | + if ($ftp_file == '') { |
|
| 917 | + $ftp_file = '.'; |
|
| 918 | + } |
|
| 868 | 919 | |
| 869 | 920 | // Do we have a file or a dir? |
| 870 | 921 | $is_dir = is_dir($ftp_file); |
@@ -880,9 +931,7 @@ discard block |
||
| 880 | 931 | { |
| 881 | 932 | $is_writable = true; |
| 882 | 933 | break; |
| 883 | - } |
|
| 884 | - |
|
| 885 | - else |
|
| 934 | + } else |
|
| 886 | 935 | { |
| 887 | 936 | // Convert the chmod value from octal (0777) to text ("777"). |
| 888 | 937 | fwrite($this->connection, 'SITE CHMOD ' . decoct($val) . ' ' . $ftp_file . "\r\n"); |
@@ -905,8 +954,9 @@ discard block |
||
| 905 | 954 | public function unlink($ftp_file) |
| 906 | 955 | { |
| 907 | 956 | // We are actually connected, right? |
| 908 | - if (!is_resource($this->connection)) |
|
| 909 | - return false; |
|
| 957 | + if (!is_resource($this->connection)) { |
|
| 958 | + return false; |
|
| 959 | + } |
|
| 910 | 960 | |
| 911 | 961 | // Delete file X. |
| 912 | 962 | fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n"); |
@@ -935,9 +985,9 @@ discard block |
||
| 935 | 985 | { |
| 936 | 986 | // Wait for a response that isn't continued with -, but don't wait too long. |
| 937 | 987 | $time = time(); |
| 938 | - do |
|
| 939 | - $this->last_message = fgets($this->connection, 1024); |
|
| 940 | - while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5); |
|
| 988 | + do { |
|
| 989 | + $this->last_message = fgets($this->connection, 1024); |
|
| 990 | + } while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5); |
|
| 941 | 991 | |
| 942 | 992 | // Was the desired response returned? |
| 943 | 993 | return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired; |
@@ -951,15 +1001,16 @@ discard block |
||
| 951 | 1001 | public function passive() |
| 952 | 1002 | { |
| 953 | 1003 | // We can't create a passive data connection without a primary one first being there. |
| 954 | - if (!is_resource($this->connection)) |
|
| 955 | - return false; |
|
| 1004 | + if (!is_resource($this->connection)) { |
|
| 1005 | + return false; |
|
| 1006 | + } |
|
| 956 | 1007 | |
| 957 | 1008 | // Request a passive connection - this means, we'll talk to you, you don't talk to us. |
| 958 | 1009 | @fwrite($this->connection, 'PASV' . "\r\n"); |
| 959 | 1010 | $time = time(); |
| 960 | - do |
|
| 961 | - $response = fgets($this->connection, 1024); |
|
| 962 | - while (strpos($response, ' ', 3) !== 3 && time() - $time < 5); |
|
| 1011 | + do { |
|
| 1012 | + $response = fgets($this->connection, 1024); |
|
| 1013 | + } while (strpos($response, ' ', 3) !== 3 && time() - $time < 5); |
|
| 963 | 1014 | |
| 964 | 1015 | // If it's not 227, we weren't given an IP and port, which means it failed. |
| 965 | 1016 | if (strpos($response, '227 ') !== 0) |
@@ -990,12 +1041,14 @@ discard block |
||
| 990 | 1041 | public function create_file($ftp_file) |
| 991 | 1042 | { |
| 992 | 1043 | // First, we have to be connected... very important. |
| 993 | - if (!is_resource($this->connection)) |
|
| 994 | - return false; |
|
| 1044 | + if (!is_resource($this->connection)) { |
|
| 1045 | + return false; |
|
| 1046 | + } |
|
| 995 | 1047 | |
| 996 | 1048 | // I'd like one passive mode, please! |
| 997 | - if (!$this->passive()) |
|
| 998 | - return false; |
|
| 1049 | + if (!$this->passive()) { |
|
| 1050 | + return false; |
|
| 1051 | + } |
|
| 999 | 1052 | |
| 1000 | 1053 | // Seems logical enough, so far... |
| 1001 | 1054 | fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n"); |
@@ -1030,12 +1083,14 @@ discard block |
||
| 1030 | 1083 | public function list_dir($ftp_path = '', $search = false) |
| 1031 | 1084 | { |
| 1032 | 1085 | // Are we even connected...? |
| 1033 | - if (!is_resource($this->connection)) |
|
| 1034 | - return false; |
|
| 1086 | + if (!is_resource($this->connection)) { |
|
| 1087 | + return false; |
|
| 1088 | + } |
|
| 1035 | 1089 | |
| 1036 | 1090 | // Passive... non-agressive... |
| 1037 | - if (!$this->passive()) |
|
| 1038 | - return false; |
|
| 1091 | + if (!$this->passive()) { |
|
| 1092 | + return false; |
|
| 1093 | + } |
|
| 1039 | 1094 | |
| 1040 | 1095 | // Get the listing! |
| 1041 | 1096 | fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n"); |
@@ -1051,8 +1106,9 @@ discard block |
||
| 1051 | 1106 | |
| 1052 | 1107 | // Read in the file listing. |
| 1053 | 1108 | $data = ''; |
| 1054 | - while (!feof($fp)) |
|
| 1055 | - $data .= fread($fp, 4096); |
|
| 1109 | + while (!feof($fp)) { |
|
| 1110 | + $data .= fread($fp, 4096); |
|
| 1111 | + } |
|
| 1056 | 1112 | fclose($fp); |
| 1057 | 1113 | |
| 1058 | 1114 | // Everything go okay? |
@@ -1074,21 +1130,23 @@ discard block |
||
| 1074 | 1130 | */ |
| 1075 | 1131 | public function locate($file, $listing = null) |
| 1076 | 1132 | { |
| 1077 | - if ($listing === null) |
|
| 1078 | - $listing = $this->list_dir('', true); |
|
| 1133 | + if ($listing === null) { |
|
| 1134 | + $listing = $this->list_dir('', true); |
|
| 1135 | + } |
|
| 1079 | 1136 | $listing = explode("\n", $listing); |
| 1080 | 1137 | |
| 1081 | 1138 | @fwrite($this->connection, 'PWD' . "\r\n"); |
| 1082 | 1139 | $time = time(); |
| 1083 | - do |
|
| 1084 | - $response = fgets($this->connection, 1024); |
|
| 1085 | - while ($response[3] != ' ' && time() - $time < 5); |
|
| 1140 | + do { |
|
| 1141 | + $response = fgets($this->connection, 1024); |
|
| 1142 | + } while ($response[3] != ' ' && time() - $time < 5); |
|
| 1086 | 1143 | |
| 1087 | 1144 | // Check for 257! |
| 1088 | - if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) |
|
| 1089 | - $current_dir = strtr($match[1], array('""' => '"')); |
|
| 1090 | - else |
|
| 1091 | - $current_dir = ''; |
|
| 1145 | + if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) { |
|
| 1146 | + $current_dir = strtr($match[1], array('""' => '"')); |
|
| 1147 | + } else { |
|
| 1148 | + $current_dir = ''; |
|
| 1149 | + } |
|
| 1092 | 1150 | |
| 1093 | 1151 | for ($i = 0, $n = count($listing); $i < $n; $i++) |
| 1094 | 1152 | { |
@@ -1101,12 +1159,15 @@ discard block |
||
| 1101 | 1159 | // Okay, this file's name is: |
| 1102 | 1160 | $listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]); |
| 1103 | 1161 | |
| 1104 | - if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) |
|
| 1105 | - return $listing[$i]; |
|
| 1106 | - if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) |
|
| 1107 | - return $listing[$i]; |
|
| 1108 | - if (basename($listing[$i]) == $file || $listing[$i] == $file) |
|
| 1109 | - return $listing[$i]; |
|
| 1162 | + if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) { |
|
| 1163 | + return $listing[$i]; |
|
| 1164 | + } |
|
| 1165 | + if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) { |
|
| 1166 | + return $listing[$i]; |
|
| 1167 | + } |
|
| 1168 | + if (basename($listing[$i]) == $file || $listing[$i] == $file) { |
|
| 1169 | + return $listing[$i]; |
|
| 1170 | + } |
|
| 1110 | 1171 | } |
| 1111 | 1172 | |
| 1112 | 1173 | return false; |
@@ -1121,8 +1182,9 @@ discard block |
||
| 1121 | 1182 | public function create_dir($ftp_dir) |
| 1122 | 1183 | { |
| 1123 | 1184 | // We must be connected to the server to do something. |
| 1124 | - if (!is_resource($this->connection)) |
|
| 1125 | - return false; |
|
| 1185 | + if (!is_resource($this->connection)) { |
|
| 1186 | + return false; |
|
| 1187 | + } |
|
| 1126 | 1188 | |
| 1127 | 1189 | // Make this new beautiful directory! |
| 1128 | 1190 | fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n"); |
@@ -1154,35 +1216,40 @@ discard block |
||
| 1154 | 1216 | |
| 1155 | 1217 | $path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => '')); |
| 1156 | 1218 | |
| 1157 | - if (substr($path, -1) == '/') |
|
| 1158 | - $path = substr($path, 0, -1); |
|
| 1219 | + if (substr($path, -1) == '/') { |
|
| 1220 | + $path = substr($path, 0, -1); |
|
| 1221 | + } |
|
| 1159 | 1222 | |
| 1160 | - if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) |
|
| 1161 | - $path .= dirname($_SERVER['PHP_SELF']); |
|
| 1223 | + if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) { |
|
| 1224 | + $path .= dirname($_SERVER['PHP_SELF']); |
|
| 1225 | + } |
|
| 1226 | + } elseif (strpos($filesystem_path, '/var/www/') === 0) { |
|
| 1227 | + $path = substr($filesystem_path, 8); |
|
| 1228 | + } else { |
|
| 1229 | + $path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => '')); |
|
| 1162 | 1230 | } |
| 1163 | - elseif (strpos($filesystem_path, '/var/www/') === 0) |
|
| 1164 | - $path = substr($filesystem_path, 8); |
|
| 1165 | - else |
|
| 1166 | - $path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => '')); |
|
| 1231 | + } else { |
|
| 1232 | + $path = ''; |
|
| 1167 | 1233 | } |
| 1168 | - else |
|
| 1169 | - $path = ''; |
|
| 1170 | 1234 | |
| 1171 | 1235 | if (is_resource($this->connection) && $this->list_dir($path) == '') |
| 1172 | 1236 | { |
| 1173 | 1237 | $data = $this->list_dir('', true); |
| 1174 | 1238 | |
| 1175 | - if ($lookup_file === null) |
|
| 1176 | - $lookup_file = $_SERVER['PHP_SELF']; |
|
| 1239 | + if ($lookup_file === null) { |
|
| 1240 | + $lookup_file = $_SERVER['PHP_SELF']; |
|
| 1241 | + } |
|
| 1177 | 1242 | |
| 1178 | 1243 | $found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data)); |
| 1179 | - if ($found_path == false) |
|
| 1180 | - $found_path = dirname($this->locate(basename($lookup_file))); |
|
| 1181 | - if ($found_path != false) |
|
| 1182 | - $path = $found_path; |
|
| 1244 | + if ($found_path == false) { |
|
| 1245 | + $found_path = dirname($this->locate(basename($lookup_file))); |
|
| 1246 | + } |
|
| 1247 | + if ($found_path != false) { |
|
| 1248 | + $path = $found_path; |
|
| 1249 | + } |
|
| 1250 | + } elseif (is_resource($this->connection)) { |
|
| 1251 | + $found_path = true; |
|
| 1183 | 1252 | } |
| 1184 | - elseif (is_resource($this->connection)) |
|
| 1185 | - $found_path = true; |
|
| 1186 | 1253 | |
| 1187 | 1254 | return array($username, $path, isset($found_path)); |
| 1188 | 1255 | } |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | ) |
| 51 | 51 | ); |
| 52 | 52 | $members = array(); |
| 53 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 54 | - $members[$row['id_member']] = array( |
|
| 53 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 54 | + $members[$row['id_member']] = array( |
|
| 55 | 55 | 'id' => $row['id_member'], |
| 56 | 56 | 'real_name' => $row['real_name'], |
| 57 | 57 | 'email_address' => $row['email_address'], |
@@ -62,6 +62,7 @@ discard block |
||
| 62 | 62 | ), |
| 63 | 63 | 'lngfile' => $row['lngfile'], |
| 64 | 64 | ); |
| 65 | + } |
|
| 65 | 66 | $smcFunc['db_free_result']($request); |
| 66 | 67 | |
| 67 | 68 | return $members; |
@@ -83,13 +84,14 @@ discard block |
||
| 83 | 84 | |
| 84 | 85 | call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members)); |
| 85 | 86 | |
| 86 | - foreach ($members as $member) |
|
| 87 | - $smcFunc['db_insert']('ignore', |
|
| 87 | + foreach ($members as $member) { |
|
| 88 | + $smcFunc['db_insert']('ignore', |
|
| 88 | 89 | '{db_prefix}mentions', |
| 89 | 90 | array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'), |
| 90 | 91 | array((int) $content_id, $content_type, $id_member, $member['id'], time()), |
| 91 | 92 | array('content_id', 'content_type', 'id_mentioned') |
| 92 | 93 | ); |
| 94 | + } |
|
| 93 | 95 | } |
| 94 | 96 | |
| 95 | 97 | /** |
@@ -103,8 +105,9 @@ discard block |
||
| 103 | 105 | */ |
| 104 | 106 | public static function getBody($body, array $members) |
| 105 | 107 | { |
| 106 | - foreach ($members as $member) |
|
| 107 | - $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
| 108 | + foreach ($members as $member) { |
|
| 109 | + $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
| 110 | + } |
|
| 108 | 111 | |
| 109 | 112 | return $body; |
| 110 | 113 | } |
@@ -123,8 +126,9 @@ discard block |
||
| 123 | 126 | |
| 124 | 127 | $possible_names = self::getPossibleMentions($body); |
| 125 | 128 | |
| 126 | - if (empty($possible_names) || !allowedTo('mention')) |
|
| 127 | - return array(); |
|
| 129 | + if (empty($possible_names) || !allowedTo('mention')) { |
|
| 130 | + return array(); |
|
| 131 | + } |
|
| 128 | 132 | |
| 129 | 133 | $request = $smcFunc['db_query']('', ' |
| 130 | 134 | SELECT id_member, real_name |
@@ -140,8 +144,9 @@ discard block |
||
| 140 | 144 | $members = array(); |
| 141 | 145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 142 | 146 | { |
| 143 | - if (stripos($body, static::$char . $row['real_name']) === false) |
|
| 144 | - continue; |
|
| 147 | + if (stripos($body, static::$char . $row['real_name']) === false) { |
|
| 148 | + continue; |
|
| 149 | + } |
|
| 145 | 150 | |
| 146 | 151 | $members[$row['id_member']] = array( |
| 147 | 152 | 'id' => $row['id_member'], |
@@ -185,8 +190,9 @@ discard block |
||
| 185 | 190 | $body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace(' ', ' ', $body)), ENT_QUOTES); |
| 186 | 191 | |
| 187 | 192 | // Remove quotes, we don't want to get double mentions. |
| 188 | - while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) |
|
| 189 | - $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
| 193 | + while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) { |
|
| 194 | + $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | $matches = array(); |
| 192 | 198 | $string = str_split($body); |
@@ -197,9 +203,9 @@ discard block |
||
| 197 | 203 | { |
| 198 | 204 | $depth++; |
| 199 | 205 | $matches[] = array(); |
| 206 | + } elseif ($char == "\n") { |
|
| 207 | + $depth = 0; |
|
| 200 | 208 | } |
| 201 | - elseif ($char == "\n") |
|
| 202 | - $depth = 0; |
|
| 203 | 209 | |
| 204 | 210 | for ($i = $depth; $i > 0; $i--) |
| 205 | 211 | { |
@@ -212,8 +218,9 @@ discard block |
||
| 212 | 218 | } |
| 213 | 219 | } |
| 214 | 220 | |
| 215 | - foreach ($matches as $k => $match) |
|
| 216 | - $matches[$k] = substr(implode('', $match), 1); |
|
| 221 | + foreach ($matches as $k => $match) { |
|
| 222 | + $matches[$k] = substr(implode('', $match), 1); |
|
| 223 | + } |
|
| 217 | 224 | |
| 218 | 225 | // Names can have spaces, other breaks, or they can't...we try to match every possible |
| 219 | 226 | // combination. |
@@ -223,8 +230,9 @@ discard block |
||
| 223 | 230 | $match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 224 | 231 | $count = count($match); |
| 225 | 232 | |
| 226 | - for ($i = 1; $i <= $count; $i++) |
|
| 227 | - $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
| 233 | + for ($i = 1; $i <= $count; $i++) { |
|
| 234 | + $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
| 235 | + } |
|
| 228 | 236 | } |
| 229 | 237 | |
| 230 | 238 | $names = array_unique($names); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | 'member_name' => $regOptions['username'], |
| 587 | 587 | 'email_address' => $regOptions['email'], |
| 588 | 588 | 'passwd' => hash_password($regOptions['username'], $regOptions['password']), |
| 589 | - 'password_salt' => substr(md5(mt_rand()), 0, 4) , |
|
| 589 | + 'password_salt' => substr(md5(mt_rand()), 0, 4), |
|
| 590 | 590 | 'posts' => 0, |
| 591 | 591 | 'date_registered' => time(), |
| 592 | 592 | 'member_ip' => $regOptions['interface'] == 'admin' ? '127.0.0.1' : $user_info['ip'], |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | 'time_offset', |
| 677 | 677 | ); |
| 678 | 678 | $knownInets = array( |
| 679 | - 'member_ip','member_ip2', |
|
| 679 | + 'member_ip', 'member_ip2', |
|
| 680 | 680 | ); |
| 681 | 681 | |
| 682 | 682 | // Call an optional function to validate the users' input. |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
| 905 | 905 | |
| 906 | 906 | //when we got no wildcard we can use equal -> fast |
| 907 | - $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '=' ); |
|
| 907 | + $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '='); |
|
| 908 | 908 | |
| 909 | 909 | // Make sure they don't want someone else's name. |
| 910 | 910 | $request = $smcFunc['db_query']('', ' |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | $user_info['buddies'][] = $userReceiver; |
| 1274 | 1274 | |
| 1275 | 1275 | // And add a nice alert. Don't abuse though! |
| 1276 | - if ((cache_get_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, 86400)) == null) |
|
| 1276 | + if ((cache_get_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, 86400)) == null) |
|
| 1277 | 1277 | { |
| 1278 | 1278 | $smcFunc['db_insert']('insert', |
| 1279 | 1279 | '{db_prefix}background_tasks', |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | ); |
| 1289 | 1289 | |
| 1290 | 1290 | // Store this in a cache entry to avoid creating multiple alerts. Give it a long life cycle. |
| 1291 | - cache_put_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, '1', 86400); |
|
| 1291 | + cache_put_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, '1', 86400); |
|
| 1292 | 1292 | } |
| 1293 | 1293 | } |
| 1294 | 1294 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Delete one or more members. |
@@ -43,30 +44,32 @@ discard block |
||
| 43 | 44 | setMemoryLimit('128M'); |
| 44 | 45 | |
| 45 | 46 | // If it's not an array, make it so! |
| 46 | - if (!is_array($users)) |
|
| 47 | - $users = array($users); |
|
| 48 | - else |
|
| 49 | - $users = array_unique($users); |
|
| 47 | + if (!is_array($users)) { |
|
| 48 | + $users = array($users); |
|
| 49 | + } else { |
|
| 50 | + $users = array_unique($users); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Make sure there's no void user in here. |
| 52 | 54 | $users = array_diff($users, array(0)); |
| 53 | 55 | |
| 54 | 56 | // How many are they deleting? |
| 55 | - if (empty($users)) |
|
| 56 | - return; |
|
| 57 | - elseif (count($users) == 1) |
|
| 57 | + if (empty($users)) { |
|
| 58 | + return; |
|
| 59 | + } elseif (count($users) == 1) |
|
| 58 | 60 | { |
| 59 | 61 | list ($user) = $users; |
| 60 | 62 | |
| 61 | - if ($user == $user_info['id']) |
|
| 62 | - isAllowedTo('profile_remove_own'); |
|
| 63 | - else |
|
| 64 | - isAllowedTo('profile_remove_any'); |
|
| 65 | - } |
|
| 66 | - else |
|
| 63 | + if ($user == $user_info['id']) { |
|
| 64 | + isAllowedTo('profile_remove_own'); |
|
| 65 | + } else { |
|
| 66 | + isAllowedTo('profile_remove_any'); |
|
| 67 | + } |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | - foreach ($users as $k => $v) |
|
| 69 | - $users[$k] = (int) $v; |
|
| 70 | + foreach ($users as $k => $v) { |
|
| 71 | + $users[$k] = (int) $v; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | // Deleting more than one? You can't have more than one account... |
| 72 | 75 | isAllowedTo('profile_remove_any'); |
@@ -88,26 +91,30 @@ discard block |
||
| 88 | 91 | $user_log_details = array(); |
| 89 | 92 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 90 | 93 | { |
| 91 | - if ($row['is_admin']) |
|
| 92 | - $admins[] = $row['id_member']; |
|
| 94 | + if ($row['is_admin']) { |
|
| 95 | + $admins[] = $row['id_member']; |
|
| 96 | + } |
|
| 93 | 97 | $user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']); |
| 94 | 98 | } |
| 95 | 99 | $smcFunc['db_free_result']($request); |
| 96 | 100 | |
| 97 | - if (empty($user_log_details)) |
|
| 98 | - return; |
|
| 101 | + if (empty($user_log_details)) { |
|
| 102 | + return; |
|
| 103 | + } |
|
| 99 | 104 | |
| 100 | 105 | // Make sure they aren't trying to delete administrators if they aren't one. But don't bother checking if it's just themself. |
| 101 | 106 | if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id'])))) |
| 102 | 107 | { |
| 103 | 108 | $users = array_diff($users, $admins); |
| 104 | - foreach ($admins as $id) |
|
| 105 | - unset($user_log_details[$id]); |
|
| 109 | + foreach ($admins as $id) { |
|
| 110 | + unset($user_log_details[$id]); |
|
| 111 | + } |
|
| 106 | 112 | } |
| 107 | 113 | |
| 108 | 114 | // No one left? |
| 109 | - if (empty($users)) |
|
| 110 | - return; |
|
| 115 | + if (empty($users)) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 111 | 118 | |
| 112 | 119 | // Log the action - regardless of who is deleting it. |
| 113 | 120 | $log_changes = array(); |
@@ -124,8 +131,9 @@ discard block |
||
| 124 | 131 | ); |
| 125 | 132 | |
| 126 | 133 | // Remove any cached data if enabled. |
| 127 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 128 | - cache_put_data('user_settings-' . $user[0], null, 60); |
|
| 134 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 135 | + cache_put_data('user_settings-' . $user[0], null, 60); |
|
| 136 | + } |
|
| 129 | 137 | } |
| 130 | 138 | |
| 131 | 139 | // Make these peoples' posts guest posts. |
@@ -388,8 +396,8 @@ discard block |
||
| 388 | 396 | 'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users), |
| 389 | 397 | ) |
| 390 | 398 | ); |
| 391 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 392 | - $smcFunc['db_query']('', ' |
|
| 399 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 400 | + $smcFunc['db_query']('', ' |
|
| 393 | 401 | UPDATE {db_prefix}members |
| 394 | 402 | SET |
| 395 | 403 | pm_ignore_list = {string:pm_ignore_list}, |
@@ -401,6 +409,7 @@ discard block |
||
| 401 | 409 | 'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users)), |
| 402 | 410 | ) |
| 403 | 411 | ); |
| 412 | + } |
|
| 404 | 413 | $smcFunc['db_free_result']($request); |
| 405 | 414 | |
| 406 | 415 | // Make sure no member's birthday is still sticking in the calendar... |
@@ -455,29 +464,34 @@ discard block |
||
| 455 | 464 | elseif ($regOptions['interface'] == 'guest') |
| 456 | 465 | { |
| 457 | 466 | // You cannot register twice... |
| 458 | - if (empty($user_info['is_guest'])) |
|
| 459 | - redirectexit(); |
|
| 467 | + if (empty($user_info['is_guest'])) { |
|
| 468 | + redirectexit(); |
|
| 469 | + } |
|
| 460 | 470 | |
| 461 | 471 | // Make sure they didn't just register with this session. |
| 462 | - if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) |
|
| 463 | - fatal_lang_error('register_only_once', false); |
|
| 472 | + if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) { |
|
| 473 | + fatal_lang_error('register_only_once', false); |
|
| 474 | + } |
|
| 464 | 475 | } |
| 465 | 476 | |
| 466 | 477 | // Spaces and other odd characters are evil... |
| 467 | 478 | $regOptions['username'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $regOptions['username'])); |
| 468 | 479 | |
| 469 | 480 | // @todo Separate the sprintf? |
| 470 | - if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) |
|
| 471 | - $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
| 481 | + if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) { |
|
| 482 | + $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
| 483 | + } |
|
| 472 | 484 | |
| 473 | 485 | $username_validation_errors = validateUsername(0, $regOptions['username'], true, !empty($regOptions['check_reserved_name'])); |
| 474 | - if (!empty($username_validation_errors)) |
|
| 475 | - $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
| 486 | + if (!empty($username_validation_errors)) { |
|
| 487 | + $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
| 488 | + } |
|
| 476 | 489 | |
| 477 | 490 | // Generate a validation code if it's supposed to be emailed. |
| 478 | 491 | $validation_code = ''; |
| 479 | - if ($regOptions['require'] == 'activation') |
|
| 480 | - $validation_code = generateValidationCode(); |
|
| 492 | + if ($regOptions['require'] == 'activation') { |
|
| 493 | + $validation_code = generateValidationCode(); |
|
| 494 | + } |
|
| 481 | 495 | |
| 482 | 496 | // If you haven't put in a password generate one. |
| 483 | 497 | if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '') |
@@ -487,8 +501,9 @@ discard block |
||
| 487 | 501 | $regOptions['password_check'] = $regOptions['password']; |
| 488 | 502 | } |
| 489 | 503 | // Does the first password match the second? |
| 490 | - elseif ($regOptions['password'] != $regOptions['password_check']) |
|
| 491 | - $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
| 504 | + elseif ($regOptions['password'] != $regOptions['password_check']) { |
|
| 505 | + $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
| 506 | + } |
|
| 492 | 507 | |
| 493 | 508 | // That's kind of easy to guess... |
| 494 | 509 | if ($regOptions['password'] == '') |
@@ -502,13 +517,15 @@ discard block |
||
| 502 | 517 | $passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email'])); |
| 503 | 518 | |
| 504 | 519 | // Password isn't legal? |
| 505 | - if ($passwordError != null) |
|
| 506 | - $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
| 520 | + if ($passwordError != null) { |
|
| 521 | + $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
| 522 | + } |
|
| 507 | 523 | } |
| 508 | 524 | |
| 509 | 525 | // You may not be allowed to register this email. |
| 510 | - if (!empty($regOptions['check_email_ban'])) |
|
| 511 | - isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
| 526 | + if (!empty($regOptions['check_email_ban'])) { |
|
| 527 | + isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
| 528 | + } |
|
| 512 | 529 | |
| 513 | 530 | // Check if the email address is in use. |
| 514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -523,8 +540,9 @@ discard block |
||
| 523 | 540 | ) |
| 524 | 541 | ); |
| 525 | 542 | // @todo Separate the sprintf? |
| 526 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 527 | - $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
| 543 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 544 | + $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
| 545 | + } |
|
| 528 | 546 | |
| 529 | 547 | $smcFunc['db_free_result']($request); |
| 530 | 548 | |
@@ -539,24 +557,27 @@ discard block |
||
| 539 | 557 | 1 = The text/index. |
| 540 | 558 | 2 = Whether to log. |
| 541 | 559 | 3 = sprintf data if necessary. */ |
| 542 | - if ($error[0] == 'lang') |
|
| 543 | - loadLanguage('Errors'); |
|
| 560 | + if ($error[0] == 'lang') { |
|
| 561 | + loadLanguage('Errors'); |
|
| 562 | + } |
|
| 544 | 563 | $message = $error[0] == 'lang' ? (empty($error[3]) ? $txt[$error[1]] : vsprintf($txt[$error[1]], $error[3])) : $error[1]; |
| 545 | 564 | |
| 546 | 565 | // What to do, what to do, what to do. |
| 547 | 566 | if ($return_errors) |
| 548 | 567 | { |
| 549 | - if (!empty($error[2])) |
|
| 550 | - log_error($message, $error[2]); |
|
| 568 | + if (!empty($error[2])) { |
|
| 569 | + log_error($message, $error[2]); |
|
| 570 | + } |
|
| 551 | 571 | $reg_errors[$key] = $message; |
| 572 | + } else { |
|
| 573 | + fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
| 552 | 574 | } |
| 553 | - else |
|
| 554 | - fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
| 555 | 575 | } |
| 556 | 576 | |
| 557 | 577 | // If there's any errors left return them at once! |
| 558 | - if (!empty($reg_errors)) |
|
| 559 | - return $reg_errors; |
|
| 578 | + if (!empty($reg_errors)) { |
|
| 579 | + return $reg_errors; |
|
| 580 | + } |
|
| 560 | 581 | |
| 561 | 582 | $reservedVars = array( |
| 562 | 583 | 'actual_theme_url', |
@@ -578,8 +599,9 @@ discard block |
||
| 578 | 599 | ); |
| 579 | 600 | |
| 580 | 601 | // Can't change reserved vars. |
| 581 | - if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) |
|
| 582 | - fatal_lang_error('no_theme'); |
|
| 602 | + if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) { |
|
| 603 | + fatal_lang_error('no_theme'); |
|
| 604 | + } |
|
| 583 | 605 | |
| 584 | 606 | // Some of these might be overwritten. (the lower ones that are in the arrays below.) |
| 585 | 607 | $regOptions['register_vars'] = array( |
@@ -621,14 +643,17 @@ discard block |
||
| 621 | 643 | $regOptions['register_vars']['validation_code'] = ''; |
| 622 | 644 | } |
| 623 | 645 | // Maybe it can be activated right away? |
| 624 | - elseif ($regOptions['require'] == 'nothing') |
|
| 625 | - $regOptions['register_vars']['is_activated'] = 1; |
|
| 646 | + elseif ($regOptions['require'] == 'nothing') { |
|
| 647 | + $regOptions['register_vars']['is_activated'] = 1; |
|
| 648 | + } |
|
| 626 | 649 | // Maybe it must be activated by email? |
| 627 | - elseif ($regOptions['require'] == 'activation') |
|
| 628 | - $regOptions['register_vars']['is_activated'] = 0; |
|
| 650 | + elseif ($regOptions['require'] == 'activation') { |
|
| 651 | + $regOptions['register_vars']['is_activated'] = 0; |
|
| 652 | + } |
|
| 629 | 653 | // Otherwise it must be awaiting approval! |
| 630 | - else |
|
| 631 | - $regOptions['register_vars']['is_activated'] = 3; |
|
| 654 | + else { |
|
| 655 | + $regOptions['register_vars']['is_activated'] = 3; |
|
| 656 | + } |
|
| 632 | 657 | |
| 633 | 658 | if (isset($regOptions['memberGroup'])) |
| 634 | 659 | { |
@@ -647,24 +672,28 @@ discard block |
||
| 647 | 672 | 'is_protected' => 1, |
| 648 | 673 | ) |
| 649 | 674 | ); |
| 650 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 651 | - $unassignableGroups[] = $row['id_group']; |
|
| 675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 676 | + $unassignableGroups[] = $row['id_group']; |
|
| 677 | + } |
|
| 652 | 678 | $smcFunc['db_free_result']($request); |
| 653 | 679 | |
| 654 | - if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) |
|
| 655 | - $regOptions['register_vars']['id_group'] = 0; |
|
| 680 | + if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) { |
|
| 681 | + $regOptions['register_vars']['id_group'] = 0; |
|
| 682 | + } |
|
| 656 | 683 | } |
| 657 | 684 | |
| 658 | 685 | // Integrate optional member settings to be set. |
| 659 | - if (!empty($regOptions['extra_register_vars'])) |
|
| 660 | - foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
| 686 | + if (!empty($regOptions['extra_register_vars'])) { |
|
| 687 | + foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
| 661 | 688 | $regOptions['register_vars'][$var] = $value; |
| 689 | + } |
|
| 662 | 690 | |
| 663 | 691 | // Integrate optional user theme options to be set. |
| 664 | 692 | $theme_vars = array(); |
| 665 | - if (!empty($regOptions['theme_vars'])) |
|
| 666 | - foreach ($regOptions['theme_vars'] as $var => $value) |
|
| 693 | + if (!empty($regOptions['theme_vars'])) { |
|
| 694 | + foreach ($regOptions['theme_vars'] as $var => $value) |
|
| 667 | 695 | $theme_vars[$var] = $value; |
| 696 | + } |
|
| 668 | 697 | |
| 669 | 698 | // Right, now let's prepare for insertion. |
| 670 | 699 | $knownInts = array( |
@@ -687,14 +716,15 @@ discard block |
||
| 687 | 716 | foreach ($regOptions['register_vars'] as $var => $val) |
| 688 | 717 | { |
| 689 | 718 | $type = 'string'; |
| 690 | - if (in_array($var, $knownInts)) |
|
| 691 | - $type = 'int'; |
|
| 692 | - elseif (in_array($var, $knownFloats)) |
|
| 693 | - $type = 'float'; |
|
| 694 | - elseif (in_array($var, $knownInets)) |
|
| 695 | - $type = 'inet'; |
|
| 696 | - elseif ($var == 'birthdate') |
|
| 697 | - $type = 'date'; |
|
| 719 | + if (in_array($var, $knownInts)) { |
|
| 720 | + $type = 'int'; |
|
| 721 | + } elseif (in_array($var, $knownFloats)) { |
|
| 722 | + $type = 'float'; |
|
| 723 | + } elseif (in_array($var, $knownInets)) { |
|
| 724 | + $type = 'inet'; |
|
| 725 | + } elseif ($var == 'birthdate') { |
|
| 726 | + $type = 'date'; |
|
| 727 | + } |
|
| 698 | 728 | |
| 699 | 729 | $column_names[$var] = $type; |
| 700 | 730 | $values[$var] = $val; |
@@ -713,17 +743,19 @@ discard block |
||
| 713 | 743 | call_integration_hook('integrate_post_register', array(&$regOptions, &$theme_vars, &$memberID)); |
| 714 | 744 | |
| 715 | 745 | // Update the number of members and latest member's info - and pass the name, but remove the 's. |
| 716 | - if ($regOptions['register_vars']['is_activated'] == 1) |
|
| 717 | - updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
| 718 | - else |
|
| 719 | - updateStats('member'); |
|
| 746 | + if ($regOptions['register_vars']['is_activated'] == 1) { |
|
| 747 | + updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
| 748 | + } else { |
|
| 749 | + updateStats('member'); |
|
| 750 | + } |
|
| 720 | 751 | |
| 721 | 752 | // Theme variables too? |
| 722 | 753 | if (!empty($theme_vars)) |
| 723 | 754 | { |
| 724 | 755 | $inserts = array(); |
| 725 | - foreach ($theme_vars as $var => $val) |
|
| 726 | - $inserts[] = array($memberID, $var, $val); |
|
| 756 | + foreach ($theme_vars as $var => $val) { |
|
| 757 | + $inserts[] = array($memberID, $var, $val); |
|
| 758 | + } |
|
| 727 | 759 | $smcFunc['db_insert']('insert', |
| 728 | 760 | '{db_prefix}themes', |
| 729 | 761 | array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
@@ -738,10 +770,11 @@ discard block |
||
| 738 | 770 | // Administrative registrations are a bit different... |
| 739 | 771 | if ($regOptions['interface'] == 'admin') |
| 740 | 772 | { |
| 741 | - if ($regOptions['require'] == 'activation') |
|
| 742 | - $email_message = 'admin_register_activate'; |
|
| 743 | - elseif (!empty($regOptions['send_welcome_email'])) |
|
| 744 | - $email_message = 'admin_register_immediate'; |
|
| 773 | + if ($regOptions['require'] == 'activation') { |
|
| 774 | + $email_message = 'admin_register_activate'; |
|
| 775 | + } elseif (!empty($regOptions['send_welcome_email'])) { |
|
| 776 | + $email_message = 'admin_register_immediate'; |
|
| 777 | + } |
|
| 745 | 778 | |
| 746 | 779 | if (isset($email_message)) |
| 747 | 780 | { |
@@ -792,16 +825,17 @@ discard block |
||
| 792 | 825 | 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', |
| 793 | 826 | ); |
| 794 | 827 | |
| 795 | - if ($regOptions['require'] == 'activation') |
|
| 796 | - $replacements += array( |
|
| 828 | + if ($regOptions['require'] == 'activation') { |
|
| 829 | + $replacements += array( |
|
| 797 | 830 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code, |
| 798 | 831 | 'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID, |
| 799 | 832 | 'ACTIVATIONCODE' => $validation_code, |
| 800 | 833 | ); |
| 801 | - else |
|
| 802 | - $replacements += array( |
|
| 834 | + } else { |
|
| 835 | + $replacements += array( |
|
| 803 | 836 | 'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID, |
| 804 | 837 | ); |
| 838 | + } |
|
| 805 | 839 | |
| 806 | 840 | $emaildata = loadEmailTemplate('register_' . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements); |
| 807 | 841 | |
@@ -866,39 +900,45 @@ discard block |
||
| 866 | 900 | // Check each name in the list... |
| 867 | 901 | foreach ($reservedNames as $reserved) |
| 868 | 902 | { |
| 869 | - if ($reserved == '') |
|
| 870 | - continue; |
|
| 903 | + if ($reserved == '') { |
|
| 904 | + continue; |
|
| 905 | + } |
|
| 871 | 906 | |
| 872 | 907 | // The admin might've used entities too, level the playing field. |
| 873 | 908 | $reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved); |
| 874 | 909 | |
| 875 | 910 | // Case sensitive name? |
| 876 | - if (empty($modSettings['reserveCase'])) |
|
| 877 | - $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
| 911 | + if (empty($modSettings['reserveCase'])) { |
|
| 912 | + $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
| 913 | + } |
|
| 878 | 914 | |
| 879 | 915 | // If it's not just entire word, check for it in there somewhere... |
| 880 | - if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) |
|
| 881 | - if ($fatal) |
|
| 916 | + if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) { |
|
| 917 | + if ($fatal) |
|
| 882 | 918 | fatal_lang_error('username_reserved', 'password', array($reserved)); |
| 883 | - else |
|
| 884 | - return true; |
|
| 919 | + } else { |
|
| 920 | + return true; |
|
| 921 | + } |
|
| 885 | 922 | } |
| 886 | 923 | |
| 887 | 924 | $censor_name = $name; |
| 888 | - if (censorText($censor_name) != $name) |
|
| 889 | - if ($fatal) |
|
| 925 | + if (censorText($censor_name) != $name) { |
|
| 926 | + if ($fatal) |
|
| 890 | 927 | fatal_lang_error('name_censored', 'password', array($name)); |
| 891 | - else |
|
| 892 | - return true; |
|
| 928 | + } else { |
|
| 929 | + return true; |
|
| 930 | + } |
|
| 893 | 931 | } |
| 894 | 932 | |
| 895 | 933 | // Characters we just shouldn't allow, regardless. |
| 896 | - foreach (array('*') as $char) |
|
| 897 | - if (strpos($checkName, $char) !== false) |
|
| 934 | + foreach (array('*') as $char) { |
|
| 935 | + if (strpos($checkName, $char) !== false) |
|
| 898 | 936 | if ($fatal) |
| 899 | 937 | fatal_lang_error('username_reserved', 'password', array($char)); |
| 900 | - else |
|
| 901 | - return true; |
|
| 938 | + } |
|
| 939 | + else { |
|
| 940 | + return true; |
|
| 941 | + } |
|
| 902 | 942 | |
| 903 | 943 | // Get rid of any SQL parts of the reserved name... |
| 904 | 944 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
@@ -980,8 +1020,9 @@ discard block |
||
| 980 | 1020 | 'permission' => $permission, |
| 981 | 1021 | ) |
| 982 | 1022 | ); |
| 983 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 984 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1023 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1024 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1025 | + } |
|
| 985 | 1026 | $smcFunc['db_free_result']($request); |
| 986 | 1027 | } |
| 987 | 1028 | |
@@ -989,9 +1030,9 @@ discard block |
||
| 989 | 1030 | else |
| 990 | 1031 | { |
| 991 | 1032 | // First get the profile of the given board. |
| 992 | - if (isset($board_info['id']) && $board_info['id'] == $board_id) |
|
| 993 | - $profile_id = $board_info['profile']; |
|
| 994 | - elseif ($board_id !== 0) |
|
| 1033 | + if (isset($board_info['id']) && $board_info['id'] == $board_id) { |
|
| 1034 | + $profile_id = $board_info['profile']; |
|
| 1035 | + } elseif ($board_id !== 0) |
|
| 995 | 1036 | { |
| 996 | 1037 | $request = $smcFunc['db_query']('', ' |
| 997 | 1038 | SELECT id_profile |
@@ -1002,13 +1043,14 @@ discard block |
||
| 1002 | 1043 | 'id_board' => $board_id, |
| 1003 | 1044 | ) |
| 1004 | 1045 | ); |
| 1005 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1006 | - fatal_lang_error('no_board'); |
|
| 1046 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1047 | + fatal_lang_error('no_board'); |
|
| 1048 | + } |
|
| 1007 | 1049 | list ($profile_id) = $smcFunc['db_fetch_row']($request); |
| 1008 | 1050 | $smcFunc['db_free_result']($request); |
| 1051 | + } else { |
|
| 1052 | + $profile_id = 1; |
|
| 1009 | 1053 | } |
| 1010 | - else |
|
| 1011 | - $profile_id = 1; |
|
| 1012 | 1054 | |
| 1013 | 1055 | $request = $smcFunc['db_query']('', ' |
| 1014 | 1056 | SELECT bp.id_group, bp.add_deny |
@@ -1020,8 +1062,9 @@ discard block |
||
| 1020 | 1062 | 'permission' => $permission, |
| 1021 | 1063 | ) |
| 1022 | 1064 | ); |
| 1023 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1024 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1065 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1066 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
| 1067 | + } |
|
| 1025 | 1068 | $smcFunc['db_free_result']($request); |
| 1026 | 1069 | |
| 1027 | 1070 | $moderator_groups = array(); |
@@ -1030,8 +1073,7 @@ discard block |
||
| 1030 | 1073 | if (isset($board_info['moderator_groups'])) |
| 1031 | 1074 | { |
| 1032 | 1075 | $moderator_groups = array_keys($board_info['moderator_groups']); |
| 1033 | - } |
|
| 1034 | - elseif ($board_id !== 0) |
|
| 1076 | + } elseif ($board_id !== 0) |
|
| 1035 | 1077 | { |
| 1036 | 1078 | // Get the groups that can moderate this board |
| 1037 | 1079 | $request = $smcFunc['db_query']('', ' |
@@ -1116,8 +1158,9 @@ discard block |
||
| 1116 | 1158 | ) |
| 1117 | 1159 | ); |
| 1118 | 1160 | $members = array(); |
| 1119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1120 | - $members[] = $row['id_member']; |
|
| 1161 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1162 | + $members[] = $row['id_member']; |
|
| 1163 | + } |
|
| 1121 | 1164 | $smcFunc['db_free_result']($request); |
| 1122 | 1165 | |
| 1123 | 1166 | return $members; |
@@ -1190,10 +1233,12 @@ discard block |
||
| 1190 | 1233 | } |
| 1191 | 1234 | |
| 1192 | 1235 | $query_parts = array(); |
| 1193 | - if (!empty($email)) |
|
| 1194 | - $query_parts[] = 'poster_email = {string:email_address}'; |
|
| 1195 | - if (!empty($membername)) |
|
| 1196 | - $query_parts[] = 'poster_name = {string:member_name}'; |
|
| 1236 | + if (!empty($email)) { |
|
| 1237 | + $query_parts[] = 'poster_email = {string:email_address}'; |
|
| 1238 | + } |
|
| 1239 | + if (!empty($membername)) { |
|
| 1240 | + $query_parts[] = 'poster_name = {string:member_name}'; |
|
| 1241 | + } |
|
| 1197 | 1242 | $query = implode(' AND ', $query_parts); |
| 1198 | 1243 | |
| 1199 | 1244 | // Finally, update the posts themselves! |
@@ -1260,12 +1305,14 @@ discard block |
||
| 1260 | 1305 | |
| 1261 | 1306 | $userReceiver = (int) !empty($_REQUEST['u']) ? $_REQUEST['u'] : 0; |
| 1262 | 1307 | |
| 1263 | - if (empty($userReceiver)) |
|
| 1264 | - fatal_lang_error('no_access', false); |
|
| 1308 | + if (empty($userReceiver)) { |
|
| 1309 | + fatal_lang_error('no_access', false); |
|
| 1310 | + } |
|
| 1265 | 1311 | |
| 1266 | 1312 | // Remove if it's already there... |
| 1267 | - if (in_array($userReceiver, $user_info['buddies'])) |
|
| 1268 | - $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
| 1313 | + if (in_array($userReceiver, $user_info['buddies'])) { |
|
| 1314 | + $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
| 1315 | + } |
|
| 1269 | 1316 | |
| 1270 | 1317 | // ...or add if it's not and if it's not you. |
| 1271 | 1318 | elseif ($user_info['id'] != $userReceiver) |
@@ -1340,8 +1387,9 @@ discard block |
||
| 1340 | 1387 | $smcFunc['db_free_result']($request); |
| 1341 | 1388 | |
| 1342 | 1389 | // If we want duplicates pass the members array off. |
| 1343 | - if ($get_duplicates) |
|
| 1344 | - populateDuplicateMembers($members); |
|
| 1390 | + if ($get_duplicates) { |
|
| 1391 | + populateDuplicateMembers($members); |
|
| 1392 | + } |
|
| 1345 | 1393 | |
| 1346 | 1394 | return $members; |
| 1347 | 1395 | } |
@@ -1358,8 +1406,9 @@ discard block |
||
| 1358 | 1406 | global $smcFunc, $modSettings; |
| 1359 | 1407 | |
| 1360 | 1408 | // We know how many members there are in total. |
| 1361 | - if (empty($where) || $where == '1=1') |
|
| 1362 | - $num_members = $modSettings['totalMembers']; |
|
| 1409 | + if (empty($where) || $where == '1=1') { |
|
| 1410 | + $num_members = $modSettings['totalMembers']; |
|
| 1411 | + } |
|
| 1363 | 1412 | |
| 1364 | 1413 | // The database knows the amount when there are extra conditions. |
| 1365 | 1414 | else |
@@ -1395,16 +1444,19 @@ discard block |
||
| 1395 | 1444 | $members[$key]['duplicate_members'] = array(); |
| 1396 | 1445 | |
| 1397 | 1446 | // Store the IPs. |
| 1398 | - if (!empty($member['member_ip'])) |
|
| 1399 | - $ips[] = $member['member_ip']; |
|
| 1400 | - if (!empty($member['member_ip2'])) |
|
| 1401 | - $ips[] = $member['member_ip2']; |
|
| 1447 | + if (!empty($member['member_ip'])) { |
|
| 1448 | + $ips[] = $member['member_ip']; |
|
| 1449 | + } |
|
| 1450 | + if (!empty($member['member_ip2'])) { |
|
| 1451 | + $ips[] = $member['member_ip2']; |
|
| 1452 | + } |
|
| 1402 | 1453 | } |
| 1403 | 1454 | |
| 1404 | 1455 | $ips = array_unique($ips); |
| 1405 | 1456 | |
| 1406 | - if (empty($ips)) |
|
| 1407 | - return false; |
|
| 1457 | + if (empty($ips)) { |
|
| 1458 | + return false; |
|
| 1459 | + } |
|
| 1408 | 1460 | |
| 1409 | 1461 | // Fetch all members with this IP address, we'll filter out the current ones in a sec. |
| 1410 | 1462 | $request = $smcFunc['db_query']('', ' |
@@ -1434,10 +1486,12 @@ discard block |
||
| 1434 | 1486 | 'ip2' => $row['member_ip2'], |
| 1435 | 1487 | ); |
| 1436 | 1488 | |
| 1437 | - if (in_array($row['member_ip'], $ips)) |
|
| 1438 | - $duplicate_members[$row['member_ip']][] = $member_context; |
|
| 1439 | - if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) |
|
| 1440 | - $duplicate_members[$row['member_ip2']][] = $member_context; |
|
| 1489 | + if (in_array($row['member_ip'], $ips)) { |
|
| 1490 | + $duplicate_members[$row['member_ip']][] = $member_context; |
|
| 1491 | + } |
|
| 1492 | + if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) { |
|
| 1493 | + $duplicate_members[$row['member_ip2']][] = $member_context; |
|
| 1494 | + } |
|
| 1441 | 1495 | } |
| 1442 | 1496 | $smcFunc['db_free_result']($request); |
| 1443 | 1497 | |
@@ -1462,8 +1516,9 @@ discard block |
||
| 1462 | 1516 | $row['poster_ip'] = inet_dtop($row['poster_ip']); |
| 1463 | 1517 | |
| 1464 | 1518 | // Don't collect lots of the same. |
| 1465 | - if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) |
|
| 1466 | - continue; |
|
| 1519 | + if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) { |
|
| 1520 | + continue; |
|
| 1521 | + } |
|
| 1467 | 1522 | $had_ips[$row['poster_ip']][] = $row['id_member']; |
| 1468 | 1523 | |
| 1469 | 1524 | $duplicate_members[$row['poster_ip']][] = array( |
@@ -1478,13 +1533,15 @@ discard block |
||
| 1478 | 1533 | $smcFunc['db_free_result']($request); |
| 1479 | 1534 | |
| 1480 | 1535 | // Now we have all the duplicate members, stick them with their respective member in the list. |
| 1481 | - if (!empty($duplicate_members)) |
|
| 1482 | - foreach ($members as $key => $member) |
|
| 1536 | + if (!empty($duplicate_members)) { |
|
| 1537 | + foreach ($members as $key => $member) |
|
| 1483 | 1538 | { |
| 1484 | 1539 | if (isset($duplicate_members[$member['member_ip']])) |
| 1485 | 1540 | $members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']]; |
| 1486 | - if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) |
|
| 1487 | - $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
| 1541 | + } |
|
| 1542 | + if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) { |
|
| 1543 | + $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
| 1544 | + } |
|
| 1488 | 1545 | |
| 1489 | 1546 | // Check we don't have lots of the same member. |
| 1490 | 1547 | $member_track = array($member['id_member']); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | else |
| 238 | 238 | { |
| 239 | 239 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
| 240 | - AND b.id_board != {int:recycle_board}' : ''). ' |
|
| 240 | + AND b.id_board != {int:recycle_board}' : '') . ' |
|
| 241 | 241 | AND m.id_msg >= {int:max_id_msg}'; |
| 242 | 242 | $query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6); |
| 243 | 243 | $query_parameters['recycle_board'] = $modSettings['recycle_board']; |
@@ -1124,7 +1124,7 @@ discard block |
||
| 1124 | 1124 | ); |
| 1125 | 1125 | else |
| 1126 | 1126 | $request = $smcFunc['db_query']('', ' |
| 1127 | - SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
|
| 1127 | + SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'] . ' |
|
| 1128 | 1128 | FROM {db_prefix}topics AS t |
| 1129 | 1129 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
| 1130 | 1130 | INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : ' |
@@ -1391,7 +1391,7 @@ discard block |
||
| 1391 | 1391 | if ($is_topics) |
| 1392 | 1392 | { |
| 1393 | 1393 | $context['recent_buttons'] = array( |
| 1394 | - 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
| 1394 | + 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
| 1395 | 1395 | ); |
| 1396 | 1396 | |
| 1397 | 1397 | if ($context['showCheckboxes']) |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | elseif (!$is_topics && isset($context['topics_to_mark'])) |
| 1408 | 1408 | { |
| 1409 | 1409 | $context['recent_buttons'] = array( |
| 1410 | - 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
| 1410 | + 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
| 1411 | 1411 | ); |
| 1412 | 1412 | |
| 1413 | 1413 | if ($context['showCheckboxes']) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | 'is_approved' => 1, |
| 45 | 46 | ) |
| 46 | 47 | ); |
| 47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 48 | - return array(); |
|
| 48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 49 | + return array(); |
|
| 50 | + } |
|
| 49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
| 50 | 52 | $smcFunc['db_free_result']($request); |
| 51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | censorText($row['body']); |
| 55 | 57 | |
| 56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
| 57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | // Send the data. |
| 61 | 64 | return array( |
@@ -83,8 +86,9 @@ discard block |
||
| 83 | 86 | |
| 84 | 87 | $context['is_redirect'] = false; |
| 85 | 88 | |
| 86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
| 87 | - $_REQUEST['start'] = 95; |
|
| 89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
| 90 | + $_REQUEST['start'] = 95; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | $_REQUEST['start'] = (int) $_REQUEST['start']; |
| 90 | 94 | |
@@ -92,8 +96,9 @@ discard block |
||
| 92 | 96 | if (!empty($_REQUEST['c']) && empty($board)) |
| 93 | 97 | { |
| 94 | 98 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 95 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 96 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 99 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 100 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 101 | + } |
|
| 97 | 102 | |
| 98 | 103 | if (count($_REQUEST['c']) == 1) |
| 99 | 104 | { |
@@ -109,8 +114,9 @@ discard block |
||
| 109 | 114 | list ($name) = $smcFunc['db_fetch_row']($request); |
| 110 | 115 | $smcFunc['db_free_result']($request); |
| 111 | 116 | |
| 112 | - if (empty($name)) |
|
| 113 | - fatal_lang_error('no_access', false); |
|
| 117 | + if (empty($name)) { |
|
| 118 | + fatal_lang_error('no_access', false); |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $context['linktree'][] = array( |
| 116 | 122 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -142,8 +148,9 @@ discard block |
||
| 142 | 148 | } |
| 143 | 149 | $smcFunc['db_free_result']($request); |
| 144 | 150 | |
| 145 | - if (empty($boards)) |
|
| 146 | - fatal_lang_error('error_no_boards_selected'); |
|
| 151 | + if (empty($boards)) { |
|
| 152 | + fatal_lang_error('error_no_boards_selected'); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 149 | 156 | $query_parameters['boards'] = $boards; |
@@ -157,12 +164,12 @@ discard block |
||
| 157 | 164 | } |
| 158 | 165 | |
| 159 | 166 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
| 160 | - } |
|
| 161 | - elseif (!empty($_REQUEST['boards'])) |
|
| 167 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 162 | 168 | { |
| 163 | 169 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 164 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 165 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 170 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 171 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 172 | + } |
|
| 166 | 173 | |
| 167 | 174 | $request = $smcFunc['db_query']('', ' |
| 168 | 175 | SELECT b.id_board, b.num_posts |
@@ -186,8 +193,9 @@ discard block |
||
| 186 | 193 | } |
| 187 | 194 | $smcFunc['db_free_result']($request); |
| 188 | 195 | |
| 189 | - if (empty($boards)) |
|
| 190 | - fatal_lang_error('error_no_boards_selected'); |
|
| 196 | + if (empty($boards)) { |
|
| 197 | + fatal_lang_error('error_no_boards_selected'); |
|
| 198 | + } |
|
| 191 | 199 | |
| 192 | 200 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 193 | 201 | $query_parameters['boards'] = $boards; |
@@ -201,8 +209,7 @@ discard block |
||
| 201 | 209 | } |
| 202 | 210 | |
| 203 | 211 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
| 204 | - } |
|
| 205 | - elseif (!empty($board)) |
|
| 212 | + } elseif (!empty($board)) |
|
| 206 | 213 | { |
| 207 | 214 | $request = $smcFunc['db_query']('', ' |
| 208 | 215 | SELECT num_posts, redirect |
@@ -235,8 +242,7 @@ discard block |
||
| 235 | 242 | } |
| 236 | 243 | |
| 237 | 244 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
| 238 | - } |
|
| 239 | - else |
|
| 245 | + } else |
|
| 240 | 246 | { |
| 241 | 247 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
| 242 | 248 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -271,8 +277,9 @@ discard block |
||
| 271 | 277 | ); |
| 272 | 278 | |
| 273 | 279 | // If you selected a redirection board, don't try getting posts for it... |
| 274 | - if ($context['is_redirect']) |
|
| 275 | - $messages = 0; |
|
| 280 | + if ($context['is_redirect']) { |
|
| 281 | + $messages = 0; |
|
| 282 | + } |
|
| 276 | 283 | |
| 277 | 284 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
| 278 | 285 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -303,16 +310,18 @@ discard block |
||
| 303 | 310 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
| 304 | 311 | $cache_results = true; |
| 305 | 312 | unset($query_parameters['max_id_msg']); |
| 313 | + } else { |
|
| 314 | + $done = true; |
|
| 306 | 315 | } |
| 307 | - else |
|
| 308 | - $done = true; |
|
| 309 | 316 | } |
| 310 | 317 | $messages = array(); |
| 311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 312 | - $messages[] = $row['id_msg']; |
|
| 318 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 319 | + $messages[] = $row['id_msg']; |
|
| 320 | + } |
|
| 313 | 321 | $smcFunc['db_free_result']($request); |
| 314 | - if (!empty($cache_results)) |
|
| 315 | - cache_put_data($key, $messages, 120); |
|
| 322 | + if (!empty($cache_results)) { |
|
| 323 | + cache_put_data($key, $messages, 120); |
|
| 324 | + } |
|
| 316 | 325 | } |
| 317 | 326 | |
| 318 | 327 | // Nothing here... Or at least, nothing you can see... |
@@ -399,8 +408,9 @@ discard block |
||
| 399 | 408 | 'css_class' => 'windowbg', |
| 400 | 409 | ); |
| 401 | 410 | |
| 402 | - if ($user_info['id'] == $row['id_first_member']) |
|
| 403 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 411 | + if ($user_info['id'] == $row['id_first_member']) { |
|
| 412 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 413 | + } |
|
| 404 | 414 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
| 405 | 415 | } |
| 406 | 416 | $smcFunc['db_free_result']($request); |
@@ -426,20 +436,23 @@ discard block |
||
| 426 | 436 | $boards = boardsAllowedTo($permission); |
| 427 | 437 | |
| 428 | 438 | // If 0 is the only thing in the array, they can do it everywhere! |
| 429 | - if (!empty($boards) && $boards[0] == 0) |
|
| 430 | - $boards = array_keys($board_ids[$type]); |
|
| 439 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 440 | + $boards = array_keys($board_ids[$type]); |
|
| 441 | + } |
|
| 431 | 442 | |
| 432 | 443 | // Go through the boards, and look for posts they can do this on. |
| 433 | 444 | foreach ($boards as $board_id) |
| 434 | 445 | { |
| 435 | 446 | // Hmm, they have permission, but there are no topics from that board on this page. |
| 436 | - if (!isset($board_ids[$type][$board_id])) |
|
| 437 | - continue; |
|
| 447 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 448 | + continue; |
|
| 449 | + } |
|
| 438 | 450 | |
| 439 | 451 | // Okay, looks like they can do it for these posts. |
| 440 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 441 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 452 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 453 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 442 | 454 | $context['posts'][$counter][$allowed] = true; |
| 455 | + } |
|
| 443 | 456 | } |
| 444 | 457 | } |
| 445 | 458 | } |
@@ -482,17 +495,19 @@ discard block |
||
| 482 | 495 | $context['showing_all_topics'] = isset($_GET['all']); |
| 483 | 496 | $context['start'] = (int) $_REQUEST['start']; |
| 484 | 497 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
| 485 | - if ($_REQUEST['action'] == 'unread') |
|
| 486 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 487 | - else |
|
| 488 | - $context['page_title'] = $txt['unread_replies']; |
|
| 498 | + if ($_REQUEST['action'] == 'unread') { |
|
| 499 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 500 | + } else { |
|
| 501 | + $context['page_title'] = $txt['unread_replies']; |
|
| 502 | + } |
|
| 489 | 503 | |
| 490 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
| 491 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 492 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
| 493 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 494 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
| 495 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
| 504 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
| 505 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 506 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
| 507 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 508 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
| 509 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
| 510 | + } |
|
| 496 | 511 | |
| 497 | 512 | // Parameters for the main query. |
| 498 | 513 | $query_parameters = array(); |
@@ -505,12 +520,14 @@ discard block |
||
| 505 | 520 | if (!empty($_REQUEST['boards'])) |
| 506 | 521 | { |
| 507 | 522 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 508 | - foreach ($_REQUEST['boards'] as $b) |
|
| 509 | - $boards[] = (int) $b; |
|
| 523 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 524 | + $boards[] = (int) $b; |
|
| 525 | + } |
|
| 510 | 526 | } |
| 511 | 527 | |
| 512 | - if (!empty($board)) |
|
| 513 | - $boards[] = (int) $board; |
|
| 528 | + if (!empty($board)) { |
|
| 529 | + $boards[] = (int) $board; |
|
| 530 | + } |
|
| 514 | 531 | |
| 515 | 532 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
| 516 | 533 | $request = $smcFunc['db_query']('', ' |
@@ -527,30 +544,31 @@ discard block |
||
| 527 | 544 | ) |
| 528 | 545 | ); |
| 529 | 546 | |
| 530 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 531 | - if (in_array($row['id_parent'], $boards)) |
|
| 547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 548 | + if (in_array($row['id_parent'], $boards)) |
|
| 532 | 549 | $boards[] = $row['id_board']; |
| 550 | + } |
|
| 533 | 551 | |
| 534 | 552 | $smcFunc['db_free_result']($request); |
| 535 | 553 | |
| 536 | - if (empty($boards)) |
|
| 537 | - fatal_lang_error('error_no_boards_selected'); |
|
| 554 | + if (empty($boards)) { |
|
| 555 | + fatal_lang_error('error_no_boards_selected'); |
|
| 556 | + } |
|
| 538 | 557 | |
| 539 | 558 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 540 | 559 | $query_parameters['boards'] = $boards; |
| 541 | 560 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
| 542 | - } |
|
| 543 | - elseif (!empty($board)) |
|
| 561 | + } elseif (!empty($board)) |
|
| 544 | 562 | { |
| 545 | 563 | $query_this_board = 'id_board = {int:board}'; |
| 546 | 564 | $query_parameters['board'] = $board; |
| 547 | 565 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
| 548 | - } |
|
| 549 | - elseif (!empty($_REQUEST['boards'])) |
|
| 566 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 550 | 567 | { |
| 551 | 568 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 552 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 553 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 569 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 570 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 571 | + } |
|
| 554 | 572 | |
| 555 | 573 | $request = $smcFunc['db_query']('', ' |
| 556 | 574 | SELECT b.id_board |
@@ -562,22 +580,24 @@ discard block |
||
| 562 | 580 | ) |
| 563 | 581 | ); |
| 564 | 582 | $boards = array(); |
| 565 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 566 | - $boards[] = $row['id_board']; |
|
| 583 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 584 | + $boards[] = $row['id_board']; |
|
| 585 | + } |
|
| 567 | 586 | $smcFunc['db_free_result']($request); |
| 568 | 587 | |
| 569 | - if (empty($boards)) |
|
| 570 | - fatal_lang_error('error_no_boards_selected'); |
|
| 588 | + if (empty($boards)) { |
|
| 589 | + fatal_lang_error('error_no_boards_selected'); |
|
| 590 | + } |
|
| 571 | 591 | |
| 572 | 592 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 573 | 593 | $query_parameters['boards'] = $boards; |
| 574 | 594 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
| 575 | - } |
|
| 576 | - elseif (!empty($_REQUEST['c'])) |
|
| 595 | + } elseif (!empty($_REQUEST['c'])) |
|
| 577 | 596 | { |
| 578 | 597 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 579 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 580 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 598 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 599 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 600 | + } |
|
| 581 | 601 | |
| 582 | 602 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 583 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -590,18 +610,19 @@ discard block |
||
| 590 | 610 | ) |
| 591 | 611 | ); |
| 592 | 612 | $boards = array(); |
| 593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 594 | - $boards[] = $row['id_board']; |
|
| 613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 614 | + $boards[] = $row['id_board']; |
|
| 615 | + } |
|
| 595 | 616 | $smcFunc['db_free_result']($request); |
| 596 | 617 | |
| 597 | - if (empty($boards)) |
|
| 598 | - fatal_lang_error('error_no_boards_selected'); |
|
| 618 | + if (empty($boards)) { |
|
| 619 | + fatal_lang_error('error_no_boards_selected'); |
|
| 620 | + } |
|
| 599 | 621 | |
| 600 | 622 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 601 | 623 | $query_parameters['boards'] = $boards; |
| 602 | 624 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
| 603 | - } |
|
| 604 | - else |
|
| 625 | + } else |
|
| 605 | 626 | { |
| 606 | 627 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 607 | 628 | // Don't bother to show deleted posts! |
@@ -615,12 +636,14 @@ discard block |
||
| 615 | 636 | ) |
| 616 | 637 | ); |
| 617 | 638 | $boards = array(); |
| 618 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 619 | - $boards[] = $row['id_board']; |
|
| 639 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 640 | + $boards[] = $row['id_board']; |
|
| 641 | + } |
|
| 620 | 642 | $smcFunc['db_free_result']($request); |
| 621 | 643 | |
| 622 | - if (empty($boards)) |
|
| 623 | - fatal_lang_error('error_no_boards_available', false); |
|
| 644 | + if (empty($boards)) { |
|
| 645 | + fatal_lang_error('error_no_boards_available', false); |
|
| 646 | + } |
|
| 624 | 647 | |
| 625 | 648 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 626 | 649 | $query_parameters['boards'] = $boards; |
@@ -682,13 +705,14 @@ discard block |
||
| 682 | 705 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
| 683 | 706 | ); |
| 684 | 707 | |
| 685 | - if ($context['showing_all_topics']) |
|
| 686 | - $context['linktree'][] = array( |
|
| 708 | + if ($context['showing_all_topics']) { |
|
| 709 | + $context['linktree'][] = array( |
|
| 687 | 710 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
| 688 | 711 | 'name' => $txt['unread_topics_all'] |
| 689 | 712 | ); |
| 690 | - else |
|
| 691 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 713 | + } else { |
|
| 714 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 715 | + } |
|
| 692 | 716 | |
| 693 | 717 | loadTemplate('Recent'); |
| 694 | 718 | loadTemplate('MessageIndex'); |
@@ -696,8 +720,9 @@ discard block |
||
| 696 | 720 | |
| 697 | 721 | // Setup the default topic icons... for checking they exist and the like ;) |
| 698 | 722 | $context['icon_sources'] = array(); |
| 699 | - foreach ($context['stable_icons'] as $icon) |
|
| 700 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 723 | + foreach ($context['stable_icons'] as $icon) { |
|
| 724 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 725 | + } |
|
| 701 | 726 | |
| 702 | 727 | $is_topics = $_REQUEST['action'] == 'unread'; |
| 703 | 728 | |
@@ -727,8 +752,7 @@ discard block |
||
| 727 | 752 | ); |
| 728 | 753 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
| 729 | 754 | $smcFunc['db_free_result']($request); |
| 730 | - } |
|
| 731 | - else |
|
| 755 | + } else |
|
| 732 | 756 | { |
| 733 | 757 | $request = $smcFunc['db_query']('', ' |
| 734 | 758 | SELECT MIN(lmr.id_msg) |
@@ -744,14 +768,14 @@ discard block |
||
| 744 | 768 | } |
| 745 | 769 | |
| 746 | 770 | // This is needed in case of topics marked unread. |
| 747 | - if (empty($earliest_msg)) |
|
| 748 | - $earliest_msg = 0; |
|
| 749 | - else |
|
| 771 | + if (empty($earliest_msg)) { |
|
| 772 | + $earliest_msg = 0; |
|
| 773 | + } else |
|
| 750 | 774 | { |
| 751 | 775 | // Using caching, when possible, to ignore the below slow query. |
| 752 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
| 753 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 754 | - else |
|
| 776 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
| 777 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 778 | + } else |
|
| 755 | 779 | { |
| 756 | 780 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
| 757 | 781 | $request = $smcFunc['db_query']('', ' |
@@ -766,8 +790,9 @@ discard block |
||
| 766 | 790 | $smcFunc['db_free_result']($request); |
| 767 | 791 | |
| 768 | 792 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
| 769 | - if ($earliest_msg2 == 0) |
|
| 770 | - $earliest_msg2 = -1; |
|
| 793 | + if ($earliest_msg2 == 0) { |
|
| 794 | + $earliest_msg2 = -1; |
|
| 795 | + } |
|
| 771 | 796 | |
| 772 | 797 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
| 773 | 798 | } |
@@ -805,9 +830,9 @@ discard block |
||
| 805 | 830 | 'db_error_skip' => true, |
| 806 | 831 | )) |
| 807 | 832 | ) !== false; |
| 833 | + } else { |
|
| 834 | + $have_temp_table = false; |
|
| 808 | 835 | } |
| 809 | - else |
|
| 810 | - $have_temp_table = false; |
|
| 811 | 836 | |
| 812 | 837 | if ($context['showing_all_topics'] && $have_temp_table) |
| 813 | 838 | { |
@@ -853,14 +878,15 @@ discard block |
||
| 853 | 878 | |
| 854 | 879 | $context['topics'] = array(); |
| 855 | 880 | $context['no_topic_listing'] = true; |
| 856 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
| 857 | - $context['querystring_board_limits'] = ''; |
|
| 858 | - else |
|
| 859 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 881 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
| 882 | + $context['querystring_board_limits'] = ''; |
|
| 883 | + } else { |
|
| 884 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 885 | + } |
|
| 860 | 886 | return; |
| 887 | + } else { |
|
| 888 | + $min_message = (int) $min_message; |
|
| 861 | 889 | } |
| 862 | - else |
|
| 863 | - $min_message = (int) $min_message; |
|
| 864 | 890 | |
| 865 | 891 | $request = $smcFunc['db_query']('substring', ' |
| 866 | 892 | SELECT ' . $select_clause . ' |
@@ -889,8 +915,7 @@ discard block |
||
| 889 | 915 | 'limit' => $context['topics_per_page'], |
| 890 | 916 | )) |
| 891 | 917 | ); |
| 892 | - } |
|
| 893 | - elseif ($is_topics) |
|
| 918 | + } elseif ($is_topics) |
|
| 894 | 919 | { |
| 895 | 920 | $request = $smcFunc['db_query']('', ' |
| 896 | 921 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -941,14 +966,15 @@ discard block |
||
| 941 | 966 | |
| 942 | 967 | $context['topics'] = array(); |
| 943 | 968 | $context['no_topic_listing'] = true; |
| 944 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 945 | - $context['querystring_board_limits'] = ''; |
|
| 946 | - else |
|
| 947 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 969 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 970 | + $context['querystring_board_limits'] = ''; |
|
| 971 | + } else { |
|
| 972 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 973 | + } |
|
| 948 | 974 | return; |
| 975 | + } else { |
|
| 976 | + $min_message = (int) $min_message; |
|
| 949 | 977 | } |
| 950 | - else |
|
| 951 | - $min_message = (int) $min_message; |
|
| 952 | 978 | |
| 953 | 979 | $request = $smcFunc['db_query']('substring', ' |
| 954 | 980 | SELECT ' . $select_clause . ' |
@@ -978,8 +1004,7 @@ discard block |
||
| 978 | 1004 | 'limit' => $context['topics_per_page'], |
| 979 | 1005 | )) |
| 980 | 1006 | ); |
| 981 | - } |
|
| 982 | - else |
|
| 1007 | + } else |
|
| 983 | 1008 | { |
| 984 | 1009 | if ($modSettings['totalMessages'] > 100000) |
| 985 | 1010 | { |
@@ -1031,8 +1056,8 @@ discard block |
||
| 1031 | 1056 | ) !== false; |
| 1032 | 1057 | |
| 1033 | 1058 | // If that worked, create a sample of the log_topics table too. |
| 1034 | - if ($have_temp_table) |
|
| 1035 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1059 | + if ($have_temp_table) { |
|
| 1060 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1036 | 1061 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
| 1037 | 1062 | PRIMARY KEY (id_topic) |
| 1038 | 1063 | ) |
@@ -1045,6 +1070,7 @@ discard block |
||
| 1045 | 1070 | 'db_error_skip' => true, |
| 1046 | 1071 | ) |
| 1047 | 1072 | ) !== false; |
| 1073 | + } |
|
| 1048 | 1074 | } |
| 1049 | 1075 | |
| 1050 | 1076 | if (!empty($have_temp_table)) |
@@ -1060,8 +1086,7 @@ discard block |
||
| 1060 | 1086 | ); |
| 1061 | 1087 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
| 1062 | 1088 | $smcFunc['db_free_result']($request); |
| 1063 | - } |
|
| 1064 | - else |
|
| 1089 | + } else |
|
| 1065 | 1090 | { |
| 1066 | 1091 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
| 1067 | 1092 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1102,15 +1127,16 @@ discard block |
||
| 1102 | 1127 | { |
| 1103 | 1128 | $context['topics'] = array(); |
| 1104 | 1129 | $context['no_topic_listing'] = true; |
| 1105 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1106 | - $context['querystring_board_limits'] = ''; |
|
| 1107 | - else |
|
| 1108 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1130 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1131 | + $context['querystring_board_limits'] = ''; |
|
| 1132 | + } else { |
|
| 1133 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1134 | + } |
|
| 1109 | 1135 | return; |
| 1110 | 1136 | } |
| 1111 | 1137 | |
| 1112 | - if (!empty($have_temp_table)) |
|
| 1113 | - $request = $smcFunc['db_query']('', ' |
|
| 1138 | + if (!empty($have_temp_table)) { |
|
| 1139 | + $request = $smcFunc['db_query']('', ' |
|
| 1114 | 1140 | SELECT t.id_topic |
| 1115 | 1141 | FROM {db_prefix}topics_posted_in AS t |
| 1116 | 1142 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1124,8 +1150,8 @@ discard block |
||
| 1124 | 1150 | 'limit' => $context['topics_per_page'], |
| 1125 | 1151 | )) |
| 1126 | 1152 | ); |
| 1127 | - else |
|
| 1128 | - $request = $smcFunc['db_query']('', ' |
|
| 1153 | + } else { |
|
| 1154 | + $request = $smcFunc['db_query']('', ' |
|
| 1129 | 1155 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
| 1130 | 1156 | FROM {db_prefix}topics AS t |
| 1131 | 1157 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1149,10 +1175,12 @@ discard block |
||
| 1149 | 1175 | 'sort' => $_REQUEST['sort'], |
| 1150 | 1176 | )) |
| 1151 | 1177 | ); |
| 1178 | + } |
|
| 1152 | 1179 | |
| 1153 | 1180 | $topics = array(); |
| 1154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1155 | - $topics[] = $row['id_topic']; |
|
| 1181 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1182 | + $topics[] = $row['id_topic']; |
|
| 1183 | + } |
|
| 1156 | 1184 | $smcFunc['db_free_result']($request); |
| 1157 | 1185 | |
| 1158 | 1186 | // Sanity... where have you gone? |
@@ -1160,10 +1188,11 @@ discard block |
||
| 1160 | 1188 | { |
| 1161 | 1189 | $context['topics'] = array(); |
| 1162 | 1190 | $context['no_topic_listing'] = true; |
| 1163 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1164 | - $context['querystring_board_limits'] = ''; |
|
| 1165 | - else |
|
| 1166 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1191 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1192 | + $context['querystring_board_limits'] = ''; |
|
| 1193 | + } else { |
|
| 1194 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1195 | + } |
|
| 1167 | 1196 | return; |
| 1168 | 1197 | } |
| 1169 | 1198 | |
@@ -1197,8 +1226,9 @@ discard block |
||
| 1197 | 1226 | |
| 1198 | 1227 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1199 | 1228 | { |
| 1200 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 1201 | - continue; |
|
| 1229 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 1230 | + continue; |
|
| 1231 | + } |
|
| 1202 | 1232 | |
| 1203 | 1233 | $topic_ids[] = $row['id_topic']; |
| 1204 | 1234 | |
@@ -1206,11 +1236,13 @@ discard block |
||
| 1206 | 1236 | { |
| 1207 | 1237 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
| 1208 | 1238 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 1209 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
| 1210 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1239 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
| 1240 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1241 | + } |
|
| 1211 | 1242 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 1212 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
| 1213 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1243 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
| 1244 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1245 | + } |
|
| 1214 | 1246 | |
| 1215 | 1247 | // Censor the subject and message preview. |
| 1216 | 1248 | censorText($row['first_subject']); |
@@ -1221,23 +1253,22 @@ discard block |
||
| 1221 | 1253 | { |
| 1222 | 1254 | $row['last_subject'] = $row['first_subject']; |
| 1223 | 1255 | $row['last_body'] = $row['first_body']; |
| 1224 | - } |
|
| 1225 | - else |
|
| 1256 | + } else |
|
| 1226 | 1257 | { |
| 1227 | 1258 | censorText($row['last_subject']); |
| 1228 | 1259 | censorText($row['last_body']); |
| 1229 | 1260 | } |
| 1230 | - } |
|
| 1231 | - else |
|
| 1261 | + } else |
|
| 1232 | 1262 | { |
| 1233 | 1263 | $row['first_body'] = ''; |
| 1234 | 1264 | $row['last_body'] = ''; |
| 1235 | 1265 | censorText($row['first_subject']); |
| 1236 | 1266 | |
| 1237 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 1238 | - $row['last_subject'] = $row['first_subject']; |
|
| 1239 | - else |
|
| 1240 | - censorText($row['last_subject']); |
|
| 1267 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 1268 | + $row['last_subject'] = $row['first_subject']; |
|
| 1269 | + } else { |
|
| 1270 | + censorText($row['last_subject']); |
|
| 1271 | + } |
|
| 1241 | 1272 | } |
| 1242 | 1273 | |
| 1243 | 1274 | // Decide how many pages the topic should have. |
@@ -1249,22 +1280,24 @@ discard block |
||
| 1249 | 1280 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
| 1250 | 1281 | |
| 1251 | 1282 | // If we can use all, show all. |
| 1252 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
| 1253 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1283 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
| 1284 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1285 | + } |
|
| 1286 | + } else { |
|
| 1287 | + $pages = ''; |
|
| 1254 | 1288 | } |
| 1255 | 1289 | |
| 1256 | - else |
|
| 1257 | - $pages = ''; |
|
| 1258 | - |
|
| 1259 | 1290 | // We need to check the topic icons exist... you can never be too sure! |
| 1260 | 1291 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 1261 | 1292 | { |
| 1262 | 1293 | // First icon first... as you'd expect. |
| 1263 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 1264 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1294 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 1295 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1296 | + } |
|
| 1265 | 1297 | // Last icon... last... duh. |
| 1266 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 1267 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1298 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 1299 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1300 | + } |
|
| 1268 | 1301 | } |
| 1269 | 1302 | |
| 1270 | 1303 | // Force the recycling icon if appropriate |
@@ -1278,12 +1311,14 @@ discard block |
||
| 1278 | 1311 | $colorClass = 'windowbg'; |
| 1279 | 1312 | |
| 1280 | 1313 | // Sticky topics should get a different color, too. |
| 1281 | - if ($row['is_sticky']) |
|
| 1282 | - $colorClass .= ' sticky'; |
|
| 1314 | + if ($row['is_sticky']) { |
|
| 1315 | + $colorClass .= ' sticky'; |
|
| 1316 | + } |
|
| 1283 | 1317 | |
| 1284 | 1318 | // Locked topics get special treatment as well. |
| 1285 | - if ($row['locked']) |
|
| 1286 | - $colorClass .= ' locked'; |
|
| 1319 | + if ($row['locked']) { |
|
| 1320 | + $colorClass .= ' locked'; |
|
| 1321 | + } |
|
| 1287 | 1322 | |
| 1288 | 1323 | // And build the array. |
| 1289 | 1324 | $context['topics'][$row['id_topic']] = array( |
@@ -1380,8 +1415,9 @@ discard block |
||
| 1380 | 1415 | ); |
| 1381 | 1416 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1382 | 1417 | { |
| 1383 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
| 1384 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1418 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
| 1419 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1420 | + } |
|
| 1385 | 1421 | } |
| 1386 | 1422 | $smcFunc['db_free_result']($result); |
| 1387 | 1423 | } |
@@ -1396,28 +1432,30 @@ discard block |
||
| 1396 | 1432 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1397 | 1433 | ); |
| 1398 | 1434 | |
| 1399 | - if ($context['showCheckboxes']) |
|
| 1400 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1435 | + if ($context['showCheckboxes']) { |
|
| 1436 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1401 | 1437 | 'text' => 'quick_mod_markread', |
| 1402 | 1438 | 'image' => 'markselectedread.png', |
| 1403 | 1439 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1404 | 1440 | ); |
| 1441 | + } |
|
| 1405 | 1442 | |
| 1406 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
| 1407 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1408 | - } |
|
| 1409 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1443 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
| 1444 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1445 | + } |
|
| 1446 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1410 | 1447 | { |
| 1411 | 1448 | $context['recent_buttons'] = array( |
| 1412 | 1449 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1413 | 1450 | ); |
| 1414 | 1451 | |
| 1415 | - if ($context['showCheckboxes']) |
|
| 1416 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1452 | + if ($context['showCheckboxes']) { |
|
| 1453 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1417 | 1454 | 'text' => 'quick_mod_markread', |
| 1418 | 1455 | 'image' => 'markselectedread.png', |
| 1419 | 1456 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1420 | 1457 | ); |
| 1458 | + } |
|
| 1421 | 1459 | } |
| 1422 | 1460 | |
| 1423 | 1461 | // Allow mods to add additional buttons here |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | - * Determine if the browser is Opera or not |
|
| 105 | - * @return boolean Whether or not this is Opera |
|
| 106 | - */ |
|
| 104 | + * Determine if the browser is Opera or not |
|
| 105 | + * @return boolean Whether or not this is Opera |
|
| 106 | + */ |
|
| 107 | 107 | function isOpera() |
| 108 | 108 | { |
| 109 | 109 | if (!isset($this->_browsers['is_opera'])) |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | - * Determine if the browser is IE or not |
|
| 116 | - * @return boolean true Whether or not the browser is IE |
|
| 117 | - */ |
|
| 115 | + * Determine if the browser is IE or not |
|
| 116 | + * @return boolean true Whether or not the browser is IE |
|
| 117 | + */ |
|
| 118 | 118 | function isIe() |
| 119 | 119 | { |
| 120 | 120 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * Determine if the browser is IE11 or not |
|
| 128 | - * @return boolean Whether or not the browser is IE11 |
|
| 129 | - */ |
|
| 127 | + * Determine if the browser is IE11 or not |
|
| 128 | + * @return boolean Whether or not the browser is IE11 |
|
| 129 | + */ |
|
| 130 | 130 | function isIe11() |
| 131 | 131 | { |
| 132 | 132 | // IE11 is a bit different than earlier versions |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | - * Determine if the browser is Edge or not |
|
| 141 | - * @return boolean Whether or not the browser is Edge |
|
| 142 | - */ |
|
| 140 | + * Determine if the browser is Edge or not |
|
| 141 | + * @return boolean Whether or not the browser is Edge |
|
| 142 | + */ |
|
| 143 | 143 | function isEdge() |
| 144 | 144 | { |
| 145 | 145 | if (!isset($this->_browsers['is_edge'])) |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * Determine if the browser is a Webkit based one or not |
|
| 152 | - * @return boolean Whether or not this is a Webkit-based browser |
|
| 153 | - */ |
|
| 151 | + * Determine if the browser is a Webkit based one or not |
|
| 152 | + * @return boolean Whether or not this is a Webkit-based browser |
|
| 153 | + */ |
|
| 154 | 154 | function isWebkit() |
| 155 | 155 | { |
| 156 | 156 | if (!isset($this->_browsers['is_webkit'])) |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | - * Determine if the browser is Firefox or one of its variants |
|
| 163 | - * @return boolean Whether or not this is Firefox (or one of its variants) |
|
| 164 | - */ |
|
| 162 | + * Determine if the browser is Firefox or one of its variants |
|
| 163 | + * @return boolean Whether or not this is Firefox (or one of its variants) |
|
| 164 | + */ |
|
| 165 | 165 | function isFirefox() |
| 166 | 166 | { |
| 167 | 167 | if (!isset($this->_browsers['is_firefox'])) |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * Determine if the browser is WebTv or not |
|
| 174 | - * @return boolean Whether or not this is WebTV |
|
| 175 | - */ |
|
| 173 | + * Determine if the browser is WebTv or not |
|
| 174 | + * @return boolean Whether or not this is WebTV |
|
| 175 | + */ |
|
| 176 | 176 | function isWebTv() |
| 177 | 177 | { |
| 178 | 178 | if (!isset($this->_browsers['is_web_tv'])) |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | - * Determine if the browser is konqueror or not |
|
| 185 | - * @return boolean Whether or not this is Konqueror |
|
| 186 | - */ |
|
| 184 | + * Determine if the browser is konqueror or not |
|
| 185 | + * @return boolean Whether or not this is Konqueror |
|
| 186 | + */ |
|
| 187 | 187 | function isKonqueror() |
| 188 | 188 | { |
| 189 | 189 | if (!isset($this->_browsers['is_konqueror'])) |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | - * Determine if the browser is Gecko or not |
|
| 196 | - * @return boolean Whether or not this is a Gecko-based browser |
|
| 197 | - */ |
|
| 195 | + * Determine if the browser is Gecko or not |
|
| 196 | + * @return boolean Whether or not this is a Gecko-based browser |
|
| 197 | + */ |
|
| 198 | 198 | function isGecko() |
| 199 | 199 | { |
| 200 | 200 | if (!isset($this->_browsers['is_gecko'])) |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | - * Determine if the browser is Opera Mini or not |
|
| 207 | - * @return boolean Whether or not this is Opera Mini |
|
| 208 | - */ |
|
| 206 | + * Determine if the browser is Opera Mini or not |
|
| 207 | + * @return boolean Whether or not this is Opera Mini |
|
| 208 | + */ |
|
| 209 | 209 | function isOperaMini() |
| 210 | 210 | { |
| 211 | 211 | if (!isset($this->_browsers['is_opera_mini'])) |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | - * Determine if the browser is Opera Mobile or not |
|
| 220 | - * @return boolean Whether or not this is Opera Mobile |
|
| 221 | - */ |
|
| 219 | + * Determine if the browser is Opera Mobile or not |
|
| 220 | + * @return boolean Whether or not this is Opera Mobile |
|
| 221 | + */ |
|
| 222 | 222 | function isOperaMobi() |
| 223 | 223 | { |
| 224 | 224 | if (!isset($this->_browsers['is_opera_mobi'])) |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Class browser_detector |
@@ -55,20 +56,25 @@ discard block |
||
| 55 | 56 | $this->_browsers['needs_size_fix'] = false; |
| 56 | 57 | |
| 57 | 58 | // One at a time, one at a time, and in this order too |
| 58 | - if ($this->isOpera()) |
|
| 59 | - $this->setupOpera(); |
|
| 59 | + if ($this->isOpera()) { |
|
| 60 | + $this->setupOpera(); |
|
| 61 | + } |
|
| 60 | 62 | // Meh... |
| 61 | - elseif ($this->isEdge()) |
|
| 62 | - $this->setupEdge(); |
|
| 63 | + elseif ($this->isEdge()) { |
|
| 64 | + $this->setupEdge(); |
|
| 65 | + } |
|
| 63 | 66 | // Them webkits need to be set up too |
| 64 | - elseif ($this->isWebkit()) |
|
| 65 | - $this->setupWebkit(); |
|
| 67 | + elseif ($this->isWebkit()) { |
|
| 68 | + $this->setupWebkit(); |
|
| 69 | + } |
|
| 66 | 70 | // We may have work to do on Firefox... |
| 67 | - elseif ($this->isFirefox()) |
|
| 68 | - $this->setupFirefox(); |
|
| 71 | + elseif ($this->isFirefox()) { |
|
| 72 | + $this->setupFirefox(); |
|
| 73 | + } |
|
| 69 | 74 | // Old friend, old frenemy |
| 70 | - elseif ($this->isIe()) |
|
| 71 | - $this->setupIe(); |
|
| 75 | + elseif ($this->isIe()) { |
|
| 76 | + $this->setupIe(); |
|
| 77 | + } |
|
| 72 | 78 | |
| 73 | 79 | // Just a few mobile checks |
| 74 | 80 | $this->isOperaMini(); |
@@ -84,11 +90,12 @@ discard block |
||
| 84 | 90 | $this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']); |
| 85 | 91 | |
| 86 | 92 | // Robots shouldn't be logging in or registering. So, they aren't a bot. Better to be wrong than sorry (or people won't be able to log in!), anyway. |
| 87 | - if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) |
|
| 88 | - $this->_browsers['possibly_robot'] = false; |
|
| 93 | + if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) { |
|
| 94 | + $this->_browsers['possibly_robot'] = false; |
|
| 95 | + } |
|
| 96 | + } else { |
|
| 97 | + $this->_browsers['possibly_robot'] = false; |
|
| 89 | 98 | } |
| 90 | - else |
|
| 91 | - $this->_browsers['possibly_robot'] = false; |
|
| 92 | 99 | |
| 93 | 100 | // Fill out the historical array as needed to support old mods that don't use isBrowser |
| 94 | 101 | $this->fillInformation(); |
@@ -106,8 +113,9 @@ discard block |
||
| 106 | 113 | */ |
| 107 | 114 | function isOpera() |
| 108 | 115 | { |
| 109 | - if (!isset($this->_browsers['is_opera'])) |
|
| 110 | - $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
| 116 | + if (!isset($this->_browsers['is_opera'])) { |
|
| 117 | + $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
| 118 | + } |
|
| 111 | 119 | return $this->_browsers['is_opera']; |
| 112 | 120 | } |
| 113 | 121 | |
@@ -118,8 +126,9 @@ discard block |
||
| 118 | 126 | function isIe() |
| 119 | 127 | { |
| 120 | 128 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
| 121 | - if (!isset($this->_browsers['is_ie'])) |
|
| 122 | - $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
| 129 | + if (!isset($this->_browsers['is_ie'])) { |
|
| 130 | + $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
| 131 | + } |
|
| 123 | 132 | return $this->_browsers['is_ie']; |
| 124 | 133 | } |
| 125 | 134 | |
@@ -131,8 +140,9 @@ discard block |
||
| 131 | 140 | { |
| 132 | 141 | // IE11 is a bit different than earlier versions |
| 133 | 142 | // The isGecko() part is to ensure we get this right... |
| 134 | - if (!isset($this->_browsers['is_ie11'])) |
|
| 135 | - $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
| 143 | + if (!isset($this->_browsers['is_ie11'])) { |
|
| 144 | + $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
| 145 | + } |
|
| 136 | 146 | return $this->_browsers['is_ie11']; |
| 137 | 147 | } |
| 138 | 148 | |
@@ -142,8 +152,9 @@ discard block |
||
| 142 | 152 | */ |
| 143 | 153 | function isEdge() |
| 144 | 154 | { |
| 145 | - if (!isset($this->_browsers['is_edge'])) |
|
| 146 | - $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
| 155 | + if (!isset($this->_browsers['is_edge'])) { |
|
| 156 | + $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
| 157 | + } |
|
| 147 | 158 | return $this->_browsers['is_edge']; |
| 148 | 159 | } |
| 149 | 160 | |
@@ -153,8 +164,9 @@ discard block |
||
| 153 | 164 | */ |
| 154 | 165 | function isWebkit() |
| 155 | 166 | { |
| 156 | - if (!isset($this->_browsers['is_webkit'])) |
|
| 157 | - $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
| 167 | + if (!isset($this->_browsers['is_webkit'])) { |
|
| 168 | + $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
| 169 | + } |
|
| 158 | 170 | return $this->_browsers['is_webkit']; |
| 159 | 171 | } |
| 160 | 172 | |
@@ -164,8 +176,9 @@ discard block |
||
| 164 | 176 | */ |
| 165 | 177 | function isFirefox() |
| 166 | 178 | { |
| 167 | - if (!isset($this->_browsers['is_firefox'])) |
|
| 168 | - $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
| 179 | + if (!isset($this->_browsers['is_firefox'])) { |
|
| 180 | + $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
| 181 | + } |
|
| 169 | 182 | return $this->_browsers['is_firefox']; |
| 170 | 183 | } |
| 171 | 184 | |
@@ -175,8 +188,9 @@ discard block |
||
| 175 | 188 | */ |
| 176 | 189 | function isWebTv() |
| 177 | 190 | { |
| 178 | - if (!isset($this->_browsers['is_web_tv'])) |
|
| 179 | - $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
| 191 | + if (!isset($this->_browsers['is_web_tv'])) { |
|
| 192 | + $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
| 193 | + } |
|
| 180 | 194 | return $this->_browsers['is_web_tv']; |
| 181 | 195 | } |
| 182 | 196 | |
@@ -186,8 +200,9 @@ discard block |
||
| 186 | 200 | */ |
| 187 | 201 | function isKonqueror() |
| 188 | 202 | { |
| 189 | - if (!isset($this->_browsers['is_konqueror'])) |
|
| 190 | - $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
| 203 | + if (!isset($this->_browsers['is_konqueror'])) { |
|
| 204 | + $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
| 205 | + } |
|
| 191 | 206 | return $this->_browsers['is_konqueror']; |
| 192 | 207 | } |
| 193 | 208 | |
@@ -197,8 +212,9 @@ discard block |
||
| 197 | 212 | */ |
| 198 | 213 | function isGecko() |
| 199 | 214 | { |
| 200 | - if (!isset($this->_browsers['is_gecko'])) |
|
| 201 | - $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
| 215 | + if (!isset($this->_browsers['is_gecko'])) { |
|
| 216 | + $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
| 217 | + } |
|
| 202 | 218 | return $this->_browsers['is_gecko']; |
| 203 | 219 | } |
| 204 | 220 | |
@@ -208,10 +224,12 @@ discard block |
||
| 208 | 224 | */ |
| 209 | 225 | function isOperaMini() |
| 210 | 226 | { |
| 211 | - if (!isset($this->_browsers['is_opera_mini'])) |
|
| 212 | - $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
| 213 | - if ($this->_browsers['is_opera_mini']) |
|
| 214 | - $this->_is_mobile = true; |
|
| 227 | + if (!isset($this->_browsers['is_opera_mini'])) { |
|
| 228 | + $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
| 229 | + } |
|
| 230 | + if ($this->_browsers['is_opera_mini']) { |
|
| 231 | + $this->_is_mobile = true; |
|
| 232 | + } |
|
| 215 | 233 | return $this->_browsers['is_opera_mini']; |
| 216 | 234 | } |
| 217 | 235 | |
@@ -221,10 +239,12 @@ discard block |
||
| 221 | 239 | */ |
| 222 | 240 | function isOperaMobi() |
| 223 | 241 | { |
| 224 | - if (!isset($this->_browsers['is_opera_mobi'])) |
|
| 225 | - $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
| 226 | - if ($this->_browsers['is_opera_mobi']) |
|
| 227 | - $this->_is_mobile = true; |
|
| 242 | + if (!isset($this->_browsers['is_opera_mobi'])) { |
|
| 243 | + $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
| 244 | + } |
|
| 245 | + if ($this->_browsers['is_opera_mobi']) { |
|
| 246 | + $this->_is_mobile = true; |
|
| 247 | + } |
|
| 228 | 248 | return $this->_browsers['is_opera_mini']; |
| 229 | 249 | } |
| 230 | 250 | |
@@ -244,8 +264,9 @@ discard block |
||
| 244 | 264 | ); |
| 245 | 265 | |
| 246 | 266 | // blackberry, playbook, iphone, nokia, android and ipods set a mobile flag |
| 247 | - if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) |
|
| 248 | - $this->_is_mobile = true; |
|
| 267 | + if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) { |
|
| 268 | + $this->_is_mobile = true; |
|
| 269 | + } |
|
| 249 | 270 | |
| 250 | 271 | // @todo what to do with the blaPad? ... for now leave it detected as Safari ... |
| 251 | 272 | $this->_browsers['is_safari'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && !$this->_browsers['is_chrome'] && !$this->_browsers['is_iphone']; |
@@ -254,15 +275,17 @@ discard block |
||
| 254 | 275 | // if Chrome, get the major version |
| 255 | 276 | if ($this->_browsers['is_chrome']) |
| 256 | 277 | { |
| 257 | - if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 258 | - $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
| 278 | + if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 279 | + $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
| 280 | + } |
|
| 259 | 281 | } |
| 260 | 282 | |
| 261 | 283 | // or if Safari get its major version |
| 262 | 284 | if ($this->_browsers['is_safari']) |
| 263 | 285 | { |
| 264 | - if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 265 | - $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
| 286 | + if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 287 | + $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
| 288 | + } |
|
| 266 | 289 | } |
| 267 | 290 | } |
| 268 | 291 | |
@@ -291,8 +314,9 @@ discard block |
||
| 291 | 314 | $this->_browsers['is_ie' . ((int) $trident_match[1] + 4)] = true; |
| 292 | 315 | |
| 293 | 316 | // If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view |
| 294 | - if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) |
|
| 295 | - $this->_browsers['is_ie_compat_view'] = true; |
|
| 317 | + if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) { |
|
| 318 | + $this->_browsers['is_ie_compat_view'] = true; |
|
| 319 | + } |
|
| 296 | 320 | } |
| 297 | 321 | |
| 298 | 322 | // Detect true IE6 and IE7 and not IE in compat mode. |
@@ -326,8 +350,9 @@ discard block |
||
| 326 | 350 | */ |
| 327 | 351 | private function setupFirefox() |
| 328 | 352 | { |
| 329 | - if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 330 | - $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
| 353 | + if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 354 | + $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
| 355 | + } |
|
| 331 | 356 | } |
| 332 | 357 | |
| 333 | 358 | /** |
@@ -338,11 +363,13 @@ discard block |
||
| 338 | 363 | private function setupOpera() |
| 339 | 364 | { |
| 340 | 365 | // Opera 10+ uses the version tag at the end of the string |
| 341 | - if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
| 342 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 366 | + if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
| 367 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 368 | + } |
|
| 343 | 369 | // Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers |
| 344 | - elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
| 345 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 370 | + elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
| 371 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
| 372 | + } |
|
| 346 | 373 | |
| 347 | 374 | // Needs size fix? |
| 348 | 375 | $this->_browsers['needs_size_fix'] = !empty($this->_browsers['is_opera6']); |
@@ -353,8 +380,9 @@ discard block |
||
| 353 | 380 | */ |
| 354 | 381 | private function setupEdge() |
| 355 | 382 | { |
| 356 | - if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
| 357 | - $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
| 383 | + if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
| 384 | + $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
| 385 | + } |
|
| 358 | 386 | } |
| 359 | 387 | |
| 360 | 388 | /** |
@@ -367,9 +395,9 @@ discard block |
||
| 367 | 395 | { |
| 368 | 396 | global $context; |
| 369 | 397 | |
| 370 | - if ($this->_is_mobile) |
|
| 371 | - $context['browser_body_id'] = 'mobile'; |
|
| 372 | - else |
|
| 398 | + if ($this->_is_mobile) { |
|
| 399 | + $context['browser_body_id'] = 'mobile'; |
|
| 400 | + } else |
|
| 373 | 401 | { |
| 374 | 402 | // add in any specific detection conversions here if you want a special body id e.g. 'is_opera9' => 'opera9' |
| 375 | 403 | $browser_priority = array( |
@@ -694,7 +694,6 @@ |
||
| 694 | 694 | * It shows as the maintain_forum admin area. |
| 695 | 695 | * It is accessed from ?action=admin;area=maintain;sa=database;activity=optimize. |
| 696 | 696 | * It also updates the optimize scheduled task such that the tables are not automatically optimized again too soon. |
| 697 | - |
|
| 698 | 697 | * @uses the optimize sub template |
| 699 | 698 | */ |
| 700 | 699 | function OptimizeTables() |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | WHERE table_name = {string:cur_table} |
| 571 | 571 | AND (data_type = \'character varying\' or data_type = \'text\')', |
| 572 | 572 | array( |
| 573 | - 'cur_table' => $db_prefix.$cur_table, |
|
| 573 | + 'cur_table' => $db_prefix . $cur_table, |
|
| 574 | 574 | ) |
| 575 | 575 | ); |
| 576 | 576 | else |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | WHERE i.indrelid = {string:cur_table}::regclass |
| 596 | 596 | AND i.indisprimary', |
| 597 | 597 | array( |
| 598 | - 'cur_table' => $db_prefix.$cur_table, |
|
| 598 | + 'cur_table' => $db_prefix . $cur_table, |
|
| 599 | 599 | ) |
| 600 | 600 | ); |
| 601 | 601 | else |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Main dispatcher, the maintenance access point. |
@@ -95,14 +96,16 @@ discard block |
||
| 95 | 96 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
| 96 | 97 | |
| 97 | 98 | // Yep, sub-action time! |
| 98 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 99 | - $subAction = $_REQUEST['sa']; |
|
| 100 | - else |
|
| 101 | - $subAction = 'routine'; |
|
| 99 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 100 | + $subAction = $_REQUEST['sa']; |
|
| 101 | + } else { |
|
| 102 | + $subAction = 'routine'; |
|
| 103 | + } |
|
| 102 | 104 | |
| 103 | 105 | // Doing something special? |
| 104 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
| 105 | - $activity = $_REQUEST['activity']; |
|
| 106 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
| 107 | + $activity = $_REQUEST['activity']; |
|
| 108 | + } |
|
| 106 | 109 | |
| 107 | 110 | // Set a few things. |
| 108 | 111 | $context['page_title'] = $txt['maintain_title']; |
@@ -113,8 +116,9 @@ discard block |
||
| 113 | 116 | call_helper($subActions[$subAction]['function']); |
| 114 | 117 | |
| 115 | 118 | // Any special activity? |
| 116 | - if (isset($activity)) |
|
| 117 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 119 | + if (isset($activity)) { |
|
| 120 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 121 | + } |
|
| 118 | 122 | |
| 119 | 123 | // Create a maintenance token. Kinda hard to do it any other way. |
| 120 | 124 | createToken('admin-maint'); |
@@ -135,17 +139,19 @@ discard block |
||
| 135 | 139 | db_extend('packages'); |
| 136 | 140 | |
| 137 | 141 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 138 | - foreach ($colData as $column) |
|
| 139 | - if ($column['name'] == 'body') |
|
| 142 | + foreach ($colData as $column) { |
|
| 143 | + if ($column['name'] == 'body') |
|
| 140 | 144 | $body_type = $column['type']; |
| 145 | + } |
|
| 141 | 146 | |
| 142 | 147 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 143 | 148 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 144 | 149 | } |
| 145 | 150 | |
| 146 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
| 147 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 148 | -} |
|
| 151 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
| 152 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 153 | + } |
|
| 154 | + } |
|
| 149 | 155 | |
| 150 | 156 | /** |
| 151 | 157 | * Supporting function for the routine maintenance area. |
@@ -154,9 +160,10 @@ discard block |
||
| 154 | 160 | { |
| 155 | 161 | global $context, $txt; |
| 156 | 162 | |
| 157 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
| 158 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 159 | -} |
|
| 163 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
| 164 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 165 | + } |
|
| 166 | + } |
|
| 160 | 167 | |
| 161 | 168 | /** |
| 162 | 169 | * Supporting function for the members maintenance area. |
@@ -187,8 +194,9 @@ discard block |
||
| 187 | 194 | } |
| 188 | 195 | $smcFunc['db_free_result']($result); |
| 189 | 196 | |
| 190 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
| 191 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 197 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
| 198 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 199 | + } |
|
| 192 | 200 | |
| 193 | 201 | loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest'); |
| 194 | 202 | } |
@@ -214,11 +222,12 @@ discard block |
||
| 214 | 222 | $context['categories'] = array(); |
| 215 | 223 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 216 | 224 | { |
| 217 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 218 | - $context['categories'][$row['id_cat']] = array( |
|
| 225 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 226 | + $context['categories'][$row['id_cat']] = array( |
|
| 219 | 227 | 'name' => $row['cat_name'], |
| 220 | 228 | 'boards' => array() |
| 221 | 229 | ); |
| 230 | + } |
|
| 222 | 231 | |
| 223 | 232 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
| 224 | 233 | 'id' => $row['id_board'], |
@@ -231,11 +240,12 @@ discard block |
||
| 231 | 240 | require_once($sourcedir . '/Subs-Boards.php'); |
| 232 | 241 | sortCategories($context['categories']); |
| 233 | 242 | |
| 234 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
| 235 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 236 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
| 237 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 238 | -} |
|
| 243 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
| 244 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 245 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
| 246 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 247 | + } |
|
| 248 | + } |
|
| 239 | 249 | |
| 240 | 250 | /** |
| 241 | 251 | * Find and fix all errors on the forum. |
@@ -343,15 +353,17 @@ discard block |
||
| 343 | 353 | // Show me your badge! |
| 344 | 354 | isAllowedTo('admin_forum'); |
| 345 | 355 | |
| 346 | - if ($db_type != 'mysql') |
|
| 347 | - return; |
|
| 356 | + if ($db_type != 'mysql') { |
|
| 357 | + return; |
|
| 358 | + } |
|
| 348 | 359 | |
| 349 | 360 | db_extend('packages'); |
| 350 | 361 | |
| 351 | 362 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 352 | - foreach ($colData as $column) |
|
| 353 | - if ($column['name'] == 'body') |
|
| 363 | + foreach ($colData as $column) { |
|
| 364 | + if ($column['name'] == 'body') |
|
| 354 | 365 | $body_type = $column['type']; |
| 366 | + } |
|
| 355 | 367 | |
| 356 | 368 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 357 | 369 | |
@@ -361,33 +373,36 @@ discard block |
||
| 361 | 373 | validateToken('admin-maint'); |
| 362 | 374 | |
| 363 | 375 | // Make it longer so we can do their limit. |
| 364 | - if ($body_type == 'text') |
|
| 365 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 376 | + if ($body_type == 'text') { |
|
| 377 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 378 | + } |
|
| 366 | 379 | // Shorten the column so we can have a bit (literally per record) less space occupied |
| 367 | - else |
|
| 368 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 380 | + else { |
|
| 381 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 382 | + } |
|
| 369 | 383 | |
| 370 | 384 | // 3rd party integrations may be interested in knowning about this. |
| 371 | 385 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
| 372 | 386 | |
| 373 | 387 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 374 | - foreach ($colData as $column) |
|
| 375 | - if ($column['name'] == 'body') |
|
| 388 | + foreach ($colData as $column) { |
|
| 389 | + if ($column['name'] == 'body') |
|
| 376 | 390 | $body_type = $column['type']; |
| 391 | + } |
|
| 377 | 392 | |
| 378 | 393 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
| 379 | 394 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 380 | 395 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 381 | 396 | |
| 382 | 397 | return; |
| 383 | - } |
|
| 384 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 398 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 385 | 399 | { |
| 386 | 400 | checkSession(); |
| 387 | - if (empty($_REQUEST['start'])) |
|
| 388 | - validateToken('admin-maint'); |
|
| 389 | - else |
|
| 390 | - validateToken('admin-convertMsg'); |
|
| 401 | + if (empty($_REQUEST['start'])) { |
|
| 402 | + validateToken('admin-maint'); |
|
| 403 | + } else { |
|
| 404 | + validateToken('admin-convertMsg'); |
|
| 405 | + } |
|
| 391 | 406 | |
| 392 | 407 | $context['page_title'] = $txt['not_done_title']; |
| 393 | 408 | $context['continue_post_data'] = ''; |
@@ -419,8 +434,9 @@ discard block |
||
| 419 | 434 | 'increment' => $increment - 1, |
| 420 | 435 | ) |
| 421 | 436 | ); |
| 422 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 423 | - $id_msg_exceeding[] = $row['id_msg']; |
|
| 437 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 438 | + $id_msg_exceeding[] = $row['id_msg']; |
|
| 439 | + } |
|
| 424 | 440 | $smcFunc['db_free_result']($request); |
| 425 | 441 | |
| 426 | 442 | $_REQUEST['start'] += $increment; |
@@ -449,9 +465,9 @@ discard block |
||
| 449 | 465 | { |
| 450 | 466 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
| 451 | 467 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
| 468 | + } else { |
|
| 469 | + $query_msg = $id_msg_exceeding; |
|
| 452 | 470 | } |
| 453 | - else |
|
| 454 | - $query_msg = $id_msg_exceeding; |
|
| 455 | 471 | |
| 456 | 472 | $context['exceeding_messages'] = array(); |
| 457 | 473 | $request = $smcFunc['db_query']('', ' |
@@ -462,8 +478,9 @@ discard block |
||
| 462 | 478 | 'messages' => $query_msg, |
| 463 | 479 | ) |
| 464 | 480 | ); |
| 465 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 466 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 481 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 482 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 483 | + } |
|
| 467 | 484 | $smcFunc['db_free_result']($request); |
| 468 | 485 | } |
| 469 | 486 | } |
@@ -487,8 +504,9 @@ discard block |
||
| 487 | 504 | isAllowedTo('admin_forum'); |
| 488 | 505 | |
| 489 | 506 | // Check to see if UTF-8 is currently the default character set. |
| 490 | - if ($modSettings['global_character_set'] !== 'UTF-8') |
|
| 491 | - fatal_lang_error('entity_convert_only_utf8'); |
|
| 507 | + if ($modSettings['global_character_set'] !== 'UTF-8') { |
|
| 508 | + fatal_lang_error('entity_convert_only_utf8'); |
|
| 509 | + } |
|
| 492 | 510 | |
| 493 | 511 | // Some starting values. |
| 494 | 512 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -550,13 +568,14 @@ discard block |
||
| 550 | 568 | // Make sure we keep stuff unique! |
| 551 | 569 | $primary_keys = array(); |
| 552 | 570 | |
| 553 | - if (function_exists('apache_reset_timeout')) |
|
| 554 | - @apache_reset_timeout(); |
|
| 571 | + if (function_exists('apache_reset_timeout')) { |
|
| 572 | + @apache_reset_timeout(); |
|
| 573 | + } |
|
| 555 | 574 | |
| 556 | 575 | // Get a list of text columns. |
| 557 | 576 | $columns = array(); |
| 558 | - if ($db_type == 'postgresql') |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 577 | + if ($db_type == 'postgresql') { |
|
| 578 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 579 | SELECT column_name "Field", data_type "Type" |
| 561 | 580 | FROM information_schema.columns |
| 562 | 581 | WHERE table_name = {string:cur_table} |
@@ -565,21 +584,23 @@ discard block |
||
| 565 | 584 | 'cur_table' => $db_prefix.$cur_table, |
| 566 | 585 | ) |
| 567 | 586 | ); |
| 568 | - else |
|
| 569 | - $request = $smcFunc['db_query']('', ' |
|
| 587 | + } else { |
|
| 588 | + $request = $smcFunc['db_query']('', ' |
|
| 570 | 589 | SHOW FULL COLUMNS |
| 571 | 590 | FROM {db_prefix}{raw:cur_table}', |
| 572 | 591 | array( |
| 573 | 592 | 'cur_table' => $cur_table, |
| 574 | 593 | ) |
| 575 | 594 | ); |
| 576 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
| 577 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 595 | + } |
|
| 596 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
| 597 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 578 | 598 | $columns[] = strtolower($column_info['Field']); |
| 599 | + } |
|
| 579 | 600 | |
| 580 | 601 | // Get the column with the (first) primary key. |
| 581 | - if ($db_type == 'postgresql') |
|
| 582 | - $request = $smcFunc['db_query']('', ' |
|
| 602 | + if ($db_type == 'postgresql') { |
|
| 603 | + $request = $smcFunc['db_query']('', ' |
|
| 583 | 604 | SELECT a.attname "Column_name", \'PRIMARY\' "Key_name", attnum "Seq_in_index" |
| 584 | 605 | FROM pg_index i |
| 585 | 606 | JOIN pg_attribute a ON a.attrelid = i.indrelid |
@@ -590,20 +611,22 @@ discard block |
||
| 590 | 611 | 'cur_table' => $db_prefix.$cur_table, |
| 591 | 612 | ) |
| 592 | 613 | ); |
| 593 | - else |
|
| 594 | - $request = $smcFunc['db_query']('', ' |
|
| 614 | + } else { |
|
| 615 | + $request = $smcFunc['db_query']('', ' |
|
| 595 | 616 | SHOW KEYS |
| 596 | 617 | FROM {db_prefix}{raw:cur_table}', |
| 597 | 618 | array( |
| 598 | 619 | 'cur_table' => $cur_table, |
| 599 | 620 | ) |
| 600 | 621 | ); |
| 622 | + } |
|
| 601 | 623 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 602 | 624 | { |
| 603 | 625 | if ($row['Key_name'] === 'PRIMARY') |
| 604 | 626 | { |
| 605 | - if ((empty($primary_key) || $row['Seq_in_index'] == 1) && !in_array(strtolower($row['Column_name']), $columns)) |
|
| 606 | - $primary_key = $row['Column_name']; |
|
| 627 | + if ((empty($primary_key) || $row['Seq_in_index'] == 1) && !in_array(strtolower($row['Column_name']), $columns)) { |
|
| 628 | + $primary_key = $row['Column_name']; |
|
| 629 | + } |
|
| 607 | 630 | |
| 608 | 631 | $primary_keys[] = $row['Column_name']; |
| 609 | 632 | } |
@@ -612,8 +635,9 @@ discard block |
||
| 612 | 635 | |
| 613 | 636 | // No primary key, no glory. |
| 614 | 637 | // Same for columns. Just to be sure we've work to do! |
| 615 | - if (empty($primary_key) || empty($columns)) |
|
| 616 | - continue; |
|
| 638 | + if (empty($primary_key) || empty($columns)) { |
|
| 639 | + continue; |
|
| 640 | + } |
|
| 617 | 641 | |
| 618 | 642 | // Get the maximum value for the primary key. |
| 619 | 643 | $request = $smcFunc['db_query']('', ' |
@@ -627,8 +651,9 @@ discard block |
||
| 627 | 651 | list($max_value) = $smcFunc['db_fetch_row']($request); |
| 628 | 652 | $smcFunc['db_free_result']($request); |
| 629 | 653 | |
| 630 | - if (empty($max_value)) |
|
| 631 | - continue; |
|
| 654 | + if (empty($max_value)) { |
|
| 655 | + continue; |
|
| 656 | + } |
|
| 632 | 657 | |
| 633 | 658 | while ($context['start'] <= $max_value) |
| 634 | 659 | { |
@@ -652,10 +677,11 @@ discard block |
||
| 652 | 677 | { |
| 653 | 678 | $insertion_variables = array(); |
| 654 | 679 | $changes = array(); |
| 655 | - foreach ($row as $column_name => $column_value) |
|
| 656 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 680 | + foreach ($row as $column_name => $column_value) { |
|
| 681 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 657 | 682 | { |
| 658 | 683 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
| 684 | + } |
|
| 659 | 685 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,5}|x[0-9a-fA-F]{1,4});~', 'fixchardb__callback', $column_value); |
| 660 | 686 | } |
| 661 | 687 | |
@@ -667,8 +693,8 @@ discard block |
||
| 667 | 693 | } |
| 668 | 694 | |
| 669 | 695 | // Update the row. |
| 670 | - if (!empty($changes)) |
|
| 671 | - $smcFunc['db_query']('', ' |
|
| 696 | + if (!empty($changes)) { |
|
| 697 | + $smcFunc['db_query']('', ' |
|
| 672 | 698 | UPDATE {db_prefix}' . $cur_table . ' |
| 673 | 699 | SET |
| 674 | 700 | ' . implode(', |
@@ -676,6 +702,7 @@ discard block |
||
| 676 | 702 | WHERE ' . implode(' AND ', $where), |
| 677 | 703 | $insertion_variables |
| 678 | 704 | ); |
| 705 | + } |
|
| 679 | 706 | } |
| 680 | 707 | $smcFunc['db_free_result']($request); |
| 681 | 708 | $context['start'] += 500; |
@@ -716,10 +743,11 @@ discard block |
||
| 716 | 743 | |
| 717 | 744 | checkSession('request'); |
| 718 | 745 | |
| 719 | - if (!isset($_SESSION['optimized_tables'])) |
|
| 720 | - validateToken('admin-maint'); |
|
| 721 | - else |
|
| 722 | - validateToken('admin-optimize', 'post', false); |
|
| 746 | + if (!isset($_SESSION['optimized_tables'])) { |
|
| 747 | + validateToken('admin-maint'); |
|
| 748 | + } else { |
|
| 749 | + validateToken('admin-optimize', 'post', false); |
|
| 750 | + } |
|
| 723 | 751 | |
| 724 | 752 | ignore_user_abort(true); |
| 725 | 753 | db_extend(); |
@@ -735,13 +763,15 @@ discard block |
||
| 735 | 763 | // Get a list of tables, as well as how many there are. |
| 736 | 764 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
| 737 | 765 | $tables = array(); |
| 738 | - foreach ($temp_tables as $table) |
|
| 739 | - $tables[] = array('table_name' => $table); |
|
| 766 | + foreach ($temp_tables as $table) { |
|
| 767 | + $tables[] = array('table_name' => $table); |
|
| 768 | + } |
|
| 740 | 769 | |
| 741 | 770 | // If there aren't any tables then I believe that would mean the world has exploded... |
| 742 | 771 | $context['num_tables'] = count($tables); |
| 743 | - if ($context['num_tables'] == 0) |
|
| 744 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 772 | + if ($context['num_tables'] == 0) { |
|
| 773 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 774 | + } |
|
| 745 | 775 | |
| 746 | 776 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 747 | 777 | |
@@ -752,8 +782,9 @@ discard block |
||
| 752 | 782 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
| 753 | 783 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
| 754 | 784 | { |
| 755 | - if (empty($tables[$key])) |
|
| 756 | - break; |
|
| 785 | + if (empty($tables[$key])) { |
|
| 786 | + break; |
|
| 787 | + } |
|
| 757 | 788 | |
| 758 | 789 | // Continue? |
| 759 | 790 | if (microtime(true) - $time_start > 10) |
@@ -767,8 +798,9 @@ discard block |
||
| 767 | 798 | createToken('admin-optimize'); |
| 768 | 799 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
| 769 | 800 | |
| 770 | - if (function_exists('apache_reset_timeout')) |
|
| 771 | - apache_reset_timeout(); |
|
| 801 | + if (function_exists('apache_reset_timeout')) { |
|
| 802 | + apache_reset_timeout(); |
|
| 803 | + } |
|
| 772 | 804 | |
| 773 | 805 | return; |
| 774 | 806 | } |
@@ -776,11 +808,12 @@ discard block |
||
| 776 | 808 | // Optimize the table! We use backticks here because it might be a custom table. |
| 777 | 809 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
| 778 | 810 | |
| 779 | - if ($data_freed > 0) |
|
| 780 | - $_SESSION['optimized_tables'][] = array( |
|
| 811 | + if ($data_freed > 0) { |
|
| 812 | + $_SESSION['optimized_tables'][] = array( |
|
| 781 | 813 | 'name' => $tables[$key]['table_name'], |
| 782 | 814 | 'data_freed' => $data_freed, |
| 783 | 815 | ); |
| 816 | + } |
|
| 784 | 817 | } |
| 785 | 818 | |
| 786 | 819 | // Number of tables, etc... |
@@ -815,10 +848,11 @@ discard block |
||
| 815 | 848 | checkSession('request'); |
| 816 | 849 | |
| 817 | 850 | // validate the request or the loop |
| 818 | - if (!isset($_REQUEST['step'])) |
|
| 819 | - validateToken('admin-maint'); |
|
| 820 | - else |
|
| 821 | - validateToken('admin-boardrecount'); |
|
| 851 | + if (!isset($_REQUEST['step'])) { |
|
| 852 | + validateToken('admin-maint'); |
|
| 853 | + } else { |
|
| 854 | + validateToken('admin-boardrecount'); |
|
| 855 | + } |
|
| 822 | 856 | |
| 823 | 857 | $context['page_title'] = $txt['not_done_title']; |
| 824 | 858 | $context['continue_post_data'] = ''; |
@@ -839,8 +873,9 @@ discard block |
||
| 839 | 873 | $smcFunc['db_free_result']($request); |
| 840 | 874 | |
| 841 | 875 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
| 842 | - if (empty($_REQUEST['start'])) |
|
| 843 | - $_REQUEST['start'] = 0; |
|
| 876 | + if (empty($_REQUEST['start'])) { |
|
| 877 | + $_REQUEST['start'] = 0; |
|
| 878 | + } |
|
| 844 | 879 | |
| 845 | 880 | $total_steps = 8; |
| 846 | 881 | |
@@ -867,8 +902,8 @@ discard block |
||
| 867 | 902 | 'max_id' => $_REQUEST['start'] + $increment, |
| 868 | 903 | ) |
| 869 | 904 | ); |
| 870 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 871 | - $smcFunc['db_query']('', ' |
|
| 905 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 906 | + $smcFunc['db_query']('', ' |
|
| 872 | 907 | UPDATE {db_prefix}topics |
| 873 | 908 | SET num_replies = {int:num_replies} |
| 874 | 909 | WHERE id_topic = {int:id_topic}', |
@@ -877,6 +912,7 @@ discard block |
||
| 877 | 912 | 'id_topic' => $row['id_topic'], |
| 878 | 913 | ) |
| 879 | 914 | ); |
| 915 | + } |
|
| 880 | 916 | $smcFunc['db_free_result']($request); |
| 881 | 917 | |
| 882 | 918 | // Recount unapproved messages |
@@ -895,8 +931,8 @@ discard block |
||
| 895 | 931 | 'max_id' => $_REQUEST['start'] + $increment, |
| 896 | 932 | ) |
| 897 | 933 | ); |
| 898 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 899 | - $smcFunc['db_query']('', ' |
|
| 934 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 935 | + $smcFunc['db_query']('', ' |
|
| 900 | 936 | UPDATE {db_prefix}topics |
| 901 | 937 | SET unapproved_posts = {int:unapproved_posts} |
| 902 | 938 | WHERE id_topic = {int:id_topic}', |
@@ -905,6 +941,7 @@ discard block |
||
| 905 | 941 | 'id_topic' => $row['id_topic'], |
| 906 | 942 | ) |
| 907 | 943 | ); |
| 944 | + } |
|
| 908 | 945 | $smcFunc['db_free_result']($request); |
| 909 | 946 | |
| 910 | 947 | $_REQUEST['start'] += $increment; |
@@ -927,8 +964,8 @@ discard block |
||
| 927 | 964 | // Update the post count of each board. |
| 928 | 965 | if ($_REQUEST['step'] <= 1) |
| 929 | 966 | { |
| 930 | - if (empty($_REQUEST['start'])) |
|
| 931 | - $smcFunc['db_query']('', ' |
|
| 967 | + if (empty($_REQUEST['start'])) { |
|
| 968 | + $smcFunc['db_query']('', ' |
|
| 932 | 969 | UPDATE {db_prefix}boards |
| 933 | 970 | SET num_posts = {int:num_posts} |
| 934 | 971 | WHERE redirect = {string:redirect}', |
@@ -937,6 +974,7 @@ discard block |
||
| 937 | 974 | 'redirect' => '', |
| 938 | 975 | ) |
| 939 | 976 | ); |
| 977 | + } |
|
| 940 | 978 | |
| 941 | 979 | while ($_REQUEST['start'] < $max_topics) |
| 942 | 980 | { |
@@ -953,8 +991,8 @@ discard block |
||
| 953 | 991 | 'is_approved' => 1, |
| 954 | 992 | ) |
| 955 | 993 | ); |
| 956 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 957 | - $smcFunc['db_query']('', ' |
|
| 994 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 995 | + $smcFunc['db_query']('', ' |
|
| 958 | 996 | UPDATE {db_prefix}boards |
| 959 | 997 | SET num_posts = num_posts + {int:real_num_posts} |
| 960 | 998 | WHERE id_board = {int:id_board}', |
@@ -963,6 +1001,7 @@ discard block |
||
| 963 | 1001 | 'real_num_posts' => $row['real_num_posts'], |
| 964 | 1002 | ) |
| 965 | 1003 | ); |
| 1004 | + } |
|
| 966 | 1005 | $smcFunc['db_free_result']($request); |
| 967 | 1006 | |
| 968 | 1007 | $_REQUEST['start'] += $increment; |
@@ -985,14 +1024,15 @@ discard block |
||
| 985 | 1024 | // Update the topic count of each board. |
| 986 | 1025 | if ($_REQUEST['step'] <= 2) |
| 987 | 1026 | { |
| 988 | - if (empty($_REQUEST['start'])) |
|
| 989 | - $smcFunc['db_query']('', ' |
|
| 1027 | + if (empty($_REQUEST['start'])) { |
|
| 1028 | + $smcFunc['db_query']('', ' |
|
| 990 | 1029 | UPDATE {db_prefix}boards |
| 991 | 1030 | SET num_topics = {int:num_topics}', |
| 992 | 1031 | array( |
| 993 | 1032 | 'num_topics' => 0, |
| 994 | 1033 | ) |
| 995 | 1034 | ); |
| 1035 | + } |
|
| 996 | 1036 | |
| 997 | 1037 | while ($_REQUEST['start'] < $max_topics) |
| 998 | 1038 | { |
@@ -1009,8 +1049,8 @@ discard block |
||
| 1009 | 1049 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 1010 | 1050 | ) |
| 1011 | 1051 | ); |
| 1012 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1013 | - $smcFunc['db_query']('', ' |
|
| 1052 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1053 | + $smcFunc['db_query']('', ' |
|
| 1014 | 1054 | UPDATE {db_prefix}boards |
| 1015 | 1055 | SET num_topics = num_topics + {int:real_num_topics} |
| 1016 | 1056 | WHERE id_board = {int:id_board}', |
@@ -1019,6 +1059,7 @@ discard block |
||
| 1019 | 1059 | 'real_num_topics' => $row['real_num_topics'], |
| 1020 | 1060 | ) |
| 1021 | 1061 | ); |
| 1062 | + } |
|
| 1022 | 1063 | $smcFunc['db_free_result']($request); |
| 1023 | 1064 | |
| 1024 | 1065 | $_REQUEST['start'] += $increment; |
@@ -1041,14 +1082,15 @@ discard block |
||
| 1041 | 1082 | // Update the unapproved post count of each board. |
| 1042 | 1083 | if ($_REQUEST['step'] <= 3) |
| 1043 | 1084 | { |
| 1044 | - if (empty($_REQUEST['start'])) |
|
| 1045 | - $smcFunc['db_query']('', ' |
|
| 1085 | + if (empty($_REQUEST['start'])) { |
|
| 1086 | + $smcFunc['db_query']('', ' |
|
| 1046 | 1087 | UPDATE {db_prefix}boards |
| 1047 | 1088 | SET unapproved_posts = {int:unapproved_posts}', |
| 1048 | 1089 | array( |
| 1049 | 1090 | 'unapproved_posts' => 0, |
| 1050 | 1091 | ) |
| 1051 | 1092 | ); |
| 1093 | + } |
|
| 1052 | 1094 | |
| 1053 | 1095 | while ($_REQUEST['start'] < $max_topics) |
| 1054 | 1096 | { |
@@ -1065,8 +1107,8 @@ discard block |
||
| 1065 | 1107 | 'is_approved' => 0, |
| 1066 | 1108 | ) |
| 1067 | 1109 | ); |
| 1068 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1069 | - $smcFunc['db_query']('', ' |
|
| 1110 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1111 | + $smcFunc['db_query']('', ' |
|
| 1070 | 1112 | UPDATE {db_prefix}boards |
| 1071 | 1113 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
| 1072 | 1114 | WHERE id_board = {int:id_board}', |
@@ -1075,6 +1117,7 @@ discard block |
||
| 1075 | 1117 | 'unapproved_posts' => $row['real_unapproved_posts'], |
| 1076 | 1118 | ) |
| 1077 | 1119 | ); |
| 1120 | + } |
|
| 1078 | 1121 | $smcFunc['db_free_result']($request); |
| 1079 | 1122 | |
| 1080 | 1123 | $_REQUEST['start'] += $increment; |
@@ -1097,14 +1140,15 @@ discard block |
||
| 1097 | 1140 | // Update the unapproved topic count of each board. |
| 1098 | 1141 | if ($_REQUEST['step'] <= 4) |
| 1099 | 1142 | { |
| 1100 | - if (empty($_REQUEST['start'])) |
|
| 1101 | - $smcFunc['db_query']('', ' |
|
| 1143 | + if (empty($_REQUEST['start'])) { |
|
| 1144 | + $smcFunc['db_query']('', ' |
|
| 1102 | 1145 | UPDATE {db_prefix}boards |
| 1103 | 1146 | SET unapproved_topics = {int:unapproved_topics}', |
| 1104 | 1147 | array( |
| 1105 | 1148 | 'unapproved_topics' => 0, |
| 1106 | 1149 | ) |
| 1107 | 1150 | ); |
| 1151 | + } |
|
| 1108 | 1152 | |
| 1109 | 1153 | while ($_REQUEST['start'] < $max_topics) |
| 1110 | 1154 | { |
@@ -1121,8 +1165,8 @@ discard block |
||
| 1121 | 1165 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 1122 | 1166 | ) |
| 1123 | 1167 | ); |
| 1124 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1125 | - $smcFunc['db_query']('', ' |
|
| 1168 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1169 | + $smcFunc['db_query']('', ' |
|
| 1126 | 1170 | UPDATE {db_prefix}boards |
| 1127 | 1171 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
| 1128 | 1172 | WHERE id_board = {int:id_board}', |
@@ -1131,6 +1175,7 @@ discard block |
||
| 1131 | 1175 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
| 1132 | 1176 | ) |
| 1133 | 1177 | ); |
| 1178 | + } |
|
| 1134 | 1179 | $smcFunc['db_free_result']($request); |
| 1135 | 1180 | |
| 1136 | 1181 | $_REQUEST['start'] += $increment; |
@@ -1164,8 +1209,9 @@ discard block |
||
| 1164 | 1209 | 'is_not_deleted' => 0, |
| 1165 | 1210 | ) |
| 1166 | 1211 | ); |
| 1167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1168 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1212 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1213 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1214 | + } |
|
| 1169 | 1215 | $smcFunc['db_free_result']($request); |
| 1170 | 1216 | |
| 1171 | 1217 | $request = $smcFunc['db_query']('', ' |
@@ -1180,8 +1226,9 @@ discard block |
||
| 1180 | 1226 | 'is_not_read' => 0, |
| 1181 | 1227 | ) |
| 1182 | 1228 | ); |
| 1183 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1184 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1229 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1230 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1231 | + } |
|
| 1185 | 1232 | $smcFunc['db_free_result']($request); |
| 1186 | 1233 | |
| 1187 | 1234 | if (microtime(true) - $time_start > 3) |
@@ -1213,12 +1260,13 @@ discard block |
||
| 1213 | 1260 | ) |
| 1214 | 1261 | ); |
| 1215 | 1262 | $boards = array(); |
| 1216 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1217 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1263 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1264 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1265 | + } |
|
| 1218 | 1266 | $smcFunc['db_free_result']($request); |
| 1219 | 1267 | |
| 1220 | - foreach ($boards as $board_id => $messages) |
|
| 1221 | - $smcFunc['db_query']('', ' |
|
| 1268 | + foreach ($boards as $board_id => $messages) { |
|
| 1269 | + $smcFunc['db_query']('', ' |
|
| 1222 | 1270 | UPDATE {db_prefix}messages |
| 1223 | 1271 | SET id_board = {int:id_board} |
| 1224 | 1272 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1227,6 +1275,7 @@ discard block |
||
| 1227 | 1275 | 'id_board' => $board_id, |
| 1228 | 1276 | ) |
| 1229 | 1277 | ); |
| 1278 | + } |
|
| 1230 | 1279 | |
| 1231 | 1280 | $_REQUEST['start'] += $increment; |
| 1232 | 1281 | |
@@ -1256,8 +1305,9 @@ discard block |
||
| 1256 | 1305 | ) |
| 1257 | 1306 | ); |
| 1258 | 1307 | $realBoardCounts = array(); |
| 1259 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1260 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1308 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1309 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1310 | + } |
|
| 1261 | 1311 | $smcFunc['db_free_result']($request); |
| 1262 | 1312 | |
| 1263 | 1313 | $request = $smcFunc['db_query']('', ' |
@@ -1277,18 +1327,20 @@ discard block |
||
| 1277 | 1327 | krsort($resort_me); |
| 1278 | 1328 | |
| 1279 | 1329 | $lastModifiedMsg = array(); |
| 1280 | - foreach ($resort_me as $rows) |
|
| 1281 | - foreach ($rows as $row) |
|
| 1330 | + foreach ($resort_me as $rows) { |
|
| 1331 | + foreach ($rows as $row) |
|
| 1282 | 1332 | { |
| 1283 | 1333 | // The latest message is the latest of the current board and its children. |
| 1284 | 1334 | if (isset($lastModifiedMsg[$row['id_board']])) |
| 1285 | 1335 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
| 1286 | - else |
|
| 1287 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1336 | + } |
|
| 1337 | + else { |
|
| 1338 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1339 | + } |
|
| 1288 | 1340 | |
| 1289 | 1341 | // If what is and what should be the latest message differ, an update is necessary. |
| 1290 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
| 1291 | - $smcFunc['db_query']('', ' |
|
| 1342 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
| 1343 | + $smcFunc['db_query']('', ' |
|
| 1292 | 1344 | UPDATE {db_prefix}boards |
| 1293 | 1345 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
| 1294 | 1346 | WHERE id_board = {int:id_board}', |
@@ -1298,12 +1350,14 @@ discard block |
||
| 1298 | 1350 | 'id_board' => $row['id_board'], |
| 1299 | 1351 | ) |
| 1300 | 1352 | ); |
| 1353 | + } |
|
| 1301 | 1354 | |
| 1302 | 1355 | // Parent boards inherit the latest modified message of their children. |
| 1303 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
| 1304 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1305 | - else |
|
| 1306 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1356 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
| 1357 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1358 | + } else { |
|
| 1359 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1360 | + } |
|
| 1307 | 1361 | } |
| 1308 | 1362 | |
| 1309 | 1363 | // Update all the basic statistics. |
@@ -1375,8 +1429,9 @@ discard block |
||
| 1375 | 1429 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1376 | 1430 | $members = findMembers($_POST['to']); |
| 1377 | 1431 | |
| 1378 | - if (empty($members)) |
|
| 1379 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1432 | + if (empty($members)) { |
|
| 1433 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1434 | + } |
|
| 1380 | 1435 | |
| 1381 | 1436 | $memID = array_shift($members); |
| 1382 | 1437 | $memID = $memID['id']; |
@@ -1406,8 +1461,9 @@ discard block |
||
| 1406 | 1461 | validateToken('admin-maint'); |
| 1407 | 1462 | |
| 1408 | 1463 | $groups = array(); |
| 1409 | - foreach ($_POST['groups'] as $id => $dummy) |
|
| 1410 | - $groups[] = (int) $id; |
|
| 1464 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
| 1465 | + $groups[] = (int) $id; |
|
| 1466 | + } |
|
| 1411 | 1467 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
| 1412 | 1468 | $where_vars = array( |
| 1413 | 1469 | 'time_limit' => $time_limit, |
@@ -1416,9 +1472,9 @@ discard block |
||
| 1416 | 1472 | { |
| 1417 | 1473 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
| 1418 | 1474 | $where_vars['is_activated'] = 0; |
| 1475 | + } else { |
|
| 1476 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1419 | 1477 | } |
| 1420 | - else |
|
| 1421 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1422 | 1478 | |
| 1423 | 1479 | // Need to get *all* groups then work out which (if any) we avoid. |
| 1424 | 1480 | $request = $smcFunc['db_query']('', ' |
@@ -1437,8 +1493,7 @@ discard block |
||
| 1437 | 1493 | { |
| 1438 | 1494 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
| 1439 | 1495 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
| 1440 | - } |
|
| 1441 | - else |
|
| 1496 | + } else |
|
| 1442 | 1497 | { |
| 1443 | 1498 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
| 1444 | 1499 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1465,8 +1520,9 @@ discard block |
||
| 1465 | 1520 | $members = array(); |
| 1466 | 1521 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1467 | 1522 | { |
| 1468 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
| 1469 | - $members[] = $row['id_member']; |
|
| 1523 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
| 1524 | + $members[] = $row['id_member']; |
|
| 1525 | + } |
|
| 1470 | 1526 | } |
| 1471 | 1527 | $smcFunc['db_free_result']($request); |
| 1472 | 1528 | |
@@ -1513,8 +1569,9 @@ discard block |
||
| 1513 | 1569 | ) |
| 1514 | 1570 | ); |
| 1515 | 1571 | |
| 1516 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1517 | - $drafts[] = (int) $row[0]; |
|
| 1572 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1573 | + $drafts[] = (int) $row[0]; |
|
| 1574 | + } |
|
| 1518 | 1575 | $smcFunc['db_free_result']($request); |
| 1519 | 1576 | |
| 1520 | 1577 | // If we have old drafts, remove them |
@@ -1557,8 +1614,9 @@ discard block |
||
| 1557 | 1614 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
| 1558 | 1615 | |
| 1559 | 1616 | // No boards then this is your stop. |
| 1560 | - if (empty($id_board_from) || empty($id_board_to)) |
|
| 1561 | - return; |
|
| 1617 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
| 1618 | + return; |
|
| 1619 | + } |
|
| 1562 | 1620 | |
| 1563 | 1621 | // The big WHERE clause |
| 1564 | 1622 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1606,18 +1664,20 @@ discard block |
||
| 1606 | 1664 | ); |
| 1607 | 1665 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
| 1608 | 1666 | $smcFunc['db_free_result']($request); |
| 1667 | + } else { |
|
| 1668 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1609 | 1669 | } |
| 1610 | - else |
|
| 1611 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1612 | 1670 | |
| 1613 | 1671 | // Seems like we need this here. |
| 1614 | 1672 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
| 1615 | 1673 | |
| 1616 | - if ($locked) |
|
| 1617 | - $context['continue_get_data'] .= ';locked'; |
|
| 1674 | + if ($locked) { |
|
| 1675 | + $context['continue_get_data'] .= ';locked'; |
|
| 1676 | + } |
|
| 1618 | 1677 | |
| 1619 | - if ($sticky) |
|
| 1620 | - $context['continue_get_data'] .= ';sticky'; |
|
| 1678 | + if ($sticky) { |
|
| 1679 | + $context['continue_get_data'] .= ';sticky'; |
|
| 1680 | + } |
|
| 1621 | 1681 | |
| 1622 | 1682 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1623 | 1683 | |
@@ -1638,8 +1698,9 @@ discard block |
||
| 1638 | 1698 | |
| 1639 | 1699 | // Get the ids. |
| 1640 | 1700 | $topics = array(); |
| 1641 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1642 | - $topics[] = $row['id_topic']; |
|
| 1701 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1702 | + $topics[] = $row['id_topic']; |
|
| 1703 | + } |
|
| 1643 | 1704 | |
| 1644 | 1705 | // Just return if we don't have any topics left to move. |
| 1645 | 1706 | if (empty($topics)) |
@@ -1730,9 +1791,9 @@ discard block |
||
| 1730 | 1791 | // save it so we don't do this again for this task |
| 1731 | 1792 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
| 1732 | 1793 | $smcFunc['db_free_result']($request); |
| 1794 | + } else { |
|
| 1795 | + validateToken('admin-recountposts'); |
|
| 1733 | 1796 | } |
| 1734 | - else |
|
| 1735 | - validateToken('admin-recountposts'); |
|
| 1736 | 1797 | |
| 1737 | 1798 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
| 1738 | 1799 | $request = $smcFunc['db_query']('', ' |
@@ -1778,8 +1839,9 @@ discard block |
||
| 1778 | 1839 | createToken('admin-recountposts'); |
| 1779 | 1840 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
| 1780 | 1841 | |
| 1781 | - if (function_exists('apache_reset_timeout')) |
|
| 1782 | - apache_reset_timeout(); |
|
| 1842 | + if (function_exists('apache_reset_timeout')) { |
|
| 1843 | + apache_reset_timeout(); |
|
| 1844 | + } |
|
| 1783 | 1845 | return; |
| 1784 | 1846 | } |
| 1785 | 1847 | |
@@ -1865,10 +1927,9 @@ discard block |
||
| 1865 | 1927 | checkSession('request'); |
| 1866 | 1928 | validateToken('admin-hook', 'request'); |
| 1867 | 1929 | |
| 1868 | - if ($_REQUEST['do'] == 'remove') |
|
| 1869 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1870 | - |
|
| 1871 | - else |
|
| 1930 | + if ($_REQUEST['do'] == 'remove') { |
|
| 1931 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1932 | + } else |
|
| 1872 | 1933 | { |
| 1873 | 1934 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
| 1874 | 1935 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1918,11 +1979,11 @@ discard block |
||
| 1918 | 1979 | // Show a nice icon to indicate this is an instance. |
| 1919 | 1980 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
| 1920 | 1981 | |
| 1921 | - if (!empty($data['included_file'])) |
|
| 1922 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1923 | - |
|
| 1924 | - else |
|
| 1925 | - return $instance . $data['real_function']; |
|
| 1982 | + if (!empty($data['included_file'])) { |
|
| 1983 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1984 | + } else { |
|
| 1985 | + return $instance . $data['real_function']; |
|
| 1986 | + } |
|
| 1926 | 1987 | }, |
| 1927 | 1988 | ), |
| 1928 | 1989 | 'sort' => array( |
@@ -1987,11 +2048,12 @@ discard block |
||
| 1987 | 2048 | 'data' => array( |
| 1988 | 2049 | 'function' => function($data) use ($txt, $scripturl, $context) |
| 1989 | 2050 | { |
| 1990 | - if (!$data['hook_exists']) |
|
| 1991 | - return ' |
|
| 2051 | + if (!$data['hook_exists']) { |
|
| 2052 | + return ' |
|
| 1992 | 2053 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
| 1993 | 2054 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
| 1994 | 2055 | </a>'; |
| 2056 | + } |
|
| 1995 | 2057 | }, |
| 1996 | 2058 | 'class' => 'centertext', |
| 1997 | 2059 | ), |
@@ -2026,10 +2088,11 @@ discard block |
||
| 2026 | 2088 | { |
| 2027 | 2089 | if ($file != '.' && $file != '..') |
| 2028 | 2090 | { |
| 2029 | - if (is_dir($dir_path . '/' . $file)) |
|
| 2030 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2031 | - else |
|
| 2032 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2091 | + if (is_dir($dir_path . '/' . $file)) { |
|
| 2092 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2093 | + } else { |
|
| 2094 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2095 | + } |
|
| 2033 | 2096 | } |
| 2034 | 2097 | } |
| 2035 | 2098 | } |
@@ -2078,16 +2141,16 @@ discard block |
||
| 2078 | 2141 | // I need to know if there is at least one function called in this file. |
| 2079 | 2142 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
| 2080 | 2143 | unset($temp_hooks[$hook][$rawFunc]); |
| 2081 | - } |
|
| 2082 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2144 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2083 | 2145 | { |
| 2084 | 2146 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
| 2085 | 2147 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
| 2086 | 2148 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
| 2087 | 2149 | |
| 2088 | 2150 | // Does the hook has its own file? |
| 2089 | - if (!empty($hookParsedData['hookFile'])) |
|
| 2090 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2151 | + if (!empty($hookParsedData['hookFile'])) { |
|
| 2152 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2153 | + } |
|
| 2091 | 2154 | |
| 2092 | 2155 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
| 2093 | 2156 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2114,15 +2177,17 @@ discard block |
||
| 2114 | 2177 | $sort = array(); |
| 2115 | 2178 | $hooks_filters = array(); |
| 2116 | 2179 | |
| 2117 | - foreach ($hooks as $hook => $functions) |
|
| 2118 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2180 | + foreach ($hooks as $hook => $functions) { |
|
| 2181 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2182 | + } |
|
| 2119 | 2183 | |
| 2120 | - if (!empty($hooks_filters)) |
|
| 2121 | - $context['insert_after_template'] .= ' |
|
| 2184 | + if (!empty($hooks_filters)) { |
|
| 2185 | + $context['insert_after_template'] .= ' |
|
| 2122 | 2186 | <script> |
| 2123 | 2187 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
| 2124 | 2188 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . '; |
| 2125 | 2189 | </script>'; |
| 2190 | + } |
|
| 2126 | 2191 | |
| 2127 | 2192 | $temp_data = array(); |
| 2128 | 2193 | $id = 0; |
@@ -2164,10 +2229,11 @@ discard block |
||
| 2164 | 2229 | |
| 2165 | 2230 | foreach ($temp_data as $data) |
| 2166 | 2231 | { |
| 2167 | - if (++$counter < $start) |
|
| 2168 | - continue; |
|
| 2169 | - elseif ($counter == $start + $per_page) |
|
| 2170 | - break; |
|
| 2232 | + if (++$counter < $start) { |
|
| 2233 | + continue; |
|
| 2234 | + } elseif ($counter == $start + $per_page) { |
|
| 2235 | + break; |
|
| 2236 | + } |
|
| 2171 | 2237 | |
| 2172 | 2238 | $hooks_data[] = $data; |
| 2173 | 2239 | } |
@@ -2189,13 +2255,15 @@ discard block |
||
| 2189 | 2255 | $hooks_count = 0; |
| 2190 | 2256 | |
| 2191 | 2257 | $context['filter'] = false; |
| 2192 | - if (isset($_GET['filter'])) |
|
| 2193 | - $context['filter'] = $_GET['filter']; |
|
| 2258 | + if (isset($_GET['filter'])) { |
|
| 2259 | + $context['filter'] = $_GET['filter']; |
|
| 2260 | + } |
|
| 2194 | 2261 | |
| 2195 | 2262 | foreach ($hooks as $hook => $functions) |
| 2196 | 2263 | { |
| 2197 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
| 2198 | - $hooks_count += count($functions); |
|
| 2264 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
| 2265 | + $hooks_count += count($functions); |
|
| 2266 | + } |
|
| 2199 | 2267 | } |
| 2200 | 2268 | |
| 2201 | 2269 | return $hooks_count; |
@@ -2216,8 +2284,9 @@ discard block |
||
| 2216 | 2284 | $integration_hooks = array(); |
| 2217 | 2285 | foreach ($modSettings as $key => $value) |
| 2218 | 2286 | { |
| 2219 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
| 2220 | - $integration_hooks[$key] = explode(',', $value); |
|
| 2287 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
| 2288 | + $integration_hooks[$key] = explode(',', $value); |
|
| 2289 | + } |
|
| 2221 | 2290 | } |
| 2222 | 2291 | } |
| 2223 | 2292 | |
@@ -2248,8 +2317,9 @@ discard block |
||
| 2248 | 2317 | ); |
| 2249 | 2318 | |
| 2250 | 2319 | // Meh... |
| 2251 | - if (empty($rawData)) |
|
| 2252 | - return $hookData; |
|
| 2320 | + if (empty($rawData)) { |
|
| 2321 | + return $hookData; |
|
| 2322 | + } |
|
| 2253 | 2323 | |
| 2254 | 2324 | // For convenience purposes only! |
| 2255 | 2325 | $modFunc = $rawData; |
@@ -2260,11 +2330,11 @@ discard block |
||
| 2260 | 2330 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
| 2261 | 2331 | |
| 2262 | 2332 | // Does the file exists? who knows! |
| 2263 | - if (empty($settings['theme_dir'])) |
|
| 2264 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2265 | - |
|
| 2266 | - else |
|
| 2267 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2333 | + if (empty($settings['theme_dir'])) { |
|
| 2334 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2335 | + } else { |
|
| 2336 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2337 | + } |
|
| 2268 | 2338 | |
| 2269 | 2339 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
| 2270 | 2340 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2289,11 +2359,10 @@ discard block |
||
| 2289 | 2359 | { |
| 2290 | 2360 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
| 2291 | 2361 | $hookData['pureFunc'] = $hookData['method']; |
| 2362 | + } else { |
|
| 2363 | + $hookData['pureFunc'] = $modFunc; |
|
| 2292 | 2364 | } |
| 2293 | 2365 | |
| 2294 | - else |
|
| 2295 | - $hookData['pureFunc'] = $modFunc; |
|
| 2296 | - |
|
| 2297 | 2366 | return $hookData; |
| 2298 | 2367 | } |
| 2299 | 2368 | |
@@ -2311,16 +2380,18 @@ discard block |
||
| 2311 | 2380 | function fixchardb__callback($matches) |
| 2312 | 2381 | { |
| 2313 | 2382 | global $smcFunc; |
| 2314 | - if (!isset($matches[1])) |
|
| 2315 | - return ''; |
|
| 2383 | + if (!isset($matches[1])) { |
|
| 2384 | + return ''; |
|
| 2385 | + } |
|
| 2316 | 2386 | |
| 2317 | 2387 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 2318 | 2388 | |
| 2319 | 2389 | // it's to big for mb3? |
| 2320 | - if ($num > 0xFFFF && !$smcFunc['db_mb4']) |
|
| 2321 | - return $matches[0]; |
|
| 2322 | - else |
|
| 2323 | - return fixchar__callback($matches); |
|
| 2324 | -} |
|
| 2390 | + if ($num > 0xFFFF && !$smcFunc['db_mb4']) { |
|
| 2391 | + return $matches[0]; |
|
| 2392 | + } else { |
|
| 2393 | + return fixchar__callback($matches); |
|
| 2394 | + } |
|
| 2395 | + } |
|
| 2325 | 2396 | |
| 2326 | 2397 | ?> |
| 2327 | 2398 | \ No newline at end of file |
@@ -130,7 +130,6 @@ |
||
| 130 | 130 | * |
| 131 | 131 | * @param int $closed 1 for counting closed reports, 0 for open ones. |
| 132 | 132 | * @return integer How many reports. |
| 133 | - |
|
| 134 | 133 | */ |
| 135 | 134 | function countReports($closed = 0) |
| 136 | 135 | { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $smcFunc['db_query']('', ' |
| 50 | 50 | UPDATE {db_prefix}log_reported |
| 51 | 51 | SET {raw:action} = {string:value} |
| 52 | - '. (is_array($report_id) ? 'WHERE id_report IN ({array_int:id_report})' : 'WHERE id_report = {int:id_report}') .' |
|
| 52 | + '. (is_array($report_id) ? 'WHERE id_report IN ({array_int:id_report})' : 'WHERE id_report = {int:id_report}') . ' |
|
| 53 | 53 | ' . $board_query, |
| 54 | 54 | array( |
| 55 | 55 | 'action' => $action, |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | ) |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 100 | + while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 101 | 101 | $extra[$row['id_report']] = array( |
| 102 | 102 | 'report' => $row['id_report'], |
| 103 | 103 | 'member' => $row['id_member'], |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Updates a report with the given parameters. Logs each action via logAction() |
@@ -28,19 +29,20 @@ discard block |
||
| 28 | 29 | global $smcFunc, $user_info, $context; |
| 29 | 30 | |
| 30 | 31 | // Don't bother. |
| 31 | - if (empty($action) || empty($report_id)) |
|
| 32 | - return false; |
|
| 32 | + if (empty($action) || empty($report_id)) { |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | // Add the "_all" thingy. |
| 35 | - if ($action == 'ignore') |
|
| 36 | - $action = 'ignore_all'; |
|
| 37 | + if ($action == 'ignore') { |
|
| 38 | + $action = 'ignore_all'; |
|
| 39 | + } |
|
| 37 | 40 | |
| 38 | 41 | // We don't need the board query for reported members |
| 39 | 42 | if ($context['report_type'] == 'members') |
| 40 | 43 | { |
| 41 | 44 | $board_query = ''; |
| 42 | - } |
|
| 43 | - else |
|
| 45 | + } else |
|
| 44 | 46 | { |
| 45 | 47 | $board_query = ' AND ' . $user_info['mod_cache']['bq']; |
| 46 | 48 | } |
@@ -76,17 +78,17 @@ discard block |
||
| 76 | 78 | ) |
| 77 | 79 | ); |
| 78 | 80 | |
| 79 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 80 | - $extra[$row['id_report']] = array( |
|
| 81 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 82 | + $extra[$row['id_report']] = array( |
|
| 81 | 83 | 'report' => $row['id_report'], |
| 82 | 84 | 'board' => $row['id_board'], |
| 83 | 85 | 'message' => $row['id_msg'], |
| 84 | 86 | 'topic' => $row['id_topic'], |
| 85 | 87 | ); |
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $smcFunc['db_free_result']($request); |
| 88 | - } |
|
| 89 | - else |
|
| 91 | + } else |
|
| 90 | 92 | { |
| 91 | 93 | $request = $smcFunc['db_query']('', ' |
| 92 | 94 | SELECT id_report, id_member, membername |
@@ -97,28 +99,32 @@ discard block |
||
| 97 | 99 | ) |
| 98 | 100 | ); |
| 99 | 101 | |
| 100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 101 | - $extra[$row['id_report']] = array( |
|
| 102 | + while($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 103 | + $extra[$row['id_report']] = array( |
|
| 102 | 104 | 'report' => $row['id_report'], |
| 103 | 105 | 'member' => $row['id_member'], |
| 104 | 106 | ); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | $smcFunc['db_free_result']($request); |
| 107 | 110 | } |
| 108 | 111 | |
| 109 | 112 | // Back to "ignore". |
| 110 | - if ($action == 'ignore_all') |
|
| 111 | - $action = 'ignore'; |
|
| 113 | + if ($action == 'ignore_all') { |
|
| 114 | + $action = 'ignore'; |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | $log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open'); |
| 114 | 118 | |
| 115 | - if ($context['report_type'] == 'members') |
|
| 116 | - $log_report .= '_user'; |
|
| 119 | + if ($context['report_type'] == 'members') { |
|
| 120 | + $log_report .= '_user'; |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | // Log this action. |
| 119 | - if (!empty($extra)) |
|
| 120 | - foreach ($extra as $report) |
|
| 124 | + if (!empty($extra)) { |
|
| 125 | + foreach ($extra as $report) |
|
| 121 | 126 | logAction($log_report . '_report', $report); |
| 127 | + } |
|
| 122 | 128 | |
| 123 | 129 | // Time to update. |
| 124 | 130 | updateSettings(array('last_mod_report_action' => time())); |
@@ -140,14 +146,12 @@ discard block |
||
| 140 | 146 | if ($context['report_type'] == 'members') |
| 141 | 147 | { |
| 142 | 148 | $and = 'lr.id_board = 0'; |
| 143 | - } |
|
| 144 | - else |
|
| 149 | + } else |
|
| 145 | 150 | { |
| 146 | 151 | if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1') |
| 147 | 152 | { |
| 148 | 153 | $bq = $user_info['mod_cache']['bq']; |
| 149 | - } |
|
| 150 | - else |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | $bq = 'lr.' . $user_info['mod_cache']['bq']; |
| 153 | 157 | } |
@@ -203,8 +207,7 @@ discard block |
||
| 203 | 207 | 'max' => 10, |
| 204 | 208 | ) |
| 205 | 209 | ); |
| 206 | - } |
|
| 207 | - else |
|
| 210 | + } else |
|
| 208 | 211 | { |
| 209 | 212 | $request = $smcFunc['db_query']('', ' |
| 210 | 213 | SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body, |
@@ -252,8 +255,7 @@ discard block |
||
| 252 | 255 | 'href' => $scripturl . '?action=profile;u=' . $row['id_user'], |
| 253 | 256 | ), |
| 254 | 257 | ); |
| 255 | - } |
|
| 256 | - else |
|
| 258 | + } else |
|
| 257 | 259 | { |
| 258 | 260 | $report_boards_ids[] = $row['id_board']; |
| 259 | 261 | $extraDetails = array( |
@@ -293,14 +295,16 @@ discard block |
||
| 293 | 295 | ) |
| 294 | 296 | ); |
| 295 | 297 | |
| 296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 297 | - $board_names[$row['id_board']] = $row['name']; |
|
| 298 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 299 | + $board_names[$row['id_board']] = $row['name']; |
|
| 300 | + } |
|
| 298 | 301 | |
| 299 | 302 | $smcFunc['db_free_result']($request); |
| 300 | 303 | |
| 301 | - foreach ($reports as $id_report => $report) |
|
| 302 | - if (!empty($board_names[$report['topic']['id_board']])) |
|
| 304 | + foreach ($reports as $id_report => $report) { |
|
| 305 | + if (!empty($board_names[$report['topic']['id_board']])) |
|
| 303 | 306 | $reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']]; |
| 307 | + } |
|
| 304 | 308 | } |
| 305 | 309 | |
| 306 | 310 | // Now get all the people who reported it. |
@@ -350,10 +354,11 @@ discard block |
||
| 350 | 354 | { |
| 351 | 355 | global $user_info, $smcFunc; |
| 352 | 356 | |
| 353 | - if ($type == 'members') |
|
| 354 | - $bq = ''; |
|
| 355 | - else |
|
| 356 | - $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
| 357 | + if ($type == 'members') { |
|
| 358 | + $bq = ''; |
|
| 359 | + } else { |
|
| 360 | + $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
| 361 | + } |
|
| 357 | 362 | |
| 358 | 363 | $request = $smcFunc['db_query']('', ' |
| 359 | 364 | SELECT COUNT(*) |
@@ -392,8 +397,9 @@ discard block |
||
| 392 | 397 | { |
| 393 | 398 | global $smcFunc, $user_info, $context; |
| 394 | 399 | |
| 395 | - if (empty($report_id)) |
|
| 396 | - return false; |
|
| 400 | + if (empty($report_id)) { |
|
| 401 | + return false; |
|
| 402 | + } |
|
| 397 | 403 | |
| 398 | 404 | // We don't need all this info if we're only getting user info |
| 399 | 405 | if ($context['report_type'] == 'members') |
@@ -411,8 +417,7 @@ discard block |
||
| 411 | 417 | 'id_report' => $report_id, |
| 412 | 418 | ) |
| 413 | 419 | ); |
| 414 | - } |
|
| 415 | - else |
|
| 420 | + } else |
|
| 416 | 421 | { |
| 417 | 422 | // Get the report details, need this so we can limit access to a particular board. |
| 418 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -431,8 +436,9 @@ discard block |
||
| 431 | 436 | } |
| 432 | 437 | |
| 433 | 438 | // So did we find anything? |
| 434 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 435 | - return false; |
|
| 439 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 440 | + return false; |
|
| 441 | + } |
|
| 436 | 442 | |
| 437 | 443 | // Woohoo we found a report and they can see it! |
| 438 | 444 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -451,8 +457,9 @@ discard block |
||
| 451 | 457 | { |
| 452 | 458 | global $smcFunc, $scripturl, $user_info, $txt; |
| 453 | 459 | |
| 454 | - if (empty($report_id)) |
|
| 455 | - return false; |
|
| 460 | + if (empty($report_id)) { |
|
| 461 | + return false; |
|
| 462 | + } |
|
| 456 | 463 | |
| 457 | 464 | $report = array( |
| 458 | 465 | 'comments' => array(), |
@@ -533,8 +540,9 @@ discard block |
||
| 533 | 540 | { |
| 534 | 541 | global $smcFunc, $user_info; |
| 535 | 542 | |
| 536 | - if (empty($comment_id)) |
|
| 537 | - return false; |
|
| 543 | + if (empty($comment_id)) { |
|
| 544 | + return false; |
|
| 545 | + } |
|
| 538 | 546 | |
| 539 | 547 | $request = $smcFunc['db_query']('', ' |
| 540 | 548 | SELECT id_comment, id_notice, log_time, body, id_member |
@@ -551,8 +559,9 @@ discard block |
||
| 551 | 559 | $smcFunc['db_free_result']($request); |
| 552 | 560 | |
| 553 | 561 | // Add the permission |
| 554 | - if (!empty($comment)) |
|
| 555 | - $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
| 562 | + if (!empty($comment)) { |
|
| 563 | + $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
| 564 | + } |
|
| 556 | 565 | |
| 557 | 566 | return $comment; |
| 558 | 567 | } |
@@ -568,8 +577,9 @@ discard block |
||
| 568 | 577 | { |
| 569 | 578 | global $smcFunc, $user_info, $context; |
| 570 | 579 | |
| 571 | - if (empty($data)) |
|
| 572 | - return false; |
|
| 580 | + if (empty($data)) { |
|
| 581 | + return false; |
|
| 582 | + } |
|
| 573 | 583 | |
| 574 | 584 | $data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data); |
| 575 | 585 | |
@@ -598,8 +608,7 @@ discard block |
||
| 598 | 608 | 'comment_id' => $last_comment, |
| 599 | 609 | 'time' => time(), |
| 600 | 610 | ); |
| 601 | - } |
|
| 602 | - else |
|
| 611 | + } else |
|
| 603 | 612 | { |
| 604 | 613 | $prefix = 'Msg'; |
| 605 | 614 | $data = array( |
@@ -615,14 +624,15 @@ discard block |
||
| 615 | 624 | } |
| 616 | 625 | |
| 617 | 626 | // And get ready to notify people. |
| 618 | - if (!empty($report)) |
|
| 619 | - $smcFunc['db_insert']('insert', |
|
| 627 | + if (!empty($report)) { |
|
| 628 | + $smcFunc['db_insert']('insert', |
|
| 620 | 629 | '{db_prefix}background_tasks', |
| 621 | 630 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 622 | 631 | array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', $smcFunc['json_encode']($data), 0), |
| 623 | 632 | array('id_task') |
| 624 | 633 | ); |
| 625 | -} |
|
| 634 | + } |
|
| 635 | + } |
|
| 626 | 636 | |
| 627 | 637 | /** |
| 628 | 638 | * Saves the new information whenever a moderator comment is edited. |
@@ -635,8 +645,9 @@ discard block |
||
| 635 | 645 | { |
| 636 | 646 | global $smcFunc; |
| 637 | 647 | |
| 638 | - if (empty($comment_id) || empty($edited_comment)) |
|
| 639 | - return false; |
|
| 648 | + if (empty($comment_id) || empty($edited_comment)) { |
|
| 649 | + return false; |
|
| 650 | + } |
|
| 640 | 651 | |
| 641 | 652 | $smcFunc['db_query']('', ' |
| 642 | 653 | UPDATE {db_prefix}log_comments |
@@ -659,8 +670,9 @@ discard block |
||
| 659 | 670 | { |
| 660 | 671 | global $smcFunc; |
| 661 | 672 | |
| 662 | - if (empty($comment_id)) |
|
| 663 | - return false; |
|
| 673 | + if (empty($comment_id)) { |
|
| 674 | + return false; |
|
| 675 | + } |
|
| 664 | 676 | |
| 665 | 677 | $smcFunc['db_query']('', ' |
| 666 | 678 | DELETE FROM {db_prefix}log_comments |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param integer $value The new value to update. |
| 24 | 24 | * @param integer|array $report_id The affected report(s). |
| 25 | 25 | * |
| 26 | - * @return bool |
|
| 26 | + * @return false|null |
|
| 27 | 27 | */ |
| 28 | 28 | function updateReport($action, $value, $report_id) |
| 29 | 29 | { |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * |
| 565 | 565 | * @param int $report_id The report ID is used to fire a notification about the event. |
| 566 | 566 | * @param array $data a formatted array of data to be inserted. Should be already properly sanitized. |
| 567 | - * @return bool Boolean false if no data was provided. |
|
| 567 | + * @return false|null Boolean false if no data was provided. |
|
| 568 | 568 | */ |
| 569 | 569 | function saveModComment($report_id, $data) |
| 570 | 570 | { |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | * Deletes a moderator comment from the DB. |
| 657 | 657 | * |
| 658 | 658 | * @param int $comment_id The moderator comment ID used to identify which report will be deleted. |
| 659 | - * @return bool Boolean false if no data was provided. |
|
| 659 | + * @return false|null Boolean false if no data was provided. |
|
| 660 | 660 | */ |
| 661 | 661 | function deleteModComment($comment_id) |
| 662 | 662 | { |