Completed
Push — release-2.1 ( 15f485...ae1be0 )
by Mathias
08:27
created
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/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/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/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.
other/upgrade-helper.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 /**
82 82
  * Make files writable. First try to use regular chmod, but if that fails, try to use FTP.
83 83
  *
84
- * @param $files
84
+ * @param string[] $files
85 85
  * @return bool
86 86
  */
87 87
 function makeFilesWritable(&$files)
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 /**
323 323
  * Prints an error to stderr.
324 324
  *
325
- * @param $message
325
+ * @param string $message
326 326
  * @param bool $fatal
327 327
  */
328 328
 function print_error($message, $fatal = false)
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 /**
342 342
  * Throws a graphical error message.
343 343
  *
344
- * @param $message
344
+ * @param string $message
345 345
  * @return bool
346 346
  */
347 347
 function throw_error($message)
Please login to merge, or discard this patch.
Braces   +90 added lines, -64 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * This file contains helper functions for upgrade.php
14 14
  */
15 15
 
16
-if (!defined('SMF_VERSION'))
16
+if (!defined('SMF_VERSION')) {
17 17
 	die('No direct access!');
18
+}
18 19
 
19 20
 /**
20 21
  * Clean the cache using the SMF 2.1 CacheAPI.
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
 	global $smcFunc;
46 47
 	static $member_groups = array();
47 48
 
48
-	if (!empty($member_groups))
49
-		return $member_groups;
49
+	if (!empty($member_groups)) {
50
+			return $member_groups;
51
+	}
50 52
 
51 53
 	$request = $smcFunc['db_query']('', '
52 54
 		SELECT group_name, id_group
@@ -71,8 +73,9 @@  discard block
 block discarded – undo
71 73
 			)
72 74
 		);
73 75
 	}
74
-	while ($row = $smcFunc['db_fetch_row']($request))
75
-		$member_groups[trim($row[0])] = $row[1];
76
+	while ($row = $smcFunc['db_fetch_row']($request)) {
77
+			$member_groups[trim($row[0])] = $row[1];
78
+	}
76 79
 	$smcFunc['db_free_result']($request);
77 80
 
78 81
 	return $member_groups;
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
 {
89 92
 	global $upcontext, $boarddir, $sourcedir;
90 93
 
91
-	if (empty($files))
92
-		return true;
94
+	if (empty($files)) {
95
+			return true;
96
+	}
93 97
 
94 98
 	$failure = false;
95 99
 	// On linux, it's easy - just use is_writable!
@@ -104,14 +108,16 @@  discard block
 block discarded – undo
104 108
 				@chmod($file, 0755);
105 109
 
106 110
 				// Well, 755 hopefully worked... if not, try 777.
107
-				if (!is_writable($file) && !@chmod($file, 0777))
108
-					$failure = true;
111
+				if (!is_writable($file) && !@chmod($file, 0777)) {
112
+									$failure = true;
113
+				}
109 114
 				// Otherwise remove it as it's good!
110
-				else
111
-					unset($files[$k]);
115
+				else {
116
+									unset($files[$k]);
117
+				}
118
+			} else {
119
+							unset($files[$k]);
112 120
 			}
113
-			else
114
-				unset($files[$k]);
115 121
 		}
116 122
 	}
117 123
 	// Windows is trickier.  Let's try opening for r+...
@@ -122,30 +128,35 @@  discard block
 block discarded – undo
122 128
 		foreach ($files as $k => $file)
123 129
 		{
124 130
 			// Folders can't be opened for write... but the index.php in them can ;).
125
-			if (is_dir($file))
126
-				$file .= '/index.php';
131
+			if (is_dir($file)) {
132
+							$file .= '/index.php';
133
+			}
127 134
 
128 135
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
129 136
 			@chmod($file, 0777);
130 137
 			$fp = @fopen($file, 'r+');
131 138
 
132 139
 			// Hmm, okay, try just for write in that case...
133
-			if (!$fp)
134
-				$fp = @fopen($file, 'w');
140
+			if (!$fp) {
141
+							$fp = @fopen($file, 'w');
142
+			}
135 143
 
136
-			if (!$fp)
137
-				$failure = true;
138
-			else
139
-				unset($files[$k]);
144
+			if (!$fp) {
145
+							$failure = true;
146
+			} else {
147
+							unset($files[$k]);
148
+			}
140 149
 			@fclose($fp);
141 150
 		}
142 151
 	}
143 152
 
144
-	if (empty($files))
145
-		return true;
153
+	if (empty($files)) {
154
+			return true;
155
+	}
146 156
 
147
-	if (!isset($_SERVER))
148
-		return !$failure;
157
+	if (!isset($_SERVER)) {
158
+			return !$failure;
159
+	}
149 160
 
150 161
 	// What still needs to be done?
151 162
 	$upcontext['chmod']['files'] = $files;
@@ -197,36 +208,40 @@  discard block
 block discarded – undo
197 208
 
198 209
 		if (!isset($ftp) || $ftp->error !== false)
199 210
 		{
200
-			if (!isset($ftp))
201
-				$ftp = new ftp_connection(null);
211
+			if (!isset($ftp)) {
212
+							$ftp = new ftp_connection(null);
213
+			}
202 214
 			// Save the error so we can mess with listing...
203
-			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error']))
204
-				$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
215
+			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) {
216
+							$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
217
+			}
205 218
 
206 219
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
207 220
 
208
-			if ($found_path || !isset($upcontext['chmod']['path']))
209
-				$upcontext['chmod']['path'] = $detect_path;
221
+			if ($found_path || !isset($upcontext['chmod']['path'])) {
222
+							$upcontext['chmod']['path'] = $detect_path;
223
+			}
210 224
 
211
-			if (!isset($upcontext['chmod']['username']))
212
-				$upcontext['chmod']['username'] = $username;
225
+			if (!isset($upcontext['chmod']['username'])) {
226
+							$upcontext['chmod']['username'] = $username;
227
+			}
213 228
 
214 229
 			// Don't forget the login token.
215 230
 			$upcontext += createToken('login');
216 231
 
217 232
 			return false;
218
-		}
219
-		else
233
+		} else
220 234
 		{
221 235
 			// We want to do a relative path for FTP.
222 236
 			if (!in_array($upcontext['chmod']['path'], array('', '/')))
223 237
 			{
224 238
 				$ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => ''));
225
-				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/'))
226
-					$ftp_root = substr($ftp_root, 0, -1);
239
+				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) {
240
+									$ftp_root = substr($ftp_root, 0, -1);
241
+				}
242
+			} else {
243
+							$ftp_root = $boarddir;
227 244
 			}
228
-			else
229
-				$ftp_root = $boarddir;
230 245
 
231 246
 			// Save the info for next time!
232 247
 			$_SESSION['installer_temp_ftp'] = array(
@@ -240,10 +255,12 @@  discard block
 block discarded – undo
240 255
 
241 256
 			foreach ($files as $k => $file)
242 257
 			{
243
-				if (!is_writable($file))
244
-					$ftp->chmod($file, 0755);
245
-				if (!is_writable($file))
246
-					$ftp->chmod($file, 0777);
258
+				if (!is_writable($file)) {
259
+									$ftp->chmod($file, 0755);
260
+				}
261
+				if (!is_writable($file)) {
262
+									$ftp->chmod($file, 0777);
263
+				}
247 264
 
248 265
 				// Assuming that didn't work calculate the path without the boarddir.
249 266
 				if (!is_writable($file))
@@ -252,19 +269,23 @@  discard block
 block discarded – undo
252 269
 					{
253 270
 						$ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => ''));
254 271
 						$ftp->chmod($ftp_file, 0755);
255
-						if (!is_writable($file))
256
-							$ftp->chmod($ftp_file, 0777);
272
+						if (!is_writable($file)) {
273
+													$ftp->chmod($ftp_file, 0777);
274
+						}
257 275
 						// Sometimes an extra slash can help...
258 276
 						$ftp_file = '/' . $ftp_file;
259
-						if (!is_writable($file))
260
-							$ftp->chmod($ftp_file, 0755);
261
-						if (!is_writable($file))
262
-							$ftp->chmod($ftp_file, 0777);
277
+						if (!is_writable($file)) {
278
+													$ftp->chmod($ftp_file, 0755);
279
+						}
280
+						if (!is_writable($file)) {
281
+													$ftp->chmod($ftp_file, 0777);
282
+						}
263 283
 					}
264 284
 				}
265 285
 
266
-				if (is_writable($file))
267
-					unset($files[$k]);
286
+				if (is_writable($file)) {
287
+									unset($files[$k]);
288
+				}
268 289
 			}
269 290
 
270 291
 			$ftp->close();
@@ -274,8 +295,9 @@  discard block
 block discarded – undo
274 295
 	// What remains?
275 296
 	$upcontext['chmod']['files'] = $files;
276 297
 
277
-	if (empty($files))
278
-		return true;
298
+	if (empty($files)) {
299
+			return true;
300
+	}
279 301
 
280 302
 	return false;
281 303
 }
@@ -288,8 +310,9 @@  discard block
 block discarded – undo
288 310
  */
289 311
 function quickFileWritable($file)
290 312
 {
291
-	if (is_writable($file))
292
-		return true;
313
+	if (is_writable($file)) {
314
+			return true;
315
+	}
293 316
 
294 317
 	@chmod($file, 0755);
295 318
 
@@ -299,10 +322,11 @@  discard block
 block discarded – undo
299 322
 	foreach ($chmod_values as $val)
300 323
 	{
301 324
 		// If it's writable, break out of the loop
302
-		if (is_writable($file))
303
-			break;
304
-		else
305
-			@chmod($file, $val);
325
+		if (is_writable($file)) {
326
+					break;
327
+		} else {
328
+					@chmod($file, $val);
329
+		}
306 330
 	}
307 331
 
308 332
 	return is_writable($file);
@@ -329,14 +353,16 @@  discard block
 block discarded – undo
329 353
 {
330 354
 	static $fp = null;
331 355
 
332
-	if ($fp === null)
333
-		$fp = fopen('php://stderr', 'wb');
356
+	if ($fp === null) {
357
+			$fp = fopen('php://stderr', 'wb');
358
+	}
334 359
 
335 360
 	fwrite($fp, $message . "\n");
336 361
 
337
-	if ($fatal)
338
-		exit;
339
-}
362
+	if ($fatal) {
363
+			exit;
364
+	}
365
+	}
340 366
 
341 367
 /**
342 368
  * Throws a graphical error message.
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
@@ -393,6 +393,9 @@  discard block
 block discarded – undo
393 393
 }
394 394
 
395 395
 // Used to direct the user to another location.
396
+/**
397
+ * @param string $location
398
+ */
396 399
 function redirectLocation($location, $addForm = true)
397 400
 {
398 401
 	global $upgradeurl, $upcontext, $command_line;
@@ -1573,6 +1576,9 @@  discard block
 block discarded – undo
1573 1576
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
1574 1577
 }
1575 1578
 
1579
+/**
1580
+ * @param string $filename
1581
+ */
1576 1582
 function parse_sql($filename)
1577 1583
 {
1578 1584
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -1607,6 +1613,10 @@  discard block
 block discarded – undo
1607 1613
 
1608 1614
 	// Our custom error handler - does nothing but does stop public errors from XML!
1609 1615
 	set_error_handler(
1616
+
1617
+		/**
1618
+		 * @param string $errno
1619
+		 */
1610 1620
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1611 1621
 		{
1612 1622
 			if ($support_js)
@@ -1853,6 +1863,9 @@  discard block
 block discarded – undo
1853 1863
 	return true;
1854 1864
 }
1855 1865
 
1866
+/**
1867
+ * @param string $string
1868
+ */
1856 1869
 function upgrade_query($string, $unbuffered = false)
1857 1870
 {
1858 1871
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -4512,7 +4525,7 @@  discard block
 block discarded – undo
4512 4525
  * @param int $setSize The amount of entries after which to update the database.
4513 4526
  *
4514 4527
  * newCol needs to be a varbinary(16) null able field
4515
- * @return bool
4528
+ * @return boolean|null
4516 4529
  */
4517 4530
 function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100)
4518 4531
 {
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
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 
1626 1626
 	// Our custom error handler - does nothing but does stop public errors from XML!
1627 1627
 	set_error_handler(
1628
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1628
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1629 1629
 		{
1630 1630
 			if ($support_js)
1631 1631
 				return true;
@@ -2610,94 +2610,94 @@  discard block
 block discarded – undo
2610 2610
 		// Translation table for the character sets not native for MySQL.
2611 2611
 		$translation_tables = array(
2612 2612
 			'windows-1255' => array(
2613
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2614
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2615
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2616
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2617
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2618
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2619
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2620
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2621
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2622
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2623
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2624
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2625
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2626
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2627
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2628
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2629
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2630
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2631
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2632
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2633
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2634
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2635
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2636
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2637
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2638
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2639
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2640
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2641
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2642
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2643
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2644
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2645
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2646
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2647
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2648
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2649
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2650
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2651
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2652
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2653
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2654
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2613
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2614
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2615
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2616
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2617
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2618
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2619
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2620
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2621
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2622
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2623
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2624
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2625
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2626
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2627
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2628
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2629
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2630
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2631
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2632
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2633
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2634
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2635
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2636
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2637
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2638
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2639
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2640
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2641
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2642
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2643
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2644
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2645
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2646
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2647
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2648
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2649
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2650
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2651
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2652
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2653
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2654
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2655 2655
 				'0xFA' => '0xD7AA',
2656 2656
 			),
2657 2657
 			'windows-1253' => array(
2658
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2659
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2660
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2661
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2662
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2663
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2664
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2665
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2666
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2667
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2668
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2669
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2670
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2671
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2672
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2673
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2674
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2675
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2676
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2677
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2678
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2679
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2680
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2681
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2682
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2683
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2684
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2685
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2686
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2687
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2688
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2689
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2690
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2691
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2692
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2693
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2694
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2695
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2696
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2697
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2698
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2699
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2700
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2658
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2659
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2660
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2661
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2662
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2663
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2664
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2665
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2666
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2667
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2668
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2669
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2670
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2671
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2672
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2673
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2674
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2675
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2676
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2677
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2678
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2679
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2680
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2681
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2682
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2683
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2684
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2685
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2686
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2687
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2688
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2689
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2690
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2691
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2692
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2693
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2694
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2695
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2696
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2697
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2698
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2699
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2700
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2701 2701
 			),
2702 2702
 		);
2703 2703
 
@@ -3799,7 +3799,7 @@  discard block
 block discarded – undo
3799 3799
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
3800 3800
 			<input type="hidden" name="backup_done" id="backup_done" value="0">
3801 3801
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
3802
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
3802
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
3803 3803
 			<span id="debuginfo"></span>
3804 3804
 			</div>';
3805 3805
 
@@ -4300,7 +4300,7 @@  discard block
 block discarded – undo
4300 4300
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4301 4301
 			<input type="hidden" name="utf8_done" id="utf8_done" value="0">
4302 4302
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4303
-			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;">
4303
+			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;">
4304 4304
 			<span id="debuginfo"></span>
4305 4305
 			</div>';
4306 4306
 
@@ -4401,7 +4401,7 @@  discard block
 block discarded – undo
4401 4401
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4402 4402
 			<input type="hidden" name="json_done" id="json_done" value="0">
4403 4403
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4404
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
4404
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
4405 4405
 			<span id="debuginfo"></span>
4406 4406
 			</div>';
4407 4407
 
Please login to merge, or discard this patch.
Braces   +875 added lines, -643 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)
@@ -431,12 +456,14 @@  discard block
 block discarded – undo
431 456
 	define('SMF', 1);
432 457
 
433 458
 	// Start the session.
434
-	if (@ini_get('session.save_handler') == 'user')
435
-		@ini_set('session.save_handler', 'files');
459
+	if (@ini_get('session.save_handler') == 'user') {
460
+			@ini_set('session.save_handler', 'files');
461
+	}
436 462
 	@session_start();
437 463
 
438
-	if (empty($smcFunc))
439
-		$smcFunc = array();
464
+	if (empty($smcFunc)) {
465
+			$smcFunc = array();
466
+	}
440 467
 
441 468
 	// We need this for authentication and some upgrade code
442 469
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -448,32 +475,36 @@  discard block
 block discarded – undo
448 475
 	initialize_inputs();
449 476
 
450 477
 	// Get the database going!
451
-	if (empty($db_type) || $db_type == 'mysqli')
452
-		$db_type = 'mysql';
478
+	if (empty($db_type) || $db_type == 'mysqli') {
479
+			$db_type = 'mysql';
480
+	}
453 481
 
454 482
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
455 483
 	{
456 484
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
457 485
 
458 486
 		// Make the connection...
459
-		if (empty($db_connection))
460
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
461
-		else
462
-			// If we've returned here, ping/reconnect to be safe
487
+		if (empty($db_connection)) {
488
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
489
+		} else {
490
+					// If we've returned here, ping/reconnect to be safe
463 491
 			$smcFunc['db_ping']($db_connection);
492
+		}
464 493
 
465 494
 		// Oh dear god!!
466
-		if ($db_connection === null)
467
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
495
+		if ($db_connection === null) {
496
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
497
+		}
468 498
 
469
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
470
-			$smcFunc['db_query']('', '
499
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
500
+					$smcFunc['db_query']('', '
471 501
 			SET NAMES {string:db_character_set}',
472 502
 			array(
473 503
 				'db_error_skip' => true,
474 504
 				'db_character_set' => $db_character_set,
475 505
 			)
476 506
 		);
507
+		}
477 508
 
478 509
 		// Load the modSettings data...
479 510
 		$request = $smcFunc['db_query']('', '
@@ -484,11 +515,11 @@  discard block
 block discarded – undo
484 515
 			)
485 516
 		);
486 517
 		$modSettings = array();
487
-		while ($row = $smcFunc['db_fetch_assoc']($request))
488
-			$modSettings[$row['variable']] = $row['value'];
518
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
519
+					$modSettings[$row['variable']] = $row['value'];
520
+		}
489 521
 		$smcFunc['db_free_result']($request);
490
-	}
491
-	else
522
+	} else
492 523
 	{
493 524
 		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.');
494 525
 	}
@@ -502,9 +533,10 @@  discard block
 block discarded – undo
502 533
 		cleanRequest();
503 534
 	}
504 535
 
505
-	if (!isset($_GET['substep']))
506
-		$_GET['substep'] = 0;
507
-}
536
+	if (!isset($_GET['substep'])) {
537
+			$_GET['substep'] = 0;
538
+	}
539
+	}
508 540
 
509 541
 function initialize_inputs()
510 542
 {
@@ -534,8 +566,9 @@  discard block
 block discarded – undo
534 566
 		$dh = opendir(dirname(__FILE__));
535 567
 		while ($file = readdir($dh))
536 568
 		{
537
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
538
-				@unlink(dirname(__FILE__) . '/' . $file);
569
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
570
+							@unlink(dirname(__FILE__) . '/' . $file);
571
+			}
539 572
 		}
540 573
 		closedir($dh);
541 574
 
@@ -564,8 +597,9 @@  discard block
 block discarded – undo
564 597
 	$temp = 'upgrade_php?step';
565 598
 	while (strlen($temp) > 4)
566 599
 	{
567
-		if (isset($_GET[$temp]))
568
-			unset($_GET[$temp]);
600
+		if (isset($_GET[$temp])) {
601
+					unset($_GET[$temp]);
602
+		}
569 603
 		$temp = substr($temp, 1);
570 604
 	}
571 605
 
@@ -592,32 +626,39 @@  discard block
 block discarded – undo
592 626
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
593 627
 
594 628
 	// Need legacy scripts?
595
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
596
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
597
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
598
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
599
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
600
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
629
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
630
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
631
+	}
632
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
633
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
634
+	}
635
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
636
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
637
+	}
601 638
 
602 639
 	// We don't need "-utf8" files anymore...
603 640
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
604 641
 
605 642
 	// This needs to exist!
606
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
607
-		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>]');
608
-	else
609
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
643
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
644
+			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>]');
645
+	} else {
646
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
647
+	}
610 648
 
611
-	if (!$check)
612
-		// 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.
649
+	if (!$check) {
650
+			// 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.
613 651
 		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.');
652
+	}
614 653
 
615 654
 	// Do they meet the install requirements?
616
-	if (!php_version_check())
617
-		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.');
655
+	if (!php_version_check()) {
656
+			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.');
657
+	}
618 658
 
619
-	if (!db_version_check())
620
-		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.');
659
+	if (!db_version_check()) {
660
+			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.');
661
+	}
621 662
 
622 663
 	// Do some checks to make sure they have proper privileges
623 664
 	db_extend('packages');
@@ -632,14 +673,16 @@  discard block
 block discarded – undo
632 673
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
633 674
 
634 675
 	// Sorry... we need CREATE, ALTER and DROP
635
-	if (!$create || !$alter || !$drop)
636
-		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.');
676
+	if (!$create || !$alter || !$drop) {
677
+			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.');
678
+	}
637 679
 
638 680
 	// Do a quick version spot check.
639 681
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
640 682
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
641
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
642
-		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.');
683
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
684
+			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.');
685
+	}
643 686
 
644 687
 	// What absolutely needs to be writable?
645 688
 	$writable_files = array(
@@ -661,12 +704,13 @@  discard block
 block discarded – undo
661 704
 	quickFileWritable($custom_av_dir);
662 705
 
663 706
 	// Are we good now?
664
-	if (!is_writable($custom_av_dir))
665
-		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));
666
-	elseif ($need_settings_update)
707
+	if (!is_writable($custom_av_dir)) {
708
+			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));
709
+	} elseif ($need_settings_update)
667 710
 	{
668
-		if (!function_exists('cache_put_data'))
669
-			require_once($sourcedir . '/Load.php');
711
+		if (!function_exists('cache_put_data')) {
712
+					require_once($sourcedir . '/Load.php');
713
+		}
670 714
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
671 715
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
672 716
 	}
@@ -675,28 +719,33 @@  discard block
 block discarded – undo
675 719
 
676 720
 	// Check the cache directory.
677 721
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
678
-	if (!file_exists($cachedir_temp))
679
-		@mkdir($cachedir_temp);
680
-	if (!file_exists($cachedir_temp))
681
-		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.');
682
-
683
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
684
-		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>.');
685
-	elseif (!isset($_GET['skiplang']))
722
+	if (!file_exists($cachedir_temp)) {
723
+			@mkdir($cachedir_temp);
724
+	}
725
+	if (!file_exists($cachedir_temp)) {
726
+			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.');
727
+	}
728
+
729
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
730
+			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>.');
731
+	} elseif (!isset($_GET['skiplang']))
686 732
 	{
687 733
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
688 734
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
689 735
 
690
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
691
-			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>]');
736
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
737
+					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>]');
738
+		}
692 739
 	}
693 740
 
694
-	if (!makeFilesWritable($writable_files))
695
-		return false;
741
+	if (!makeFilesWritable($writable_files)) {
742
+			return false;
743
+	}
696 744
 
697 745
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
698
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
699
-		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.');
746
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
747
+			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.');
748
+	}
700 749
 
701 750
 	// Upgrade the agreement.
702 751
 	elseif (isset($modSettings['agreement']))
@@ -707,8 +756,8 @@  discard block
 block discarded – undo
707 756
 	}
708 757
 
709 758
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
710
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
711
-		$upcontext['warning'] = '
759
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
760
+			$upcontext['warning'] = '
712 761
 			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>
713 762
 			<ul>
714 763
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -716,10 +765,12 @@  discard block
 block discarded – undo
716 765
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
717 766
 			</ul>
718 767
 			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.';
768
+	}
719 769
 
720 770
 	// Either we're logged in or we're going to present the login.
721
-	if (checkLogin())
722
-		return true;
771
+	if (checkLogin()) {
772
+			return true;
773
+	}
723 774
 
724 775
 	$upcontext += createToken('login');
725 776
 
@@ -733,15 +784,17 @@  discard block
 block discarded – undo
733 784
 	global $smcFunc, $db_type, $support_js;
734 785
 
735 786
 	// Don't bother if the security is disabled.
736
-	if ($disable_security)
737
-		return true;
787
+	if ($disable_security) {
788
+			return true;
789
+	}
738 790
 
739 791
 	// Are we trying to login?
740 792
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
741 793
 	{
742 794
 		// If we've disabled security pick a suitable name!
743
-		if (empty($_POST['user']))
744
-			$_POST['user'] = 'Administrator';
795
+		if (empty($_POST['user'])) {
796
+					$_POST['user'] = 'Administrator';
797
+		}
745 798
 
746 799
 		// Before 2.0 these column names were different!
747 800
 		$oldDB = false;
@@ -756,16 +809,17 @@  discard block
 block discarded – undo
756 809
 					'db_error_skip' => true,
757 810
 				)
758 811
 			);
759
-			if ($smcFunc['db_num_rows']($request) != 0)
760
-				$oldDB = true;
812
+			if ($smcFunc['db_num_rows']($request) != 0) {
813
+							$oldDB = true;
814
+			}
761 815
 			$smcFunc['db_free_result']($request);
762 816
 		}
763 817
 
764 818
 		// Get what we believe to be their details.
765 819
 		if (!$disable_security)
766 820
 		{
767
-			if ($oldDB)
768
-				$request = $smcFunc['db_query']('', '
821
+			if ($oldDB) {
822
+							$request = $smcFunc['db_query']('', '
769 823
 					SELECT id_member, memberName AS member_name, passwd, id_group,
770 824
 					additionalGroups AS additional_groups, lngfile
771 825
 					FROM {db_prefix}members
@@ -775,8 +829,8 @@  discard block
 block discarded – undo
775 829
 						'db_error_skip' => true,
776 830
 					)
777 831
 				);
778
-			else
779
-				$request = $smcFunc['db_query']('', '
832
+			} else {
833
+							$request = $smcFunc['db_query']('', '
780 834
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
781 835
 					FROM {db_prefix}members
782 836
 					WHERE member_name = {string:member_name}',
@@ -785,6 +839,7 @@  discard block
 block discarded – undo
785 839
 						'db_error_skip' => true,
786 840
 					)
787 841
 				);
842
+			}
788 843
 			if ($smcFunc['db_num_rows']($request) != 0)
789 844
 			{
790 845
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -792,16 +847,17 @@  discard block
 block discarded – undo
792 847
 				$groups = explode(',', $addGroups);
793 848
 				$groups[] = $id_group;
794 849
 
795
-				foreach ($groups as $k => $v)
796
-					$groups[$k] = (int) $v;
850
+				foreach ($groups as $k => $v) {
851
+									$groups[$k] = (int) $v;
852
+				}
797 853
 
798 854
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
799 855
 
800 856
 				// We don't use "-utf8" anymore...
801 857
 				$user_language = str_ireplace('-utf8', '', $user_language);
858
+			} else {
859
+							$upcontext['username_incorrect'] = true;
802 860
 			}
803
-			else
804
-				$upcontext['username_incorrect'] = true;
805 861
 			$smcFunc['db_free_result']($request);
806 862
 		}
807 863
 		$upcontext['username'] = $_POST['user'];
@@ -811,13 +867,14 @@  discard block
 block discarded – undo
811 867
 		{
812 868
 			$upcontext['upgrade_status']['js'] = 1;
813 869
 			$support_js = 1;
870
+		} else {
871
+					$support_js = 0;
814 872
 		}
815
-		else
816
-			$support_js = 0;
817 873
 
818 874
 		// Note down the version we are coming from.
819
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
820
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
875
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
876
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
877
+		}
821 878
 
822 879
 		// Didn't get anywhere?
823 880
 		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']))
@@ -851,15 +908,15 @@  discard block
 block discarded – undo
851 908
 							'db_error_skip' => true,
852 909
 						)
853 910
 					);
854
-					if ($smcFunc['db_num_rows']($request) == 0)
855
-						return throw_error('You need to be an admin to perform an upgrade!');
911
+					if ($smcFunc['db_num_rows']($request) == 0) {
912
+											return throw_error('You need to be an admin to perform an upgrade!');
913
+					}
856 914
 					$smcFunc['db_free_result']($request);
857 915
 				}
858 916
 
859 917
 				$upcontext['user']['id'] = $id_member;
860 918
 				$upcontext['user']['name'] = $name;
861
-			}
862
-			else
919
+			} else
863 920
 			{
864 921
 				$upcontext['user']['id'] = 1;
865 922
 				$upcontext['user']['name'] = 'Administrator';
@@ -875,11 +932,11 @@  discard block
 block discarded – undo
875 932
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
876 933
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
877 934
 
878
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
879
-					$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'] . '.';
880
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
881
-					$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'] . '.';
882
-				else
935
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
936
+									$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'] . '.';
937
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
938
+									$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'] . '.';
939
+				} else
883 940
 				{
884 941
 					// Set this as the new language.
885 942
 					$upcontext['language'] = $user_language;
@@ -923,8 +980,9 @@  discard block
 block discarded – undo
923 980
 	unset($member_columns);
924 981
 
925 982
 	// If we've not submitted then we're done.
926
-	if (empty($_POST['upcont']))
927
-		return false;
983
+	if (empty($_POST['upcont'])) {
984
+			return false;
985
+	}
928 986
 
929 987
 	// Firstly, if they're enabling SM stat collection just do it.
930 988
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -944,16 +1002,17 @@  discard block
 block discarded – undo
944 1002
 				fwrite($fp, $out);
945 1003
 
946 1004
 				$return_data = '';
947
-				while (!feof($fp))
948
-					$return_data .= fgets($fp, 128);
1005
+				while (!feof($fp)) {
1006
+									$return_data .= fgets($fp, 128);
1007
+				}
949 1008
 
950 1009
 				fclose($fp);
951 1010
 
952 1011
 				// Get the unique site ID.
953 1012
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
954 1013
 
955
-				if (!empty($ID[1]))
956
-					$smcFunc['db_insert']('replace',
1014
+				if (!empty($ID[1])) {
1015
+									$smcFunc['db_insert']('replace',
957 1016
 						$db_prefix . 'settings',
958 1017
 						array('variable' => 'string', 'value' => 'string'),
959 1018
 						array(
@@ -962,9 +1021,9 @@  discard block
 block discarded – undo
962 1021
 						),
963 1022
 						array('variable')
964 1023
 					);
1024
+				}
965 1025
 			}
966
-		}
967
-		else
1026
+		} else
968 1027
 		{
969 1028
 			$smcFunc['db_insert']('replace',
970 1029
 				$db_prefix . 'settings',
@@ -975,8 +1034,8 @@  discard block
 block discarded – undo
975 1034
 		}
976 1035
 	}
977 1036
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
978
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
979
-		$smcFunc['db_query']('', '
1037
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1038
+			$smcFunc['db_query']('', '
980 1039
 			DELETE FROM {db_prefix}settings
981 1040
 			WHERE variable = {string:enable_sm_stats}',
982 1041
 			array(
@@ -984,6 +1043,7 @@  discard block
 block discarded – undo
984 1043
 				'db_error_skip' => true,
985 1044
 			)
986 1045
 		);
1046
+	}
987 1047
 
988 1048
 	// Deleting old karma stuff?
989 1049
 	if (!empty($_POST['delete_karma']))
@@ -998,20 +1058,22 @@  discard block
 block discarded – undo
998 1058
 		);
999 1059
 
1000 1060
 		// Cleaning up old karma member settings.
1001
-		if ($upcontext['karma_installed']['good'])
1002
-			$smcFunc['db_query']('', '
1061
+		if ($upcontext['karma_installed']['good']) {
1062
+					$smcFunc['db_query']('', '
1003 1063
 				ALTER TABLE {db_prefix}members
1004 1064
 				DROP karma_good',
1005 1065
 				array()
1006 1066
 			);
1067
+		}
1007 1068
 
1008 1069
 		// Does karma bad was enable?
1009
-		if ($upcontext['karma_installed']['bad'])
1010
-			$smcFunc['db_query']('', '
1070
+		if ($upcontext['karma_installed']['bad']) {
1071
+					$smcFunc['db_query']('', '
1011 1072
 				ALTER TABLE {db_prefix}members
1012 1073
 				DROP karma_bad',
1013 1074
 				array()
1014 1075
 			);
1076
+		}
1015 1077
 
1016 1078
 		// Cleaning up old karma permissions.
1017 1079
 		$smcFunc['db_query']('', '
@@ -1024,26 +1086,29 @@  discard block
 block discarded – undo
1024 1086
 	}
1025 1087
 
1026 1088
 	// Emptying the error log?
1027
-	if (!empty($_POST['empty_error']))
1028
-		$smcFunc['db_query']('truncate_table', '
1089
+	if (!empty($_POST['empty_error'])) {
1090
+			$smcFunc['db_query']('truncate_table', '
1029 1091
 			TRUNCATE {db_prefix}log_errors',
1030 1092
 			array(
1031 1093
 			)
1032 1094
 		);
1095
+	}
1033 1096
 
1034 1097
 	$changes = array();
1035 1098
 
1036 1099
 	// Add proxy settings.
1037
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1038
-		$changes += array(
1100
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1101
+			$changes += array(
1039 1102
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1040 1103
 			'image_proxy_maxsize' => 5190,
1041 1104
 			'image_proxy_enabled' => 0,
1042 1105
 		);
1106
+	}
1043 1107
 
1044 1108
 	// If we're overriding the language follow it through.
1045
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1046
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1109
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1110
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1111
+	}
1047 1112
 
1048 1113
 	if (!empty($_POST['maint']))
1049 1114
 	{
@@ -1055,30 +1120,34 @@  discard block
 block discarded – undo
1055 1120
 		{
1056 1121
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1057 1122
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1058
-		}
1059
-		else
1123
+		} else
1060 1124
 		{
1061 1125
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1062 1126
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1063 1127
 		}
1064 1128
 	}
1065 1129
 
1066
-	if ($command_line)
1067
-		echo ' * Updating Settings.php...';
1130
+	if ($command_line) {
1131
+			echo ' * Updating Settings.php...';
1132
+	}
1068 1133
 
1069 1134
 	// Fix some old paths.
1070
-	if (substr($boarddir, 0, 1) == '.')
1071
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1135
+	if (substr($boarddir, 0, 1) == '.') {
1136
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1137
+	}
1072 1138
 
1073
-	if (substr($sourcedir, 0, 1) == '.')
1074
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1139
+	if (substr($sourcedir, 0, 1) == '.') {
1140
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1141
+	}
1075 1142
 
1076
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1077
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1143
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1144
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1145
+	}
1078 1146
 
1079 1147
 	// Not had the database type added before?
1080
-	if (empty($db_type))
1081
-		$changes['db_type'] = 'mysql';
1148
+	if (empty($db_type)) {
1149
+			$changes['db_type'] = 'mysql';
1150
+	}
1082 1151
 
1083 1152
 	// If they have a "host:port" setup for the host, split that into separate values
1084 1153
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1089,32 +1158,36 @@  discard block
 block discarded – undo
1089 1158
 		$changes['db_server'] = '\'' . $db_server . '\'';
1090 1159
 
1091 1160
 		// Only set this if we're not using the default port
1092
-		if ($db_port != ini_get('mysqli.default_port'))
1093
-			$changes['db_port'] = (int) $db_port;
1094
-	}
1095
-	elseif (!empty($db_port))
1161
+		if ($db_port != ini_get('mysqli.default_port')) {
1162
+					$changes['db_port'] = (int) $db_port;
1163
+		}
1164
+	} elseif (!empty($db_port))
1096 1165
 	{
1097 1166
 		// If db_port is set and is the same as the default, set it to ''
1098 1167
 		if ($db_type == 'mysql')
1099 1168
 		{
1100
-			if ($db_port == ini_get('mysqli.default_port'))
1101
-				$changes['db_port'] = '\'\'';
1102
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1103
-				$changes['db_port'] = '\'\'';
1169
+			if ($db_port == ini_get('mysqli.default_port')) {
1170
+							$changes['db_port'] = '\'\'';
1171
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1172
+							$changes['db_port'] = '\'\'';
1173
+			}
1104 1174
 		}
1105 1175
 	}
1106 1176
 
1107 1177
 	// Maybe we haven't had this option yet?
1108
-	if (empty($packagesdir))
1109
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1178
+	if (empty($packagesdir)) {
1179
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1180
+	}
1110 1181
 
1111 1182
 	// Add support for $tasksdir var.
1112
-	if (empty($tasksdir))
1113
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1183
+	if (empty($tasksdir)) {
1184
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1185
+	}
1114 1186
 
1115 1187
 	// Make sure we fix the language as well.
1116
-	if (stristr($language, '-utf8'))
1117
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1188
+	if (stristr($language, '-utf8')) {
1189
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1190
+	}
1118 1191
 
1119 1192
 	// @todo Maybe change the cookie name if going to 1.1, too?
1120 1193
 
@@ -1122,8 +1195,9 @@  discard block
 block discarded – undo
1122 1195
 	require_once($sourcedir . '/Subs-Admin.php');
1123 1196
 	updateSettingsFile($changes);
1124 1197
 
1125
-	if ($command_line)
1126
-		echo ' Successful.' . "\n";
1198
+	if ($command_line) {
1199
+			echo ' Successful.' . "\n";
1200
+	}
1127 1201
 
1128 1202
 	// Are we doing debug?
1129 1203
 	if (isset($_POST['debug']))
@@ -1133,8 +1207,9 @@  discard block
 block discarded – undo
1133 1207
 	}
1134 1208
 
1135 1209
 	// If we're not backing up then jump one.
1136
-	if (empty($_POST['backup']))
1137
-		$upcontext['current_step']++;
1210
+	if (empty($_POST['backup'])) {
1211
+			$upcontext['current_step']++;
1212
+	}
1138 1213
 
1139 1214
 	// If we've got here then let's proceed to the next step!
1140 1215
 	return true;
@@ -1149,8 +1224,9 @@  discard block
 block discarded – undo
1149 1224
 	$upcontext['page_title'] = 'Backup Database';
1150 1225
 
1151 1226
 	// Done it already - js wise?
1152
-	if (!empty($_POST['backup_done']))
1153
-		return true;
1227
+	if (!empty($_POST['backup_done'])) {
1228
+			return true;
1229
+	}
1154 1230
 
1155 1231
 	// Some useful stuff here.
1156 1232
 	db_extend();
@@ -1164,9 +1240,10 @@  discard block
 block discarded – undo
1164 1240
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1165 1241
 
1166 1242
 	$table_names = array();
1167
-	foreach ($tables as $table)
1168
-		if (substr($table, 0, 7) !== 'backup_')
1243
+	foreach ($tables as $table) {
1244
+			if (substr($table, 0, 7) !== 'backup_')
1169 1245
 			$table_names[] = $table;
1246
+	}
1170 1247
 
1171 1248
 	$upcontext['table_count'] = count($table_names);
1172 1249
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1176,12 +1253,14 @@  discard block
 block discarded – undo
1176 1253
 	$file_steps = $upcontext['table_count'];
1177 1254
 
1178 1255
 	// What ones have we already done?
1179
-	foreach ($table_names as $id => $table)
1180
-		if ($id < $_GET['substep'])
1256
+	foreach ($table_names as $id => $table) {
1257
+			if ($id < $_GET['substep'])
1181 1258
 			$upcontext['previous_tables'][] = $table;
1259
+	}
1182 1260
 
1183
-	if ($command_line)
1184
-		echo 'Backing Up Tables.';
1261
+	if ($command_line) {
1262
+			echo 'Backing Up Tables.';
1263
+	}
1185 1264
 
1186 1265
 	// If we don't support javascript we backup here.
1187 1266
 	if (!$support_js || isset($_GET['xml']))
@@ -1200,8 +1279,9 @@  discard block
 block discarded – undo
1200 1279
 			backupTable($table_names[$substep]);
1201 1280
 
1202 1281
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1203
-			if (isset($_GET['xml']))
1204
-				return upgradeExit();
1282
+			if (isset($_GET['xml'])) {
1283
+							return upgradeExit();
1284
+			}
1205 1285
 		}
1206 1286
 
1207 1287
 		if ($command_line)
@@ -1234,9 +1314,10 @@  discard block
 block discarded – undo
1234 1314
 
1235 1315
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1236 1316
 
1237
-	if ($command_line)
1238
-		echo ' done.';
1239
-}
1317
+	if ($command_line) {
1318
+			echo ' done.';
1319
+	}
1320
+	}
1240 1321
 
1241 1322
 // Step 2: Everything.
1242 1323
 function DatabaseChanges()
@@ -1245,8 +1326,9 @@  discard block
 block discarded – undo
1245 1326
 	global $upcontext, $support_js, $db_type;
1246 1327
 
1247 1328
 	// Have we just completed this?
1248
-	if (!empty($_POST['database_done']))
1249
-		return true;
1329
+	if (!empty($_POST['database_done'])) {
1330
+			return true;
1331
+	}
1250 1332
 
1251 1333
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1252 1334
 	$upcontext['page_title'] = 'Database Changes';
@@ -1261,15 +1343,16 @@  discard block
 block discarded – undo
1261 1343
 	);
1262 1344
 
1263 1345
 	// How many files are there in total?
1264
-	if (isset($_GET['filecount']))
1265
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1266
-	else
1346
+	if (isset($_GET['filecount'])) {
1347
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1348
+	} else
1267 1349
 	{
1268 1350
 		$upcontext['file_count'] = 0;
1269 1351
 		foreach ($files as $file)
1270 1352
 		{
1271
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1272
-				$upcontext['file_count']++;
1353
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1354
+							$upcontext['file_count']++;
1355
+			}
1273 1356
 		}
1274 1357
 	}
1275 1358
 
@@ -1279,9 +1362,9 @@  discard block
 block discarded – undo
1279 1362
 	$upcontext['cur_file_num'] = 0;
1280 1363
 	foreach ($files as $file)
1281 1364
 	{
1282
-		if ($did_not_do)
1283
-			$did_not_do--;
1284
-		else
1365
+		if ($did_not_do) {
1366
+					$did_not_do--;
1367
+		} else
1285 1368
 		{
1286 1369
 			$upcontext['cur_file_num']++;
1287 1370
 			$upcontext['cur_file_name'] = $file[0];
@@ -1308,12 +1391,13 @@  discard block
 block discarded – undo
1308 1391
 					// Flag to move on to the next.
1309 1392
 					$upcontext['completed_step'] = true;
1310 1393
 					// Did we complete the whole file?
1311
-					if ($nextFile)
1312
-						$upcontext['current_debug_item_num'] = -1;
1394
+					if ($nextFile) {
1395
+											$upcontext['current_debug_item_num'] = -1;
1396
+					}
1313 1397
 					return upgradeExit();
1398
+				} elseif ($support_js) {
1399
+									break;
1314 1400
 				}
1315
-				elseif ($support_js)
1316
-					break;
1317 1401
 			}
1318 1402
 			// Set the progress bar to be right as if we had - even if we hadn't...
1319 1403
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1338,8 +1422,9 @@  discard block
 block discarded – undo
1338 1422
 	global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1339 1423
 
1340 1424
 	// Now it's nice to have some of the basic SMF source files.
1341
-	if (!isset($_GET['ssi']) && !$command_line)
1342
-		redirectLocation('&ssi=1');
1425
+	if (!isset($_GET['ssi']) && !$command_line) {
1426
+			redirectLocation('&ssi=1');
1427
+	}
1343 1428
 
1344 1429
 	$upcontext['sub_template'] = 'upgrade_complete';
1345 1430
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1355,14 +1440,16 @@  discard block
 block discarded – undo
1355 1440
 	// Are we in maintenance mode?
1356 1441
 	if (isset($upcontext['user']['main']))
1357 1442
 	{
1358
-		if ($command_line)
1359
-			echo ' * ';
1443
+		if ($command_line) {
1444
+					echo ' * ';
1445
+		}
1360 1446
 		$upcontext['removed_maintenance'] = true;
1361 1447
 		$changes['maintenance'] = $upcontext['user']['main'];
1362 1448
 	}
1363 1449
 	// Otherwise if somehow we are in 2 let's go to 1.
1364
-	elseif (!empty($maintenance) && $maintenance == 2)
1365
-		$changes['maintenance'] = 1;
1450
+	elseif (!empty($maintenance) && $maintenance == 2) {
1451
+			$changes['maintenance'] = 1;
1452
+	}
1366 1453
 
1367 1454
 	// Wipe this out...
1368 1455
 	$upcontext['user'] = array();
@@ -1377,9 +1464,9 @@  discard block
 block discarded – undo
1377 1464
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1378 1465
 
1379 1466
 	// Now is the perfect time to fetch the SM files.
1380
-	if ($command_line)
1381
-		cli_scheduled_fetchSMfiles();
1382
-	else
1467
+	if ($command_line) {
1468
+			cli_scheduled_fetchSMfiles();
1469
+	} else
1383 1470
 	{
1384 1471
 		require_once($sourcedir . '/ScheduledTasks.php');
1385 1472
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1387,8 +1474,9 @@  discard block
 block discarded – undo
1387 1474
 	}
1388 1475
 
1389 1476
 	// Log what we've done.
1390
-	if (empty($user_info['id']))
1391
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1477
+	if (empty($user_info['id'])) {
1478
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1479
+	}
1392 1480
 
1393 1481
 	// Log the action manually, so CLI still works.
1394 1482
 	$smcFunc['db_insert']('',
@@ -1407,8 +1495,9 @@  discard block
 block discarded – undo
1407 1495
 
1408 1496
 	// Save the current database version.
1409 1497
 	$server_version = $smcFunc['db_server_info']();
1410
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1411
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1498
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1499
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1500
+	}
1412 1501
 
1413 1502
 	if ($command_line)
1414 1503
 	{
@@ -1420,8 +1509,9 @@  discard block
 block discarded – undo
1420 1509
 
1421 1510
 	// Make sure it says we're done.
1422 1511
 	$upcontext['overall_percent'] = 100;
1423
-	if (isset($upcontext['step_progress']))
1424
-		unset($upcontext['step_progress']);
1512
+	if (isset($upcontext['step_progress'])) {
1513
+			unset($upcontext['step_progress']);
1514
+	}
1425 1515
 
1426 1516
 	$_GET['substep'] = 0;
1427 1517
 	return false;
@@ -1432,8 +1522,9 @@  discard block
 block discarded – undo
1432 1522
 {
1433 1523
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1434 1524
 
1435
-	if (empty($modSettings['time_format']))
1436
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1525
+	if (empty($modSettings['time_format'])) {
1526
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1527
+	}
1437 1528
 
1438 1529
 	// What files do we want to get
1439 1530
 	$request = $smcFunc['db_query']('', '
@@ -1467,8 +1558,9 @@  discard block
 block discarded – undo
1467 1558
 		$file_data = fetch_web_data($url);
1468 1559
 
1469 1560
 		// If we got an error - give up - the site might be down.
1470
-		if ($file_data === false)
1471
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1561
+		if ($file_data === false) {
1562
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1563
+		}
1472 1564
 
1473 1565
 		// Save the file to the database.
1474 1566
 		$smcFunc['db_query']('substring', '
@@ -1510,8 +1602,9 @@  discard block
 block discarded – undo
1510 1602
 	$themeData = array();
1511 1603
 	foreach ($values as $variable => $value)
1512 1604
 	{
1513
-		if (!isset($value) || $value === null)
1514
-			$value = 0;
1605
+		if (!isset($value) || $value === null) {
1606
+					$value = 0;
1607
+		}
1515 1608
 
1516 1609
 		$themeData[] = array(0, 1, $variable, $value);
1517 1610
 	}
@@ -1540,8 +1633,9 @@  discard block
 block discarded – undo
1540 1633
 
1541 1634
 	foreach ($values as $variable => $value)
1542 1635
 	{
1543
-		if (empty($modSettings[$value[0]]))
1544
-			continue;
1636
+		if (empty($modSettings[$value[0]])) {
1637
+					continue;
1638
+		}
1545 1639
 
1546 1640
 		$smcFunc['db_query']('', '
1547 1641
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1627,19 +1721,21 @@  discard block
 block discarded – undo
1627 1721
 	set_error_handler(
1628 1722
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1629 1723
 		{
1630
-			if ($support_js)
1631
-				return true;
1632
-			else
1633
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1724
+			if ($support_js) {
1725
+							return true;
1726
+			} else {
1727
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1728
+			}
1634 1729
 		}
1635 1730
 	);
1636 1731
 
1637 1732
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1638 1733
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1639
-	if ($db_type == 'mysql')
1640
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1641
-	else
1642
-		$db_collation = '';
1734
+	if ($db_type == 'mysql') {
1735
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1736
+	} else {
1737
+			$db_collation = '';
1738
+	}
1643 1739
 
1644 1740
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1645 1741
 
@@ -1651,8 +1747,9 @@  discard block
 block discarded – undo
1651 1747
 	$last_step = '';
1652 1748
 
1653 1749
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1654
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1655
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1750
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1751
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1752
+	}
1656 1753
 
1657 1754
 	// Count the total number of steps within this file - for progress.
1658 1755
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1672,15 +1769,18 @@  discard block
 block discarded – undo
1672 1769
 		$do_current = $substep >= $_GET['substep'];
1673 1770
 
1674 1771
 		// Get rid of any comments in the beginning of the line...
1675
-		if (substr(trim($line), 0, 2) === '/*')
1676
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1772
+		if (substr(trim($line), 0, 2) === '/*') {
1773
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1774
+		}
1677 1775
 
1678 1776
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1679
-		if ($is_debug && !$support_js && $command_line)
1680
-			flush();
1777
+		if ($is_debug && !$support_js && $command_line) {
1778
+					flush();
1779
+		}
1681 1780
 
1682
-		if (trim($line) === '')
1683
-			continue;
1781
+		if (trim($line) === '') {
1782
+					continue;
1783
+		}
1684 1784
 
1685 1785
 		if (trim(substr($line, 0, 3)) === '---')
1686 1786
 		{
@@ -1690,8 +1790,9 @@  discard block
 block discarded – undo
1690 1790
 			if (trim($current_data) != '' && $type !== '}')
1691 1791
 			{
1692 1792
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1693
-				if ($command_line)
1694
-					echo $upcontext['error_message'];
1793
+				if ($command_line) {
1794
+									echo $upcontext['error_message'];
1795
+				}
1695 1796
 			}
1696 1797
 
1697 1798
 			if ($type == ' ')
@@ -1709,17 +1810,18 @@  discard block
 block discarded – undo
1709 1810
 				if ($do_current)
1710 1811
 				{
1711 1812
 					$upcontext['actioned_items'][] = $last_step;
1712
-					if ($command_line)
1713
-						echo ' * ';
1813
+					if ($command_line) {
1814
+											echo ' * ';
1815
+					}
1714 1816
 				}
1715
-			}
1716
-			elseif ($type == '#')
1817
+			} elseif ($type == '#')
1717 1818
 			{
1718 1819
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1719 1820
 
1720 1821
 				$upcontext['current_debug_item_num']++;
1721
-				if (trim($line) != '---#')
1722
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1822
+				if (trim($line) != '---#') {
1823
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1824
+				}
1723 1825
 
1724 1826
 				// Have we already done something?
1725 1827
 				if (isset($_GET['xml']) && $done_something)
@@ -1730,34 +1832,36 @@  discard block
 block discarded – undo
1730 1832
 
1731 1833
 				if ($do_current)
1732 1834
 				{
1733
-					if (trim($line) == '---#' && $command_line)
1734
-						echo ' done.', $endl;
1735
-					elseif ($command_line)
1736
-						echo ' +++ ', rtrim(substr($line, 4));
1737
-					elseif (trim($line) != '---#')
1835
+					if (trim($line) == '---#' && $command_line) {
1836
+											echo ' done.', $endl;
1837
+					} elseif ($command_line) {
1838
+											echo ' +++ ', rtrim(substr($line, 4));
1839
+					} elseif (trim($line) != '---#')
1738 1840
 					{
1739
-						if ($is_debug)
1740
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1841
+						if ($is_debug) {
1842
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1843
+						}
1741 1844
 					}
1742 1845
 				}
1743 1846
 
1744 1847
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1745 1848
 				{
1746
-					if ($command_line)
1747
-						echo ' * ';
1748
-					else
1749
-						$upcontext['actioned_items'][] = $last_step;
1849
+					if ($command_line) {
1850
+											echo ' * ';
1851
+					} else {
1852
+											$upcontext['actioned_items'][] = $last_step;
1853
+					}
1750 1854
 				}
1751 1855
 
1752 1856
 				// Small step - only if we're actually doing stuff.
1753
-				if ($do_current)
1754
-					nextSubstep(++$substep);
1755
-				else
1756
-					$substep++;
1757
-			}
1758
-			elseif ($type == '{')
1759
-				$current_type = 'code';
1760
-			elseif ($type == '}')
1857
+				if ($do_current) {
1858
+									nextSubstep(++$substep);
1859
+				} else {
1860
+									$substep++;
1861
+				}
1862
+			} elseif ($type == '{') {
1863
+							$current_type = 'code';
1864
+			} elseif ($type == '}')
1761 1865
 			{
1762 1866
 				$current_type = 'sql';
1763 1867
 
@@ -1770,8 +1874,9 @@  discard block
 block discarded – undo
1770 1874
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1771 1875
 				{
1772 1876
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1773
-					if ($command_line)
1774
-						echo $upcontext['error_message'];
1877
+					if ($command_line) {
1878
+											echo $upcontext['error_message'];
1879
+					}
1775 1880
 				}
1776 1881
 
1777 1882
 				// Done with code!
@@ -1851,8 +1956,9 @@  discard block
 block discarded – undo
1851 1956
 	$db_unbuffered = false;
1852 1957
 
1853 1958
 	// Failure?!
1854
-	if ($result !== false)
1855
-		return $result;
1959
+	if ($result !== false) {
1960
+			return $result;
1961
+	}
1856 1962
 
1857 1963
 	$db_error_message = $smcFunc['db_error']($db_connection);
1858 1964
 	// If MySQL we do something more clever.
@@ -1880,54 +1986,61 @@  discard block
 block discarded – undo
1880 1986
 			{
1881 1987
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1882 1988
 				$result = mysqli_query($db_connection, $string);
1883
-				if ($result !== false)
1884
-					return $result;
1989
+				if ($result !== false) {
1990
+									return $result;
1991
+				}
1885 1992
 			}
1886
-		}
1887
-		elseif ($mysqli_errno == 2013)
1993
+		} elseif ($mysqli_errno == 2013)
1888 1994
 		{
1889 1995
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1890 1996
 			mysqli_select_db($db_connection, $db_name);
1891 1997
 			if ($db_connection)
1892 1998
 			{
1893 1999
 				$result = mysqli_query($db_connection, $string);
1894
-				if ($result !== false)
1895
-					return $result;
2000
+				if ($result !== false) {
2001
+									return $result;
2002
+				}
1896 2003
 			}
1897 2004
 		}
1898 2005
 		// Duplicate column name... should be okay ;).
1899
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1900
-			return false;
2006
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2007
+					return false;
2008
+		}
1901 2009
 		// Duplicate insert... make sure it's the proper type of query ;).
1902
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1903
-			return false;
2010
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2011
+					return false;
2012
+		}
1904 2013
 		// Creating an index on a non-existent column.
1905
-		elseif ($mysqli_errno == 1072)
1906
-			return false;
1907
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1908
-			return false;
2014
+		elseif ($mysqli_errno == 1072) {
2015
+					return false;
2016
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2017
+					return false;
2018
+		}
1909 2019
 	}
1910 2020
 	// If a table already exists don't go potty.
1911 2021
 	else
1912 2022
 	{
1913 2023
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1914 2024
 		{
1915
-			if (strpos($db_error_message, 'exist') !== false)
1916
-				return true;
1917
-		}
1918
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2025
+			if (strpos($db_error_message, 'exist') !== false) {
2026
+							return true;
2027
+			}
2028
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1919 2029
 		{
1920
-			if (strpos($db_error_message, 'duplicate') !== false)
1921
-				return true;
2030
+			if (strpos($db_error_message, 'duplicate') !== false) {
2031
+							return true;
2032
+			}
1922 2033
 		}
1923 2034
 	}
1924 2035
 
1925 2036
 	// Get the query string so we pass everything.
1926 2037
 	$query_string = '';
1927
-	foreach ($_GET as $k => $v)
1928
-		$query_string .= ';' . $k . '=' . $v;
1929
-	if (strlen($query_string) != 0)
1930
-		$query_string = '?' . substr($query_string, 1);
2038
+	foreach ($_GET as $k => $v) {
2039
+			$query_string .= ';' . $k . '=' . $v;
2040
+	}
2041
+	if (strlen($query_string) != 0) {
2042
+			$query_string = '?' . substr($query_string, 1);
2043
+	}
1931 2044
 
1932 2045
 	if ($command_line)
1933 2046
 	{
@@ -1982,16 +2095,18 @@  discard block
 block discarded – undo
1982 2095
 			{
1983 2096
 				$found |= 1;
1984 2097
 				// Do some checks on the data if we have it set.
1985
-				if (isset($change['col_type']))
1986
-					$found &= $change['col_type'] === $column['type'];
1987
-				if (isset($change['null_allowed']))
1988
-					$found &= $column['null'] == $change['null_allowed'];
1989
-				if (isset($change['default']))
1990
-					$found &= $change['default'] === $column['default'];
2098
+				if (isset($change['col_type'])) {
2099
+									$found &= $change['col_type'] === $column['type'];
2100
+				}
2101
+				if (isset($change['null_allowed'])) {
2102
+									$found &= $column['null'] == $change['null_allowed'];
2103
+				}
2104
+				if (isset($change['default'])) {
2105
+									$found &= $change['default'] === $column['default'];
2106
+				}
1991 2107
 			}
1992 2108
 		}
1993
-	}
1994
-	elseif ($change['type'] === 'index')
2109
+	} elseif ($change['type'] === 'index')
1995 2110
 	{
1996 2111
 		$request = upgrade_query('
1997 2112
 			SHOW INDEX
@@ -2000,9 +2115,10 @@  discard block
 block discarded – undo
2000 2115
 		{
2001 2116
 			$cur_index = array();
2002 2117
 
2003
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2004
-				if ($row['Key_name'] === $change['name'])
2118
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2119
+							if ($row['Key_name'] === $change['name'])
2005 2120
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2121
+			}
2006 2122
 
2007 2123
 			ksort($cur_index, SORT_NUMERIC);
2008 2124
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2012,14 +2128,17 @@  discard block
 block discarded – undo
2012 2128
 	}
2013 2129
 
2014 2130
 	// If we're trying to add and it's added, we're done.
2015
-	if ($found && in_array($change['method'], array('add', 'change')))
2016
-		return true;
2131
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2132
+			return true;
2133
+	}
2017 2134
 	// Otherwise if we're removing and it wasn't found we're also done.
2018
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2019
-		return true;
2135
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2136
+			return true;
2137
+	}
2020 2138
 	// Otherwise is it just a test?
2021
-	elseif ($is_test)
2022
-		return false;
2139
+	elseif ($is_test) {
2140
+			return false;
2141
+	}
2023 2142
 
2024 2143
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2025 2144
 	$running = false;
@@ -2030,8 +2149,9 @@  discard block
 block discarded – undo
2030 2149
 			SHOW FULL PROCESSLIST');
2031 2150
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2032 2151
 		{
2033
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2034
-				$found = true;
2152
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2153
+							$found = true;
2154
+			}
2035 2155
 		}
2036 2156
 
2037 2157
 		// Can't find it? Then we need to run it fools!
@@ -2043,8 +2163,9 @@  discard block
 block discarded – undo
2043 2163
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2044 2164
 				' . $change['text'], true) !== false;
2045 2165
 
2046
-			if (!$success)
2047
-				return false;
2166
+			if (!$success) {
2167
+							return false;
2168
+			}
2048 2169
 
2049 2170
 			// Return
2050 2171
 			$running = true;
@@ -2086,8 +2207,9 @@  discard block
 block discarded – undo
2086 2207
 			'db_error_skip' => true,
2087 2208
 		)
2088 2209
 	);
2089
-	if ($smcFunc['db_num_rows']($request) === 0)
2090
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2210
+	if ($smcFunc['db_num_rows']($request) === 0) {
2211
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2212
+	}
2091 2213
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2092 2214
 	$smcFunc['db_free_result']($request);
2093 2215
 
@@ -2109,18 +2231,19 @@  discard block
 block discarded – undo
2109 2231
 			)
2110 2232
 		);
2111 2233
 		// No results? Just forget it all together.
2112
-		if ($smcFunc['db_num_rows']($request) === 0)
2113
-			unset($table_row['Collation']);
2114
-		else
2115
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2234
+		if ($smcFunc['db_num_rows']($request) === 0) {
2235
+					unset($table_row['Collation']);
2236
+		} else {
2237
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2238
+		}
2116 2239
 		$smcFunc['db_free_result']($request);
2117 2240
 	}
2118 2241
 
2119 2242
 	if ($column_fix)
2120 2243
 	{
2121 2244
 		// Make sure there are no NULL's left.
2122
-		if ($null_fix)
2123
-			$smcFunc['db_query']('', '
2245
+		if ($null_fix) {
2246
+					$smcFunc['db_query']('', '
2124 2247
 				UPDATE {db_prefix}' . $change['table'] . '
2125 2248
 				SET ' . $change['column'] . ' = {string:default}
2126 2249
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2129,6 +2252,7 @@  discard block
 block discarded – undo
2129 2252
 					'db_error_skip' => true,
2130 2253
 				)
2131 2254
 			);
2255
+		}
2132 2256
 
2133 2257
 		// Do the actual alteration.
2134 2258
 		$smcFunc['db_query']('', '
@@ -2157,8 +2281,9 @@  discard block
 block discarded – undo
2157 2281
 	}
2158 2282
 
2159 2283
 	// Not a column we need to check on?
2160
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2161
-		return;
2284
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2285
+			return;
2286
+	}
2162 2287
 
2163 2288
 	// Break it up you (six|seven).
2164 2289
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2177,13 +2302,13 @@  discard block
 block discarded – undo
2177 2302
 				'new_name' => $temp[2],
2178 2303
 		));
2179 2304
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2180
-		if ($smcFunc['db_num_rows'] != 1)
2181
-			return;
2305
+		if ($smcFunc['db_num_rows'] != 1) {
2306
+					return;
2307
+		}
2182 2308
 
2183 2309
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2184 2310
 		$smcFunc['db_free_result']($request);
2185
-	}
2186
-	else
2311
+	} else
2187 2312
 	{
2188 2313
 		// Do this the old fashion, sure method way.
2189 2314
 		$request = $smcFunc['db_query']('', '
@@ -2194,21 +2319,24 @@  discard block
 block discarded – undo
2194 2319
 		));
2195 2320
 		// Mayday!
2196 2321
 		// !!! 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'] == 0)
2198
-			return;
2322
+		if ($smcFunc['db_num_rows'] == 0) {
2323
+					return;
2324
+		}
2199 2325
 
2200 2326
 		// Oh where, oh where has my little field gone. Oh where can it be...
2201
-		while ($row = $smcFunc['db_query']($request))
2202
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2327
+		while ($row = $smcFunc['db_query']($request)) {
2328
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2203 2329
 			{
2204 2330
 				$current_type = $row['Type'];
2331
+		}
2205 2332
 				break;
2206 2333
 			}
2207 2334
 	}
2208 2335
 
2209 2336
 	// If this doesn't match, the column may of been altered for a reason.
2210
-	if (trim($current_type) != trim($temp[3]))
2211
-		$temp[3] = $current_type;
2337
+	if (trim($current_type) != trim($temp[3])) {
2338
+			$temp[3] = $current_type;
2339
+	}
2212 2340
 
2213 2341
 	// Piece this back together.
2214 2342
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2220,8 +2348,9 @@  discard block
 block discarded – undo
2220 2348
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2221 2349
 	global $step_progress, $is_debug, $upcontext;
2222 2350
 
2223
-	if ($_GET['substep'] < $substep)
2224
-		$_GET['substep'] = $substep;
2351
+	if ($_GET['substep'] < $substep) {
2352
+			$_GET['substep'] = $substep;
2353
+	}
2225 2354
 
2226 2355
 	if ($command_line)
2227 2356
 	{
@@ -2234,29 +2363,33 @@  discard block
 block discarded – undo
2234 2363
 	}
2235 2364
 
2236 2365
 	@set_time_limit(300);
2237
-	if (function_exists('apache_reset_timeout'))
2238
-		@apache_reset_timeout();
2366
+	if (function_exists('apache_reset_timeout')) {
2367
+			@apache_reset_timeout();
2368
+	}
2239 2369
 
2240
-	if (time() - $start_time <= $timeLimitThreshold)
2241
-		return;
2370
+	if (time() - $start_time <= $timeLimitThreshold) {
2371
+			return;
2372
+	}
2242 2373
 
2243 2374
 	// Do we have some custom step progress stuff?
2244 2375
 	if (!empty($step_progress))
2245 2376
 	{
2246 2377
 		$upcontext['substep_progress'] = 0;
2247 2378
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2248
-		if ($step_progress['current'] > $step_progress['total'])
2249
-			$upcontext['substep_progress'] = 99.9;
2250
-		else
2251
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2379
+		if ($step_progress['current'] > $step_progress['total']) {
2380
+					$upcontext['substep_progress'] = 99.9;
2381
+		} else {
2382
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2383
+		}
2252 2384
 
2253 2385
 		// Make it nicely rounded.
2254 2386
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2255 2387
 	}
2256 2388
 
2257 2389
 	// If this is XML we just exit right away!
2258
-	if (isset($_GET['xml']))
2259
-		return upgradeExit();
2390
+	if (isset($_GET['xml'])) {
2391
+			return upgradeExit();
2392
+	}
2260 2393
 
2261 2394
 	// We're going to pause after this!
2262 2395
 	$upcontext['pause'] = true;
@@ -2264,13 +2397,15 @@  discard block
 block discarded – undo
2264 2397
 	$upcontext['query_string'] = '';
2265 2398
 	foreach ($_GET as $k => $v)
2266 2399
 	{
2267
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2268
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2400
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2401
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2402
+		}
2269 2403
 	}
2270 2404
 
2271 2405
 	// Custom warning?
2272
-	if (!empty($custom_warning))
2273
-		$upcontext['custom_warning'] = $custom_warning;
2406
+	if (!empty($custom_warning)) {
2407
+			$upcontext['custom_warning'] = $custom_warning;
2408
+	}
2274 2409
 
2275 2410
 	upgradeExit();
2276 2411
 }
@@ -2285,25 +2420,26 @@  discard block
 block discarded – undo
2285 2420
 	ob_implicit_flush(true);
2286 2421
 	@set_time_limit(600);
2287 2422
 
2288
-	if (!isset($_SERVER['argv']))
2289
-		$_SERVER['argv'] = array();
2423
+	if (!isset($_SERVER['argv'])) {
2424
+			$_SERVER['argv'] = array();
2425
+	}
2290 2426
 	$_GET['maint'] = 1;
2291 2427
 
2292 2428
 	foreach ($_SERVER['argv'] as $i => $arg)
2293 2429
 	{
2294
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2295
-			$_GET['lang'] = $match[1];
2296
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2297
-			continue;
2298
-		elseif ($arg == '--no-maintenance')
2299
-			$_GET['maint'] = 0;
2300
-		elseif ($arg == '--debug')
2301
-			$is_debug = true;
2302
-		elseif ($arg == '--backup')
2303
-			$_POST['backup'] = 1;
2304
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2305
-			$_GET['conv'] = 1;
2306
-		elseif ($i != 0)
2430
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2431
+					$_GET['lang'] = $match[1];
2432
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2433
+					continue;
2434
+		} elseif ($arg == '--no-maintenance') {
2435
+					$_GET['maint'] = 0;
2436
+		} elseif ($arg == '--debug') {
2437
+					$is_debug = true;
2438
+		} elseif ($arg == '--backup') {
2439
+					$_POST['backup'] = 1;
2440
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2441
+					$_GET['conv'] = 1;
2442
+		} elseif ($i != 0)
2307 2443
 		{
2308 2444
 			echo 'SMF Command-line Upgrader
2309 2445
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2317,10 +2453,12 @@  discard block
 block discarded – undo
2317 2453
 		}
2318 2454
 	}
2319 2455
 
2320
-	if (!php_version_check())
2321
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2322
-	if (!db_version_check())
2323
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2456
+	if (!php_version_check()) {
2457
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2458
+	}
2459
+	if (!db_version_check()) {
2460
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2461
+	}
2324 2462
 
2325 2463
 	// Do some checks to make sure they have proper privileges
2326 2464
 	db_extend('packages');
@@ -2335,34 +2473,39 @@  discard block
 block discarded – undo
2335 2473
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2336 2474
 
2337 2475
 	// Sorry... we need CREATE, ALTER and DROP
2338
-	if (!$create || !$alter || !$drop)
2339
-		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);
2476
+	if (!$create || !$alter || !$drop) {
2477
+			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);
2478
+	}
2340 2479
 
2341 2480
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2342 2481
 		&& @file_exists($sourcedir . '/QueryString.php')
2343 2482
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2344
-	if (!$check && !isset($modSettings['smfVersion']))
2345
-		print_error('Error: Some files are missing or out-of-date.', true);
2483
+	if (!$check && !isset($modSettings['smfVersion'])) {
2484
+			print_error('Error: Some files are missing or out-of-date.', true);
2485
+	}
2346 2486
 
2347 2487
 	// Do a quick version spot check.
2348 2488
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2349 2489
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2350
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2351
-		print_error('Error: Some files have not yet been updated properly.');
2490
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2491
+			print_error('Error: Some files have not yet been updated properly.');
2492
+	}
2352 2493
 
2353 2494
 	// Make sure Settings.php is writable.
2354 2495
 		quickFileWritable($boarddir . '/Settings.php');
2355
-	if (!is_writable($boarddir . '/Settings.php'))
2356
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2496
+	if (!is_writable($boarddir . '/Settings.php')) {
2497
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2498
+	}
2357 2499
 
2358 2500
 	// Make sure Settings_bak.php is writable.
2359 2501
 		quickFileWritable($boarddir . '/Settings_bak.php');
2360
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2361
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2502
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2503
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2504
+	}
2362 2505
 
2363
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2364
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2365
-	elseif (isset($modSettings['agreement']))
2506
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2507
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2508
+	} elseif (isset($modSettings['agreement']))
2366 2509
 	{
2367 2510
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2368 2511
 		fwrite($fp, $modSettings['agreement']);
@@ -2372,31 +2515,36 @@  discard block
 block discarded – undo
2372 2515
 	// Make sure Themes is writable.
2373 2516
 	quickFileWritable($modSettings['theme_dir']);
2374 2517
 
2375
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2376
-		print_error('Error: Unable to obtain write access to "Themes".');
2518
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2519
+			print_error('Error: Unable to obtain write access to "Themes".');
2520
+	}
2377 2521
 
2378 2522
 	// Make sure cache directory exists and is writable!
2379 2523
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2380
-	if (!file_exists($cachedir_temp))
2381
-		@mkdir($cachedir_temp);
2524
+	if (!file_exists($cachedir_temp)) {
2525
+			@mkdir($cachedir_temp);
2526
+	}
2382 2527
 
2383 2528
 	// Make sure the cache temp dir is writable.
2384 2529
 	quickFileWritable($cachedir_temp);
2385 2530
 
2386
-	if (!is_writable($cachedir_temp))
2387
-		print_error('Error: Unable to obtain write access to "cache".', true);
2531
+	if (!is_writable($cachedir_temp)) {
2532
+			print_error('Error: Unable to obtain write access to "cache".', true);
2533
+	}
2388 2534
 
2389
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2390
-		print_error('Error: Unable to find language files!', true);
2391
-	else
2535
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2536
+			print_error('Error: Unable to find language files!', true);
2537
+	} else
2392 2538
 	{
2393 2539
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2394 2540
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2395 2541
 
2396
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2397
-			print_error('Error: Language files out of date.', true);
2398
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2399
-			print_error('Error: Install language is missing for selected language.', true);
2542
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2543
+					print_error('Error: Language files out of date.', true);
2544
+		}
2545
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2546
+					print_error('Error: Install language is missing for selected language.', true);
2547
+		}
2400 2548
 
2401 2549
 		// Otherwise include it!
2402 2550
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2415,8 +2563,9 @@  discard block
 block discarded – undo
2415 2563
 	global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js;
2416 2564
 
2417 2565
 	// Done it already?
2418
-	if (!empty($_POST['utf8_done']))
2419
-		return true;
2566
+	if (!empty($_POST['utf8_done'])) {
2567
+			return true;
2568
+	}
2420 2569
 
2421 2570
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2422 2571
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2429,8 +2578,7 @@  discard block
 block discarded – undo
2429 2578
 		);
2430 2579
 
2431 2580
 		return true;
2432
-	}
2433
-	else
2581
+	} else
2434 2582
 	{
2435 2583
 		$upcontext['page_title'] = 'Converting to UTF8';
2436 2584
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2474,8 +2622,9 @@  discard block
 block discarded – undo
2474 2622
 			)
2475 2623
 		);
2476 2624
 		$db_charsets = array();
2477
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2478
-			$db_charsets[] = $row['Charset'];
2625
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2626
+					$db_charsets[] = $row['Charset'];
2627
+		}
2479 2628
 
2480 2629
 		$smcFunc['db_free_result']($request);
2481 2630
 
@@ -2511,13 +2660,15 @@  discard block
 block discarded – undo
2511 2660
 		// If there's a fulltext index, we need to drop it first...
2512 2661
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2513 2662
 		{
2514
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2515
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2663
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2664
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2516 2665
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2666
+			}
2517 2667
 			$smcFunc['db_free_result']($request);
2518 2668
 
2519
-			if (isset($upcontext['fulltext_index']))
2520
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2669
+			if (isset($upcontext['fulltext_index'])) {
2670
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2671
+			}
2521 2672
 		}
2522 2673
 
2523 2674
 		// Drop it and make a note...
@@ -2707,8 +2858,9 @@  discard block
 block discarded – undo
2707 2858
 			$replace = '%field%';
2708 2859
 
2709 2860
 			// Build a huge REPLACE statement...
2710
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2711
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2861
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2862
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2863
+			}
2712 2864
 		}
2713 2865
 
2714 2866
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2718,9 +2870,10 @@  discard block
 block discarded – undo
2718 2870
 		$upcontext['table_count'] = count($queryTables);
2719 2871
 
2720 2872
 		// What ones have we already done?
2721
-		foreach ($queryTables as $id => $table)
2722
-			if ($id < $_GET['substep'])
2873
+		foreach ($queryTables as $id => $table) {
2874
+					if ($id < $_GET['substep'])
2723 2875
 				$upcontext['previous_tables'][] = $table;
2876
+		}
2724 2877
 
2725 2878
 		$upcontext['cur_table_num'] = $_GET['substep'];
2726 2879
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2757,8 +2910,9 @@  discard block
 block discarded – undo
2757 2910
 			nextSubstep($substep);
2758 2911
 
2759 2912
 			// Just to make sure it doesn't time out.
2760
-			if (function_exists('apache_reset_timeout'))
2761
-				@apache_reset_timeout();
2913
+			if (function_exists('apache_reset_timeout')) {
2914
+							@apache_reset_timeout();
2915
+			}
2762 2916
 
2763 2917
 			$table_charsets = array();
2764 2918
 
@@ -2781,8 +2935,9 @@  discard block
 block discarded – undo
2781 2935
 
2782 2936
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2783 2937
 						if ($charset != 'utf8') {
2784
-							if (!isset($table_charsets[$charset]))
2785
-								$table_charsets[$charset] = array();
2938
+							if (!isset($table_charsets[$charset])) {
2939
+															$table_charsets[$charset] = array();
2940
+							}
2786 2941
 
2787 2942
 							$table_charsets[$charset][] = $column_info;
2788 2943
 						}
@@ -2823,10 +2978,11 @@  discard block
 block discarded – undo
2823 2978
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2824 2979
 				{
2825 2980
 					$update = '';
2826
-					foreach ($table_charsets as $charset => $columns)
2827
-						foreach ($columns as $column)
2981
+					foreach ($table_charsets as $charset => $columns) {
2982
+											foreach ($columns as $column)
2828 2983
 							$update .= '
2829 2984
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
2985
+					}
2830 2986
 
2831 2987
 					$smcFunc['db_query']('', '
2832 2988
 						UPDATE {raw:table_name}
@@ -2851,8 +3007,9 @@  discard block
 block discarded – undo
2851 3007
 			// Now do the actual conversion (if still needed).
2852 3008
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2853 3009
 			{
2854
-				if ($command_line)
2855
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3010
+				if ($command_line) {
3011
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3012
+				}
2856 3013
 
2857 3014
 				$smcFunc['db_query']('', '
2858 3015
 					ALTER TABLE {raw:table_name}
@@ -2862,12 +3019,14 @@  discard block
 block discarded – undo
2862 3019
 					)
2863 3020
 				);
2864 3021
 
2865
-				if ($command_line)
2866
-					echo " done.\n";
3022
+				if ($command_line) {
3023
+									echo " done.\n";
3024
+				}
2867 3025
 			}
2868 3026
 			// If this is XML to keep it nice for the user do one table at a time anyway!
2869
-			if (isset($_GET['xml']))
2870
-				return upgradeExit();
3027
+			if (isset($_GET['xml'])) {
3028
+							return upgradeExit();
3029
+			}
2871 3030
 		}
2872 3031
 
2873 3032
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -2896,8 +3055,8 @@  discard block
 block discarded – undo
2896 3055
 		);
2897 3056
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2898 3057
 		{
2899
-			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)
2900
-				$smcFunc['db_query']('', '
3058
+			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) {
3059
+							$smcFunc['db_query']('', '
2901 3060
 					UPDATE {db_prefix}log_actions
2902 3061
 					SET extra = {string:extra}
2903 3062
 					WHERE id_action = {int:current_action}',
@@ -2906,6 +3065,7 @@  discard block
 block discarded – undo
2906 3065
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2907 3066
 					)
2908 3067
 				);
3068
+			}
2909 3069
 		}
2910 3070
 		$smcFunc['db_free_result']($request);
2911 3071
 
@@ -2927,15 +3087,17 @@  discard block
 block discarded – undo
2927 3087
 	// First thing's first - did we already do this?
2928 3088
 	if (!empty($modSettings['json_done']))
2929 3089
 	{
2930
-		if ($command_line)
2931
-			return DeleteUpgrade();
2932
-		else
2933
-			return true;
3090
+		if ($command_line) {
3091
+					return DeleteUpgrade();
3092
+		} else {
3093
+					return true;
3094
+		}
2934 3095
 	}
2935 3096
 
2936 3097
 	// Done it already - js wise?
2937
-	if (!empty($_POST['json_done']))
2938
-		return true;
3098
+	if (!empty($_POST['json_done'])) {
3099
+			return true;
3100
+	}
2939 3101
 
2940 3102
 	// List of tables affected by this function
2941 3103
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2967,12 +3129,14 @@  discard block
 block discarded – undo
2967 3129
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
2968 3130
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2969 3131
 
2970
-	foreach ($keys as $id => $table)
2971
-		if ($id < $_GET['substep'])
3132
+	foreach ($keys as $id => $table) {
3133
+			if ($id < $_GET['substep'])
2972 3134
 			$upcontext['previous_tables'][] = $table;
3135
+	}
2973 3136
 
2974
-	if ($command_line)
2975
-		echo 'Converting data from serialize() to json_encode().';
3137
+	if ($command_line) {
3138
+			echo 'Converting data from serialize() to json_encode().';
3139
+	}
2976 3140
 
2977 3141
 	if (!$support_js || isset($_GET['xml']))
2978 3142
 	{
@@ -3012,8 +3176,9 @@  discard block
 block discarded – undo
3012 3176
 
3013 3177
 				// Loop through and fix these...
3014 3178
 				$new_settings = array();
3015
-				if ($command_line)
3016
-					echo "\n" . 'Fixing some settings...';
3179
+				if ($command_line) {
3180
+									echo "\n" . 'Fixing some settings...';
3181
+				}
3017 3182
 
3018 3183
 				foreach ($serialized_settings as $var)
3019 3184
 				{
@@ -3021,22 +3186,24 @@  discard block
 block discarded – undo
3021 3186
 					{
3022 3187
 						// Attempt to unserialize the setting
3023 3188
 						$temp = @safe_unserialize($modSettings[$var]);
3024
-						if (!$temp && $command_line)
3025
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3026
-						elseif ($temp !== false)
3027
-							$new_settings[$var] = json_encode($temp);
3189
+						if (!$temp && $command_line) {
3190
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3191
+						} elseif ($temp !== false) {
3192
+													$new_settings[$var] = json_encode($temp);
3193
+						}
3028 3194
 					}
3029 3195
 				}
3030 3196
 
3031 3197
 				// Update everything at once
3032
-				if (!function_exists('cache_put_data'))
3033
-					require_once($sourcedir . '/Load.php');
3198
+				if (!function_exists('cache_put_data')) {
3199
+									require_once($sourcedir . '/Load.php');
3200
+				}
3034 3201
 				updateSettings($new_settings, true);
3035 3202
 
3036
-				if ($command_line)
3037
-					echo ' done.';
3038
-			}
3039
-			elseif ($table == 'themes')
3203
+				if ($command_line) {
3204
+									echo ' done.';
3205
+				}
3206
+			} elseif ($table == 'themes')
3040 3207
 			{
3041 3208
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3042 3209
 				$query = $smcFunc['db_query']('', '
@@ -3055,10 +3222,11 @@  discard block
 block discarded – undo
3055 3222
 
3056 3223
 						if ($command_line)
3057 3224
 						{
3058
-							if ($temp === false)
3059
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3060
-							else
3061
-								echo "\n" . 'Fixing admin preferences...';
3225
+							if ($temp === false) {
3226
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3227
+							} else {
3228
+															echo "\n" . 'Fixing admin preferences...';
3229
+							}
3062 3230
 						}
3063 3231
 
3064 3232
 						if ($temp !== false)
@@ -3080,15 +3248,15 @@  discard block
 block discarded – undo
3080 3248
 								)
3081 3249
 							);
3082 3250
 
3083
-							if ($command_line)
3084
-								echo ' done.';
3251
+							if ($command_line) {
3252
+															echo ' done.';
3253
+							}
3085 3254
 						}
3086 3255
 					}
3087 3256
 
3088 3257
 					$smcFunc['db_free_result']($query);
3089 3258
 				}
3090
-			}
3091
-			else
3259
+			} else
3092 3260
 			{
3093 3261
 				// First item is always the key...
3094 3262
 				$key = $info[0];
@@ -3099,8 +3267,7 @@  discard block
 block discarded – undo
3099 3267
 				{
3100 3268
 					$col_select = $info[1];
3101 3269
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3102
-				}
3103
-				else
3270
+				} else
3104 3271
 				{
3105 3272
 					$col_select = implode(', ', $info);
3106 3273
 				}
@@ -3133,8 +3300,7 @@  discard block
 block discarded – undo
3133 3300
 								if ($temp === false && $command_line)
3134 3301
 								{
3135 3302
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3136
-								}
3137
-								else
3303
+								} else
3138 3304
 								{
3139 3305
 									$row[$col] = json_encode($temp);
3140 3306
 
@@ -3159,16 +3325,18 @@  discard block
 block discarded – undo
3159 3325
 						}
3160 3326
 					}
3161 3327
 
3162
-					if ($command_line)
3163
-						echo ' done.';
3328
+					if ($command_line) {
3329
+											echo ' done.';
3330
+					}
3164 3331
 
3165 3332
 					// Free up some memory...
3166 3333
 					$smcFunc['db_free_result']($query);
3167 3334
 				}
3168 3335
 			}
3169 3336
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3170
-			if (isset($_GET['xml']))
3171
-				return upgradeExit();
3337
+			if (isset($_GET['xml'])) {
3338
+							return upgradeExit();
3339
+			}
3172 3340
 		}
3173 3341
 
3174 3342
 		if ($command_line)
@@ -3183,8 +3351,9 @@  discard block
 block discarded – undo
3183 3351
 
3184 3352
 		$_GET['substep'] = 0;
3185 3353
 		// Make sure we move on!
3186
-		if ($command_line)
3187
-			return DeleteUpgrade();
3354
+		if ($command_line) {
3355
+					return DeleteUpgrade();
3356
+		}
3188 3357
 
3189 3358
 		return true;
3190 3359
 	}
@@ -3204,14 +3373,16 @@  discard block
 block discarded – undo
3204 3373
 	global $upcontext, $txt, $settings;
3205 3374
 
3206 3375
 	// Don't call me twice!
3207
-	if (!empty($upcontext['chmod_called']))
3208
-		return;
3376
+	if (!empty($upcontext['chmod_called'])) {
3377
+			return;
3378
+	}
3209 3379
 
3210 3380
 	$upcontext['chmod_called'] = true;
3211 3381
 
3212 3382
 	// Nothing?
3213
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3214
-		return;
3383
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3384
+			return;
3385
+	}
3215 3386
 
3216 3387
 	// Was it a problem with Windows?
3217 3388
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3243,11 +3414,12 @@  discard block
 block discarded – undo
3243 3414
 					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\');
3244 3415
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3245 3416
 
3246
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3247
-		echo '
3417
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3418
+			echo '
3248 3419
 					content.write(\'<hr>\n\t\t\t\');
3249 3420
 					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\');
3250 3421
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3422
+	}
3251 3423
 
3252 3424
 	echo '
3253 3425
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3255,17 +3427,19 @@  discard block
 block discarded – undo
3255 3427
 				}
3256 3428
 			</script>';
3257 3429
 
3258
-	if (!empty($upcontext['chmod']['ftp_error']))
3259
-		echo '
3430
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3431
+			echo '
3260 3432
 			<div class="error_message red">
3261 3433
 				The following error was encountered when trying to connect:<br><br>
3262 3434
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3263 3435
 			</div>
3264 3436
 			<br>';
3437
+	}
3265 3438
 
3266
-	if (empty($upcontext['chmod_in_form']))
3267
-		echo '
3439
+	if (empty($upcontext['chmod_in_form'])) {
3440
+			echo '
3268 3441
 	<form action="', $upcontext['form_url'], '" method="post">';
3442
+	}
3269 3443
 
3270 3444
 	echo '
3271 3445
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3300,10 +3474,11 @@  discard block
 block discarded – undo
3300 3474
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
3301 3475
 	</div>';
3302 3476
 
3303
-	if (empty($upcontext['chmod_in_form']))
3304
-		echo '
3477
+	if (empty($upcontext['chmod_in_form'])) {
3478
+			echo '
3305 3479
 	</form>';
3306
-}
3480
+	}
3481
+	}
3307 3482
 
3308 3483
 function template_upgrade_above()
3309 3484
 {
@@ -3363,9 +3538,10 @@  discard block
 block discarded – undo
3363 3538
 				<h2>', $txt['upgrade_progress'], '</h2>
3364 3539
 				<ul>';
3365 3540
 
3366
-	foreach ($upcontext['steps'] as $num => $step)
3367
-		echo '
3541
+	foreach ($upcontext['steps'] as $num => $step) {
3542
+			echo '
3368 3543
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3544
+	}
3369 3545
 
3370 3546
 	echo '
3371 3547
 					</ul>
@@ -3378,8 +3554,8 @@  discard block
 block discarded – undo
3378 3554
 				</div>
3379 3555
 			</div>';
3380 3556
 
3381
-	if (isset($upcontext['step_progress']))
3382
-		echo '
3557
+	if (isset($upcontext['step_progress'])) {
3558
+			echo '
3383 3559
 				<br>
3384 3560
 				<br>
3385 3561
 				<div id="progress_bar_step">
@@ -3388,6 +3564,7 @@  discard block
 block discarded – undo
3388 3564
 						<span>', $txt['upgrade_step_progress'], '</span>
3389 3565
 					</div>
3390 3566
 				</div>';
3567
+	}
3391 3568
 
3392 3569
 	echo '
3393 3570
 				<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>
@@ -3418,32 +3595,36 @@  discard block
 block discarded – undo
3418 3595
 {
3419 3596
 	global $upcontext, $txt;
3420 3597
 
3421
-	if (!empty($upcontext['pause']))
3422
-		echo '
3598
+	if (!empty($upcontext['pause'])) {
3599
+			echo '
3423 3600
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3424 3601
 
3425 3602
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3426 3603
 								<h3>
3427 3604
 									', $txt['upgrade_paused_overload'], '
3428 3605
 								</h3>';
3606
+	}
3429 3607
 
3430
-	if (!empty($upcontext['custom_warning']))
3431
-		echo '
3608
+	if (!empty($upcontext['custom_warning'])) {
3609
+			echo '
3432 3610
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3433 3611
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3434 3612
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3435 3613
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3436 3614
 								</div>';
3615
+	}
3437 3616
 
3438 3617
 	echo '
3439 3618
 								<div class="righttext" style="margin: 1ex;">';
3440 3619
 
3441
-	if (!empty($upcontext['continue']))
3442
-		echo '
3620
+	if (!empty($upcontext['continue'])) {
3621
+			echo '
3443 3622
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
3444
-	if (!empty($upcontext['skip']))
3445
-		echo '
3623
+	}
3624
+	if (!empty($upcontext['skip'])) {
3625
+			echo '
3446 3626
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
3627
+	}
3447 3628
 
3448 3629
 	echo '
3449 3630
 								</div>
@@ -3493,11 +3674,12 @@  discard block
 block discarded – undo
3493 3674
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3494 3675
 	<smf>';
3495 3676
 
3496
-	if (!empty($upcontext['get_data']))
3497
-		foreach ($upcontext['get_data'] as $k => $v)
3677
+	if (!empty($upcontext['get_data'])) {
3678
+			foreach ($upcontext['get_data'] as $k => $v)
3498 3679
 			echo '
3499 3680
 		<get key="', $k, '">', $v, '</get>';
3500
-}
3681
+	}
3682
+	}
3501 3683
 
3502 3684
 function template_xml_below()
3503 3685
 {
@@ -3538,8 +3720,8 @@  discard block
 block discarded – undo
3538 3720
 	template_chmod();
3539 3721
 
3540 3722
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3541
-	if ($upcontext['is_large_forum'])
3542
-		echo '
3723
+	if ($upcontext['is_large_forum']) {
3724
+			echo '
3543 3725
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3544 3726
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3545 3727
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3547,10 +3729,11 @@  discard block
 block discarded – undo
3547 3729
 				', $txt['upgrade_warning_lots_data'], '
3548 3730
 			</div>
3549 3731
 		</div>';
3732
+	}
3550 3733
 
3551 3734
 	// A warning message?
3552
-	if (!empty($upcontext['warning']))
3553
-		echo '
3735
+	if (!empty($upcontext['warning'])) {
3736
+			echo '
3554 3737
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3555 3738
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3556 3739
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3558,6 +3741,7 @@  discard block
 block discarded – undo
3558 3741
 				', $upcontext['warning'], '
3559 3742
 			</div>
3560 3743
 		</div>';
3744
+	}
3561 3745
 
3562 3746
 	// Paths are incorrect?
3563 3747
 	echo '
@@ -3573,20 +3757,22 @@  discard block
 block discarded – undo
3573 3757
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3574 3758
 	{
3575 3759
 		$ago = time() - $upcontext['started'];
3576
-		if ($ago < 60)
3577
-			$ago = $ago . ' seconds';
3578
-		elseif ($ago < 3600)
3579
-			$ago = (int) ($ago / 60) . ' minutes';
3580
-		else
3581
-			$ago = (int) ($ago / 3600) . ' hours';
3760
+		if ($ago < 60) {
3761
+					$ago = $ago . ' seconds';
3762
+		} elseif ($ago < 3600) {
3763
+					$ago = (int) ($ago / 60) . ' minutes';
3764
+		} else {
3765
+					$ago = (int) ($ago / 3600) . ' hours';
3766
+		}
3582 3767
 
3583 3768
 		$active = time() - $upcontext['updated'];
3584
-		if ($active < 60)
3585
-			$updated = $active . ' seconds';
3586
-		elseif ($active < 3600)
3587
-			$updated = (int) ($active / 60) . ' minutes';
3588
-		else
3589
-			$updated = (int) ($active / 3600) . ' hours';
3769
+		if ($active < 60) {
3770
+					$updated = $active . ' seconds';
3771
+		} elseif ($active < 3600) {
3772
+					$updated = (int) ($active / 60) . ' minutes';
3773
+		} else {
3774
+					$updated = (int) ($active / 3600) . ' hours';
3775
+		}
3590 3776
 
3591 3777
 		echo '
3592 3778
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3595,16 +3781,18 @@  discard block
 block discarded – undo
3595 3781
 			<div style="padding-left: 6ex;">
3596 3782
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3597 3783
 
3598
-		if ($active < 600)
3599
-			echo '
3784
+		if ($active < 600) {
3785
+					echo '
3600 3786
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3787
+		}
3601 3788
 
3602
-		if ($active > $upcontext['inactive_timeout'])
3603
-			echo '
3789
+		if ($active > $upcontext['inactive_timeout']) {
3790
+					echo '
3604 3791
 				<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.';
3605
-		else
3606
-			echo '
3792
+		} else {
3793
+					echo '
3607 3794
 				<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!');
3795
+		}
3608 3796
 
3609 3797
 		echo '
3610 3798
 			</div>
@@ -3620,9 +3808,10 @@  discard block
 block discarded – undo
3620 3808
 					<td>
3621 3809
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
3622 3810
 
3623
-	if (!empty($upcontext['username_incorrect']))
3624
-		echo '
3811
+	if (!empty($upcontext['username_incorrect'])) {
3812
+			echo '
3625 3813
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3814
+	}
3626 3815
 
3627 3816
 	echo '
3628 3817
 					</td>
@@ -3633,9 +3822,10 @@  discard block
 block discarded – undo
3633 3822
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
3634 3823
 						<input type="hidden" name="hash_passwrd" value="">';
3635 3824
 
3636
-	if (!empty($upcontext['password_failed']))
3637
-		echo '
3825
+	if (!empty($upcontext['password_failed'])) {
3826
+			echo '
3638 3827
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3828
+	}
3639 3829
 
3640 3830
 	echo '
3641 3831
 					</td>
@@ -3706,8 +3896,8 @@  discard block
 block discarded – undo
3706 3896
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3707 3897
 
3708 3898
 	// Warning message?
3709
-	if (!empty($upcontext['upgrade_options_warning']))
3710
-		echo '
3899
+	if (!empty($upcontext['upgrade_options_warning'])) {
3900
+			echo '
3711 3901
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3712 3902
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3713 3903
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3715,6 +3905,7 @@  discard block
 block discarded – undo
3715 3905
 				', $upcontext['upgrade_options_warning'], '
3716 3906
 			</div>
3717 3907
 		</div>';
3908
+	}
3718 3909
 
3719 3910
 	echo '
3720 3911
 				<table>
@@ -3757,8 +3948,8 @@  discard block
 block discarded – undo
3757 3948
 						</td>
3758 3949
 					</tr>';
3759 3950
 
3760
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3761
-		echo '
3951
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3952
+			echo '
3762 3953
 					<tr valign="top">
3763 3954
 						<td width="2%">
3764 3955
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -3767,6 +3958,7 @@  discard block
 block discarded – undo
3767 3958
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3768 3959
 						</td>
3769 3960
 					</tr>';
3961
+	}
3770 3962
 
3771 3963
 	echo '
3772 3964
 					<tr valign="top">
@@ -3804,10 +3996,11 @@  discard block
 block discarded – undo
3804 3996
 			</div>';
3805 3997
 
3806 3998
 	// Dont any tables so far?
3807
-	if (!empty($upcontext['previous_tables']))
3808
-		foreach ($upcontext['previous_tables'] as $table)
3999
+	if (!empty($upcontext['previous_tables'])) {
4000
+			foreach ($upcontext['previous_tables'] as $table)
3809 4001
 			echo '
3810 4002
 			<br>Completed Table: &quot;', $table, '&quot;.';
4003
+	}
3811 4004
 
3812 4005
 	echo '
3813 4006
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3844,12 +4037,13 @@  discard block
 block discarded – undo
3844 4037
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3845 4038
 
3846 4039
 		// If debug flood the screen.
3847
-		if ($is_debug)
3848
-			echo '
4040
+		if ($is_debug) {
4041
+					echo '
3849 4042
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3850 4043
 
3851 4044
 				if (document.getElementById(\'debug_section\').scrollHeight)
3852 4045
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4046
+		}
3853 4047
 
3854 4048
 		echo '
3855 4049
 				// Get the next update...
@@ -3882,8 +4076,9 @@  discard block
 block discarded – undo
3882 4076
 {
3883 4077
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3884 4078
 
3885
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3886
-		$is_debug = true;
4079
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4080
+			$is_debug = true;
4081
+	}
3887 4082
 
3888 4083
 	echo '
3889 4084
 		<h3>Executing database changes</h3>
@@ -3898,8 +4093,9 @@  discard block
 block discarded – undo
3898 4093
 	{
3899 4094
 		foreach ($upcontext['actioned_items'] as $num => $item)
3900 4095
 		{
3901
-			if ($num != 0)
3902
-				echo ' Successful!';
4096
+			if ($num != 0) {
4097
+							echo ' Successful!';
4098
+			}
3903 4099
 			echo '<br>' . $item;
3904 4100
 		}
3905 4101
 		if (!empty($upcontext['changes_complete']))
@@ -3912,28 +4108,32 @@  discard block
 block discarded – undo
3912 4108
 				$seconds = intval($active % 60);
3913 4109
 
3914 4110
 				$totalTime = '';
3915
-				if ($hours > 0)
3916
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3917
-				if ($minutes > 0)
3918
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3919
-				if ($seconds > 0)
3920
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4111
+				if ($hours > 0) {
4112
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4113
+				}
4114
+				if ($minutes > 0) {
4115
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4116
+				}
4117
+				if ($seconds > 0) {
4118
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4119
+				}
3921 4120
 			}
3922 4121
 
3923
-			if ($is_debug && !empty($totalTime))
3924
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3925
-			else
3926
-				echo ' Successful!<br><br>';
4122
+			if ($is_debug && !empty($totalTime)) {
4123
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4124
+			} else {
4125
+							echo ' Successful!<br><br>';
4126
+			}
3927 4127
 
3928 4128
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3929 4129
 		}
3930
-	}
3931
-	else
4130
+	} else
3932 4131
 	{
3933 4132
 		// Tell them how many files we have in total.
3934
-		if ($upcontext['file_count'] > 1)
3935
-			echo '
4133
+		if ($upcontext['file_count'] > 1) {
4134
+					echo '
3936 4135
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4136
+		}
3937 4137
 
3938 4138
 		echo '
3939 4139
 		<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>
@@ -3949,19 +4149,23 @@  discard block
 block discarded – undo
3949 4149
 				$seconds = intval($active % 60);
3950 4150
 
3951 4151
 				$totalTime = '';
3952
-				if ($hours > 0)
3953
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3954
-				if ($minutes > 0)
3955
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3956
-				if ($seconds > 0)
3957
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4152
+				if ($hours > 0) {
4153
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4154
+				}
4155
+				if ($minutes > 0) {
4156
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4157
+				}
4158
+				if ($seconds > 0) {
4159
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4160
+				}
3958 4161
 			}
3959 4162
 
3960 4163
 			echo '
3961 4164
 			<br><span id="upgradeCompleted">';
3962 4165
 
3963
-			if (!empty($totalTime))
3964
-				echo 'Completed in ', $totalTime, '<br>';
4166
+			if (!empty($totalTime)) {
4167
+							echo 'Completed in ', $totalTime, '<br>';
4168
+			}
3965 4169
 
3966 4170
 			echo '</span>
3967 4171
 			<div id="debug_section" style="height: 59px; overflow: auto;">
@@ -3998,9 +4202,10 @@  discard block
 block discarded – undo
3998 4202
 			var getData = "";
3999 4203
 			var debugItems = ', $upcontext['debug_items'], ';';
4000 4204
 
4001
-		if ($is_debug)
4002
-			echo '
4205
+		if ($is_debug) {
4206
+					echo '
4003 4207
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4208
+		}
4004 4209
 
4005 4210
 		echo '
4006 4211
 			function getNextItem()
@@ -4040,9 +4245,10 @@  discard block
 block discarded – undo
4040 4245
 						document.getElementById("error_block").style.display = "";
4041 4246
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4042 4247
 
4043
-	if ($is_debug)
4044
-		echo '
4248
+	if ($is_debug) {
4249
+			echo '
4045 4250
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4251
+	}
4046 4252
 
4047 4253
 	echo '
4048 4254
 					}
@@ -4063,9 +4269,10 @@  discard block
 block discarded – undo
4063 4269
 						document.getElementById("error_block").style.display = "";
4064 4270
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4065 4271
 
4066
-	if ($is_debug)
4067
-		echo '
4272
+	if ($is_debug) {
4273
+			echo '
4068 4274
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4275
+	}
4069 4276
 
4070 4277
 	echo '
4071 4278
 					}
@@ -4124,8 +4331,8 @@  discard block
 block discarded – undo
4124 4331
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4125 4332
 				{';
4126 4333
 
4127
-		if ($is_debug)
4128
-			echo '
4334
+		if ($is_debug) {
4335
+					echo '
4129 4336
 					document.getElementById(\'debug_section\').style.display = "none";
4130 4337
 
4131 4338
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4143,6 +4350,7 @@  discard block
 block discarded – undo
4143 4350
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4144 4351
 
4145 4352
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4353
+		}
4146 4354
 
4147 4355
 		echo '
4148 4356
 
@@ -4150,9 +4358,10 @@  discard block
 block discarded – undo
4150 4358
 					document.getElementById(\'contbutt\').disabled = 0;
4151 4359
 					document.getElementById(\'database_done\').value = 1;';
4152 4360
 
4153
-		if ($upcontext['file_count'] > 1)
4154
-			echo '
4361
+		if ($upcontext['file_count'] > 1) {
4362
+					echo '
4155 4363
 					document.getElementById(\'info1\').style.display = "none";';
4364
+		}
4156 4365
 
4157 4366
 		echo '
4158 4367
 					document.getElementById(\'info2\').style.display = "none";
@@ -4165,9 +4374,10 @@  discard block
 block discarded – undo
4165 4374
 					lastItem = 0;
4166 4375
 					prevFile = curFile;';
4167 4376
 
4168
-		if ($is_debug)
4169
-			echo '
4377
+		if ($is_debug) {
4378
+					echo '
4170 4379
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4380
+		}
4171 4381
 
4172 4382
 		echo '
4173 4383
 					getNextItem();
@@ -4175,8 +4385,8 @@  discard block
 block discarded – undo
4175 4385
 				}';
4176 4386
 
4177 4387
 		// If debug scroll the screen.
4178
-		if ($is_debug)
4179
-			echo '
4388
+		if ($is_debug) {
4389
+					echo '
4180 4390
 				if (iLastSubStepProgress == -1)
4181 4391
 				{
4182 4392
 					// Give it consistent dots.
@@ -4195,6 +4405,7 @@  discard block
 block discarded – undo
4195 4405
 
4196 4406
 				if (document.getElementById(\'debug_section\').scrollHeight)
4197 4407
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4408
+		}
4198 4409
 
4199 4410
 		echo '
4200 4411
 				// Update the page.
@@ -4255,9 +4466,10 @@  discard block
 block discarded – undo
4255 4466
 			}';
4256 4467
 
4257 4468
 		// Start things off assuming we've not errored.
4258
-		if (empty($upcontext['error_message']))
4259
-			echo '
4469
+		if (empty($upcontext['error_message'])) {
4470
+					echo '
4260 4471
 			getNextItem();';
4472
+		}
4261 4473
 
4262 4474
 		echo '
4263 4475
 		//# sourceURL=dynamicScript-dbch.js
@@ -4275,18 +4487,21 @@  discard block
 block discarded – undo
4275 4487
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4276 4488
 	<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>';
4277 4489
 
4278
-	if (!empty($upcontext['error_message']))
4279
-		echo '
4490
+	if (!empty($upcontext['error_message'])) {
4491
+			echo '
4280 4492
 	<error>', $upcontext['error_message'], '</error>';
4493
+	}
4281 4494
 
4282
-	if (!empty($upcontext['error_string']))
4283
-		echo '
4495
+	if (!empty($upcontext['error_string'])) {
4496
+			echo '
4284 4497
 	<sql>', $upcontext['error_string'], '</sql>';
4498
+	}
4285 4499
 
4286
-	if ($is_debug)
4287
-		echo '
4500
+	if ($is_debug) {
4501
+			echo '
4288 4502
 	<curtime>', time(), '</curtime>';
4289
-}
4503
+	}
4504
+	}
4290 4505
 
4291 4506
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4292 4507
 function template_convert_utf8()
@@ -4305,18 +4520,20 @@  discard block
 block discarded – undo
4305 4520
 			</div>';
4306 4521
 
4307 4522
 	// Done any tables so far?
4308
-	if (!empty($upcontext['previous_tables']))
4309
-		foreach ($upcontext['previous_tables'] as $table)
4523
+	if (!empty($upcontext['previous_tables'])) {
4524
+			foreach ($upcontext['previous_tables'] as $table)
4310 4525
 			echo '
4311 4526
 			<br>Completed Table: &quot;', $table, '&quot;.';
4527
+	}
4312 4528
 
4313 4529
 	echo '
4314 4530
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4315 4531
 
4316 4532
 	// If we dropped their index, let's let them know
4317
-	if ($upcontext['dropping_index'])
4318
-		echo '
4533
+	if ($upcontext['dropping_index']) {
4534
+			echo '
4319 4535
 				<br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>';
4536
+	}
4320 4537
 
4321 4538
 	// Completion notification
4322 4539
 	echo '
@@ -4353,12 +4570,13 @@  discard block
 block discarded – undo
4353 4570
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4354 4571
 
4355 4572
 		// If debug flood the screen.
4356
-		if ($is_debug)
4357
-			echo '
4573
+		if ($is_debug) {
4574
+					echo '
4358 4575
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4359 4576
 
4360 4577
 				if (document.getElementById(\'debug_section\').scrollHeight)
4361 4578
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4579
+		}
4362 4580
 
4363 4581
 		echo '
4364 4582
 				// Get the next update...
@@ -4406,19 +4624,21 @@  discard block
 block discarded – undo
4406 4624
 			</div>';
4407 4625
 
4408 4626
 	// Dont any tables so far?
4409
-	if (!empty($upcontext['previous_tables']))
4410
-		foreach ($upcontext['previous_tables'] as $table)
4627
+	if (!empty($upcontext['previous_tables'])) {
4628
+			foreach ($upcontext['previous_tables'] as $table)
4411 4629
 			echo '
4412 4630
 			<br>Completed Table: &quot;', $table, '&quot;.';
4631
+	}
4413 4632
 
4414 4633
 	echo '
4415 4634
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4416 4635
 			<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>';
4417 4636
 
4418 4637
 	// Try to make sure substep was reset.
4419
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4420
-		echo '
4638
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4639
+			echo '
4421 4640
 			<input type="hidden" name="substep" id="substep" value="0">';
4641
+	}
4422 4642
 
4423 4643
 	// Continue please!
4424 4644
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4451,12 +4671,13 @@  discard block
 block discarded – undo
4451 4671
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4452 4672
 
4453 4673
 		// If debug flood the screen.
4454
-		if ($is_debug)
4455
-			echo '
4674
+		if ($is_debug) {
4675
+					echo '
4456 4676
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4457 4677
 
4458 4678
 				if (document.getElementById(\'debug_section\').scrollHeight)
4459 4679
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4680
+		}
4460 4681
 
4461 4682
 		echo '
4462 4683
 				// Get the next update...
@@ -4492,8 +4713,8 @@  discard block
 block discarded – undo
4492 4713
 	<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>
4493 4714
 	<form action="', $boardurl, '/index.php">';
4494 4715
 
4495
-	if (!empty($upcontext['can_delete_script']))
4496
-		echo '
4716
+	if (!empty($upcontext['can_delete_script'])) {
4717
+			echo '
4497 4718
 			<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>
4498 4719
 			<script>
4499 4720
 				function doTheDelete(theCheck)
@@ -4505,6 +4726,7 @@  discard block
 block discarded – undo
4505 4726
 				}
4506 4727
 			</script>
4507 4728
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4729
+	}
4508 4730
 
4509 4731
 	$active = time() - $upcontext['started'];
4510 4732
 	$hours = floor($active / 3600);
@@ -4514,16 +4736,20 @@  discard block
 block discarded – undo
4514 4736
 	if ($is_debug)
4515 4737
 	{
4516 4738
 		$totalTime = '';
4517
-		if ($hours > 0)
4518
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4519
-		if ($minutes > 0)
4520
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4521
-		if ($seconds > 0)
4522
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4739
+		if ($hours > 0) {
4740
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4741
+		}
4742
+		if ($minutes > 0) {
4743
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4744
+		}
4745
+		if ($seconds > 0) {
4746
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4747
+		}
4523 4748
 	}
4524 4749
 
4525
-	if ($is_debug && !empty($totalTime))
4526
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4750
+	if ($is_debug && !empty($totalTime)) {
4751
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4752
+	}
4527 4753
 
4528 4754
 	echo '<br>
4529 4755
 			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>
@@ -4550,8 +4776,9 @@  discard block
 block discarded – undo
4550 4776
 
4551 4777
 	$current_substep = $_GET['substep'];
4552 4778
 
4553
-	if (empty($_GET['a']))
4554
-		$_GET['a'] = 0;
4779
+	if (empty($_GET['a'])) {
4780
+			$_GET['a'] = 0;
4781
+	}
4555 4782
 	$step_progress['name'] = 'Converting ips';
4556 4783
 	$step_progress['current'] = $_GET['a'];
4557 4784
 
@@ -4594,16 +4821,19 @@  discard block
 block discarded – undo
4594 4821
 				'empty' => '',
4595 4822
 				'limit' => $limit,
4596 4823
 		));
4597
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4598
-			$arIp[] = $row[$oldCol];
4824
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4825
+					$arIp[] = $row[$oldCol];
4826
+		}
4599 4827
 		$smcFunc['db_free_result']($request);
4600 4828
 
4601 4829
 		// Special case, null ip could keep us in a loop.
4602
-		if (is_null($arIp[0]))
4603
-			unset($arIp[0]);
4830
+		if (is_null($arIp[0])) {
4831
+					unset($arIp[0]);
4832
+		}
4604 4833
 
4605
-		if (empty($arIp))
4606
-			$is_done = true;
4834
+		if (empty($arIp)) {
4835
+					$is_done = true;
4836
+		}
4607 4837
 
4608 4838
 		$updates = array();
4609 4839
 		$cases = array();
@@ -4612,16 +4842,18 @@  discard block
 block discarded – undo
4612 4842
 		{
4613 4843
 			$arIp[$i] = trim($arIp[$i]);
4614 4844
 
4615
-			if (empty($arIp[$i]))
4616
-				continue;
4845
+			if (empty($arIp[$i])) {
4846
+							continue;
4847
+			}
4617 4848
 
4618 4849
 			$updates['ip' . $i] = $arIp[$i];
4619 4850
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4620 4851
 
4621 4852
 			if ($setSize > 0 && $i % $setSize === 0)
4622 4853
 			{
4623
-				if (count($updates) == 1)
4624
-					continue;
4854
+				if (count($updates) == 1) {
4855
+									continue;
4856
+				}
4625 4857
 
4626 4858
 				$updates['whereSet'] = array_values($updates);
4627 4859
 				$smcFunc['db_query']('', '
@@ -4655,8 +4887,7 @@  discard block
 block discarded – undo
4655 4887
 							'ip' => $ip
4656 4888
 					));
4657 4889
 				}
4658
-			}
4659
-			else
4890
+			} else
4660 4891
 			{
4661 4892
 				$updates['whereSet'] = array_values($updates);
4662 4893
 				$smcFunc['db_query']('', '
@@ -4670,9 +4901,9 @@  discard block
 block discarded – undo
4670 4901
 					$updates
4671 4902
 				);
4672 4903
 			}
4904
+		} else {
4905
+					$is_done = true;
4673 4906
 		}
4674
-		else
4675
-			$is_done = true;
4676 4907
 
4677 4908
 		$_GET['a'] += $limit;
4678 4909
 		$step_progress['current'] = $_GET['a'];
@@ -4698,10 +4929,11 @@  discard block
 block discarded – undo
4698 4929
 
4699 4930
  	$columns = $smcFunc['db_list_columns']($targetTable, true);
4700 4931
 
4701
-	if (isset($columns[$column]))
4702
-		return $columns[$column];
4703
-	else
4704
-		return null;
4705
-}
4932
+	if (isset($columns[$column])) {
4933
+			return $columns[$column];
4934
+	} else {
4935
+			return null;
4936
+	}
4937
+	}
4706 4938
 
4707 4939
 ?>
4708 4940
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/News.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -540,6 +540,7 @@
 block discarded – undo
540 540
  * @param string $xml_format The format to use ('atom', 'rss', 'rss2' or empty for plain XML)
541 541
  * @param array $forceCdataKeys A list of keys on which to force cdata wrapping (used by mods, maybe)
542 542
  * @param array $nsKeys Key-value pairs of namespace prefixes to pass to cdata_parse() (used by mods, maybe)
543
+ * @param string $tag
543 544
  */
544 545
 function dumpTags($data, $i, $tag = null, $xml_format = '', $forceCdataKeys = array(), $nsKeys = array())
545 546
 {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 			{
863 863
 				uasort($loaded_attachments, function($a, $b) {
864 864
 					if ($a['filesize'] == $b['filesize'])
865
-					        return 0;
865
+							return 0;
866 866
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
867 867
 				});
868 868
 			}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 			{
1273 1273
 				uasort($loaded_attachments, function($a, $b) {
1274 1274
 					if ($a['filesize'] == $b['filesize'])
1275
-					        return 0;
1275
+							return 0;
1276 1276
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
1277 1277
 				});
1278 1278
 			}
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		$smcFunc['db_free_result']($request);
166 166
 
167 167
 		$feed_meta['title'] = ' - ' . strip_tags($board_info['name']);
168
-		$feed_meta['source'] .= '?board=' . $board . '.0' ;
168
+		$feed_meta['source'] .= '?board=' . $board . '.0';
169 169
 
170 170
 		$query_this_board = 'b.id_board = ' . $board;
171 171
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
 		foreach ($xml_data as $item)
391 391
 		{
392
-			$link = array_filter($item['content'], function ($e) { return ($e['tag'] == 'link'); });
392
+			$link = array_filter($item['content'], function($e) { return ($e['tag'] == 'link'); });
393 393
 			$link = array_pop($link);
394 394
 
395 395
 			echo '
Please login to merge, or discard this patch.
Braces   +226 added lines, -185 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Outputs xml data representing recent information or a profile.
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
 	global $query_this_board, $smcFunc, $forum_version, $settings;
38 39
 
39 40
 	// If it's not enabled, die.
40
-	if (empty($modSettings['xmlnews_enable']))
41
-		obExit(false);
41
+	if (empty($modSettings['xmlnews_enable'])) {
42
+			obExit(false);
43
+	}
42 44
 
43 45
 	loadLanguage('Stats');
44 46
 
@@ -64,8 +66,9 @@  discard block
 block discarded – undo
64 66
 	if (!empty($_REQUEST['c']) && empty($board))
65 67
 	{
66 68
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
67
-		foreach ($_REQUEST['c'] as $i => $c)
68
-			$_REQUEST['c'][$i] = (int) $c;
69
+		foreach ($_REQUEST['c'] as $i => $c) {
70
+					$_REQUEST['c'][$i] = (int) $c;
71
+		}
69 72
 
70 73
 		if (count($_REQUEST['c']) == 1)
71 74
 		{
@@ -101,18 +104,20 @@  discard block
 block discarded – undo
101 104
 		}
102 105
 		$smcFunc['db_free_result']($request);
103 106
 
104
-		if (!empty($boards))
105
-			$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
107
+		if (!empty($boards)) {
108
+					$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
109
+		}
106 110
 
107 111
 		// Try to limit the number of messages we look through.
108
-		if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15)
109
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
110
-	}
111
-	elseif (!empty($_REQUEST['boards']))
112
+		if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) {
113
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
114
+		}
115
+	} elseif (!empty($_REQUEST['boards']))
112 116
 	{
113 117
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
114
-		foreach ($_REQUEST['boards'] as $i => $b)
115
-			$_REQUEST['boards'][$i] = (int) $b;
118
+		foreach ($_REQUEST['boards'] as $i => $b) {
119
+					$_REQUEST['boards'][$i] = (int) $b;
120
+		}
116 121
 
117 122
 		$request = $smcFunc['db_query']('', '
118 123
 			SELECT b.id_board, b.num_posts, b.name
@@ -128,29 +133,32 @@  discard block
 block discarded – undo
128 133
 
129 134
 		// Either the board specified doesn't exist or you have no access.
130 135
 		$num_boards = $smcFunc['db_num_rows']($request);
131
-		if ($num_boards == 0)
132
-			fatal_lang_error('no_board');
136
+		if ($num_boards == 0) {
137
+					fatal_lang_error('no_board');
138
+		}
133 139
 
134 140
 		$total_posts = 0;
135 141
 		$boards = array();
136 142
 		while ($row = $smcFunc['db_fetch_assoc']($request))
137 143
 		{
138
-			if ($num_boards == 1)
139
-				$feed_meta['title'] = ' - ' . strip_tags($row['name']);
144
+			if ($num_boards == 1) {
145
+							$feed_meta['title'] = ' - ' . strip_tags($row['name']);
146
+			}
140 147
 
141 148
 			$boards[] = $row['id_board'];
142 149
 			$total_posts += $row['num_posts'];
143 150
 		}
144 151
 		$smcFunc['db_free_result']($request);
145 152
 
146
-		if (!empty($boards))
147
-			$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
153
+		if (!empty($boards)) {
154
+					$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
155
+		}
148 156
 
149 157
 		// The more boards, the more we're going to look through...
150
-		if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12)
151
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
152
-	}
153
-	elseif (!empty($board))
158
+		if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) {
159
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
160
+		}
161
+	} elseif (!empty($board))
154 162
 	{
155 163
 		$request = $smcFunc['db_query']('', '
156 164
 			SELECT num_posts
@@ -170,10 +178,10 @@  discard block
 block discarded – undo
170 178
 		$query_this_board = 'b.id_board = ' . $board;
171 179
 
172 180
 		// Try to look through just a few messages, if at all possible.
173
-		if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10)
174
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
175
-	}
176
-	else
181
+		if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) {
182
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
183
+		}
184
+	} else
177 185
 	{
178 186
 		$query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
179 187
 			AND b.id_board != ' . $modSettings['recycle_board'] : '');
@@ -196,30 +204,35 @@  discard block
 block discarded – undo
196 204
 	// Easy adding of sub actions
197 205
  	call_integration_hook('integrate_xmlfeeds', array(&$subActions));
198 206
 
199
-	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']]))
200
-		$_GET['sa'] = 'recent';
207
+	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) {
208
+			$_GET['sa'] = 'recent';
209
+	}
201 210
 
202 211
 	// We only want some information, not all of it.
203 212
 	$cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']);
204
-	foreach (array('board', 'boards', 'c') as $var)
205
-		if (isset($_REQUEST[$var]))
213
+	foreach (array('board', 'boards', 'c') as $var) {
214
+			if (isset($_REQUEST[$var]))
206 215
 			$cachekey[] = $_REQUEST[$var];
216
+	}
207 217
 	$cachekey = md5(json_encode($cachekey) . (!empty($query_this_board) ? $query_this_board : ''));
208 218
 	$cache_t = microtime();
209 219
 
210 220
 	// Get the associative array representing the xml.
211
-	if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3))
212
-		$xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240);
221
+	if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) {
222
+			$xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240);
223
+	}
213 224
 	if (empty($xml_data))
214 225
 	{
215 226
 		$call = call_helper($subActions[$_GET['sa']][0], true);
216 227
 
217
-		if (!empty($call))
218
-			$xml_data = call_user_func($call, $xml_format);
228
+		if (!empty($call)) {
229
+					$xml_data = call_user_func($call, $xml_format);
230
+		}
219 231
 
220 232
 		if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3)
221
-		|| (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2))))
222
-			cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240);
233
+		|| (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) {
234
+					cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240);
235
+		}
223 236
 	}
224 237
 
225 238
 	$feed_meta['title'] = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_meta['title']) ? $feed_meta['title'] : '');
@@ -259,43 +272,49 @@  discard block
 block discarded – undo
259 272
 	call_integration_hook('integrate_xml_data', array(&$xml_data, &$feed_meta, &$namespaces, &$extraFeedTags, &$forceCdataKeys, &$nsKeys, $xml_format, $_GET['sa']));
260 273
 
261 274
 	// These can't be empty
262
-	foreach (array('title', 'desc', 'source') as $mkey)
263
-		$feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey];
275
+	foreach (array('title', 'desc', 'source') as $mkey) {
276
+			$feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey];
277
+	}
264 278
 
265 279
 	// Sanitize basic feed metadata values
266
-	foreach ($feed_meta as $mkey => $mvalue)
267
-		$feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey])));
280
+	foreach ($feed_meta as $mkey => $mvalue) {
281
+			$feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey])));
282
+	}
268 283
 
269 284
 	$ns_string = '';
270 285
 	if (!empty($namespaces[$xml_format]))
271 286
 	{
272
-		foreach ($namespaces[$xml_format] as $nsprefix => $nsurl)
273
-			$ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"';
287
+		foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) {
288
+					$ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"';
289
+		}
274 290
 	}
275 291
 
276 292
 	$extraFeedTags_string = '';
277 293
 	if (!empty($extraFeedTags[$xml_format]))
278 294
 	{
279 295
 		$indent = "\t" . ($xml_format !== 'atom' ? "\t" : '');
280
-		foreach ($extraFeedTags[$xml_format] as $extraTag)
281
-			$extraFeedTags_string .= "\n" . $indent . $extraTag;
296
+		foreach ($extraFeedTags[$xml_format] as $extraTag) {
297
+					$extraFeedTags_string .= "\n" . $indent . $extraTag;
298
+		}
282 299
 	}
283 300
 
284 301
 	// This is an xml file....
285 302
 	ob_end_clean();
286
-	if (!empty($modSettings['enableCompressedOutput']))
287
-		@ob_start('ob_gzhandler');
288
-	else
289
-		ob_start();
303
+	if (!empty($modSettings['enableCompressedOutput'])) {
304
+			@ob_start('ob_gzhandler');
305
+	} else {
306
+			ob_start();
307
+	}
290 308
 
291
-	if ($xml_format == 'smf' || isset($_REQUEST['debug']))
292
-		header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
293
-	elseif ($xml_format == 'rss' || $xml_format == 'rss2')
294
-		header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
295
-	elseif ($xml_format == 'atom')
296
-		header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
297
-	elseif ($xml_format == 'rdf')
298
-		header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
309
+	if ($xml_format == 'smf' || isset($_REQUEST['debug'])) {
310
+			header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
311
+	} elseif ($xml_format == 'rss' || $xml_format == 'rss2') {
312
+			header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
313
+	} elseif ($xml_format == 'atom') {
314
+			header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
315
+	} elseif ($xml_format == 'rdf') {
316
+			header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
317
+	}
299 318
 
300 319
 	// First, output the xml header.
301 320
 	echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>';
@@ -303,10 +322,11 @@  discard block
 block discarded – undo
303 322
 	// Are we outputting an rss feed or one with more information?
304 323
 	if ($xml_format == 'rss' || $xml_format == 'rss2')
305 324
 	{
306
-		if ($xml_format == 'rss2')
307
-			foreach ($_REQUEST as $var => $val)
325
+		if ($xml_format == 'rss2') {
326
+					foreach ($_REQUEST as $var => $val)
308 327
 				if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
309 328
 					$url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val);
329
+		}
310 330
 
311 331
 		// Start with an RSS 2.0 header.
312 332
 		echo '
@@ -327,9 +347,10 @@  discard block
 block discarded – undo
327 347
 		<language>' . $feed_meta['language'] . '</language>' : '';
328 348
 
329 349
 		// RSS2 calls for this.
330
-		if ($xml_format == 'rss2')
331
-			echo '
350
+		if ($xml_format == 'rss2') {
351
+					echo '
332 352
 		<atom:link rel="self" type="application/rss+xml" href="', $scripturl, !empty($url_parts) ? '?' . implode(';', $url_parts) : '', '" />';
353
+		}
333 354
 
334 355
 		echo $extraFeedTags_string;
335 356
 
@@ -340,12 +361,12 @@  discard block
 block discarded – undo
340 361
 		echo '
341 362
 	</channel>
342 363
 </rss>';
343
-	}
344
-	elseif ($xml_format == 'atom')
364
+	} elseif ($xml_format == 'atom')
345 365
 	{
346
-		foreach ($_REQUEST as $var => $val)
347
-			if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
366
+		foreach ($_REQUEST as $var => $val) {
367
+					if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
348 368
 				$url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val);
369
+		}
349 370
 
350 371
 		echo '
351 372
 <feed', $ns_string, !empty($feed_meta['language']) ? ' xml:lang="' . $feed_meta['language'] . '"' : '', '>
@@ -371,8 +392,7 @@  discard block
 block discarded – undo
371 392
 
372 393
 		echo '
373 394
 </feed>';
374
-	}
375
-	elseif ($xml_format == 'rdf')
395
+	} elseif ($xml_format == 'rdf')
376 396
 	{
377 397
 		echo '
378 398
 <rdf:RDF', $ns_string, '>
@@ -437,13 +457,15 @@  discard block
 block discarded – undo
437 457
 {
438 458
 	global $modSettings, $context, $scripturl;
439 459
 
440
-	if (substr($val, 0, strlen($scripturl)) != $scripturl)
441
-		return $val;
460
+	if (substr($val, 0, strlen($scripturl)) != $scripturl) {
461
+			return $val;
462
+	}
442 463
 
443 464
 	call_integration_hook('integrate_fix_url', array(&$val));
444 465
 
445
-	if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd']))
446
-		return $val;
466
+	if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) {
467
+			return $val;
468
+	}
447 469
 
448 470
 	$val = preg_replace_callback('~\b' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function($m) use ($scripturl)
449 471
 		{
@@ -466,8 +488,9 @@  discard block
 block discarded – undo
466 488
 	global $smcFunc;
467 489
 
468 490
 	// Do we even need to do this?
469
-	if (strpbrk($data, '<>&') == false && $force !== true)
470
-		return $data;
491
+	if (strpbrk($data, '<>&') == false && $force !== true) {
492
+			return $data;
493
+	}
471 494
 
472 495
 	$cdata = '<![CDATA[';
473 496
 
@@ -477,49 +500,55 @@  discard block
 block discarded – undo
477 500
 			$smcFunc['strpos']($data, '&', $pos),
478 501
 			$smcFunc['strpos']($data, ']', $pos),
479 502
 		);
480
-		if ($ns != '')
481
-			$positions[] = $smcFunc['strpos']($data, '<', $pos);
503
+		if ($ns != '') {
504
+					$positions[] = $smcFunc['strpos']($data, '<', $pos);
505
+		}
482 506
 		foreach ($positions as $k => $dummy)
483 507
 		{
484
-			if ($dummy === false)
485
-				unset($positions[$k]);
508
+			if ($dummy === false) {
509
+							unset($positions[$k]);
510
+			}
486 511
 		}
487 512
 
488 513
 		$old = $pos;
489 514
 		$pos = empty($positions) ? $n : min($positions);
490 515
 
491
-		if ($pos - $old > 0)
492
-			$cdata .= $smcFunc['substr']($data, $old, $pos - $old);
493
-		if ($pos >= $n)
494
-			break;
516
+		if ($pos - $old > 0) {
517
+					$cdata .= $smcFunc['substr']($data, $old, $pos - $old);
518
+		}
519
+		if ($pos >= $n) {
520
+					break;
521
+		}
495 522
 
496 523
 		if ($smcFunc['substr']($data, $pos, 1) == '<')
497 524
 		{
498 525
 			$pos2 = $smcFunc['strpos']($data, '>', $pos);
499
-			if ($pos2 === false)
500
-				$pos2 = $n;
501
-			if ($smcFunc['substr']($data, $pos + 1, 1) == '/')
502
-				$cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
503
-			else
504
-				$cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
526
+			if ($pos2 === false) {
527
+							$pos2 = $n;
528
+			}
529
+			if ($smcFunc['substr']($data, $pos + 1, 1) == '/') {
530
+							$cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
531
+			} else {
532
+							$cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
533
+			}
505 534
 			$pos = $pos2 + 1;
506
-		}
507
-		elseif ($smcFunc['substr']($data, $pos, 1) == ']')
535
+		} elseif ($smcFunc['substr']($data, $pos, 1) == ']')
508 536
 		{
509 537
 			$cdata .= ']]>&#093;<![CDATA[';
510 538
 			$pos++;
511
-		}
512
-		elseif ($smcFunc['substr']($data, $pos, 1) == '&')
539
+		} elseif ($smcFunc['substr']($data, $pos, 1) == '&')
513 540
 		{
514 541
 			$pos2 = $smcFunc['strpos']($data, ';', $pos);
515
-			if ($pos2 === false)
516
-				$pos2 = $n;
542
+			if ($pos2 === false) {
543
+							$pos2 = $n;
544
+			}
517 545
 			$ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1);
518 546
 
519
-			if ($smcFunc['substr']($data, $pos + 1, 1) == '#')
520
-				$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
521
-			elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot')))
522
-				$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
547
+			if ($smcFunc['substr']($data, $pos + 1, 1) == '#') {
548
+							$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
549
+			} elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) {
550
+							$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
551
+			}
523 552
 
524 553
 			$pos = $pos2 + 1;
525 554
 		}
@@ -558,8 +587,9 @@  discard block
 block discarded – undo
558 587
 		'gender',
559 588
 		'blurb',
560 589
 	);
561
-	if ($xml_format != 'atom')
562
-		$keysToCdata[] = 'category';
590
+	if ($xml_format != 'atom') {
591
+			$keysToCdata[] = 'category';
592
+	}
563 593
 
564 594
 	if (!empty($forceCdataKeys))
565 595
 	{
@@ -576,8 +606,9 @@  discard block
 block discarded – undo
576 606
 		$attrs = isset($element['attributes']) ? $element['attributes'] : null;
577 607
 
578 608
 		// Skip it, it's been set to null.
579
-		if ($key === null || ($val === null && $attrs === null))
580
-			continue;
609
+		if ($key === null || ($val === null && $attrs === null)) {
610
+					continue;
611
+		}
581 612
 
582 613
 		$forceCdata = in_array($key, $forceCdataKeys);
583 614
 		$ns = !empty($nsKeys[$key]) ? $nsKeys[$key] : '';
@@ -590,16 +621,16 @@  discard block
 block discarded – undo
590 621
 
591 622
 		if (!empty($attrs))
592 623
 		{
593
-			foreach ($attrs as $attr_key => $attr_value)
594
-				echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"';
624
+			foreach ($attrs as $attr_key => $attr_value) {
625
+							echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"';
626
+			}
595 627
 		}
596 628
 
597 629
 		// If it's empty, simply output an empty element.
598 630
 		if (empty($val))
599 631
 		{
600 632
 			echo ' />';
601
-		}
602
-		else
633
+		} else
603 634
 		{
604 635
 			echo '>';
605 636
 
@@ -611,11 +642,13 @@  discard block
 block discarded – undo
611 642
 				echo "\n", str_repeat("\t", $i);
612 643
 			}
613 644
 			// A string with returns in it.... show this as a multiline element.
614
-			elseif (strpos($val, "\n") !== false)
615
-				echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i);
645
+			elseif (strpos($val, "\n") !== false) {
646
+							echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i);
647
+			}
616 648
 			// A simple string.
617
-			else
618
-				echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val);
649
+			else {
650
+							echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val);
651
+			}
619 652
 
620 653
 			// Ending tag.
621 654
 			echo '</', $key, '>';
@@ -635,8 +668,9 @@  discard block
 block discarded – undo
635 668
 {
636 669
 	global $scripturl, $smcFunc;
637 670
 
638
-	if (!allowedTo('view_mlist'))
639
-		return array();
671
+	if (!allowedTo('view_mlist')) {
672
+			return array();
673
+	}
640 674
 
641 675
 	// Find the most recent members.
642 676
 	$request = $smcFunc['db_query']('', '
@@ -655,8 +689,8 @@  discard block
 block discarded – undo
655 689
 		$guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['date_registered']) . ':member=' . $row['id_member'];
656 690
 
657 691
 		// Make the data look rss-ish.
658
-		if ($xml_format == 'rss' || $xml_format == 'rss2')
659
-			$data[] = array(
692
+		if ($xml_format == 'rss' || $xml_format == 'rss2') {
693
+					$data[] = array(
660 694
 				'tag' => 'item',
661 695
 				'content' => array(
662 696
 					array(
@@ -684,8 +718,8 @@  discard block
 block discarded – undo
684 718
 					),
685 719
 				),
686 720
 			);
687
-		elseif ($xml_format == 'rdf')
688
-			$data[] = array(
721
+		} elseif ($xml_format == 'rdf') {
722
+					$data[] = array(
689 723
 				'tag' => 'item',
690 724
 				'attributes' => array('rdf:about' => $scripturl . '?action=profile;u=' . $row['id_member']),
691 725
 				'content' => array(
@@ -703,8 +737,8 @@  discard block
 block discarded – undo
703 737
 					),
704 738
 				),
705 739
 			);
706
-		elseif ($xml_format == 'atom')
707
-			$data[] = array(
740
+		} elseif ($xml_format == 'atom') {
741
+					$data[] = array(
708 742
 				'tag' => 'entry',
709 743
 				'content' => array(
710 744
 					array(
@@ -733,9 +767,10 @@  discard block
 block discarded – undo
733 767
 					),
734 768
 				),
735 769
 			);
770
+		}
736 771
 		// More logical format for the data, but harder to apply.
737
-		else
738
-			$data[] = array(
772
+		else {
773
+					$data[] = array(
739 774
 				'tag' => 'member',
740 775
 				'content' => array(
741 776
 					array(
@@ -756,6 +791,7 @@  discard block
 block discarded – undo
756 791
 					),
757 792
 				),
758 793
 			);
794
+		}
759 795
 	}
760 796
 	$smcFunc['db_free_result']($request);
761 797
 
@@ -816,22 +852,24 @@  discard block
 block discarded – undo
816 852
 		if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
817 853
 		{
818 854
 			$smcFunc['db_free_result']($request);
819
-			if (empty($_REQUEST['boards']) && empty($board))
820
-				unset($context['optimize_msg']['lowest']);
821
-			else
822
-				$context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
855
+			if (empty($_REQUEST['boards']) && empty($board)) {
856
+							unset($context['optimize_msg']['lowest']);
857
+			} else {
858
+							$context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
859
+			}
823 860
 			$context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg';
824 861
 			$loops++;
862
+		} else {
863
+					$done = true;
825 864
 		}
826
-		else
827
-			$done = true;
828 865
 	}
829 866
 	$data = array();
830 867
 	while ($row = $smcFunc['db_fetch_assoc']($request))
831 868
 	{
832 869
 		// Limit the length of the message, if the option is set.
833
-		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
834
-			$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
870
+		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) {
871
+					$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
872
+		}
835 873
 
836 874
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
837 875
 
@@ -858,8 +896,9 @@  discard block
 block discarded – undo
858 896
 			while ($attach = $smcFunc['db_fetch_assoc']($attach_request))
859 897
 			{
860 898
 				// Include approved attachments only
861
-				if ($attach['approved'])
862
-					$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
899
+				if ($attach['approved']) {
900
+									$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
901
+				}
863 902
 			}
864 903
 			$smcFunc['db_free_result']($attach_request);
865 904
 
@@ -867,16 +906,17 @@  discard block
 block discarded – undo
867 906
 			if (!empty($loaded_attachments))
868 907
 			{
869 908
 				uasort($loaded_attachments, function($a, $b) {
870
-					if ($a['filesize'] == $b['filesize'])
871
-					        return 0;
909
+					if ($a['filesize'] == $b['filesize']) {
910
+										        return 0;
911
+					}
872 912
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
873 913
 				});
914
+			} else {
915
+							$loaded_attachments = null;
874 916
 			}
875
-			else
876
-				$loaded_attachments = null;
917
+		} else {
918
+					$loaded_attachments = null;
877 919
 		}
878
-		else
879
-			$loaded_attachments = null;
880 920
 
881 921
 		// Create a GUID for this topic using the tag URI scheme
882 922
 		$guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':topic=' . $row['id_topic'];
@@ -893,9 +933,9 @@  discard block
 block discarded – undo
893 933
 					'length' => $attachment['filesize'],
894 934
 					'type' => $attachment['mime_type'],
895 935
 				);
936
+			} else {
937
+							$enclosure = null;
896 938
 			}
897
-			else
898
-				$enclosure = null;
899 939
 
900 940
 			$data[] = array(
901 941
 				'tag' => 'item',
@@ -941,8 +981,7 @@  discard block
 block discarded – undo
941 981
 					),
942 982
 				),
943 983
 			);
944
-		}
945
-		elseif ($xml_format == 'rdf')
984
+		} elseif ($xml_format == 'rdf')
946 985
 		{
947 986
 			$data[] = array(
948 987
 				'tag' => 'item',
@@ -966,8 +1005,7 @@  discard block
 block discarded – undo
966 1005
 					),
967 1006
 				),
968 1007
 			);
969
-		}
970
-		elseif ($xml_format == 'atom')
1008
+		} elseif ($xml_format == 'atom')
971 1009
 		{
972 1010
 			// Only one attachment allowed
973 1011
 			if (!empty($loaded_attachments))
@@ -979,9 +1017,9 @@  discard block
 block discarded – undo
979 1017
 					'length' => $attachment['filesize'],
980 1018
 					'type' => $attachment['mime_type'],
981 1019
 				);
1020
+			} else {
1021
+							$enclosure = null;
982 1022
 			}
983
-			else
984
-				$enclosure = null;
985 1023
 
986 1024
 			$data[] = array(
987 1025
 				'tag' => 'entry',
@@ -1081,9 +1119,9 @@  discard block
 block discarded – undo
1081 1119
 						)
1082 1120
 					);
1083 1121
 				}
1122
+			} else {
1123
+							$attachments = null;
1084 1124
 			}
1085
-			else
1086
-				$attachments = null;
1087 1125
 
1088 1126
 			$data[] = array(
1089 1127
 				'tag' => 'article',
@@ -1201,22 +1239,25 @@  discard block
 block discarded – undo
1201 1239
 		if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
1202 1240
 		{
1203 1241
 			$smcFunc['db_free_result']($request);
1204
-			if (empty($_REQUEST['boards']) && empty($board))
1205
-				unset($context['optimize_msg']['lowest']);
1206
-			else
1207
-				$context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
1242
+			if (empty($_REQUEST['boards']) && empty($board)) {
1243
+							unset($context['optimize_msg']['lowest']);
1244
+			} else {
1245
+							$context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
1246
+			}
1208 1247
 			$loops++;
1248
+		} else {
1249
+					$done = true;
1209 1250
 		}
1210
-		else
1211
-			$done = true;
1212 1251
 	}
1213 1252
 	$messages = array();
1214
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1215
-		$messages[] = $row['id_msg'];
1253
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1254
+			$messages[] = $row['id_msg'];
1255
+	}
1216 1256
 	$smcFunc['db_free_result']($request);
1217 1257
 
1218
-	if (empty($messages))
1219
-		return array();
1258
+	if (empty($messages)) {
1259
+			return array();
1260
+	}
1220 1261
 
1221 1262
 	// Find the most recent posts this user can see.
1222 1263
 	$request = $smcFunc['db_query']('', '
@@ -1246,8 +1287,9 @@  discard block
 block discarded – undo
1246 1287
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1247 1288
 	{
1248 1289
 		// Limit the length of the message, if the option is set.
1249
-		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
1250
-			$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
1290
+		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) {
1291
+					$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
1292
+		}
1251 1293
 
1252 1294
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
1253 1295
 
@@ -1274,8 +1316,9 @@  discard block
 block discarded – undo
1274 1316
 			while ($attach = $smcFunc['db_fetch_assoc']($attach_request))
1275 1317
 			{
1276 1318
 				// Include approved attachments only
1277
-				if ($attach['approved'])
1278
-					$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
1319
+				if ($attach['approved']) {
1320
+									$loaded_attachments['attachment_' . $attach['id_attach']] = $attach;
1321
+				}
1279 1322
 			}
1280 1323
 			$smcFunc['db_free_result']($attach_request);
1281 1324
 
@@ -1283,16 +1326,17 @@  discard block
 block discarded – undo
1283 1326
 			if (!empty($loaded_attachments))
1284 1327
 			{
1285 1328
 				uasort($loaded_attachments, function($a, $b) {
1286
-					if ($a['filesize'] == $b['filesize'])
1287
-					        return 0;
1329
+					if ($a['filesize'] == $b['filesize']) {
1330
+										        return 0;
1331
+					}
1288 1332
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
1289 1333
 				});
1334
+			} else {
1335
+							$loaded_attachments = null;
1290 1336
 			}
1291
-			else
1292
-				$loaded_attachments = null;
1337
+		} else {
1338
+					$loaded_attachments = null;
1293 1339
 		}
1294
-		else
1295
-			$loaded_attachments = null;
1296 1340
 
1297 1341
 		// Create a GUID for this post using the tag URI scheme
1298 1342
 		$guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':msg=' . $row['id_msg'];
@@ -1309,9 +1353,9 @@  discard block
 block discarded – undo
1309 1353
 					'length' => $attachment['filesize'],
1310 1354
 					'type' => $attachment['mime_type'],
1311 1355
 				);
1356
+			} else {
1357
+							$enclosure = null;
1312 1358
 			}
1313
-			else
1314
-				$enclosure = null;
1315 1359
 
1316 1360
 			$data[] = array(
1317 1361
 				'tag' => 'item',
@@ -1357,8 +1401,7 @@  discard block
 block discarded – undo
1357 1401
 					),
1358 1402
 				),
1359 1403
 			);
1360
-		}
1361
-		elseif ($xml_format == 'rdf')
1404
+		} elseif ($xml_format == 'rdf')
1362 1405
 		{
1363 1406
 			$data[] = array(
1364 1407
 				'tag' => 'item',
@@ -1382,8 +1425,7 @@  discard block
 block discarded – undo
1382 1425
 					),
1383 1426
 				),
1384 1427
 			);
1385
-		}
1386
-		elseif ($xml_format == 'atom')
1428
+		} elseif ($xml_format == 'atom')
1387 1429
 		{
1388 1430
 			// Only one attachment allowed
1389 1431
 			if (!empty($loaded_attachments))
@@ -1395,9 +1437,9 @@  discard block
 block discarded – undo
1395 1437
 					'length' => $attachment['filesize'],
1396 1438
 					'type' => $attachment['mime_type'],
1397 1439
 				);
1440
+			} else {
1441
+							$enclosure = null;
1398 1442
 			}
1399
-			else
1400
-				$enclosure = null;
1401 1443
 
1402 1444
 			$data[] = array(
1403 1445
 				'tag' => 'entry',
@@ -1497,9 +1539,9 @@  discard block
 block discarded – undo
1497 1539
 						)
1498 1540
 					);
1499 1541
 				}
1542
+			} else {
1543
+							$attachments = null;
1500 1544
 			}
1501
-			else
1502
-				$attachments = null;
1503 1545
 
1504 1546
 			$data[] = array(
1505 1547
 				'tag' => 'recent-post',
@@ -1618,14 +1660,16 @@  discard block
 block discarded – undo
1618 1660
 	global $scripturl, $memberContext, $user_profile, $user_info;
1619 1661
 
1620 1662
 	// You must input a valid user....
1621
-	if (empty($_GET['u']) || !loadMemberData((int) $_GET['u']))
1622
-		return array();
1663
+	if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) {
1664
+			return array();
1665
+	}
1623 1666
 
1624 1667
 	// Make sure the id is a number and not "I like trying to hack the database".
1625 1668
 	$_GET['u'] = (int) $_GET['u'];
1626 1669
 	// Load the member's contextual information!
1627
-	if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view'))
1628
-		return array();
1670
+	if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) {
1671
+			return array();
1672
+	}
1629 1673
 
1630 1674
 	// Okay, I admit it, I'm lazy.  Stupid $_GET['u'] is long and hard to type.
1631 1675
 	$profile = &$memberContext[$_GET['u']];
@@ -1667,8 +1711,7 @@  discard block
 block discarded – undo
1667 1711
 				),
1668 1712
 			)
1669 1713
 		);
1670
-	}
1671
-	elseif ($xml_format == 'rdf')
1714
+	} elseif ($xml_format == 'rdf')
1672 1715
 	{
1673 1716
 		$data[] = array(
1674 1717
 			'tag' => 'item',
@@ -1692,8 +1735,7 @@  discard block
 block discarded – undo
1692 1735
 				),
1693 1736
 			)
1694 1737
 		);
1695
-	}
1696
-	elseif ($xml_format == 'atom')
1738
+	} elseif ($xml_format == 'atom')
1697 1739
 	{
1698 1740
 		$data[] = array(
1699 1741
 			'tag' => 'entry',
@@ -1746,8 +1788,7 @@  discard block
 block discarded – undo
1746 1788
 				),
1747 1789
 			)
1748 1790
 		);
1749
-	}
1750
-	else
1791
+	} else
1751 1792
 	{
1752 1793
 		$data = array(
1753 1794
 			array(
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.
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.
Braces   +154 added lines, -118 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'] == 'viewweek')
43
+	} elseif ($context['calendar_view'] == 'viewweek')
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;
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, $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,19 +405,21 @@  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
-				elseif ($is_mini)
398
-					echo '<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
399
-				else
400
-					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
+				} elseif ($is_mini) {
411
+									echo '<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
412
+				} else {
413
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
414
+				}
401 415
 
402 416
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
403 417
 				if ($is_mini === false)
404 418
 				{
405 419
 					// Holidays are always fun, let's show them!
406
-					if (!empty($day['holidays']))
407
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
420
+					if (!empty($day['holidays'])) {
421
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
422
+					}
408 423
 
409 424
 					// Happy Birthday Dear, Member!
410 425
 					if (!empty($day['birthdays']))
@@ -422,14 +437,16 @@  discard block
 block discarded – undo
422 437
 							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) ? '' : ', ';
423 438
 
424 439
 							// 9...10! Let's stop there.
425
-							if ($birthday_count == 10 && $use_js_hide)
426
-								// !!TODO - Inline CSS and JavaScript should be moved.
440
+							if ($birthday_count == 10 && $use_js_hide) {
441
+															// !!TODO - Inline CSS and JavaScript should be moved.
427 442
 								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;">, ';
443
+							}
428 444
 
429 445
 							++$birthday_count;
430 446
 						}
431
-						if ($use_js_hide)
432
-							echo '</span>';
447
+						if ($use_js_hide) {
448
+													echo '</span>';
449
+						}
433 450
 
434 451
 						echo '</div>';
435 452
 					}
@@ -439,8 +456,9 @@  discard block
 block discarded – undo
439 456
 					{
440 457
 						// Sort events by start time (all day events will be listed first)
441 458
 						uasort($day['events'], function($a, $b) {
442
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
443
-						        return 0;
459
+						    if ($a['start_timestamp'] == $b['start_timestamp']) {
460
+						    						        return 0;
461
+						    }
444 462
 						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
445 463
 						});
446 464
 
@@ -456,17 +474,19 @@  discard block
 block discarded – undo
456 474
 
457 475
 							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' : '', '">';
458 476
 
459
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
460
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
461
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
462
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
463
-							elseif (!empty($event['allday']))
464
-								echo $txt['calendar_allday'];
477
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
478
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
479
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
480
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
481
+							} elseif (!empty($event['allday'])) {
482
+															echo $txt['calendar_allday'];
483
+							}
465 484
 
466 485
 							echo '</span>';
467 486
 
468
-							if (!empty($event['location']))
469
-								echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
487
+							if (!empty($event['location'])) {
488
+															echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
489
+							}
470 490
 
471 491
 							if ($event['can_edit'] || $event['can_export'])
472 492
 							{
@@ -503,10 +523,11 @@  discard block
 block discarded – undo
503 523
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
504 524
 			elseif ($is_mini === false)
505 525
 			{
506
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
507
-					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>';
508
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
509
-					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>';
526
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
527
+									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>';
528
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
529
+									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>';
530
+				}
510 531
 			}
511 532
 
512 533
 			// Close this day and increase var count.
@@ -532,8 +553,9 @@  discard block
 block discarded – undo
532 553
 	global $context, $txt, $scripturl, $modSettings;
533 554
 
534 555
 	// We might have no reason to proceed, if the variable isn't there.
535
-	if (!isset($context['calendar_grid_' . $grid_name]))
536
-		return false;
556
+	if (!isset($context['calendar_grid_' . $grid_name])) {
557
+			return false;
558
+	}
537 559
 
538 560
 	// Handy pointer.
539 561
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -568,8 +590,9 @@  discard block
 block discarded – undo
568 590
 					}
569 591
 
570 592
 					// The Month Title + Week Number...
571
-					if (!empty($calendar_data['week_title']))
572
-							echo $calendar_data['week_title'];
593
+					if (!empty($calendar_data['week_title'])) {
594
+												echo $calendar_data['week_title'];
595
+					}
573 596
 
574 597
 					echo '
575 598
 					</h3>
@@ -608,10 +631,11 @@  discard block
 block discarded – undo
608 631
 						<tr class="days_wrapper">
609 632
 							<td class="', implode(' ', $classes), ' act_day">';
610 633
 							// Should the day number be a link?
611
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
612
-								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>';
613
-							else
614
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
634
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
635
+															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>';
636
+							} else {
637
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
638
+							}
615 639
 
616 640
 							echo '</td>
617 641
 							<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'] : '', '">';
@@ -620,8 +644,9 @@  discard block
 block discarded – undo
620 644
 							{
621 645
 								// Sort events by start time (all day events will be listed first)
622 646
 								uasort($day['events'], function($a, $b) {
623
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
624
-								        return 0;
647
+								    if ($a['start_timestamp'] == $b['start_timestamp']) {
648
+								    								        return 0;
649
+								    }
625 650
 								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
626 651
 								});
627 652
 
@@ -633,15 +658,17 @@  discard block
 block discarded – undo
633 658
 
634 659
 									echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
635 660
 
636
-									if (!empty($event['start_time_local']))
637
-										echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
638
-									else
639
-										echo $txt['calendar_allday'];
661
+									if (!empty($event['start_time_local'])) {
662
+																			echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
663
+									} else {
664
+																			echo $txt['calendar_allday'];
665
+									}
640 666
 
641 667
 									echo '</span>';
642 668
 
643
-									if (!empty($event['location']))
644
-										echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
669
+									if (!empty($event['location'])) {
670
+																			echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
671
+									}
645 672
 
646 673
 									if (!empty($event_icons_needed))
647 674
 									{
@@ -678,8 +705,7 @@  discard block
 block discarded – undo
678 705
 									</div>
679 706
 									<br class="clear">';
680 707
 								}
681
-							}
682
-							else
708
+							} else
683 709
 							{
684 710
 								if (!empty($context['can_post']))
685 711
 								{
@@ -692,8 +718,9 @@  discard block
 block discarded – undo
692 718
 							echo '</td>
693 719
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
694 720
 							// Show any holidays!
695
-							if (!empty($day['holidays']))
696
-								echo implode('<br>', $day['holidays']);
721
+							if (!empty($day['holidays'])) {
722
+															echo implode('<br>', $day['holidays']);
723
+							}
697 724
 
698 725
 							echo '</td>
699 726
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">';
@@ -751,8 +778,7 @@  discard block
 block discarded – undo
751 778
 				<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">
752 779
 				<input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '">
753 780
 			</form>';
754
-	}
755
-	else
781
+	} else
756 782
 	{
757 783
 		echo'
758 784
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
@@ -794,8 +820,9 @@  discard block
 block discarded – undo
794 820
 	echo '
795 821
 		<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;">';
796 822
 
797
-	if (!empty($context['event']['new']))
798
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
823
+	if (!empty($context['event']['new'])) {
824
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
825
+	}
799 826
 
800 827
 	// Start the main table.
801 828
 	echo '
@@ -845,9 +872,10 @@  discard block
 block discarded – undo
845 872
 		{
846 873
 			echo '
847 874
 								<optgroup label="', $category['name'], '">';
848
-			foreach ($category['boards'] as $board)
849
-				echo '
875
+			foreach ($category['boards'] as $board) {
876
+							echo '
850 877
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
878
+			}
851 879
 			echo '
852 880
 								</optgroup>';
853 881
 		}
@@ -883,9 +911,10 @@  discard block
 block discarded – undo
883 911
 							<span class="label">', $txt['calendar_timezone'], '</span>
884 912
 							<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
885 913
 
886
-	foreach ($context['all_timezones'] as $tz => $tzname)
887
-		echo '
914
+	foreach ($context['all_timezones'] as $tz => $tzname) {
915
+			echo '
888 916
 								<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
917
+	}
889 918
 
890 919
 	echo '
891 920
 							</select>
@@ -900,9 +929,10 @@  discard block
 block discarded – undo
900 929
 	echo '
901 930
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
902 931
 	// Delete button?
903
-	if (empty($context['event']['new']))
904
-		echo '
932
+	if (empty($context['event']['new'])) {
933
+			echo '
905 934
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
935
+	}
906 936
 
907 937
 	echo '
908 938
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -946,9 +976,10 @@  discard block
 block discarded – undo
946 976
 
947 977
 		foreach ($context['clockicons'] as $t => $v)
948 978
 		{
949
-			foreach ($v as $i)
950
-				echo '
979
+			foreach ($v as $i) {
980
+							echo '
951 981
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
982
+			}
952 983
 		}
953 984
 
954 985
 		echo '
@@ -973,13 +1004,14 @@  discard block
 block discarded – undo
973 1004
 
974 1005
 		foreach ($context['clockicons'] as $t => $v)
975 1006
 		{
976
-			foreach ($v as $i)
977
-				echo '
1007
+			foreach ($v as $i) {
1008
+							echo '
978 1009
 			if (', $t, ' >= ', $i, ')
979 1010
 			{
980 1011
 				turnon.push("', $t, '_', $i, '");
981 1012
 				', $t, ' -= ', $i, ';
982 1013
 			}';
1014
+			}
983 1015
 		}
984 1016
 
985 1017
 		echo '
@@ -1043,9 +1075,10 @@  discard block
 block discarded – undo
1043 1075
 
1044 1076
 	foreach ($context['clockicons'] as $t => $v)
1045 1077
 	{
1046
-		foreach ($v as $i)
1047
-			echo '
1078
+		foreach ($v as $i) {
1079
+					echo '
1048 1080
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1081
+		}
1049 1082
 	}
1050 1083
 
1051 1084
 	echo '
@@ -1062,13 +1095,14 @@  discard block
 block discarded – undo
1062 1095
 
1063 1096
 	foreach ($context['clockicons'] as $t => $v)
1064 1097
 	{
1065
-		foreach ($v as $i)
1066
-			echo '
1098
+		foreach ($v as $i) {
1099
+					echo '
1067 1100
 		if (', $t, ' >= ', $i, ')
1068 1101
 		{
1069 1102
 			turnon.push("', $t, '_', $i, '");
1070 1103
 			', $t, ' -= ', $i, ';
1071 1104
 		}';
1105
+		}
1072 1106
 	}
1073 1107
 
1074 1108
 	echo '
@@ -1127,9 +1161,10 @@  discard block
 block discarded – undo
1127 1161
 
1128 1162
 	foreach ($context['clockicons'] as $t => $v)
1129 1163
 	{
1130
-		foreach ($v as $i)
1131
-			echo '
1164
+		foreach ($v as $i) {
1165
+					echo '
1132 1166
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1167
+		}
1133 1168
 	}
1134 1169
 
1135 1170
 	echo '
@@ -1150,13 +1185,14 @@  discard block
 block discarded – undo
1150 1185
 
1151 1186
 	foreach ($context['clockicons'] as $t => $v)
1152 1187
 	{
1153
-		foreach ($v as $i)
1154
-		echo '
1188
+		foreach ($v as $i) {
1189
+				echo '
1155 1190
 		if (', $t, ' >= ', $i, ')
1156 1191
 		{
1157 1192
 			turnon.push("', $t, '_', $i, '");
1158 1193
 			', $t, ' -= ', $i, ';
1159 1194
 		}';
1195
+		}
1160 1196
 	}
1161 1197
 
1162 1198
 	echo '
Please login to merge, or discard this patch.