@@ -66,26 +66,31 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function checkRequest() |
| 68 | 68 | { |
| 69 | - if (!$this->enabled) |
|
| 70 | - return false; |
|
| 69 | + if (!$this->enabled) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 71 | 72 | |
| 72 | 73 | // Try to create the image cache directory if it doesn't exist |
| 73 | - if (!file_exists($this->cache)) |
|
| 74 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
| 74 | + if (!file_exists($this->cache)) { |
|
| 75 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
| 75 | 76 | return false; |
| 77 | + } |
|
| 76 | 78 | |
| 77 | - if (empty($_GET['hash']) || empty($_GET['request'])) |
|
| 78 | - return false; |
|
| 79 | + if (empty($_GET['hash']) || empty($_GET['request'])) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 79 | 82 | |
| 80 | 83 | $hash = $_GET['hash']; |
| 81 | 84 | $request = $_GET['request']; |
| 82 | 85 | |
| 83 | - if (md5($request . $this->secret) != $hash) |
|
| 84 | - return false; |
|
| 86 | + if (md5($request . $this->secret) != $hash) { |
|
| 87 | + return false; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | // Attempt to cache the request if it doesn't exist |
| 87 | - if (!$this->isCached($request)) |
|
| 88 | - return $this->cacheImage($request); |
|
| 91 | + if (!$this->isCached($request)) { |
|
| 92 | + return $this->cacheImage($request); |
|
| 93 | + } |
|
| 89 | 94 | |
| 90 | 95 | return true; |
| 91 | 96 | } |
@@ -106,15 +111,17 @@ discard block |
||
| 106 | 111 | if (!$cached || time() - $cached['time'] > (5 * 86400)) |
| 107 | 112 | { |
| 108 | 113 | @unlink($cached_file); |
| 109 | - if ($this->checkRequest()) |
|
| 110 | - $this->serve(); |
|
| 114 | + if ($this->checkRequest()) { |
|
| 115 | + $this->serve(); |
|
| 116 | + } |
|
| 111 | 117 | exit; |
| 112 | 118 | } |
| 113 | 119 | |
| 114 | 120 | // Make sure we're serving an image |
| 115 | 121 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
| 116 | - if ($contentParts[0] != 'image') |
|
| 117 | - exit; |
|
| 122 | + if ($contentParts[0] != 'image') { |
|
| 123 | + exit; |
|
| 124 | + } |
|
| 118 | 125 | |
| 119 | 126 | header('Content-type: ' . $cached['content_type']); |
| 120 | 127 | header('Content-length: ' . $cached['size']); |
@@ -160,19 +167,22 @@ discard block |
||
| 160 | 167 | $request = $curl->get_url_data($request); |
| 161 | 168 | $response = $request->result(); |
| 162 | 169 | |
| 163 | - if (empty($response)) |
|
| 164 | - return false; |
|
| 170 | + if (empty($response)) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 165 | 173 | |
| 166 | 174 | $headers = $response['headers']; |
| 167 | 175 | |
| 168 | 176 | // Make sure the url is returning an image |
| 169 | 177 | $contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : ''); |
| 170 | - if ($contentParts[0] != 'image') |
|
| 171 | - return false; |
|
| 178 | + if ($contentParts[0] != 'image') { |
|
| 179 | + return false; |
|
| 180 | + } |
|
| 172 | 181 | |
| 173 | 182 | // Validate the filesize |
| 174 | - if ($response['size'] > ($this->maxSize * 1024)) |
|
| 175 | - return false; |
|
| 183 | + if ($response['size'] > ($this->maxSize * 1024)) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 176 | 186 | |
| 177 | 187 | return file_put_contents($dest, json_encode(array( |
| 178 | 188 | 'content_type' => $headers['content-type'], |
@@ -184,7 +194,8 @@ discard block |
||
| 184 | 194 | } |
| 185 | 195 | |
| 186 | 196 | $proxy = new ProxyServer(); |
| 187 | -if ($proxy->checkRequest()) |
|
| 197 | +if ($proxy->checkRequest()) { |
|
| 188 | 198 | $proxy->serve(); |
| 199 | +} |
|
| 189 | 200 | |
| 190 | 201 | exit; |
@@ -583,8 +583,7 @@ discard block |
||
| 583 | 583 | { |
| 584 | 584 | $header = '<?php require("' . ($user_info['is_admin'] ? addslashes(realpath($boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header; |
| 585 | 585 | return $header . template_homepage_sample1_html() . $footer; |
| 586 | - } |
|
| 587 | - else |
|
| 586 | + } else |
|
| 588 | 587 | { |
| 589 | 588 | echo $header; |
| 590 | 589 | template_homepage_sample1_php(); |
@@ -599,9 +598,10 @@ discard block |
||
| 599 | 598 | |
| 600 | 599 | $topics = ssi_recentTopics(8, null, null, 'array'); |
| 601 | 600 | |
| 602 | - foreach ($topics as $topic) |
|
| 603 | - echo ' |
|
| 601 | + foreach ($topics as $topic) { |
|
| 602 | + echo ' |
|
| 604 | 603 | <li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], '</li>'; |
| 604 | + } |
|
| 605 | 605 | |
| 606 | 606 | unset($topics); |
| 607 | 607 | |
@@ -186,8 +186,9 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | ########## Error-Catching ########## |
| 188 | 188 | # Note: You shouldn't touch these settings. |
| 189 | -if (file_exists(dirname(__FILE__) . '/db_last_error.php')) |
|
| 189 | +if (file_exists(dirname(__FILE__) . '/db_last_error.php')) { |
|
| 190 | 190 | include(dirname(__FILE__) . '/db_last_error.php'); |
| 191 | +} |
|
| 191 | 192 | |
| 192 | 193 | if (!isset($db_last_error)) |
| 193 | 194 | { |
@@ -202,11 +203,14 @@ discard block |
||
| 202 | 203 | } |
| 203 | 204 | |
| 204 | 205 | # Make sure the paths are correct... at least try to fix them. |
| 205 | -if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) |
|
| 206 | +if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) { |
|
| 206 | 207 | $boarddir = dirname(__FILE__); |
| 207 | -if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) |
|
| 208 | +} |
|
| 209 | +if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) { |
|
| 208 | 210 | $sourcedir = $boarddir . '/Sources'; |
| 209 | -if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) |
|
| 211 | +} |
|
| 212 | +if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) { |
|
| 210 | 213 | $cachedir = $boarddir . '/cache'; |
| 214 | +} |
|
| 211 | 215 | |
| 212 | 216 | ?> |
| 213 | 217 | \ No newline at end of file |
@@ -78,11 +78,14 @@ discard block |
||
| 78 | 78 | ini_set('default_socket_timeout', 900); |
| 79 | 79 | } |
| 80 | 80 | // Clean the upgrade path if this is from the client. |
| 81 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 82 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 81 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 82 | + for ($i = 1; |
|
| 83 | +} |
|
| 84 | +$i < $_SERVER['argc']; $i++) |
|
| 83 | 85 | { |
| 84 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 85 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 86 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 87 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 88 | + } |
|
| 86 | 89 | } |
| 87 | 90 | |
| 88 | 91 | // Are we from the client? |
@@ -90,9 +93,9 @@ discard block |
||
| 90 | 93 | { |
| 91 | 94 | $command_line = true; |
| 92 | 95 | $disable_security = 1; |
| 93 | -} |
|
| 94 | -else |
|
| 96 | +} else { |
|
| 95 | 97 | $command_line = false; |
| 98 | +} |
|
| 96 | 99 | |
| 97 | 100 | // Load this now just because we can. |
| 98 | 101 | require_once($upgrade_path . '/Settings.php'); |
@@ -103,10 +106,12 @@ discard block |
||
| 103 | 106 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
| 104 | 107 | |
| 105 | 108 | // Check for sensible values. |
| 106 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 107 | - $upcontext['user']['started'] = time(); |
|
| 108 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 109 | - $upcontext['user']['updated'] = 0; |
|
| 109 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 110 | + $upcontext['user']['started'] = time(); |
|
| 111 | + } |
|
| 112 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 113 | + $upcontext['user']['updated'] = 0; |
|
| 114 | + } |
|
| 110 | 115 | |
| 111 | 116 | $upcontext['started'] = $upcontext['user']['started']; |
| 112 | 117 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -169,8 +174,9 @@ discard block |
||
| 169 | 174 | { |
| 170 | 175 | $word = trim($word, '-_\''); |
| 171 | 176 | |
| 172 | - if ($word != '') |
|
| 173 | - $returned_words[] = substr($word, 0, 20); |
|
| 177 | + if ($word != '') { |
|
| 178 | + $returned_words[] = substr($word, 0, 20); |
|
| 179 | + } |
|
| 174 | 180 | } |
| 175 | 181 | |
| 176 | 182 | return array_unique($returned_words); |
@@ -185,15 +191,17 @@ discard block |
||
| 185 | 191 | global $cachedir, $sourcedir; |
| 186 | 192 | |
| 187 | 193 | // No directory = no game. |
| 188 | - if (!is_dir($cachedir)) |
|
| 189 | - return; |
|
| 194 | + if (!is_dir($cachedir)) { |
|
| 195 | + return; |
|
| 196 | + } |
|
| 190 | 197 | |
| 191 | 198 | // Remove the files in SMF's own disk cache, if any |
| 192 | 199 | $dh = opendir($cachedir); |
| 193 | 200 | while ($file = readdir($dh)) |
| 194 | 201 | { |
| 195 | - if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) |
|
| 196 | - @unlink($cachedir . '/' . $file); |
|
| 202 | + if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) { |
|
| 203 | + @unlink($cachedir . '/' . $file); |
|
| 204 | + } |
|
| 197 | 205 | } |
| 198 | 206 | closedir($dh); |
| 199 | 207 | |
@@ -209,8 +217,9 @@ discard block |
||
| 209 | 217 | { |
| 210 | 218 | function md5_hmac($data, $key) |
| 211 | 219 | { |
| 212 | - if (strlen($key) > 64) |
|
| 213 | - $key = pack('H*', md5($key)); |
|
| 220 | + if (strlen($key) > 64) { |
|
| 221 | + $key = pack('H*', md5($key)); |
|
| 222 | + } |
|
| 214 | 223 | $key = str_pad($key, 64, chr(0x00)); |
| 215 | 224 | |
| 216 | 225 | $k_ipad = $key ^ str_repeat(chr(0x36), 64); |
@@ -221,8 +230,9 @@ discard block |
||
| 221 | 230 | } |
| 222 | 231 | |
| 223 | 232 | // Don't do security check if on Yabbse |
| 224 | -if (!isset($modSettings['smfVersion'])) |
|
| 233 | +if (!isset($modSettings['smfVersion'])) { |
|
| 225 | 234 | $disable_security = true; |
| 235 | +} |
|
| 226 | 236 | |
| 227 | 237 | // This only exists if we're on SMF ;) |
| 228 | 238 | if (isset($modSettings['smfVersion'])) |
@@ -240,8 +250,9 @@ discard block |
||
| 240 | 250 | 'db_error_skip' => true, |
| 241 | 251 | ) |
| 242 | 252 | ); |
| 243 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 244 | - $modSettings[$row['variable']] = $row['value']; |
|
| 253 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 254 | + $modSettings[$row['variable']] = $row['value']; |
|
| 255 | + } |
|
| 245 | 256 | $smcFunc['db_free_result']($request); |
| 246 | 257 | } |
| 247 | 258 | |
@@ -251,10 +262,12 @@ discard block |
||
| 251 | 262 | $modSettings['theme_url'] = 'Themes/default'; |
| 252 | 263 | $modSettings['images_url'] = 'Themes/default/images'; |
| 253 | 264 | } |
| 254 | -if (!isset($settings['default_theme_url'])) |
|
| 265 | +if (!isset($settings['default_theme_url'])) { |
|
| 255 | 266 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 256 | -if (!isset($settings['default_theme_dir'])) |
|
| 267 | +} |
|
| 268 | +if (!isset($settings['default_theme_dir'])) { |
|
| 257 | 269 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 270 | +} |
|
| 258 | 271 | |
| 259 | 272 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 260 | 273 | // Default title... |
@@ -272,13 +285,15 @@ discard block |
||
| 272 | 285 | $support_js = $upcontext['upgrade_status']['js']; |
| 273 | 286 | |
| 274 | 287 | // Only set this if the upgrader status says so. |
| 275 | - if (empty($is_debug)) |
|
| 276 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 288 | + if (empty($is_debug)) { |
|
| 289 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 290 | + } |
|
| 277 | 291 | |
| 278 | 292 | // Load the language. |
| 279 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 280 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 281 | -} |
|
| 293 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 294 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 295 | + } |
|
| 296 | + } |
|
| 282 | 297 | // Set the defaults. |
| 283 | 298 | else |
| 284 | 299 | { |
@@ -296,15 +311,18 @@ discard block |
||
| 296 | 311 | } |
| 297 | 312 | |
| 298 | 313 | // If this isn't the first stage see whether they are logging in and resuming. |
| 299 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 314 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 300 | 315 | checkLogin(); |
| 316 | +} |
|
| 301 | 317 | |
| 302 | -if ($command_line) |
|
| 318 | +if ($command_line) { |
|
| 303 | 319 | cmdStep0(); |
| 320 | +} |
|
| 304 | 321 | |
| 305 | 322 | // Don't error if we're using xml. |
| 306 | -if (isset($_GET['xml'])) |
|
| 323 | +if (isset($_GET['xml'])) { |
|
| 307 | 324 | $upcontext['return_error'] = true; |
| 325 | +} |
|
| 308 | 326 | |
| 309 | 327 | // Loop through all the steps doing each one as required. |
| 310 | 328 | $upcontext['overall_percent'] = 0; |
@@ -325,10 +343,11 @@ discard block |
||
| 325 | 343 | } |
| 326 | 344 | |
| 327 | 345 | // Call the step and if it returns false that means pause! |
| 328 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 329 | - break; |
|
| 330 | - elseif (function_exists($step[2])) |
|
| 331 | - $upcontext['current_step']++; |
|
| 346 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 347 | + break; |
|
| 348 | + } elseif (function_exists($step[2])) { |
|
| 349 | + $upcontext['current_step']++; |
|
| 350 | + } |
|
| 332 | 351 | } |
| 333 | 352 | $upcontext['overall_percent'] += $step[3]; |
| 334 | 353 | } |
@@ -367,17 +386,18 @@ discard block |
||
| 367 | 386 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 368 | 387 | if (!empty($command_line)) |
| 369 | 388 | { |
| 370 | - if (function_exists('debug_print_backtrace')) |
|
| 371 | - debug_print_backtrace(); |
|
| 389 | + if (function_exists('debug_print_backtrace')) { |
|
| 390 | + debug_print_backtrace(); |
|
| 391 | + } |
|
| 372 | 392 | |
| 373 | 393 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 374 | 394 | flush(); |
| 375 | 395 | die(); |
| 376 | 396 | } |
| 377 | 397 | |
| 378 | - if (!isset($_GET['xml'])) |
|
| 379 | - template_upgrade_above(); |
|
| 380 | - else |
|
| 398 | + if (!isset($_GET['xml'])) { |
|
| 399 | + template_upgrade_above(); |
|
| 400 | + } else |
|
| 381 | 401 | { |
| 382 | 402 | header('Content-Type: text/xml; charset=UTF-8'); |
| 383 | 403 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -399,21 +419,24 @@ discard block |
||
| 399 | 419 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
| 400 | 420 | |
| 401 | 421 | // Custom stuff to pass back? |
| 402 | - if (!empty($upcontext['query_string'])) |
|
| 403 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 422 | + if (!empty($upcontext['query_string'])) { |
|
| 423 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 424 | + } |
|
| 404 | 425 | |
| 405 | 426 | call_user_func('template_' . $upcontext['sub_template']); |
| 406 | 427 | } |
| 407 | 428 | |
| 408 | 429 | // Was there an error? |
| 409 | - if (!empty($upcontext['forced_error_message'])) |
|
| 410 | - echo $upcontext['forced_error_message']; |
|
| 430 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 431 | + echo $upcontext['forced_error_message']; |
|
| 432 | + } |
|
| 411 | 433 | |
| 412 | 434 | // Show the footer. |
| 413 | - if (!isset($_GET['xml'])) |
|
| 414 | - template_upgrade_below(); |
|
| 415 | - else |
|
| 416 | - template_xml_below(); |
|
| 435 | + if (!isset($_GET['xml'])) { |
|
| 436 | + template_upgrade_below(); |
|
| 437 | + } else { |
|
| 438 | + template_xml_below(); |
|
| 439 | + } |
|
| 417 | 440 | } |
| 418 | 441 | |
| 419 | 442 | |
@@ -425,15 +448,19 @@ discard block |
||
| 425 | 448 | $seconds = intval($active % 60); |
| 426 | 449 | |
| 427 | 450 | $totalTime = ''; |
| 428 | - if ($hours > 0) |
|
| 429 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 430 | - if ($minutes > 0) |
|
| 431 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 432 | - if ($seconds > 0) |
|
| 433 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 451 | + if ($hours > 0) { |
|
| 452 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 453 | + } |
|
| 454 | + if ($minutes > 0) { |
|
| 455 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 456 | + } |
|
| 457 | + if ($seconds > 0) { |
|
| 458 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 459 | + } |
|
| 434 | 460 | |
| 435 | - if (!empty($totalTime)) |
|
| 436 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 461 | + if (!empty($totalTime)) { |
|
| 462 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 463 | + } |
|
| 437 | 464 | } |
| 438 | 465 | |
| 439 | 466 | // Bang - gone! |
@@ -446,8 +473,9 @@ discard block |
||
| 446 | 473 | global $upgradeurl, $upcontext, $command_line; |
| 447 | 474 | |
| 448 | 475 | // Command line users can't be redirected. |
| 449 | - if ($command_line) |
|
| 450 | - upgradeExit(true); |
|
| 476 | + if ($command_line) { |
|
| 477 | + upgradeExit(true); |
|
| 478 | + } |
|
| 451 | 479 | |
| 452 | 480 | // Are we providing the core info? |
| 453 | 481 | if ($addForm) |
@@ -470,19 +498,22 @@ discard block |
||
| 470 | 498 | global $modSettings, $sourcedir, $smcFunc; |
| 471 | 499 | |
| 472 | 500 | // Do the non-SSI stuff... |
| 473 | - if (function_exists('set_magic_quotes_runtime')) |
|
| 474 | - @set_magic_quotes_runtime(0); |
|
| 501 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 502 | + @set_magic_quotes_runtime(0); |
|
| 503 | + } |
|
| 475 | 504 | |
| 476 | 505 | error_reporting(E_ALL); |
| 477 | 506 | define('SMF', 1); |
| 478 | 507 | |
| 479 | 508 | // Start the session. |
| 480 | - if (@ini_get('session.save_handler') == 'user') |
|
| 481 | - @ini_set('session.save_handler', 'files'); |
|
| 509 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 510 | + @ini_set('session.save_handler', 'files'); |
|
| 511 | + } |
|
| 482 | 512 | @session_start(); |
| 483 | 513 | |
| 484 | - if (empty($smcFunc)) |
|
| 485 | - $smcFunc = array(); |
|
| 514 | + if (empty($smcFunc)) { |
|
| 515 | + $smcFunc = array(); |
|
| 516 | + } |
|
| 486 | 517 | |
| 487 | 518 | // We need this for authentication and some upgrade code |
| 488 | 519 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -495,8 +526,9 @@ discard block |
||
| 495 | 526 | initialize_inputs(); |
| 496 | 527 | |
| 497 | 528 | // Get the database going! |
| 498 | - if (empty($db_type)) |
|
| 499 | - $db_type = 'mysql'; |
|
| 529 | + if (empty($db_type)) { |
|
| 530 | + $db_type = 'mysql'; |
|
| 531 | + } |
|
| 500 | 532 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 501 | 533 | { |
| 502 | 534 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -505,17 +537,19 @@ discard block |
||
| 505 | 537 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
| 506 | 538 | |
| 507 | 539 | // Oh dear god!! |
| 508 | - if ($db_connection === null) |
|
| 509 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 540 | + if ($db_connection === null) { |
|
| 541 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 542 | + } |
|
| 510 | 543 | |
| 511 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 512 | - $smcFunc['db_query']('', ' |
|
| 544 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 545 | + $smcFunc['db_query']('', ' |
|
| 513 | 546 | SET NAMES {string:db_character_set}', |
| 514 | 547 | array( |
| 515 | 548 | 'db_error_skip' => true, |
| 516 | 549 | 'db_character_set' => $db_character_set, |
| 517 | 550 | ) |
| 518 | 551 | ); |
| 552 | + } |
|
| 519 | 553 | |
| 520 | 554 | // Load the modSettings data... |
| 521 | 555 | $request = $smcFunc['db_query']('', ' |
@@ -526,11 +560,11 @@ discard block |
||
| 526 | 560 | ) |
| 527 | 561 | ); |
| 528 | 562 | $modSettings = array(); |
| 529 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 530 | - $modSettings[$row['variable']] = $row['value']; |
|
| 563 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 564 | + $modSettings[$row['variable']] = $row['value']; |
|
| 565 | + } |
|
| 531 | 566 | $smcFunc['db_free_result']($request); |
| 532 | - } |
|
| 533 | - else |
|
| 567 | + } else |
|
| 534 | 568 | { |
| 535 | 569 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 536 | 570 | } |
@@ -544,9 +578,10 @@ discard block |
||
| 544 | 578 | cleanRequest(); |
| 545 | 579 | } |
| 546 | 580 | |
| 547 | - if (!isset($_GET['substep'])) |
|
| 548 | - $_GET['substep'] = 0; |
|
| 549 | -} |
|
| 581 | + if (!isset($_GET['substep'])) { |
|
| 582 | + $_GET['substep'] = 0; |
|
| 583 | + } |
|
| 584 | + } |
|
| 550 | 585 | |
| 551 | 586 | function initialize_inputs() |
| 552 | 587 | { |
@@ -584,8 +619,9 @@ discard block |
||
| 584 | 619 | $dh = opendir(dirname(__FILE__)); |
| 585 | 620 | while ($file = readdir($dh)) |
| 586 | 621 | { |
| 587 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 588 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 622 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 623 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 624 | + } |
|
| 589 | 625 | } |
| 590 | 626 | closedir($dh); |
| 591 | 627 | |
@@ -615,8 +651,9 @@ discard block |
||
| 615 | 651 | { |
| 616 | 652 | $upcontext['remote_files_available'] = false; |
| 617 | 653 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
| 618 | - if ($test) |
|
| 619 | - $upcontext['remote_files_available'] = true; |
|
| 654 | + if ($test) { |
|
| 655 | + $upcontext['remote_files_available'] = true; |
|
| 656 | + } |
|
| 620 | 657 | @fclose($test); |
| 621 | 658 | } |
| 622 | 659 | |
@@ -624,8 +661,9 @@ discard block |
||
| 624 | 661 | $temp = 'upgrade_php?step'; |
| 625 | 662 | while (strlen($temp) > 4) |
| 626 | 663 | { |
| 627 | - if (isset($_GET[$temp])) |
|
| 628 | - unset($_GET[$temp]); |
|
| 664 | + if (isset($_GET[$temp])) { |
|
| 665 | + unset($_GET[$temp]); |
|
| 666 | + } |
|
| 629 | 667 | $temp = substr($temp, 1); |
| 630 | 668 | } |
| 631 | 669 | |
@@ -651,29 +689,36 @@ discard block |
||
| 651 | 689 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql'); |
| 652 | 690 | |
| 653 | 691 | // Need legacy scripts? |
| 654 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 655 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 656 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 657 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 658 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 659 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 692 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 693 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 694 | + } |
|
| 695 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 696 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 697 | + } |
|
| 698 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 699 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 700 | + } |
|
| 660 | 701 | |
| 661 | 702 | // This needs to exist! |
| 662 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 663 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 664 | - else |
|
| 665 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 703 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 704 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 705 | + } else { |
|
| 706 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 707 | + } |
|
| 666 | 708 | |
| 667 | - if (!$check) |
|
| 668 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 709 | + if (!$check) { |
|
| 710 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 669 | 711 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 712 | + } |
|
| 670 | 713 | |
| 671 | 714 | // Do they meet the install requirements? |
| 672 | - if (!php_version_check()) |
|
| 673 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 715 | + if (!php_version_check()) { |
|
| 716 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 717 | + } |
|
| 674 | 718 | |
| 675 | - if (!db_version_check()) |
|
| 676 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 719 | + if (!db_version_check()) { |
|
| 720 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 721 | + } |
|
| 677 | 722 | |
| 678 | 723 | // Do some checks to make sure they have proper privileges |
| 679 | 724 | db_extend('packages'); |
@@ -688,14 +733,16 @@ discard block |
||
| 688 | 733 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 689 | 734 | |
| 690 | 735 | // Sorry... we need CREATE, ALTER and DROP |
| 691 | - if (!$create || !$alter || !$drop) |
|
| 692 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 736 | + if (!$create || !$alter || !$drop) { |
|
| 737 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 738 | + } |
|
| 693 | 739 | |
| 694 | 740 | // Do a quick version spot check. |
| 695 | 741 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 696 | 742 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 697 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 698 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 743 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 744 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 745 | + } |
|
| 699 | 746 | |
| 700 | 747 | // What absolutely needs to be writable? |
| 701 | 748 | $writable_files = array( |
@@ -717,12 +764,13 @@ discard block |
||
| 717 | 764 | quickFileWritable($custom_av_dir); |
| 718 | 765 | |
| 719 | 766 | // Are we good now? |
| 720 | - if(!is_writable($custom_av_dir)) |
|
| 721 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 722 | - elseif ($need_settings_update) |
|
| 767 | + if(!is_writable($custom_av_dir)) { |
|
| 768 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 769 | + } elseif ($need_settings_update) |
|
| 723 | 770 | { |
| 724 | - if (!function_exists('cache_put_data')) |
|
| 725 | - require_once($sourcedir . '/Load.php'); |
|
| 771 | + if (!function_exists('cache_put_data')) { |
|
| 772 | + require_once($sourcedir . '/Load.php'); |
|
| 773 | + } |
|
| 726 | 774 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 727 | 775 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 728 | 776 | } |
@@ -731,28 +779,33 @@ discard block |
||
| 731 | 779 | |
| 732 | 780 | // Check the cache directory. |
| 733 | 781 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 734 | - if (!file_exists($cachedir_temp)) |
|
| 735 | - @mkdir($cachedir_temp); |
|
| 736 | - if (!file_exists($cachedir_temp)) |
|
| 737 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 738 | - |
|
| 739 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 740 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 741 | - elseif (!isset($_GET['skiplang'])) |
|
| 782 | + if (!file_exists($cachedir_temp)) { |
|
| 783 | + @mkdir($cachedir_temp); |
|
| 784 | + } |
|
| 785 | + if (!file_exists($cachedir_temp)) { |
|
| 786 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 790 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 791 | + } elseif (!isset($_GET['skiplang'])) |
|
| 742 | 792 | { |
| 743 | 793 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 744 | 794 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 745 | 795 | |
| 746 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 747 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 796 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 797 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 798 | + } |
|
| 748 | 799 | } |
| 749 | 800 | |
| 750 | - if (!makeFilesWritable($writable_files)) |
|
| 751 | - return false; |
|
| 801 | + if (!makeFilesWritable($writable_files)) { |
|
| 802 | + return false; |
|
| 803 | + } |
|
| 752 | 804 | |
| 753 | 805 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 754 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 755 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 806 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 807 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 808 | + } |
|
| 756 | 809 | |
| 757 | 810 | // Upgrade the agreement. |
| 758 | 811 | elseif (isset($modSettings['agreement'])) |
@@ -763,8 +816,8 @@ discard block |
||
| 763 | 816 | } |
| 764 | 817 | |
| 765 | 818 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 766 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 767 | - $upcontext['warning'] = ' |
|
| 819 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 820 | + $upcontext['warning'] = ' |
|
| 768 | 821 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 769 | 822 | <ul> |
| 770 | 823 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -772,10 +825,12 @@ discard block |
||
| 772 | 825 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 773 | 826 | </ul> |
| 774 | 827 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 828 | + } |
|
| 775 | 829 | |
| 776 | 830 | // Either we're logged in or we're going to present the login. |
| 777 | - if (checkLogin()) |
|
| 778 | - return true; |
|
| 831 | + if (checkLogin()) { |
|
| 832 | + return true; |
|
| 833 | + } |
|
| 779 | 834 | |
| 780 | 835 | $upcontext += createToken('login'); |
| 781 | 836 | |
@@ -792,8 +847,9 @@ discard block |
||
| 792 | 847 | if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security)) |
| 793 | 848 | { |
| 794 | 849 | // If we've disabled security pick a suitable name! |
| 795 | - if (empty($_POST['user'])) |
|
| 796 | - $_POST['user'] = 'Administrator'; |
|
| 850 | + if (empty($_POST['user'])) { |
|
| 851 | + $_POST['user'] = 'Administrator'; |
|
| 852 | + } |
|
| 797 | 853 | |
| 798 | 854 | // Before 2.0 these column names were different! |
| 799 | 855 | $oldDB = false; |
@@ -808,16 +864,17 @@ discard block |
||
| 808 | 864 | 'db_error_skip' => true, |
| 809 | 865 | ) |
| 810 | 866 | ); |
| 811 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 812 | - $oldDB = true; |
|
| 867 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 868 | + $oldDB = true; |
|
| 869 | + } |
|
| 813 | 870 | $smcFunc['db_free_result']($request); |
| 814 | 871 | } |
| 815 | 872 | |
| 816 | 873 | // Get what we believe to be their details. |
| 817 | 874 | if (!$disable_security) |
| 818 | 875 | { |
| 819 | - if ($oldDB) |
|
| 820 | - $request = $smcFunc['db_query']('', ' |
|
| 876 | + if ($oldDB) { |
|
| 877 | + $request = $smcFunc['db_query']('', ' |
|
| 821 | 878 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 822 | 879 | additionalGroups AS additional_groups, lngfile |
| 823 | 880 | FROM {db_prefix}members |
@@ -827,8 +884,8 @@ discard block |
||
| 827 | 884 | 'db_error_skip' => true, |
| 828 | 885 | ) |
| 829 | 886 | ); |
| 830 | - else |
|
| 831 | - $request = $smcFunc['db_query']('', ' |
|
| 887 | + } else { |
|
| 888 | + $request = $smcFunc['db_query']('', ' |
|
| 832 | 889 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 833 | 890 | FROM {db_prefix}members |
| 834 | 891 | WHERE member_name = {string:member_name}', |
@@ -837,6 +894,7 @@ discard block |
||
| 837 | 894 | 'db_error_skip' => true, |
| 838 | 895 | ) |
| 839 | 896 | ); |
| 897 | + } |
|
| 840 | 898 | if ($smcFunc['db_num_rows']($request) != 0) |
| 841 | 899 | { |
| 842 | 900 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -844,13 +902,14 @@ discard block |
||
| 844 | 902 | $groups = explode(',', $addGroups); |
| 845 | 903 | $groups[] = $id_group; |
| 846 | 904 | |
| 847 | - foreach ($groups as $k => $v) |
|
| 848 | - $groups[$k] = (int) $v; |
|
| 905 | + foreach ($groups as $k => $v) { |
|
| 906 | + $groups[$k] = (int) $v; |
|
| 907 | + } |
|
| 849 | 908 | |
| 850 | 909 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 910 | + } else { |
|
| 911 | + $upcontext['username_incorrect'] = true; |
|
| 851 | 912 | } |
| 852 | - else |
|
| 853 | - $upcontext['username_incorrect'] = true; |
|
| 854 | 913 | $smcFunc['db_free_result']($request); |
| 855 | 914 | } |
| 856 | 915 | $upcontext['username'] = $_POST['user']; |
@@ -860,13 +919,14 @@ discard block |
||
| 860 | 919 | { |
| 861 | 920 | $upcontext['upgrade_status']['js'] = 1; |
| 862 | 921 | $support_js = 1; |
| 922 | + } else { |
|
| 923 | + $support_js = 0; |
|
| 863 | 924 | } |
| 864 | - else |
|
| 865 | - $support_js = 0; |
|
| 866 | 925 | |
| 867 | 926 | // Note down the version we are coming from. |
| 868 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 869 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 927 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 928 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 929 | + } |
|
| 870 | 930 | |
| 871 | 931 | // Didn't get anywhere? |
| 872 | 932 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -900,15 +960,15 @@ discard block |
||
| 900 | 960 | 'db_error_skip' => true, |
| 901 | 961 | ) |
| 902 | 962 | ); |
| 903 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 904 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 963 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 964 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 965 | + } |
|
| 905 | 966 | $smcFunc['db_free_result']($request); |
| 906 | 967 | } |
| 907 | 968 | |
| 908 | 969 | $upcontext['user']['id'] = $id_member; |
| 909 | 970 | $upcontext['user']['name'] = $name; |
| 910 | - } |
|
| 911 | - else |
|
| 971 | + } else |
|
| 912 | 972 | { |
| 913 | 973 | $upcontext['user']['id'] = 1; |
| 914 | 974 | $upcontext['user']['name'] = 'Administrator'; |
@@ -924,11 +984,11 @@ discard block |
||
| 924 | 984 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 925 | 985 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 926 | 986 | |
| 927 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 928 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 929 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 930 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 931 | - else |
|
| 987 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 988 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 989 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 990 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 991 | + } else |
|
| 932 | 992 | { |
| 933 | 993 | // Set this as the new language. |
| 934 | 994 | $upcontext['language'] = $user_language; |
@@ -972,8 +1032,9 @@ discard block |
||
| 972 | 1032 | unset($member_columns); |
| 973 | 1033 | |
| 974 | 1034 | // If we've not submitted then we're done. |
| 975 | - if (empty($_POST['upcont'])) |
|
| 976 | - return false; |
|
| 1035 | + if (empty($_POST['upcont'])) { |
|
| 1036 | + return false; |
|
| 1037 | + } |
|
| 977 | 1038 | |
| 978 | 1039 | require_once($sourcedir . '/Subs-Admin.php'); |
| 979 | 1040 | updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'')); |
@@ -991,25 +1052,26 @@ discard block |
||
| 991 | 1052 | fwrite($fp, $out); |
| 992 | 1053 | |
| 993 | 1054 | $return_data = ''; |
| 994 | - while (!feof($fp)) |
|
| 995 | - $return_data .= fgets($fp, 128); |
|
| 1055 | + while (!feof($fp)) { |
|
| 1056 | + $return_data .= fgets($fp, 128); |
|
| 1057 | + } |
|
| 996 | 1058 | |
| 997 | 1059 | fclose($fp); |
| 998 | 1060 | |
| 999 | 1061 | // Get the unique site ID. |
| 1000 | 1062 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1001 | 1063 | |
| 1002 | - if (!empty($ID[1])) |
|
| 1003 | - $smcFunc['db_insert']('replace', |
|
| 1064 | + if (!empty($ID[1])) { |
|
| 1065 | + $smcFunc['db_insert']('replace', |
|
| 1004 | 1066 | $db_prefix . 'settings', |
| 1005 | 1067 | array('variable' => 'string', 'value' => 'string'), |
| 1006 | 1068 | array('allow_sm_stats', $ID[1]), |
| 1007 | 1069 | array('variable') |
| 1008 | 1070 | ); |
| 1071 | + } |
|
| 1009 | 1072 | } |
| 1010 | - } |
|
| 1011 | - else |
|
| 1012 | - $smcFunc['db_query']('', ' |
|
| 1073 | + } else { |
|
| 1074 | + $smcFunc['db_query']('', ' |
|
| 1013 | 1075 | DELETE FROM {db_prefix}settings |
| 1014 | 1076 | WHERE variable = {string:allow_sm_stats}', |
| 1015 | 1077 | array( |
@@ -1017,6 +1079,7 @@ discard block |
||
| 1017 | 1079 | 'db_error_skip' => true, |
| 1018 | 1080 | ) |
| 1019 | 1081 | ); |
| 1082 | + } |
|
| 1020 | 1083 | |
| 1021 | 1084 | // Deleting old karma stuff? |
| 1022 | 1085 | if (!empty($_POST['delete_karma'])) |
@@ -1031,20 +1094,22 @@ discard block |
||
| 1031 | 1094 | ); |
| 1032 | 1095 | |
| 1033 | 1096 | // Cleaning up old karma member settings. |
| 1034 | - if ($upcontext['karma_installed']['good']) |
|
| 1035 | - $smcFunc['db_query']('', ' |
|
| 1097 | + if ($upcontext['karma_installed']['good']) { |
|
| 1098 | + $smcFunc['db_query']('', ' |
|
| 1036 | 1099 | ALTER TABLE {db_prefix}members |
| 1037 | 1100 | DROP karma_good', |
| 1038 | 1101 | array() |
| 1039 | 1102 | ); |
| 1103 | + } |
|
| 1040 | 1104 | |
| 1041 | 1105 | // Does karma bad was enable? |
| 1042 | - if ($upcontext['karma_installed']['bad']) |
|
| 1043 | - $smcFunc['db_query']('', ' |
|
| 1106 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1107 | + $smcFunc['db_query']('', ' |
|
| 1044 | 1108 | ALTER TABLE {db_prefix}members |
| 1045 | 1109 | DROP karma_bad', |
| 1046 | 1110 | array() |
| 1047 | 1111 | ); |
| 1112 | + } |
|
| 1048 | 1113 | |
| 1049 | 1114 | // Cleaning up old karma permissions. |
| 1050 | 1115 | $smcFunc['db_query']('', ' |
@@ -1057,18 +1122,20 @@ discard block |
||
| 1057 | 1122 | } |
| 1058 | 1123 | |
| 1059 | 1124 | // Emptying the error log? |
| 1060 | - if (!empty($_POST['empty_error'])) |
|
| 1061 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1125 | + if (!empty($_POST['empty_error'])) { |
|
| 1126 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1062 | 1127 | TRUNCATE {db_prefix}log_errors', |
| 1063 | 1128 | array( |
| 1064 | 1129 | ) |
| 1065 | 1130 | ); |
| 1131 | + } |
|
| 1066 | 1132 | |
| 1067 | 1133 | $changes = array(); |
| 1068 | 1134 | |
| 1069 | 1135 | // If we're overriding the language follow it through. |
| 1070 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1071 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1136 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1137 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1138 | + } |
|
| 1072 | 1139 | |
| 1073 | 1140 | if (!empty($_POST['maint'])) |
| 1074 | 1141 | { |
@@ -1080,37 +1147,42 @@ discard block |
||
| 1080 | 1147 | { |
| 1081 | 1148 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1082 | 1149 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1083 | - } |
|
| 1084 | - else |
|
| 1150 | + } else |
|
| 1085 | 1151 | { |
| 1086 | 1152 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1087 | 1153 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1088 | 1154 | } |
| 1089 | 1155 | } |
| 1090 | 1156 | |
| 1091 | - if ($command_line) |
|
| 1092 | - echo ' * Updating Settings.php...'; |
|
| 1157 | + if ($command_line) { |
|
| 1158 | + echo ' * Updating Settings.php...'; |
|
| 1159 | + } |
|
| 1093 | 1160 | |
| 1094 | 1161 | // Backup the current one first. |
| 1095 | 1162 | copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
| 1096 | 1163 | |
| 1097 | 1164 | // Fix some old paths. |
| 1098 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1099 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1165 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1166 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1167 | + } |
|
| 1100 | 1168 | |
| 1101 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1102 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1169 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1170 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1171 | + } |
|
| 1103 | 1172 | |
| 1104 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1105 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1173 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1174 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1175 | + } |
|
| 1106 | 1176 | |
| 1107 | 1177 | // Not had the database type added before? |
| 1108 | - if (empty($db_type)) |
|
| 1109 | - $changes['db_type'] = 'mysql'; |
|
| 1178 | + if (empty($db_type)) { |
|
| 1179 | + $changes['db_type'] = 'mysql'; |
|
| 1180 | + } |
|
| 1110 | 1181 | |
| 1111 | 1182 | // For now we offer a option, this may change in future versions when mysql is completely removed. |
| 1112 | - if (!empty($_POST['convertMysql']) && $db_type == 'mysql') |
|
| 1113 | - $changes['db_type'] = '\'mysqli\''; |
|
| 1183 | + if (!empty($_POST['convertMysql']) && $db_type == 'mysql') { |
|
| 1184 | + $changes['db_type'] = '\'mysqli\''; |
|
| 1185 | + } |
|
| 1114 | 1186 | |
| 1115 | 1187 | // If they have a "host:port" setup for the host, split that into separate values |
| 1116 | 1188 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1121,28 +1193,31 @@ discard block |
||
| 1121 | 1193 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1122 | 1194 | |
| 1123 | 1195 | // Only set this if we're not using the default port |
| 1124 | - if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
| 1125 | - $changes['db_port'] = (int) $db_port; |
|
| 1126 | - } |
|
| 1127 | - elseif(!empty($db_port)) |
|
| 1196 | + if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
| 1197 | + $changes['db_port'] = (int) $db_port; |
|
| 1198 | + } |
|
| 1199 | + } elseif(!empty($db_port)) |
|
| 1128 | 1200 | { |
| 1129 | 1201 | // If db_port is set and is the same as the default, set it to '' |
| 1130 | 1202 | if ($db_type == 'mysql' || $db_type == 'mysqli') |
| 1131 | 1203 | { |
| 1132 | - if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
| 1133 | - $changes['db_port'] = '\'\''; |
|
| 1134 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1135 | - $changes['db_port'] = '\'\''; |
|
| 1204 | + if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
| 1205 | + $changes['db_port'] = '\'\''; |
|
| 1206 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1207 | + $changes['db_port'] = '\'\''; |
|
| 1208 | + } |
|
| 1136 | 1209 | } |
| 1137 | 1210 | } |
| 1138 | 1211 | |
| 1139 | 1212 | // Maybe we haven't had this option yet? |
| 1140 | - if (empty($packagesdir)) |
|
| 1141 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1213 | + if (empty($packagesdir)) { |
|
| 1214 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1215 | + } |
|
| 1142 | 1216 | |
| 1143 | 1217 | // Add support for $tasksdir var. |
| 1144 | - if (empty($tasksdir)) |
|
| 1145 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1218 | + if (empty($tasksdir)) { |
|
| 1219 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1220 | + } |
|
| 1146 | 1221 | |
| 1147 | 1222 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1148 | 1223 | |
@@ -1187,8 +1262,7 @@ discard block |
||
| 1187 | 1262 | $found_old = true; |
| 1188 | 1263 | // Replace the old line with the new code |
| 1189 | 1264 | $settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file); |
| 1190 | - } |
|
| 1191 | - else |
|
| 1265 | + } else |
|
| 1192 | 1266 | { |
| 1193 | 1267 | $found_old = false; |
| 1194 | 1268 | // We want the comments as well as the code... |
@@ -1219,8 +1293,9 @@ discard block |
||
| 1219 | 1293 | fclose($file); |
| 1220 | 1294 | } |
| 1221 | 1295 | |
| 1222 | - if ($command_line) |
|
| 1223 | - echo ' Successful.' . "\n"; |
|
| 1296 | + if ($command_line) { |
|
| 1297 | + echo ' Successful.' . "\n"; |
|
| 1298 | + } |
|
| 1224 | 1299 | |
| 1225 | 1300 | // Are we doing debug? |
| 1226 | 1301 | if (isset($_POST['debug'])) |
@@ -1230,8 +1305,9 @@ discard block |
||
| 1230 | 1305 | } |
| 1231 | 1306 | |
| 1232 | 1307 | // If we're not backing up then jump one. |
| 1233 | - if (empty($_POST['backup'])) |
|
| 1234 | - $upcontext['current_step']++; |
|
| 1308 | + if (empty($_POST['backup'])) { |
|
| 1309 | + $upcontext['current_step']++; |
|
| 1310 | + } |
|
| 1235 | 1311 | |
| 1236 | 1312 | // If we've got here then let's proceed to the next step! |
| 1237 | 1313 | return true; |
@@ -1246,8 +1322,9 @@ discard block |
||
| 1246 | 1322 | $upcontext['page_title'] = 'Backup Database'; |
| 1247 | 1323 | |
| 1248 | 1324 | // Done it already - js wise? |
| 1249 | - if (!empty($_POST['backup_done'])) |
|
| 1250 | - return true; |
|
| 1325 | + if (!empty($_POST['backup_done'])) { |
|
| 1326 | + return true; |
|
| 1327 | + } |
|
| 1251 | 1328 | |
| 1252 | 1329 | // Some useful stuff here. |
| 1253 | 1330 | db_extend(); |
@@ -1261,9 +1338,10 @@ discard block |
||
| 1261 | 1338 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1262 | 1339 | |
| 1263 | 1340 | $table_names = array(); |
| 1264 | - foreach ($tables as $table) |
|
| 1265 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1341 | + foreach ($tables as $table) { |
|
| 1342 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1266 | 1343 | $table_names[] = $table; |
| 1344 | + } |
|
| 1267 | 1345 | |
| 1268 | 1346 | $upcontext['table_count'] = count($table_names); |
| 1269 | 1347 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1273,12 +1351,14 @@ discard block |
||
| 1273 | 1351 | $file_steps = $upcontext['table_count']; |
| 1274 | 1352 | |
| 1275 | 1353 | // What ones have we already done? |
| 1276 | - foreach ($table_names as $id => $table) |
|
| 1277 | - if ($id < $_GET['substep']) |
|
| 1354 | + foreach ($table_names as $id => $table) { |
|
| 1355 | + if ($id < $_GET['substep']) |
|
| 1278 | 1356 | $upcontext['previous_tables'][] = $table; |
| 1357 | + } |
|
| 1279 | 1358 | |
| 1280 | - if ($command_line) |
|
| 1281 | - echo 'Backing Up Tables.'; |
|
| 1359 | + if ($command_line) { |
|
| 1360 | + echo 'Backing Up Tables.'; |
|
| 1361 | + } |
|
| 1282 | 1362 | |
| 1283 | 1363 | // If we don't support javascript we backup here. |
| 1284 | 1364 | if (!$support_js || isset($_GET['xml'])) |
@@ -1297,8 +1377,9 @@ discard block |
||
| 1297 | 1377 | backupTable($table_names[$substep]); |
| 1298 | 1378 | |
| 1299 | 1379 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1300 | - if (isset($_GET['xml'])) |
|
| 1301 | - return upgradeExit(); |
|
| 1380 | + if (isset($_GET['xml'])) { |
|
| 1381 | + return upgradeExit(); |
|
| 1382 | + } |
|
| 1302 | 1383 | } |
| 1303 | 1384 | |
| 1304 | 1385 | if ($command_line) |
@@ -1331,9 +1412,10 @@ discard block |
||
| 1331 | 1412 | |
| 1332 | 1413 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1333 | 1414 | |
| 1334 | - if ($command_line) |
|
| 1335 | - echo ' done.'; |
|
| 1336 | -} |
|
| 1415 | + if ($command_line) { |
|
| 1416 | + echo ' done.'; |
|
| 1417 | + } |
|
| 1418 | + } |
|
| 1337 | 1419 | |
| 1338 | 1420 | // Step 2: Everything. |
| 1339 | 1421 | function DatabaseChanges() |
@@ -1342,8 +1424,9 @@ discard block |
||
| 1342 | 1424 | global $upcontext, $support_js, $db_type; |
| 1343 | 1425 | |
| 1344 | 1426 | // Have we just completed this? |
| 1345 | - if (!empty($_POST['database_done'])) |
|
| 1346 | - return true; |
|
| 1427 | + if (!empty($_POST['database_done'])) { |
|
| 1428 | + return true; |
|
| 1429 | + } |
|
| 1347 | 1430 | |
| 1348 | 1431 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1349 | 1432 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1360,15 +1443,16 @@ discard block |
||
| 1360 | 1443 | ); |
| 1361 | 1444 | |
| 1362 | 1445 | // How many files are there in total? |
| 1363 | - if (isset($_GET['filecount'])) |
|
| 1364 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1365 | - else |
|
| 1446 | + if (isset($_GET['filecount'])) { |
|
| 1447 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1448 | + } else |
|
| 1366 | 1449 | { |
| 1367 | 1450 | $upcontext['file_count'] = 0; |
| 1368 | 1451 | foreach ($files as $file) |
| 1369 | 1452 | { |
| 1370 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1371 | - $upcontext['file_count']++; |
|
| 1453 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1454 | + $upcontext['file_count']++; |
|
| 1455 | + } |
|
| 1372 | 1456 | } |
| 1373 | 1457 | } |
| 1374 | 1458 | |
@@ -1378,9 +1462,9 @@ discard block |
||
| 1378 | 1462 | $upcontext['cur_file_num'] = 0; |
| 1379 | 1463 | foreach ($files as $file) |
| 1380 | 1464 | { |
| 1381 | - if ($did_not_do) |
|
| 1382 | - $did_not_do--; |
|
| 1383 | - else |
|
| 1465 | + if ($did_not_do) { |
|
| 1466 | + $did_not_do--; |
|
| 1467 | + } else |
|
| 1384 | 1468 | { |
| 1385 | 1469 | $upcontext['cur_file_num']++; |
| 1386 | 1470 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1407,12 +1491,13 @@ discard block |
||
| 1407 | 1491 | // Flag to move on to the next. |
| 1408 | 1492 | $upcontext['completed_step'] = true; |
| 1409 | 1493 | // Did we complete the whole file? |
| 1410 | - if ($nextFile) |
|
| 1411 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1494 | + if ($nextFile) { |
|
| 1495 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1496 | + } |
|
| 1412 | 1497 | return upgradeExit(); |
| 1498 | + } elseif ($support_js) { |
|
| 1499 | + break; |
|
| 1413 | 1500 | } |
| 1414 | - elseif ($support_js) |
|
| 1415 | - break; |
|
| 1416 | 1501 | } |
| 1417 | 1502 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1418 | 1503 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1436,8 +1521,9 @@ discard block |
||
| 1436 | 1521 | global $db_prefix, $upcontext, $boarddir, $packagesdir, $settings, $smcFunc, $command_line; |
| 1437 | 1522 | |
| 1438 | 1523 | // Sorry. Not supported for command line users. |
| 1439 | - if ($command_line) |
|
| 1440 | - return true; |
|
| 1524 | + if ($command_line) { |
|
| 1525 | + return true; |
|
| 1526 | + } |
|
| 1441 | 1527 | |
| 1442 | 1528 | // Skipping first? |
| 1443 | 1529 | if (!empty($_POST['skip'])) |
@@ -1447,8 +1533,9 @@ discard block |
||
| 1447 | 1533 | } |
| 1448 | 1534 | |
| 1449 | 1535 | // If we get here withOUT SSI we need to redirect to ensure we get it! |
| 1450 | - if (!isset($_GET['ssi']) || !function_exists('mktree')) |
|
| 1451 | - redirectLocation('&ssi=1'); |
|
| 1536 | + if (!isset($_GET['ssi']) || !function_exists('mktree')) { |
|
| 1537 | + redirectLocation('&ssi=1'); |
|
| 1538 | + } |
|
| 1452 | 1539 | |
| 1453 | 1540 | $upcontext['sub_template'] = 'clean_mods'; |
| 1454 | 1541 | $upcontext['page_title'] = 'Cleanup Modifications'; |
@@ -1457,8 +1544,9 @@ discard block |
||
| 1457 | 1544 | $upcontext['skip'] = true; |
| 1458 | 1545 | |
| 1459 | 1546 | // If we're on the second redirect continue... |
| 1460 | - if (isset($_POST['cleandone2'])) |
|
| 1461 | - return true; |
|
| 1547 | + if (isset($_POST['cleandone2'])) { |
|
| 1548 | + return true; |
|
| 1549 | + } |
|
| 1462 | 1550 | |
| 1463 | 1551 | // Do we already know about some writable files? |
| 1464 | 1552 | if (isset($_POST['writable_files'])) |
@@ -1473,8 +1561,9 @@ discard block |
||
| 1473 | 1561 | } |
| 1474 | 1562 | |
| 1475 | 1563 | // Make sure we have some sort of packages directory. |
| 1476 | - if (!isset($packagesdir)) |
|
| 1477 | - $packagesdir = $boarddir . '/Packages'; |
|
| 1564 | + if (!isset($packagesdir)) { |
|
| 1565 | + $packagesdir = $boarddir . '/Packages'; |
|
| 1566 | + } |
|
| 1478 | 1567 | |
| 1479 | 1568 | // Load all theme paths.... |
| 1480 | 1569 | $request = $smcFunc['db_query']('', ' |
@@ -1492,10 +1581,11 @@ discard block |
||
| 1492 | 1581 | $theme_paths = array(); |
| 1493 | 1582 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1494 | 1583 | { |
| 1495 | - if ($row['id_theme'] == 1) |
|
| 1496 | - $settings['default_' . $row['variable']] = $row['value']; |
|
| 1497 | - elseif ($row['variable'] == 'theme_dir') |
|
| 1498 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1584 | + if ($row['id_theme'] == 1) { |
|
| 1585 | + $settings['default_' . $row['variable']] = $row['value']; |
|
| 1586 | + } elseif ($row['variable'] == 'theme_dir') { |
|
| 1587 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1588 | + } |
|
| 1499 | 1589 | } |
| 1500 | 1590 | $smcFunc['db_free_result']($request); |
| 1501 | 1591 | |
@@ -1519,8 +1609,7 @@ discard block |
||
| 1519 | 1609 | $status = 'Missing'; |
| 1520 | 1610 | $status_color = 'red'; |
| 1521 | 1611 | $result = 'Removed'; |
| 1522 | - } |
|
| 1523 | - else |
|
| 1612 | + } else |
|
| 1524 | 1613 | { |
| 1525 | 1614 | $status = 'Installed'; |
| 1526 | 1615 | $status_color = 'green'; |
@@ -1545,12 +1634,14 @@ discard block |
||
| 1545 | 1634 | $smcFunc['db_free_result']($request); |
| 1546 | 1635 | |
| 1547 | 1636 | // Don't carry on if there are none. |
| 1548 | - if (empty($upcontext['packages'])) |
|
| 1549 | - return true; |
|
| 1637 | + if (empty($upcontext['packages'])) { |
|
| 1638 | + return true; |
|
| 1639 | + } |
|
| 1550 | 1640 | |
| 1551 | 1641 | // Setup some basics. |
| 1552 | - if (!empty($upcontext['user']['version'])) |
|
| 1553 | - $_SESSION['version_emulate'] = $upcontext['user']['version']; |
|
| 1642 | + if (!empty($upcontext['user']['version'])) { |
|
| 1643 | + $_SESSION['version_emulate'] = $upcontext['user']['version']; |
|
| 1644 | + } |
|
| 1554 | 1645 | |
| 1555 | 1646 | // Before we get started, don't report notice errors. |
| 1556 | 1647 | $oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE); |
@@ -1573,34 +1664,40 @@ discard block |
||
| 1573 | 1664 | foreach ($upcontext['packages'] as $id => $package) |
| 1574 | 1665 | { |
| 1575 | 1666 | // Can't do anything about this.... |
| 1576 | - if ($package['missing_file']) |
|
| 1577 | - continue; |
|
| 1667 | + if ($package['missing_file']) { |
|
| 1668 | + continue; |
|
| 1669 | + } |
|
| 1578 | 1670 | |
| 1579 | 1671 | // Not testing *and* this wasn't checked? |
| 1580 | - if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) |
|
| 1581 | - continue; |
|
| 1672 | + if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) { |
|
| 1673 | + continue; |
|
| 1674 | + } |
|
| 1582 | 1675 | |
| 1583 | 1676 | // What are the themes this was installed into? |
| 1584 | 1677 | $cur_theme_paths = array(); |
| 1585 | - foreach ($theme_paths as $tid => $data) |
|
| 1586 | - if ($tid != 1 && in_array($tid, $package['themes'])) |
|
| 1678 | + foreach ($theme_paths as $tid => $data) { |
|
| 1679 | + if ($tid != 1 && in_array($tid, $package['themes'])) |
|
| 1587 | 1680 | $cur_theme_paths[$tid] = $data; |
| 1681 | + } |
|
| 1588 | 1682 | |
| 1589 | 1683 | // Get the modifications data if applicable. |
| 1590 | 1684 | $filename = $package['filename']; |
| 1591 | 1685 | $packageInfo = getPackageInfo($filename); |
| 1592 | - if (!is_array($packageInfo)) |
|
| 1593 | - continue; |
|
| 1686 | + if (!is_array($packageInfo)) { |
|
| 1687 | + continue; |
|
| 1688 | + } |
|
| 1594 | 1689 | |
| 1595 | 1690 | $info = parsePackageInfo($packageInfo['xml'], $test, 'uninstall'); |
| 1596 | 1691 | // Also get the reinstall details... |
| 1597 | - if (isset($_POST['remove'])) |
|
| 1598 | - $infoInstall = parsePackageInfo($packageInfo['xml'], true); |
|
| 1692 | + if (isset($_POST['remove'])) { |
|
| 1693 | + $infoInstall = parsePackageInfo($packageInfo['xml'], true); |
|
| 1694 | + } |
|
| 1599 | 1695 | |
| 1600 | - if (is_file($packagesdir . '/' . $filename)) |
|
| 1601 | - read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1602 | - else |
|
| 1603 | - copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1696 | + if (is_file($packagesdir . '/' . $filename)) { |
|
| 1697 | + read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1698 | + } else { |
|
| 1699 | + copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1700 | + } |
|
| 1604 | 1701 | |
| 1605 | 1702 | // Work out how we uninstall... |
| 1606 | 1703 | $files = array(); |
@@ -1612,16 +1709,18 @@ discard block |
||
| 1612 | 1709 | if ($change['type'] == 'modification') |
| 1613 | 1710 | { |
| 1614 | 1711 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
| 1615 | - if ($change['boardmod']) |
|
| 1616 | - $results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths); |
|
| 1617 | - else |
|
| 1618 | - $results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths); |
|
| 1712 | + if ($change['boardmod']) { |
|
| 1713 | + $results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths); |
|
| 1714 | + } else { |
|
| 1715 | + $results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths); |
|
| 1716 | + } |
|
| 1619 | 1717 | |
| 1620 | 1718 | foreach ($results as $action) |
| 1621 | 1719 | { |
| 1622 | 1720 | // Something we can remove? Probably means it existed! |
| 1623 | - if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) |
|
| 1624 | - $files[] = $action['filename']; |
|
| 1721 | + if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) { |
|
| 1722 | + $files[] = $action['filename']; |
|
| 1723 | + } |
|
| 1625 | 1724 | if ($action['type'] == 'failure') |
| 1626 | 1725 | { |
| 1627 | 1726 | $upcontext['packages'][$id]['needs_removing'] = true; |
@@ -1637,17 +1736,19 @@ discard block |
||
| 1637 | 1736 | $upcontext['packages'][$id]['file_count'] = count($files); |
| 1638 | 1737 | |
| 1639 | 1738 | // If we've done something save the changes! |
| 1640 | - if (!$test) |
|
| 1641 | - package_flush_cache(); |
|
| 1739 | + if (!$test) { |
|
| 1740 | + package_flush_cache(); |
|
| 1741 | + } |
|
| 1642 | 1742 | |
| 1643 | 1743 | // Are we attempting to reinstall this thing? |
| 1644 | 1744 | if (isset($_POST['remove']) && !$test && isset($infoInstall)) |
| 1645 | 1745 | { |
| 1646 | 1746 | // Need to extract again I'm afraid. |
| 1647 | - if (is_file($packagesdir . '/' . $filename)) |
|
| 1648 | - read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1649 | - else |
|
| 1650 | - copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1747 | + if (is_file($packagesdir . '/' . $filename)) { |
|
| 1748 | + read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1749 | + } else { |
|
| 1750 | + copytree($packagesdir . '/' . $filename, $packagesdir . '/temp'); |
|
| 1751 | + } |
|
| 1651 | 1752 | |
| 1652 | 1753 | $errors = false; |
| 1653 | 1754 | $upcontext['packages'][$id]['result'] = 'Removed'; |
@@ -1656,15 +1757,17 @@ discard block |
||
| 1656 | 1757 | if ($change['type'] == 'modification') |
| 1657 | 1758 | { |
| 1658 | 1759 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
| 1659 | - if ($change['boardmod']) |
|
| 1660 | - $results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths); |
|
| 1661 | - else |
|
| 1662 | - $results = parseModification($contents, true, $change['reverse'], $cur_theme_paths); |
|
| 1760 | + if ($change['boardmod']) { |
|
| 1761 | + $results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths); |
|
| 1762 | + } else { |
|
| 1763 | + $results = parseModification($contents, true, $change['reverse'], $cur_theme_paths); |
|
| 1764 | + } |
|
| 1663 | 1765 | |
| 1664 | 1766 | // Are there any errors? |
| 1665 | - foreach ($results as $action) |
|
| 1666 | - if ($action['type'] == 'failure') |
|
| 1767 | + foreach ($results as $action) { |
|
| 1768 | + if ($action['type'] == 'failure') |
|
| 1667 | 1769 | $errors = true; |
| 1770 | + } |
|
| 1668 | 1771 | } |
| 1669 | 1772 | } |
| 1670 | 1773 | if (!$errors) |
@@ -1677,10 +1780,11 @@ discard block |
||
| 1677 | 1780 | if ($change['type'] == 'modification') |
| 1678 | 1781 | { |
| 1679 | 1782 | $contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']); |
| 1680 | - if ($change['boardmod']) |
|
| 1681 | - $results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths); |
|
| 1682 | - else |
|
| 1683 | - $results = parseModification($contents, false, $change['reverse'], $cur_theme_paths); |
|
| 1783 | + if ($change['boardmod']) { |
|
| 1784 | + $results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths); |
|
| 1785 | + } else { |
|
| 1786 | + $results = parseModification($contents, false, $change['reverse'], $cur_theme_paths); |
|
| 1787 | + } |
|
| 1684 | 1788 | } |
| 1685 | 1789 | } |
| 1686 | 1790 | |
@@ -1699,9 +1803,10 @@ discard block |
||
| 1699 | 1803 | $writable_files = array(); |
| 1700 | 1804 | foreach ($upcontext['packages'] as $package) |
| 1701 | 1805 | { |
| 1702 | - if (!empty($package['files'])) |
|
| 1703 | - foreach ($package['files'] as $file) |
|
| 1806 | + if (!empty($package['files'])) { |
|
| 1807 | + foreach ($package['files'] as $file) |
|
| 1704 | 1808 | $writable_files[] = $file; |
| 1809 | + } |
|
| 1705 | 1810 | } |
| 1706 | 1811 | |
| 1707 | 1812 | if (!empty($writable_files)) |
@@ -1709,13 +1814,15 @@ discard block |
||
| 1709 | 1814 | $writable_files = array_unique($writable_files); |
| 1710 | 1815 | $upcontext['writable_files'] = $writable_files; |
| 1711 | 1816 | |
| 1712 | - if (!makeFilesWritable($writable_files)) |
|
| 1713 | - return false; |
|
| 1817 | + if (!makeFilesWritable($writable_files)) { |
|
| 1818 | + return false; |
|
| 1819 | + } |
|
| 1714 | 1820 | } |
| 1715 | 1821 | } |
| 1716 | 1822 | |
| 1717 | - if (file_exists($packagesdir . '/temp')) |
|
| 1718 | - deltree($packagesdir . '/temp'); |
|
| 1823 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1824 | + deltree($packagesdir . '/temp'); |
|
| 1825 | + } |
|
| 1719 | 1826 | |
| 1720 | 1827 | // Removing/Reinstalling any packages? |
| 1721 | 1828 | if (isset($_POST['remove'])) |
@@ -1723,32 +1830,35 @@ discard block |
||
| 1723 | 1830 | $deletes = array(); |
| 1724 | 1831 | foreach ($_POST['remove'] as $id => $dummy) |
| 1725 | 1832 | { |
| 1726 | - if (!in_array((int) $id, $reinstall_worked)) |
|
| 1727 | - $deletes[] = (int) $id; |
|
| 1833 | + if (!in_array((int) $id, $reinstall_worked)) { |
|
| 1834 | + $deletes[] = (int) $id; |
|
| 1835 | + } |
|
| 1728 | 1836 | } |
| 1729 | 1837 | |
| 1730 | - if (!empty($deletes)) |
|
| 1731 | - upgrade_query( ' |
|
| 1838 | + if (!empty($deletes)) { |
|
| 1839 | + upgrade_query( ' |
|
| 1732 | 1840 | UPDATE ' . $db_prefix . 'log_packages |
| 1733 | 1841 | SET install_state = 0 |
| 1734 | 1842 | WHERE id_install IN (' . implode(',', $deletes) . ')'); |
| 1843 | + } |
|
| 1735 | 1844 | |
| 1736 | 1845 | // Ensure we don't lose our changes! |
| 1737 | 1846 | package_put_contents($packagesdir . '/installed.list', time()); |
| 1738 | 1847 | |
| 1739 | 1848 | $upcontext['sub_template'] = 'cleanup_done'; |
| 1740 | 1849 | return false; |
| 1741 | - } |
|
| 1742 | - else |
|
| 1850 | + } else |
|
| 1743 | 1851 | { |
| 1744 | 1852 | $allgood = true; |
| 1745 | 1853 | // Is there actually anything that needs our attention? |
| 1746 | - foreach ($upcontext['packages'] as $package) |
|
| 1747 | - if ($package['color'] != 'green') |
|
| 1854 | + foreach ($upcontext['packages'] as $package) { |
|
| 1855 | + if ($package['color'] != 'green') |
|
| 1748 | 1856 | $allgood = false; |
| 1857 | + } |
|
| 1749 | 1858 | |
| 1750 | - if ($allgood) |
|
| 1751 | - return true; |
|
| 1859 | + if ($allgood) { |
|
| 1860 | + return true; |
|
| 1861 | + } |
|
| 1752 | 1862 | } |
| 1753 | 1863 | |
| 1754 | 1864 | $_GET['substep'] = 0; |
@@ -1762,8 +1872,9 @@ discard block |
||
| 1762 | 1872 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1763 | 1873 | |
| 1764 | 1874 | // Now it's nice to have some of the basic SMF source files. |
| 1765 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1766 | - redirectLocation('&ssi=1'); |
|
| 1875 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1876 | + redirectLocation('&ssi=1'); |
|
| 1877 | + } |
|
| 1767 | 1878 | |
| 1768 | 1879 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1769 | 1880 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1779,14 +1890,16 @@ discard block |
||
| 1779 | 1890 | // Are we in maintenance mode? |
| 1780 | 1891 | if (isset($upcontext['user']['main'])) |
| 1781 | 1892 | { |
| 1782 | - if ($command_line) |
|
| 1783 | - echo ' * '; |
|
| 1893 | + if ($command_line) { |
|
| 1894 | + echo ' * '; |
|
| 1895 | + } |
|
| 1784 | 1896 | $upcontext['removed_maintenance'] = true; |
| 1785 | 1897 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1786 | 1898 | } |
| 1787 | 1899 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1788 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1789 | - $changes['maintenance'] = 1; |
|
| 1900 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1901 | + $changes['maintenance'] = 1; |
|
| 1902 | + } |
|
| 1790 | 1903 | |
| 1791 | 1904 | // Wipe this out... |
| 1792 | 1905 | $upcontext['user'] = array(); |
@@ -1802,9 +1915,9 @@ discard block |
||
| 1802 | 1915 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1803 | 1916 | |
| 1804 | 1917 | // Now is the perfect time to fetch the SM files. |
| 1805 | - if ($command_line) |
|
| 1806 | - cli_scheduled_fetchSMfiles(); |
|
| 1807 | - else |
|
| 1918 | + if ($command_line) { |
|
| 1919 | + cli_scheduled_fetchSMfiles(); |
|
| 1920 | + } else |
|
| 1808 | 1921 | { |
| 1809 | 1922 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1810 | 1923 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1812,8 +1925,9 @@ discard block |
||
| 1812 | 1925 | } |
| 1813 | 1926 | |
| 1814 | 1927 | // Log what we've done. |
| 1815 | - if (empty($user_info['id'])) |
|
| 1816 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1928 | + if (empty($user_info['id'])) { |
|
| 1929 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1930 | + } |
|
| 1817 | 1931 | |
| 1818 | 1932 | // Log the action manually, so CLI still works. |
| 1819 | 1933 | $smcFunc['db_insert']('', |
@@ -1832,8 +1946,9 @@ discard block |
||
| 1832 | 1946 | |
| 1833 | 1947 | // Save the current database version. |
| 1834 | 1948 | $server_version = $smcFunc['db_server_info'](); |
| 1835 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1836 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1949 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1950 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1951 | + } |
|
| 1837 | 1952 | |
| 1838 | 1953 | if ($command_line) |
| 1839 | 1954 | { |
@@ -1845,8 +1960,9 @@ discard block |
||
| 1845 | 1960 | |
| 1846 | 1961 | // Make sure it says we're done. |
| 1847 | 1962 | $upcontext['overall_percent'] = 100; |
| 1848 | - if (isset($upcontext['step_progress'])) |
|
| 1849 | - unset($upcontext['step_progress']); |
|
| 1963 | + if (isset($upcontext['step_progress'])) { |
|
| 1964 | + unset($upcontext['step_progress']); |
|
| 1965 | + } |
|
| 1850 | 1966 | |
| 1851 | 1967 | $_GET['substep'] = 0; |
| 1852 | 1968 | return false; |
@@ -1857,8 +1973,9 @@ discard block |
||
| 1857 | 1973 | { |
| 1858 | 1974 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1859 | 1975 | |
| 1860 | - if (empty($modSettings['time_format'])) |
|
| 1861 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1976 | + if (empty($modSettings['time_format'])) { |
|
| 1977 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1978 | + } |
|
| 1862 | 1979 | |
| 1863 | 1980 | // What files do we want to get |
| 1864 | 1981 | $request = $smcFunc['db_query']('', ' |
@@ -1892,8 +2009,9 @@ discard block |
||
| 1892 | 2009 | $file_data = fetch_web_data($url); |
| 1893 | 2010 | |
| 1894 | 2011 | // If we got an error - give up - the site might be down. |
| 1895 | - if ($file_data === false) |
|
| 1896 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 2012 | + if ($file_data === false) { |
|
| 2013 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 2014 | + } |
|
| 1897 | 2015 | |
| 1898 | 2016 | // Save the file to the database. |
| 1899 | 2017 | $smcFunc['db_query']('substring', ' |
@@ -1935,8 +2053,9 @@ discard block |
||
| 1935 | 2053 | $themeData = array(); |
| 1936 | 2054 | foreach ($values as $variable => $value) |
| 1937 | 2055 | { |
| 1938 | - if (!isset($value) || $value === null) |
|
| 1939 | - $value = 0; |
|
| 2056 | + if (!isset($value) || $value === null) { |
|
| 2057 | + $value = 0; |
|
| 2058 | + } |
|
| 1940 | 2059 | |
| 1941 | 2060 | $themeData[] = array(0, 1, $variable, $value); |
| 1942 | 2061 | } |
@@ -1965,8 +2084,9 @@ discard block |
||
| 1965 | 2084 | |
| 1966 | 2085 | foreach ($values as $variable => $value) |
| 1967 | 2086 | { |
| 1968 | - if (empty($modSettings[$value[0]])) |
|
| 1969 | - continue; |
|
| 2087 | + if (empty($modSettings[$value[0]])) { |
|
| 2088 | + continue; |
|
| 2089 | + } |
|
| 1970 | 2090 | |
| 1971 | 2091 | $smcFunc['db_query']('', ' |
| 1972 | 2092 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1999,8 +2119,9 @@ discard block |
||
| 1999 | 2119 | |
| 2000 | 2120 | $settingsArray = file($boarddir . '/Settings_bak.php'); |
| 2001 | 2121 | |
| 2002 | - if (count($settingsArray) == 1) |
|
| 2003 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 2122 | + if (count($settingsArray) == 1) { |
|
| 2123 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 2124 | + } |
|
| 2004 | 2125 | |
| 2005 | 2126 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 2006 | 2127 | { |
@@ -2013,9 +2134,9 @@ discard block |
||
| 2013 | 2134 | { |
| 2014 | 2135 | if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
| 2015 | 2136 | { |
| 2016 | - if ($val == '#remove#') |
|
| 2017 | - unset($settingsArray[$i]); |
|
| 2018 | - else |
|
| 2137 | + if ($val == '#remove#') { |
|
| 2138 | + unset($settingsArray[$i]); |
|
| 2139 | + } else |
|
| 2019 | 2140 | { |
| 2020 | 2141 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 2021 | 2142 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
@@ -2027,22 +2148,25 @@ discard block |
||
| 2027 | 2148 | } |
| 2028 | 2149 | if (isset($settingsArray[$i])) |
| 2029 | 2150 | { |
| 2030 | - if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') |
|
| 2031 | - $end = $i; |
|
| 2151 | + if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') { |
|
| 2152 | + $end = $i; |
|
| 2153 | + } |
|
| 2032 | 2154 | } |
| 2033 | 2155 | } |
| 2034 | 2156 | |
| 2035 | 2157 | // Assume end-of-file if the end wasn't found. |
| 2036 | - if (empty($end) || $end < 10) |
|
| 2037 | - $end = count($settingsArray); |
|
| 2158 | + if (empty($end) || $end < 10) { |
|
| 2159 | + $end = count($settingsArray); |
|
| 2160 | + } |
|
| 2038 | 2161 | |
| 2039 | 2162 | if (!empty($config_vars)) |
| 2040 | 2163 | { |
| 2041 | 2164 | $settingsArray[$end++] = ''; |
| 2042 | 2165 | foreach ($config_vars as $var => $val) |
| 2043 | 2166 | { |
| 2044 | - if ($val != '#remove#') |
|
| 2045 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 2167 | + if ($val != '#remove#') { |
|
| 2168 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 2169 | + } |
|
| 2046 | 2170 | } |
| 2047 | 2171 | } |
| 2048 | 2172 | // This should be the last line and even last bytes of the file. |
@@ -2055,8 +2179,9 @@ discard block |
||
| 2055 | 2179 | $fp = fopen($boarddir . '/Settings.php', 'r+'); |
| 2056 | 2180 | for ($i = 0; $i < $end; $i++) |
| 2057 | 2181 | { |
| 2058 | - if (isset($settingsArray[$i])) |
|
| 2059 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 2182 | + if (isset($settingsArray[$i])) { |
|
| 2183 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 2184 | + } |
|
| 2060 | 2185 | } |
| 2061 | 2186 | fwrite($fp, rtrim($settingsArray[$i])); |
| 2062 | 2187 | fclose($fp); |
@@ -2087,8 +2212,9 @@ discard block |
||
| 2087 | 2212 | global $smcFunc; |
| 2088 | 2213 | static $member_groups = array(); |
| 2089 | 2214 | |
| 2090 | - if (!empty($member_groups)) |
|
| 2091 | - return $member_groups; |
|
| 2215 | + if (!empty($member_groups)) { |
|
| 2216 | + return $member_groups; |
|
| 2217 | + } |
|
| 2092 | 2218 | |
| 2093 | 2219 | $request = $smcFunc['db_query']('', ' |
| 2094 | 2220 | SELECT group_name, id_group |
@@ -2113,8 +2239,9 @@ discard block |
||
| 2113 | 2239 | ) |
| 2114 | 2240 | ); |
| 2115 | 2241 | } |
| 2116 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 2117 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 2242 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 2243 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 2244 | + } |
|
| 2118 | 2245 | $smcFunc['db_free_result']($request); |
| 2119 | 2246 | |
| 2120 | 2247 | return $member_groups; |
@@ -2167,10 +2294,11 @@ discard block |
||
| 2167 | 2294 | { |
| 2168 | 2295 | global $support_js; |
| 2169 | 2296 | |
| 2170 | - if ($support_js) |
|
| 2171 | - return true; |
|
| 2172 | - else |
|
| 2173 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 2297 | + if ($support_js) { |
|
| 2298 | + return true; |
|
| 2299 | + } else { |
|
| 2300 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 2301 | + } |
|
| 2174 | 2302 | } |
| 2175 | 2303 | } |
| 2176 | 2304 | |
@@ -2188,8 +2316,9 @@ discard block |
||
| 2188 | 2316 | 'db_error_skip' => true, |
| 2189 | 2317 | ) |
| 2190 | 2318 | ); |
| 2191 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2192 | - die('Unable to find members table!'); |
|
| 2319 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2320 | + die('Unable to find members table!'); |
|
| 2321 | + } |
|
| 2193 | 2322 | $table_status = $smcFunc['db_fetch_assoc']($request); |
| 2194 | 2323 | $smcFunc['db_free_result']($request); |
| 2195 | 2324 | |
@@ -2204,17 +2333,20 @@ discard block |
||
| 2204 | 2333 | ) |
| 2205 | 2334 | ); |
| 2206 | 2335 | // Got something? |
| 2207 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
| 2208 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2336 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
| 2337 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2338 | + } |
|
| 2209 | 2339 | $smcFunc['db_free_result']($request); |
| 2210 | 2340 | |
| 2211 | 2341 | // Excellent! |
| 2212 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
| 2213 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 2342 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
| 2343 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 2344 | + } |
|
| 2214 | 2345 | } |
| 2215 | 2346 | } |
| 2216 | - if (empty($db_collation)) |
|
| 2217 | - $db_collation = ''; |
|
| 2347 | + if (empty($db_collation)) { |
|
| 2348 | + $db_collation = ''; |
|
| 2349 | + } |
|
| 2218 | 2350 | |
| 2219 | 2351 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 2220 | 2352 | |
@@ -2226,8 +2358,9 @@ discard block |
||
| 2226 | 2358 | $last_step = ''; |
| 2227 | 2359 | |
| 2228 | 2360 | // Make sure all newly created tables will have the proper characters set. |
| 2229 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 2230 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 2361 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 2362 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 2363 | + } |
|
| 2231 | 2364 | |
| 2232 | 2365 | // Count the total number of steps within this file - for progress. |
| 2233 | 2366 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -2247,15 +2380,18 @@ discard block |
||
| 2247 | 2380 | $do_current = $substep >= $_GET['substep']; |
| 2248 | 2381 | |
| 2249 | 2382 | // Get rid of any comments in the beginning of the line... |
| 2250 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 2251 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 2383 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 2384 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 2385 | + } |
|
| 2252 | 2386 | |
| 2253 | 2387 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 2254 | - if ($is_debug && !$support_js && $command_line) |
|
| 2255 | - flush(); |
|
| 2388 | + if ($is_debug && !$support_js && $command_line) { |
|
| 2389 | + flush(); |
|
| 2390 | + } |
|
| 2256 | 2391 | |
| 2257 | - if (trim($line) === '') |
|
| 2258 | - continue; |
|
| 2392 | + if (trim($line) === '') { |
|
| 2393 | + continue; |
|
| 2394 | + } |
|
| 2259 | 2395 | |
| 2260 | 2396 | if (trim(substr($line, 0, 3)) === '---') |
| 2261 | 2397 | { |
@@ -2265,8 +2401,9 @@ discard block |
||
| 2265 | 2401 | if (trim($current_data) != '' && $type !== '}') |
| 2266 | 2402 | { |
| 2267 | 2403 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 2268 | - if ($command_line) |
|
| 2269 | - echo $upcontext['error_message']; |
|
| 2404 | + if ($command_line) { |
|
| 2405 | + echo $upcontext['error_message']; |
|
| 2406 | + } |
|
| 2270 | 2407 | } |
| 2271 | 2408 | |
| 2272 | 2409 | if ($type == ' ') |
@@ -2284,17 +2421,18 @@ discard block |
||
| 2284 | 2421 | if ($do_current) |
| 2285 | 2422 | { |
| 2286 | 2423 | $upcontext['actioned_items'][] = $last_step; |
| 2287 | - if ($command_line) |
|
| 2288 | - echo ' * '; |
|
| 2424 | + if ($command_line) { |
|
| 2425 | + echo ' * '; |
|
| 2426 | + } |
|
| 2289 | 2427 | } |
| 2290 | - } |
|
| 2291 | - elseif ($type == '#') |
|
| 2428 | + } elseif ($type == '#') |
|
| 2292 | 2429 | { |
| 2293 | 2430 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 2294 | 2431 | |
| 2295 | 2432 | $upcontext['current_debug_item_num']++; |
| 2296 | - if (trim($line) != '---#') |
|
| 2297 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2433 | + if (trim($line) != '---#') { |
|
| 2434 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2435 | + } |
|
| 2298 | 2436 | |
| 2299 | 2437 | // Have we already done something? |
| 2300 | 2438 | if (isset($_GET['xml']) && $done_something) |
@@ -2305,34 +2443,36 @@ discard block |
||
| 2305 | 2443 | |
| 2306 | 2444 | if ($do_current) |
| 2307 | 2445 | { |
| 2308 | - if (trim($line) == '---#' && $command_line) |
|
| 2309 | - echo ' done.', $endl; |
|
| 2310 | - elseif ($command_line) |
|
| 2311 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2312 | - elseif (trim($line) != '---#') |
|
| 2446 | + if (trim($line) == '---#' && $command_line) { |
|
| 2447 | + echo ' done.', $endl; |
|
| 2448 | + } elseif ($command_line) { |
|
| 2449 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2450 | + } elseif (trim($line) != '---#') |
|
| 2313 | 2451 | { |
| 2314 | - if ($is_debug) |
|
| 2315 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2452 | + if ($is_debug) { |
|
| 2453 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2454 | + } |
|
| 2316 | 2455 | } |
| 2317 | 2456 | } |
| 2318 | 2457 | |
| 2319 | 2458 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 2320 | 2459 | { |
| 2321 | - if ($command_line) |
|
| 2322 | - echo ' * '; |
|
| 2323 | - else |
|
| 2324 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2460 | + if ($command_line) { |
|
| 2461 | + echo ' * '; |
|
| 2462 | + } else { |
|
| 2463 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2464 | + } |
|
| 2325 | 2465 | } |
| 2326 | 2466 | |
| 2327 | 2467 | // Small step - only if we're actually doing stuff. |
| 2328 | - if ($do_current) |
|
| 2329 | - nextSubstep(++$substep); |
|
| 2330 | - else |
|
| 2331 | - $substep++; |
|
| 2332 | - } |
|
| 2333 | - elseif ($type == '{') |
|
| 2334 | - $current_type = 'code'; |
|
| 2335 | - elseif ($type == '}') |
|
| 2468 | + if ($do_current) { |
|
| 2469 | + nextSubstep(++$substep); |
|
| 2470 | + } else { |
|
| 2471 | + $substep++; |
|
| 2472 | + } |
|
| 2473 | + } elseif ($type == '{') { |
|
| 2474 | + $current_type = 'code'; |
|
| 2475 | + } elseif ($type == '}') |
|
| 2336 | 2476 | { |
| 2337 | 2477 | $current_type = 'sql'; |
| 2338 | 2478 | |
@@ -2345,8 +2485,9 @@ discard block |
||
| 2345 | 2485 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 2346 | 2486 | { |
| 2347 | 2487 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 2348 | - if ($command_line) |
|
| 2349 | - echo $upcontext['error_message']; |
|
| 2488 | + if ($command_line) { |
|
| 2489 | + echo $upcontext['error_message']; |
|
| 2490 | + } |
|
| 2350 | 2491 | } |
| 2351 | 2492 | |
| 2352 | 2493 | // Done with code! |
@@ -2426,8 +2567,9 @@ discard block |
||
| 2426 | 2567 | $db_unbuffered = false; |
| 2427 | 2568 | |
| 2428 | 2569 | // Failure?! |
| 2429 | - if ($result !== false) |
|
| 2430 | - return $result; |
|
| 2570 | + if ($result !== false) { |
|
| 2571 | + return $result; |
|
| 2572 | + } |
|
| 2431 | 2573 | |
| 2432 | 2574 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2433 | 2575 | // If MySQL we do something more clever. |
@@ -2457,17 +2599,16 @@ discard block |
||
| 2457 | 2599 | { |
| 2458 | 2600 | mysql_query('REPAIR TABLE `' . $match[1] . '`'); |
| 2459 | 2601 | $result = mysql_query($string); |
| 2460 | - } |
|
| 2461 | - else |
|
| 2602 | + } else |
|
| 2462 | 2603 | { |
| 2463 | 2604 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2464 | 2605 | $result = mysqli_query($db_connection, $string); |
| 2465 | 2606 | } |
| 2466 | - if ($result !== false) |
|
| 2467 | - return $result; |
|
| 2607 | + if ($result !== false) { |
|
| 2608 | + return $result; |
|
| 2609 | + } |
|
| 2468 | 2610 | } |
| 2469 | - } |
|
| 2470 | - elseif ($mysql_errno == 2013) |
|
| 2611 | + } elseif ($mysql_errno == 2013) |
|
| 2471 | 2612 | { |
| 2472 | 2613 | $db_connection = mysql_connect($db_server, $db_user, $db_passwd); |
| 2473 | 2614 | if ($db_type == 'mysql') |
@@ -2476,54 +2617,61 @@ discard block |
||
| 2476 | 2617 | if ($db_connection) |
| 2477 | 2618 | { |
| 2478 | 2619 | $result = mysql_query($string); |
| 2479 | - if ($result !== false) |
|
| 2480 | - return $result; |
|
| 2620 | + if ($result !== false) { |
|
| 2621 | + return $result; |
|
| 2622 | + } |
|
| 2481 | 2623 | } |
| 2482 | - } |
|
| 2483 | - else |
|
| 2624 | + } else |
|
| 2484 | 2625 | { |
| 2485 | 2626 | mysqli_select_db($db_connection, $db_name); |
| 2486 | 2627 | if ($db_connection) |
| 2487 | 2628 | { |
| 2488 | 2629 | $result = mysqli_query($db_connection, $string); |
| 2489 | - if ($result !== false) |
|
| 2490 | - return $result; |
|
| 2630 | + if ($result !== false) { |
|
| 2631 | + return $result; |
|
| 2632 | + } |
|
| 2491 | 2633 | } |
| 2492 | 2634 | } |
| 2493 | 2635 | } |
| 2494 | 2636 | // Duplicate column name... should be okay ;). |
| 2495 | - elseif (in_array($mysql_errno, array(1060, 1061, 1068, 1091))) |
|
| 2496 | - return false; |
|
| 2637 | + elseif (in_array($mysql_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2638 | + return false; |
|
| 2639 | + } |
|
| 2497 | 2640 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2498 | - elseif (in_array($mysql_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2499 | - return false; |
|
| 2641 | + elseif (in_array($mysql_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2642 | + return false; |
|
| 2643 | + } |
|
| 2500 | 2644 | // Creating an index on a non-existent column. |
| 2501 | - elseif ($mysql_errno == 1072) |
|
| 2502 | - return false; |
|
| 2503 | - elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2504 | - return false; |
|
| 2645 | + elseif ($mysql_errno == 1072) { |
|
| 2646 | + return false; |
|
| 2647 | + } elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2648 | + return false; |
|
| 2649 | + } |
|
| 2505 | 2650 | } |
| 2506 | 2651 | // If a table already exists don't go potty. |
| 2507 | 2652 | else |
| 2508 | 2653 | { |
| 2509 | 2654 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2510 | 2655 | { |
| 2511 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2512 | - return true; |
|
| 2513 | - } |
|
| 2514 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2656 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2657 | + return true; |
|
| 2658 | + } |
|
| 2659 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2515 | 2660 | { |
| 2516 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 2517 | - return true; |
|
| 2661 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2662 | + return true; |
|
| 2663 | + } |
|
| 2518 | 2664 | } |
| 2519 | 2665 | } |
| 2520 | 2666 | |
| 2521 | 2667 | // Get the query string so we pass everything. |
| 2522 | 2668 | $query_string = ''; |
| 2523 | - foreach ($_GET as $k => $v) |
|
| 2524 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2525 | - if (strlen($query_string) != 0) |
|
| 2526 | - $query_string = '?' . substr($query_string, 1); |
|
| 2669 | + foreach ($_GET as $k => $v) { |
|
| 2670 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2671 | + } |
|
| 2672 | + if (strlen($query_string) != 0) { |
|
| 2673 | + $query_string = '?' . substr($query_string, 1); |
|
| 2674 | + } |
|
| 2527 | 2675 | |
| 2528 | 2676 | if ($command_line) |
| 2529 | 2677 | { |
@@ -2614,16 +2762,18 @@ discard block |
||
| 2614 | 2762 | { |
| 2615 | 2763 | $found |= 1; |
| 2616 | 2764 | // Do some checks on the data if we have it set. |
| 2617 | - if (isset($change['col_type'])) |
|
| 2618 | - $found &= $change['col_type'] === $column['type']; |
|
| 2619 | - if (isset($change['null_allowed'])) |
|
| 2620 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2621 | - if (isset($change['default'])) |
|
| 2622 | - $found &= $change['default'] === $column['default']; |
|
| 2765 | + if (isset($change['col_type'])) { |
|
| 2766 | + $found &= $change['col_type'] === $column['type']; |
|
| 2767 | + } |
|
| 2768 | + if (isset($change['null_allowed'])) { |
|
| 2769 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2770 | + } |
|
| 2771 | + if (isset($change['default'])) { |
|
| 2772 | + $found &= $change['default'] === $column['default']; |
|
| 2773 | + } |
|
| 2623 | 2774 | } |
| 2624 | 2775 | } |
| 2625 | - } |
|
| 2626 | - elseif ($change['type'] === 'index') |
|
| 2776 | + } elseif ($change['type'] === 'index') |
|
| 2627 | 2777 | { |
| 2628 | 2778 | $request = upgrade_query( ' |
| 2629 | 2779 | SHOW INDEX |
@@ -2632,9 +2782,10 @@ discard block |
||
| 2632 | 2782 | { |
| 2633 | 2783 | $cur_index = array(); |
| 2634 | 2784 | |
| 2635 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2636 | - if ($row['Key_name'] === $change['name']) |
|
| 2785 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2786 | + if ($row['Key_name'] === $change['name']) |
|
| 2637 | 2787 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2788 | + } |
|
| 2638 | 2789 | |
| 2639 | 2790 | ksort($cur_index, SORT_NUMERIC); |
| 2640 | 2791 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2644,14 +2795,17 @@ discard block |
||
| 2644 | 2795 | } |
| 2645 | 2796 | |
| 2646 | 2797 | // If we're trying to add and it's added, we're done. |
| 2647 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2648 | - return true; |
|
| 2798 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2799 | + return true; |
|
| 2800 | + } |
|
| 2649 | 2801 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2650 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2651 | - return true; |
|
| 2802 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2803 | + return true; |
|
| 2804 | + } |
|
| 2652 | 2805 | // Otherwise is it just a test? |
| 2653 | - elseif ($is_test) |
|
| 2654 | - return false; |
|
| 2806 | + elseif ($is_test) { |
|
| 2807 | + return false; |
|
| 2808 | + } |
|
| 2655 | 2809 | |
| 2656 | 2810 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2657 | 2811 | $running = false; |
@@ -2662,8 +2816,9 @@ discard block |
||
| 2662 | 2816 | SHOW FULL PROCESSLIST'); |
| 2663 | 2817 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2664 | 2818 | { |
| 2665 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2666 | - $found = true; |
|
| 2819 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2820 | + $found = true; |
|
| 2821 | + } |
|
| 2667 | 2822 | } |
| 2668 | 2823 | |
| 2669 | 2824 | // Can't find it? Then we need to run it fools! |
@@ -2675,8 +2830,9 @@ discard block |
||
| 2675 | 2830 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2676 | 2831 | ' . $change['text'], true) !== false; |
| 2677 | 2832 | |
| 2678 | - if (!$success) |
|
| 2679 | - return false; |
|
| 2833 | + if (!$success) { |
|
| 2834 | + return false; |
|
| 2835 | + } |
|
| 2680 | 2836 | |
| 2681 | 2837 | // Return |
| 2682 | 2838 | $running = true; |
@@ -2709,8 +2865,7 @@ discard block |
||
| 2709 | 2865 | { |
| 2710 | 2866 | $column_fix = true; |
| 2711 | 2867 | $null_fix = !$change['null_allowed']; |
| 2712 | - } |
|
| 2713 | - else |
|
| 2868 | + } else |
|
| 2714 | 2869 | { |
| 2715 | 2870 | $request = $smcFunc['db_query']('', ' |
| 2716 | 2871 | SHOW FULL COLUMNS |
@@ -2721,8 +2876,9 @@ discard block |
||
| 2721 | 2876 | 'db_error_skip' => true, |
| 2722 | 2877 | ) |
| 2723 | 2878 | ); |
| 2724 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2725 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2879 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2880 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2881 | + } |
|
| 2726 | 2882 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2727 | 2883 | $smcFunc['db_free_result']($request); |
| 2728 | 2884 | |
@@ -2744,10 +2900,11 @@ discard block |
||
| 2744 | 2900 | ) |
| 2745 | 2901 | ); |
| 2746 | 2902 | // No results? Just forget it all together. |
| 2747 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2748 | - unset($table_row['Collation']); |
|
| 2749 | - else |
|
| 2750 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2903 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2904 | + unset($table_row['Collation']); |
|
| 2905 | + } else { |
|
| 2906 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2907 | + } |
|
| 2751 | 2908 | $smcFunc['db_free_result']($request); |
| 2752 | 2909 | } |
| 2753 | 2910 | } |
@@ -2755,8 +2912,8 @@ discard block |
||
| 2755 | 2912 | if ($column_fix) |
| 2756 | 2913 | { |
| 2757 | 2914 | // Make sure there are no NULL's left. |
| 2758 | - if ($null_fix) |
|
| 2759 | - $smcFunc['db_query']('', ' |
|
| 2915 | + if ($null_fix) { |
|
| 2916 | + $smcFunc['db_query']('', ' |
|
| 2760 | 2917 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2761 | 2918 | SET ' . $change['column'] . ' = {string:default} |
| 2762 | 2919 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2765,6 +2922,7 @@ discard block |
||
| 2765 | 2922 | 'db_error_skip' => true, |
| 2766 | 2923 | ) |
| 2767 | 2924 | ); |
| 2925 | + } |
|
| 2768 | 2926 | |
| 2769 | 2927 | // Do the actual alteration. |
| 2770 | 2928 | $smcFunc['db_query']('', ' |
@@ -2793,8 +2951,9 @@ discard block |
||
| 2793 | 2951 | } |
| 2794 | 2952 | |
| 2795 | 2953 | // Not a column we need to check on? |
| 2796 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2797 | - return; |
|
| 2954 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2955 | + return; |
|
| 2956 | + } |
|
| 2798 | 2957 | |
| 2799 | 2958 | // Break it up you (six|seven). |
| 2800 | 2959 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2813,13 +2972,13 @@ discard block |
||
| 2813 | 2972 | 'new_name' => $temp[2], |
| 2814 | 2973 | )); |
| 2815 | 2974 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2816 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2817 | - return; |
|
| 2975 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2976 | + return; |
|
| 2977 | + } |
|
| 2818 | 2978 | |
| 2819 | 2979 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2820 | 2980 | $smcFunc['db_free_result']($request); |
| 2821 | - } |
|
| 2822 | - else |
|
| 2981 | + } else |
|
| 2823 | 2982 | { |
| 2824 | 2983 | // Do this the old fashion, sure method way. |
| 2825 | 2984 | $request = $smcFunc['db_query']('', ' |
@@ -2830,21 +2989,24 @@ discard block |
||
| 2830 | 2989 | )); |
| 2831 | 2990 | // Mayday! |
| 2832 | 2991 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2833 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2834 | - return; |
|
| 2992 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2993 | + return; |
|
| 2994 | + } |
|
| 2835 | 2995 | |
| 2836 | 2996 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2837 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2838 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2997 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2998 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2839 | 2999 | { |
| 2840 | 3000 | $current_type = $row['Type']; |
| 3001 | + } |
|
| 2841 | 3002 | break; |
| 2842 | 3003 | } |
| 2843 | 3004 | } |
| 2844 | 3005 | |
| 2845 | 3006 | // If this doesn't match, the column may of been altered for a reason. |
| 2846 | - if (trim($current_type) != trim($temp[3])) |
|
| 2847 | - $temp[3] = $current_type; |
|
| 3007 | + if (trim($current_type) != trim($temp[3])) { |
|
| 3008 | + $temp[3] = $current_type; |
|
| 3009 | + } |
|
| 2848 | 3010 | |
| 2849 | 3011 | // Piece this back together. |
| 2850 | 3012 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2856,8 +3018,9 @@ discard block |
||
| 2856 | 3018 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2857 | 3019 | global $step_progress, $is_debug, $upcontext; |
| 2858 | 3020 | |
| 2859 | - if ($_GET['substep'] < $substep) |
|
| 2860 | - $_GET['substep'] = $substep; |
|
| 3021 | + if ($_GET['substep'] < $substep) { |
|
| 3022 | + $_GET['substep'] = $substep; |
|
| 3023 | + } |
|
| 2861 | 3024 | |
| 2862 | 3025 | if ($command_line) |
| 2863 | 3026 | { |
@@ -2870,29 +3033,33 @@ discard block |
||
| 2870 | 3033 | } |
| 2871 | 3034 | |
| 2872 | 3035 | @set_time_limit(300); |
| 2873 | - if (function_exists('apache_reset_timeout')) |
|
| 2874 | - @apache_reset_timeout(); |
|
| 3036 | + if (function_exists('apache_reset_timeout')) { |
|
| 3037 | + @apache_reset_timeout(); |
|
| 3038 | + } |
|
| 2875 | 3039 | |
| 2876 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2877 | - return; |
|
| 3040 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 3041 | + return; |
|
| 3042 | + } |
|
| 2878 | 3043 | |
| 2879 | 3044 | // Do we have some custom step progress stuff? |
| 2880 | 3045 | if (!empty($step_progress)) |
| 2881 | 3046 | { |
| 2882 | 3047 | $upcontext['substep_progress'] = 0; |
| 2883 | 3048 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2884 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2885 | - $upcontext['substep_progress'] = 99.9; |
|
| 2886 | - else |
|
| 2887 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 3049 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 3050 | + $upcontext['substep_progress'] = 99.9; |
|
| 3051 | + } else { |
|
| 3052 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 3053 | + } |
|
| 2888 | 3054 | |
| 2889 | 3055 | // Make it nicely rounded. |
| 2890 | 3056 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2891 | 3057 | } |
| 2892 | 3058 | |
| 2893 | 3059 | // If this is XML we just exit right away! |
| 2894 | - if (isset($_GET['xml'])) |
|
| 2895 | - return upgradeExit(); |
|
| 3060 | + if (isset($_GET['xml'])) { |
|
| 3061 | + return upgradeExit(); |
|
| 3062 | + } |
|
| 2896 | 3063 | |
| 2897 | 3064 | // We're going to pause after this! |
| 2898 | 3065 | $upcontext['pause'] = true; |
@@ -2900,13 +3067,15 @@ discard block |
||
| 2900 | 3067 | $upcontext['query_string'] = ''; |
| 2901 | 3068 | foreach ($_GET as $k => $v) |
| 2902 | 3069 | { |
| 2903 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2904 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 3070 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 3071 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 3072 | + } |
|
| 2905 | 3073 | } |
| 2906 | 3074 | |
| 2907 | 3075 | // Custom warning? |
| 2908 | - if (!empty($custom_warning)) |
|
| 2909 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 3076 | + if (!empty($custom_warning)) { |
|
| 3077 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 3078 | + } |
|
| 2910 | 3079 | |
| 2911 | 3080 | upgradeExit(); |
| 2912 | 3081 | } |
@@ -2921,25 +3090,26 @@ discard block |
||
| 2921 | 3090 | ob_implicit_flush(true); |
| 2922 | 3091 | @set_time_limit(600); |
| 2923 | 3092 | |
| 2924 | - if (!isset($_SERVER['argv'])) |
|
| 2925 | - $_SERVER['argv'] = array(); |
|
| 3093 | + if (!isset($_SERVER['argv'])) { |
|
| 3094 | + $_SERVER['argv'] = array(); |
|
| 3095 | + } |
|
| 2926 | 3096 | $_GET['maint'] = 1; |
| 2927 | 3097 | |
| 2928 | 3098 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2929 | 3099 | { |
| 2930 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2931 | - $_GET['lang'] = $match[1]; |
|
| 2932 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2933 | - continue; |
|
| 2934 | - elseif ($arg == '--no-maintenance') |
|
| 2935 | - $_GET['maint'] = 0; |
|
| 2936 | - elseif ($arg == '--debug') |
|
| 2937 | - $is_debug = true; |
|
| 2938 | - elseif ($arg == '--backup') |
|
| 2939 | - $_POST['backup'] = 1; |
|
| 2940 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2941 | - $_GET['conv'] = 1; |
|
| 2942 | - elseif ($i != 0) |
|
| 3100 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 3101 | + $_GET['lang'] = $match[1]; |
|
| 3102 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 3103 | + continue; |
|
| 3104 | + } elseif ($arg == '--no-maintenance') { |
|
| 3105 | + $_GET['maint'] = 0; |
|
| 3106 | + } elseif ($arg == '--debug') { |
|
| 3107 | + $is_debug = true; |
|
| 3108 | + } elseif ($arg == '--backup') { |
|
| 3109 | + $_POST['backup'] = 1; |
|
| 3110 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 3111 | + $_GET['conv'] = 1; |
|
| 3112 | + } elseif ($i != 0) |
|
| 2943 | 3113 | { |
| 2944 | 3114 | echo 'SMF Command-line Upgrader |
| 2945 | 3115 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2953,10 +3123,12 @@ discard block |
||
| 2953 | 3123 | } |
| 2954 | 3124 | } |
| 2955 | 3125 | |
| 2956 | - if (!php_version_check()) |
|
| 2957 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2958 | - if (!db_version_check()) |
|
| 2959 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 3126 | + if (!php_version_check()) { |
|
| 3127 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 3128 | + } |
|
| 3129 | + if (!db_version_check()) { |
|
| 3130 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 3131 | + } |
|
| 2960 | 3132 | |
| 2961 | 3133 | // Do some checks to make sure they have proper privileges |
| 2962 | 3134 | db_extend('packages'); |
@@ -2971,34 +3143,39 @@ discard block |
||
| 2971 | 3143 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2972 | 3144 | |
| 2973 | 3145 | // Sorry... we need CREATE, ALTER and DROP |
| 2974 | - if (!$create || !$alter || !$drop) |
|
| 2975 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 3146 | + if (!$create || !$alter || !$drop) { |
|
| 3147 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 3148 | + } |
|
| 2976 | 3149 | |
| 2977 | 3150 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2978 | 3151 | && @file_exists($sourcedir . '/QueryString.php') |
| 2979 | 3152 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2980 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2981 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 3153 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 3154 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 3155 | + } |
|
| 2982 | 3156 | |
| 2983 | 3157 | // Do a quick version spot check. |
| 2984 | 3158 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2985 | 3159 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2986 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2987 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 3160 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 3161 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 3162 | + } |
|
| 2988 | 3163 | |
| 2989 | 3164 | // Make sure Settings.php is writable. |
| 2990 | 3165 | quickFileWritable($boarddir . '/Settings.php'); |
| 2991 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2992 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 3166 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 3167 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 3168 | + } |
|
| 2993 | 3169 | |
| 2994 | 3170 | // Make sure Settings_bak.php is writable. |
| 2995 | 3171 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2996 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2997 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 3172 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 3173 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 3174 | + } |
|
| 2998 | 3175 | |
| 2999 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 3000 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 3001 | - elseif (isset($modSettings['agreement'])) |
|
| 3176 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 3177 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 3178 | + } elseif (isset($modSettings['agreement'])) |
|
| 3002 | 3179 | { |
| 3003 | 3180 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 3004 | 3181 | fwrite($fp, $modSettings['agreement']); |
@@ -3008,31 +3185,36 @@ discard block |
||
| 3008 | 3185 | // Make sure Themes is writable. |
| 3009 | 3186 | quickFileWritable($modSettings['theme_dir']); |
| 3010 | 3187 | |
| 3011 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 3012 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 3188 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 3189 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 3190 | + } |
|
| 3013 | 3191 | |
| 3014 | 3192 | // Make sure cache directory exists and is writable! |
| 3015 | 3193 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 3016 | - if (!file_exists($cachedir_temp)) |
|
| 3017 | - @mkdir($cachedir_temp); |
|
| 3194 | + if (!file_exists($cachedir_temp)) { |
|
| 3195 | + @mkdir($cachedir_temp); |
|
| 3196 | + } |
|
| 3018 | 3197 | |
| 3019 | 3198 | // Make sure the cache temp dir is writable. |
| 3020 | 3199 | quickFileWritable($cachedir_temp); |
| 3021 | 3200 | |
| 3022 | - if (!is_writable($cachedir_temp)) |
|
| 3023 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 3201 | + if (!is_writable($cachedir_temp)) { |
|
| 3202 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 3203 | + } |
|
| 3024 | 3204 | |
| 3025 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 3026 | - print_error('Error: Unable to find language files!', true); |
|
| 3027 | - else |
|
| 3205 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 3206 | + print_error('Error: Unable to find language files!', true); |
|
| 3207 | + } else |
|
| 3028 | 3208 | { |
| 3029 | 3209 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 3030 | 3210 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 3031 | 3211 | |
| 3032 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 3033 | - print_error('Error: Language files out of date.', true); |
|
| 3034 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 3035 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 3212 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 3213 | + print_error('Error: Language files out of date.', true); |
|
| 3214 | + } |
|
| 3215 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 3216 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 3217 | + } |
|
| 3036 | 3218 | |
| 3037 | 3219 | // Otherwise include it! |
| 3038 | 3220 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -3047,14 +3229,16 @@ discard block |
||
| 3047 | 3229 | { |
| 3048 | 3230 | static $fp = null; |
| 3049 | 3231 | |
| 3050 | - if ($fp === null) |
|
| 3051 | - $fp = fopen('php://stderr', 'wb'); |
|
| 3232 | + if ($fp === null) { |
|
| 3233 | + $fp = fopen('php://stderr', 'wb'); |
|
| 3234 | + } |
|
| 3052 | 3235 | |
| 3053 | 3236 | fwrite($fp, $message . "\n"); |
| 3054 | 3237 | |
| 3055 | - if ($fatal) |
|
| 3056 | - exit; |
|
| 3057 | -} |
|
| 3238 | + if ($fatal) { |
|
| 3239 | + exit; |
|
| 3240 | + } |
|
| 3241 | + } |
|
| 3058 | 3242 | |
| 3059 | 3243 | function throw_error($message) |
| 3060 | 3244 | { |
@@ -3071,8 +3255,9 @@ discard block |
||
| 3071 | 3255 | { |
| 3072 | 3256 | global $upcontext, $boarddir; |
| 3073 | 3257 | |
| 3074 | - if (empty($files)) |
|
| 3075 | - return true; |
|
| 3258 | + if (empty($files)) { |
|
| 3259 | + return true; |
|
| 3260 | + } |
|
| 3076 | 3261 | |
| 3077 | 3262 | $failure = false; |
| 3078 | 3263 | // On linux, it's easy - just use is_writable! |
@@ -3087,14 +3272,16 @@ discard block |
||
| 3087 | 3272 | @chmod($file, 0755); |
| 3088 | 3273 | |
| 3089 | 3274 | // Well, 755 hopefully worked... if not, try 777. |
| 3090 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 3091 | - $failure = true; |
|
| 3275 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
| 3276 | + $failure = true; |
|
| 3277 | + } |
|
| 3092 | 3278 | // Otherwise remove it as it's good! |
| 3093 | - else |
|
| 3094 | - unset($files[$k]); |
|
| 3279 | + else { |
|
| 3280 | + unset($files[$k]); |
|
| 3281 | + } |
|
| 3282 | + } else { |
|
| 3283 | + unset($files[$k]); |
|
| 3095 | 3284 | } |
| 3096 | - else |
|
| 3097 | - unset($files[$k]); |
|
| 3098 | 3285 | } |
| 3099 | 3286 | } |
| 3100 | 3287 | // Windows is trickier. Let's try opening for r+... |
@@ -3105,30 +3292,35 @@ discard block |
||
| 3105 | 3292 | foreach ($files as $k => $file) |
| 3106 | 3293 | { |
| 3107 | 3294 | // Folders can't be opened for write... but the index.php in them can ;). |
| 3108 | - if (is_dir($file)) |
|
| 3109 | - $file .= '/index.php'; |
|
| 3295 | + if (is_dir($file)) { |
|
| 3296 | + $file .= '/index.php'; |
|
| 3297 | + } |
|
| 3110 | 3298 | |
| 3111 | 3299 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 3112 | 3300 | @chmod($file, 0777); |
| 3113 | 3301 | $fp = @fopen($file, 'r+'); |
| 3114 | 3302 | |
| 3115 | 3303 | // Hmm, okay, try just for write in that case... |
| 3116 | - if (!$fp) |
|
| 3117 | - $fp = @fopen($file, 'w'); |
|
| 3304 | + if (!$fp) { |
|
| 3305 | + $fp = @fopen($file, 'w'); |
|
| 3306 | + } |
|
| 3118 | 3307 | |
| 3119 | - if (!$fp) |
|
| 3120 | - $failure = true; |
|
| 3121 | - else |
|
| 3122 | - unset($files[$k]); |
|
| 3308 | + if (!$fp) { |
|
| 3309 | + $failure = true; |
|
| 3310 | + } else { |
|
| 3311 | + unset($files[$k]); |
|
| 3312 | + } |
|
| 3123 | 3313 | @fclose($fp); |
| 3124 | 3314 | } |
| 3125 | 3315 | } |
| 3126 | 3316 | |
| 3127 | - if (empty($files)) |
|
| 3128 | - return true; |
|
| 3317 | + if (empty($files)) { |
|
| 3318 | + return true; |
|
| 3319 | + } |
|
| 3129 | 3320 | |
| 3130 | - if (!isset($_SERVER)) |
|
| 3131 | - return !$failure; |
|
| 3321 | + if (!isset($_SERVER)) { |
|
| 3322 | + return !$failure; |
|
| 3323 | + } |
|
| 3132 | 3324 | |
| 3133 | 3325 | // What still needs to be done? |
| 3134 | 3326 | $upcontext['chmod']['files'] = $files; |
@@ -3179,36 +3371,40 @@ discard block |
||
| 3179 | 3371 | |
| 3180 | 3372 | if (!isset($ftp) || $ftp->error !== false) |
| 3181 | 3373 | { |
| 3182 | - if (!isset($ftp)) |
|
| 3183 | - $ftp = new ftp_connection(null); |
|
| 3374 | + if (!isset($ftp)) { |
|
| 3375 | + $ftp = new ftp_connection(null); |
|
| 3376 | + } |
|
| 3184 | 3377 | // Save the error so we can mess with listing... |
| 3185 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 3186 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 3378 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
| 3379 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 3380 | + } |
|
| 3187 | 3381 | |
| 3188 | 3382 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 3189 | 3383 | |
| 3190 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 3191 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 3384 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
| 3385 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 3386 | + } |
|
| 3192 | 3387 | |
| 3193 | - if (!isset($upcontext['chmod']['username'])) |
|
| 3194 | - $upcontext['chmod']['username'] = $username; |
|
| 3388 | + if (!isset($upcontext['chmod']['username'])) { |
|
| 3389 | + $upcontext['chmod']['username'] = $username; |
|
| 3390 | + } |
|
| 3195 | 3391 | |
| 3196 | 3392 | // Don't forget the login token. |
| 3197 | 3393 | $upcontext += createToken('login'); |
| 3198 | 3394 | |
| 3199 | 3395 | return false; |
| 3200 | - } |
|
| 3201 | - else |
|
| 3396 | + } else |
|
| 3202 | 3397 | { |
| 3203 | 3398 | // We want to do a relative path for FTP. |
| 3204 | 3399 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
| 3205 | 3400 | { |
| 3206 | 3401 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
| 3207 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 3208 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 3402 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
| 3403 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 3404 | + } |
|
| 3405 | + } else { |
|
| 3406 | + $ftp_root = $boarddir; |
|
| 3209 | 3407 | } |
| 3210 | - else |
|
| 3211 | - $ftp_root = $boarddir; |
|
| 3212 | 3408 | |
| 3213 | 3409 | // Save the info for next time! |
| 3214 | 3410 | $_SESSION['installer_temp_ftp'] = array( |
@@ -3222,10 +3418,12 @@ discard block |
||
| 3222 | 3418 | |
| 3223 | 3419 | foreach ($files as $k => $file) |
| 3224 | 3420 | { |
| 3225 | - if (!is_writable($file)) |
|
| 3226 | - $ftp->chmod($file, 0755); |
|
| 3227 | - if (!is_writable($file)) |
|
| 3228 | - $ftp->chmod($file, 0777); |
|
| 3421 | + if (!is_writable($file)) { |
|
| 3422 | + $ftp->chmod($file, 0755); |
|
| 3423 | + } |
|
| 3424 | + if (!is_writable($file)) { |
|
| 3425 | + $ftp->chmod($file, 0777); |
|
| 3426 | + } |
|
| 3229 | 3427 | |
| 3230 | 3428 | // Assuming that didn't work calculate the path without the boarddir. |
| 3231 | 3429 | if (!is_writable($file)) |
@@ -3234,19 +3432,23 @@ discard block |
||
| 3234 | 3432 | { |
| 3235 | 3433 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
| 3236 | 3434 | $ftp->chmod($ftp_file, 0755); |
| 3237 | - if (!is_writable($file)) |
|
| 3238 | - $ftp->chmod($ftp_file, 0777); |
|
| 3435 | + if (!is_writable($file)) { |
|
| 3436 | + $ftp->chmod($ftp_file, 0777); |
|
| 3437 | + } |
|
| 3239 | 3438 | // Sometimes an extra slash can help... |
| 3240 | 3439 | $ftp_file = '/' . $ftp_file; |
| 3241 | - if (!is_writable($file)) |
|
| 3242 | - $ftp->chmod($ftp_file, 0755); |
|
| 3243 | - if (!is_writable($file)) |
|
| 3244 | - $ftp->chmod($ftp_file, 0777); |
|
| 3440 | + if (!is_writable($file)) { |
|
| 3441 | + $ftp->chmod($ftp_file, 0755); |
|
| 3442 | + } |
|
| 3443 | + if (!is_writable($file)) { |
|
| 3444 | + $ftp->chmod($ftp_file, 0777); |
|
| 3445 | + } |
|
| 3245 | 3446 | } |
| 3246 | 3447 | } |
| 3247 | 3448 | |
| 3248 | - if (is_writable($file)) |
|
| 3249 | - unset($files[$k]); |
|
| 3449 | + if (is_writable($file)) { |
|
| 3450 | + unset($files[$k]); |
|
| 3451 | + } |
|
| 3250 | 3452 | } |
| 3251 | 3453 | |
| 3252 | 3454 | $ftp->close(); |
@@ -3256,16 +3458,18 @@ discard block |
||
| 3256 | 3458 | // What remains? |
| 3257 | 3459 | $upcontext['chmod']['files'] = $files; |
| 3258 | 3460 | |
| 3259 | - if (empty($files)) |
|
| 3260 | - return true; |
|
| 3461 | + if (empty($files)) { |
|
| 3462 | + return true; |
|
| 3463 | + } |
|
| 3261 | 3464 | |
| 3262 | 3465 | return false; |
| 3263 | 3466 | } |
| 3264 | 3467 | |
| 3265 | 3468 | function quickFileWritable($file) |
| 3266 | 3469 | { |
| 3267 | - if (is_writable($file)) |
|
| 3268 | - return true; |
|
| 3470 | + if (is_writable($file)) { |
|
| 3471 | + return true; |
|
| 3472 | + } |
|
| 3269 | 3473 | |
| 3270 | 3474 | @chmod($file, 0755); |
| 3271 | 3475 | |
@@ -3275,17 +3479,19 @@ discard block |
||
| 3275 | 3479 | foreach($chmod_values as $val) |
| 3276 | 3480 | { |
| 3277 | 3481 | // If it's writable, break out of the loop |
| 3278 | - if (is_writable($file)) |
|
| 3279 | - break; |
|
| 3280 | - else |
|
| 3281 | - @chmod($file, $val); |
|
| 3482 | + if (is_writable($file)) { |
|
| 3483 | + break; |
|
| 3484 | + } else { |
|
| 3485 | + @chmod($file, $val); |
|
| 3486 | + } |
|
| 3282 | 3487 | } |
| 3283 | 3488 | } |
| 3284 | 3489 | function smf_strtolower($string) |
| 3285 | 3490 | { |
| 3286 | 3491 | global $sourcedir; |
| 3287 | - if (function_exists('mb_strtolower')) |
|
| 3288 | - return mb_strtolower($string, 'UTF-8'); |
|
| 3492 | + if (function_exists('mb_strtolower')) { |
|
| 3493 | + return mb_strtolower($string, 'UTF-8'); |
|
| 3494 | + } |
|
| 3289 | 3495 | require_once($sourcedir . '/Subs-Charset.php'); |
| 3290 | 3496 | return utf8_strtolower($string); |
| 3291 | 3497 | } |
@@ -3308,8 +3514,7 @@ discard block |
||
| 3308 | 3514 | ); |
| 3309 | 3515 | |
| 3310 | 3516 | return true; |
| 3311 | - } |
|
| 3312 | - else |
|
| 3517 | + } else |
|
| 3313 | 3518 | { |
| 3314 | 3519 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 3315 | 3520 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -3353,8 +3558,9 @@ discard block |
||
| 3353 | 3558 | ) |
| 3354 | 3559 | ); |
| 3355 | 3560 | $db_charsets = array(); |
| 3356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3357 | - $db_charsets[] = $row['Charset']; |
|
| 3561 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3562 | + $db_charsets[] = $row['Charset']; |
|
| 3563 | + } |
|
| 3358 | 3564 | |
| 3359 | 3565 | $smcFunc['db_free_result']($request); |
| 3360 | 3566 | |
@@ -3390,13 +3596,15 @@ discard block |
||
| 3390 | 3596 | // If there's a fulltext index, we need to drop it first... |
| 3391 | 3597 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 3392 | 3598 | { |
| 3393 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3394 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 3599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3600 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 3395 | 3601 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 3602 | + } |
|
| 3396 | 3603 | $smcFunc['db_free_result']($request); |
| 3397 | 3604 | |
| 3398 | - if (isset($upcontext['fulltext_index'])) |
|
| 3399 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 3605 | + if (isset($upcontext['fulltext_index'])) { |
|
| 3606 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 3607 | + } |
|
| 3400 | 3608 | } |
| 3401 | 3609 | |
| 3402 | 3610 | // Drop it and make a note... |
@@ -3588,8 +3796,9 @@ discard block |
||
| 3588 | 3796 | $replace = '%field%'; |
| 3589 | 3797 | |
| 3590 | 3798 | // Build a huge REPLACE statement... |
| 3591 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 3592 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3799 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3800 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3801 | + } |
|
| 3593 | 3802 | } |
| 3594 | 3803 | |
| 3595 | 3804 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -3623,8 +3832,9 @@ discard block |
||
| 3623 | 3832 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3624 | 3833 | |
| 3625 | 3834 | // Just to make sure it doesn't time out. |
| 3626 | - if (function_exists('apache_reset_timeout')) |
|
| 3627 | - @apache_reset_timeout(); |
|
| 3835 | + if (function_exists('apache_reset_timeout')) { |
|
| 3836 | + @apache_reset_timeout(); |
|
| 3837 | + } |
|
| 3628 | 3838 | |
| 3629 | 3839 | $table_charsets = array(); |
| 3630 | 3840 | |
@@ -3645,8 +3855,9 @@ discard block |
||
| 3645 | 3855 | { |
| 3646 | 3856 | list($charset) = explode('_', $collation); |
| 3647 | 3857 | |
| 3648 | - if (!isset($table_charsets[$charset])) |
|
| 3649 | - $table_charsets[$charset] = array(); |
|
| 3858 | + if (!isset($table_charsets[$charset])) { |
|
| 3859 | + $table_charsets[$charset] = array(); |
|
| 3860 | + } |
|
| 3650 | 3861 | |
| 3651 | 3862 | $table_charsets[$charset][] = $column_info; |
| 3652 | 3863 | } |
@@ -3686,10 +3897,11 @@ discard block |
||
| 3686 | 3897 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 3687 | 3898 | { |
| 3688 | 3899 | $update = ''; |
| 3689 | - foreach ($table_charsets as $charset => $columns) |
|
| 3690 | - foreach ($columns as $column) |
|
| 3900 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3901 | + foreach ($columns as $column) |
|
| 3691 | 3902 | $update .= ' |
| 3692 | 3903 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3904 | + } |
|
| 3693 | 3905 | |
| 3694 | 3906 | $smcFunc['db_query']('', ' |
| 3695 | 3907 | UPDATE {raw:table_name} |
@@ -3714,8 +3926,9 @@ discard block |
||
| 3714 | 3926 | // Now do the actual conversion (if still needed). |
| 3715 | 3927 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 3716 | 3928 | { |
| 3717 | - if ($command_line) |
|
| 3718 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3929 | + if ($command_line) { |
|
| 3930 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3931 | + } |
|
| 3719 | 3932 | |
| 3720 | 3933 | $smcFunc['db_query']('', ' |
| 3721 | 3934 | ALTER TABLE {raw:table_name} |
@@ -3725,8 +3938,9 @@ discard block |
||
| 3725 | 3938 | ) |
| 3726 | 3939 | ); |
| 3727 | 3940 | |
| 3728 | - if ($command_line) |
|
| 3729 | - echo " done.\n"; |
|
| 3941 | + if ($command_line) { |
|
| 3942 | + echo " done.\n"; |
|
| 3943 | + } |
|
| 3730 | 3944 | } |
| 3731 | 3945 | } |
| 3732 | 3946 | |
@@ -3756,8 +3970,8 @@ discard block |
||
| 3756 | 3970 | ); |
| 3757 | 3971 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3758 | 3972 | { |
| 3759 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 3760 | - $smcFunc['db_query']('', ' |
|
| 3973 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3974 | + $smcFunc['db_query']('', ' |
|
| 3761 | 3975 | UPDATE {db_prefix}log_actions |
| 3762 | 3976 | SET extra = {string:extra} |
| 3763 | 3977 | WHERE id_action = {int:current_action}', |
@@ -3766,6 +3980,7 @@ discard block |
||
| 3766 | 3980 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3767 | 3981 | ) |
| 3768 | 3982 | ); |
| 3983 | + } |
|
| 3769 | 3984 | } |
| 3770 | 3985 | $smcFunc['db_free_result']($request); |
| 3771 | 3986 | |
@@ -3787,15 +4002,17 @@ discard block |
||
| 3787 | 4002 | // First thing's first - did we already do this? |
| 3788 | 4003 | if (!empty($modSettings['json_done'])) |
| 3789 | 4004 | { |
| 3790 | - if ($command_line) |
|
| 3791 | - return DeleteUpgrade(); |
|
| 3792 | - else |
|
| 3793 | - return true; |
|
| 4005 | + if ($command_line) { |
|
| 4006 | + return DeleteUpgrade(); |
|
| 4007 | + } else { |
|
| 4008 | + return true; |
|
| 4009 | + } |
|
| 3794 | 4010 | } |
| 3795 | 4011 | |
| 3796 | 4012 | // Done it already - js wise? |
| 3797 | - if (!empty($_POST['json_done'])) |
|
| 3798 | - return true; |
|
| 4013 | + if (!empty($_POST['json_done'])) { |
|
| 4014 | + return true; |
|
| 4015 | + } |
|
| 3799 | 4016 | |
| 3800 | 4017 | // List of tables affected by this function |
| 3801 | 4018 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3827,12 +4044,14 @@ discard block |
||
| 3827 | 4044 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3828 | 4045 | $file_steps = $upcontext['table_count']; |
| 3829 | 4046 | |
| 3830 | - foreach($keys as $id => $table) |
|
| 3831 | - if ($id < $_GET['substep']) |
|
| 4047 | + foreach($keys as $id => $table) { |
|
| 4048 | + if ($id < $_GET['substep']) |
|
| 3832 | 4049 | $upcontext['previous_tables'][] = $table; |
| 4050 | + } |
|
| 3833 | 4051 | |
| 3834 | - if ($command_line) |
|
| 3835 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 4052 | + if ($command_line) { |
|
| 4053 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 4054 | + } |
|
| 3836 | 4055 | |
| 3837 | 4056 | if (!$support_js || isset($_GET['xml'])) |
| 3838 | 4057 | { |
@@ -3872,8 +4091,9 @@ discard block |
||
| 3872 | 4091 | |
| 3873 | 4092 | // Loop through and fix these... |
| 3874 | 4093 | $new_settings = array(); |
| 3875 | - if ($command_line) |
|
| 3876 | - echo "\n" . 'Fixing some settings...'; |
|
| 4094 | + if ($command_line) { |
|
| 4095 | + echo "\n" . 'Fixing some settings...'; |
|
| 4096 | + } |
|
| 3877 | 4097 | |
| 3878 | 4098 | foreach ($serialized_settings as $var) |
| 3879 | 4099 | { |
@@ -3881,22 +4101,24 @@ discard block |
||
| 3881 | 4101 | { |
| 3882 | 4102 | // Attempt to unserialize the setting |
| 3883 | 4103 | $temp = @safe_unserialize($modSettings[$var]); |
| 3884 | - if (!$temp && $command_line) |
|
| 3885 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3886 | - elseif ($temp !== false) |
|
| 3887 | - $new_settings[$var] = json_encode($temp); |
|
| 4104 | + if (!$temp && $command_line) { |
|
| 4105 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 4106 | + } elseif ($temp !== false) { |
|
| 4107 | + $new_settings[$var] = json_encode($temp); |
|
| 4108 | + } |
|
| 3888 | 4109 | } |
| 3889 | 4110 | } |
| 3890 | 4111 | |
| 3891 | 4112 | // Update everything at once |
| 3892 | - if (!function_exists('cache_put_data')) |
|
| 3893 | - require_once($sourcedir . '/Load.php'); |
|
| 4113 | + if (!function_exists('cache_put_data')) { |
|
| 4114 | + require_once($sourcedir . '/Load.php'); |
|
| 4115 | + } |
|
| 3894 | 4116 | updateSettings($new_settings, true); |
| 3895 | 4117 | |
| 3896 | - if ($command_line) |
|
| 3897 | - echo ' done.'; |
|
| 3898 | - } |
|
| 3899 | - elseif ($table == 'themes') |
|
| 4118 | + if ($command_line) { |
|
| 4119 | + echo ' done.'; |
|
| 4120 | + } |
|
| 4121 | + } elseif ($table == 'themes') |
|
| 3900 | 4122 | { |
| 3901 | 4123 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3902 | 4124 | $query = $smcFunc['db_query']('', ' |
@@ -3915,10 +4137,11 @@ discard block |
||
| 3915 | 4137 | |
| 3916 | 4138 | if ($command_line) |
| 3917 | 4139 | { |
| 3918 | - if ($temp === false) |
|
| 3919 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3920 | - else |
|
| 3921 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 4140 | + if ($temp === false) { |
|
| 4141 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 4142 | + } else { |
|
| 4143 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 4144 | + } |
|
| 3922 | 4145 | } |
| 3923 | 4146 | |
| 3924 | 4147 | if ($temp !== false) |
@@ -3938,15 +4161,15 @@ discard block |
||
| 3938 | 4161 | ) |
| 3939 | 4162 | ); |
| 3940 | 4163 | |
| 3941 | - if ($command_line) |
|
| 3942 | - echo ' done.'; |
|
| 4164 | + if ($command_line) { |
|
| 4165 | + echo ' done.'; |
|
| 4166 | + } |
|
| 3943 | 4167 | } |
| 3944 | 4168 | } |
| 3945 | 4169 | |
| 3946 | 4170 | $smcFunc['db_free_result']($query); |
| 3947 | 4171 | } |
| 3948 | - } |
|
| 3949 | - else |
|
| 4172 | + } else |
|
| 3950 | 4173 | { |
| 3951 | 4174 | // First item is always the key... |
| 3952 | 4175 | $key = $info[0]; |
@@ -3957,8 +4180,7 @@ discard block |
||
| 3957 | 4180 | { |
| 3958 | 4181 | $col_select = $info[1]; |
| 3959 | 4182 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3960 | - } |
|
| 3961 | - else |
|
| 4183 | + } else |
|
| 3962 | 4184 | { |
| 3963 | 4185 | $col_select = implode(', ', $info); |
| 3964 | 4186 | } |
@@ -3991,8 +4213,7 @@ discard block |
||
| 3991 | 4213 | if ($temp === false && $command_line) |
| 3992 | 4214 | { |
| 3993 | 4215 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3994 | - } |
|
| 3995 | - else |
|
| 4216 | + } else |
|
| 3996 | 4217 | { |
| 3997 | 4218 | $row[$col] = json_encode($temp); |
| 3998 | 4219 | |
@@ -4017,16 +4238,18 @@ discard block |
||
| 4017 | 4238 | } |
| 4018 | 4239 | } |
| 4019 | 4240 | |
| 4020 | - if ($command_line) |
|
| 4021 | - echo ' done.'; |
|
| 4241 | + if ($command_line) { |
|
| 4242 | + echo ' done.'; |
|
| 4243 | + } |
|
| 4022 | 4244 | |
| 4023 | 4245 | // Free up some memory... |
| 4024 | 4246 | $smcFunc['db_free_result']($query); |
| 4025 | 4247 | } |
| 4026 | 4248 | } |
| 4027 | 4249 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 4028 | - if (isset($_GET['xml'])) |
|
| 4029 | - return upgradeExit(); |
|
| 4250 | + if (isset($_GET['xml'])) { |
|
| 4251 | + return upgradeExit(); |
|
| 4252 | + } |
|
| 4030 | 4253 | } |
| 4031 | 4254 | |
| 4032 | 4255 | if ($command_line) |
@@ -4041,8 +4264,9 @@ discard block |
||
| 4041 | 4264 | |
| 4042 | 4265 | $_GET['substep'] = 0; |
| 4043 | 4266 | // Make sure we move on! |
| 4044 | - if ($command_line) |
|
| 4045 | - return DeleteUpgrade(); |
|
| 4267 | + if ($command_line) { |
|
| 4268 | + return DeleteUpgrade(); |
|
| 4269 | + } |
|
| 4046 | 4270 | |
| 4047 | 4271 | return true; |
| 4048 | 4272 | } |
@@ -4062,14 +4286,16 @@ discard block |
||
| 4062 | 4286 | global $upcontext, $txt, $settings; |
| 4063 | 4287 | |
| 4064 | 4288 | // Don't call me twice! |
| 4065 | - if (!empty($upcontext['chmod_called'])) |
|
| 4066 | - return; |
|
| 4289 | + if (!empty($upcontext['chmod_called'])) { |
|
| 4290 | + return; |
|
| 4291 | + } |
|
| 4067 | 4292 | |
| 4068 | 4293 | $upcontext['chmod_called'] = true; |
| 4069 | 4294 | |
| 4070 | 4295 | // Nothing? |
| 4071 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 4072 | - return; |
|
| 4296 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 4297 | + return; |
|
| 4298 | + } |
|
| 4073 | 4299 | |
| 4074 | 4300 | // Was it a problem with Windows? |
| 4075 | 4301 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -4101,11 +4327,12 @@ discard block |
||
| 4101 | 4327 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 4102 | 4328 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 4103 | 4329 | |
| 4104 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 4105 | - echo ' |
|
| 4330 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 4331 | + echo ' |
|
| 4106 | 4332 | content.write(\'<hr>\n\t\t\t\'); |
| 4107 | 4333 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 4108 | 4334 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 4335 | + } |
|
| 4109 | 4336 | |
| 4110 | 4337 | echo ' |
| 4111 | 4338 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -4113,17 +4340,19 @@ discard block |
||
| 4113 | 4340 | } |
| 4114 | 4341 | </script>'; |
| 4115 | 4342 | |
| 4116 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 4117 | - echo ' |
|
| 4343 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 4344 | + echo ' |
|
| 4118 | 4345 | <div class="error_message red"> |
| 4119 | 4346 | The following error was encountered when trying to connect:<br><br> |
| 4120 | 4347 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 4121 | 4348 | </div> |
| 4122 | 4349 | <br>'; |
| 4350 | + } |
|
| 4123 | 4351 | |
| 4124 | - if (empty($upcontext['chmod_in_form'])) |
|
| 4125 | - echo ' |
|
| 4352 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 4353 | + echo ' |
|
| 4126 | 4354 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 4355 | + } |
|
| 4127 | 4356 | |
| 4128 | 4357 | echo ' |
| 4129 | 4358 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -4158,10 +4387,11 @@ discard block |
||
| 4158 | 4387 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 4159 | 4388 | </div>'; |
| 4160 | 4389 | |
| 4161 | - if (empty($upcontext['chmod_in_form'])) |
|
| 4162 | - echo ' |
|
| 4390 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 4391 | + echo ' |
|
| 4163 | 4392 | </form>'; |
| 4164 | -} |
|
| 4393 | + } |
|
| 4394 | + } |
|
| 4165 | 4395 | |
| 4166 | 4396 | function template_upgrade_above() |
| 4167 | 4397 | { |
@@ -4221,9 +4451,10 @@ discard block |
||
| 4221 | 4451 | <h2>', $txt['upgrade_progress'], '</h2> |
| 4222 | 4452 | <ul>'; |
| 4223 | 4453 | |
| 4224 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 4225 | - echo ' |
|
| 4454 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 4455 | + echo ' |
|
| 4226 | 4456 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 4457 | + } |
|
| 4227 | 4458 | |
| 4228 | 4459 | echo ' |
| 4229 | 4460 | </ul> |
@@ -4236,8 +4467,8 @@ discard block |
||
| 4236 | 4467 | </div> |
| 4237 | 4468 | </div>'; |
| 4238 | 4469 | |
| 4239 | - if (isset($upcontext['step_progress'])) |
|
| 4240 | - echo ' |
|
| 4470 | + if (isset($upcontext['step_progress'])) { |
|
| 4471 | + echo ' |
|
| 4241 | 4472 | <br> |
| 4242 | 4473 | <br> |
| 4243 | 4474 | <div id="progress_bar_step"> |
@@ -4246,6 +4477,7 @@ discard block |
||
| 4246 | 4477 | <span>', $txt['upgrade_step_progress'], '</span> |
| 4247 | 4478 | </div> |
| 4248 | 4479 | </div>'; |
| 4480 | + } |
|
| 4249 | 4481 | |
| 4250 | 4482 | echo ' |
| 4251 | 4483 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -4276,32 +4508,36 @@ discard block |
||
| 4276 | 4508 | { |
| 4277 | 4509 | global $upcontext, $txt; |
| 4278 | 4510 | |
| 4279 | - if (!empty($upcontext['pause'])) |
|
| 4280 | - echo ' |
|
| 4511 | + if (!empty($upcontext['pause'])) { |
|
| 4512 | + echo ' |
|
| 4281 | 4513 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 4282 | 4514 | |
| 4283 | 4515 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 4284 | 4516 | <h3> |
| 4285 | 4517 | ', $txt['upgrade_paused_overload'], ' |
| 4286 | 4518 | </h3>'; |
| 4519 | + } |
|
| 4287 | 4520 | |
| 4288 | - if (!empty($upcontext['custom_warning'])) |
|
| 4289 | - echo ' |
|
| 4521 | + if (!empty($upcontext['custom_warning'])) { |
|
| 4522 | + echo ' |
|
| 4290 | 4523 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 4291 | 4524 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 4292 | 4525 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 4293 | 4526 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 4294 | 4527 | </div>'; |
| 4528 | + } |
|
| 4295 | 4529 | |
| 4296 | 4530 | echo ' |
| 4297 | 4531 | <div class="righttext" style="margin: 1ex;">'; |
| 4298 | 4532 | |
| 4299 | - if (!empty($upcontext['continue'])) |
|
| 4300 | - echo ' |
|
| 4533 | + if (!empty($upcontext['continue'])) { |
|
| 4534 | + echo ' |
|
| 4301 | 4535 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 4302 | - if (!empty($upcontext['skip'])) |
|
| 4303 | - echo ' |
|
| 4536 | + } |
|
| 4537 | + if (!empty($upcontext['skip'])) { |
|
| 4538 | + echo ' |
|
| 4304 | 4539 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 4540 | + } |
|
| 4305 | 4541 | |
| 4306 | 4542 | echo ' |
| 4307 | 4543 | </div> |
@@ -4351,11 +4587,12 @@ discard block |
||
| 4351 | 4587 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 4352 | 4588 | <smf>'; |
| 4353 | 4589 | |
| 4354 | - if (!empty($upcontext['get_data'])) |
|
| 4355 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 4590 | + if (!empty($upcontext['get_data'])) { |
|
| 4591 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 4356 | 4592 | echo ' |
| 4357 | 4593 | <get key="', $k, '">', $v, '</get>'; |
| 4358 | -} |
|
| 4594 | + } |
|
| 4595 | + } |
|
| 4359 | 4596 | |
| 4360 | 4597 | function template_xml_below() |
| 4361 | 4598 | { |
@@ -4396,8 +4633,8 @@ discard block |
||
| 4396 | 4633 | template_chmod(); |
| 4397 | 4634 | |
| 4398 | 4635 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 4399 | - if ($upcontext['is_large_forum']) |
|
| 4400 | - echo ' |
|
| 4636 | + if ($upcontext['is_large_forum']) { |
|
| 4637 | + echo ' |
|
| 4401 | 4638 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 4402 | 4639 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 4403 | 4640 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4405,10 +4642,11 @@ discard block |
||
| 4405 | 4642 | ', $txt['upgrade_warning_lots_data'], ' |
| 4406 | 4643 | </div> |
| 4407 | 4644 | </div>'; |
| 4645 | + } |
|
| 4408 | 4646 | |
| 4409 | 4647 | // A warning message? |
| 4410 | - if (!empty($upcontext['warning'])) |
|
| 4411 | - echo ' |
|
| 4648 | + if (!empty($upcontext['warning'])) { |
|
| 4649 | + echo ' |
|
| 4412 | 4650 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 4413 | 4651 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 4414 | 4652 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4416,6 +4654,7 @@ discard block |
||
| 4416 | 4654 | ', $upcontext['warning'], ' |
| 4417 | 4655 | </div> |
| 4418 | 4656 | </div>'; |
| 4657 | + } |
|
| 4419 | 4658 | |
| 4420 | 4659 | // Paths are incorrect? |
| 4421 | 4660 | echo ' |
@@ -4431,20 +4670,22 @@ discard block |
||
| 4431 | 4670 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 4432 | 4671 | { |
| 4433 | 4672 | $ago = time() - $upcontext['started']; |
| 4434 | - if ($ago < 60) |
|
| 4435 | - $ago = $ago . ' seconds'; |
|
| 4436 | - elseif ($ago < 3600) |
|
| 4437 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 4438 | - else |
|
| 4439 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 4673 | + if ($ago < 60) { |
|
| 4674 | + $ago = $ago . ' seconds'; |
|
| 4675 | + } elseif ($ago < 3600) { |
|
| 4676 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 4677 | + } else { |
|
| 4678 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 4679 | + } |
|
| 4440 | 4680 | |
| 4441 | 4681 | $active = time() - $upcontext['updated']; |
| 4442 | - if ($active < 60) |
|
| 4443 | - $updated = $active . ' seconds'; |
|
| 4444 | - elseif ($active < 3600) |
|
| 4445 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 4446 | - else |
|
| 4447 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 4682 | + if ($active < 60) { |
|
| 4683 | + $updated = $active . ' seconds'; |
|
| 4684 | + } elseif ($active < 3600) { |
|
| 4685 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 4686 | + } else { |
|
| 4687 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 4688 | + } |
|
| 4448 | 4689 | |
| 4449 | 4690 | echo ' |
| 4450 | 4691 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -4453,16 +4694,18 @@ discard block |
||
| 4453 | 4694 | <div style="padding-left: 6ex;"> |
| 4454 | 4695 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 4455 | 4696 | |
| 4456 | - if ($active < 600) |
|
| 4457 | - echo ' |
|
| 4697 | + if ($active < 600) { |
|
| 4698 | + echo ' |
|
| 4458 | 4699 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 4700 | + } |
|
| 4459 | 4701 | |
| 4460 | - if ($active > $upcontext['inactive_timeout']) |
|
| 4461 | - echo ' |
|
| 4702 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 4703 | + echo ' |
|
| 4462 | 4704 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 4463 | - else |
|
| 4464 | - echo ' |
|
| 4705 | + } else { |
|
| 4706 | + echo ' |
|
| 4465 | 4707 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 4708 | + } |
|
| 4466 | 4709 | |
| 4467 | 4710 | echo ' |
| 4468 | 4711 | </div> |
@@ -4478,9 +4721,10 @@ discard block |
||
| 4478 | 4721 | <td> |
| 4479 | 4722 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 4480 | 4723 | |
| 4481 | - if (!empty($upcontext['username_incorrect'])) |
|
| 4482 | - echo ' |
|
| 4724 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4725 | + echo ' |
|
| 4483 | 4726 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 4727 | + } |
|
| 4484 | 4728 | |
| 4485 | 4729 | echo ' |
| 4486 | 4730 | </td> |
@@ -4491,9 +4735,10 @@ discard block |
||
| 4491 | 4735 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 4492 | 4736 | <input type="hidden" name="hash_passwrd" value="">'; |
| 4493 | 4737 | |
| 4494 | - if (!empty($upcontext['password_failed'])) |
|
| 4495 | - echo ' |
|
| 4738 | + if (!empty($upcontext['password_failed'])) { |
|
| 4739 | + echo ' |
|
| 4496 | 4740 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 4741 | + } |
|
| 4497 | 4742 | |
| 4498 | 4743 | echo ' |
| 4499 | 4744 | </td> |
@@ -4564,8 +4809,8 @@ discard block |
||
| 4564 | 4809 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 4565 | 4810 | |
| 4566 | 4811 | // Warning message? |
| 4567 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 4568 | - echo ' |
|
| 4812 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4813 | + echo ' |
|
| 4569 | 4814 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 4570 | 4815 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 4571 | 4816 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -4573,6 +4818,7 @@ discard block |
||
| 4573 | 4818 | ', $upcontext['upgrade_options_warning'], ' |
| 4574 | 4819 | </div> |
| 4575 | 4820 | </div>'; |
| 4821 | + } |
|
| 4576 | 4822 | |
| 4577 | 4823 | echo ' |
| 4578 | 4824 | <table> |
@@ -4600,8 +4846,8 @@ discard block |
||
| 4600 | 4846 | </tr>'; |
| 4601 | 4847 | |
| 4602 | 4848 | // Offer mysql users to switch to mysqli |
| 4603 | - if ($db_type == 'mysql' && function_exists('mysqli_query')) |
|
| 4604 | - echo ' |
|
| 4849 | + if ($db_type == 'mysql' && function_exists('mysqli_query')) { |
|
| 4850 | + echo ' |
|
| 4605 | 4851 | <tr valign="top"> |
| 4606 | 4852 | <td width="2%"> |
| 4607 | 4853 | <input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check"> |
@@ -4611,6 +4857,7 @@ discard block |
||
| 4611 | 4857 | <strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br> |
| 4612 | 4858 | </td> |
| 4613 | 4859 | </tr>'; |
| 4860 | + } |
|
| 4614 | 4861 | |
| 4615 | 4862 | echo ' |
| 4616 | 4863 | <tr valign="top"> |
@@ -4630,8 +4877,8 @@ discard block |
||
| 4630 | 4877 | </td> |
| 4631 | 4878 | </tr>'; |
| 4632 | 4879 | |
| 4633 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 4634 | - echo ' |
|
| 4880 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4881 | + echo ' |
|
| 4635 | 4882 | <tr valign="top"> |
| 4636 | 4883 | <td width="2%"> |
| 4637 | 4884 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -4640,6 +4887,7 @@ discard block |
||
| 4640 | 4887 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 4641 | 4888 | </td> |
| 4642 | 4889 | </tr>'; |
| 4890 | + } |
|
| 4643 | 4891 | |
| 4644 | 4892 | echo ' |
| 4645 | 4893 | <tr valign="top"> |
@@ -4675,10 +4923,11 @@ discard block |
||
| 4675 | 4923 | <span id="debuginfo"></span>'; |
| 4676 | 4924 | |
| 4677 | 4925 | // Dont any tables so far? |
| 4678 | - if (!empty($upcontext['previous_tables'])) |
|
| 4679 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4926 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4927 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4680 | 4928 | echo ' |
| 4681 | 4929 | <br>Completed Table: "', $table, '".'; |
| 4930 | + } |
|
| 4682 | 4931 | |
| 4683 | 4932 | echo ' |
| 4684 | 4933 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -4715,12 +4964,13 @@ discard block |
||
| 4715 | 4964 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4716 | 4965 | |
| 4717 | 4966 | // If debug flood the screen. |
| 4718 | - if ($is_debug) |
|
| 4719 | - echo ' |
|
| 4967 | + if ($is_debug) { |
|
| 4968 | + echo ' |
|
| 4720 | 4969 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4721 | 4970 | |
| 4722 | 4971 | if (document.getElementById(\'debuginfo\').scrollHeight) |
| 4723 | 4972 | document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;'; |
| 4973 | + } |
|
| 4724 | 4974 | |
| 4725 | 4975 | echo ' |
| 4726 | 4976 | // Get the next update... |
@@ -4752,8 +5002,9 @@ discard block |
||
| 4752 | 5002 | { |
| 4753 | 5003 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 4754 | 5004 | |
| 4755 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4756 | - $is_debug = true; |
|
| 5005 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 5006 | + $is_debug = true; |
|
| 5007 | + } |
|
| 4757 | 5008 | |
| 4758 | 5009 | echo ' |
| 4759 | 5010 | <h3>Executing database changes</h3> |
@@ -4768,8 +5019,9 @@ discard block |
||
| 4768 | 5019 | { |
| 4769 | 5020 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4770 | 5021 | { |
| 4771 | - if ($num != 0) |
|
| 4772 | - echo ' Successful!'; |
|
| 5022 | + if ($num != 0) { |
|
| 5023 | + echo ' Successful!'; |
|
| 5024 | + } |
|
| 4773 | 5025 | echo '<br>' . $item; |
| 4774 | 5026 | } |
| 4775 | 5027 | if (!empty($upcontext['changes_complete'])) |
@@ -4782,28 +5034,32 @@ discard block |
||
| 4782 | 5034 | $seconds = intval($active % 60); |
| 4783 | 5035 | |
| 4784 | 5036 | $totalTime = ''; |
| 4785 | - if ($hours > 0) |
|
| 4786 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 4787 | - if ($minutes > 0) |
|
| 4788 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 4789 | - if ($seconds > 0) |
|
| 4790 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 5037 | + if ($hours > 0) { |
|
| 5038 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 5039 | + } |
|
| 5040 | + if ($minutes > 0) { |
|
| 5041 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 5042 | + } |
|
| 5043 | + if ($seconds > 0) { |
|
| 5044 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 5045 | + } |
|
| 4791 | 5046 | } |
| 4792 | 5047 | |
| 4793 | - if ($is_debug && !empty($totalTime)) |
|
| 4794 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4795 | - else |
|
| 4796 | - echo ' Successful!<br><br>'; |
|
| 5048 | + if ($is_debug && !empty($totalTime)) { |
|
| 5049 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 5050 | + } else { |
|
| 5051 | + echo ' Successful!<br><br>'; |
|
| 5052 | + } |
|
| 4797 | 5053 | |
| 4798 | 5054 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 4799 | 5055 | } |
| 4800 | - } |
|
| 4801 | - else |
|
| 5056 | + } else |
|
| 4802 | 5057 | { |
| 4803 | 5058 | // Tell them how many files we have in total. |
| 4804 | - if ($upcontext['file_count'] > 1) |
|
| 4805 | - echo ' |
|
| 5059 | + if ($upcontext['file_count'] > 1) { |
|
| 5060 | + echo ' |
|
| 4806 | 5061 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 5062 | + } |
|
| 4807 | 5063 | |
| 4808 | 5064 | echo ' |
| 4809 | 5065 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -4819,19 +5075,23 @@ discard block |
||
| 4819 | 5075 | $seconds = intval($active % 60); |
| 4820 | 5076 | |
| 4821 | 5077 | $totalTime = ''; |
| 4822 | - if ($hours > 0) |
|
| 4823 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 4824 | - if ($minutes > 0) |
|
| 4825 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 4826 | - if ($seconds > 0) |
|
| 4827 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 5078 | + if ($hours > 0) { |
|
| 5079 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 5080 | + } |
|
| 5081 | + if ($minutes > 0) { |
|
| 5082 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 5083 | + } |
|
| 5084 | + if ($seconds > 0) { |
|
| 5085 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 5086 | + } |
|
| 4828 | 5087 | } |
| 4829 | 5088 | |
| 4830 | 5089 | echo ' |
| 4831 | 5090 | <br><span id="upgradeCompleted">'; |
| 4832 | 5091 | |
| 4833 | - if (!empty($totalTime)) |
|
| 4834 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 5092 | + if (!empty($totalTime)) { |
|
| 5093 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 5094 | + } |
|
| 4835 | 5095 | |
| 4836 | 5096 | echo '</span> |
| 4837 | 5097 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -4868,9 +5128,10 @@ discard block |
||
| 4868 | 5128 | var getData = ""; |
| 4869 | 5129 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4870 | 5130 | |
| 4871 | - if ($is_debug) |
|
| 4872 | - echo ' |
|
| 5131 | + if ($is_debug) { |
|
| 5132 | + echo ' |
|
| 4873 | 5133 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 5134 | + } |
|
| 4874 | 5135 | |
| 4875 | 5136 | echo ' |
| 4876 | 5137 | function getNextItem() |
@@ -4910,9 +5171,10 @@ discard block |
||
| 4910 | 5171 | document.getElementById("error_block").style.display = ""; |
| 4911 | 5172 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4912 | 5173 | |
| 4913 | - if ($is_debug) |
|
| 4914 | - echo ' |
|
| 5174 | + if ($is_debug) { |
|
| 5175 | + echo ' |
|
| 4915 | 5176 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 5177 | + } |
|
| 4916 | 5178 | |
| 4917 | 5179 | echo ' |
| 4918 | 5180 | } |
@@ -4933,9 +5195,10 @@ discard block |
||
| 4933 | 5195 | document.getElementById("error_block").style.display = ""; |
| 4934 | 5196 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4935 | 5197 | |
| 4936 | - if ($is_debug) |
|
| 4937 | - echo ' |
|
| 5198 | + if ($is_debug) { |
|
| 5199 | + echo ' |
|
| 4938 | 5200 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 5201 | + } |
|
| 4939 | 5202 | |
| 4940 | 5203 | echo ' |
| 4941 | 5204 | } |
@@ -4994,8 +5257,8 @@ discard block |
||
| 4994 | 5257 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4995 | 5258 | {'; |
| 4996 | 5259 | |
| 4997 | - if ($is_debug) |
|
| 4998 | - echo ' |
|
| 5260 | + if ($is_debug) { |
|
| 5261 | + echo ' |
|
| 4999 | 5262 | document.getElementById(\'debug_section\').style.display = "none"; |
| 5000 | 5263 | |
| 5001 | 5264 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -5013,6 +5276,7 @@ discard block |
||
| 5013 | 5276 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 5014 | 5277 | |
| 5015 | 5278 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 5279 | + } |
|
| 5016 | 5280 | |
| 5017 | 5281 | echo ' |
| 5018 | 5282 | |
@@ -5020,9 +5284,10 @@ discard block |
||
| 5020 | 5284 | document.getElementById(\'contbutt\').disabled = 0; |
| 5021 | 5285 | document.getElementById(\'database_done\').value = 1;'; |
| 5022 | 5286 | |
| 5023 | - if ($upcontext['file_count'] > 1) |
|
| 5024 | - echo ' |
|
| 5287 | + if ($upcontext['file_count'] > 1) { |
|
| 5288 | + echo ' |
|
| 5025 | 5289 | document.getElementById(\'info1\').style.display = "none";'; |
| 5290 | + } |
|
| 5026 | 5291 | |
| 5027 | 5292 | echo ' |
| 5028 | 5293 | document.getElementById(\'info2\').style.display = "none"; |
@@ -5035,9 +5300,10 @@ discard block |
||
| 5035 | 5300 | lastItem = 0; |
| 5036 | 5301 | prevFile = curFile;'; |
| 5037 | 5302 | |
| 5038 | - if ($is_debug) |
|
| 5039 | - echo ' |
|
| 5303 | + if ($is_debug) { |
|
| 5304 | + echo ' |
|
| 5040 | 5305 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 5306 | + } |
|
| 5041 | 5307 | |
| 5042 | 5308 | echo ' |
| 5043 | 5309 | getNextItem(); |
@@ -5045,8 +5311,8 @@ discard block |
||
| 5045 | 5311 | }'; |
| 5046 | 5312 | |
| 5047 | 5313 | // If debug scroll the screen. |
| 5048 | - if ($is_debug) |
|
| 5049 | - echo ' |
|
| 5314 | + if ($is_debug) { |
|
| 5315 | + echo ' |
|
| 5050 | 5316 | if (iLastSubStepProgress == -1) |
| 5051 | 5317 | { |
| 5052 | 5318 | // Give it consistent dots. |
@@ -5065,6 +5331,7 @@ discard block |
||
| 5065 | 5331 | |
| 5066 | 5332 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 5067 | 5333 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 5334 | + } |
|
| 5068 | 5335 | |
| 5069 | 5336 | echo ' |
| 5070 | 5337 | // Update the page. |
@@ -5125,9 +5392,10 @@ discard block |
||
| 5125 | 5392 | }'; |
| 5126 | 5393 | |
| 5127 | 5394 | // Start things off assuming we've not errored. |
| 5128 | - if (empty($upcontext['error_message'])) |
|
| 5129 | - echo ' |
|
| 5395 | + if (empty($upcontext['error_message'])) { |
|
| 5396 | + echo ' |
|
| 5130 | 5397 | getNextItem();'; |
| 5398 | + } |
|
| 5131 | 5399 | |
| 5132 | 5400 | echo ' |
| 5133 | 5401 | </script>'; |
@@ -5144,18 +5412,21 @@ discard block |
||
| 5144 | 5412 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 5145 | 5413 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 5146 | 5414 | |
| 5147 | - if (!empty($upcontext['error_message'])) |
|
| 5148 | - echo ' |
|
| 5415 | + if (!empty($upcontext['error_message'])) { |
|
| 5416 | + echo ' |
|
| 5149 | 5417 | <error>', $upcontext['error_message'], '</error>'; |
| 5418 | + } |
|
| 5150 | 5419 | |
| 5151 | - if (!empty($upcontext['error_string'])) |
|
| 5152 | - echo ' |
|
| 5420 | + if (!empty($upcontext['error_string'])) { |
|
| 5421 | + echo ' |
|
| 5153 | 5422 | <sql>', $upcontext['error_string'], '</sql>'; |
| 5423 | + } |
|
| 5154 | 5424 | |
| 5155 | - if ($is_debug) |
|
| 5156 | - echo ' |
|
| 5425 | + if ($is_debug) { |
|
| 5426 | + echo ' |
|
| 5157 | 5427 | <curtime>', time(), '</curtime>'; |
| 5158 | -} |
|
| 5428 | + } |
|
| 5429 | + } |
|
| 5159 | 5430 | |
| 5160 | 5431 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 5161 | 5432 | function template_convert_utf8() |
@@ -5172,18 +5443,20 @@ discard block |
||
| 5172 | 5443 | <span id="debuginfo"></span>'; |
| 5173 | 5444 | |
| 5174 | 5445 | // Done any tables so far? |
| 5175 | - if (!empty($upcontext['previous_tables'])) |
|
| 5176 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 5446 | + if (!empty($upcontext['previous_tables'])) { |
|
| 5447 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 5177 | 5448 | echo ' |
| 5178 | 5449 | <br>Completed Table: "', $table, '".'; |
| 5450 | + } |
|
| 5179 | 5451 | |
| 5180 | 5452 | echo ' |
| 5181 | 5453 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 5182 | 5454 | |
| 5183 | 5455 | // If we dropped their index, let's let them know |
| 5184 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
| 5185 | - echo ' |
|
| 5456 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
| 5457 | + echo ' |
|
| 5186 | 5458 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
| 5459 | + } |
|
| 5187 | 5460 | |
| 5188 | 5461 | echo ' |
| 5189 | 5462 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -5219,9 +5492,10 @@ discard block |
||
| 5219 | 5492 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 5220 | 5493 | |
| 5221 | 5494 | // If debug flood the screen. |
| 5222 | - if ($is_debug) |
|
| 5223 | - echo ' |
|
| 5495 | + if ($is_debug) { |
|
| 5496 | + echo ' |
|
| 5224 | 5497 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 5498 | + } |
|
| 5225 | 5499 | |
| 5226 | 5500 | echo ' |
| 5227 | 5501 | // Get the next update... |
@@ -5290,14 +5564,16 @@ discard block |
||
| 5290 | 5564 | <input type="hidden" name="cleandone" value="1">'; |
| 5291 | 5565 | |
| 5292 | 5566 | // Files to make writable? |
| 5293 | - if (!empty($upcontext['writable_files'])) |
|
| 5294 | - echo ' |
|
| 5567 | + if (!empty($upcontext['writable_files'])) { |
|
| 5568 | + echo ' |
|
| 5295 | 5569 | <input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">'; |
| 5570 | + } |
|
| 5296 | 5571 | |
| 5297 | 5572 | // We'll want a continue button... |
| 5298 | - if (empty($upcontext['chmod']['files'])) |
|
| 5299 | - $upcontext['continue'] = 1; |
|
| 5300 | -} |
|
| 5573 | + if (empty($upcontext['chmod']['files'])) { |
|
| 5574 | + $upcontext['continue'] = 1; |
|
| 5575 | + } |
|
| 5576 | + } |
|
| 5301 | 5577 | |
| 5302 | 5578 | // Finished with the mods - let them know what we've done. |
| 5303 | 5579 | function template_cleanup_done() |
@@ -5359,8 +5635,9 @@ discard block |
||
| 5359 | 5635 | "', $language['name'], '" Language Pack |
| 5360 | 5636 | <div class="smalltext">('; |
| 5361 | 5637 | |
| 5362 | - foreach ($language['files'] as $k => $file) |
|
| 5363 | - echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')'; |
|
| 5638 | + foreach ($language['files'] as $k => $file) { |
|
| 5639 | + echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')'; |
|
| 5640 | + } |
|
| 5364 | 5641 | |
| 5365 | 5642 | echo ' |
| 5366 | 5643 | </div> |
@@ -5377,8 +5654,9 @@ discard block |
||
| 5377 | 5654 | "', $theme['name'], '" Theme |
| 5378 | 5655 | <div class="smalltext">('; |
| 5379 | 5656 | |
| 5380 | - foreach ($theme['files'] as $k => $file) |
|
| 5381 | - echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')'; |
|
| 5657 | + foreach ($theme['files'] as $k => $file) { |
|
| 5658 | + echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')'; |
|
| 5659 | + } |
|
| 5382 | 5660 | |
| 5383 | 5661 | echo ' |
| 5384 | 5662 | </div> |
@@ -5389,47 +5667,54 @@ discard block |
||
| 5389 | 5667 | |
| 5390 | 5668 | echo ' |
| 5391 | 5669 | </table>'; |
| 5392 | - } |
|
| 5393 | - else |
|
| 5670 | + } else |
|
| 5394 | 5671 | { |
| 5395 | 5672 | $langFiles = 0; |
| 5396 | 5673 | $themeFiles = 0; |
| 5397 | - if (!empty($upcontext['languages'])) |
|
| 5398 | - foreach ($upcontext['languages'] as $lang) |
|
| 5674 | + if (!empty($upcontext['languages'])) { |
|
| 5675 | + foreach ($upcontext['languages'] as $lang) |
|
| 5399 | 5676 | $langFiles += count($lang['files']); |
| 5400 | - if (!empty($upcontext['themes'])) |
|
| 5401 | - foreach ($upcontext['themes'] as $theme) |
|
| 5677 | + } |
|
| 5678 | + if (!empty($upcontext['themes'])) { |
|
| 5679 | + foreach ($upcontext['themes'] as $theme) |
|
| 5402 | 5680 | $themeFiles += count($theme['files']); |
| 5681 | + } |
|
| 5403 | 5682 | echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br>'; |
| 5404 | 5683 | |
| 5405 | 5684 | // What we're currently doing? |
| 5406 | - if (!empty($upcontext['current_message'])) |
|
| 5407 | - echo ' |
|
| 5685 | + if (!empty($upcontext['current_message'])) { |
|
| 5686 | + echo ' |
|
| 5408 | 5687 | ', $upcontext['current_message']; |
| 5688 | + } |
|
| 5409 | 5689 | } |
| 5410 | 5690 | |
| 5411 | 5691 | echo ' |
| 5412 | 5692 | <input type="hidden" name="uptempdone" value="1">'; |
| 5413 | 5693 | |
| 5414 | - if (!empty($upcontext['languages'])) |
|
| 5415 | - echo ' |
|
| 5694 | + if (!empty($upcontext['languages'])) { |
|
| 5695 | + echo ' |
|
| 5416 | 5696 | <input type="hidden" name="languages" value="', base64_encode(safe_serialize($upcontext['languages'])), '">'; |
| 5417 | - if (!empty($upcontext['themes'])) |
|
| 5418 | - echo ' |
|
| 5697 | + } |
|
| 5698 | + if (!empty($upcontext['themes'])) { |
|
| 5699 | + echo ' |
|
| 5419 | 5700 | <input type="hidden" name="themes" value="', base64_encode(safe_serialize($upcontext['themes'])), '">'; |
| 5420 | - if (!empty($upcontext['writable_files'])) |
|
| 5421 | - echo ' |
|
| 5701 | + } |
|
| 5702 | + if (!empty($upcontext['writable_files'])) { |
|
| 5703 | + echo ' |
|
| 5422 | 5704 | <input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">'; |
| 5705 | + } |
|
| 5423 | 5706 | |
| 5424 | 5707 | // Offer them the option to upgrade from YaBB SE? |
| 5425 | - if (!empty($upcontext['can_upgrade_yabbse'])) |
|
| 5426 | - echo ' |
|
| 5708 | + if (!empty($upcontext['can_upgrade_yabbse'])) { |
|
| 5709 | + echo ' |
|
| 5427 | 5710 | <br><label for="conv"><input type="checkbox" name="conv" id="conv" value="1" class="input_check"> Convert the existing YaBB SE template and set it as default.</label><br>'; |
| 5711 | + } |
|
| 5428 | 5712 | |
| 5429 | 5713 | // We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!) |
| 5430 | - if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) |
|
| 5431 | - $upcontext['continue'] = 1; |
|
| 5432 | -} |
|
| 5714 | + if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) { |
|
| 5715 | + $upcontext['continue'] = 1; |
|
| 5716 | + } |
|
| 5717 | + } |
|
| 5433 | 5718 | |
| 5434 | 5719 | // Template for the database backup tool/ |
| 5435 | 5720 | function template_serialize_json() |
@@ -5446,19 +5731,21 @@ discard block |
||
| 5446 | 5731 | <span id="debuginfo"></span>'; |
| 5447 | 5732 | |
| 5448 | 5733 | // Dont any tables so far? |
| 5449 | - if (!empty($upcontext['previous_tables'])) |
|
| 5450 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 5734 | + if (!empty($upcontext['previous_tables'])) { |
|
| 5735 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 5451 | 5736 | echo ' |
| 5452 | 5737 | <br>Completed Table: "', $table, '".'; |
| 5738 | + } |
|
| 5453 | 5739 | |
| 5454 | 5740 | echo ' |
| 5455 | 5741 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 5456 | 5742 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 5457 | 5743 | |
| 5458 | 5744 | // Try to make sure substep was reset. |
| 5459 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 5460 | - echo ' |
|
| 5745 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 5746 | + echo ' |
|
| 5461 | 5747 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 5748 | + } |
|
| 5462 | 5749 | |
| 5463 | 5750 | // Continue please! |
| 5464 | 5751 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -5491,9 +5778,10 @@ discard block |
||
| 5491 | 5778 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 5492 | 5779 | |
| 5493 | 5780 | // If debug flood the screen. |
| 5494 | - if ($is_debug) |
|
| 5495 | - echo ' |
|
| 5781 | + if ($is_debug) { |
|
| 5782 | + echo ' |
|
| 5496 | 5783 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 5784 | + } |
|
| 5497 | 5785 | |
| 5498 | 5786 | echo ' |
| 5499 | 5787 | // Get the next update... |
@@ -5528,8 +5816,8 @@ discard block |
||
| 5528 | 5816 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 5529 | 5817 | <form action="', $boardurl, '/index.php">'; |
| 5530 | 5818 | |
| 5531 | - if (!empty($upcontext['can_delete_script'])) |
|
| 5532 | - echo ' |
|
| 5819 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 5820 | + echo ' |
|
| 5533 | 5821 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 5534 | 5822 | <script> |
| 5535 | 5823 | function doTheDelete(theCheck) |
@@ -5541,6 +5829,7 @@ discard block |
||
| 5541 | 5829 | } |
| 5542 | 5830 | </script> |
| 5543 | 5831 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 5832 | + } |
|
| 5544 | 5833 | |
| 5545 | 5834 | $active = time() - $upcontext['started']; |
| 5546 | 5835 | $hours = floor($active / 3600); |
@@ -5550,16 +5839,20 @@ discard block |
||
| 5550 | 5839 | if ($is_debug) |
| 5551 | 5840 | { |
| 5552 | 5841 | $totalTime = ''; |
| 5553 | - if ($hours > 0) |
|
| 5554 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 5555 | - if ($minutes > 0) |
|
| 5556 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 5557 | - if ($seconds > 0) |
|
| 5558 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 5842 | + if ($hours > 0) { |
|
| 5843 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's':'') . ' '; |
|
| 5844 | + } |
|
| 5845 | + if ($minutes > 0) { |
|
| 5846 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's':'') . ' '; |
|
| 5847 | + } |
|
| 5848 | + if ($seconds > 0) { |
|
| 5849 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's':'') . ' '; |
|
| 5850 | + } |
|
| 5559 | 5851 | } |
| 5560 | 5852 | |
| 5561 | - if ($is_debug && !empty($totalTime)) |
|
| 5562 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 5853 | + if ($is_debug && !empty($totalTime)) { |
|
| 5854 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 5855 | + } |
|
| 5563 | 5856 | |
| 5564 | 5857 | echo '<br> |
| 5565 | 5858 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -5616,16 +5909,19 @@ discard block |
||
| 5616 | 5909 | 'empty' => '', |
| 5617 | 5910 | 'limit' => $limit, |
| 5618 | 5911 | )); |
| 5619 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 5620 | - $arIp[] = $row[$oldCol]; |
|
| 5912 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5913 | + $arIp[] = $row[$oldCol]; |
|
| 5914 | + } |
|
| 5621 | 5915 | $smcFunc['db_free_result']($request); |
| 5622 | 5916 | |
| 5623 | 5917 | // Special case, null ip could keep us in a loop. |
| 5624 | - if (is_null($arIp[0])) |
|
| 5625 | - unset($arIp[0]); |
|
| 5918 | + if (is_null($arIp[0])) { |
|
| 5919 | + unset($arIp[0]); |
|
| 5920 | + } |
|
| 5626 | 5921 | |
| 5627 | - if (empty($arIp)) |
|
| 5628 | - $is_done = true; |
|
| 5922 | + if (empty($arIp)) { |
|
| 5923 | + $is_done = true; |
|
| 5924 | + } |
|
| 5629 | 5925 | |
| 5630 | 5926 | $updates = array(); |
| 5631 | 5927 | $cases = array(); |
@@ -5634,16 +5930,18 @@ discard block |
||
| 5634 | 5930 | { |
| 5635 | 5931 | $arIp[$i] = trim($arIp[$i]); |
| 5636 | 5932 | |
| 5637 | - if (empty($arIp[$i])) |
|
| 5638 | - continue; |
|
| 5933 | + if (empty($arIp[$i])) { |
|
| 5934 | + continue; |
|
| 5935 | + } |
|
| 5639 | 5936 | |
| 5640 | 5937 | $updates['ip' . $i] = $arIp[$i]; |
| 5641 | 5938 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 5642 | 5939 | |
| 5643 | 5940 | if ($setSize > 0 && $i % $setSize === 0) |
| 5644 | 5941 | { |
| 5645 | - if (count($updates) == 1) |
|
| 5646 | - continue; |
|
| 5942 | + if (count($updates) == 1) { |
|
| 5943 | + continue; |
|
| 5944 | + } |
|
| 5647 | 5945 | |
| 5648 | 5946 | $updates['whereSet'] = array_values($updates); |
| 5649 | 5947 | $smcFunc['db_query']('', ' |
@@ -5677,8 +5975,7 @@ discard block |
||
| 5677 | 5975 | 'ip' => $ip |
| 5678 | 5976 | )); |
| 5679 | 5977 | } |
| 5680 | - } |
|
| 5681 | - else |
|
| 5978 | + } else |
|
| 5682 | 5979 | { |
| 5683 | 5980 | $updates['whereSet'] = array_values($updates); |
| 5684 | 5981 | $request = $smcFunc['db_query']('', ' |
@@ -5692,9 +5989,9 @@ discard block |
||
| 5692 | 5989 | $updates |
| 5693 | 5990 | ); |
| 5694 | 5991 | } |
| 5992 | + } else { |
|
| 5993 | + $is_done = true; |
|
| 5695 | 5994 | } |
| 5696 | - else |
|
| 5697 | - $is_done = true; |
|
| 5698 | 5995 | |
| 5699 | 5996 | $_GET['a'] += $limit; |
| 5700 | 5997 | $step_progress['current'] = $_GET['a']; |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Get everything started up... |
| 27 | 27 | define('SMF', 1); |
| 28 | -if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(),'5.3.0') < 0) |
|
| 28 | +if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(),'5.3.0') < 0) { |
|
| 29 | 29 | @set_magic_quotes_runtime(0); |
| 30 | +} |
|
| 30 | 31 | error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 31 | 32 | $time_start = microtime(); |
| 32 | 33 | |
@@ -34,16 +35,18 @@ discard block |
||
| 34 | 35 | ob_start(); |
| 35 | 36 | |
| 36 | 37 | // Do some cleaning, just in case. |
| 37 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 38 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 38 | 39 | if (isset($GLOBALS[$variable])) |
| 39 | 40 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // Load the settings... |
| 42 | 44 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 43 | 45 | |
| 44 | 46 | // Make absolutely sure the cache directory is defined. |
| 45 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 47 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 46 | 48 | $cachedir = $boarddir . '/cache'; |
| 49 | +} |
|
| 47 | 50 | |
| 48 | 51 | // Without those we can't go anywhere |
| 49 | 52 | require_once($sourcedir . '/QueryString.php'); |
@@ -53,8 +56,9 @@ discard block |
||
| 53 | 56 | require_once($sourcedir . '/Load.php'); |
| 54 | 57 | |
| 55 | 58 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 56 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 59 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 57 | 60 | display_maintenance_message(); |
| 61 | +} |
|
| 58 | 62 | |
| 59 | 63 | // Create a variable to store some SMF specific functions in. |
| 60 | 64 | $smcFunc = array(); |
@@ -69,8 +73,9 @@ discard block |
||
| 69 | 73 | cleanRequest(); |
| 70 | 74 | |
| 71 | 75 | // Seed the random generator. |
| 72 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 76 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 73 | 77 | smf_seed_generator(); |
| 78 | +} |
|
| 74 | 79 | |
| 75 | 80 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 76 | 81 | if (isset($_GET['scheduled'])) |
@@ -90,9 +95,9 @@ discard block |
||
| 90 | 95 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 91 | 96 | { |
| 92 | 97 | // If zlib is being used, turn off output compression. |
| 93 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 94 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 95 | - else |
|
| 98 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 99 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 100 | + } else |
|
| 96 | 101 | { |
| 97 | 102 | ob_end_clean(); |
| 98 | 103 | ob_start('ob_gzhandler'); |
@@ -141,18 +146,21 @@ discard block |
||
| 141 | 146 | loadPermissions(); |
| 142 | 147 | |
| 143 | 148 | // Attachments don't require the entire theme to be loaded. |
| 144 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 145 | - detectBrowser(); |
|
| 149 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 150 | + detectBrowser(); |
|
| 151 | + } |
|
| 146 | 152 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 147 | - else |
|
| 148 | - loadTheme(); |
|
| 153 | + else { |
|
| 154 | + loadTheme(); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // Check if the user should be disallowed access. |
| 151 | 158 | is_not_banned(); |
| 152 | 159 | |
| 153 | 160 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 154 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 155 | - fatal_lang_error('not_a_topic', false); |
|
| 161 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 162 | + fatal_lang_error('not_a_topic', false); |
|
| 163 | + } |
|
| 156 | 164 | |
| 157 | 165 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 158 | 166 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -163,8 +171,9 @@ discard block |
||
| 163 | 171 | writeLog(); |
| 164 | 172 | |
| 165 | 173 | // Track forum statistics and hits...? |
| 166 | - if (!empty($modSettings['hitStats'])) |
|
| 167 | - trackStats(array('hits' => '+')); |
|
| 174 | + if (!empty($modSettings['hitStats'])) { |
|
| 175 | + trackStats(array('hits' => '+')); |
|
| 176 | + } |
|
| 168 | 177 | } |
| 169 | 178 | unset($no_stat_actions); |
| 170 | 179 | |
@@ -178,13 +187,14 @@ discard block |
||
| 178 | 187 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 179 | 188 | } |
| 180 | 189 | // Don't even try it, sonny. |
| 181 | - else |
|
| 182 | - return 'InMaintenance'; |
|
| 190 | + else { |
|
| 191 | + return 'InMaintenance'; |
|
| 192 | + } |
|
| 183 | 193 | } |
| 184 | 194 | // If guest access is off, a guest can only do one of the very few following actions. |
| 185 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 186 | - return 'KickGuest'; |
|
| 187 | - elseif (empty($_REQUEST['action'])) |
|
| 195 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 196 | + return 'KickGuest'; |
|
| 197 | + } elseif (empty($_REQUEST['action'])) |
|
| 188 | 198 | { |
| 189 | 199 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 190 | 200 | if (empty($board) && empty($topic)) |
@@ -200,8 +210,9 @@ discard block |
||
| 200 | 210 | |
| 201 | 211 | $call = call_helper($defaultAction, true); |
| 202 | 212 | |
| 203 | - if (!empty($call)) |
|
| 204 | - return $call; |
|
| 213 | + if (!empty($call)) { |
|
| 214 | + return $call; |
|
| 215 | + } |
|
| 205 | 216 | } |
| 206 | 217 | |
| 207 | 218 | // No default action huh? then go to our good old BoardIndex. |
@@ -331,8 +342,9 @@ discard block |
||
| 331 | 342 | |
| 332 | 343 | $call = call_helper($fallbackAction, true); |
| 333 | 344 | |
| 334 | - if (!empty($call)) |
|
| 335 | - return $call; |
|
| 345 | + if (!empty($call)) { |
|
| 346 | + return $call; |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | 349 | |
| 338 | 350 | // No fallback action, huh? |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | global $context, $txt; |
| 25 | 25 | |
| 26 | - if (!empty($context['simple_action'])) |
|
| 27 | - echo ' |
|
| 26 | + if (!empty($context['simple_action'])) { |
|
| 27 | + echo ' |
|
| 28 | 28 | <strong> |
| 29 | 29 | ', $context['error_title'], ' |
| 30 | 30 | </strong><br> |
| 31 | 31 | <div ', $context['error_code'], 'class="padding">', $context['error_message'], '</div>'; |
| 32 | - else |
|
| 32 | + } else |
|
| 33 | 33 | { |
| 34 | 34 | echo ' |
| 35 | 35 | <div id="fatal_error"> |
@@ -82,21 +82,23 @@ discard block |
||
| 82 | 82 | ', $txt['apply_filter_of_type'], ':'; |
| 83 | 83 | |
| 84 | 84 | $error_types = array(); |
| 85 | - foreach ($context['error_types'] as $type => $details) |
|
| 86 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
| 85 | + foreach ($context['error_types'] as $type => $details) { |
|
| 86 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
| 87 | + } |
|
| 87 | 88 | |
| 88 | 89 | echo ' |
| 89 | 90 | ', implode(' | ', $error_types), ' |
| 90 | 91 | </td> |
| 91 | 92 | </tr>'; |
| 92 | 93 | |
| 93 | - if ($context['has_filter']) |
|
| 94 | - echo ' |
|
| 94 | + if ($context['has_filter']) { |
|
| 95 | + echo ' |
|
| 95 | 96 | <tr> |
| 96 | 97 | <td colspan="3" class="windowbg"> |
| 97 | 98 | <strong> ', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
| 98 | 99 | </td> |
| 99 | 100 | </tr>'; |
| 101 | + } |
|
| 100 | 102 | |
| 101 | 103 | echo ' |
| 102 | 104 | <tr> |
@@ -107,11 +109,12 @@ discard block |
||
| 107 | 109 | </tr>'; |
| 108 | 110 | |
| 109 | 111 | // No errors, then show a message |
| 110 | - if (count($context['errors']) == 0) |
|
| 111 | - echo ' |
|
| 112 | + if (count($context['errors']) == 0) { |
|
| 113 | + echo ' |
|
| 112 | 114 | <tr class="windowbg"> |
| 113 | 115 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
| 114 | 116 | </tr>'; |
| 117 | + } |
|
| 115 | 118 | |
| 116 | 119 | // we have some errors, must be some mods installed :P |
| 117 | 120 | foreach ($context['errors'] as $error) |
@@ -126,20 +129,22 @@ discard block |
||
| 126 | 129 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
| 127 | 130 | ', $error['time'], '<br>'; |
| 128 | 131 | |
| 129 | - if (!empty($error['member']['ip'])) |
|
| 130 | - echo ' |
|
| 132 | + if (!empty($error['member']['ip'])) { |
|
| 133 | + echo ' |
|
| 131 | 134 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
| 132 | 135 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong> <br>'; |
| 136 | + } |
|
| 133 | 137 | |
| 134 | 138 | echo ' |
| 135 | 139 | </div> |
| 136 | 140 | |
| 137 | 141 | <div style="float: left; width: 50%; line-height: 1.8em; padding: 0 4px;">'; |
| 138 | 142 | |
| 139 | - if ($error['member']['session'] != '') |
|
| 140 | - echo ' |
|
| 143 | + if ($error['member']['session'] != '') { |
|
| 144 | + echo ' |
|
| 141 | 145 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
| 142 | 146 | ', $error['member']['session'], '<br>'; |
| 147 | + } |
|
| 143 | 148 | |
| 144 | 149 | echo ' |
| 145 | 150 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=error_type;value=', $error['error_type']['type'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '"><span class="generic_icons filter centericon"></span></a> |
@@ -153,8 +158,8 @@ discard block |
||
| 153 | 158 | <a style="display: table-cell;" href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
| 154 | 159 | </div>'; |
| 155 | 160 | |
| 156 | - if (!empty($error['file'])) |
|
| 157 | - echo ' |
|
| 161 | + if (!empty($error['file'])) { |
|
| 162 | + echo ' |
|
| 158 | 163 | <div style="float: left; width: 100%; padding: 4px 0; line-height: 1.6em; border-top: 1px solid #e3e3e3;"> |
| 159 | 164 | <a style="display: table-cell; padding: 4px; width: 20px; vertical-align: top;" href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '"><span class="generic_icons filter"></span></a> |
| 160 | 165 | <div> |
@@ -162,6 +167,7 @@ discard block |
||
| 162 | 167 | ', $txt['line'], ': ', $error['file']['line'], ' |
| 163 | 168 | </div> |
| 164 | 169 | </div>'; |
| 170 | + } |
|
| 165 | 171 | |
| 166 | 172 | echo ' |
| 167 | 173 | </td> |
@@ -190,9 +196,10 @@ discard block |
||
| 190 | 196 | </div> |
| 191 | 197 | <br>'; |
| 192 | 198 | |
| 193 | - if ($context['sort_direction'] == 'down') |
|
| 194 | - echo ' |
|
| 199 | + if ($context['sort_direction'] == 'down') { |
|
| 200 | + echo ' |
|
| 195 | 201 | <input type="hidden" name="desc" value="1">'; |
| 202 | + } |
|
| 196 | 203 | |
| 197 | 204 | echo ' |
| 198 | 205 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
@@ -19,26 +19,28 @@ discard block |
||
| 19 | 19 | global $context, $settings, $scripturl, $txt, $modSettings; |
| 20 | 20 | |
| 21 | 21 | // Not allowed to edit? |
| 22 | - if (!$context['can_modify']) |
|
| 23 | - echo ' |
|
| 22 | + if (!$context['can_modify']) { |
|
| 23 | + echo ' |
|
| 24 | 24 | <div class="errorbox"> |
| 25 | 25 | ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), ' |
| 26 | 26 | </div>'; |
| 27 | + } |
|
| 27 | 28 | |
| 28 | 29 | echo ' |
| 29 | 30 | <div id="admin_form_wrapper"> |
| 30 | 31 | <form action="', $scripturl, '?action=admin;area=permissions;sa=quick" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" id="permissionForm">'; |
| 31 | 32 | |
| 32 | - if (!empty($context['profile'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['profile'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <div class="cat_bar"> |
| 35 | 36 | <h3 class="catbg">', $txt['permissions_for_profile'], ': "', $context['profile']['name'], '"</h3> |
| 36 | 37 | </div>'; |
| 37 | - else |
|
| 38 | - echo ' |
|
| 38 | + } else { |
|
| 39 | + echo ' |
|
| 39 | 40 | <div class="cat_bar"> |
| 40 | 41 | <h3 class="catbg">', $txt['permissions_title'], '</h3> |
| 41 | 42 | </div>'; |
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | echo ' |
| 44 | 46 | <table class="table_grid"> |
@@ -47,13 +49,14 @@ discard block |
||
| 47 | 49 | <th>', $txt['membergroups_name'], '</th> |
| 48 | 50 | <th class="small_table">', $txt['membergroups_members_top'], '</th>'; |
| 49 | 51 | |
| 50 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 51 | - echo ' |
|
| 52 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 53 | + echo ' |
|
| 52 | 54 | <th class="small_table">', $txt['membergroups_permissions'], '</th>'; |
| 53 | - else |
|
| 54 | - echo ' |
|
| 55 | + } else { |
|
| 56 | + echo ' |
|
| 55 | 57 | <th class="small_table">', $txt['permissions_allowed'], '</th> |
| 56 | 58 | <th class="small_table">', $txt['permissions_denied'], '</th>'; |
| 59 | + } |
|
| 57 | 60 | |
| 58 | 61 | echo ' |
| 59 | 62 | <th class="small_table">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th> |
@@ -71,22 +74,24 @@ discard block |
||
| 71 | 74 | <td> |
| 72 | 75 | ', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="'. $txt['help'].'"></span></a>' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '">', ' <span>', $group['name'], '</span>'; |
| 73 | 76 | |
| 74 | - if (!empty($group['children'])) |
|
| 75 | - echo ' |
|
| 77 | + if (!empty($group['children'])) { |
|
| 78 | + echo ' |
|
| 76 | 79 | <br> |
| 77 | 80 | <span class="smalltext">', $txt['permissions_includes_inherited'], ': "', implode('", "', $group['children']), '"</span>'; |
| 81 | + } |
|
| 78 | 82 | |
| 79 | 83 | echo ' |
| 80 | 84 | </td> |
| 81 | 85 | <td>', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>'; |
| 82 | 86 | |
| 83 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 84 | - echo ' |
|
| 87 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 88 | + echo ' |
|
| 85 | 89 | <td>', $group['num_permissions']['allowed'], '</td>'; |
| 86 | - else |
|
| 87 | - echo ' |
|
| 90 | + } else { |
|
| 91 | + echo ' |
|
| 88 | 92 | <td ', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '>', $group['num_permissions']['allowed'], '</td> |
| 89 | 93 | <td ', $group['id'] == 1 || $group['id'] == -1 ? ' style="font-style: italic;"' : (!empty($group['num_permissions']['denied']) ? ' class="red"' : ''), '>', $group['num_permissions']['denied'], '</td>'; |
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | echo ' |
| 92 | 97 | <td>', $group['allow_modify'] ? '<a href="' . $scripturl . '?action=admin;area=permissions;sa=modify;group=' . $group['id'] . (empty($context['profile']) ? '' : ';pid=' . $context['profile']['id']) . '">' . ($context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view']). '</a>' : '', '</td> |
@@ -133,9 +138,10 @@ discard block |
||
| 133 | 138 | <option value="empty">(', $txt['permissions_select_membergroup'], ')</option>'; |
| 134 | 139 | foreach ($context['groups'] as $group) |
| 135 | 140 | { |
| 136 | - if ($group['id'] != 1) |
|
| 137 | - echo ' |
|
| 141 | + if ($group['id'] != 1) { |
|
| 142 | + echo ' |
|
| 138 | 143 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
| 144 | + } |
|
| 139 | 145 | } |
| 140 | 146 | |
| 141 | 147 | echo ' |
@@ -145,9 +151,10 @@ discard block |
||
| 145 | 151 | <select name="add_remove"> |
| 146 | 152 | <option value="add">', $txt['permissions_add'], '...</option> |
| 147 | 153 | <option value="clear">', $txt['permissions_remove'], '...</option>'; |
| 148 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 149 | - echo ' |
|
| 154 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 155 | + echo ' |
|
| 150 | 156 | <option value="deny">', $txt['permissions_deny'], '...</option>'; |
| 157 | + } |
|
| 151 | 158 | echo ' |
| 152 | 159 | </select> |
| 153 | 160 | </dt> |
@@ -156,30 +163,34 @@ discard block |
||
| 156 | 163 | <option value="">(', $txt['permissions_select_permission'], ')</option>'; |
| 157 | 164 | foreach ($context['permissions'] as $permissionType) |
| 158 | 165 | { |
| 159 | - if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) |
|
| 160 | - continue; |
|
| 166 | + if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) { |
|
| 167 | + continue; |
|
| 168 | + } |
|
| 161 | 169 | |
| 162 | 170 | foreach ($permissionType['columns'] as $column) |
| 163 | 171 | { |
| 164 | 172 | foreach ($column as $permissionGroup) |
| 165 | 173 | { |
| 166 | - if ($permissionGroup['hidden']) |
|
| 167 | - continue; |
|
| 174 | + if ($permissionGroup['hidden']) { |
|
| 175 | + continue; |
|
| 176 | + } |
|
| 168 | 177 | |
| 169 | 178 | echo ' |
| 170 | 179 | <option value="" disabled>[', $permissionGroup['name'], ']</option>'; |
| 171 | 180 | foreach ($permissionGroup['permissions'] as $perm) |
| 172 | 181 | { |
| 173 | - if ($perm['hidden']) |
|
| 174 | - continue; |
|
| 182 | + if ($perm['hidden']) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 175 | 185 | |
| 176 | - if ($perm['has_own_any']) |
|
| 177 | - echo ' |
|
| 186 | + if ($perm['has_own_any']) { |
|
| 187 | + echo ' |
|
| 178 | 188 | <option value="', $permissionType['id'], '/', $perm['own']['id'], '"> ', $perm['name'], ' (', $perm['own']['name'], ')</option> |
| 179 | 189 | <option value="', $permissionType['id'], '/', $perm['any']['id'], '"> ', $perm['name'], ' (', $perm['any']['name'], ')</option>'; |
| 180 | - else |
|
| 181 | - echo ' |
|
| 190 | + } else { |
|
| 191 | + echo ' |
|
| 182 | 192 | <option value="', $permissionType['id'], '/', $perm['id'], '"> ', $perm['name'], '</option>'; |
| 193 | + } |
|
| 183 | 194 | } |
| 184 | 195 | } |
| 185 | 196 | } |
@@ -246,17 +257,18 @@ discard block |
||
| 246 | 257 | } |
| 247 | 258 | </script>'; |
| 248 | 259 | |
| 249 | - if (!empty($context['profile'])) |
|
| 250 | - echo ' |
|
| 260 | + if (!empty($context['profile'])) { |
|
| 261 | + echo ' |
|
| 251 | 262 | <input type="hidden" name="pid" value="', $context['profile']['id'], '">'; |
| 263 | + } |
|
| 252 | 264 | |
| 253 | 265 | echo ' |
| 254 | 266 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 255 | 267 | <input type="hidden" name="', $context['admin-mpq_token_var'], '" value="', $context['admin-mpq_token'], '">'; |
| 256 | - } |
|
| 257 | - else |
|
| 258 | - echo ' |
|
| 268 | + } else { |
|
| 269 | + echo ' |
|
| 259 | 270 | </table>'; |
| 271 | + } |
|
| 260 | 272 | |
| 261 | 273 | echo ' |
| 262 | 274 | </form> |
@@ -296,9 +308,10 @@ discard block |
||
| 296 | 308 | <h3 class="subbg">', $category['name'], '</h3> |
| 297 | 309 | </div>'; |
| 298 | 310 | |
| 299 | - if (!empty($category['boards'])) |
|
| 300 | - echo ' |
|
| 311 | + if (!empty($category['boards'])) { |
|
| 312 | + echo ' |
|
| 301 | 313 | <ul class="perm_boards flow_hidden">'; |
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | foreach ($category['boards'] as $board) |
| 304 | 317 | { |
@@ -315,33 +328,36 @@ discard block |
||
| 315 | 328 | echo ' |
| 316 | 329 | <select name="boardprofile[', $board['id'], ']">'; |
| 317 | 330 | |
| 318 | - foreach ($context['profiles'] as $id => $profile) |
|
| 319 | - echo ' |
|
| 331 | + foreach ($context['profiles'] as $id => $profile) { |
|
| 332 | + echo ' |
|
| 320 | 333 | <option value="', $id, '"', $id == $board['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
| 334 | + } |
|
| 321 | 335 | |
| 322 | 336 | echo ' |
| 323 | 337 | </select>'; |
| 324 | - } |
|
| 325 | - else |
|
| 326 | - echo ' |
|
| 338 | + } else { |
|
| 339 | + echo ' |
|
| 327 | 340 | <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '">', $board['profile_name'], '</a>'; |
| 341 | + } |
|
| 328 | 342 | |
| 329 | 343 | echo ' |
| 330 | 344 | </span> |
| 331 | 345 | </li>'; |
| 332 | 346 | } |
| 333 | 347 | |
| 334 | - if (!empty($category['boards'])) |
|
| 335 | - echo ' |
|
| 348 | + if (!empty($category['boards'])) { |
|
| 349 | + echo ' |
|
| 336 | 350 | </ul>'; |
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | |
| 339 | - if ($context['edit_all']) |
|
| 340 | - echo ' |
|
| 354 | + if ($context['edit_all']) { |
|
| 355 | + echo ' |
|
| 341 | 356 | <input type="submit" name="save_changes" value="', $txt['save'], '" class="button_submit">'; |
| 342 | - else |
|
| 343 | - echo ' |
|
| 357 | + } else { |
|
| 358 | + echo ' |
|
| 344 | 359 | <a class="button_link" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>'; |
| 360 | + } |
|
| 345 | 361 | |
| 346 | 362 | echo ' |
| 347 | 363 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -381,12 +397,13 @@ discard block |
||
| 381 | 397 | <tr class="windowbg"> |
| 382 | 398 | <td>'; |
| 383 | 399 | |
| 384 | - if (!empty($context['show_rename_boxes']) && $profile['can_edit']) |
|
| 385 | - echo ' |
|
| 400 | + if (!empty($context['show_rename_boxes']) && $profile['can_edit']) { |
|
| 401 | + echo ' |
|
| 386 | 402 | <input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '" class="input_text">'; |
| 387 | - else |
|
| 388 | - echo ' |
|
| 403 | + } else { |
|
| 404 | + echo ' |
|
| 389 | 405 | <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>'; |
| 406 | + } |
|
| 390 | 407 | |
| 391 | 408 | echo ' |
| 392 | 409 | </td> |
@@ -406,9 +423,10 @@ discard block |
||
| 406 | 423 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 407 | 424 | <input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">'; |
| 408 | 425 | |
| 409 | - if ($context['can_edit_something']) |
|
| 410 | - echo ' |
|
| 426 | + if ($context['can_edit_something']) { |
|
| 427 | + echo ' |
|
| 411 | 428 | <input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button_submit">'; |
| 429 | + } |
|
| 412 | 430 | |
| 413 | 431 | echo ' |
| 414 | 432 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button_submit" ', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '/> |
@@ -433,9 +451,10 @@ discard block |
||
| 433 | 451 | <dd> |
| 434 | 452 | <select name="copy_from">'; |
| 435 | 453 | |
| 436 | - foreach ($context['profiles'] as $id => $profile) |
|
| 437 | - echo ' |
|
| 454 | + foreach ($context['profiles'] as $id => $profile) { |
|
| 455 | + echo ' |
|
| 438 | 456 | <option value="', $id, '">', $profile['name'], '</option>'; |
| 457 | + } |
|
| 439 | 458 | |
| 440 | 459 | echo ' |
| 441 | 460 | </select> |
@@ -463,8 +482,7 @@ discard block |
||
| 463 | 482 | <div class="errorbox"> |
| 464 | 483 | ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), ' |
| 465 | 484 | </div>'; |
| 466 | - } |
|
| 467 | - else |
|
| 485 | + } else |
|
| 468 | 486 | { |
| 469 | 487 | echo ' |
| 470 | 488 | <script> |
@@ -484,21 +502,23 @@ discard block |
||
| 484 | 502 | <div id="admincenter"> |
| 485 | 503 | <form id="permissions" action="', $scripturl, '?action=admin;area=permissions;sa=modify2;group=', $context['group']['id'], ';pid=', $context['profile']['id'], '" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" onsubmit="return warnAboutDeny();">'; |
| 486 | 504 | |
| 487 | - if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) |
|
| 488 | - echo ' |
|
| 505 | + if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) { |
|
| 506 | + echo ' |
|
| 489 | 507 | <div class="information"> |
| 490 | 508 | ', $txt['permissions_option_desc'], ' |
| 491 | 509 | </div>'; |
| 510 | + } |
|
| 492 | 511 | |
| 493 | 512 | echo ' |
| 494 | 513 | <div class="cat_bar"> |
| 495 | 514 | <h3 class="catbg">'; |
| 496 | - if ($context['permission_type'] == 'board') |
|
| 497 | - echo ' |
|
| 515 | + if ($context['permission_type'] == 'board') { |
|
| 516 | + echo ' |
|
| 498 | 517 | ', $txt['permissions_local_for'], ' "', $context['group']['name'], '" ', $txt['permissions_on'], ' "', $context['profile']['name'], '"'; |
| 499 | - else |
|
| 500 | - echo ' |
|
| 518 | + } else { |
|
| 519 | + echo ' |
|
| 501 | 520 | ', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - "', $context['group']['name'], '"'; |
| 521 | + } |
|
| 502 | 522 | echo ' |
| 503 | 523 | </h3> |
| 504 | 524 | </div>'; |
@@ -521,15 +541,17 @@ discard block |
||
| 521 | 541 | template_modify_group_display('board'); |
| 522 | 542 | } |
| 523 | 543 | |
| 524 | - if ($context['profile']['can_modify']) |
|
| 525 | - echo ' |
|
| 544 | + if ($context['profile']['can_modify']) { |
|
| 545 | + echo ' |
|
| 526 | 546 | <div class="padding"> |
| 527 | 547 | <input type="submit" value="', $txt['permissions_commit'], '" class="button_submit"> |
| 528 | 548 | </div>'; |
| 549 | + } |
|
| 529 | 550 | |
| 530 | - foreach ($context['hidden_perms'] as $hidden_perm) |
|
| 531 | - echo ' |
|
| 551 | + foreach ($context['hidden_perms'] as $hidden_perm) { |
|
| 552 | + echo ' |
|
| 532 | 553 | <input type="hidden" name="perm[', $hidden_perm[0], '][', $hidden_perm[1], ']" value="', $hidden_perm[2], '">'; |
| 554 | + } |
|
| 533 | 555 | |
| 534 | 556 | echo ' |
| 535 | 557 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -557,17 +579,19 @@ discard block |
||
| 557 | 579 | |
| 558 | 580 | foreach ($column as $permissionGroup) |
| 559 | 581 | { |
| 560 | - if (empty($permissionGroup['permissions'])) |
|
| 561 | - continue; |
|
| 582 | + if (empty($permissionGroup['permissions'])) { |
|
| 583 | + continue; |
|
| 584 | + } |
|
| 562 | 585 | |
| 563 | 586 | // Are we likely to have something in this group to display or is it all hidden? |
| 564 | 587 | $has_display_content = false; |
| 565 | 588 | if (!$permissionGroup['hidden']) |
| 566 | 589 | { |
| 567 | 590 | // Before we go any further check we are going to have some data to print otherwise we just have a silly heading. |
| 568 | - foreach ($permissionGroup['permissions'] as $permission) |
|
| 569 | - if (!$permission['hidden']) |
|
| 591 | + foreach ($permissionGroup['permissions'] as $permission) { |
|
| 592 | + if (!$permission['hidden']) |
|
| 570 | 593 | $has_display_content = true; |
| 594 | + } |
|
| 571 | 595 | |
| 572 | 596 | if ($has_display_content) |
| 573 | 597 | { |
@@ -576,10 +600,11 @@ discard block |
||
| 576 | 600 | <th></th> |
| 577 | 601 | <th', $context['group']['id'] == -1 ? ' colspan="2"' : '', ' class="smalltext">', $permissionGroup['name'], '</th>'; |
| 578 | 602 | |
| 579 | - if ($context['group']['id'] != -1) |
|
| 580 | - echo ' |
|
| 603 | + if ($context['group']['id'] != -1) { |
|
| 604 | + echo ' |
|
| 581 | 605 | <th>', $txt['permissions_option_own'], '</th> |
| 582 | 606 | <th>', $txt['permissions_option_any'], '</th>'; |
| 607 | + } |
|
| 583 | 608 | |
| 584 | 609 | echo ' |
| 585 | 610 | </tr>'; |
@@ -602,17 +627,18 @@ discard block |
||
| 602 | 627 | // Guests can't do their own thing. |
| 603 | 628 | if ($context['group']['id'] != -1) |
| 604 | 629 | { |
| 605 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 606 | - echo ' |
|
| 630 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 631 | + echo ' |
|
| 607 | 632 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" class="input_check" ', $disable_field, '/>'; |
| 608 | - else |
|
| 633 | + } else |
|
| 609 | 634 | { |
| 610 | 635 | echo ' |
| 611 | 636 | <select name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" ', $disable_field, '>'; |
| 612 | 637 | |
| 613 | - foreach (array('on', 'off', 'deny') as $c) |
|
| 614 | - echo ' |
|
| 638 | + foreach (array('on', 'off', 'deny') as $c) { |
|
| 639 | + echo ' |
|
| 615 | 640 | <option ', $permission['own']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
| 641 | + } |
|
| 616 | 642 | echo ' |
| 617 | 643 | </select>'; |
| 618 | 644 | } |
@@ -622,39 +648,41 @@ discard block |
||
| 622 | 648 | <td>'; |
| 623 | 649 | } |
| 624 | 650 | |
| 625 | - if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) |
|
| 626 | - echo ' |
|
| 651 | + if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) { |
|
| 652 | + echo ' |
|
| 627 | 653 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/>'; |
| 628 | - else |
|
| 654 | + } else |
|
| 629 | 655 | { |
| 630 | 656 | echo ' |
| 631 | 657 | <select name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" ', $disable_field, '>'; |
| 632 | 658 | |
| 633 | - foreach (array('on', 'off', 'deny') as $c) |
|
| 634 | - echo ' |
|
| 659 | + foreach (array('on', 'off', 'deny') as $c) { |
|
| 660 | + echo ' |
|
| 635 | 661 | <option ', $permission['any']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
| 662 | + } |
|
| 636 | 663 | echo ' |
| 637 | 664 | </select>'; |
| 638 | 665 | } |
| 639 | - } |
|
| 640 | - else |
|
| 666 | + } else |
|
| 641 | 667 | { |
| 642 | - if ($context['group']['id'] != -1) |
|
| 643 | - echo ' |
|
| 668 | + if ($context['group']['id'] != -1) { |
|
| 669 | + echo ' |
|
| 644 | 670 | </td> |
| 645 | 671 | <td>'; |
| 672 | + } |
|
| 646 | 673 | |
| 647 | - if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) |
|
| 648 | - echo ' |
|
| 674 | + if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) { |
|
| 675 | + echo ' |
|
| 649 | 676 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/>'; |
| 650 | - else |
|
| 677 | + } else |
|
| 651 | 678 | { |
| 652 | 679 | echo ' |
| 653 | 680 | <select name="perm[', $permission_type['id'], '][', $permission['id'], ']" ', $disable_field, '>'; |
| 654 | 681 | |
| 655 | - foreach (array('on', 'off', 'deny') as $c) |
|
| 656 | - echo ' |
|
| 682 | + foreach (array('on', 'off', 'deny') as $c) { |
|
| 683 | + echo ' |
|
| 657 | 684 | <option ', $permission['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
| 685 | + } |
|
| 658 | 686 | echo ' |
| 659 | 687 | </select>'; |
| 660 | 688 | } |
@@ -684,11 +712,11 @@ discard block |
||
| 684 | 712 | echo ' |
| 685 | 713 | <fieldset id="', $context['current_permission'], '"> |
| 686 | 714 | <legend><a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'none\';document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'block\'; return false;" class="toggle_up"> ', $txt['avatar_select_permission'], '</a></legend>'; |
| 687 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 688 | - echo ' |
|
| 715 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 716 | + echo ' |
|
| 689 | 717 | <ul>'; |
| 690 | - else |
|
| 691 | - echo ' |
|
| 718 | + } else { |
|
| 719 | + echo ' |
|
| 692 | 720 | <div class="information">', $txt['permissions_option_desc'], '</div> |
| 693 | 721 | <dl class="settings"> |
| 694 | 722 | <dt> |
@@ -698,46 +726,51 @@ discard block |
||
| 698 | 726 | </dt> |
| 699 | 727 | <dd> |
| 700 | 728 | </dd>'; |
| 729 | + } |
|
| 701 | 730 | foreach ($context['member_groups'] as $group) |
| 702 | 731 | { |
| 703 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 704 | - echo ' |
|
| 732 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 733 | + echo ' |
|
| 705 | 734 | <dt>'; |
| 706 | - else |
|
| 707 | - echo ' |
|
| 735 | + } else { |
|
| 736 | + echo ' |
|
| 708 | 737 | <li>'; |
| 738 | + } |
|
| 709 | 739 | |
| 710 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 711 | - echo ' |
|
| 740 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 741 | + echo ' |
|
| 712 | 742 | <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', ' class="input_check">'; |
| 713 | - else |
|
| 714 | - echo ' |
|
| 743 | + } else { |
|
| 744 | + echo ' |
|
| 715 | 745 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', ' class="input_radio"></span> |
| 716 | 746 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', ' class="input_radio"></span> |
| 717 | 747 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', ' class="input_radio"></span>'; |
| 748 | + } |
|
| 718 | 749 | |
| 719 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 720 | - echo ' |
|
| 750 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 751 | + echo ' |
|
| 721 | 752 | </dt> |
| 722 | 753 | <dd> |
| 723 | 754 | <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span> |
| 724 | 755 | </dd>'; |
| 725 | - else |
|
| 726 | - echo ' |
|
| 756 | + } else { |
|
| 757 | + echo ' |
|
| 727 | 758 | <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span> |
| 728 | 759 | </li>'; |
| 760 | + } |
|
| 729 | 761 | } |
| 730 | 762 | |
| 731 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 732 | - echo ' |
|
| 763 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 764 | + echo ' |
|
| 733 | 765 | <li> |
| 734 | 766 | <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \''. $context['current_permission']. '[\');"> |
| 735 | 767 | <span>', $txt['check_all'], '</span> |
| 736 | 768 | </li> |
| 737 | 769 | </ul>'; |
| 738 | - else |
|
| 739 | - echo ' |
|
| 770 | + } else { |
|
| 771 | + echo ' |
|
| 740 | 772 | </dl>'; |
| 773 | + } |
|
| 741 | 774 | |
| 742 | 775 | echo ' |
| 743 | 776 | </fieldset> |
@@ -777,9 +810,10 @@ discard block |
||
| 777 | 810 | if (!empty($modSettings['postmod_active'])) |
| 778 | 811 | { |
| 779 | 812 | // Got advanced permissions - if so warn! |
| 780 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 781 | - echo ' |
|
| 813 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 814 | + echo ' |
|
| 782 | 815 | <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>'; |
| 816 | + } |
|
| 783 | 817 | |
| 784 | 818 | echo ' |
| 785 | 819 | <div class="padding"> |
@@ -794,10 +828,11 @@ discard block |
||
| 794 | 828 | ', $txt['permissions_post_moderation_select'], ': |
| 795 | 829 | <select name="pid" onchange="document.forms.postmodForm.submit();">'; |
| 796 | 830 | |
| 797 | - foreach ($context['profiles'] as $profile) |
|
| 798 | - if ($profile['can_modify']) |
|
| 831 | + foreach ($context['profiles'] as $profile) { |
|
| 832 | + if ($profile['can_modify']) |
|
| 799 | 833 | echo ' |
| 800 | 834 | <option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
| 835 | + } |
|
| 801 | 836 | |
| 802 | 837 | echo ' |
| 803 | 838 | </select> |
@@ -818,11 +853,12 @@ discard block |
||
| 818 | 853 | ', $txt['permissions_post_moderation_replies_any'], ' |
| 819 | 854 | </th>'; |
| 820 | 855 | |
| 821 | - if ($modSettings['attachmentEnable'] == 1) |
|
| 822 | - echo ' |
|
| 856 | + if ($modSettings['attachmentEnable'] == 1) { |
|
| 857 | + echo ' |
|
| 823 | 858 | <th class="centercol" colspan="3"> |
| 824 | 859 | ', $txt['permissions_post_moderation_attachments'], ' |
| 825 | 860 | </th>'; |
| 861 | + } |
|
| 826 | 862 | |
| 827 | 863 | echo ' |
| 828 | 864 | </tr> |
@@ -840,11 +876,12 @@ discard block |
||
| 840 | 876 | <th><span class="generic_icons post_moderation_moderate"></span></th> |
| 841 | 877 | <th><span class="generic_icons post_moderation_deny"></span></th>'; |
| 842 | 878 | |
| 843 | - if ($modSettings['attachmentEnable'] == 1) |
|
| 844 | - echo ' |
|
| 879 | + if ($modSettings['attachmentEnable'] == 1) { |
|
| 880 | + echo ' |
|
| 845 | 881 | <th><span class="generic_icons post_moderation_allow"></span></th> |
| 846 | 882 | <th><span class="generic_icons post_moderation_moderate"></span></th> |
| 847 | 883 | <th><span class="generic_icons post_moderation_deny"></span></th>'; |
| 884 | + } |
|
| 848 | 885 | |
| 849 | 886 | echo ' |
| 850 | 887 | </tr> |
@@ -857,9 +894,10 @@ discard block |
||
| 857 | 894 | <tr class="windowbg"> |
| 858 | 895 | <td class="half_table"> |
| 859 | 896 | <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>'; |
| 860 | - if (!empty($group['children'])) |
|
| 861 | - echo ' |
|
| 897 | + if (!empty($group['children'])) { |
|
| 898 | + echo ' |
|
| 862 | 899 | <br><span class="smalltext">', $txt['permissions_includes_inherited'], ': "', implode('", "', $group['children']), '"</span>'; |
| 900 | + } |
|
| 863 | 901 | |
| 864 | 902 | echo ' |
| 865 | 903 | </td> |
@@ -872,8 +910,7 @@ discard block |
||
| 872 | 910 | { |
| 873 | 911 | echo ' |
| 874 | 912 | <td colspan="3"></td>'; |
| 875 | - } |
|
| 876 | - else |
|
| 913 | + } else |
|
| 877 | 914 | { |
| 878 | 915 | echo ' |
| 879 | 916 | <td class="centercol"><input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', ' class="input_radio"></td> |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | <div id="personal_messages">'; |
| 22 | 22 | |
| 23 | 23 | // Show the capacity bar, if available. |
| 24 | - if (!empty($context['limit_bar'])) |
|
| 25 | - echo ' |
|
| 24 | + if (!empty($context['limit_bar'])) { |
|
| 25 | + echo ' |
|
| 26 | 26 | <div class="cat_bar"> |
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
@@ -32,14 +32,16 @@ discard block |
||
| 32 | 32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
| 33 | 33 | </h3> |
| 34 | 34 | </div>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | // Message sent? Show a small indication. |
| 37 | - if (isset($context['pm_sent'])) |
|
| 38 | - echo ' |
|
| 38 | + if (isset($context['pm_sent'])) { |
|
| 39 | + echo ' |
|
| 39 | 40 | <div class="infobox"> |
| 40 | 41 | ', $txt['pm_sent'], ' |
| 41 | 42 | </div>'; |
| 42 | -} |
|
| 43 | + } |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | /** |
| 45 | 47 | * Just the end of the index bar, nothing special. |
@@ -72,8 +74,7 @@ discard block |
||
| 72 | 74 | { |
| 73 | 75 | echo ' |
| 74 | 76 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
| 75 | - } |
|
| 76 | - else |
|
| 77 | + } else |
|
| 77 | 78 | { |
| 78 | 79 | foreach ($context['unread_pms'] as $id_pm => $pm_details) |
| 79 | 80 | { |
@@ -193,14 +194,15 @@ discard block |
||
| 193 | 194 | if ($context['get_pmessage']('message', true)) |
| 194 | 195 | { |
| 195 | 196 | // Show the helpful titlebar - generally. |
| 196 | - if ($context['display_mode'] != 1) |
|
| 197 | - echo ' |
|
| 197 | + if ($context['display_mode'] != 1) { |
|
| 198 | + echo ' |
|
| 198 | 199 | <div class="cat_bar"> |
| 199 | 200 | <h3 class="catbg"> |
| 200 | 201 | <span id="author">', $txt['author'], '</span> |
| 201 | 202 | <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span> |
| 202 | 203 | </h3> |
| 203 | 204 | </div>'; |
| 205 | + } |
|
| 204 | 206 | |
| 205 | 207 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 206 | 208 | if ($context['display_mode'] == 2) |
@@ -229,9 +231,10 @@ discard block |
||
| 229 | 231 | <div class="custom_fields_above_member"> |
| 230 | 232 | <ul class="nolist">'; |
| 231 | 233 | |
| 232 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 233 | - echo ' |
|
| 234 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 235 | + echo ' |
|
| 234 | 236 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 237 | + } |
|
| 235 | 238 | |
| 236 | 239 | echo ' |
| 237 | 240 | </ul> |
@@ -243,9 +246,10 @@ discard block |
||
| 243 | 246 | <a id="msg', $message['id'], '"></a>'; |
| 244 | 247 | |
| 245 | 248 | // Show online and offline buttons? |
| 246 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 247 | - echo ' |
|
| 249 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 250 | + echo ' |
|
| 248 | 251 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
| 252 | + } |
|
| 249 | 253 | |
| 250 | 254 | // Show a link to the member's profile (but only if the sender isn't a guest). |
| 251 | 255 | echo ' |
@@ -258,48 +262,56 @@ discard block |
||
| 258 | 262 | <ul class="user_info">'; |
| 259 | 263 | |
| 260 | 264 | // Show the user's avatar. |
| 261 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 262 | - echo ' |
|
| 265 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 266 | + echo ' |
|
| 263 | 267 | <li class="avatar"> |
| 264 | 268 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
| 265 | 269 | </li>'; |
| 270 | + } |
|
| 266 | 271 | |
| 267 | 272 | // Are there any custom fields below the avatar? |
| 268 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 269 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 273 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 274 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 270 | 275 | echo ' |
| 271 | 276 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 277 | + } |
|
| 272 | 278 | |
| 273 | - if (!$message['member']['is_guest']) |
|
| 274 | - echo ' |
|
| 279 | + if (!$message['member']['is_guest']) { |
|
| 280 | + echo ' |
|
| 275 | 281 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 282 | + } |
|
| 276 | 283 | // Show the member's primary group (like 'Administrator') if they have one. |
| 277 | - if (isset($message['member']['group']) && $message['member']['group'] != '') |
|
| 278 | - echo ' |
|
| 284 | + if (isset($message['member']['group']) && $message['member']['group'] != '') { |
|
| 285 | + echo ' |
|
| 279 | 286 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 287 | + } |
|
| 280 | 288 | |
| 281 | 289 | // Show the member's custom title, if they have one. |
| 282 | - if (isset($message['member']['title']) && $message['member']['title'] != '') |
|
| 283 | - echo ' |
|
| 290 | + if (isset($message['member']['title']) && $message['member']['title'] != '') { |
|
| 291 | + echo ' |
|
| 284 | 292 | <li class="title">', $message['member']['title'], '</li>'; |
| 293 | + } |
|
| 285 | 294 | |
| 286 | 295 | // Don't show these things for guests. |
| 287 | 296 | if (!$message['member']['is_guest']) |
| 288 | 297 | { |
| 289 | 298 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 290 | - if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
|
| 291 | - echo ' |
|
| 299 | + if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') { |
|
| 300 | + echo ' |
|
| 292 | 301 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 302 | + } |
|
| 293 | 303 | |
| 294 | 304 | // Show how many posts they have made. |
| 295 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 296 | - echo ' |
|
| 305 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 306 | + echo ' |
|
| 297 | 307 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 308 | + } |
|
| 298 | 309 | |
| 299 | 310 | // Show their personal text? |
| 300 | - if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
|
| 301 | - echo ' |
|
| 311 | + if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') { |
|
| 312 | + echo ' |
|
| 302 | 313 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 314 | + } |
|
| 303 | 315 | |
| 304 | 316 | // Any custom fields to show as icons? |
| 305 | 317 | if (!empty($message['custom_fields']['icons'])) |
@@ -308,9 +320,10 @@ discard block |
||
| 308 | 320 | <li class="im_icons"> |
| 309 | 321 | <ol>'; |
| 310 | 322 | |
| 311 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 312 | - echo ' |
|
| 323 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 324 | + echo ' |
|
| 313 | 325 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 326 | + } |
|
| 314 | 327 | |
| 315 | 328 | echo ' |
| 316 | 329 | </ol> |
@@ -318,19 +331,22 @@ discard block |
||
| 318 | 331 | } |
| 319 | 332 | |
| 320 | 333 | // Show the IP to this user for this post - because you can moderate? |
| 321 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 322 | - echo ' |
|
| 334 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 335 | + echo ' |
|
| 323 | 336 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
| 337 | + } |
|
| 324 | 338 | |
| 325 | 339 | // Or, should we show it because this is you? |
| 326 | - elseif ($message['can_see_ip']) |
|
| 327 | - echo ' |
|
| 340 | + elseif ($message['can_see_ip']) { |
|
| 341 | + echo ' |
|
| 328 | 342 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
| 343 | + } |
|
| 329 | 344 | |
| 330 | 345 | // Okay, you are logged in, then we can show something about why IPs are logged... |
| 331 | - else |
|
| 332 | - echo ' |
|
| 346 | + else { |
|
| 347 | + echo ' |
|
| 333 | 348 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
| 349 | + } |
|
| 334 | 350 | |
| 335 | 351 | // Show the profile, website, email address, and personal message buttons. |
| 336 | 352 | if ($message['member']['show_profile_buttons']) |
@@ -340,24 +356,28 @@ discard block |
||
| 340 | 356 | <ol class="profile_icons">'; |
| 341 | 357 | |
| 342 | 358 | // Show the profile button |
| 343 | - if ($message['member']['can_view_profile']) |
|
| 344 | - echo ' |
|
| 359 | + if ($message['member']['can_view_profile']) { |
|
| 360 | + echo ' |
|
| 345 | 361 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
| 362 | + } |
|
| 346 | 363 | |
| 347 | 364 | // Don't show an icon if they haven't specified a website. |
| 348 | - if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
|
| 349 | - echo ' |
|
| 365 | + if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) { |
|
| 366 | + echo ' |
|
| 350 | 367 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 368 | + } |
|
| 351 | 369 | |
| 352 | 370 | // Don't show the email address if they want it hidden. |
| 353 | - if ($message['member']['show_email']) |
|
| 354 | - echo ' |
|
| 371 | + if ($message['member']['show_email']) { |
|
| 372 | + echo ' |
|
| 355 | 373 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 374 | + } |
|
| 356 | 375 | |
| 357 | 376 | // Since we know this person isn't a guest, you *can* message them. |
| 358 | - if ($context['can_send_pm']) |
|
| 359 | - echo ' |
|
| 377 | + if ($context['can_send_pm']) { |
|
| 378 | + echo ' |
|
| 360 | 379 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 380 | + } |
|
| 361 | 381 | |
| 362 | 382 | echo ' |
| 363 | 383 | </ol> |
@@ -365,21 +385,24 @@ discard block |
||
| 365 | 385 | } |
| 366 | 386 | |
| 367 | 387 | // Any custom fields for standard placement? |
| 368 | - if (!empty($message['custom_fields']['standard'])) |
|
| 369 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 388 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 389 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 370 | 390 | echo ' |
| 371 | 391 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 392 | + } |
|
| 372 | 393 | |
| 373 | 394 | // Are we showing the warning status? |
| 374 | - if ($message['member']['can_see_warning']) |
|
| 375 | - echo ' |
|
| 395 | + if ($message['member']['can_see_warning']) { |
|
| 396 | + echo ' |
|
| 376 | 397 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 398 | + } |
|
| 377 | 399 | |
| 378 | 400 | // Are there any custom fields to show at the bottom of the poster info? |
| 379 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 380 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 401 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 402 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 381 | 403 | echo ' |
| 382 | 404 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 405 | + } |
|
| 383 | 406 | } |
| 384 | 407 | |
| 385 | 408 | // Done with the information about the poster... on to the post itself. |
@@ -398,25 +421,29 @@ discard block |
||
| 398 | 421 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
| 399 | 422 | |
| 400 | 423 | // People it was sent directly to.... |
| 401 | - if (!empty($message['recipients']['to'])) |
|
| 402 | - echo implode(', ', $message['recipients']['to']); |
|
| 424 | + if (!empty($message['recipients']['to'])) { |
|
| 425 | + echo implode(', ', $message['recipients']['to']); |
|
| 426 | + } |
|
| 403 | 427 | // Otherwise, we're just going to say "some people"... |
| 404 | - elseif ($context['folder'] != 'sent') |
|
| 405 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 428 | + elseif ($context['folder'] != 'sent') { |
|
| 429 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 430 | + } |
|
| 406 | 431 | |
| 407 | 432 | echo ' |
| 408 | 433 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
| 409 | 434 | </span>'; |
| 410 | 435 | |
| 411 | 436 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
| 412 | - if (!empty($message['recipients']['bcc'])) |
|
| 413 | - echo ' |
|
| 437 | + if (!empty($message['recipients']['bcc'])) { |
|
| 438 | + echo ' |
|
| 414 | 439 | <br><span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
| 440 | + } |
|
| 415 | 441 | |
| 416 | - if (!empty($message['is_replied_to'])) |
|
| 417 | - echo ' |
|
| 442 | + if (!empty($message['is_replied_to'])) { |
|
| 443 | + echo ' |
|
| 418 | 444 | <br><span class="smalltext">« ', $txt['pm_is_replied_to'], ' »</span> |
| 419 | 445 | <br><span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
| 446 | + } |
|
| 420 | 447 | |
| 421 | 448 | echo ' |
| 422 | 449 | </div> |
@@ -424,13 +451,15 @@ discard block |
||
| 424 | 451 | <div class="post"> |
| 425 | 452 | <div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>'; |
| 426 | 453 | |
| 427 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 428 | - echo ' |
|
| 454 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 455 | + echo ' |
|
| 429 | 456 | <div class="under_message">'; |
| 457 | + } |
|
| 430 | 458 | |
| 431 | - if ($message['can_report']) |
|
| 432 | - echo ' |
|
| 459 | + if ($message['can_report']) { |
|
| 460 | + echo ' |
|
| 433 | 461 | <a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>'; |
| 462 | + } |
|
| 434 | 463 | |
| 435 | 464 | echo ' |
| 436 | 465 | <ul class="quickbuttons">'; |
@@ -442,32 +471,36 @@ discard block |
||
| 442 | 471 | if (!$message['member']['is_guest']) |
| 443 | 472 | { |
| 444 | 473 | // Is there than more than one recipient you can reply to? |
| 445 | - if ($message['number_recipients'] > 1) |
|
| 446 | - echo ' |
|
| 474 | + if ($message['number_recipients'] > 1) { |
|
| 475 | + echo ' |
|
| 447 | 476 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>'; |
| 477 | + } |
|
| 448 | 478 | |
| 449 | 479 | echo ' |
| 450 | 480 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li> |
| 451 | 481 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 452 | 482 | } |
| 453 | 483 | // This is for "forwarding" - even if the member is gone. |
| 454 | - else |
|
| 455 | - echo ' |
|
| 484 | + else { |
|
| 485 | + echo ' |
|
| 456 | 486 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>'; |
| 487 | + } |
|
| 457 | 488 | } |
| 458 | 489 | echo ' |
| 459 | 490 | <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>'; |
| 460 | 491 | |
| 461 | - if (empty($context['display_mode'])) |
|
| 462 | - echo ' |
|
| 492 | + if (empty($context['display_mode'])) { |
|
| 493 | + echo ' |
|
| 463 | 494 | <li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;" class="input_check"></li>'; |
| 495 | + } |
|
| 464 | 496 | |
| 465 | 497 | echo ' |
| 466 | 498 | </ul>'; |
| 467 | 499 | |
| 468 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 469 | - echo ' |
|
| 500 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 501 | + echo ' |
|
| 470 | 502 | </div>'; |
| 503 | + } |
|
| 471 | 504 | |
| 472 | 505 | // Are there any custom profile fields for above the signature? |
| 473 | 506 | if (!empty($message['custom_fields']['above_signature'])) |
@@ -476,9 +509,10 @@ discard block |
||
| 476 | 509 | <div class="custom_fields_above_signature"> |
| 477 | 510 | <ul class="nolist">'; |
| 478 | 511 | |
| 479 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 480 | - echo ' |
|
| 512 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 513 | + echo ' |
|
| 481 | 514 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 515 | + } |
|
| 482 | 516 | |
| 483 | 517 | echo ' |
| 484 | 518 | </ul> |
@@ -486,9 +520,10 @@ discard block |
||
| 486 | 520 | } |
| 487 | 521 | |
| 488 | 522 | // Show the member's signature? |
| 489 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 490 | - echo ' |
|
| 523 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 524 | + echo ' |
|
| 491 | 525 | <div class="signature">', $message['member']['signature'], '</div>'; |
| 526 | + } |
|
| 492 | 527 | |
| 493 | 528 | // Are there any custom profile fields for below the signature? |
| 494 | 529 | if (!empty($message['custom_fields']['below_signature'])) |
@@ -497,9 +532,10 @@ discard block |
||
| 497 | 532 | <div class="custom_fields_below_signature"> |
| 498 | 533 | <ul class="nolist">'; |
| 499 | 534 | |
| 500 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 501 | - echo ' |
|
| 535 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 536 | + echo ' |
|
| 502 | 537 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 538 | + } |
|
| 503 | 539 | |
| 504 | 540 | echo ' |
| 505 | 541 | </ul> |
@@ -524,19 +560,21 @@ discard block |
||
| 524 | 560 | { |
| 525 | 561 | echo ' |
| 526 | 562 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
| 527 | - foreach ($context['labels'] as $label) |
|
| 528 | - if (!isset($message['labels'][$label['id']])) |
|
| 563 | + foreach ($context['labels'] as $label) { |
|
| 564 | + if (!isset($message['labels'][$label['id']])) |
|
| 529 | 565 | echo ' |
| 530 | 566 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
| 567 | + } |
|
| 531 | 568 | } |
| 532 | 569 | // ... and are there any that can be removed? |
| 533 | 570 | if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1]))) |
| 534 | 571 | { |
| 535 | 572 | echo ' |
| 536 | 573 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
| 537 | - foreach ($message['labels'] as $label) |
|
| 538 | - echo ' |
|
| 574 | + foreach ($message['labels'] as $label) { |
|
| 575 | + echo ' |
|
| 539 | 576 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
| 577 | + } |
|
| 540 | 578 | } |
| 541 | 579 | echo ' |
| 542 | 580 | </select> |
@@ -556,13 +594,14 @@ discard block |
||
| 556 | 594 | </div>'; |
| 557 | 595 | } |
| 558 | 596 | |
| 559 | - if (empty($context['display_mode'])) |
|
| 560 | - echo ' |
|
| 597 | + if (empty($context['display_mode'])) { |
|
| 598 | + echo ' |
|
| 561 | 599 | |
| 562 | 600 | <div class="pagesection"> |
| 563 | 601 | <div class="floatleft">', $context['page_index'], '</div> |
| 564 | 602 | <div class="floatright"><input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" style="font-weight: normal;" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit"></div> |
| 565 | 603 | </div>'; |
| 604 | + } |
|
| 566 | 605 | |
| 567 | 606 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 568 | 607 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
@@ -622,11 +661,12 @@ discard block |
||
| 622 | 661 | </tr> |
| 623 | 662 | </thead> |
| 624 | 663 | <tbody>'; |
| 625 | - if (!$context['show_delete']) |
|
| 626 | - echo ' |
|
| 664 | + if (!$context['show_delete']) { |
|
| 665 | + echo ' |
|
| 627 | 666 | <tr class="windowbg"> |
| 628 | 667 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
| 629 | 668 | </tr>'; |
| 669 | + } |
|
| 630 | 670 | |
| 631 | 671 | while ($message = $context['get_pmessage']('subject')) |
| 632 | 672 | { |
@@ -679,9 +719,10 @@ discard block |
||
| 679 | 719 | |
| 680 | 720 | foreach ($context['labels'] as $label) |
| 681 | 721 | { |
| 682 | - if ($label['id'] != $context['current_label_id']) |
|
| 683 | - echo ' |
|
| 722 | + if ($label['id'] != $context['current_label_id']) { |
|
| 723 | + echo ' |
|
| 684 | 724 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
| 725 | + } |
|
| 685 | 726 | } |
| 686 | 727 | |
| 687 | 728 | echo ' |
@@ -766,9 +807,10 @@ discard block |
||
| 766 | 807 | <dt class="between">', $txt['pm_search_post_age'], ':</dt> |
| 767 | 808 | <dd>', $txt['pm_search_between'], ' <input type="number" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" class="input_text" min="0" max="9999"> ', $txt['pm_search_between_and'], ' <input type="number" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" class="input_text" min="0" max="9999"> ', $txt['pm_search_between_days'], '</dd> |
| 768 | 809 | </dl>'; |
| 769 | - if (!$context['currently_using_labels']) |
|
| 770 | - echo ' |
|
| 810 | + if (!$context['currently_using_labels']) { |
|
| 811 | + echo ' |
|
| 771 | 812 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit">'; |
| 813 | + } |
|
| 772 | 814 | echo ' |
| 773 | 815 | <br class="clear_right"> |
| 774 | 816 | </div> |
@@ -788,12 +830,13 @@ discard block |
||
| 788 | 830 | <div id="advanced_panel_div"> |
| 789 | 831 | <ul id="searchLabelsExpand">'; |
| 790 | 832 | |
| 791 | - foreach ($context['search_labels'] as $label) |
|
| 792 | - echo ' |
|
| 833 | + foreach ($context['search_labels'] as $label) { |
|
| 834 | + echo ' |
|
| 793 | 835 | <li> |
| 794 | 836 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', ' class="input_check"> |
| 795 | 837 | ', $label['name'], '</label> |
| 796 | 838 | </li>'; |
| 839 | + } |
|
| 797 | 840 | |
| 798 | 841 | echo ' |
| 799 | 842 | </ul> |
@@ -853,8 +896,8 @@ discard block |
||
| 853 | 896 | </div>'; |
| 854 | 897 | |
| 855 | 898 | // complete results ? |
| 856 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 857 | - echo ' |
|
| 899 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 900 | + echo ' |
|
| 858 | 901 | <table class="table_grid"> |
| 859 | 902 | <thead> |
| 860 | 903 | <tr class="title_bar"> |
@@ -864,6 +907,7 @@ discard block |
||
| 864 | 907 | </tr> |
| 865 | 908 | </thead> |
| 866 | 909 | <tbody>'; |
| 910 | + } |
|
| 867 | 911 | |
| 868 | 912 | // Print each message out... |
| 869 | 913 | foreach ($context['personal_messages'] as $message) |
@@ -883,11 +927,13 @@ discard block |
||
| 883 | 927 | |
| 884 | 928 | // Show the recipients. |
| 885 | 929 | // @todo This doesn't deal with the sent item searching quite right for bcc. |
| 886 | - if (!empty($message['recipients']['to'])) |
|
| 887 | - echo implode(', ', $message['recipients']['to']); |
|
| 930 | + if (!empty($message['recipients']['to'])) { |
|
| 931 | + echo implode(', ', $message['recipients']['to']); |
|
| 932 | + } |
|
| 888 | 933 | // Otherwise, we're just going to say "some people"... |
| 889 | - elseif ($context['folder'] != 'sent') |
|
| 890 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 934 | + elseif ($context['folder'] != 'sent') { |
|
| 935 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 936 | + } |
|
| 891 | 937 | |
| 892 | 938 | echo ' |
| 893 | 939 | </h3> |
@@ -901,14 +947,16 @@ discard block |
||
| 901 | 947 | $quote_button = create_button('quote.png', 'reply_quote', 'reply_quote', 'class="centericon"'); |
| 902 | 948 | $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"'); |
| 903 | 949 | // You can only reply if they are not a guest... |
| 904 | - if (!$message['member']['is_guest']) |
|
| 905 | - echo ' |
|
| 950 | + if (!$message['member']['is_guest']) { |
|
| 951 | + echo ' |
|
| 906 | 952 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
| 907 | 953 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
| 954 | + } |
|
| 908 | 955 | // This is for "forwarding" - even if the member is gone. |
| 909 | - else |
|
| 910 | - echo ' |
|
| 956 | + else { |
|
| 957 | + echo ' |
|
| 911 | 958 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
| 959 | + } |
|
| 912 | 960 | } |
| 913 | 961 | |
| 914 | 962 | echo ' |
@@ -929,17 +977,19 @@ discard block |
||
| 929 | 977 | } |
| 930 | 978 | |
| 931 | 979 | // Finish off the page... |
| 932 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 933 | - echo ' |
|
| 980 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 981 | + echo ' |
|
| 934 | 982 | </tbody> |
| 935 | 983 | </table>'; |
| 984 | + } |
|
| 936 | 985 | |
| 937 | 986 | // No results? |
| 938 | - if (empty($context['personal_messages'])) |
|
| 939 | - echo ' |
|
| 987 | + if (empty($context['personal_messages'])) { |
|
| 988 | + echo ' |
|
| 940 | 989 | <div class="windowbg"> |
| 941 | 990 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
| 942 | 991 | </div>'; |
| 992 | + } |
|
| 943 | 993 | |
| 944 | 994 | echo ' |
| 945 | 995 | <div class="pagesection"> |
@@ -963,12 +1013,14 @@ discard block |
||
| 963 | 1013 | <h3 class="catbg">', $txt['pm_send_report'], '</h3> |
| 964 | 1014 | </div> |
| 965 | 1015 | <div class="windowbg">'; |
| 966 | - if (!empty($context['send_log']['sent'])) |
|
| 967 | - foreach ($context['send_log']['sent'] as $log_entry) |
|
| 1016 | + if (!empty($context['send_log']['sent'])) { |
|
| 1017 | + foreach ($context['send_log']['sent'] as $log_entry) |
|
| 968 | 1018 | echo '<span class="error">', $log_entry, '</span><br>'; |
| 969 | - if (!empty($context['send_log']['failed'])) |
|
| 970 | - foreach ($context['send_log']['failed'] as $log_entry) |
|
| 1019 | + } |
|
| 1020 | + if (!empty($context['send_log']['failed'])) { |
|
| 1021 | + foreach ($context['send_log']['failed'] as $log_entry) |
|
| 971 | 1022 | echo '<span class="error">', $log_entry, '</span><br>'; |
| 1023 | + } |
|
| 972 | 1024 | echo ' |
| 973 | 1025 | </div> |
| 974 | 1026 | <br>'; |
@@ -1016,12 +1068,13 @@ discard block |
||
| 1016 | 1068 | </dl> |
| 1017 | 1069 | </div>'; |
| 1018 | 1070 | |
| 1019 | - if (!empty($modSettings['drafts_pm_enabled'])) |
|
| 1020 | - echo ' |
|
| 1071 | + if (!empty($modSettings['drafts_pm_enabled'])) { |
|
| 1072 | + echo ' |
|
| 1021 | 1073 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
| 1022 | 1074 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
| 1023 | 1075 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
| 1024 | 1076 | </div>'; |
| 1077 | + } |
|
| 1025 | 1078 | |
| 1026 | 1079 | echo ' |
| 1027 | 1080 | <dl id="post_header">'; |
@@ -1076,9 +1129,10 @@ discard block |
||
| 1076 | 1129 | } |
| 1077 | 1130 | |
| 1078 | 1131 | // What about smileys? |
| 1079 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
| 1080 | - echo ' |
|
| 1132 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
| 1133 | + echo ' |
|
| 1081 | 1134 | <div id="smileyBox_message"></div>'; |
| 1135 | + } |
|
| 1082 | 1136 | |
| 1083 | 1137 | // Show BBC buttons, smileys and textbox. |
| 1084 | 1138 | echo ' |
@@ -1125,10 +1179,11 @@ discard block |
||
| 1125 | 1179 | <dt><strong>', $txt['subject'], '</strong></dt> |
| 1126 | 1180 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
| 1127 | 1181 | |
| 1128 | - foreach ($context['drafts'] as $draft) |
|
| 1129 | - echo ' |
|
| 1182 | + foreach ($context['drafts'] as $draft) { |
|
| 1183 | + echo ' |
|
| 1130 | 1184 | <dt>', $draft['link'], '</dt> |
| 1131 | 1185 | <dd>', $draft['poster_time'], '</dd>'; |
| 1186 | + } |
|
| 1132 | 1187 | echo ' |
| 1133 | 1188 | </dl> |
| 1134 | 1189 | </div>'; |
@@ -1234,8 +1289,8 @@ discard block |
||
| 1234 | 1289 | }'; |
| 1235 | 1290 | |
| 1236 | 1291 | // Code for showing and hiding drafts |
| 1237 | - if (!empty($context['drafts'])) |
|
| 1238 | - echo ' |
|
| 1292 | + if (!empty($context['drafts'])) { |
|
| 1293 | + echo ' |
|
| 1239 | 1294 | var oSwapDraftOptions = new smc_Toggle({ |
| 1240 | 1295 | bToggleEnabled: true, |
| 1241 | 1296 | bCurrentlyCollapsed: true, |
@@ -1257,13 +1312,14 @@ discard block |
||
| 1257 | 1312 | } |
| 1258 | 1313 | ] |
| 1259 | 1314 | });'; |
| 1315 | + } |
|
| 1260 | 1316 | |
| 1261 | 1317 | echo ' |
| 1262 | 1318 | </script>'; |
| 1263 | 1319 | |
| 1264 | 1320 | // Show the message you're replying to. |
| 1265 | - if ($context['reply']) |
|
| 1266 | - echo ' |
|
| 1321 | + if ($context['reply']) { |
|
| 1322 | + echo ' |
|
| 1267 | 1323 | <br> |
| 1268 | 1324 | <br> |
| 1269 | 1325 | <div class="cat_bar"> |
@@ -1277,6 +1333,7 @@ discard block |
||
| 1277 | 1333 | <hr> |
| 1278 | 1334 | ', $context['quoted_message']['body'], ' |
| 1279 | 1335 | </div><br class="clear">'; |
| 1336 | + } |
|
| 1280 | 1337 | |
| 1281 | 1338 | echo ' |
| 1282 | 1339 | <script> |
@@ -1287,22 +1344,24 @@ discard block |
||
| 1287 | 1344 | sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\', |
| 1288 | 1345 | sToControlId: \'to_control\', |
| 1289 | 1346 | aToRecipients: ['; |
| 1290 | - foreach ($context['recipients']['to'] as $i => $member) |
|
| 1291 | - echo ' |
|
| 1347 | + foreach ($context['recipients']['to'] as $i => $member) { |
|
| 1348 | + echo ' |
|
| 1292 | 1349 | { |
| 1293 | 1350 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1294 | 1351 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1295 | 1352 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
| 1353 | + } |
|
| 1296 | 1354 | |
| 1297 | 1355 | echo ' |
| 1298 | 1356 | ], |
| 1299 | 1357 | aBccRecipients: ['; |
| 1300 | - foreach ($context['recipients']['bcc'] as $i => $member) |
|
| 1301 | - echo ' |
|
| 1358 | + foreach ($context['recipients']['bcc'] as $i => $member) { |
|
| 1359 | + echo ' |
|
| 1302 | 1360 | { |
| 1303 | 1361 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1304 | 1362 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1305 | 1363 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
| 1364 | + } |
|
| 1306 | 1365 | |
| 1307 | 1366 | echo ' |
| 1308 | 1367 | ], |
@@ -1389,26 +1448,28 @@ discard block |
||
| 1389 | 1448 | </th> |
| 1390 | 1449 | <th class="centertext table_icon">'; |
| 1391 | 1450 | |
| 1392 | - if (count($context['labels']) > 2) |
|
| 1393 | - echo ' |
|
| 1451 | + if (count($context['labels']) > 2) { |
|
| 1452 | + echo ' |
|
| 1394 | 1453 | <input type="checkbox" class="input_check" onclick="invertAll(this, this.form);">'; |
| 1454 | + } |
|
| 1395 | 1455 | |
| 1396 | 1456 | echo ' |
| 1397 | 1457 | </th> |
| 1398 | 1458 | </tr> |
| 1399 | 1459 | </thead> |
| 1400 | 1460 | <tbody>'; |
| 1401 | - if (count($context['labels']) < 2) |
|
| 1402 | - echo ' |
|
| 1461 | + if (count($context['labels']) < 2) { |
|
| 1462 | + echo ' |
|
| 1403 | 1463 | <tr class="windowbg"> |
| 1404 | 1464 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
| 1405 | 1465 | </tr>'; |
| 1406 | - else |
|
| 1466 | + } else |
|
| 1407 | 1467 | { |
| 1408 | 1468 | foreach ($context['labels'] as $label) |
| 1409 | 1469 | { |
| 1410 | - if ($label['id'] == -1) |
|
| 1411 | - continue; |
|
| 1470 | + if ($label['id'] == -1) { |
|
| 1471 | + continue; |
|
| 1472 | + } |
|
| 1412 | 1473 | |
| 1413 | 1474 | echo ' |
| 1414 | 1475 | <tr class="windowbg"> |
@@ -1423,12 +1484,13 @@ discard block |
||
| 1423 | 1484 | </tbody> |
| 1424 | 1485 | </table>'; |
| 1425 | 1486 | |
| 1426 | - if (!count($context['labels']) < 2) |
|
| 1427 | - echo ' |
|
| 1487 | + if (!count($context['labels']) < 2) { |
|
| 1488 | + echo ' |
|
| 1428 | 1489 | <div class="padding"> |
| 1429 | 1490 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit"> |
| 1430 | 1491 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button_submit you_sure"> |
| 1431 | 1492 | </div>'; |
| 1493 | + } |
|
| 1432 | 1494 | |
| 1433 | 1495 | echo ' |
| 1434 | 1496 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1483,9 +1545,10 @@ discard block |
||
| 1483 | 1545 | <dd> |
| 1484 | 1546 | <select name="id_admin"> |
| 1485 | 1547 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
| 1486 | - foreach ($context['admins'] as $id => $name) |
|
| 1487 | - echo ' |
|
| 1548 | + foreach ($context['admins'] as $id => $name) { |
|
| 1549 | + echo ' |
|
| 1488 | 1550 | <option value="', $id, '">', $name, '</option>'; |
| 1551 | + } |
|
| 1489 | 1552 | echo ' |
| 1490 | 1553 | </select> |
| 1491 | 1554 | </dd>'; |
@@ -1547,9 +1610,10 @@ discard block |
||
| 1547 | 1610 | </th> |
| 1548 | 1611 | <th class="centertext table_icon">'; |
| 1549 | 1612 | |
| 1550 | - if (!empty($context['rules'])) |
|
| 1551 | - echo ' |
|
| 1613 | + if (!empty($context['rules'])) { |
|
| 1614 | + echo ' |
|
| 1552 | 1615 | <input type="checkbox" onclick="invertAll(this, this.form);" class="input_check">'; |
| 1616 | + } |
|
| 1553 | 1617 | |
| 1554 | 1618 | echo ' |
| 1555 | 1619 | </th> |
@@ -1557,13 +1621,14 @@ discard block |
||
| 1557 | 1621 | </thead> |
| 1558 | 1622 | <tbody>'; |
| 1559 | 1623 | |
| 1560 | - if (empty($context['rules'])) |
|
| 1561 | - echo ' |
|
| 1624 | + if (empty($context['rules'])) { |
|
| 1625 | + echo ' |
|
| 1562 | 1626 | <tr class="windowbg"> |
| 1563 | 1627 | <td colspan="2"> |
| 1564 | 1628 | ', $txt['pm_rules_none'], ' |
| 1565 | 1629 | </td> |
| 1566 | 1630 | </tr>'; |
| 1631 | + } |
|
| 1567 | 1632 | |
| 1568 | 1633 | foreach ($context['rules'] as $rule) |
| 1569 | 1634 | { |
@@ -1584,14 +1649,16 @@ discard block |
||
| 1584 | 1649 | <div class="righttext"> |
| 1585 | 1650 | <a class="button_link" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
| 1586 | 1651 | |
| 1587 | - if (!empty($context['rules'])) |
|
| 1588 | - echo ' |
|
| 1652 | + if (!empty($context['rules'])) { |
|
| 1653 | + echo ' |
|
| 1589 | 1654 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
| 1655 | + } |
|
| 1590 | 1656 | |
| 1591 | - if (!empty($context['rules'])) |
|
| 1592 | - echo ' |
|
| 1657 | + if (!empty($context['rules'])) { |
|
| 1658 | + echo ' |
|
| 1593 | 1659 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1594 | 1660 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button_submit smalltext you_sure">'; |
| 1661 | + } |
|
| 1595 | 1662 | |
| 1596 | 1663 | echo ' |
| 1597 | 1664 | </div> |
@@ -1613,14 +1680,16 @@ discard block |
||
| 1613 | 1680 | var groups = new Array() |
| 1614 | 1681 | var labels = new Array()'; |
| 1615 | 1682 | |
| 1616 | - foreach ($context['groups'] as $id => $title) |
|
| 1617 | - echo ' |
|
| 1683 | + foreach ($context['groups'] as $id => $title) { |
|
| 1684 | + echo ' |
|
| 1618 | 1685 | groups[', $id, '] = "', addslashes($title), '";'; |
| 1686 | + } |
|
| 1619 | 1687 | |
| 1620 | - foreach ($context['labels'] as $label) |
|
| 1621 | - if ($label['id'] != -1) |
|
| 1688 | + foreach ($context['labels'] as $label) { |
|
| 1689 | + if ($label['id'] != -1) |
|
| 1622 | 1690 | echo ' |
| 1623 | 1691 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
| 1692 | + } |
|
| 1624 | 1693 | |
| 1625 | 1694 | echo ' |
| 1626 | 1695 | function addCriteriaOption() |
@@ -1635,8 +1704,9 @@ discard block |
||
| 1635 | 1704 | |
| 1636 | 1705 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value="" class="input_text"><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
| 1637 | 1706 | |
| 1638 | - foreach ($context['groups'] as $id => $group) |
|
| 1639 | - echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1707 | + foreach ($context['groups'] as $id => $group) { |
|
| 1708 | + echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1709 | + } |
|
| 1640 | 1710 | |
| 1641 | 1711 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
| 1642 | 1712 | } |
@@ -1653,9 +1723,10 @@ discard block |
||
| 1653 | 1723 | |
| 1654 | 1724 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
| 1655 | 1725 | |
| 1656 | - foreach ($context['labels'] as $label) |
|
| 1657 | - if ($label['id'] != -1) |
|
| 1726 | + foreach ($context['labels'] as $label) { |
|
| 1727 | + if ($label['id'] != -1) |
|
| 1658 | 1728 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
| 1729 | + } |
|
| 1659 | 1730 | |
| 1660 | 1731 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
| 1661 | 1732 | } |
@@ -1769,18 +1840,20 @@ discard block |
||
| 1769 | 1840 | $isFirst = true; |
| 1770 | 1841 | foreach ($context['rule']['criteria'] as $k => $criteria) |
| 1771 | 1842 | { |
| 1772 | - if (!$isFirst && $criteria['t'] == '') |
|
| 1773 | - echo '<div id="removeonjs1">'; |
|
| 1774 | - elseif (!$isFirst) |
|
| 1775 | - echo '<br>'; |
|
| 1843 | + if (!$isFirst && $criteria['t'] == '') { |
|
| 1844 | + echo '<div id="removeonjs1">'; |
|
| 1845 | + } elseif (!$isFirst) { |
|
| 1846 | + echo '<br>'; |
|
| 1847 | + } |
|
| 1776 | 1848 | |
| 1777 | 1849 | echo ' |
| 1778 | 1850 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
| 1779 | 1851 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
| 1780 | 1852 | |
| 1781 | - foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
|
| 1782 | - echo ' |
|
| 1853 | + foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) { |
|
| 1854 | + echo ' |
|
| 1783 | 1855 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
| 1856 | + } |
|
| 1784 | 1857 | |
| 1785 | 1858 | echo ' |
| 1786 | 1859 | </select> |
@@ -1791,18 +1864,20 @@ discard block |
||
| 1791 | 1864 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
| 1792 | 1865 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
| 1793 | 1866 | |
| 1794 | - foreach ($context['groups'] as $id => $group) |
|
| 1795 | - echo ' |
|
| 1867 | + foreach ($context['groups'] as $id => $group) { |
|
| 1868 | + echo ' |
|
| 1796 | 1869 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
| 1870 | + } |
|
| 1797 | 1871 | echo ' |
| 1798 | 1872 | </select> |
| 1799 | 1873 | </span>'; |
| 1800 | 1874 | |
| 1801 | 1875 | // If this is the dummy we add a means to hide for non js users. |
| 1802 | - if ($isFirst) |
|
| 1803 | - $isFirst = false; |
|
| 1804 | - elseif ($criteria['t'] == '') |
|
| 1805 | - echo '</div>'; |
|
| 1876 | + if ($isFirst) { |
|
| 1877 | + $isFirst = false; |
|
| 1878 | + } elseif ($criteria['t'] == '') { |
|
| 1879 | + echo '</div>'; |
|
| 1880 | + } |
|
| 1806 | 1881 | } |
| 1807 | 1882 | |
| 1808 | 1883 | echo ' |
@@ -1825,10 +1900,11 @@ discard block |
||
| 1825 | 1900 | $isFirst = true; |
| 1826 | 1901 | foreach ($context['rule']['actions'] as $k => $action) |
| 1827 | 1902 | { |
| 1828 | - if (!$isFirst && $action['t'] == '') |
|
| 1829 | - echo '<div id="removeonjs2">'; |
|
| 1830 | - elseif (!$isFirst) |
|
| 1831 | - echo '<br>'; |
|
| 1903 | + if (!$isFirst && $action['t'] == '') { |
|
| 1904 | + echo '<div id="removeonjs2">'; |
|
| 1905 | + } elseif (!$isFirst) { |
|
| 1906 | + echo '<br>'; |
|
| 1907 | + } |
|
| 1832 | 1908 | |
| 1833 | 1909 | echo ' |
| 1834 | 1910 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
@@ -1839,20 +1915,22 @@ discard block |
||
| 1839 | 1915 | <span id="labdiv', $k, '"> |
| 1840 | 1916 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
| 1841 | 1917 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
| 1842 | - foreach ($context['labels'] as $label) |
|
| 1843 | - if ($label['id'] != -1) |
|
| 1918 | + foreach ($context['labels'] as $label) { |
|
| 1919 | + if ($label['id'] != -1) |
|
| 1844 | 1920 | echo ' |
| 1845 | 1921 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
| 1922 | + } |
|
| 1846 | 1923 | |
| 1847 | 1924 | echo ' |
| 1848 | 1925 | </select> |
| 1849 | 1926 | </span>'; |
| 1850 | 1927 | |
| 1851 | - if ($isFirst) |
|
| 1852 | - $isFirst = false; |
|
| 1853 | - elseif ($action['t'] == '') |
|
| 1854 | - echo ' |
|
| 1928 | + if ($isFirst) { |
|
| 1929 | + $isFirst = false; |
|
| 1930 | + } elseif ($action['t'] == '') { |
|
| 1931 | + echo ' |
|
| 1855 | 1932 | </div>'; |
| 1933 | + } |
|
| 1856 | 1934 | } |
| 1857 | 1935 | |
| 1858 | 1936 | echo ' |
@@ -1876,22 +1954,25 @@ discard block |
||
| 1876 | 1954 | echo ' |
| 1877 | 1955 | <script>'; |
| 1878 | 1956 | |
| 1879 | - foreach ($context['rule']['criteria'] as $k => $c) |
|
| 1880 | - echo ' |
|
| 1957 | + foreach ($context['rule']['criteria'] as $k => $c) { |
|
| 1958 | + echo ' |
|
| 1881 | 1959 | updateRuleDef(', $k, ');'; |
| 1960 | + } |
|
| 1882 | 1961 | |
| 1883 | - foreach ($context['rule']['actions'] as $k => $c) |
|
| 1884 | - echo ' |
|
| 1962 | + foreach ($context['rule']['actions'] as $k => $c) { |
|
| 1963 | + echo ' |
|
| 1885 | 1964 | updateActionDef(', $k, ');'; |
| 1965 | + } |
|
| 1886 | 1966 | |
| 1887 | 1967 | echo ' |
| 1888 | 1968 | rebuildRuleDesc();'; |
| 1889 | 1969 | |
| 1890 | 1970 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
| 1891 | - if ($context['rid']) |
|
| 1892 | - echo ' |
|
| 1971 | + if ($context['rid']) { |
|
| 1972 | + echo ' |
|
| 1893 | 1973 | document.getElementById("removeonjs1").style.display = "none"; |
| 1894 | 1974 | document.getElementById("removeonjs2").style.display = "none";'; |
| 1975 | + } |
|
| 1895 | 1976 | |
| 1896 | 1977 | echo ' |
| 1897 | 1978 | document.getElementById("addonjs1").style.display = ""; |
@@ -1924,12 +2005,12 @@ discard block |
||
| 1924 | 2005 | |
| 1925 | 2006 | |
| 1926 | 2007 | // No drafts? Just show an informative message. |
| 1927 | - if (empty($context['drafts'])) |
|
| 1928 | - echo ' |
|
| 2008 | + if (empty($context['drafts'])) { |
|
| 2009 | + echo ' |
|
| 1929 | 2010 | <div class="windowbg2 centertext"> |
| 1930 | 2011 | ', $txt['draft_none'], ' |
| 1931 | 2012 | </div>'; |
| 1932 | - else |
|
| 2013 | + } else |
|
| 1933 | 2014 | { |
| 1934 | 2015 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 1935 | 2016 | foreach ($context['drafts'] as $draft) |
@@ -116,9 +116,10 @@ discard block |
||
| 116 | 116 | <h3 class="catbg">', $txt['attachment_transfer'], '</h3> |
| 117 | 117 | </div>'; |
| 118 | 118 | |
| 119 | - if (!empty($context['results'])) |
|
| 120 | - echo ' |
|
| 119 | + if (!empty($context['results'])) { |
|
| 120 | + echo ' |
|
| 121 | 121 | <div class="noticebox">', $context['results'], '</div>'; |
| 122 | + } |
|
| 122 | 123 | |
| 123 | 124 | echo ' |
| 124 | 125 | <div class="windowbg2 noup"> |
@@ -129,9 +130,10 @@ discard block |
||
| 129 | 130 | <dd><select name="from"> |
| 130 | 131 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
| 131 | 132 | |
| 132 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
| 133 | - echo ' |
|
| 133 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
| 134 | + echo ' |
|
| 134 | 135 | <option value="', $id, '">', $dir, '</option>'; |
| 136 | + } |
|
| 135 | 137 | echo ' |
| 136 | 138 | </select></dd> |
| 137 | 139 | <dt>', $txt['attachment_transfer_auto'], '</dt> |
@@ -139,13 +141,14 @@ discard block |
||
| 139 | 141 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
| 140 | 142 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
| 141 | 143 | |
| 142 | - if (!empty($context['base_dirs'])) |
|
| 143 | - foreach ($context['base_dirs'] as $id => $dir) |
|
| 144 | + if (!empty($context['base_dirs'])) { |
|
| 145 | + foreach ($context['base_dirs'] as $id => $dir) |
|
| 144 | 146 | echo ' |
| 145 | 147 | <option value="', $id, '">', $dir, '</option>'; |
| 146 | - else |
|
| 147 | - echo ' |
|
| 148 | + } else { |
|
| 149 | + echo ' |
|
| 148 | 150 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
| 151 | + } |
|
| 149 | 152 | |
| 150 | 153 | echo ' |
| 151 | 154 | </select></dd> |
@@ -153,16 +156,18 @@ discard block |
||
| 153 | 156 | <dd><select name="to"> |
| 154 | 157 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
| 155 | 158 | |
| 156 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
| 157 | - echo ' |
|
| 159 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
| 160 | + echo ' |
|
| 158 | 161 | <option value="', $id, '">', $dir, '</option>'; |
| 162 | + } |
|
| 159 | 163 | echo ' |
| 160 | 164 | </select></dd>'; |
| 161 | 165 | |
| 162 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
| 163 | - echo ' |
|
| 166 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
| 167 | + echo ' |
|
| 164 | 168 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
| 165 | 169 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
| 170 | + } |
|
| 166 | 171 | echo ' |
| 167 | 172 | </dl> |
| 168 | 173 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -238,10 +243,11 @@ discard block |
||
| 238 | 243 | // Loop through each error reporting the status |
| 239 | 244 | foreach ($context['repair_errors'] as $error => $number) |
| 240 | 245 | { |
| 241 | - if (!empty($number)) |
|
| 242 | - echo ' |
|
| 246 | + if (!empty($number)) { |
|
| 247 | + echo ' |
|
| 243 | 248 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '" class="input_check"> |
| 244 | 249 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
| 250 | + } |
|
| 245 | 251 | } |
| 246 | 252 | |
| 247 | 253 | echo ' <br> |