Completed
Push — release-2.1 ( 73c57a...e797f1 )
by Michael
08:24
created
Sources/ReCaptcha/RequestMethod.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@
 block discarded – undo
32 32
 interface RequestMethod
33 33
 {
34 34
 
35
-    /**
36
-     * Submit the request with the specified parameters.
37
-     *
38
-     * @param RequestParameters $params Request parameters
39
-     * @return string Body of the reCAPTCHA response
40
-     */
41
-    public function submit(RequestParameters $params);
35
+	/**
36
+	 * Submit the request with the specified parameters.
37
+	 *
38
+	 * @param RequestParameters $params Request parameters
39
+	 * @return string Body of the reCAPTCHA response
40
+	 */
41
+	public function submit(RequestParameters $params);
42 42
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/CurlPost.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -36,53 +36,53 @@
 block discarded – undo
36 36
  */
37 37
 class CurlPost implements RequestMethod
38 38
 {
39
-    /**
40
-     * URL to which requests are sent via cURL.
41
-     * @const string
42
-     */
43
-    const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
39
+	/**
40
+	 * URL to which requests are sent via cURL.
41
+	 * @const string
42
+	 */
43
+	const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
44 44
 
45
-    /**
46
-     * Curl connection to the reCAPTCHA service
47
-     * @var Curl
48
-     */
49
-    private $curl;
45
+	/**
46
+	 * Curl connection to the reCAPTCHA service
47
+	 * @var Curl
48
+	 */
49
+	private $curl;
50 50
 
51
-    public function __construct(Curl $curl = null)
52
-    {
53
-        if (!is_null($curl)) {
54
-            $this->curl = $curl;
55
-        } else {
56
-            $this->curl = new Curl();
57
-        }
58
-    }
51
+	public function __construct(Curl $curl = null)
52
+	{
53
+		if (!is_null($curl)) {
54
+			$this->curl = $curl;
55
+		} else {
56
+			$this->curl = new Curl();
57
+		}
58
+	}
59 59
 
60
-    /**
61
-     * Submit the cURL request with the specified parameters.
62
-     *
63
-     * @param RequestParameters $params Request parameters
64
-     * @return string Body of the reCAPTCHA response
65
-     */
66
-    public function submit(RequestParameters $params)
67
-    {
68
-        $handle = $this->curl->init(self::SITE_VERIFY_URL);
60
+	/**
61
+	 * Submit the cURL request with the specified parameters.
62
+	 *
63
+	 * @param RequestParameters $params Request parameters
64
+	 * @return string Body of the reCAPTCHA response
65
+	 */
66
+	public function submit(RequestParameters $params)
67
+	{
68
+		$handle = $this->curl->init(self::SITE_VERIFY_URL);
69 69
 
70
-        $options = array(
71
-            CURLOPT_POST => true,
72
-            CURLOPT_POSTFIELDS => $params->toQueryString(),
73
-            CURLOPT_HTTPHEADER => array(
74
-                'Content-Type: application/x-www-form-urlencoded'
75
-            ),
76
-            CURLINFO_HEADER_OUT => false,
77
-            CURLOPT_HEADER => false,
78
-            CURLOPT_RETURNTRANSFER => true,
79
-            CURLOPT_SSL_VERIFYPEER => true
80
-        );
81
-        $this->curl->setoptArray($handle, $options);
70
+		$options = array(
71
+			CURLOPT_POST => true,
72
+			CURLOPT_POSTFIELDS => $params->toQueryString(),
73
+			CURLOPT_HTTPHEADER => array(
74
+				'Content-Type: application/x-www-form-urlencoded'
75
+			),
76
+			CURLINFO_HEADER_OUT => false,
77
+			CURLOPT_HEADER => false,
78
+			CURLOPT_RETURNTRANSFER => true,
79
+			CURLOPT_SSL_VERIFYPEER => true
80
+		);
81
+		$this->curl->setoptArray($handle, $options);
82 82
 
83
-        $response = $this->curl->exec($handle);
84
-        $this->curl->close($handle);
83
+		$response = $this->curl->exec($handle);
84
+		$this->curl->close($handle);
85 85
 
86
-        return $response;
87
-    }
86
+		return $response;
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/Post.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -34,37 +34,37 @@
 block discarded – undo
34 34
  */
35 35
 class Post implements RequestMethod
36 36
 {
37
-    /**
38
-     * URL to which requests are POSTed.
39
-     * @const string
40
-     */
41
-    const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
37
+	/**
38
+	 * URL to which requests are POSTed.
39
+	 * @const string
40
+	 */
41
+	const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
42 42
 
43
-    /**
44
-     * Submit the POST request with the specified parameters.
45
-     *
46
-     * @param RequestParameters $params Request parameters
47
-     * @return string Body of the reCAPTCHA response
48
-     */
49
-    public function submit(RequestParameters $params)
50
-    {
51
-        /**
52
-         * PHP 5.6.0 changed the way you specify the peer name for SSL context options.
53
-         * Using "CN_name" will still work, but it will raise deprecated errors.
54
-         */
55
-        $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
56
-        $options = array(
57
-            'http' => array(
58
-                'header' => "Content-type: application/x-www-form-urlencoded\r\n",
59
-                'method' => 'POST',
60
-                'content' => $params->toQueryString(),
61
-                // Force the peer to validate (not needed in 5.6.0+, but still works
62
-                'verify_peer' => true,
63
-                // Force the peer validation to use www.google.com
64
-                $peer_key => 'www.google.com',
65
-            ),
66
-        );
67
-        $context = stream_context_create($options);
68
-        return file_get_contents(self::SITE_VERIFY_URL, false, $context);
69
-    }
43
+	/**
44
+	 * Submit the POST request with the specified parameters.
45
+	 *
46
+	 * @param RequestParameters $params Request parameters
47
+	 * @return string Body of the reCAPTCHA response
48
+	 */
49
+	public function submit(RequestParameters $params)
50
+	{
51
+		/**
52
+		 * PHP 5.6.0 changed the way you specify the peer name for SSL context options.
53
+		 * Using "CN_name" will still work, but it will raise deprecated errors.
54
+		 */
55
+		$peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
56
+		$options = array(
57
+			'http' => array(
58
+				'header' => "Content-type: application/x-www-form-urlencoded\r\n",
59
+				'method' => 'POST',
60
+				'content' => $params->toQueryString(),
61
+				// Force the peer to validate (not needed in 5.6.0+, but still works
62
+				'verify_peer' => true,
63
+				// Force the peer validation to use www.google.com
64
+				$peer_key => 'www.google.com',
65
+			),
66
+		);
67
+		$context = stream_context_create($options);
68
+		return file_get_contents(self::SITE_VERIFY_URL, false, $context);
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/SocketPost.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -36,86 +36,86 @@
 block discarded – undo
36 36
  */
37 37
 class SocketPost implements RequestMethod
38 38
 {
39
-    /**
40
-     * reCAPTCHA service host.
41
-     * @const string
42
-     */
43
-    const RECAPTCHA_HOST = 'www.google.com';
44
-
45
-    /**
46
-     * @const string reCAPTCHA service path
47
-     */
48
-    const SITE_VERIFY_PATH = '/recaptcha/api/siteverify';
49
-
50
-    /**
51
-     * @const string Bad request error
52
-     */
53
-    const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}';
54
-
55
-    /**
56
-     * @const string Bad response error
57
-     */
58
-    const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}';
59
-
60
-    /**
61
-     * Socket to the reCAPTCHA service
62
-     * @var Socket
63
-     */
64
-    private $socket;
65
-
66
-    /**
67
-     * Constructor
68
-     *
69
-     * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
70
-     */
71
-    public function __construct(Socket $socket = null)
72
-    {
73
-        if (!is_null($socket)) {
74
-            $this->socket = $socket;
75
-        } else {
76
-            $this->socket = new Socket();
77
-        }
78
-    }
79
-
80
-    /**
81
-     * Submit the POST request with the specified parameters.
82
-     *
83
-     * @param RequestParameters $params Request parameters
84
-     * @return string Body of the reCAPTCHA response
85
-     */
86
-    public function submit(RequestParameters $params)
87
-    {
88
-        $errno = 0;
89
-        $errstr = '';
90
-
91
-        if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) {
92
-            return self::BAD_REQUEST;
93
-        }
94
-
95
-        $content = $params->toQueryString();
96
-
97
-        $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n";
98
-        $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n";
99
-        $request .= "Content-Type: application/x-www-form-urlencoded\r\n";
100
-        $request .= "Content-length: " . strlen($content) . "\r\n";
101
-        $request .= "Connection: close\r\n\r\n";
102
-        $request .= $content . "\r\n\r\n";
103
-
104
-        $this->socket->fwrite($request);
105
-        $response = '';
106
-
107
-        while (!$this->socket->feof()) {
108
-            $response .= $this->socket->fgets(4096);
109
-        }
110
-
111
-        $this->socket->fclose();
112
-
113
-        if (0 !== strpos($response, 'HTTP/1.1 200 OK')) {
114
-            return self::BAD_RESPONSE;
115
-        }
116
-
117
-        $parts = preg_split("#\n\s*\n#Uis", $response);
118
-
119
-        return $parts[1];
120
-    }
39
+	/**
40
+	 * reCAPTCHA service host.
41
+	 * @const string
42
+	 */
43
+	const RECAPTCHA_HOST = 'www.google.com';
44
+
45
+	/**
46
+	 * @const string reCAPTCHA service path
47
+	 */
48
+	const SITE_VERIFY_PATH = '/recaptcha/api/siteverify';
49
+
50
+	/**
51
+	 * @const string Bad request error
52
+	 */
53
+	const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}';
54
+
55
+	/**
56
+	 * @const string Bad response error
57
+	 */
58
+	const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}';
59
+
60
+	/**
61
+	 * Socket to the reCAPTCHA service
62
+	 * @var Socket
63
+	 */
64
+	private $socket;
65
+
66
+	/**
67
+	 * Constructor
68
+	 *
69
+	 * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
70
+	 */
71
+	public function __construct(Socket $socket = null)
72
+	{
73
+		if (!is_null($socket)) {
74
+			$this->socket = $socket;
75
+		} else {
76
+			$this->socket = new Socket();
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * Submit the POST request with the specified parameters.
82
+	 *
83
+	 * @param RequestParameters $params Request parameters
84
+	 * @return string Body of the reCAPTCHA response
85
+	 */
86
+	public function submit(RequestParameters $params)
87
+	{
88
+		$errno = 0;
89
+		$errstr = '';
90
+
91
+		if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) {
92
+			return self::BAD_REQUEST;
93
+		}
94
+
95
+		$content = $params->toQueryString();
96
+
97
+		$request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n";
98
+		$request .= "Host: " . self::RECAPTCHA_HOST . "\r\n";
99
+		$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
100
+		$request .= "Content-length: " . strlen($content) . "\r\n";
101
+		$request .= "Connection: close\r\n\r\n";
102
+		$request .= $content . "\r\n\r\n";
103
+
104
+		$this->socket->fwrite($request);
105
+		$response = '';
106
+
107
+		while (!$this->socket->feof()) {
108
+			$response .= $this->socket->fgets(4096);
109
+		}
110
+
111
+		$this->socket->fclose();
112
+
113
+		if (0 !== strpos($response, 'HTTP/1.1 200 OK')) {
114
+			return self::BAD_RESPONSE;
115
+		}
116
+
117
+		$parts = preg_split("#\n\s*\n#Uis", $response);
118
+
119
+		return $parts[1];
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/Response.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -31,72 +31,72 @@
 block discarded – undo
31 31
  */
32 32
 class Response
33 33
 {
34
-    /**
35
-     * Succes or failure.
36
-     * @var boolean
37
-     */
38
-    private $success = false;
34
+	/**
35
+	 * Succes or failure.
36
+	 * @var boolean
37
+	 */
38
+	private $success = false;
39 39
 
40
-    /**
41
-     * Error code strings.
42
-     * @var array
43
-     */
44
-    private $errorCodes = array();
40
+	/**
41
+	 * Error code strings.
42
+	 * @var array
43
+	 */
44
+	private $errorCodes = array();
45 45
 
46
-    /**
47
-     * Build the response from the expected JSON returned by the service.
48
-     *
49
-     * @param string $json
50
-     * @return \ReCaptcha\Response
51
-     */
52
-    public static function fromJson($json)
53
-    {
54
-        $responseData = json_decode($json, true);
46
+	/**
47
+	 * Build the response from the expected JSON returned by the service.
48
+	 *
49
+	 * @param string $json
50
+	 * @return \ReCaptcha\Response
51
+	 */
52
+	public static function fromJson($json)
53
+	{
54
+		$responseData = json_decode($json, true);
55 55
 
56
-        if (!$responseData) {
57
-            return new Response(false, array('invalid-json'));
58
-        }
56
+		if (!$responseData) {
57
+			return new Response(false, array('invalid-json'));
58
+		}
59 59
 
60
-        if (isset($responseData['success']) && $responseData['success'] == true) {
61
-            return new Response(true);
62
-        }
60
+		if (isset($responseData['success']) && $responseData['success'] == true) {
61
+			return new Response(true);
62
+		}
63 63
 
64
-        if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
65
-            return new Response(false, $responseData['error-codes']);
66
-        }
64
+		if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
65
+			return new Response(false, $responseData['error-codes']);
66
+		}
67 67
 
68
-        return new Response(false);
69
-    }
68
+		return new Response(false);
69
+	}
70 70
 
71
-    /**
72
-     * Constructor.
73
-     *
74
-     * @param boolean $success
75
-     * @param array $errorCodes
76
-     */
77
-    public function __construct($success, array $errorCodes = array())
78
-    {
79
-        $this->success = $success;
80
-        $this->errorCodes = $errorCodes;
81
-    }
71
+	/**
72
+	 * Constructor.
73
+	 *
74
+	 * @param boolean $success
75
+	 * @param array $errorCodes
76
+	 */
77
+	public function __construct($success, array $errorCodes = array())
78
+	{
79
+		$this->success = $success;
80
+		$this->errorCodes = $errorCodes;
81
+	}
82 82
 
83
-    /**
84
-     * Is success?
85
-     *
86
-     * @return boolean
87
-     */
88
-    public function isSuccess()
89
-    {
90
-        return $this->success;
91
-    }
83
+	/**
84
+	 * Is success?
85
+	 *
86
+	 * @return boolean
87
+	 */
88
+	public function isSuccess()
89
+	{
90
+		return $this->success;
91
+	}
92 92
 
93
-    /**
94
-     * Get error codes.
95
-     *
96
-     * @return array
97
-     */
98
-    public function getErrorCodes()
99
-    {
100
-        return $this->errorCodes;
101
-    }
93
+	/**
94
+	 * Get error codes.
95
+	 *
96
+	 * @return array
97
+	 */
98
+	public function getErrorCodes()
99
+	{
100
+		return $this->errorCodes;
101
+	}
102 102
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/ReCaptcha.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -31,67 +31,67 @@
 block discarded – undo
31 31
  */
32 32
 class ReCaptcha
33 33
 {
34
-    /**
35
-     * Version of this client library.
36
-     * @const string
37
-     */
38
-    const VERSION = 'php_1.1.2';
34
+	/**
35
+	 * Version of this client library.
36
+	 * @const string
37
+	 */
38
+	const VERSION = 'php_1.1.2';
39 39
 
40
-    /**
41
-     * Shared secret for the site.
42
-     * @var type string
43
-     */
44
-    private $secret;
40
+	/**
41
+	 * Shared secret for the site.
42
+	 * @var type string
43
+	 */
44
+	private $secret;
45 45
 
46
-    /**
47
-     * Method used to communicate  with service. Defaults to POST request.
48
-     * @var RequestMethod
49
-     */
50
-    private $requestMethod;
46
+	/**
47
+	 * Method used to communicate  with service. Defaults to POST request.
48
+	 * @var RequestMethod
49
+	 */
50
+	private $requestMethod;
51 51
 
52
-    /**
53
-     * Create a configured instance to use the reCAPTCHA service.
54
-     *
55
-     * @param string $secret shared secret between site and reCAPTCHA server.
56
-     * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
-     */
58
-    public function __construct($secret, RequestMethod $requestMethod = null)
59
-    {
60
-        if (empty($secret)) {
61
-            throw new \RuntimeException('No secret provided');
62
-        }
52
+	/**
53
+	 * Create a configured instance to use the reCAPTCHA service.
54
+	 *
55
+	 * @param string $secret shared secret between site and reCAPTCHA server.
56
+	 * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
+	 */
58
+	public function __construct($secret, RequestMethod $requestMethod = null)
59
+	{
60
+		if (empty($secret)) {
61
+			throw new \RuntimeException('No secret provided');
62
+		}
63 63
 
64
-        if (!is_string($secret)) {
65
-            throw new \RuntimeException('The provided secret must be a string');
66
-        }
64
+		if (!is_string($secret)) {
65
+			throw new \RuntimeException('The provided secret must be a string');
66
+		}
67 67
 
68
-        $this->secret = $secret;
68
+		$this->secret = $secret;
69 69
 
70
-        if (!is_null($requestMethod)) {
71
-            $this->requestMethod = $requestMethod;
72
-        } else {
73
-            $this->requestMethod = new RequestMethod\Post();
74
-        }
75
-    }
70
+		if (!is_null($requestMethod)) {
71
+			$this->requestMethod = $requestMethod;
72
+		} else {
73
+			$this->requestMethod = new RequestMethod\Post();
74
+		}
75
+	}
76 76
 
77
-    /**
78
-     * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
-     * CAPTCHA test.
80
-     *
81
-     * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
-     * @param string $remoteIp The end user's IP address.
83
-     * @return Response Response from the service.
84
-     */
85
-    public function verify($response, $remoteIp = null)
86
-    {
87
-        // Discard empty solution submissions
88
-        if (empty($response)) {
89
-            $recaptchaResponse = new Response(false, array('missing-input-response'));
90
-            return $recaptchaResponse;
91
-        }
77
+	/**
78
+	 * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
+	 * CAPTCHA test.
80
+	 *
81
+	 * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
+	 * @param string $remoteIp The end user's IP address.
83
+	 * @return Response Response from the service.
84
+	 */
85
+	public function verify($response, $remoteIp = null)
86
+	{
87
+		// Discard empty solution submissions
88
+		if (empty($response)) {
89
+			$recaptchaResponse = new Response(false, array('missing-input-response'));
90
+			return $recaptchaResponse;
91
+		}
92 92
 
93
-        $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
-        $rawResponse = $this->requestMethod->submit($params);
95
-        return Response::fromJson($rawResponse);
96
-    }
93
+		$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
+		$rawResponse = $this->requestMethod->submit($params);
95
+		return Response::fromJson($rawResponse);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Sources/CacheAPI-sqlite.php 2 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * SQLite Cache API class
@@ -153,8 +154,7 @@  discard block
 block discarded – undo
153 154
 		if (is_null($dir) || !is_writable($dir))
154 155
 		{
155 156
 			$this->cachedir = $cachedir_sqlite;
156
-		}
157
-		else
157
+		} else
158 158
 		{
159 159
 			$this->cachedir = $dir;
160 160
 		}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 *
144 144
 	 * @param string $dir A valid path
145 145
 	 *
146
-	 * @return boolean If this was successful or not.
146
+	 * @return boolean|null If this was successful or not.
147 147
 	 */
148 148
 	public function setCachedir($dir = null)
149 149
 	{
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * Display a list of upcoming events, birthdays, and holidays.
69 69
  *
70 70
  * @param string $grid_name The grid name
71
- * @return void|bool Returns false if the grid doesn't exist.
71
+ * @return false|null Returns false if the grid doesn't exist.
72 72
  */
73 73
 function template_show_upcoming_list($grid_name)
74 74
 {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @param string $grid_name The grid name
240 240
  * @param bool $is_mini Is this a mini grid?
241
- * @return void|bool Returns false if the grid doesn't exist.
241
+ * @return false|null Returns false if the grid doesn't exist.
242 242
  */
243 243
 function template_show_month_grid($grid_name, $is_mini = false)
244 244
 {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
  * Shows a weekly grid
524 524
  *
525 525
  * @param string $grid_name The name of the grid
526
- * @return void|bool Returns false if the grid doesn't exist
526
+ * @return false|null Returns false if the grid doesn't exist
527 527
  */
528 528
 function template_show_week_grid($grid_name)
529 529
 {
Please login to merge, or discard this patch.
Braces   +152 added lines, -116 removed lines patch added patch discarded remove patch
@@ -40,16 +40,14 @@  discard block
 block discarded – undo
40 40
 				', template_show_upcoming_list('main'), '
41 41
 			</div>
42 42
 		';
43
-	}
44
-	elseif ($context['calendar_view'] == 'view_week')
43
+	} elseif ($context['calendar_view'] == 'view_week')
45 44
 	{
46 45
 		echo '
47 46
 			<div id="main_grid">
48 47
 				', template_show_week_grid('main'), '
49 48
 			</div>
50 49
 		';
51
-	}
52
-	else
50
+	} else
53 51
 	{
54 52
 		echo '
55 53
 			<div id="main_grid">
@@ -75,8 +73,9 @@  discard block
 block discarded – undo
75 73
 	global $context, $scripturl, $txt, $modSettings;
76 74
 
77 75
 	// Bail out if we have nothing to work with
78
-	if (!isset($context['calendar_grid_' . $grid_name]))
79
-		return false;
76
+	if (!isset($context['calendar_grid_' . $grid_name])) {
77
+			return false;
78
+	}
80 79
 
81 80
 	// Protect programmer sanity
82 81
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -113,11 +112,13 @@  discard block
 block discarded – undo
113 112
 					<li class="windowbg">
114 113
 						<b class="event_title">', $event['link'], '</b>';
115 114
 
116
-				if ($event['can_edit'])
117
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
115
+				if ($event['can_edit']) {
116
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
117
+				}
118 118
 
119
-				if ($event['can_export'])
120
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
119
+				if ($event['can_export']) {
120
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
121
+				}
121 122
 
122 123
 				echo '
123 124
 						<br>';
@@ -125,14 +126,14 @@  discard block
 block discarded – undo
125 126
 				if (!empty($event['allday']))
126 127
 				{
127 128
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
128
-				}
129
-				else
129
+				} else
130 130
 				{
131 131
 					// Display event info relative to user's local timezone
132 132
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
133 133
 
134
-					if ($event['start_date_local'] != $event['end_date_local'])
135
-						echo trim($event['end_date_local']) . ', ';
134
+					if ($event['start_date_local'] != $event['end_date_local']) {
135
+											echo trim($event['end_date_local']) . ', ';
136
+					}
136 137
 
137 138
 					echo trim($event['end_time_local']);
138 139
 
@@ -141,23 +142,27 @@  discard block
 block discarded – undo
141 142
 					{
142 143
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
143 144
 
144
-						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
145
-							echo trim($event['start_date_orig']), ', ';
145
+						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
146
+													echo trim($event['start_date_orig']), ', ';
147
+						}
146 148
 
147 149
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
148 150
 
149
-						if ($event['start_date_orig'] != $event['end_date_orig'])
150
-							echo trim($event['end_date_orig']) . ', ';
151
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
152
+													echo trim($event['end_date_orig']) . ', ';
153
+						}
151 154
 
152 155
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
153 156
 					}
154 157
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
155
-					else
156
-						echo ' ', $event['tz_abbrev'], '</time>';
158
+					else {
159
+											echo ' ', $event['tz_abbrev'], '</time>';
160
+					}
157 161
 				}
158 162
 
159
-				if (!empty($event['location']))
160
-					echo '<br>', $event['location'];
163
+				if (!empty($event['location'])) {
164
+									echo '<br>', $event['location'];
165
+				}
161 166
 
162 167
 				echo '
163 168
 					</li>';
@@ -189,8 +194,9 @@  discard block
 block discarded – undo
189 194
 
190 195
 			$birthdays = array();
191 196
 
192
-			foreach ($date as $member)
193
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
197
+			foreach ($date as $member) {
198
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
199
+			}
194 200
 
195 201
 			echo implode(', ', $birthdays);
196 202
 
@@ -221,8 +227,9 @@  discard block
 block discarded – undo
221 227
 			$date_local = $date['date_local'];
222 228
 			unset($date['date_local']);
223 229
 
224
-			foreach ($date as $holiday)
225
-				$holidays[] = $holiday . ' (' . $date_local . ')';
230
+			foreach ($date as $holiday) {
231
+							$holidays[] = $holiday . ' (' . $date_local . ')';
232
+			}
226 233
 		}
227 234
 
228 235
 		echo implode(', ', $holidays);
@@ -245,17 +252,19 @@  discard block
 block discarded – undo
245 252
 	global $context, $settings, $txt, $scripturl, $modSettings;
246 253
 
247 254
 	// If the grid doesn't exist, no point in proceeding.
248
-	if (!isset($context['calendar_grid_' . $grid_name]))
249
-		return false;
255
+	if (!isset($context['calendar_grid_' . $grid_name])) {
256
+			return false;
257
+	}
250 258
 
251 259
 	// A handy little pointer variable.
252 260
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
253 261
 
254 262
 	// Some conditions for whether or not we should show the week links *here*.
255
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
256
-		$show_week_links = true;
257
-	else
258
-		$show_week_links = false;
263
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
264
+			$show_week_links = true;
265
+	} else {
266
+			$show_week_links = false;
267
+	}
259 268
 
260 269
 	// Assuming that we've not disabled it, show the title block!
261 270
 	if (empty($calendar_data['disable_title']))
@@ -294,8 +303,9 @@  discard block
 block discarded – undo
294 303
 	}
295 304
 
296 305
 	// Show the controls on main grids
297
-	if ($is_mini === false)
298
-		template_calendar_top($calendar_data);
306
+	if ($is_mini === false) {
307
+			template_calendar_top($calendar_data);
308
+	}
299 309
 
300 310
 	// Finally, the main calendar table.
301 311
 	echo '<table class="calendar_table">';
@@ -306,8 +316,9 @@  discard block
 block discarded – undo
306 316
 		echo '<tr>';
307 317
 
308 318
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
309
-		if ($show_week_links === true)
310
-			echo '<th>&nbsp;</th>';
319
+		if ($show_week_links === true) {
320
+					echo '<th>&nbsp;</th>';
321
+		}
311 322
 
312 323
 		// Now, loop through each actual day of the week.
313 324
 		foreach ($calendar_data['week_days'] as $day)
@@ -354,27 +365,29 @@  discard block
 block discarded – undo
354 365
 				// Additional classes are given for events, holidays, and birthdays.
355 366
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
356 367
 				{
357
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
358
-						$classes[] = 'events';
359
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
360
-						$classes[] = 'events';
368
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) {
369
+											$classes[] = 'events';
370
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) {
371
+											$classes[] = 'events';
372
+					}
361 373
 				}
362 374
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
363 375
 				{
364
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
365
-						$classes[] = 'holidays';
366
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
367
-						$classes[] = 'holidays';
376
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) {
377
+											$classes[] = 'holidays';
378
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) {
379
+											$classes[] = 'holidays';
380
+					}
368 381
 				}
369 382
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
370 383
 				{
371
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
372
-						$classes[] = 'birthdays';
373
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
374
-						$classes[] = 'birthdays';
384
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) {
385
+											$classes[] = 'birthdays';
386
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) {
387
+											$classes[] = 'birthdays';
388
+					}
375 389
 				}
376
-			}
377
-			else
390
+			} else
378 391
 			{
379 392
 				// Default Classes (either compact or comfortable and disabled).
380 393
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
@@ -392,17 +405,19 @@  discard block
 block discarded – undo
392 405
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
393 406
 
394 407
 				// The actual day number - be it a link, or just plain old text!
395
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
396
-					echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
397
-				else
398
-					echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
408
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
409
+									echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
410
+				} else {
411
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
412
+				}
399 413
 
400 414
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
401 415
 				if ($is_mini === false)
402 416
 				{
403 417
 					// Holidays are always fun, let's show them!
404
-					if (!empty($day['holidays']))
405
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
418
+					if (!empty($day['holidays'])) {
419
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
420
+					}
406 421
 
407 422
 					// Happy Birthday Dear, Member!
408 423
 					if (!empty($day['birthdays']))
@@ -420,14 +435,16 @@  discard block
 block discarded – undo
420 435
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
421 436
 
422 437
 							// 9...10! Let's stop there.
423
-							if ($birthday_count == 10 && $use_js_hide)
424
-								// !!TODO - Inline CSS and JavaScript should be moved.
438
+							if ($birthday_count == 10 && $use_js_hide) {
439
+															// !!TODO - Inline CSS and JavaScript should be moved.
425 440
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
441
+							}
426 442
 
427 443
 							++$birthday_count;
428 444
 						}
429
-						if ($use_js_hide)
430
-							echo '</span>';
445
+						if ($use_js_hide) {
446
+													echo '</span>';
447
+						}
431 448
 
432 449
 						echo '</div>';
433 450
 					}
@@ -437,8 +454,9 @@  discard block
 block discarded – undo
437 454
 					{
438 455
 						// Sort events by start time (all day events will be listed first)
439 456
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
457
+						    if ($a['start_timestamp'] == $b['start_timestamp']) {
458
+						    						        return 0;
459
+						    }
442 460
 						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 461
 						});
444 462
 
@@ -454,17 +472,19 @@  discard block
 block discarded – undo
454 472
 
455 473
 							echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
456 474
 
457
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
458
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
459
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
460
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
461
-							elseif (!empty($event['allday']))
462
-								echo $txt['calendar_allday'];
475
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
476
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
477
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
478
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
479
+							} elseif (!empty($event['allday'])) {
480
+															echo $txt['calendar_allday'];
481
+							}
463 482
 
464 483
 							echo '</span>';
465 484
 
466
-							if (!empty($event['location']))
467
-								echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
485
+							if (!empty($event['location'])) {
486
+															echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
487
+							}
468 488
 
469 489
 							if ($event['can_edit'] || $event['can_export'])
470 490
 							{
@@ -501,10 +521,11 @@  discard block
 block discarded – undo
501 521
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
502 522
 			elseif ($is_mini === false)
503 523
 			{
504
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
505
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
506
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
507
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
524
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
525
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
526
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
527
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
528
+				}
508 529
 			}
509 530
 
510 531
 			// Close this day and increase var count.
@@ -530,8 +551,9 @@  discard block
 block discarded – undo
530 551
 	global $context, $settings, $txt, $scripturl, $modSettings;
531 552
 
532 553
 	// We might have no reason to proceed, if the variable isn't there.
533
-	if (!isset($context['calendar_grid_' . $grid_name]))
534
-		return false;
554
+	if (!isset($context['calendar_grid_' . $grid_name])) {
555
+			return false;
556
+	}
535 557
 
536 558
 	// Handy pointer.
537 559
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -567,8 +589,9 @@  discard block
 block discarded – undo
567 589
 					}
568 590
 
569 591
 					// The Month Title + Week Number...
570
-					if (!empty($calendar_data['week_title']))
571
-							echo $calendar_data['week_title'];
592
+					if (!empty($calendar_data['week_title'])) {
593
+												echo $calendar_data['week_title'];
594
+					}
572 595
 
573 596
 					echo '
574 597
 					</h3>
@@ -607,10 +630,11 @@  discard block
 block discarded – undo
607 630
 						<tr class="days_wrapper">
608 631
 							<td class="', implode(' ', $classes), ' act_day">';
609 632
 							// Should the day number be a link?
610
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
611
-								echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
612
-							else
613
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
633
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
634
+															echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
635
+							} else {
636
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
637
+							}
614 638
 
615 639
 							echo '</td>
616 640
 							<td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">';
@@ -619,8 +643,9 @@  discard block
 block discarded – undo
619 643
 							{
620 644
 								// Sort events by start time (all day events will be listed first)
621 645
 								uasort($day['events'], function($a, $b) {
622
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
623
-								        return 0;
646
+								    if ($a['start_timestamp'] == $b['start_timestamp']) {
647
+								    								        return 0;
648
+								    }
624 649
 								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
625 650
 								});
626 651
 
@@ -632,15 +657,17 @@  discard block
 block discarded – undo
632 657
 
633 658
 									echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
634 659
 
635
-									if (!empty($event['start_time_local']))
636
-										echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
637
-									else
638
-										echo $txt['calendar_allday'];
660
+									if (!empty($event['start_time_local'])) {
661
+																			echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
662
+									} else {
663
+																			echo $txt['calendar_allday'];
664
+									}
639 665
 
640 666
 									echo '</span>';
641 667
 
642
-									if (!empty($event['location']))
643
-										echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
668
+									if (!empty($event['location'])) {
669
+																			echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
670
+									}
644 671
 
645 672
 									if (!empty($event_icons_needed))
646 673
 									{
@@ -677,8 +704,7 @@  discard block
 block discarded – undo
677 704
 									</div>
678 705
 									<br class="clear">';
679 706
 								}
680
-							}
681
-							else
707
+							} else
682 708
 							{
683 709
 								if (!empty($context['can_post']))
684 710
 								{
@@ -691,8 +717,9 @@  discard block
 block discarded – undo
691 717
 							echo '</td>
692 718
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
693 719
 							// Show any holidays!
694
-							if (!empty($day['holidays']))
695
-								echo implode('<br>', $day['holidays']);
720
+							if (!empty($day['holidays'])) {
721
+															echo implode('<br>', $day['holidays']);
722
+							}
696 723
 
697 724
 							echo '</td>
698 725
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">';
@@ -750,8 +777,7 @@  discard block
 block discarded – undo
750 777
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date">
751 778
 				<input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '">
752 779
 			</form>';
753
-	}
754
-	else
780
+	} else
755 781
 	{
756 782
 		echo'
757 783
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
@@ -793,8 +819,9 @@  discard block
 block discarded – undo
793 819
 	echo '
794 820
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">';
795 821
 
796
-	if (!empty($context['event']['new']))
797
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
822
+	if (!empty($context['event']['new'])) {
823
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
824
+	}
798 825
 
799 826
 	// Start the main table.
800 827
 	echo '
@@ -844,9 +871,10 @@  discard block
 block discarded – undo
844 871
 		{
845 872
 			echo '
846 873
 								<optgroup label="', $category['name'], '">';
847
-			foreach ($category['boards'] as $board)
848
-				echo '
874
+			foreach ($category['boards'] as $board) {
875
+							echo '
849 876
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
877
+			}
850 878
 			echo '
851 879
 								</optgroup>';
852 880
 		}
@@ -882,9 +910,10 @@  discard block
 block discarded – undo
882 910
 							<span class="label">', $txt['calendar_timezone'], '</span>
883 911
 							<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
884 912
 
885
-	foreach ($context['all_timezones'] as $tz => $tzname)
886
-		echo '
913
+	foreach ($context['all_timezones'] as $tz => $tzname) {
914
+			echo '
887 915
 								<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
916
+	}
888 917
 
889 918
 	echo '
890 919
 							</select>
@@ -899,9 +928,10 @@  discard block
 block discarded – undo
899 928
 	echo '
900 929
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
901 930
 	// Delete button?
902
-	if (empty($context['event']['new']))
903
-		echo '
931
+	if (empty($context['event']['new'])) {
932
+			echo '
904 933
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
934
+	}
905 935
 
906 936
 	echo '
907 937
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -945,9 +975,10 @@  discard block
 block discarded – undo
945 975
 
946 976
 		foreach ($context['clockicons'] as $t => $v)
947 977
 		{
948
-			foreach ($v as $i)
949
-				echo '
978
+			foreach ($v as $i) {
979
+							echo '
950 980
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
981
+			}
951 982
 		}
952 983
 
953 984
 		echo '
@@ -972,13 +1003,14 @@  discard block
 block discarded – undo
972 1003
 
973 1004
 		foreach ($context['clockicons'] as $t => $v)
974 1005
 		{
975
-			foreach ($v as $i)
976
-				echo '
1006
+			foreach ($v as $i) {
1007
+							echo '
977 1008
 			if (', $t, ' >= ', $i, ')
978 1009
 			{
979 1010
 				turnon.push("', $t, '_', $i, '");
980 1011
 				', $t, ' -= ', $i, ';
981 1012
 			}';
1013
+			}
982 1014
 		}
983 1015
 
984 1016
 		echo '
@@ -1042,9 +1074,10 @@  discard block
 block discarded – undo
1042 1074
 
1043 1075
 	foreach ($context['clockicons'] as $t => $v)
1044 1076
 	{
1045
-		foreach ($v as $i)
1046
-			echo '
1077
+		foreach ($v as $i) {
1078
+					echo '
1047 1079
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1080
+		}
1048 1081
 	}
1049 1082
 
1050 1083
 	echo '
@@ -1061,13 +1094,14 @@  discard block
 block discarded – undo
1061 1094
 
1062 1095
 	foreach ($context['clockicons'] as $t => $v)
1063 1096
 	{
1064
-		foreach ($v as $i)
1065
-			echo '
1097
+		foreach ($v as $i) {
1098
+					echo '
1066 1099
 		if (', $t, ' >= ', $i, ')
1067 1100
 		{
1068 1101
 			turnon.push("', $t, '_', $i, '");
1069 1102
 			', $t, ' -= ', $i, ';
1070 1103
 		}';
1104
+		}
1071 1105
 	}
1072 1106
 
1073 1107
 	echo '
@@ -1126,9 +1160,10 @@  discard block
 block discarded – undo
1126 1160
 
1127 1161
 	foreach ($context['clockicons'] as $t => $v)
1128 1162
 	{
1129
-		foreach ($v as $i)
1130
-			echo '
1163
+		foreach ($v as $i) {
1164
+					echo '
1131 1165
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1166
+		}
1132 1167
 	}
1133 1168
 
1134 1169
 	echo '
@@ -1149,13 +1184,14 @@  discard block
 block discarded – undo
1149 1184
 
1150 1185
 	foreach ($context['clockicons'] as $t => $v)
1151 1186
 	{
1152
-		foreach ($v as $i)
1153
-		echo '
1187
+		foreach ($v as $i) {
1188
+				echo '
1154 1189
 		if (', $t, ' >= ', $i, ')
1155 1190
 		{
1156 1191
 			turnon.push("', $t, '_', $i, '");
1157 1192
 			', $t, ' -= ', $i, ';
1158 1193
 		}';
1194
+		}
1159 1195
 	}
1160 1196
 
1161 1197
 	echo '
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 					{
438 438
 						// Sort events by start time (all day events will be listed first)
439 439
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
442
-						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
440
+							if ($a['start_timestamp'] == $b['start_timestamp'])
441
+								return 0;
442
+							return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 443
 						});
444 444
 
445 445
 						echo '
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
 							{
620 620
 								// Sort events by start time (all day events will be listed first)
621 621
 								uasort($day['events'], function($a, $b) {
622
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
623
-								        return 0;
624
-								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
622
+									if ($a['start_timestamp'] == $b['start_timestamp'])
623
+										return 0;
624
+									return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
625 625
 								});
626 626
 
627 627
 								foreach ($day['events'] as $event)
Please login to merge, or discard this patch.
other/upgrade.php 4 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -388,6 +388,9 @@  discard block
 block discarded – undo
388 388
 }
389 389
 
390 390
 // Used to direct the user to another location.
391
+/**
392
+ * @param string $location
393
+ */
391 394
 function redirectLocation($location, $addForm = true)
392 395
 {
393 396
 	global $upgradeurl, $upcontext, $command_line;
@@ -1560,6 +1563,9 @@  discard block
 block discarded – undo
1560 1563
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
1561 1564
 }
1562 1565
 
1566
+/**
1567
+ * @param string $filename
1568
+ */
1563 1569
 function parse_sql($filename)
1564 1570
 {
1565 1571
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -1594,6 +1600,10 @@  discard block
 block discarded – undo
1594 1600
 
1595 1601
 	// Our custom error handler - does nothing but does stop public errors from XML!
1596 1602
 	set_error_handler(
1603
+
1604
+		/**
1605
+		 * @param string $errno
1606
+		 */
1597 1607
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1598 1608
 		{
1599 1609
 			if ($support_js)
@@ -1840,6 +1850,9 @@  discard block
 block discarded – undo
1840 1850
 	return true;
1841 1851
 }
1842 1852
 
1853
+/**
1854
+ * @param string $string
1855
+ */
1843 1856
 function upgrade_query($string, $unbuffered = false)
1844 1857
 {
1845 1858
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -4495,7 +4508,7 @@  discard block
 block discarded – undo
4495 4508
  * @param int $setSize The amount of entries after which to update the database.
4496 4509
  *
4497 4510
  * newCol needs to be a varbinary(16) null able field
4498
- * @return bool
4511
+ * @return boolean|null
4499 4512
  */
4500 4513
 function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100)
4501 4514
 {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 
83 83
 // The helper is crucial. Include it first thing.
84 84
 if (!file_exists($upgrade_path . '/upgrade-helper.php'))
85
-    die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
85
+	die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
86 86
 
87 87
 require_once($upgrade_path . '/upgrade-helper.php');
88 88
 
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
 
1627 1627
 	// Our custom error handler - does nothing but does stop public errors from XML!
1628 1628
 	set_error_handler(
1629
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1629
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1630 1630
 		{
1631 1631
 			if ($support_js)
1632 1632
 				return true;
@@ -2643,94 +2643,94 @@  discard block
 block discarded – undo
2643 2643
 		// Translation table for the character sets not native for MySQL.
2644 2644
 		$translation_tables = array(
2645 2645
 			'windows-1255' => array(
2646
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2647
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2648
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2649
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2650
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2651
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2652
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2653
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2654
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2655
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2656
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2657
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2658
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2659
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2660
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2661
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2662
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2663
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2664
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2665
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2666
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2667
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2668
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2669
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2670
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2671
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2672
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2673
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2674
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2675
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2676
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2677
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2678
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2679
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2680
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2681
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2682
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2683
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2684
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2685
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2686
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2687
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2646
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2647
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2648
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2649
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2650
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2651
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2652
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2653
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2654
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2655
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2656
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2657
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2658
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2659
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2660
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2661
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2662
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2663
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2664
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2665
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2666
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2667
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2668
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2669
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2670
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2671
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2672
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2673
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2674
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2675
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2676
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2677
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2678
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2679
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2680
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2681
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2682
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2683
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2684
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2685
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2686
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2687
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2688 2688
 				'0xFA' => '0xD7AA',
2689 2689
 			),
2690 2690
 			'windows-1253' => array(
2691
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2692
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2693
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2694
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2695
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2696
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2697
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2698
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2699
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2700
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2701
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2702
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2703
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2704
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2705
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2706
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2707
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2708
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2709
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2710
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2711
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2712
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2713
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2714
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2715
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2716
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2717
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2718
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2719
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2720
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2721
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2722
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2723
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2724
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2725
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2726
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2727
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2728
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2729
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2730
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2731
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2732
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2733
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2691
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2692
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2693
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2694
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2695
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2696
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2697
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2698
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2699
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2700
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2701
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2702
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2703
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2704
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2705
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2706
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2707
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2708
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2709
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2710
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2711
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2712
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2713
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2714
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2715
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2716
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2717
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2718
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2719
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2720
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2721
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2722
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2723
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2724
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2725
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2726
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2727
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2728
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2729
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2730
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2731
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2732
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2733
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2734 2734
 			),
2735 2735
 		);
2736 2736
 
@@ -3829,7 +3829,7 @@  discard block
 block discarded – undo
3829 3829
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
3830 3830
 			<input type="hidden" name="backup_done" id="backup_done" value="0">
3831 3831
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
3832
-			<div id="debug_section" style="height: ', ($is_debug ? '195' : '12') , 'px; overflow: auto;">
3832
+			<div id="debug_section" style="height: ', ($is_debug ? '195' : '12'), 'px; overflow: auto;">
3833 3833
 			<span id="debuginfo"></span>
3834 3834
 			</div>';
3835 3835
 
@@ -4330,7 +4330,7 @@  discard block
 block discarded – undo
4330 4330
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4331 4331
 			<input type="hidden" name="utf8_done" id="utf8_done" value="0">
4332 4332
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4333
-			<div id="debug_section" style="height: ', ($is_debug ? '195' : '12') , 'px; overflow: auto;">
4333
+			<div id="debug_section" style="height: ', ($is_debug ? '195' : '12'), 'px; overflow: auto;">
4334 4334
 			<span id="debuginfo"></span>
4335 4335
 			</div>';
4336 4336
 
@@ -4427,7 +4427,7 @@  discard block
 block discarded – undo
4427 4427
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4428 4428
 			<input type="hidden" name="json_done" id="json_done" value="0">
4429 4429
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4430
-			<div id="debug_section" style="height: ', ($is_debug ? '195' : '12') , 'px; overflow: auto;">
4430
+			<div id="debug_section" style="height: ', ($is_debug ? '195' : '12'), 'px; overflow: auto;">
4431 4431
 			<span id="debuginfo"></span>
4432 4432
 			</div>';
4433 4433
 
Please login to merge, or discard this patch.
Braces   +884 added lines, -648 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
 $upcontext['inactive_timeout'] = 10;
76 76
 
77 77
 // The helper is crucial. Include it first thing.
78
-if (!file_exists($upgrade_path . '/upgrade-helper.php'))
78
+if (!file_exists($upgrade_path . '/upgrade-helper.php')) {
79 79
     die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
80
+}
80 81
 
81 82
 require_once($upgrade_path . '/upgrade-helper.php');
82 83
 
@@ -100,11 +101,14 @@  discard block
 block discarded – undo
100 101
 	ini_set('default_socket_timeout', 900);
101 102
 }
102 103
 // Clean the upgrade path if this is from the client.
103
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
104
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
104
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
105
+	for ($i = 1;
106
+}
107
+$i < $_SERVER['argc']; $i++)
105 108
 	{
106
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
107
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
109
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
110
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
111
+		}
108 112
 	}
109 113
 
110 114
 // Are we from the client?
@@ -112,16 +116,17 @@  discard block
 block discarded – undo
112 116
 {
113 117
 	$command_line = true;
114 118
 	$disable_security = true;
115
-}
116
-else
119
+} else {
117 120
 	$command_line = false;
121
+}
118 122
 
119 123
 // Load this now just because we can.
120 124
 require_once($upgrade_path . '/Settings.php');
121 125
 
122 126
 // We don't use "-utf8" anymore...  Tweak the entry that may have been loaded by Settings.php
123
-if (isset($language))
127
+if (isset($language)) {
124 128
 	$language = str_ireplace('-utf8', '', $language);
129
+}
125 130
 
126 131
 // Are we logged in?
127 132
 if (isset($upgradeData))
@@ -129,10 +134,12 @@  discard block
 block discarded – undo
129 134
 	$upcontext['user'] = json_decode(base64_decode($upgradeData), true);
130 135
 
131 136
 	// Check for sensible values.
132
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
133
-		$upcontext['user']['started'] = time();
134
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
135
-		$upcontext['user']['updated'] = 0;
137
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
138
+			$upcontext['user']['started'] = time();
139
+	}
140
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
141
+			$upcontext['user']['updated'] = 0;
142
+	}
136 143
 
137 144
 	$upcontext['started'] = $upcontext['user']['started'];
138 145
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -190,8 +197,9 @@  discard block
 block discarded – undo
190 197
 			'db_error_skip' => true,
191 198
 		)
192 199
 	);
193
-	while ($row = $smcFunc['db_fetch_assoc']($request))
194
-		$modSettings[$row['variable']] = $row['value'];
200
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
201
+			$modSettings[$row['variable']] = $row['value'];
202
+	}
195 203
 	$smcFunc['db_free_result']($request);
196 204
 }
197 205
 
@@ -201,10 +209,12 @@  discard block
 block discarded – undo
201 209
 	$modSettings['theme_url'] = 'Themes/default';
202 210
 	$modSettings['images_url'] = 'Themes/default/images';
203 211
 }
204
-if (!isset($settings['default_theme_url']))
212
+if (!isset($settings['default_theme_url'])) {
205 213
 	$settings['default_theme_url'] = $modSettings['theme_url'];
206
-if (!isset($settings['default_theme_dir']))
214
+}
215
+if (!isset($settings['default_theme_dir'])) {
207 216
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
217
+}
208 218
 
209 219
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
210 220
 // Default title...
@@ -222,13 +232,15 @@  discard block
 block discarded – undo
222 232
 	$support_js = $upcontext['upgrade_status']['js'];
223 233
 
224 234
 	// Only set this if the upgrader status says so.
225
-	if (empty($is_debug))
226
-		$is_debug = $upcontext['upgrade_status']['debug'];
235
+	if (empty($is_debug)) {
236
+			$is_debug = $upcontext['upgrade_status']['debug'];
237
+	}
227 238
 
228 239
 	// Load the language.
229
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
230
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
231
-}
240
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
241
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
242
+	}
243
+	}
232 244
 // Set the defaults.
233 245
 else
234 246
 {
@@ -246,15 +258,18 @@  discard block
 block discarded – undo
246 258
 }
247 259
 
248 260
 // If this isn't the first stage see whether they are logging in and resuming.
249
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
261
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
250 262
 	checkLogin();
263
+}
251 264
 
252
-if ($command_line)
265
+if ($command_line) {
253 266
 	cmdStep0();
267
+}
254 268
 
255 269
 // Don't error if we're using xml.
256
-if (isset($_GET['xml']))
270
+if (isset($_GET['xml'])) {
257 271
 	$upcontext['return_error'] = true;
272
+}
258 273
 
259 274
 // Loop through all the steps doing each one as required.
260 275
 $upcontext['overall_percent'] = 0;
@@ -275,9 +290,9 @@  discard block
 block discarded – undo
275 290
 		}
276 291
 
277 292
 		// Call the step and if it returns false that means pause!
278
-		if (function_exists($step[2]) && $step[2]() === false)
279
-			break;
280
-		elseif (function_exists($step[2])) {
293
+		if (function_exists($step[2]) && $step[2]() === false) {
294
+					break;
295
+		} elseif (function_exists($step[2])) {
281 296
 			//Start each new step with this unset, so the 'normal' template is called first
282 297
 			unset($_GET['xml']);
283 298
 			$_GET['substep'] = 0;
@@ -321,17 +336,18 @@  discard block
 block discarded – undo
321 336
 		// This should not happen my dear... HELP ME DEVELOPERS!!
322 337
 		if (!empty($command_line))
323 338
 		{
324
-			if (function_exists('debug_print_backtrace'))
325
-				debug_print_backtrace();
339
+			if (function_exists('debug_print_backtrace')) {
340
+							debug_print_backtrace();
341
+			}
326 342
 
327 343
 			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.';
328 344
 			flush();
329 345
 			die();
330 346
 		}
331 347
 
332
-		if (!isset($_GET['xml']))
333
-			template_upgrade_above();
334
-		else
348
+		if (!isset($_GET['xml'])) {
349
+					template_upgrade_above();
350
+		} else
335 351
 		{
336 352
 			header('Content-Type: text/xml; charset=UTF-8');
337 353
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -353,25 +369,29 @@  discard block
 block discarded – undo
353 369
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
354 370
 
355 371
 			// Custom stuff to pass back?
356
-			if (!empty($upcontext['query_string']))
357
-				$upcontext['form_url'] .= $upcontext['query_string'];
372
+			if (!empty($upcontext['query_string'])) {
373
+							$upcontext['form_url'] .= $upcontext['query_string'];
374
+			}
358 375
 
359 376
 			// Call the appropriate subtemplate
360
-			if (is_callable('template_' . $upcontext['sub_template']))
361
-				call_user_func('template_' . $upcontext['sub_template']);
362
-			else
363
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
377
+			if (is_callable('template_' . $upcontext['sub_template'])) {
378
+							call_user_func('template_' . $upcontext['sub_template']);
379
+			} else {
380
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
381
+			}
364 382
 		}
365 383
 
366 384
 		// Was there an error?
367
-		if (!empty($upcontext['forced_error_message']))
368
-			echo $upcontext['forced_error_message'];
385
+		if (!empty($upcontext['forced_error_message'])) {
386
+					echo $upcontext['forced_error_message'];
387
+		}
369 388
 
370 389
 		// Show the footer.
371
-		if (!isset($_GET['xml']))
372
-			template_upgrade_below();
373
-		else
374
-			template_xml_below();
390
+		if (!isset($_GET['xml'])) {
391
+					template_upgrade_below();
392
+		} else {
393
+					template_xml_below();
394
+		}
375 395
 	}
376 396
 
377 397
 
@@ -383,15 +403,19 @@  discard block
 block discarded – undo
383 403
 		$seconds = intval($active % 60);
384 404
 
385 405
 		$totalTime = '';
386
-		if ($hours > 0)
387
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
388
-		if ($minutes > 0)
389
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
390
-		if ($seconds > 0)
391
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
406
+		if ($hours > 0) {
407
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
408
+		}
409
+		if ($minutes > 0) {
410
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
411
+		}
412
+		if ($seconds > 0) {
413
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
414
+		}
392 415
 
393
-		if (!empty($totalTime))
394
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
416
+		if (!empty($totalTime)) {
417
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
418
+		}
395 419
 	}
396 420
 
397 421
 	// Bang - gone!
@@ -404,8 +428,9 @@  discard block
 block discarded – undo
404 428
 	global $upgradeurl, $upcontext, $command_line;
405 429
 
406 430
 	// Command line users can't be redirected.
407
-	if ($command_line)
408
-		upgradeExit(true);
431
+	if ($command_line) {
432
+			upgradeExit(true);
433
+	}
409 434
 
410 435
 	// Are we providing the core info?
411 436
 	if ($addForm)
@@ -428,19 +453,22 @@  discard block
 block discarded – undo
428 453
 	global $modSettings, $sourcedir, $smcFunc;
429 454
 
430 455
 	// Do the non-SSI stuff...
431
-	if (function_exists('set_magic_quotes_runtime'))
432
-		@set_magic_quotes_runtime(0);
456
+	if (function_exists('set_magic_quotes_runtime')) {
457
+			@set_magic_quotes_runtime(0);
458
+	}
433 459
 
434 460
 	error_reporting(E_ALL);
435 461
 	define('SMF', 1);
436 462
 
437 463
 	// Start the session.
438
-	if (@ini_get('session.save_handler') == 'user')
439
-		@ini_set('session.save_handler', 'files');
464
+	if (@ini_get('session.save_handler') == 'user') {
465
+			@ini_set('session.save_handler', 'files');
466
+	}
440 467
 	@session_start();
441 468
 
442
-	if (empty($smcFunc))
443
-		$smcFunc = array();
469
+	if (empty($smcFunc)) {
470
+			$smcFunc = array();
471
+	}
444 472
 
445 473
 	// We need this for authentication and some upgrade code
446 474
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -452,32 +480,36 @@  discard block
 block discarded – undo
452 480
 	initialize_inputs();
453 481
 
454 482
 	// Get the database going!
455
-	if (empty($db_type) || $db_type == 'mysqli')
456
-		$db_type = 'mysql';
483
+	if (empty($db_type) || $db_type == 'mysqli') {
484
+			$db_type = 'mysql';
485
+	}
457 486
 
458 487
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
459 488
 	{
460 489
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
461 490
 
462 491
 		// Make the connection...
463
-		if (empty($db_connection))
464
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
465
-		else
466
-			// If we've returned here, ping/reconnect to be safe
492
+		if (empty($db_connection)) {
493
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
494
+		} else {
495
+					// If we've returned here, ping/reconnect to be safe
467 496
 			$smcFunc['db_ping']($db_connection);
497
+		}
468 498
 
469 499
 		// Oh dear god!!
470
-		if ($db_connection === null)
471
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
500
+		if ($db_connection === null) {
501
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
502
+		}
472 503
 
473
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
474
-			$smcFunc['db_query']('', '
504
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
505
+					$smcFunc['db_query']('', '
475 506
 			SET NAMES {string:db_character_set}',
476 507
 			array(
477 508
 				'db_error_skip' => true,
478 509
 				'db_character_set' => $db_character_set,
479 510
 			)
480 511
 		);
512
+		}
481 513
 
482 514
 		// Load the modSettings data...
483 515
 		$request = $smcFunc['db_query']('', '
@@ -488,11 +520,11 @@  discard block
 block discarded – undo
488 520
 			)
489 521
 		);
490 522
 		$modSettings = array();
491
-		while ($row = $smcFunc['db_fetch_assoc']($request))
492
-			$modSettings[$row['variable']] = $row['value'];
523
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
524
+					$modSettings[$row['variable']] = $row['value'];
525
+		}
493 526
 		$smcFunc['db_free_result']($request);
494
-	}
495
-	else
527
+	} else
496 528
 	{
497 529
 		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.');
498 530
 	}
@@ -506,9 +538,10 @@  discard block
 block discarded – undo
506 538
 		cleanRequest();
507 539
 	}
508 540
 
509
-	if (!isset($_GET['substep']))
510
-		$_GET['substep'] = 0;
511
-}
541
+	if (!isset($_GET['substep'])) {
542
+			$_GET['substep'] = 0;
543
+	}
544
+	}
512 545
 
513 546
 function initialize_inputs()
514 547
 {
@@ -538,8 +571,9 @@  discard block
 block discarded – undo
538 571
 		$dh = opendir(dirname(__FILE__));
539 572
 		while ($file = readdir($dh))
540 573
 		{
541
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
542
-				@unlink(dirname(__FILE__) . '/' . $file);
574
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
575
+							@unlink(dirname(__FILE__) . '/' . $file);
576
+			}
543 577
 		}
544 578
 		closedir($dh);
545 579
 
@@ -568,8 +602,9 @@  discard block
 block discarded – undo
568 602
 	$temp = 'upgrade_php?step';
569 603
 	while (strlen($temp) > 4)
570 604
 	{
571
-		if (isset($_GET[$temp]))
572
-			unset($_GET[$temp]);
605
+		if (isset($_GET[$temp])) {
606
+					unset($_GET[$temp]);
607
+		}
573 608
 		$temp = substr($temp, 1);
574 609
 	}
575 610
 
@@ -596,32 +631,39 @@  discard block
 block discarded – undo
596 631
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
597 632
 
598 633
 	// Need legacy scripts?
599
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
600
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
601
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
602
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
603
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
604
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
634
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
635
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
636
+	}
637
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
638
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
639
+	}
640
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
641
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
642
+	}
605 643
 
606 644
 	// We don't need "-utf8" files anymore...
607 645
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
608 646
 
609 647
 	// This needs to exist!
610
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
611
-		return throw_error('The upgrader could not find the &quot;Install&quot; 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>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
612
-	else
613
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
648
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
649
+			return throw_error('The upgrader could not find the &quot;Install&quot; 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>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
650
+	} else {
651
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
652
+	}
614 653
 
615
-	if (!$check)
616
-		// 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.
654
+	if (!$check) {
655
+			// 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.
617 656
 		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.');
657
+	}
618 658
 
619 659
 	// Do they meet the install requirements?
620
-	if (!php_version_check())
621
-		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.');
660
+	if (!php_version_check()) {
661
+			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.');
662
+	}
622 663
 
623
-	if (!db_version_check())
624
-		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.');
664
+	if (!db_version_check()) {
665
+			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.');
666
+	}
625 667
 
626 668
 	// Do some checks to make sure they have proper privileges
627 669
 	db_extend('packages');
@@ -636,14 +678,16 @@  discard block
 block discarded – undo
636 678
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
637 679
 
638 680
 	// Sorry... we need CREATE, ALTER and DROP
639
-	if (!$create || !$alter || !$drop)
640
-		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.');
681
+	if (!$create || !$alter || !$drop) {
682
+			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.');
683
+	}
641 684
 
642 685
 	// Do a quick version spot check.
643 686
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
644 687
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
645
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
646
-		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.');
688
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
689
+			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.');
690
+	}
647 691
 
648 692
 	// What absolutely needs to be writable?
649 693
 	$writable_files = array(
@@ -665,12 +709,13 @@  discard block
 block discarded – undo
665 709
 	quickFileWritable($custom_av_dir);
666 710
 
667 711
 	// Are we good now?
668
-	if (!is_writable($custom_av_dir))
669
-		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));
670
-	elseif ($need_settings_update)
712
+	if (!is_writable($custom_av_dir)) {
713
+			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));
714
+	} elseif ($need_settings_update)
671 715
 	{
672
-		if (!function_exists('cache_put_data'))
673
-			require_once($sourcedir . '/Load.php');
716
+		if (!function_exists('cache_put_data')) {
717
+					require_once($sourcedir . '/Load.php');
718
+		}
674 719
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
675 720
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
676 721
 	}
@@ -679,28 +724,33 @@  discard block
 block discarded – undo
679 724
 
680 725
 	// Check the cache directory.
681 726
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
682
-	if (!file_exists($cachedir_temp))
683
-		@mkdir($cachedir_temp);
684
-	if (!file_exists($cachedir_temp))
685
-		return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
686
-
687
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
688
-		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>.');
689
-	elseif (!isset($_GET['skiplang']))
727
+	if (!file_exists($cachedir_temp)) {
728
+			@mkdir($cachedir_temp);
729
+	}
730
+	if (!file_exists($cachedir_temp)) {
731
+			return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
732
+	}
733
+
734
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
735
+			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>.');
736
+	} elseif (!isset($_GET['skiplang']))
690 737
 	{
691 738
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
692 739
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
693 740
 
694
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
695
-			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>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
741
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
742
+					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>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
743
+		}
696 744
 	}
697 745
 
698
-	if (!makeFilesWritable($writable_files))
699
-		return false;
746
+	if (!makeFilesWritable($writable_files)) {
747
+			return false;
748
+	}
700 749
 
701 750
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
702
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
703
-		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.');
751
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
752
+			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.');
753
+	}
704 754
 
705 755
 	// Upgrade the agreement.
706 756
 	elseif (isset($modSettings['agreement']))
@@ -711,8 +761,8 @@  discard block
 block discarded – undo
711 761
 	}
712 762
 
713 763
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
714
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
715
-		$upcontext['warning'] = '
764
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
765
+			$upcontext['warning'] = '
716 766
 			It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to &quot;' . $boarddir . '&quot; but should probably be &quot;' . dirname(__FILE__) . '&quot;. Settings.php currently lists your paths as:<br>
717 767
 			<ul>
718 768
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -720,10 +770,12 @@  discard block
 block discarded – undo
720 770
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
721 771
 			</ul>
722 772
 			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="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
773
+	}
723 774
 
724 775
 	// Either we're logged in or we're going to present the login.
725
-	if (checkLogin())
726
-		return true;
776
+	if (checkLogin()) {
777
+			return true;
778
+	}
727 779
 
728 780
 	$upcontext += createToken('login');
729 781
 
@@ -737,15 +789,17 @@  discard block
 block discarded – undo
737 789
 	global $smcFunc, $db_type, $support_js;
738 790
 
739 791
 	// Don't bother if the security is disabled.
740
-	if ($disable_security)
741
-		return true;
792
+	if ($disable_security) {
793
+			return true;
794
+	}
742 795
 
743 796
 	// Are we trying to login?
744 797
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
745 798
 	{
746 799
 		// If we've disabled security pick a suitable name!
747
-		if (empty($_POST['user']))
748
-			$_POST['user'] = 'Administrator';
800
+		if (empty($_POST['user'])) {
801
+					$_POST['user'] = 'Administrator';
802
+		}
749 803
 
750 804
 		// Before 2.0 these column names were different!
751 805
 		$oldDB = false;
@@ -760,16 +814,17 @@  discard block
 block discarded – undo
760 814
 					'db_error_skip' => true,
761 815
 				)
762 816
 			);
763
-			if ($smcFunc['db_num_rows']($request) != 0)
764
-				$oldDB = true;
817
+			if ($smcFunc['db_num_rows']($request) != 0) {
818
+							$oldDB = true;
819
+			}
765 820
 			$smcFunc['db_free_result']($request);
766 821
 		}
767 822
 
768 823
 		// Get what we believe to be their details.
769 824
 		if (!$disable_security)
770 825
 		{
771
-			if ($oldDB)
772
-				$request = $smcFunc['db_query']('', '
826
+			if ($oldDB) {
827
+							$request = $smcFunc['db_query']('', '
773 828
 					SELECT id_member, memberName AS member_name, passwd, id_group,
774 829
 					additionalGroups AS additional_groups, lngfile
775 830
 					FROM {db_prefix}members
@@ -779,8 +834,8 @@  discard block
 block discarded – undo
779 834
 						'db_error_skip' => true,
780 835
 					)
781 836
 				);
782
-			else
783
-				$request = $smcFunc['db_query']('', '
837
+			} else {
838
+							$request = $smcFunc['db_query']('', '
784 839
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
785 840
 					FROM {db_prefix}members
786 841
 					WHERE member_name = {string:member_name}',
@@ -789,6 +844,7 @@  discard block
 block discarded – undo
789 844
 						'db_error_skip' => true,
790 845
 					)
791 846
 				);
847
+			}
792 848
 			if ($smcFunc['db_num_rows']($request) != 0)
793 849
 			{
794 850
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -796,16 +852,17 @@  discard block
 block discarded – undo
796 852
 				$groups = explode(',', $addGroups);
797 853
 				$groups[] = $id_group;
798 854
 
799
-				foreach ($groups as $k => $v)
800
-					$groups[$k] = (int) $v;
855
+				foreach ($groups as $k => $v) {
856
+									$groups[$k] = (int) $v;
857
+				}
801 858
 
802 859
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
803 860
 
804 861
 				// We don't use "-utf8" anymore...
805 862
 				$user_language = str_ireplace('-utf8', '', $user_language);
863
+			} else {
864
+							$upcontext['username_incorrect'] = true;
806 865
 			}
807
-			else
808
-				$upcontext['username_incorrect'] = true;
809 866
 			$smcFunc['db_free_result']($request);
810 867
 		}
811 868
 		$upcontext['username'] = $_POST['user'];
@@ -815,13 +872,14 @@  discard block
 block discarded – undo
815 872
 		{
816 873
 			$upcontext['upgrade_status']['js'] = 1;
817 874
 			$support_js = 1;
875
+		} else {
876
+					$support_js = 0;
818 877
 		}
819
-		else
820
-			$support_js = 0;
821 878
 
822 879
 		// Note down the version we are coming from.
823
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
824
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
880
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
881
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
882
+		}
825 883
 
826 884
 		// Didn't get anywhere?
827 885
 		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']))
@@ -855,15 +913,15 @@  discard block
 block discarded – undo
855 913
 							'db_error_skip' => true,
856 914
 						)
857 915
 					);
858
-					if ($smcFunc['db_num_rows']($request) == 0)
859
-						return throw_error('You need to be an admin to perform an upgrade!');
916
+					if ($smcFunc['db_num_rows']($request) == 0) {
917
+											return throw_error('You need to be an admin to perform an upgrade!');
918
+					}
860 919
 					$smcFunc['db_free_result']($request);
861 920
 				}
862 921
 
863 922
 				$upcontext['user']['id'] = $id_member;
864 923
 				$upcontext['user']['name'] = $name;
865
-			}
866
-			else
924
+			} else
867 925
 			{
868 926
 				$upcontext['user']['id'] = 1;
869 927
 				$upcontext['user']['name'] = 'Administrator';
@@ -879,11 +937,11 @@  discard block
 block discarded – undo
879 937
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
880 938
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
881 939
 
882
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
883
-					$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'] . '.';
884
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
885
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
886
-				else
940
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
941
+									$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'] . '.';
942
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
943
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
944
+				} else
887 945
 				{
888 946
 					// Set this as the new language.
889 947
 					$upcontext['language'] = $user_language;
@@ -927,8 +985,9 @@  discard block
 block discarded – undo
927 985
 	unset($member_columns);
928 986
 
929 987
 	// If we've not submitted then we're done.
930
-	if (empty($_POST['upcont']))
931
-		return false;
988
+	if (empty($_POST['upcont'])) {
989
+			return false;
990
+	}
932 991
 
933 992
 	// Firstly, if they're enabling SM stat collection just do it.
934 993
 	if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats']))
@@ -943,25 +1002,26 @@  discard block
 block discarded – undo
943 1002
 			fwrite($fp, $out);
944 1003
 
945 1004
 			$return_data = '';
946
-			while (!feof($fp))
947
-				$return_data .= fgets($fp, 128);
1005
+			while (!feof($fp)) {
1006
+							$return_data .= fgets($fp, 128);
1007
+			}
948 1008
 
949 1009
 			fclose($fp);
950 1010
 
951 1011
 			// Get the unique site ID.
952 1012
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
953 1013
 
954
-			if (!empty($ID[1]))
955
-				$smcFunc['db_insert']('replace',
1014
+			if (!empty($ID[1])) {
1015
+							$smcFunc['db_insert']('replace',
956 1016
 					$db_prefix . 'settings',
957 1017
 					array('variable' => 'string', 'value' => 'string'),
958 1018
 					array('allow_sm_stats', $ID[1]),
959 1019
 					array('variable')
960 1020
 				);
1021
+			}
961 1022
 		}
962
-	}
963
-	else
964
-		$smcFunc['db_query']('', '
1023
+	} else {
1024
+			$smcFunc['db_query']('', '
965 1025
 			DELETE FROM {db_prefix}settings
966 1026
 			WHERE variable = {string:allow_sm_stats}',
967 1027
 			array(
@@ -969,6 +1029,7 @@  discard block
 block discarded – undo
969 1029
 				'db_error_skip' => true,
970 1030
 			)
971 1031
 		);
1032
+	}
972 1033
 
973 1034
 	// Deleting old karma stuff?
974 1035
 	if (!empty($_POST['delete_karma']))
@@ -983,20 +1044,22 @@  discard block
 block discarded – undo
983 1044
 		);
984 1045
 
985 1046
 		// Cleaning up old karma member settings.
986
-		if ($upcontext['karma_installed']['good'])
987
-			$smcFunc['db_query']('', '
1047
+		if ($upcontext['karma_installed']['good']) {
1048
+					$smcFunc['db_query']('', '
988 1049
 				ALTER TABLE {db_prefix}members
989 1050
 				DROP karma_good',
990 1051
 				array()
991 1052
 			);
1053
+		}
992 1054
 
993 1055
 		// Does karma bad was enable?
994
-		if ($upcontext['karma_installed']['bad'])
995
-			$smcFunc['db_query']('', '
1056
+		if ($upcontext['karma_installed']['bad']) {
1057
+					$smcFunc['db_query']('', '
996 1058
 				ALTER TABLE {db_prefix}members
997 1059
 				DROP karma_bad',
998 1060
 				array()
999 1061
 			);
1062
+		}
1000 1063
 
1001 1064
 		// Cleaning up old karma permissions.
1002 1065
 		$smcFunc['db_query']('', '
@@ -1009,26 +1072,29 @@  discard block
 block discarded – undo
1009 1072
 	}
1010 1073
 
1011 1074
 	// Emptying the error log?
1012
-	if (!empty($_POST['empty_error']))
1013
-		$smcFunc['db_query']('truncate_table', '
1075
+	if (!empty($_POST['empty_error'])) {
1076
+			$smcFunc['db_query']('truncate_table', '
1014 1077
 			TRUNCATE {db_prefix}log_errors',
1015 1078
 			array(
1016 1079
 			)
1017 1080
 		);
1081
+	}
1018 1082
 
1019 1083
 	$changes = array();
1020 1084
 
1021 1085
 	// Add proxy settings.
1022
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1023
-		$changes += array(
1086
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1087
+			$changes += array(
1024 1088
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1025 1089
 			'image_proxy_maxsize' => 5190,
1026 1090
 			'image_proxy_enabled' => 0,
1027 1091
 		);
1092
+	}
1028 1093
 
1029 1094
 	// If we're overriding the language follow it through.
1030
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1031
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1095
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1096
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1097
+	}
1032 1098
 
1033 1099
 	if (!empty($_POST['maint']))
1034 1100
 	{
@@ -1040,30 +1106,34 @@  discard block
 block discarded – undo
1040 1106
 		{
1041 1107
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1042 1108
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1043
-		}
1044
-		else
1109
+		} else
1045 1110
 		{
1046 1111
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1047 1112
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1048 1113
 		}
1049 1114
 	}
1050 1115
 
1051
-	if ($command_line)
1052
-		echo ' * Updating Settings.php...';
1116
+	if ($command_line) {
1117
+			echo ' * Updating Settings.php...';
1118
+	}
1053 1119
 
1054 1120
 	// Fix some old paths.
1055
-	if (substr($boarddir, 0, 1) == '.')
1056
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1121
+	if (substr($boarddir, 0, 1) == '.') {
1122
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1123
+	}
1057 1124
 
1058
-	if (substr($sourcedir, 0, 1) == '.')
1059
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1125
+	if (substr($sourcedir, 0, 1) == '.') {
1126
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1127
+	}
1060 1128
 
1061
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1062
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1129
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1130
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1131
+	}
1063 1132
 
1064 1133
 	// Not had the database type added before?
1065
-	if (empty($db_type))
1066
-		$changes['db_type'] = 'mysql';
1134
+	if (empty($db_type)) {
1135
+			$changes['db_type'] = 'mysql';
1136
+	}
1067 1137
 
1068 1138
 	// If they have a "host:port" setup for the host, split that into separate values
1069 1139
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1074,32 +1144,36 @@  discard block
 block discarded – undo
1074 1144
 		$changes['db_server'] = '\'' . $db_server . '\'';
1075 1145
 
1076 1146
 		// Only set this if we're not using the default port
1077
-		if ($db_port != ini_get('mysqli.default_port'))
1078
-			$changes['db_port'] = (int) $db_port;
1079
-	}
1080
-	elseif (!empty($db_port))
1147
+		if ($db_port != ini_get('mysqli.default_port')) {
1148
+					$changes['db_port'] = (int) $db_port;
1149
+		}
1150
+	} elseif (!empty($db_port))
1081 1151
 	{
1082 1152
 		// If db_port is set and is the same as the default, set it to ''
1083 1153
 		if ($db_type == 'mysql')
1084 1154
 		{
1085
-			if ($db_port == ini_get('mysqli.default_port'))
1086
-				$changes['db_port'] = '\'\'';
1087
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1088
-				$changes['db_port'] = '\'\'';
1155
+			if ($db_port == ini_get('mysqli.default_port')) {
1156
+							$changes['db_port'] = '\'\'';
1157
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1158
+							$changes['db_port'] = '\'\'';
1159
+			}
1089 1160
 		}
1090 1161
 	}
1091 1162
 
1092 1163
 	// Maybe we haven't had this option yet?
1093
-	if (empty($packagesdir))
1094
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1164
+	if (empty($packagesdir)) {
1165
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1166
+	}
1095 1167
 
1096 1168
 	// Add support for $tasksdir var.
1097
-	if (empty($tasksdir))
1098
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1169
+	if (empty($tasksdir)) {
1170
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1171
+	}
1099 1172
 
1100 1173
 	// Make sure we fix the language as well.
1101
-	if (stristr($language, '-utf8'))
1102
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1174
+	if (stristr($language, '-utf8')) {
1175
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1176
+	}
1103 1177
 
1104 1178
 	// @todo Maybe change the cookie name if going to 1.1, too?
1105 1179
 
@@ -1107,8 +1181,9 @@  discard block
 block discarded – undo
1107 1181
 	require_once($sourcedir . '/Subs-Admin.php');
1108 1182
 	updateSettingsFile($changes);
1109 1183
 
1110
-	if ($command_line)
1111
-		echo ' Successful.' . "\n";
1184
+	if ($command_line) {
1185
+			echo ' Successful.' . "\n";
1186
+	}
1112 1187
 
1113 1188
 	// Are we doing debug?
1114 1189
 	if (isset($_POST['debug']))
@@ -1118,8 +1193,9 @@  discard block
 block discarded – undo
1118 1193
 	}
1119 1194
 
1120 1195
 	// If we're not backing up then jump one.
1121
-	if (empty($_POST['backup']))
1122
-		$upcontext['current_step']++;
1196
+	if (empty($_POST['backup'])) {
1197
+			$upcontext['current_step']++;
1198
+	}
1123 1199
 
1124 1200
 	// If we've got here then let's proceed to the next step!
1125 1201
 	return true;
@@ -1134,8 +1210,9 @@  discard block
 block discarded – undo
1134 1210
 	$upcontext['page_title'] = 'Backup Database';
1135 1211
 
1136 1212
 	// Done it already - js wise?
1137
-	if (!empty($_POST['backup_done']))
1138
-		return true;
1213
+	if (!empty($_POST['backup_done'])) {
1214
+			return true;
1215
+	}
1139 1216
 
1140 1217
 	// Some useful stuff here.
1141 1218
 	db_extend();
@@ -1149,9 +1226,10 @@  discard block
 block discarded – undo
1149 1226
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1150 1227
 
1151 1228
 	$table_names = array();
1152
-	foreach ($tables as $table)
1153
-		if (substr($table, 0, 7) !== 'backup_')
1229
+	foreach ($tables as $table) {
1230
+			if (substr($table, 0, 7) !== 'backup_')
1154 1231
 			$table_names[] = $table;
1232
+	}
1155 1233
 
1156 1234
 	$upcontext['table_count'] = count($table_names);
1157 1235
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1161,12 +1239,14 @@  discard block
 block discarded – undo
1161 1239
 	$file_steps = $upcontext['table_count'];
1162 1240
 
1163 1241
 	// What ones have we already done?
1164
-	foreach ($table_names as $id => $table)
1165
-		if ($id < $_GET['substep'])
1242
+	foreach ($table_names as $id => $table) {
1243
+			if ($id < $_GET['substep'])
1166 1244
 			$upcontext['previous_tables'][] = $table;
1245
+	}
1167 1246
 
1168
-	if ($command_line)
1169
-		echo 'Backing Up Tables.';
1247
+	if ($command_line) {
1248
+			echo 'Backing Up Tables.';
1249
+	}
1170 1250
 
1171 1251
 	// If we don't support javascript we backup here.
1172 1252
 	if (!$support_js || isset($_GET['xml']))
@@ -1185,8 +1265,9 @@  discard block
 block discarded – undo
1185 1265
 			backupTable($table_names[$substep]);
1186 1266
 
1187 1267
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1188
-			if (isset($_GET['xml']))
1189
-				return upgradeExit();
1268
+			if (isset($_GET['xml'])) {
1269
+							return upgradeExit();
1270
+			}
1190 1271
 		}
1191 1272
 
1192 1273
 		if ($command_line)
@@ -1219,9 +1300,10 @@  discard block
 block discarded – undo
1219 1300
 
1220 1301
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1221 1302
 
1222
-	if ($command_line)
1223
-		echo ' done.';
1224
-}
1303
+	if ($command_line) {
1304
+			echo ' done.';
1305
+	}
1306
+	}
1225 1307
 
1226 1308
 // Step 2: Everything.
1227 1309
 function DatabaseChanges()
@@ -1230,8 +1312,9 @@  discard block
 block discarded – undo
1230 1312
 	global $upcontext, $support_js, $db_type;
1231 1313
 
1232 1314
 	// Have we just completed this?
1233
-	if (!empty($_POST['database_done']))
1234
-		return true;
1315
+	if (!empty($_POST['database_done'])) {
1316
+			return true;
1317
+	}
1235 1318
 
1236 1319
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1237 1320
 	$upcontext['page_title'] = 'Database Changes';
@@ -1246,15 +1329,16 @@  discard block
 block discarded – undo
1246 1329
 	);
1247 1330
 
1248 1331
 	// How many files are there in total?
1249
-	if (isset($_GET['filecount']))
1250
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1251
-	else
1332
+	if (isset($_GET['filecount'])) {
1333
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1334
+	} else
1252 1335
 	{
1253 1336
 		$upcontext['file_count'] = 0;
1254 1337
 		foreach ($files as $file)
1255 1338
 		{
1256
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1257
-				$upcontext['file_count']++;
1339
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1340
+							$upcontext['file_count']++;
1341
+			}
1258 1342
 		}
1259 1343
 	}
1260 1344
 
@@ -1264,9 +1348,9 @@  discard block
 block discarded – undo
1264 1348
 	$upcontext['cur_file_num'] = 0;
1265 1349
 	foreach ($files as $file)
1266 1350
 	{
1267
-		if ($did_not_do)
1268
-			$did_not_do--;
1269
-		else
1351
+		if ($did_not_do) {
1352
+					$did_not_do--;
1353
+		} else
1270 1354
 		{
1271 1355
 			$upcontext['cur_file_num']++;
1272 1356
 			$upcontext['cur_file_name'] = $file[0];
@@ -1293,12 +1377,13 @@  discard block
 block discarded – undo
1293 1377
 					// Flag to move on to the next.
1294 1378
 					$upcontext['completed_step'] = true;
1295 1379
 					// Did we complete the whole file?
1296
-					if ($nextFile)
1297
-						$upcontext['current_debug_item_num'] = -1;
1380
+					if ($nextFile) {
1381
+											$upcontext['current_debug_item_num'] = -1;
1382
+					}
1298 1383
 					return upgradeExit();
1384
+				} elseif ($support_js) {
1385
+									break;
1299 1386
 				}
1300
-				elseif ($support_js)
1301
-					break;
1302 1387
 			}
1303 1388
 			// Set the progress bar to be right as if we had - even if we hadn't...
1304 1389
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1323,8 +1408,9 @@  discard block
 block discarded – undo
1323 1408
 	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1324 1409
 
1325 1410
 	// Now it's nice to have some of the basic SMF source files.
1326
-	if (!isset($_GET['ssi']) && !$command_line)
1327
-		redirectLocation('&ssi=1');
1411
+	if (!isset($_GET['ssi']) && !$command_line) {
1412
+			redirectLocation('&ssi=1');
1413
+	}
1328 1414
 
1329 1415
 	$upcontext['sub_template'] = 'upgrade_complete';
1330 1416
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1340,14 +1426,16 @@  discard block
 block discarded – undo
1340 1426
 	// Are we in maintenance mode?
1341 1427
 	if (isset($upcontext['user']['main']))
1342 1428
 	{
1343
-		if ($command_line)
1344
-			echo ' * ';
1429
+		if ($command_line) {
1430
+					echo ' * ';
1431
+		}
1345 1432
 		$upcontext['removed_maintenance'] = true;
1346 1433
 		$changes['maintenance'] = $upcontext['user']['main'];
1347 1434
 	}
1348 1435
 	// Otherwise if somehow we are in 2 let's go to 1.
1349
-	elseif (!empty($maintenance) && $maintenance == 2)
1350
-		$changes['maintenance'] = 1;
1436
+	elseif (!empty($maintenance) && $maintenance == 2) {
1437
+			$changes['maintenance'] = 1;
1438
+	}
1351 1439
 
1352 1440
 	// Wipe this out...
1353 1441
 	$upcontext['user'] = array();
@@ -1362,9 +1450,9 @@  discard block
 block discarded – undo
1362 1450
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1363 1451
 
1364 1452
 	// Now is the perfect time to fetch the SM files.
1365
-	if ($command_line)
1366
-		cli_scheduled_fetchSMfiles();
1367
-	else
1453
+	if ($command_line) {
1454
+			cli_scheduled_fetchSMfiles();
1455
+	} else
1368 1456
 	{
1369 1457
 		require_once($sourcedir . '/ScheduledTasks.php');
1370 1458
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1372,8 +1460,9 @@  discard block
 block discarded – undo
1372 1460
 	}
1373 1461
 
1374 1462
 	// Log what we've done.
1375
-	if (empty($user_info['id']))
1376
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1463
+	if (empty($user_info['id'])) {
1464
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1465
+	}
1377 1466
 
1378 1467
 	// Log the action manually, so CLI still works.
1379 1468
 	$smcFunc['db_insert']('',
@@ -1392,8 +1481,9 @@  discard block
 block discarded – undo
1392 1481
 
1393 1482
 	// Save the current database version.
1394 1483
 	$server_version = $smcFunc['db_server_info']();
1395
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1396
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1484
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1485
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1486
+	}
1397 1487
 
1398 1488
 	if ($command_line)
1399 1489
 	{
@@ -1405,8 +1495,9 @@  discard block
 block discarded – undo
1405 1495
 
1406 1496
 	// Make sure it says we're done.
1407 1497
 	$upcontext['overall_percent'] = 100;
1408
-	if (isset($upcontext['step_progress']))
1409
-		unset($upcontext['step_progress']);
1498
+	if (isset($upcontext['step_progress'])) {
1499
+			unset($upcontext['step_progress']);
1500
+	}
1410 1501
 
1411 1502
 	$_GET['substep'] = 0;
1412 1503
 	return false;
@@ -1417,8 +1508,9 @@  discard block
 block discarded – undo
1417 1508
 {
1418 1509
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1419 1510
 
1420
-	if (empty($modSettings['time_format']))
1421
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1511
+	if (empty($modSettings['time_format'])) {
1512
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1513
+	}
1422 1514
 
1423 1515
 	// What files do we want to get
1424 1516
 	$request = $smcFunc['db_query']('', '
@@ -1452,8 +1544,9 @@  discard block
 block discarded – undo
1452 1544
 		$file_data = fetch_web_data($url);
1453 1545
 
1454 1546
 		// If we got an error - give up - the site might be down.
1455
-		if ($file_data === false)
1456
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1547
+		if ($file_data === false) {
1548
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1549
+		}
1457 1550
 
1458 1551
 		// Save the file to the database.
1459 1552
 		$smcFunc['db_query']('substring', '
@@ -1495,8 +1588,9 @@  discard block
 block discarded – undo
1495 1588
 	$themeData = array();
1496 1589
 	foreach ($values as $variable => $value)
1497 1590
 	{
1498
-		if (!isset($value) || $value === null)
1499
-			$value = 0;
1591
+		if (!isset($value) || $value === null) {
1592
+					$value = 0;
1593
+		}
1500 1594
 
1501 1595
 		$themeData[] = array(0, 1, $variable, $value);
1502 1596
 	}
@@ -1525,8 +1619,9 @@  discard block
 block discarded – undo
1525 1619
 
1526 1620
 	foreach ($values as $variable => $value)
1527 1621
 	{
1528
-		if (empty($modSettings[$value[0]]))
1529
-			continue;
1622
+		if (empty($modSettings[$value[0]])) {
1623
+					continue;
1624
+		}
1530 1625
 
1531 1626
 		$smcFunc['db_query']('', '
1532 1627
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1612,10 +1707,11 @@  discard block
 block discarded – undo
1612 1707
 	set_error_handler(
1613 1708
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1614 1709
 		{
1615
-			if ($support_js)
1616
-				return true;
1617
-			else
1618
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1710
+			if ($support_js) {
1711
+							return true;
1712
+			} else {
1713
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1714
+			}
1619 1715
 		}
1620 1716
 	);
1621 1717
 
@@ -1630,8 +1726,9 @@  discard block
 block discarded – undo
1630 1726
 				'db_error_skip' => true,
1631 1727
 			)
1632 1728
 		);
1633
-		if ($smcFunc['db_num_rows']($request) === 0)
1634
-			die('Unable to find members table!');
1729
+		if ($smcFunc['db_num_rows']($request) === 0) {
1730
+					die('Unable to find members table!');
1731
+		}
1635 1732
 		$table_status = $smcFunc['db_fetch_assoc']($request);
1636 1733
 		$smcFunc['db_free_result']($request);
1637 1734
 
@@ -1646,17 +1743,20 @@  discard block
 block discarded – undo
1646 1743
 				)
1647 1744
 			);
1648 1745
 			// Got something?
1649
-			if ($smcFunc['db_num_rows']($request) !== 0)
1650
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
1746
+			if ($smcFunc['db_num_rows']($request) !== 0) {
1747
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
1748
+			}
1651 1749
 			$smcFunc['db_free_result']($request);
1652 1750
 
1653 1751
 			// Excellent!
1654
-			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset']))
1655
-				$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
1752
+			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) {
1753
+							$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
1754
+			}
1656 1755
 		}
1657 1756
 	}
1658
-	if (empty($db_collation))
1659
-		$db_collation = '';
1757
+	if (empty($db_collation)) {
1758
+			$db_collation = '';
1759
+	}
1660 1760
 
1661 1761
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1662 1762
 
@@ -1668,8 +1768,9 @@  discard block
 block discarded – undo
1668 1768
 	$last_step = '';
1669 1769
 
1670 1770
 	// Make sure all newly created tables will have the proper characters set.
1671
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1672
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1771
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1772
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1773
+	}
1673 1774
 
1674 1775
 	// Count the total number of steps within this file - for progress.
1675 1776
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1689,15 +1790,18 @@  discard block
 block discarded – undo
1689 1790
 		$do_current = $substep >= $_GET['substep'];
1690 1791
 
1691 1792
 		// Get rid of any comments in the beginning of the line...
1692
-		if (substr(trim($line), 0, 2) === '/*')
1693
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1793
+		if (substr(trim($line), 0, 2) === '/*') {
1794
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1795
+		}
1694 1796
 
1695 1797
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1696
-		if ($is_debug && !$support_js && $command_line)
1697
-			flush();
1798
+		if ($is_debug && !$support_js && $command_line) {
1799
+					flush();
1800
+		}
1698 1801
 
1699
-		if (trim($line) === '')
1700
-			continue;
1802
+		if (trim($line) === '') {
1803
+					continue;
1804
+		}
1701 1805
 
1702 1806
 		if (trim(substr($line, 0, 3)) === '---')
1703 1807
 		{
@@ -1707,8 +1811,9 @@  discard block
 block discarded – undo
1707 1811
 			if (trim($current_data) != '' && $type !== '}')
1708 1812
 			{
1709 1813
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1710
-				if ($command_line)
1711
-					echo $upcontext['error_message'];
1814
+				if ($command_line) {
1815
+									echo $upcontext['error_message'];
1816
+				}
1712 1817
 			}
1713 1818
 
1714 1819
 			if ($type == ' ')
@@ -1726,17 +1831,18 @@  discard block
 block discarded – undo
1726 1831
 				if ($do_current)
1727 1832
 				{
1728 1833
 					$upcontext['actioned_items'][] = $last_step;
1729
-					if ($command_line)
1730
-						echo ' * ';
1834
+					if ($command_line) {
1835
+											echo ' * ';
1836
+					}
1731 1837
 				}
1732
-			}
1733
-			elseif ($type == '#')
1838
+			} elseif ($type == '#')
1734 1839
 			{
1735 1840
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1736 1841
 
1737 1842
 				$upcontext['current_debug_item_num']++;
1738
-				if (trim($line) != '---#')
1739
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1843
+				if (trim($line) != '---#') {
1844
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1845
+				}
1740 1846
 
1741 1847
 				// Have we already done something?
1742 1848
 				if (isset($_GET['xml']) && $done_something)
@@ -1747,34 +1853,36 @@  discard block
 block discarded – undo
1747 1853
 
1748 1854
 				if ($do_current)
1749 1855
 				{
1750
-					if (trim($line) == '---#' && $command_line)
1751
-						echo ' done.', $endl;
1752
-					elseif ($command_line)
1753
-						echo ' +++ ', rtrim(substr($line, 4));
1754
-					elseif (trim($line) != '---#')
1856
+					if (trim($line) == '---#' && $command_line) {
1857
+											echo ' done.', $endl;
1858
+					} elseif ($command_line) {
1859
+											echo ' +++ ', rtrim(substr($line, 4));
1860
+					} elseif (trim($line) != '---#')
1755 1861
 					{
1756
-						if ($is_debug)
1757
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1862
+						if ($is_debug) {
1863
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1864
+						}
1758 1865
 					}
1759 1866
 				}
1760 1867
 
1761 1868
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1762 1869
 				{
1763
-					if ($command_line)
1764
-						echo ' * ';
1765
-					else
1766
-						$upcontext['actioned_items'][] = $last_step;
1870
+					if ($command_line) {
1871
+											echo ' * ';
1872
+					} else {
1873
+											$upcontext['actioned_items'][] = $last_step;
1874
+					}
1767 1875
 				}
1768 1876
 
1769 1877
 				// Small step - only if we're actually doing stuff.
1770
-				if ($do_current)
1771
-					nextSubstep(++$substep);
1772
-				else
1773
-					$substep++;
1774
-			}
1775
-			elseif ($type == '{')
1776
-				$current_type = 'code';
1777
-			elseif ($type == '}')
1878
+				if ($do_current) {
1879
+									nextSubstep(++$substep);
1880
+				} else {
1881
+									$substep++;
1882
+				}
1883
+			} elseif ($type == '{') {
1884
+							$current_type = 'code';
1885
+			} elseif ($type == '}')
1778 1886
 			{
1779 1887
 				$current_type = 'sql';
1780 1888
 
@@ -1787,8 +1895,9 @@  discard block
 block discarded – undo
1787 1895
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1788 1896
 				{
1789 1897
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1790
-					if ($command_line)
1791
-						echo $upcontext['error_message'];
1898
+					if ($command_line) {
1899
+											echo $upcontext['error_message'];
1900
+					}
1792 1901
 				}
1793 1902
 
1794 1903
 				// Done with code!
@@ -1868,8 +1977,9 @@  discard block
 block discarded – undo
1868 1977
 	$db_unbuffered = false;
1869 1978
 
1870 1979
 	// Failure?!
1871
-	if ($result !== false)
1872
-		return $result;
1980
+	if ($result !== false) {
1981
+			return $result;
1982
+	}
1873 1983
 
1874 1984
 	$db_error_message = $smcFunc['db_error']($db_connection);
1875 1985
 	// If MySQL we do something more clever.
@@ -1897,54 +2007,61 @@  discard block
 block discarded – undo
1897 2007
 			{
1898 2008
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1899 2009
 				$result = mysqli_query($db_connection, $string);
1900
-				if ($result !== false)
1901
-					return $result;
2010
+				if ($result !== false) {
2011
+									return $result;
2012
+				}
1902 2013
 			}
1903
-		}
1904
-		elseif ($mysqli_errno == 2013)
2014
+		} elseif ($mysqli_errno == 2013)
1905 2015
 		{
1906 2016
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1907 2017
 			mysqli_select_db($db_connection, $db_name);
1908 2018
 			if ($db_connection)
1909 2019
 			{
1910 2020
 				$result = mysqli_query($db_connection, $string);
1911
-				if ($result !== false)
1912
-					return $result;
2021
+				if ($result !== false) {
2022
+									return $result;
2023
+				}
1913 2024
 			}
1914 2025
 		}
1915 2026
 		// Duplicate column name... should be okay ;).
1916
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1917
-			return false;
2027
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2028
+					return false;
2029
+		}
1918 2030
 		// Duplicate insert... make sure it's the proper type of query ;).
1919
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1920
-			return false;
2031
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2032
+					return false;
2033
+		}
1921 2034
 		// Creating an index on a non-existent column.
1922
-		elseif ($mysqli_errno == 1072)
1923
-			return false;
1924
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1925
-			return false;
2035
+		elseif ($mysqli_errno == 1072) {
2036
+					return false;
2037
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2038
+					return false;
2039
+		}
1926 2040
 	}
1927 2041
 	// If a table already exists don't go potty.
1928 2042
 	else
1929 2043
 	{
1930 2044
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1931 2045
 		{
1932
-			if (strpos($db_error_message, 'exist') !== false)
1933
-				return true;
1934
-		}
1935
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2046
+			if (strpos($db_error_message, 'exist') !== false) {
2047
+							return true;
2048
+			}
2049
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1936 2050
 		{
1937
-			if (strpos($db_error_message, 'duplicate') !== false)
1938
-				return true;
2051
+			if (strpos($db_error_message, 'duplicate') !== false) {
2052
+							return true;
2053
+			}
1939 2054
 		}
1940 2055
 	}
1941 2056
 
1942 2057
 	// Get the query string so we pass everything.
1943 2058
 	$query_string = '';
1944
-	foreach ($_GET as $k => $v)
1945
-		$query_string .= ';' . $k . '=' . $v;
1946
-	if (strlen($query_string) != 0)
1947
-		$query_string = '?' . substr($query_string, 1);
2059
+	foreach ($_GET as $k => $v) {
2060
+			$query_string .= ';' . $k . '=' . $v;
2061
+	}
2062
+	if (strlen($query_string) != 0) {
2063
+			$query_string = '?' . substr($query_string, 1);
2064
+	}
1948 2065
 
1949 2066
 	if ($command_line)
1950 2067
 	{
@@ -1999,16 +2116,18 @@  discard block
 block discarded – undo
1999 2116
 			{
2000 2117
 				$found |= 1;
2001 2118
 				// Do some checks on the data if we have it set.
2002
-				if (isset($change['col_type']))
2003
-					$found &= $change['col_type'] === $column['type'];
2004
-				if (isset($change['null_allowed']))
2005
-					$found &= $column['null'] == $change['null_allowed'];
2006
-				if (isset($change['default']))
2007
-					$found &= $change['default'] === $column['default'];
2119
+				if (isset($change['col_type'])) {
2120
+									$found &= $change['col_type'] === $column['type'];
2121
+				}
2122
+				if (isset($change['null_allowed'])) {
2123
+									$found &= $column['null'] == $change['null_allowed'];
2124
+				}
2125
+				if (isset($change['default'])) {
2126
+									$found &= $change['default'] === $column['default'];
2127
+				}
2008 2128
 			}
2009 2129
 		}
2010
-	}
2011
-	elseif ($change['type'] === 'index')
2130
+	} elseif ($change['type'] === 'index')
2012 2131
 	{
2013 2132
 		$request = upgrade_query('
2014 2133
 			SHOW INDEX
@@ -2017,9 +2136,10 @@  discard block
 block discarded – undo
2017 2136
 		{
2018 2137
 			$cur_index = array();
2019 2138
 
2020
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2021
-				if ($row['Key_name'] === $change['name'])
2139
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2140
+							if ($row['Key_name'] === $change['name'])
2022 2141
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2142
+			}
2023 2143
 
2024 2144
 			ksort($cur_index, SORT_NUMERIC);
2025 2145
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2029,14 +2149,17 @@  discard block
 block discarded – undo
2029 2149
 	}
2030 2150
 
2031 2151
 	// If we're trying to add and it's added, we're done.
2032
-	if ($found && in_array($change['method'], array('add', 'change')))
2033
-		return true;
2152
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2153
+			return true;
2154
+	}
2034 2155
 	// Otherwise if we're removing and it wasn't found we're also done.
2035
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2036
-		return true;
2156
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2157
+			return true;
2158
+	}
2037 2159
 	// Otherwise is it just a test?
2038
-	elseif ($is_test)
2039
-		return false;
2160
+	elseif ($is_test) {
2161
+			return false;
2162
+	}
2040 2163
 
2041 2164
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2042 2165
 	$running = false;
@@ -2047,8 +2170,9 @@  discard block
 block discarded – undo
2047 2170
 			SHOW FULL PROCESSLIST');
2048 2171
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2049 2172
 		{
2050
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2051
-				$found = true;
2173
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2174
+							$found = true;
2175
+			}
2052 2176
 		}
2053 2177
 
2054 2178
 		// Can't find it? Then we need to run it fools!
@@ -2060,8 +2184,9 @@  discard block
 block discarded – undo
2060 2184
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2061 2185
 				' . $change['text'], true) !== false;
2062 2186
 
2063
-			if (!$success)
2064
-				return false;
2187
+			if (!$success) {
2188
+							return false;
2189
+			}
2065 2190
 
2066 2191
 			// Return
2067 2192
 			$running = true;
@@ -2103,8 +2228,9 @@  discard block
 block discarded – undo
2103 2228
 			'db_error_skip' => true,
2104 2229
 		)
2105 2230
 	);
2106
-	if ($smcFunc['db_num_rows']($request) === 0)
2107
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2231
+	if ($smcFunc['db_num_rows']($request) === 0) {
2232
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2233
+	}
2108 2234
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2109 2235
 	$smcFunc['db_free_result']($request);
2110 2236
 
@@ -2126,18 +2252,19 @@  discard block
 block discarded – undo
2126 2252
 			)
2127 2253
 		);
2128 2254
 		// No results? Just forget it all together.
2129
-		if ($smcFunc['db_num_rows']($request) === 0)
2130
-			unset($table_row['Collation']);
2131
-		else
2132
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2255
+		if ($smcFunc['db_num_rows']($request) === 0) {
2256
+					unset($table_row['Collation']);
2257
+		} else {
2258
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2259
+		}
2133 2260
 		$smcFunc['db_free_result']($request);
2134 2261
 	}
2135 2262
 
2136 2263
 	if ($column_fix)
2137 2264
 	{
2138 2265
 		// Make sure there are no NULL's left.
2139
-		if ($null_fix)
2140
-			$smcFunc['db_query']('', '
2266
+		if ($null_fix) {
2267
+					$smcFunc['db_query']('', '
2141 2268
 				UPDATE {db_prefix}' . $change['table'] . '
2142 2269
 				SET ' . $change['column'] . ' = {string:default}
2143 2270
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2146,6 +2273,7 @@  discard block
 block discarded – undo
2146 2273
 					'db_error_skip' => true,
2147 2274
 				)
2148 2275
 			);
2276
+		}
2149 2277
 
2150 2278
 		// Do the actual alteration.
2151 2279
 		$smcFunc['db_query']('', '
@@ -2174,8 +2302,9 @@  discard block
 block discarded – undo
2174 2302
 	}
2175 2303
 
2176 2304
 	// Not a column we need to check on?
2177
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2178
-		return;
2305
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2306
+			return;
2307
+	}
2179 2308
 
2180 2309
 	// Break it up you (six|seven).
2181 2310
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2194,13 +2323,13 @@  discard block
 block discarded – undo
2194 2323
 				'new_name' => $temp[2],
2195 2324
 		));
2196 2325
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2197
-		if ($smcFunc['db_num_rows'] != 1)
2198
-			return;
2326
+		if ($smcFunc['db_num_rows'] != 1) {
2327
+					return;
2328
+		}
2199 2329
 
2200 2330
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2201 2331
 		$smcFunc['db_free_result']($request);
2202
-	}
2203
-	else
2332
+	} else
2204 2333
 	{
2205 2334
 		// Do this the old fashion, sure method way.
2206 2335
 		$request = $smcFunc['db_query']('', '
@@ -2211,21 +2340,24 @@  discard block
 block discarded – undo
2211 2340
 		));
2212 2341
 		// Mayday!
2213 2342
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2214
-		if ($smcFunc['db_num_rows'] == 0)
2215
-			return;
2343
+		if ($smcFunc['db_num_rows'] == 0) {
2344
+					return;
2345
+		}
2216 2346
 
2217 2347
 		// Oh where, oh where has my little field gone. Oh where can it be...
2218
-		while ($row = $smcFunc['db_query']($request))
2219
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2348
+		while ($row = $smcFunc['db_query']($request)) {
2349
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2220 2350
 			{
2221 2351
 				$current_type = $row['Type'];
2352
+		}
2222 2353
 				break;
2223 2354
 			}
2224 2355
 	}
2225 2356
 
2226 2357
 	// If this doesn't match, the column may of been altered for a reason.
2227
-	if (trim($current_type) != trim($temp[3]))
2228
-		$temp[3] = $current_type;
2358
+	if (trim($current_type) != trim($temp[3])) {
2359
+			$temp[3] = $current_type;
2360
+	}
2229 2361
 
2230 2362
 	// Piece this back together.
2231 2363
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2237,8 +2369,9 @@  discard block
 block discarded – undo
2237 2369
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2238 2370
 	global $step_progress, $is_debug, $upcontext;
2239 2371
 
2240
-	if ($_GET['substep'] < $substep)
2241
-		$_GET['substep'] = $substep;
2372
+	if ($_GET['substep'] < $substep) {
2373
+			$_GET['substep'] = $substep;
2374
+	}
2242 2375
 
2243 2376
 	if ($command_line)
2244 2377
 	{
@@ -2251,29 +2384,33 @@  discard block
 block discarded – undo
2251 2384
 	}
2252 2385
 
2253 2386
 	@set_time_limit(300);
2254
-	if (function_exists('apache_reset_timeout'))
2255
-		@apache_reset_timeout();
2387
+	if (function_exists('apache_reset_timeout')) {
2388
+			@apache_reset_timeout();
2389
+	}
2256 2390
 
2257
-	if (time() - $start_time <= $timeLimitThreshold)
2258
-		return;
2391
+	if (time() - $start_time <= $timeLimitThreshold) {
2392
+			return;
2393
+	}
2259 2394
 
2260 2395
 	// Do we have some custom step progress stuff?
2261 2396
 	if (!empty($step_progress))
2262 2397
 	{
2263 2398
 		$upcontext['substep_progress'] = 0;
2264 2399
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2265
-		if ($step_progress['current'] > $step_progress['total'])
2266
-			$upcontext['substep_progress'] = 99.9;
2267
-		else
2268
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2400
+		if ($step_progress['current'] > $step_progress['total']) {
2401
+					$upcontext['substep_progress'] = 99.9;
2402
+		} else {
2403
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2404
+		}
2269 2405
 
2270 2406
 		// Make it nicely rounded.
2271 2407
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2272 2408
 	}
2273 2409
 
2274 2410
 	// If this is XML we just exit right away!
2275
-	if (isset($_GET['xml']))
2276
-		return upgradeExit();
2411
+	if (isset($_GET['xml'])) {
2412
+			return upgradeExit();
2413
+	}
2277 2414
 
2278 2415
 	// We're going to pause after this!
2279 2416
 	$upcontext['pause'] = true;
@@ -2281,13 +2418,15 @@  discard block
 block discarded – undo
2281 2418
 	$upcontext['query_string'] = '';
2282 2419
 	foreach ($_GET as $k => $v)
2283 2420
 	{
2284
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2285
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2421
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2422
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2423
+		}
2286 2424
 	}
2287 2425
 
2288 2426
 	// Custom warning?
2289
-	if (!empty($custom_warning))
2290
-		$upcontext['custom_warning'] = $custom_warning;
2427
+	if (!empty($custom_warning)) {
2428
+			$upcontext['custom_warning'] = $custom_warning;
2429
+	}
2291 2430
 
2292 2431
 	upgradeExit();
2293 2432
 }
@@ -2302,25 +2441,26 @@  discard block
 block discarded – undo
2302 2441
 	ob_implicit_flush(true);
2303 2442
 	@set_time_limit(600);
2304 2443
 
2305
-	if (!isset($_SERVER['argv']))
2306
-		$_SERVER['argv'] = array();
2444
+	if (!isset($_SERVER['argv'])) {
2445
+			$_SERVER['argv'] = array();
2446
+	}
2307 2447
 	$_GET['maint'] = 1;
2308 2448
 
2309 2449
 	foreach ($_SERVER['argv'] as $i => $arg)
2310 2450
 	{
2311
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2312
-			$_GET['lang'] = $match[1];
2313
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2314
-			continue;
2315
-		elseif ($arg == '--no-maintenance')
2316
-			$_GET['maint'] = 0;
2317
-		elseif ($arg == '--debug')
2318
-			$is_debug = true;
2319
-		elseif ($arg == '--backup')
2320
-			$_POST['backup'] = 1;
2321
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2322
-			$_GET['conv'] = 1;
2323
-		elseif ($i != 0)
2451
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2452
+					$_GET['lang'] = $match[1];
2453
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2454
+					continue;
2455
+		} elseif ($arg == '--no-maintenance') {
2456
+					$_GET['maint'] = 0;
2457
+		} elseif ($arg == '--debug') {
2458
+					$is_debug = true;
2459
+		} elseif ($arg == '--backup') {
2460
+					$_POST['backup'] = 1;
2461
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2462
+					$_GET['conv'] = 1;
2463
+		} elseif ($i != 0)
2324 2464
 		{
2325 2465
 			echo 'SMF Command-line Upgrader
2326 2466
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2334,10 +2474,12 @@  discard block
 block discarded – undo
2334 2474
 		}
2335 2475
 	}
2336 2476
 
2337
-	if (!php_version_check())
2338
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2339
-	if (!db_version_check())
2340
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2477
+	if (!php_version_check()) {
2478
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2479
+	}
2480
+	if (!db_version_check()) {
2481
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2482
+	}
2341 2483
 
2342 2484
 	// Do some checks to make sure they have proper privileges
2343 2485
 	db_extend('packages');
@@ -2352,34 +2494,39 @@  discard block
 block discarded – undo
2352 2494
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2353 2495
 
2354 2496
 	// Sorry... we need CREATE, ALTER and DROP
2355
-	if (!$create || !$alter || !$drop)
2356
-		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);
2497
+	if (!$create || !$alter || !$drop) {
2498
+			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);
2499
+	}
2357 2500
 
2358 2501
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2359 2502
 		&& @file_exists($sourcedir . '/QueryString.php')
2360 2503
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2361
-	if (!$check && !isset($modSettings['smfVersion']))
2362
-		print_error('Error: Some files are missing or out-of-date.', true);
2504
+	if (!$check && !isset($modSettings['smfVersion'])) {
2505
+			print_error('Error: Some files are missing or out-of-date.', true);
2506
+	}
2363 2507
 
2364 2508
 	// Do a quick version spot check.
2365 2509
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2366 2510
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2367
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2368
-		print_error('Error: Some files have not yet been updated properly.');
2511
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2512
+			print_error('Error: Some files have not yet been updated properly.');
2513
+	}
2369 2514
 
2370 2515
 	// Make sure Settings.php is writable.
2371 2516
 		quickFileWritable($boarddir . '/Settings.php');
2372
-	if (!is_writable($boarddir . '/Settings.php'))
2373
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2517
+	if (!is_writable($boarddir . '/Settings.php')) {
2518
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2519
+	}
2374 2520
 
2375 2521
 	// Make sure Settings_bak.php is writable.
2376 2522
 		quickFileWritable($boarddir . '/Settings_bak.php');
2377
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2378
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2523
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2524
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2525
+	}
2379 2526
 
2380
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2381
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2382
-	elseif (isset($modSettings['agreement']))
2527
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2528
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2529
+	} elseif (isset($modSettings['agreement']))
2383 2530
 	{
2384 2531
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2385 2532
 		fwrite($fp, $modSettings['agreement']);
@@ -2389,31 +2536,36 @@  discard block
 block discarded – undo
2389 2536
 	// Make sure Themes is writable.
2390 2537
 	quickFileWritable($modSettings['theme_dir']);
2391 2538
 
2392
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2393
-		print_error('Error: Unable to obtain write access to "Themes".');
2539
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2540
+			print_error('Error: Unable to obtain write access to "Themes".');
2541
+	}
2394 2542
 
2395 2543
 	// Make sure cache directory exists and is writable!
2396 2544
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2397
-	if (!file_exists($cachedir_temp))
2398
-		@mkdir($cachedir_temp);
2545
+	if (!file_exists($cachedir_temp)) {
2546
+			@mkdir($cachedir_temp);
2547
+	}
2399 2548
 
2400 2549
 	// Make sure the cache temp dir is writable.
2401 2550
 	quickFileWritable($cachedir_temp);
2402 2551
 
2403
-	if (!is_writable($cachedir_temp))
2404
-		print_error('Error: Unable to obtain write access to "cache".', true);
2552
+	if (!is_writable($cachedir_temp)) {
2553
+			print_error('Error: Unable to obtain write access to "cache".', true);
2554
+	}
2405 2555
 
2406
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2407
-		print_error('Error: Unable to find language files!', true);
2408
-	else
2556
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2557
+			print_error('Error: Unable to find language files!', true);
2558
+	} else
2409 2559
 	{
2410 2560
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2411 2561
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2412 2562
 
2413
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2414
-			print_error('Error: Language files out of date.', true);
2415
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2416
-			print_error('Error: Install language is missing for selected language.', true);
2563
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2564
+					print_error('Error: Language files out of date.', true);
2565
+		}
2566
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2567
+					print_error('Error: Install language is missing for selected language.', true);
2568
+		}
2417 2569
 
2418 2570
 		// Otherwise include it!
2419 2571
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2432,8 +2584,9 @@  discard block
 block discarded – undo
2432 2584
 	global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js;
2433 2585
 
2434 2586
 	// Done it already?
2435
-	if (!empty($_POST['utf8_done']))
2436
-		return true;
2587
+	if (!empty($_POST['utf8_done'])) {
2588
+			return true;
2589
+	}
2437 2590
 
2438 2591
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2439 2592
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2446,8 +2599,7 @@  discard block
 block discarded – undo
2446 2599
 		);
2447 2600
 
2448 2601
 		return true;
2449
-	}
2450
-	else
2602
+	} else
2451 2603
 	{
2452 2604
 		$upcontext['page_title'] = 'Converting to UTF8';
2453 2605
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2491,8 +2643,9 @@  discard block
 block discarded – undo
2491 2643
 			)
2492 2644
 		);
2493 2645
 		$db_charsets = array();
2494
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2495
-			$db_charsets[] = $row['Charset'];
2646
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2647
+					$db_charsets[] = $row['Charset'];
2648
+		}
2496 2649
 
2497 2650
 		$smcFunc['db_free_result']($request);
2498 2651
 
@@ -2528,13 +2681,15 @@  discard block
 block discarded – undo
2528 2681
 		// If there's a fulltext index, we need to drop it first...
2529 2682
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2530 2683
 		{
2531
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2532
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2684
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2685
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2533 2686
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2687
+			}
2534 2688
 			$smcFunc['db_free_result']($request);
2535 2689
 
2536
-			if (isset($upcontext['fulltext_index']))
2537
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2690
+			if (isset($upcontext['fulltext_index'])) {
2691
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2692
+			}
2538 2693
 		}
2539 2694
 
2540 2695
 		// Drop it and make a note...
@@ -2724,8 +2879,9 @@  discard block
 block discarded – undo
2724 2879
 			$replace = '%field%';
2725 2880
 
2726 2881
 			// Build a huge REPLACE statement...
2727
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2728
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2882
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2883
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2884
+			}
2729 2885
 		}
2730 2886
 
2731 2887
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2735,9 +2891,10 @@  discard block
 block discarded – undo
2735 2891
 		$upcontext['table_count'] = count($queryTables);
2736 2892
 	
2737 2893
 		// What ones have we already done?
2738
-		foreach ($queryTables as $id => $table)
2739
-			if ($id < $_GET['substep'])
2894
+		foreach ($queryTables as $id => $table) {
2895
+					if ($id < $_GET['substep'])
2740 2896
 				$upcontext['previous_tables'][] = $table;
2897
+		}
2741 2898
 
2742 2899
 		$upcontext['cur_table_num'] = $_GET['substep'];
2743 2900
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2774,8 +2931,9 @@  discard block
 block discarded – undo
2774 2931
 			nextSubstep($substep);
2775 2932
 
2776 2933
 			// Just to make sure it doesn't time out.
2777
-			if (function_exists('apache_reset_timeout'))
2778
-				@apache_reset_timeout();
2934
+			if (function_exists('apache_reset_timeout')) {
2935
+							@apache_reset_timeout();
2936
+			}
2779 2937
 
2780 2938
 			$table_charsets = array();
2781 2939
 
@@ -2796,8 +2954,9 @@  discard block
 block discarded – undo
2796 2954
 					{
2797 2955
 						list($charset) = explode('_', $collation);
2798 2956
 
2799
-						if (!isset($table_charsets[$charset]))
2800
-							$table_charsets[$charset] = array();
2957
+						if (!isset($table_charsets[$charset])) {
2958
+													$table_charsets[$charset] = array();
2959
+						}
2801 2960
 
2802 2961
 						$table_charsets[$charset][] = $column_info;
2803 2962
 					}
@@ -2837,10 +2996,11 @@  discard block
 block discarded – undo
2837 2996
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2838 2997
 				{
2839 2998
 					$update = '';
2840
-					foreach ($table_charsets as $charset => $columns)
2841
-						foreach ($columns as $column)
2999
+					foreach ($table_charsets as $charset => $columns) {
3000
+											foreach ($columns as $column)
2842 3001
 							$update .= '
2843 3002
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3003
+					}
2844 3004
 
2845 3005
 					$smcFunc['db_query']('', '
2846 3006
 						UPDATE {raw:table_name}
@@ -2865,8 +3025,9 @@  discard block
 block discarded – undo
2865 3025
 			// Now do the actual conversion (if still needed).
2866 3026
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2867 3027
 			{
2868
-				if ($command_line)
2869
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3028
+				if ($command_line) {
3029
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3030
+				}
2870 3031
 
2871 3032
 				$smcFunc['db_query']('', '
2872 3033
 					ALTER TABLE {raw:table_name}
@@ -2876,12 +3037,14 @@  discard block
 block discarded – undo
2876 3037
 					)
2877 3038
 				);
2878 3039
 
2879
-				if ($command_line)
2880
-					echo " done.\n";
3040
+				if ($command_line) {
3041
+									echo " done.\n";
3042
+				}
2881 3043
 			}
2882 3044
 			// If this is XML to keep it nice for the user do one table at a time anyway!
2883
-			if (isset($_GET['xml']))
2884
-				return upgradeExit();
3045
+			if (isset($_GET['xml'])) {
3046
+							return upgradeExit();
3047
+			}
2885 3048
 		}
2886 3049
 
2887 3050
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -2910,8 +3073,8 @@  discard block
 block discarded – undo
2910 3073
 		);
2911 3074
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2912 3075
 		{
2913
-			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)
2914
-				$smcFunc['db_query']('', '
3076
+			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) {
3077
+							$smcFunc['db_query']('', '
2915 3078
 					UPDATE {db_prefix}log_actions
2916 3079
 					SET extra = {string:extra}
2917 3080
 					WHERE id_action = {int:current_action}',
@@ -2920,6 +3083,7 @@  discard block
 block discarded – undo
2920 3083
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2921 3084
 					)
2922 3085
 				);
3086
+			}
2923 3087
 		}
2924 3088
 		$smcFunc['db_free_result']($request);
2925 3089
 
@@ -2941,15 +3105,17 @@  discard block
 block discarded – undo
2941 3105
 	// First thing's first - did we already do this?
2942 3106
 	if (!empty($modSettings['json_done']))
2943 3107
 	{
2944
-		if ($command_line)
2945
-			return DeleteUpgrade();
2946
-		else
2947
-			return true;
3108
+		if ($command_line) {
3109
+					return DeleteUpgrade();
3110
+		} else {
3111
+					return true;
3112
+		}
2948 3113
 	}
2949 3114
 
2950 3115
 	// Done it already - js wise?
2951
-	if (!empty($_POST['json_done']))
2952
-		return true;
3116
+	if (!empty($_POST['json_done'])) {
3117
+			return true;
3118
+	}
2953 3119
 
2954 3120
 	// List of tables affected by this function
2955 3121
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2981,12 +3147,14 @@  discard block
 block discarded – undo
2981 3147
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
2982 3148
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2983 3149
 
2984
-	foreach ($keys as $id => $table)
2985
-		if ($id < $_GET['substep'])
3150
+	foreach ($keys as $id => $table) {
3151
+			if ($id < $_GET['substep'])
2986 3152
 			$upcontext['previous_tables'][] = $table;
3153
+	}
2987 3154
 
2988
-	if ($command_line)
2989
-		echo 'Converting data from serialize() to json_encode().';
3155
+	if ($command_line) {
3156
+			echo 'Converting data from serialize() to json_encode().';
3157
+	}
2990 3158
 
2991 3159
 	if (!$support_js || isset($_GET['xml']))
2992 3160
 	{
@@ -3026,8 +3194,9 @@  discard block
 block discarded – undo
3026 3194
 
3027 3195
 				// Loop through and fix these...
3028 3196
 				$new_settings = array();
3029
-				if ($command_line)
3030
-					echo "\n" . 'Fixing some settings...';
3197
+				if ($command_line) {
3198
+									echo "\n" . 'Fixing some settings...';
3199
+				}
3031 3200
 
3032 3201
 				foreach ($serialized_settings as $var)
3033 3202
 				{
@@ -3035,22 +3204,24 @@  discard block
 block discarded – undo
3035 3204
 					{
3036 3205
 						// Attempt to unserialize the setting
3037 3206
 						$temp = @safe_unserialize($modSettings[$var]);
3038
-						if (!$temp && $command_line)
3039
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3040
-						elseif ($temp !== false)
3041
-							$new_settings[$var] = json_encode($temp);
3207
+						if (!$temp && $command_line) {
3208
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3209
+						} elseif ($temp !== false) {
3210
+													$new_settings[$var] = json_encode($temp);
3211
+						}
3042 3212
 					}
3043 3213
 				}
3044 3214
 
3045 3215
 				// Update everything at once
3046
-				if (!function_exists('cache_put_data'))
3047
-					require_once($sourcedir . '/Load.php');
3216
+				if (!function_exists('cache_put_data')) {
3217
+									require_once($sourcedir . '/Load.php');
3218
+				}
3048 3219
 				updateSettings($new_settings, true);
3049 3220
 
3050
-				if ($command_line)
3051
-					echo ' done.';
3052
-			}
3053
-			elseif ($table == 'themes')
3221
+				if ($command_line) {
3222
+									echo ' done.';
3223
+				}
3224
+			} elseif ($table == 'themes')
3054 3225
 			{
3055 3226
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3056 3227
 				$query = $smcFunc['db_query']('', '
@@ -3069,10 +3240,11 @@  discard block
 block discarded – undo
3069 3240
 
3070 3241
 						if ($command_line)
3071 3242
 						{
3072
-							if ($temp === false)
3073
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3074
-							else
3075
-								echo "\n" . 'Fixing admin preferences...';
3243
+							if ($temp === false) {
3244
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3245
+							} else {
3246
+															echo "\n" . 'Fixing admin preferences...';
3247
+							}
3076 3248
 						}
3077 3249
 
3078 3250
 						if ($temp !== false)
@@ -3094,15 +3266,15 @@  discard block
 block discarded – undo
3094 3266
 								)
3095 3267
 							);
3096 3268
 
3097
-							if ($command_line)
3098
-								echo ' done.';
3269
+							if ($command_line) {
3270
+															echo ' done.';
3271
+							}
3099 3272
 						}
3100 3273
 					}
3101 3274
 
3102 3275
 					$smcFunc['db_free_result']($query);
3103 3276
 				}
3104
-			}
3105
-			else
3277
+			} else
3106 3278
 			{
3107 3279
 				// First item is always the key...
3108 3280
 				$key = $info[0];
@@ -3113,8 +3285,7 @@  discard block
 block discarded – undo
3113 3285
 				{
3114 3286
 					$col_select = $info[1];
3115 3287
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3116
-				}
3117
-				else
3288
+				} else
3118 3289
 				{
3119 3290
 					$col_select = implode(', ', $info);
3120 3291
 				}
@@ -3147,8 +3318,7 @@  discard block
 block discarded – undo
3147 3318
 								if ($temp === false && $command_line)
3148 3319
 								{
3149 3320
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3150
-								}
3151
-								else
3321
+								} else
3152 3322
 								{
3153 3323
 									$row[$col] = json_encode($temp);
3154 3324
 
@@ -3173,16 +3343,18 @@  discard block
 block discarded – undo
3173 3343
 						}
3174 3344
 					}
3175 3345
 
3176
-					if ($command_line)
3177
-						echo ' done.';
3346
+					if ($command_line) {
3347
+											echo ' done.';
3348
+					}
3178 3349
 
3179 3350
 					// Free up some memory...
3180 3351
 					$smcFunc['db_free_result']($query);
3181 3352
 				}
3182 3353
 			}
3183 3354
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3184
-			if (isset($_GET['xml']))
3185
-				return upgradeExit();
3355
+			if (isset($_GET['xml'])) {
3356
+							return upgradeExit();
3357
+			}
3186 3358
 		}
3187 3359
 
3188 3360
 		if ($command_line)
@@ -3197,8 +3369,9 @@  discard block
 block discarded – undo
3197 3369
 
3198 3370
 		$_GET['substep'] = 0;
3199 3371
 		// Make sure we move on!
3200
-		if ($command_line)
3201
-			return DeleteUpgrade();
3372
+		if ($command_line) {
3373
+					return DeleteUpgrade();
3374
+		}
3202 3375
 
3203 3376
 		return true;
3204 3377
 	}
@@ -3218,14 +3391,16 @@  discard block
 block discarded – undo
3218 3391
 	global $upcontext, $txt, $settings;
3219 3392
 
3220 3393
 	// Don't call me twice!
3221
-	if (!empty($upcontext['chmod_called']))
3222
-		return;
3394
+	if (!empty($upcontext['chmod_called'])) {
3395
+			return;
3396
+	}
3223 3397
 
3224 3398
 	$upcontext['chmod_called'] = true;
3225 3399
 
3226 3400
 	// Nothing?
3227
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3228
-		return;
3401
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3402
+			return;
3403
+	}
3229 3404
 
3230 3405
 	// Was it a problem with Windows?
3231 3406
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3257,11 +3432,12 @@  discard block
 block discarded – undo
3257 3432
 					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\');
3258 3433
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3259 3434
 
3260
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3261
-		echo '
3435
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3436
+			echo '
3262 3437
 					content.write(\'<hr>\n\t\t\t\');
3263 3438
 					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\');
3264 3439
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3440
+	}
3265 3441
 
3266 3442
 	echo '
3267 3443
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3269,17 +3445,19 @@  discard block
 block discarded – undo
3269 3445
 				}
3270 3446
 			</script>';
3271 3447
 
3272
-	if (!empty($upcontext['chmod']['ftp_error']))
3273
-		echo '
3448
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3449
+			echo '
3274 3450
 			<div class="error_message red">
3275 3451
 				The following error was encountered when trying to connect:<br><br>
3276 3452
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3277 3453
 			</div>
3278 3454
 			<br>';
3455
+	}
3279 3456
 
3280
-	if (empty($upcontext['chmod_in_form']))
3281
-		echo '
3457
+	if (empty($upcontext['chmod_in_form'])) {
3458
+			echo '
3282 3459
 	<form action="', $upcontext['form_url'], '" method="post">';
3460
+	}
3283 3461
 
3284 3462
 	echo '
3285 3463
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3314,10 +3492,11 @@  discard block
 block discarded – undo
3314 3492
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
3315 3493
 	</div>';
3316 3494
 
3317
-	if (empty($upcontext['chmod_in_form']))
3318
-		echo '
3495
+	if (empty($upcontext['chmod_in_form'])) {
3496
+			echo '
3319 3497
 	</form>';
3320
-}
3498
+	}
3499
+	}
3321 3500
 
3322 3501
 function template_upgrade_above()
3323 3502
 {
@@ -3377,9 +3556,10 @@  discard block
 block discarded – undo
3377 3556
 				<h2>', $txt['upgrade_progress'], '</h2>
3378 3557
 				<ul>';
3379 3558
 
3380
-	foreach ($upcontext['steps'] as $num => $step)
3381
-		echo '
3559
+	foreach ($upcontext['steps'] as $num => $step) {
3560
+			echo '
3382 3561
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3562
+	}
3383 3563
 
3384 3564
 	echo '
3385 3565
 					</ul>
@@ -3392,8 +3572,8 @@  discard block
 block discarded – undo
3392 3572
 				</div>
3393 3573
 			</div>';
3394 3574
 
3395
-	if (isset($upcontext['step_progress']))
3396
-		echo '
3575
+	if (isset($upcontext['step_progress'])) {
3576
+			echo '
3397 3577
 				<br>
3398 3578
 				<br>
3399 3579
 				<div id="progress_bar_step">
@@ -3402,6 +3582,7 @@  discard block
 block discarded – undo
3402 3582
 						<span>', $txt['upgrade_step_progress'], '</span>
3403 3583
 					</div>
3404 3584
 				</div>';
3585
+	}
3405 3586
 
3406 3587
 	echo '
3407 3588
 				<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>
@@ -3432,32 +3613,36 @@  discard block
 block discarded – undo
3432 3613
 {
3433 3614
 	global $upcontext, $txt;
3434 3615
 
3435
-	if (!empty($upcontext['pause']))
3436
-		echo '
3616
+	if (!empty($upcontext['pause'])) {
3617
+			echo '
3437 3618
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3438 3619
 
3439 3620
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3440 3621
 								<h3>
3441 3622
 									', $txt['upgrade_paused_overload'], '
3442 3623
 								</h3>';
3624
+	}
3443 3625
 
3444
-	if (!empty($upcontext['custom_warning']))
3445
-		echo '
3626
+	if (!empty($upcontext['custom_warning'])) {
3627
+			echo '
3446 3628
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3447 3629
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3448 3630
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3449 3631
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3450 3632
 								</div>';
3633
+	}
3451 3634
 
3452 3635
 	echo '
3453 3636
 								<div class="righttext" style="margin: 1ex;">';
3454 3637
 
3455
-	if (!empty($upcontext['continue']))
3456
-		echo '
3638
+	if (!empty($upcontext['continue'])) {
3639
+			echo '
3457 3640
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
3458
-	if (!empty($upcontext['skip']))
3459
-		echo '
3641
+	}
3642
+	if (!empty($upcontext['skip'])) {
3643
+			echo '
3460 3644
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
3645
+	}
3461 3646
 
3462 3647
 	echo '
3463 3648
 								</div>
@@ -3507,11 +3692,12 @@  discard block
 block discarded – undo
3507 3692
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3508 3693
 	<smf>';
3509 3694
 
3510
-	if (!empty($upcontext['get_data']))
3511
-		foreach ($upcontext['get_data'] as $k => $v)
3695
+	if (!empty($upcontext['get_data'])) {
3696
+			foreach ($upcontext['get_data'] as $k => $v)
3512 3697
 			echo '
3513 3698
 		<get key="', $k, '">', $v, '</get>';
3514
-}
3699
+	}
3700
+	}
3515 3701
 
3516 3702
 function template_xml_below()
3517 3703
 {
@@ -3552,8 +3738,8 @@  discard block
 block discarded – undo
3552 3738
 	template_chmod();
3553 3739
 
3554 3740
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3555
-	if ($upcontext['is_large_forum'])
3556
-		echo '
3741
+	if ($upcontext['is_large_forum']) {
3742
+			echo '
3557 3743
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3558 3744
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3559 3745
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3561,10 +3747,11 @@  discard block
 block discarded – undo
3561 3747
 				', $txt['upgrade_warning_lots_data'], '
3562 3748
 			</div>
3563 3749
 		</div>';
3750
+	}
3564 3751
 
3565 3752
 	// A warning message?
3566
-	if (!empty($upcontext['warning']))
3567
-		echo '
3753
+	if (!empty($upcontext['warning'])) {
3754
+			echo '
3568 3755
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3569 3756
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3570 3757
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3572,6 +3759,7 @@  discard block
 block discarded – undo
3572 3759
 				', $upcontext['warning'], '
3573 3760
 			</div>
3574 3761
 		</div>';
3762
+	}
3575 3763
 
3576 3764
 	// Paths are incorrect?
3577 3765
 	echo '
@@ -3587,20 +3775,22 @@  discard block
 block discarded – undo
3587 3775
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3588 3776
 	{
3589 3777
 		$ago = time() - $upcontext['started'];
3590
-		if ($ago < 60)
3591
-			$ago = $ago . ' seconds';
3592
-		elseif ($ago < 3600)
3593
-			$ago = (int) ($ago / 60) . ' minutes';
3594
-		else
3595
-			$ago = (int) ($ago / 3600) . ' hours';
3778
+		if ($ago < 60) {
3779
+					$ago = $ago . ' seconds';
3780
+		} elseif ($ago < 3600) {
3781
+					$ago = (int) ($ago / 60) . ' minutes';
3782
+		} else {
3783
+					$ago = (int) ($ago / 3600) . ' hours';
3784
+		}
3596 3785
 
3597 3786
 		$active = time() - $upcontext['updated'];
3598
-		if ($active < 60)
3599
-			$updated = $active . ' seconds';
3600
-		elseif ($active < 3600)
3601
-			$updated = (int) ($active / 60) . ' minutes';
3602
-		else
3603
-			$updated = (int) ($active / 3600) . ' hours';
3787
+		if ($active < 60) {
3788
+					$updated = $active . ' seconds';
3789
+		} elseif ($active < 3600) {
3790
+					$updated = (int) ($active / 60) . ' minutes';
3791
+		} else {
3792
+					$updated = (int) ($active / 3600) . ' hours';
3793
+		}
3604 3794
 
3605 3795
 		echo '
3606 3796
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3609,16 +3799,18 @@  discard block
 block discarded – undo
3609 3799
 			<div style="padding-left: 6ex;">
3610 3800
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3611 3801
 
3612
-		if ($active < 600)
3613
-			echo '
3802
+		if ($active < 600) {
3803
+					echo '
3614 3804
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3805
+		}
3615 3806
 
3616
-		if ($active > $upcontext['inactive_timeout'])
3617
-			echo '
3807
+		if ($active > $upcontext['inactive_timeout']) {
3808
+					echo '
3618 3809
 				<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.';
3619
-		else
3620
-			echo '
3810
+		} else {
3811
+					echo '
3621 3812
 				<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!');
3813
+		}
3622 3814
 
3623 3815
 		echo '
3624 3816
 			</div>
@@ -3634,9 +3826,10 @@  discard block
 block discarded – undo
3634 3826
 					<td>
3635 3827
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
3636 3828
 
3637
-	if (!empty($upcontext['username_incorrect']))
3638
-		echo '
3829
+	if (!empty($upcontext['username_incorrect'])) {
3830
+			echo '
3639 3831
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3832
+	}
3640 3833
 
3641 3834
 	echo '
3642 3835
 					</td>
@@ -3647,9 +3840,10 @@  discard block
 block discarded – undo
3647 3840
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
3648 3841
 						<input type="hidden" name="hash_passwrd" value="">';
3649 3842
 
3650
-	if (!empty($upcontext['password_failed']))
3651
-		echo '
3843
+	if (!empty($upcontext['password_failed'])) {
3844
+			echo '
3652 3845
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3846
+	}
3653 3847
 
3654 3848
 	echo '
3655 3849
 					</td>
@@ -3720,8 +3914,8 @@  discard block
 block discarded – undo
3720 3914
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3721 3915
 
3722 3916
 	// Warning message?
3723
-	if (!empty($upcontext['upgrade_options_warning']))
3724
-		echo '
3917
+	if (!empty($upcontext['upgrade_options_warning'])) {
3918
+			echo '
3725 3919
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3726 3920
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3727 3921
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3729,6 +3923,7 @@  discard block
 block discarded – undo
3729 3923
 				', $upcontext['upgrade_options_warning'], '
3730 3924
 			</div>
3731 3925
 		</div>';
3926
+	}
3732 3927
 
3733 3928
 	echo '
3734 3929
 				<table>
@@ -3771,8 +3966,8 @@  discard block
 block discarded – undo
3771 3966
 						</td>
3772 3967
 					</tr>';
3773 3968
 
3774
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3775
-		echo '
3969
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3970
+			echo '
3776 3971
 					<tr valign="top">
3777 3972
 						<td width="2%">
3778 3973
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -3781,6 +3976,7 @@  discard block
 block discarded – undo
3781 3976
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3782 3977
 						</td>
3783 3978
 					</tr>';
3979
+	}
3784 3980
 
3785 3981
 	echo '
3786 3982
 					<tr valign="top">
@@ -3818,10 +4014,11 @@  discard block
 block discarded – undo
3818 4014
 			</div>';
3819 4015
 
3820 4016
 	// Dont any tables so far?
3821
-	if (!empty($upcontext['previous_tables']))
3822
-		foreach ($upcontext['previous_tables'] as $table)
4017
+	if (!empty($upcontext['previous_tables'])) {
4018
+			foreach ($upcontext['previous_tables'] as $table)
3823 4019
 			echo '
3824 4020
 			<br>Completed Table: &quot;', $table, '&quot;.';
4021
+	}
3825 4022
 
3826 4023
 	echo '
3827 4024
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3858,12 +4055,13 @@  discard block
 block discarded – undo
3858 4055
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3859 4056
 
3860 4057
 		// If debug flood the screen.
3861
-		if ($is_debug)
3862
-			echo '
4058
+		if ($is_debug) {
4059
+					echo '
3863 4060
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3864 4061
 
3865 4062
 				if (document.getElementById(\'debug_section\').scrollHeight)
3866 4063
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4064
+		}
3867 4065
 
3868 4066
 		echo '
3869 4067
 				// Get the next update...
@@ -3896,8 +4094,9 @@  discard block
 block discarded – undo
3896 4094
 {
3897 4095
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3898 4096
 
3899
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3900
-		$is_debug = true;
4097
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4098
+			$is_debug = true;
4099
+	}
3901 4100
 
3902 4101
 	echo '
3903 4102
 		<h3>Executing database changes</h3>
@@ -3912,8 +4111,9 @@  discard block
 block discarded – undo
3912 4111
 	{
3913 4112
 		foreach ($upcontext['actioned_items'] as $num => $item)
3914 4113
 		{
3915
-			if ($num != 0)
3916
-				echo ' Successful!';
4114
+			if ($num != 0) {
4115
+							echo ' Successful!';
4116
+			}
3917 4117
 			echo '<br>' . $item;
3918 4118
 		}
3919 4119
 		if (!empty($upcontext['changes_complete']))
@@ -3926,28 +4126,32 @@  discard block
 block discarded – undo
3926 4126
 				$seconds = intval($active % 60);
3927 4127
 
3928 4128
 				$totalTime = '';
3929
-				if ($hours > 0)
3930
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3931
-				if ($minutes > 0)
3932
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3933
-				if ($seconds > 0)
3934
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4129
+				if ($hours > 0) {
4130
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4131
+				}
4132
+				if ($minutes > 0) {
4133
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4134
+				}
4135
+				if ($seconds > 0) {
4136
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4137
+				}
3935 4138
 			}
3936 4139
 
3937
-			if ($is_debug && !empty($totalTime))
3938
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3939
-			else
3940
-				echo ' Successful!<br><br>';
4140
+			if ($is_debug && !empty($totalTime)) {
4141
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4142
+			} else {
4143
+							echo ' Successful!<br><br>';
4144
+			}
3941 4145
 
3942 4146
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3943 4147
 		}
3944
-	}
3945
-	else
4148
+	} else
3946 4149
 	{
3947 4150
 		// Tell them how many files we have in total.
3948
-		if ($upcontext['file_count'] > 1)
3949
-			echo '
4151
+		if ($upcontext['file_count'] > 1) {
4152
+					echo '
3950 4153
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4154
+		}
3951 4155
 
3952 4156
 		echo '
3953 4157
 		<h3 id="info2"><strong>Executing:</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<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>
@@ -3963,19 +4167,23 @@  discard block
 block discarded – undo
3963 4167
 				$seconds = intval($active % 60);
3964 4168
 
3965 4169
 				$totalTime = '';
3966
-				if ($hours > 0)
3967
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3968
-				if ($minutes > 0)
3969
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3970
-				if ($seconds > 0)
3971
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4170
+				if ($hours > 0) {
4171
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4172
+				}
4173
+				if ($minutes > 0) {
4174
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4175
+				}
4176
+				if ($seconds > 0) {
4177
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4178
+				}
3972 4179
 			}
3973 4180
 
3974 4181
 			echo '
3975 4182
 			<br><span id="upgradeCompleted">';
3976 4183
 
3977
-			if (!empty($totalTime))
3978
-				echo 'Completed in ', $totalTime, '<br>';
4184
+			if (!empty($totalTime)) {
4185
+							echo 'Completed in ', $totalTime, '<br>';
4186
+			}
3979 4187
 
3980 4188
 			echo '</span>
3981 4189
 			<div id="debug_section" style="height: 117px; overflow: auto;">
@@ -4012,9 +4220,10 @@  discard block
 block discarded – undo
4012 4220
 			var getData = "";
4013 4221
 			var debugItems = ', $upcontext['debug_items'], ';';
4014 4222
 
4015
-		if ($is_debug)
4016
-			echo '
4223
+		if ($is_debug) {
4224
+					echo '
4017 4225
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4226
+		}
4018 4227
 
4019 4228
 		echo '
4020 4229
 			function getNextItem()
@@ -4054,9 +4263,10 @@  discard block
 block discarded – undo
4054 4263
 						document.getElementById("error_block").style.display = "";
4055 4264
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4056 4265
 
4057
-	if ($is_debug)
4058
-		echo '
4266
+	if ($is_debug) {
4267
+			echo '
4059 4268
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4269
+	}
4060 4270
 
4061 4271
 	echo '
4062 4272
 					}
@@ -4077,9 +4287,10 @@  discard block
 block discarded – undo
4077 4287
 						document.getElementById("error_block").style.display = "";
4078 4288
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4079 4289
 
4080
-	if ($is_debug)
4081
-		echo '
4290
+	if ($is_debug) {
4291
+			echo '
4082 4292
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4293
+	}
4083 4294
 
4084 4295
 	echo '
4085 4296
 					}
@@ -4138,8 +4349,8 @@  discard block
 block discarded – undo
4138 4349
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4139 4350
 				{';
4140 4351
 
4141
-		if ($is_debug)
4142
-			echo '
4352
+		if ($is_debug) {
4353
+					echo '
4143 4354
 					document.getElementById(\'debug_section\').style.display = "none";
4144 4355
 
4145 4356
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4157,6 +4368,7 @@  discard block
 block discarded – undo
4157 4368
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4158 4369
 
4159 4370
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4371
+		}
4160 4372
 
4161 4373
 		echo '
4162 4374
 
@@ -4164,9 +4376,10 @@  discard block
 block discarded – undo
4164 4376
 					document.getElementById(\'contbutt\').disabled = 0;
4165 4377
 					document.getElementById(\'database_done\').value = 1;';
4166 4378
 
4167
-		if ($upcontext['file_count'] > 1)
4168
-			echo '
4379
+		if ($upcontext['file_count'] > 1) {
4380
+					echo '
4169 4381
 					document.getElementById(\'info1\').style.display = "none";';
4382
+		}
4170 4383
 
4171 4384
 		echo '
4172 4385
 					document.getElementById(\'info2\').style.display = "none";
@@ -4179,9 +4392,10 @@  discard block
 block discarded – undo
4179 4392
 					lastItem = 0;
4180 4393
 					prevFile = curFile;';
4181 4394
 
4182
-		if ($is_debug)
4183
-			echo '
4395
+		if ($is_debug) {
4396
+					echo '
4184 4397
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4398
+		}
4185 4399
 
4186 4400
 		echo '
4187 4401
 					getNextItem();
@@ -4189,8 +4403,8 @@  discard block
 block discarded – undo
4189 4403
 				}';
4190 4404
 
4191 4405
 		// If debug scroll the screen.
4192
-		if ($is_debug)
4193
-			echo '
4406
+		if ($is_debug) {
4407
+					echo '
4194 4408
 				if (iLastSubStepProgress == -1)
4195 4409
 				{
4196 4410
 					// Give it consistent dots.
@@ -4209,6 +4423,7 @@  discard block
 block discarded – undo
4209 4423
 
4210 4424
 				if (document.getElementById(\'debug_section\').scrollHeight)
4211 4425
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4426
+		}
4212 4427
 
4213 4428
 		echo '
4214 4429
 				// Update the page.
@@ -4269,9 +4484,10 @@  discard block
 block discarded – undo
4269 4484
 			}';
4270 4485
 
4271 4486
 		// Start things off assuming we've not errored.
4272
-		if (empty($upcontext['error_message']))
4273
-			echo '
4487
+		if (empty($upcontext['error_message'])) {
4488
+					echo '
4274 4489
 			getNextItem();';
4490
+		}
4275 4491
 
4276 4492
 		echo '
4277 4493
 		//# sourceURL=dynamicScript-dbch.js 
@@ -4289,18 +4505,21 @@  discard block
 block discarded – undo
4289 4505
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4290 4506
 	<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>';
4291 4507
 
4292
-	if (!empty($upcontext['error_message']))
4293
-		echo '
4508
+	if (!empty($upcontext['error_message'])) {
4509
+			echo '
4294 4510
 	<error>', $upcontext['error_message'], '</error>';
4511
+	}
4295 4512
 
4296
-	if (!empty($upcontext['error_string']))
4297
-		echo '
4513
+	if (!empty($upcontext['error_string'])) {
4514
+			echo '
4298 4515
 	<sql>', $upcontext['error_string'], '</sql>';
4516
+	}
4299 4517
 
4300
-	if ($is_debug)
4301
-		echo '
4518
+	if ($is_debug) {
4519
+			echo '
4302 4520
 	<curtime>', time(), '</curtime>';
4303
-}
4521
+	}
4522
+	}
4304 4523
 
4305 4524
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4306 4525
 function template_convert_utf8()
@@ -4319,18 +4538,20 @@  discard block
 block discarded – undo
4319 4538
 			</div>';
4320 4539
 
4321 4540
 	// Done any tables so far?
4322
-	if (!empty($upcontext['previous_tables']))
4323
-		foreach ($upcontext['previous_tables'] as $table)
4541
+	if (!empty($upcontext['previous_tables'])) {
4542
+			foreach ($upcontext['previous_tables'] as $table)
4324 4543
 			echo '
4325 4544
 			<br>Completed Table: &quot;', $table, '&quot;.';
4545
+	}
4326 4546
 
4327 4547
 	echo '
4328 4548
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4329 4549
 
4330 4550
 	// If we dropped their index, let's let them know
4331
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index'])
4332
-		echo '
4551
+	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) {
4552
+			echo '
4333 4553
 			<br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>';
4554
+	}
4334 4555
 
4335 4556
 	echo '
4336 4557
 			<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>';
@@ -4366,12 +4587,13 @@  discard block
 block discarded – undo
4366 4587
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4367 4588
 
4368 4589
 		// If debug flood the screen.
4369
-		if ($is_debug)
4370
-			echo '
4590
+		if ($is_debug) {
4591
+					echo '
4371 4592
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4372 4593
 
4373 4594
 				if (document.getElementById(\'debug_section\').scrollHeight)
4374 4595
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4596
+		}
4375 4597
 
4376 4598
 		echo '
4377 4599
 				// Get the next update...
@@ -4416,19 +4638,21 @@  discard block
 block discarded – undo
4416 4638
 			</div>';
4417 4639
 
4418 4640
 	// Dont any tables so far?
4419
-	if (!empty($upcontext['previous_tables']))
4420
-		foreach ($upcontext['previous_tables'] as $table)
4641
+	if (!empty($upcontext['previous_tables'])) {
4642
+			foreach ($upcontext['previous_tables'] as $table)
4421 4643
 			echo '
4422 4644
 			<br>Completed Table: &quot;', $table, '&quot;.';
4645
+	}
4423 4646
 
4424 4647
 	echo '
4425 4648
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4426 4649
 			<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>';
4427 4650
 
4428 4651
 	// Try to make sure substep was reset.
4429
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4430
-		echo '
4652
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4653
+			echo '
4431 4654
 			<input type="hidden" name="substep" id="substep" value="0">';
4655
+	}
4432 4656
 
4433 4657
 	// Continue please!
4434 4658
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4461,12 +4685,13 @@  discard block
 block discarded – undo
4461 4685
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4462 4686
 
4463 4687
 		// If debug flood the screen.
4464
-		if ($is_debug)
4465
-			echo '
4688
+		if ($is_debug) {
4689
+					echo '
4466 4690
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4467 4691
 
4468 4692
 				if (document.getElementById(\'debug_section\').scrollHeight)
4469 4693
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4694
+		}
4470 4695
 
4471 4696
 		echo '
4472 4697
 				// Get the next update...
@@ -4502,8 +4727,8 @@  discard block
 block discarded – undo
4502 4727
 	<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>
4503 4728
 	<form action="', $boardurl, '/index.php">';
4504 4729
 
4505
-	if (!empty($upcontext['can_delete_script']))
4506
-		echo '
4730
+	if (!empty($upcontext['can_delete_script'])) {
4731
+			echo '
4507 4732
 			<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>
4508 4733
 			<script>
4509 4734
 				function doTheDelete(theCheck)
@@ -4515,6 +4740,7 @@  discard block
 block discarded – undo
4515 4740
 				}
4516 4741
 			</script>
4517 4742
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4743
+	}
4518 4744
 
4519 4745
 	$active = time() - $upcontext['started'];
4520 4746
 	$hours = floor($active / 3600);
@@ -4524,16 +4750,20 @@  discard block
 block discarded – undo
4524 4750
 	if ($is_debug)
4525 4751
 	{
4526 4752
 		$totalTime = '';
4527
-		if ($hours > 0)
4528
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4529
-		if ($minutes > 0)
4530
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4531
-		if ($seconds > 0)
4532
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4753
+		if ($hours > 0) {
4754
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4755
+		}
4756
+		if ($minutes > 0) {
4757
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4758
+		}
4759
+		if ($seconds > 0) {
4760
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4761
+		}
4533 4762
 	}
4534 4763
 
4535
-	if ($is_debug && !empty($totalTime))
4536
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4764
+	if ($is_debug && !empty($totalTime)) {
4765
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4766
+	}
4537 4767
 
4538 4768
 	echo '<br>
4539 4769
 			If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br>
@@ -4560,8 +4790,9 @@  discard block
 block discarded – undo
4560 4790
 
4561 4791
 	$current_substep = $_GET['substep'];
4562 4792
 
4563
-	if (empty($_GET['a']))
4564
-		$_GET['a'] = 0;
4793
+	if (empty($_GET['a'])) {
4794
+			$_GET['a'] = 0;
4795
+	}
4565 4796
 	$step_progress['name'] = 'Converting ips';
4566 4797
 	$step_progress['current'] = $_GET['a'];
4567 4798
 
@@ -4604,16 +4835,19 @@  discard block
 block discarded – undo
4604 4835
 				'empty' => '',
4605 4836
 				'limit' => $limit,
4606 4837
 		));
4607
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4608
-			$arIp[] = $row[$oldCol];
4838
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4839
+					$arIp[] = $row[$oldCol];
4840
+		}
4609 4841
 		$smcFunc['db_free_result']($request);
4610 4842
 
4611 4843
 		// Special case, null ip could keep us in a loop.
4612
-		if (is_null($arIp[0]))
4613
-			unset($arIp[0]);
4844
+		if (is_null($arIp[0])) {
4845
+					unset($arIp[0]);
4846
+		}
4614 4847
 
4615
-		if (empty($arIp))
4616
-			$is_done = true;
4848
+		if (empty($arIp)) {
4849
+					$is_done = true;
4850
+		}
4617 4851
 
4618 4852
 		$updates = array();
4619 4853
 		$cases = array();
@@ -4622,16 +4856,18 @@  discard block
 block discarded – undo
4622 4856
 		{
4623 4857
 			$arIp[$i] = trim($arIp[$i]);
4624 4858
 
4625
-			if (empty($arIp[$i]))
4626
-				continue;
4859
+			if (empty($arIp[$i])) {
4860
+							continue;
4861
+			}
4627 4862
 
4628 4863
 			$updates['ip' . $i] = $arIp[$i];
4629 4864
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4630 4865
 
4631 4866
 			if ($setSize > 0 && $i % $setSize === 0)
4632 4867
 			{
4633
-				if (count($updates) == 1)
4634
-					continue;
4868
+				if (count($updates) == 1) {
4869
+									continue;
4870
+				}
4635 4871
 
4636 4872
 				$updates['whereSet'] = array_values($updates);
4637 4873
 				$smcFunc['db_query']('', '
@@ -4665,8 +4901,7 @@  discard block
 block discarded – undo
4665 4901
 							'ip' => $ip
4666 4902
 					));
4667 4903
 				}
4668
-			}
4669
-			else
4904
+			} else
4670 4905
 			{
4671 4906
 				$updates['whereSet'] = array_values($updates);
4672 4907
 				$smcFunc['db_query']('', '
@@ -4680,9 +4915,9 @@  discard block
 block discarded – undo
4680 4915
 					$updates
4681 4916
 				);
4682 4917
 			}
4918
+		} else {
4919
+					$is_done = true;
4683 4920
 		}
4684
-		else
4685
-			$is_done = true;
4686 4921
 
4687 4922
 		$_GET['a'] += $limit;
4688 4923
 		$step_progress['current'] = $_GET['a'];
@@ -4708,10 +4943,11 @@  discard block
 block discarded – undo
4708 4943
  
4709 4944
  	$columns = $smcFunc['db_list_columns']($targetTable, true);
4710 4945
 
4711
-	if (isset($columns[$column]))
4712
-		return $columns[$column];
4713
-	else
4714
-		return null;
4715
-}
4946
+	if (isset($columns[$column])) {
4947
+			return $columns[$column];
4948
+	} else {
4949
+			return null;
4950
+	}
4951
+	}
4716 4952
 
4717 4953
 ?>
4718 4954
\ No newline at end of file
Please login to merge, or discard this patch.