Completed
Pull Request — release-2.1 (#4090)
by Rick
27:33
created
Sources/ReCaptcha/RequestMethod/CurlPost.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -36,53 +36,53 @@
 block discarded – undo
36 36
  */
37 37
 class CurlPost implements RequestMethod
38 38
 {
39
-    /**
40
-     * URL to which requests are sent via cURL.
41
-     * @const string
42
-     */
43
-    const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
39
+	/**
40
+	 * URL to which requests are sent via cURL.
41
+	 * @const string
42
+	 */
43
+	const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
44 44
 
45
-    /**
46
-     * Curl connection to the reCAPTCHA service
47
-     * @var Curl
48
-     */
49
-    private $curl;
45
+	/**
46
+	 * Curl connection to the reCAPTCHA service
47
+	 * @var Curl
48
+	 */
49
+	private $curl;
50 50
 
51
-    public function __construct(Curl $curl = null)
52
-    {
53
-        if (!is_null($curl)) {
54
-            $this->curl = $curl;
55
-        } else {
56
-            $this->curl = new Curl();
57
-        }
58
-    }
51
+	public function __construct(Curl $curl = null)
52
+	{
53
+		if (!is_null($curl)) {
54
+			$this->curl = $curl;
55
+		} else {
56
+			$this->curl = new Curl();
57
+		}
58
+	}
59 59
 
60
-    /**
61
-     * Submit the cURL request with the specified parameters.
62
-     *
63
-     * @param RequestParameters $params Request parameters
64
-     * @return string Body of the reCAPTCHA response
65
-     */
66
-    public function submit(RequestParameters $params)
67
-    {
68
-        $handle = $this->curl->init(self::SITE_VERIFY_URL);
60
+	/**
61
+	 * Submit the cURL request with the specified parameters.
62
+	 *
63
+	 * @param RequestParameters $params Request parameters
64
+	 * @return string Body of the reCAPTCHA response
65
+	 */
66
+	public function submit(RequestParameters $params)
67
+	{
68
+		$handle = $this->curl->init(self::SITE_VERIFY_URL);
69 69
 
70
-        $options = array(
71
-            CURLOPT_POST => true,
72
-            CURLOPT_POSTFIELDS => $params->toQueryString(),
73
-            CURLOPT_HTTPHEADER => array(
74
-                'Content-Type: application/x-www-form-urlencoded'
75
-            ),
76
-            CURLINFO_HEADER_OUT => false,
77
-            CURLOPT_HEADER => false,
78
-            CURLOPT_RETURNTRANSFER => true,
79
-            CURLOPT_SSL_VERIFYPEER => true
80
-        );
81
-        $this->curl->setoptArray($handle, $options);
70
+		$options = array(
71
+			CURLOPT_POST => true,
72
+			CURLOPT_POSTFIELDS => $params->toQueryString(),
73
+			CURLOPT_HTTPHEADER => array(
74
+				'Content-Type: application/x-www-form-urlencoded'
75
+			),
76
+			CURLINFO_HEADER_OUT => false,
77
+			CURLOPT_HEADER => false,
78
+			CURLOPT_RETURNTRANSFER => true,
79
+			CURLOPT_SSL_VERIFYPEER => true
80
+		);
81
+		$this->curl->setoptArray($handle, $options);
82 82
 
83
-        $response = $this->curl->exec($handle);
84
-        $this->curl->close($handle);
83
+		$response = $this->curl->exec($handle);
84
+		$this->curl->close($handle);
85 85
 
86
-        return $response;
87
-    }
86
+		return $response;
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/Post.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -34,37 +34,37 @@
 block discarded – undo
34 34
  */
35 35
 class Post implements RequestMethod
36 36
 {
37
-    /**
38
-     * URL to which requests are POSTed.
39
-     * @const string
40
-     */
41
-    const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
37
+	/**
38
+	 * URL to which requests are POSTed.
39
+	 * @const string
40
+	 */
41
+	const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
42 42
 
43
-    /**
44
-     * Submit the POST request with the specified parameters.
45
-     *
46
-     * @param RequestParameters $params Request parameters
47
-     * @return string Body of the reCAPTCHA response
48
-     */
49
-    public function submit(RequestParameters $params)
50
-    {
51
-        /**
52
-         * PHP 5.6.0 changed the way you specify the peer name for SSL context options.
53
-         * Using "CN_name" will still work, but it will raise deprecated errors.
54
-         */
55
-        $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
56
-        $options = array(
57
-            'http' => array(
58
-                'header' => "Content-type: application/x-www-form-urlencoded\r\n",
59
-                'method' => 'POST',
60
-                'content' => $params->toQueryString(),
61
-                // Force the peer to validate (not needed in 5.6.0+, but still works
62
-                'verify_peer' => true,
63
-                // Force the peer validation to use www.google.com
64
-                $peer_key => 'www.google.com',
65
-            ),
66
-        );
67
-        $context = stream_context_create($options);
68
-        return file_get_contents(self::SITE_VERIFY_URL, false, $context);
69
-    }
43
+	/**
44
+	 * Submit the POST request with the specified parameters.
45
+	 *
46
+	 * @param RequestParameters $params Request parameters
47
+	 * @return string Body of the reCAPTCHA response
48
+	 */
49
+	public function submit(RequestParameters $params)
50
+	{
51
+		/**
52
+		 * PHP 5.6.0 changed the way you specify the peer name for SSL context options.
53
+		 * Using "CN_name" will still work, but it will raise deprecated errors.
54
+		 */
55
+		$peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
56
+		$options = array(
57
+			'http' => array(
58
+				'header' => "Content-type: application/x-www-form-urlencoded\r\n",
59
+				'method' => 'POST',
60
+				'content' => $params->toQueryString(),
61
+				// Force the peer to validate (not needed in 5.6.0+, but still works
62
+				'verify_peer' => true,
63
+				// Force the peer validation to use www.google.com
64
+				$peer_key => 'www.google.com',
65
+			),
66
+		);
67
+		$context = stream_context_create($options);
68
+		return file_get_contents(self::SITE_VERIFY_URL, false, $context);
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/RequestMethod/SocketPost.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -36,86 +36,86 @@
 block discarded – undo
36 36
  */
37 37
 class SocketPost implements RequestMethod
38 38
 {
39
-    /**
40
-     * reCAPTCHA service host.
41
-     * @const string
42
-     */
43
-    const RECAPTCHA_HOST = 'www.google.com';
44
-
45
-    /**
46
-     * @const string reCAPTCHA service path
47
-     */
48
-    const SITE_VERIFY_PATH = '/recaptcha/api/siteverify';
49
-
50
-    /**
51
-     * @const string Bad request error
52
-     */
53
-    const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}';
54
-
55
-    /**
56
-     * @const string Bad response error
57
-     */
58
-    const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}';
59
-
60
-    /**
61
-     * Socket to the reCAPTCHA service
62
-     * @var Socket
63
-     */
64
-    private $socket;
65
-
66
-    /**
67
-     * Constructor
68
-     *
69
-     * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
70
-     */
71
-    public function __construct(Socket $socket = null)
72
-    {
73
-        if (!is_null($socket)) {
74
-            $this->socket = $socket;
75
-        } else {
76
-            $this->socket = new Socket();
77
-        }
78
-    }
79
-
80
-    /**
81
-     * Submit the POST request with the specified parameters.
82
-     *
83
-     * @param RequestParameters $params Request parameters
84
-     * @return string Body of the reCAPTCHA response
85
-     */
86
-    public function submit(RequestParameters $params)
87
-    {
88
-        $errno = 0;
89
-        $errstr = '';
90
-
91
-        if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) {
92
-            return self::BAD_REQUEST;
93
-        }
94
-
95
-        $content = $params->toQueryString();
96
-
97
-        $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n";
98
-        $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n";
99
-        $request .= "Content-Type: application/x-www-form-urlencoded\r\n";
100
-        $request .= "Content-length: " . strlen($content) . "\r\n";
101
-        $request .= "Connection: close\r\n\r\n";
102
-        $request .= $content . "\r\n\r\n";
103
-
104
-        $this->socket->fwrite($request);
105
-        $response = '';
106
-
107
-        while (!$this->socket->feof()) {
108
-            $response .= $this->socket->fgets(4096);
109
-        }
110
-
111
-        $this->socket->fclose();
112
-
113
-        if (0 !== strpos($response, 'HTTP/1.1 200 OK')) {
114
-            return self::BAD_RESPONSE;
115
-        }
116
-
117
-        $parts = preg_split("#\n\s*\n#Uis", $response);
118
-
119
-        return $parts[1];
120
-    }
39
+	/**
40
+	 * reCAPTCHA service host.
41
+	 * @const string
42
+	 */
43
+	const RECAPTCHA_HOST = 'www.google.com';
44
+
45
+	/**
46
+	 * @const string reCAPTCHA service path
47
+	 */
48
+	const SITE_VERIFY_PATH = '/recaptcha/api/siteverify';
49
+
50
+	/**
51
+	 * @const string Bad request error
52
+	 */
53
+	const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}';
54
+
55
+	/**
56
+	 * @const string Bad response error
57
+	 */
58
+	const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}';
59
+
60
+	/**
61
+	 * Socket to the reCAPTCHA service
62
+	 * @var Socket
63
+	 */
64
+	private $socket;
65
+
66
+	/**
67
+	 * Constructor
68
+	 *
69
+	 * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
70
+	 */
71
+	public function __construct(Socket $socket = null)
72
+	{
73
+		if (!is_null($socket)) {
74
+			$this->socket = $socket;
75
+		} else {
76
+			$this->socket = new Socket();
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * Submit the POST request with the specified parameters.
82
+	 *
83
+	 * @param RequestParameters $params Request parameters
84
+	 * @return string Body of the reCAPTCHA response
85
+	 */
86
+	public function submit(RequestParameters $params)
87
+	{
88
+		$errno = 0;
89
+		$errstr = '';
90
+
91
+		if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) {
92
+			return self::BAD_REQUEST;
93
+		}
94
+
95
+		$content = $params->toQueryString();
96
+
97
+		$request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n";
98
+		$request .= "Host: " . self::RECAPTCHA_HOST . "\r\n";
99
+		$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
100
+		$request .= "Content-length: " . strlen($content) . "\r\n";
101
+		$request .= "Connection: close\r\n\r\n";
102
+		$request .= $content . "\r\n\r\n";
103
+
104
+		$this->socket->fwrite($request);
105
+		$response = '';
106
+
107
+		while (!$this->socket->feof()) {
108
+			$response .= $this->socket->fgets(4096);
109
+		}
110
+
111
+		$this->socket->fclose();
112
+
113
+		if (0 !== strpos($response, 'HTTP/1.1 200 OK')) {
114
+			return self::BAD_RESPONSE;
115
+		}
116
+
117
+		$parts = preg_split("#\n\s*\n#Uis", $response);
118
+
119
+		return $parts[1];
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/Response.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -31,72 +31,72 @@
 block discarded – undo
31 31
  */
32 32
 class Response
33 33
 {
34
-    /**
35
-     * Succes or failure.
36
-     * @var boolean
37
-     */
38
-    private $success = false;
34
+	/**
35
+	 * Succes or failure.
36
+	 * @var boolean
37
+	 */
38
+	private $success = false;
39 39
 
40
-    /**
41
-     * Error code strings.
42
-     * @var array
43
-     */
44
-    private $errorCodes = array();
40
+	/**
41
+	 * Error code strings.
42
+	 * @var array
43
+	 */
44
+	private $errorCodes = array();
45 45
 
46
-    /**
47
-     * Build the response from the expected JSON returned by the service.
48
-     *
49
-     * @param string $json
50
-     * @return \ReCaptcha\Response
51
-     */
52
-    public static function fromJson($json)
53
-    {
54
-        $responseData = json_decode($json, true);
46
+	/**
47
+	 * Build the response from the expected JSON returned by the service.
48
+	 *
49
+	 * @param string $json
50
+	 * @return \ReCaptcha\Response
51
+	 */
52
+	public static function fromJson($json)
53
+	{
54
+		$responseData = json_decode($json, true);
55 55
 
56
-        if (!$responseData) {
57
-            return new Response(false, array('invalid-json'));
58
-        }
56
+		if (!$responseData) {
57
+			return new Response(false, array('invalid-json'));
58
+		}
59 59
 
60
-        if (isset($responseData['success']) && $responseData['success'] == true) {
61
-            return new Response(true);
62
-        }
60
+		if (isset($responseData['success']) && $responseData['success'] == true) {
61
+			return new Response(true);
62
+		}
63 63
 
64
-        if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
65
-            return new Response(false, $responseData['error-codes']);
66
-        }
64
+		if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
65
+			return new Response(false, $responseData['error-codes']);
66
+		}
67 67
 
68
-        return new Response(false);
69
-    }
68
+		return new Response(false);
69
+	}
70 70
 
71
-    /**
72
-     * Constructor.
73
-     *
74
-     * @param boolean $success
75
-     * @param array $errorCodes
76
-     */
77
-    public function __construct($success, array $errorCodes = array())
78
-    {
79
-        $this->success = $success;
80
-        $this->errorCodes = $errorCodes;
81
-    }
71
+	/**
72
+	 * Constructor.
73
+	 *
74
+	 * @param boolean $success
75
+	 * @param array $errorCodes
76
+	 */
77
+	public function __construct($success, array $errorCodes = array())
78
+	{
79
+		$this->success = $success;
80
+		$this->errorCodes = $errorCodes;
81
+	}
82 82
 
83
-    /**
84
-     * Is success?
85
-     *
86
-     * @return boolean
87
-     */
88
-    public function isSuccess()
89
-    {
90
-        return $this->success;
91
-    }
83
+	/**
84
+	 * Is success?
85
+	 *
86
+	 * @return boolean
87
+	 */
88
+	public function isSuccess()
89
+	{
90
+		return $this->success;
91
+	}
92 92
 
93
-    /**
94
-     * Get error codes.
95
-     *
96
-     * @return array
97
-     */
98
-    public function getErrorCodes()
99
-    {
100
-        return $this->errorCodes;
101
-    }
93
+	/**
94
+	 * Get error codes.
95
+	 *
96
+	 * @return array
97
+	 */
98
+	public function getErrorCodes()
99
+	{
100
+		return $this->errorCodes;
101
+	}
102 102
 }
Please login to merge, or discard this patch.
Sources/CacheAPI-sqlite.php 2 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * SQLite Cache API class
@@ -153,8 +154,7 @@  discard block
 block discarded – undo
153 154
 		if (is_null($dir) || !is_writable($dir))
154 155
 		{
155 156
 			$this->cachedir = $cachedir_sqlite;
156
-		}
157
-		else
157
+		} else
158 158
 		{
159 159
 			$this->cachedir = $dir;
160 160
 		}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 *
144 144
 	 * @param string $dir A valid path
145 145
 	 *
146
-	 * @return boolean If this was successful or not.
146
+	 * @return boolean|null If this was successful or not.
147 147
 	 */
148 148
 	public function setCachedir($dir = null)
149 149
 	{
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * Display a list of upcoming events, birthdays, and holidays.
69 69
  *
70 70
  * @param string $grid_name The grid name
71
- * @return void|bool Returns false if the grid doesn't exist.
71
+ * @return false|null Returns false if the grid doesn't exist.
72 72
  */
73 73
 function template_show_upcoming_list($grid_name)
74 74
 {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @param string $grid_name The grid name
240 240
  * @param bool $is_mini Is this a mini grid?
241
- * @return void|bool Returns false if the grid doesn't exist.
241
+ * @return false|null Returns false if the grid doesn't exist.
242 242
  */
243 243
 function template_show_month_grid($grid_name, $is_mini = false)
244 244
 {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
  * Shows a weekly grid
524 524
  *
525 525
  * @param string $grid_name The name of the grid
526
- * @return void|bool Returns false if the grid doesn't exist
526
+ * @return false|null Returns false if the grid doesn't exist
527 527
  */
528 528
 function template_show_week_grid($grid_name)
529 529
 {
Please login to merge, or discard this patch.
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   +152 added lines, -116 removed lines patch added patch discarded remove patch
@@ -40,16 +40,14 @@  discard block
 block discarded – undo
40 40
 				', template_show_upcoming_list('main'), '
41 41
 			</div>
42 42
 		';
43
-	}
44
-	elseif ($context['calendar_view'] == 'view_week')
43
+	} elseif ($context['calendar_view'] == 'view_week')
45 44
 	{
46 45
 		echo '
47 46
 			<div id="main_grid">
48 47
 				', template_show_week_grid('main'), '
49 48
 			</div>
50 49
 		';
51
-	}
52
-	else
50
+	} else
53 51
 	{
54 52
 		echo '
55 53
 			<div id="main_grid">
@@ -75,8 +73,9 @@  discard block
 block discarded – undo
75 73
 	global $context, $scripturl, $txt;
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,17 +405,19 @@  discard block
 block discarded – undo
392 405
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
393 406
 
394 407
 				// The actual day number - be it a link, or just plain old text!
395
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
396
-					echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
397
-				else
398
-					echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
408
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
409
+									echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
410
+				} else {
411
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
412
+				}
399 413
 
400 414
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
401 415
 				if ($is_mini === false)
402 416
 				{
403 417
 					// Holidays are always fun, let's show them!
404
-					if (!empty($day['holidays']))
405
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
418
+					if (!empty($day['holidays'])) {
419
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
420
+					}
406 421
 
407 422
 					// Happy Birthday Dear, Member!
408 423
 					if (!empty($day['birthdays']))
@@ -420,14 +435,16 @@  discard block
 block discarded – undo
420 435
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
421 436
 
422 437
 							// 9...10! Let's stop there.
423
-							if ($birthday_count == 10 && $use_js_hide)
424
-								// !!TODO - Inline CSS and JavaScript should be moved.
438
+							if ($birthday_count == 10 && $use_js_hide) {
439
+															// !!TODO - Inline CSS and JavaScript should be moved.
425 440
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
441
+							}
426 442
 
427 443
 							++$birthday_count;
428 444
 						}
429
-						if ($use_js_hide)
430
-							echo '</span>';
445
+						if ($use_js_hide) {
446
+													echo '</span>';
447
+						}
431 448
 
432 449
 						echo '</div>';
433 450
 					}
@@ -437,8 +454,9 @@  discard block
 block discarded – undo
437 454
 					{
438 455
 						// Sort events by start time (all day events will be listed first)
439 456
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
457
+						    if ($a['start_timestamp'] == $b['start_timestamp']) {
458
+						    						        return 0;
459
+						    }
442 460
 						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 461
 						});
444 462
 
@@ -454,17 +472,19 @@  discard block
 block discarded – undo
454 472
 
455 473
 							echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
456 474
 
457
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
458
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
459
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
460
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
461
-							elseif (!empty($event['allday']))
462
-								echo $txt['calendar_allday'];
475
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
476
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
477
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
478
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
479
+							} elseif (!empty($event['allday'])) {
480
+															echo $txt['calendar_allday'];
481
+							}
463 482
 
464 483
 							echo '</span>';
465 484
 
466
-							if (!empty($event['location']))
467
-								echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
485
+							if (!empty($event['location'])) {
486
+															echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
487
+							}
468 488
 
469 489
 							if ($event['can_edit'] || $event['can_export'])
470 490
 							{
@@ -501,10 +521,11 @@  discard block
 block discarded – undo
501 521
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
502 522
 			elseif ($is_mini === false)
503 523
 			{
504
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
505
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
506
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
507
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
524
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
525
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
526
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
527
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
528
+				}
508 529
 			}
509 530
 
510 531
 			// Close this day and increase var count.
@@ -530,8 +551,9 @@  discard block
 block discarded – undo
530 551
 	global $context, $txt, $scripturl, $modSettings;
531 552
 
532 553
 	// We might have no reason to proceed, if the variable isn't there.
533
-	if (!isset($context['calendar_grid_' . $grid_name]))
534
-		return false;
554
+	if (!isset($context['calendar_grid_' . $grid_name])) {
555
+			return false;
556
+	}
535 557
 
536 558
 	// Handy pointer.
537 559
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -566,8 +588,9 @@  discard block
 block discarded – undo
566 588
 					}
567 589
 
568 590
 					// The Month Title + Week Number...
569
-					if (!empty($calendar_data['week_title']))
570
-							echo $calendar_data['week_title'];
591
+					if (!empty($calendar_data['week_title'])) {
592
+												echo $calendar_data['week_title'];
593
+					}
571 594
 
572 595
 					echo '
573 596
 					</h3>
@@ -606,10 +629,11 @@  discard block
 block discarded – undo
606 629
 						<tr class="days_wrapper">
607 630
 							<td class="', implode(' ', $classes), ' act_day">';
608 631
 							// Should the day number be a link?
609
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
610
-								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>';
611
-							else
612
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
632
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
633
+															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>';
634
+							} else {
635
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
636
+							}
613 637
 
614 638
 							echo '</td>
615 639
 							<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'] : '', '">';
@@ -618,8 +642,9 @@  discard block
 block discarded – undo
618 642
 							{
619 643
 								// Sort events by start time (all day events will be listed first)
620 644
 								uasort($day['events'], function($a, $b) {
621
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
622
-								        return 0;
645
+								    if ($a['start_timestamp'] == $b['start_timestamp']) {
646
+								    								        return 0;
647
+								    }
623 648
 								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
624 649
 								});
625 650
 
@@ -631,15 +656,17 @@  discard block
 block discarded – undo
631 656
 
632 657
 									echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
633 658
 
634
-									if (!empty($event['start_time_local']))
635
-										echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
636
-									else
637
-										echo $txt['calendar_allday'];
659
+									if (!empty($event['start_time_local'])) {
660
+																			echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
661
+									} else {
662
+																			echo $txt['calendar_allday'];
663
+									}
638 664
 
639 665
 									echo '</span>';
640 666
 
641
-									if (!empty($event['location']))
642
-										echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
667
+									if (!empty($event['location'])) {
668
+																			echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
669
+									}
643 670
 
644 671
 									if (!empty($event_icons_needed))
645 672
 									{
@@ -676,8 +703,7 @@  discard block
 block discarded – undo
676 703
 									</div>
677 704
 									<br class="clear">';
678 705
 								}
679
-							}
680
-							else
706
+							} else
681 707
 							{
682 708
 								if (!empty($context['can_post']))
683 709
 								{
@@ -690,8 +716,9 @@  discard block
 block discarded – undo
690 716
 							echo '</td>
691 717
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
692 718
 							// Show any holidays!
693
-							if (!empty($day['holidays']))
694
-								echo implode('<br>', $day['holidays']);
719
+							if (!empty($day['holidays'])) {
720
+															echo implode('<br>', $day['holidays']);
721
+							}
695 722
 
696 723
 							echo '</td>
697 724
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">';
@@ -749,8 +776,7 @@  discard block
 block discarded – undo
749 776
 				<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">
750 777
 				<input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '">
751 778
 			</form>';
752
-	}
753
-	else
779
+	} else
754 780
 	{
755 781
 		echo'
756 782
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
@@ -792,8 +818,9 @@  discard block
 block discarded – undo
792 818
 	echo '
793 819
 		<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;">';
794 820
 
795
-	if (!empty($context['event']['new']))
796
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
821
+	if (!empty($context['event']['new'])) {
822
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
823
+	}
797 824
 
798 825
 	// Start the main table.
799 826
 	echo '
@@ -843,9 +870,10 @@  discard block
 block discarded – undo
843 870
 		{
844 871
 			echo '
845 872
 								<optgroup label="', $category['name'], '">';
846
-			foreach ($category['boards'] as $board)
847
-				echo '
873
+			foreach ($category['boards'] as $board) {
874
+							echo '
848 875
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
876
+			}
849 877
 			echo '
850 878
 								</optgroup>';
851 879
 		}
@@ -881,9 +909,10 @@  discard block
 block discarded – undo
881 909
 							<span class="label">', $txt['calendar_timezone'], '</span>
882 910
 							<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
883 911
 
884
-	foreach ($context['all_timezones'] as $tz => $tzname)
885
-		echo '
912
+	foreach ($context['all_timezones'] as $tz => $tzname) {
913
+			echo '
886 914
 								<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
915
+	}
887 916
 
888 917
 	echo '
889 918
 							</select>
@@ -898,9 +927,10 @@  discard block
 block discarded – undo
898 927
 	echo '
899 928
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
900 929
 	// Delete button?
901
-	if (empty($context['event']['new']))
902
-		echo '
930
+	if (empty($context['event']['new'])) {
931
+			echo '
903 932
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
933
+	}
904 934
 
905 935
 	echo '
906 936
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -944,9 +974,10 @@  discard block
 block discarded – undo
944 974
 
945 975
 		foreach ($context['clockicons'] as $t => $v)
946 976
 		{
947
-			foreach ($v as $i)
948
-				echo '
977
+			foreach ($v as $i) {
978
+							echo '
949 979
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
980
+			}
950 981
 		}
951 982
 
952 983
 		echo '
@@ -971,13 +1002,14 @@  discard block
 block discarded – undo
971 1002
 
972 1003
 		foreach ($context['clockicons'] as $t => $v)
973 1004
 		{
974
-			foreach ($v as $i)
975
-				echo '
1005
+			foreach ($v as $i) {
1006
+							echo '
976 1007
 			if (', $t, ' >= ', $i, ')
977 1008
 			{
978 1009
 				turnon.push("', $t, '_', $i, '");
979 1010
 				', $t, ' -= ', $i, ';
980 1011
 			}';
1012
+			}
981 1013
 		}
982 1014
 
983 1015
 		echo '
@@ -1041,9 +1073,10 @@  discard block
 block discarded – undo
1041 1073
 
1042 1074
 	foreach ($context['clockicons'] as $t => $v)
1043 1075
 	{
1044
-		foreach ($v as $i)
1045
-			echo '
1076
+		foreach ($v as $i) {
1077
+					echo '
1046 1078
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1079
+		}
1047 1080
 	}
1048 1081
 
1049 1082
 	echo '
@@ -1060,13 +1093,14 @@  discard block
 block discarded – undo
1060 1093
 
1061 1094
 	foreach ($context['clockicons'] as $t => $v)
1062 1095
 	{
1063
-		foreach ($v as $i)
1064
-			echo '
1096
+		foreach ($v as $i) {
1097
+					echo '
1065 1098
 		if (', $t, ' >= ', $i, ')
1066 1099
 		{
1067 1100
 			turnon.push("', $t, '_', $i, '");
1068 1101
 			', $t, ' -= ', $i, ';
1069 1102
 		}';
1103
+		}
1070 1104
 	}
1071 1105
 
1072 1106
 	echo '
@@ -1125,9 +1159,10 @@  discard block
 block discarded – undo
1125 1159
 
1126 1160
 	foreach ($context['clockicons'] as $t => $v)
1127 1161
 	{
1128
-		foreach ($v as $i)
1129
-			echo '
1162
+		foreach ($v as $i) {
1163
+					echo '
1130 1164
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1165
+		}
1131 1166
 	}
1132 1167
 
1133 1168
 	echo '
@@ -1148,13 +1183,14 @@  discard block
 block discarded – undo
1148 1183
 
1149 1184
 	foreach ($context['clockicons'] as $t => $v)
1150 1185
 	{
1151
-		foreach ($v as $i)
1152
-		echo '
1186
+		foreach ($v as $i) {
1187
+				echo '
1153 1188
 		if (', $t, ' >= ', $i, ')
1154 1189
 		{
1155 1190
 			turnon.push("', $t, '_', $i, '");
1156 1191
 			', $t, ' -= ', $i, ';
1157 1192
 		}';
1193
+		}
1158 1194
 	}
1159 1195
 
1160 1196
 	echo '
Please login to merge, or discard this patch.
other/upgrade.php 4 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -388,6 +388,9 @@  discard block
 block discarded – undo
388 388
 }
389 389
 
390 390
 // Used to direct the user to another location.
391
+/**
392
+ * @param string $location
393
+ */
391 394
 function redirectLocation($location, $addForm = true)
392 395
 {
393 396
 	global $upgradeurl, $upcontext, $command_line;
@@ -1560,6 +1563,9 @@  discard block
 block discarded – undo
1560 1563
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
1561 1564
 }
1562 1565
 
1566
+/**
1567
+ * @param string $filename
1568
+ */
1563 1569
 function parse_sql($filename)
1564 1570
 {
1565 1571
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -1594,6 +1600,10 @@  discard block
 block discarded – undo
1594 1600
 
1595 1601
 	// Our custom error handler - does nothing but does stop public errors from XML!
1596 1602
 	set_error_handler(
1603
+
1604
+		/**
1605
+		 * @param string $errno
1606
+		 */
1597 1607
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1598 1608
 		{
1599 1609
 			if ($support_js)
@@ -1840,6 +1850,9 @@  discard block
 block discarded – undo
1840 1850
 	return true;
1841 1851
 }
1842 1852
 
1853
+/**
1854
+ * @param string $string
1855
+ */
1843 1856
 function upgrade_query($string, $unbuffered = false)
1844 1857
 {
1845 1858
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -4495,7 +4508,7 @@  discard block
 block discarded – undo
4495 4508
  * @param int $setSize The amount of entries after which to update the database.
4496 4509
  *
4497 4510
  * newCol needs to be a varbinary(16) null able field
4498
- * @return bool
4511
+ * @return boolean|null
4499 4512
  */
4500 4513
 function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100)
4501 4514
 {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 
83 83
 // The helper is crucial. Include it first thing.
84 84
 if (!file_exists($upgrade_path . '/upgrade-helper.php'))
85
-    die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
85
+	die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
86 86
 
87 87
 require_once($upgrade_path . '/upgrade-helper.php');
88 88
 
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 
1611 1611
 	// Our custom error handler - does nothing but does stop public errors from XML!
1612 1612
 	set_error_handler(
1613
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1613
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1614 1614
 		{
1615 1615
 			if ($support_js)
1616 1616
 				return true;
@@ -2595,94 +2595,94 @@  discard block
 block discarded – undo
2595 2595
 		// Translation table for the character sets not native for MySQL.
2596 2596
 		$translation_tables = array(
2597 2597
 			'windows-1255' => array(
2598
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2599
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2600
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2601
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2602
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2603
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2604
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2605
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2606
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2607
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2608
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2609
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2610
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2611
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2612
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2613
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2614
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2615
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2616
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2617
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2618
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2619
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2620
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2621
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2622
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2623
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2624
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2625
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2626
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2627
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2628
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2629
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2630
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2631
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2632
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2633
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2634
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2635
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2636
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2637
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2638
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2639
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2598
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2599
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2600
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2601
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2602
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2603
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2604
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2605
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2606
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2607
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2608
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2609
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2610
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2611
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2612
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2613
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2614
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2615
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2616
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2617
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2618
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2619
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2620
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2621
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2622
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2623
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2624
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2625
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2626
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2627
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2628
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2629
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2630
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2631
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2632
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2633
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2634
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2635
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2636
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2637
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2638
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2639
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2640 2640
 				'0xFA' => '0xD7AA',
2641 2641
 			),
2642 2642
 			'windows-1253' => array(
2643
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2644
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2645
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2646
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2647
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2648
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2649
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2650
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2651
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2652
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2653
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2654
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2655
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2656
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2657
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2658
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2659
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2660
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2661
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2662
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2663
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2664
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2665
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2666
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2667
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2668
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2669
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2670
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2671
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2672
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2673
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2674
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2675
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2676
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2677
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2678
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2679
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2680
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2681
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2682
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2683
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2684
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2685
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2643
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2644
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2645
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2646
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2647
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2648
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2649
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2650
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2651
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2652
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2653
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2654
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2655
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2656
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2657
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2658
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2659
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2660
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2661
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2662
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2663
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2664
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2665
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2666
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2667
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2668
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2669
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2670
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2671
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2672
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2673
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2674
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2675
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2676
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2677
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2678
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2679
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2680
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2681
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2682
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2683
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2684
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2685
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2686 2686
 			),
2687 2687
 		);
2688 2688
 
@@ -3781,7 +3781,7 @@  discard block
 block discarded – undo
3781 3781
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
3782 3782
 			<input type="hidden" name="backup_done" id="backup_done" value="0">
3783 3783
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
3784
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
3784
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
3785 3785
 			<span id="debuginfo"></span>
3786 3786
 			</div>';
3787 3787
 
@@ -4282,7 +4282,7 @@  discard block
 block discarded – undo
4282 4282
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4283 4283
 			<input type="hidden" name="utf8_done" id="utf8_done" value="0">
4284 4284
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4285
-			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;">
4285
+			<div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;">
4286 4286
 			<span id="debuginfo"></span>
4287 4287
 			</div>';
4288 4288
 
@@ -4383,7 +4383,7 @@  discard block
 block discarded – undo
4383 4383
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4384 4384
 			<input type="hidden" name="json_done" id="json_done" value="0">
4385 4385
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4386
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
4386
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
4387 4387
 			<span id="debuginfo"></span>
4388 4388
 			</div>';
4389 4389
 
Please login to merge, or discard this patch.
Braces   +874 added lines, -642 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' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats']))
@@ -939,25 +997,26 @@  discard block
 block discarded – undo
939 997
 			fwrite($fp, $out);
940 998
 
941 999
 			$return_data = '';
942
-			while (!feof($fp))
943
-				$return_data .= fgets($fp, 128);
1000
+			while (!feof($fp)) {
1001
+							$return_data .= fgets($fp, 128);
1002
+			}
944 1003
 
945 1004
 			fclose($fp);
946 1005
 
947 1006
 			// Get the unique site ID.
948 1007
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
949 1008
 
950
-			if (!empty($ID[1]))
951
-				$smcFunc['db_insert']('replace',
1009
+			if (!empty($ID[1])) {
1010
+							$smcFunc['db_insert']('replace',
952 1011
 					$db_prefix . 'settings',
953 1012
 					array('variable' => 'string', 'value' => 'string'),
954 1013
 					array('allow_sm_stats', $ID[1]),
955 1014
 					array('variable')
956 1015
 				);
1016
+			}
957 1017
 		}
958
-	}
959
-	else
960
-		$smcFunc['db_query']('', '
1018
+	} else {
1019
+			$smcFunc['db_query']('', '
961 1020
 			DELETE FROM {db_prefix}settings
962 1021
 			WHERE variable = {string:allow_sm_stats}',
963 1022
 			array(
@@ -965,6 +1024,7 @@  discard block
 block discarded – undo
965 1024
 				'db_error_skip' => true,
966 1025
 			)
967 1026
 		);
1027
+	}
968 1028
 
969 1029
 	// Deleting old karma stuff?
970 1030
 	if (!empty($_POST['delete_karma']))
@@ -979,20 +1039,22 @@  discard block
 block discarded – undo
979 1039
 		);
980 1040
 
981 1041
 		// Cleaning up old karma member settings.
982
-		if ($upcontext['karma_installed']['good'])
983
-			$smcFunc['db_query']('', '
1042
+		if ($upcontext['karma_installed']['good']) {
1043
+					$smcFunc['db_query']('', '
984 1044
 				ALTER TABLE {db_prefix}members
985 1045
 				DROP karma_good',
986 1046
 				array()
987 1047
 			);
1048
+		}
988 1049
 
989 1050
 		// Does karma bad was enable?
990
-		if ($upcontext['karma_installed']['bad'])
991
-			$smcFunc['db_query']('', '
1051
+		if ($upcontext['karma_installed']['bad']) {
1052
+					$smcFunc['db_query']('', '
992 1053
 				ALTER TABLE {db_prefix}members
993 1054
 				DROP karma_bad',
994 1055
 				array()
995 1056
 			);
1057
+		}
996 1058
 
997 1059
 		// Cleaning up old karma permissions.
998 1060
 		$smcFunc['db_query']('', '
@@ -1005,26 +1067,29 @@  discard block
 block discarded – undo
1005 1067
 	}
1006 1068
 
1007 1069
 	// Emptying the error log?
1008
-	if (!empty($_POST['empty_error']))
1009
-		$smcFunc['db_query']('truncate_table', '
1070
+	if (!empty($_POST['empty_error'])) {
1071
+			$smcFunc['db_query']('truncate_table', '
1010 1072
 			TRUNCATE {db_prefix}log_errors',
1011 1073
 			array(
1012 1074
 			)
1013 1075
 		);
1076
+	}
1014 1077
 
1015 1078
 	$changes = array();
1016 1079
 
1017 1080
 	// Add proxy settings.
1018
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1019
-		$changes += array(
1081
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1082
+			$changes += array(
1020 1083
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1021 1084
 			'image_proxy_maxsize' => 5190,
1022 1085
 			'image_proxy_enabled' => 0,
1023 1086
 		);
1087
+	}
1024 1088
 
1025 1089
 	// If we're overriding the language follow it through.
1026
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1027
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1090
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1091
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1092
+	}
1028 1093
 
1029 1094
 	if (!empty($_POST['maint']))
1030 1095
 	{
@@ -1036,30 +1101,34 @@  discard block
 block discarded – undo
1036 1101
 		{
1037 1102
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1038 1103
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1039
-		}
1040
-		else
1104
+		} else
1041 1105
 		{
1042 1106
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1043 1107
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1044 1108
 		}
1045 1109
 	}
1046 1110
 
1047
-	if ($command_line)
1048
-		echo ' * Updating Settings.php...';
1111
+	if ($command_line) {
1112
+			echo ' * Updating Settings.php...';
1113
+	}
1049 1114
 
1050 1115
 	// Fix some old paths.
1051
-	if (substr($boarddir, 0, 1) == '.')
1052
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1116
+	if (substr($boarddir, 0, 1) == '.') {
1117
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1118
+	}
1053 1119
 
1054
-	if (substr($sourcedir, 0, 1) == '.')
1055
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1120
+	if (substr($sourcedir, 0, 1) == '.') {
1121
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1122
+	}
1056 1123
 
1057
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1058
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1124
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1125
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1126
+	}
1059 1127
 
1060 1128
 	// Not had the database type added before?
1061
-	if (empty($db_type))
1062
-		$changes['db_type'] = 'mysql';
1129
+	if (empty($db_type)) {
1130
+			$changes['db_type'] = 'mysql';
1131
+	}
1063 1132
 
1064 1133
 	// If they have a "host:port" setup for the host, split that into separate values
1065 1134
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1070,32 +1139,36 @@  discard block
 block discarded – undo
1070 1139
 		$changes['db_server'] = '\'' . $db_server . '\'';
1071 1140
 
1072 1141
 		// Only set this if we're not using the default port
1073
-		if ($db_port != ini_get('mysqli.default_port'))
1074
-			$changes['db_port'] = (int) $db_port;
1075
-	}
1076
-	elseif (!empty($db_port))
1142
+		if ($db_port != ini_get('mysqli.default_port')) {
1143
+					$changes['db_port'] = (int) $db_port;
1144
+		}
1145
+	} elseif (!empty($db_port))
1077 1146
 	{
1078 1147
 		// If db_port is set and is the same as the default, set it to ''
1079 1148
 		if ($db_type == 'mysql')
1080 1149
 		{
1081
-			if ($db_port == ini_get('mysqli.default_port'))
1082
-				$changes['db_port'] = '\'\'';
1083
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1084
-				$changes['db_port'] = '\'\'';
1150
+			if ($db_port == ini_get('mysqli.default_port')) {
1151
+							$changes['db_port'] = '\'\'';
1152
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1153
+							$changes['db_port'] = '\'\'';
1154
+			}
1085 1155
 		}
1086 1156
 	}
1087 1157
 
1088 1158
 	// Maybe we haven't had this option yet?
1089
-	if (empty($packagesdir))
1090
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1159
+	if (empty($packagesdir)) {
1160
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1161
+	}
1091 1162
 
1092 1163
 	// Add support for $tasksdir var.
1093
-	if (empty($tasksdir))
1094
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1164
+	if (empty($tasksdir)) {
1165
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1166
+	}
1095 1167
 
1096 1168
 	// Make sure we fix the language as well.
1097
-	if (stristr($language, '-utf8'))
1098
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1169
+	if (stristr($language, '-utf8')) {
1170
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1171
+	}
1099 1172
 
1100 1173
 	// @todo Maybe change the cookie name if going to 1.1, too?
1101 1174
 
@@ -1103,8 +1176,9 @@  discard block
 block discarded – undo
1103 1176
 	require_once($sourcedir . '/Subs-Admin.php');
1104 1177
 	updateSettingsFile($changes);
1105 1178
 
1106
-	if ($command_line)
1107
-		echo ' Successful.' . "\n";
1179
+	if ($command_line) {
1180
+			echo ' Successful.' . "\n";
1181
+	}
1108 1182
 
1109 1183
 	// Are we doing debug?
1110 1184
 	if (isset($_POST['debug']))
@@ -1114,8 +1188,9 @@  discard block
 block discarded – undo
1114 1188
 	}
1115 1189
 
1116 1190
 	// If we're not backing up then jump one.
1117
-	if (empty($_POST['backup']))
1118
-		$upcontext['current_step']++;
1191
+	if (empty($_POST['backup'])) {
1192
+			$upcontext['current_step']++;
1193
+	}
1119 1194
 
1120 1195
 	// If we've got here then let's proceed to the next step!
1121 1196
 	return true;
@@ -1130,8 +1205,9 @@  discard block
 block discarded – undo
1130 1205
 	$upcontext['page_title'] = 'Backup Database';
1131 1206
 
1132 1207
 	// Done it already - js wise?
1133
-	if (!empty($_POST['backup_done']))
1134
-		return true;
1208
+	if (!empty($_POST['backup_done'])) {
1209
+			return true;
1210
+	}
1135 1211
 
1136 1212
 	// Some useful stuff here.
1137 1213
 	db_extend();
@@ -1145,9 +1221,10 @@  discard block
 block discarded – undo
1145 1221
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1146 1222
 
1147 1223
 	$table_names = array();
1148
-	foreach ($tables as $table)
1149
-		if (substr($table, 0, 7) !== 'backup_')
1224
+	foreach ($tables as $table) {
1225
+			if (substr($table, 0, 7) !== 'backup_')
1150 1226
 			$table_names[] = $table;
1227
+	}
1151 1228
 
1152 1229
 	$upcontext['table_count'] = count($table_names);
1153 1230
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1157,12 +1234,14 @@  discard block
 block discarded – undo
1157 1234
 	$file_steps = $upcontext['table_count'];
1158 1235
 
1159 1236
 	// What ones have we already done?
1160
-	foreach ($table_names as $id => $table)
1161
-		if ($id < $_GET['substep'])
1237
+	foreach ($table_names as $id => $table) {
1238
+			if ($id < $_GET['substep'])
1162 1239
 			$upcontext['previous_tables'][] = $table;
1240
+	}
1163 1241
 
1164
-	if ($command_line)
1165
-		echo 'Backing Up Tables.';
1242
+	if ($command_line) {
1243
+			echo 'Backing Up Tables.';
1244
+	}
1166 1245
 
1167 1246
 	// If we don't support javascript we backup here.
1168 1247
 	if (!$support_js || isset($_GET['xml']))
@@ -1181,8 +1260,9 @@  discard block
 block discarded – undo
1181 1260
 			backupTable($table_names[$substep]);
1182 1261
 
1183 1262
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1184
-			if (isset($_GET['xml']))
1185
-				return upgradeExit();
1263
+			if (isset($_GET['xml'])) {
1264
+							return upgradeExit();
1265
+			}
1186 1266
 		}
1187 1267
 
1188 1268
 		if ($command_line)
@@ -1215,9 +1295,10 @@  discard block
 block discarded – undo
1215 1295
 
1216 1296
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1217 1297
 
1218
-	if ($command_line)
1219
-		echo ' done.';
1220
-}
1298
+	if ($command_line) {
1299
+			echo ' done.';
1300
+	}
1301
+	}
1221 1302
 
1222 1303
 // Step 2: Everything.
1223 1304
 function DatabaseChanges()
@@ -1226,8 +1307,9 @@  discard block
 block discarded – undo
1226 1307
 	global $upcontext, $support_js, $db_type;
1227 1308
 
1228 1309
 	// Have we just completed this?
1229
-	if (!empty($_POST['database_done']))
1230
-		return true;
1310
+	if (!empty($_POST['database_done'])) {
1311
+			return true;
1312
+	}
1231 1313
 
1232 1314
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1233 1315
 	$upcontext['page_title'] = 'Database Changes';
@@ -1242,15 +1324,16 @@  discard block
 block discarded – undo
1242 1324
 	);
1243 1325
 
1244 1326
 	// How many files are there in total?
1245
-	if (isset($_GET['filecount']))
1246
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1247
-	else
1327
+	if (isset($_GET['filecount'])) {
1328
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1329
+	} else
1248 1330
 	{
1249 1331
 		$upcontext['file_count'] = 0;
1250 1332
 		foreach ($files as $file)
1251 1333
 		{
1252
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1253
-				$upcontext['file_count']++;
1334
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1335
+							$upcontext['file_count']++;
1336
+			}
1254 1337
 		}
1255 1338
 	}
1256 1339
 
@@ -1260,9 +1343,9 @@  discard block
 block discarded – undo
1260 1343
 	$upcontext['cur_file_num'] = 0;
1261 1344
 	foreach ($files as $file)
1262 1345
 	{
1263
-		if ($did_not_do)
1264
-			$did_not_do--;
1265
-		else
1346
+		if ($did_not_do) {
1347
+					$did_not_do--;
1348
+		} else
1266 1349
 		{
1267 1350
 			$upcontext['cur_file_num']++;
1268 1351
 			$upcontext['cur_file_name'] = $file[0];
@@ -1289,12 +1372,13 @@  discard block
 block discarded – undo
1289 1372
 					// Flag to move on to the next.
1290 1373
 					$upcontext['completed_step'] = true;
1291 1374
 					// Did we complete the whole file?
1292
-					if ($nextFile)
1293
-						$upcontext['current_debug_item_num'] = -1;
1375
+					if ($nextFile) {
1376
+											$upcontext['current_debug_item_num'] = -1;
1377
+					}
1294 1378
 					return upgradeExit();
1379
+				} elseif ($support_js) {
1380
+									break;
1295 1381
 				}
1296
-				elseif ($support_js)
1297
-					break;
1298 1382
 			}
1299 1383
 			// Set the progress bar to be right as if we had - even if we hadn't...
1300 1384
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1319,8 +1403,9 @@  discard block
 block discarded – undo
1319 1403
 	global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1320 1404
 
1321 1405
 	// Now it's nice to have some of the basic SMF source files.
1322
-	if (!isset($_GET['ssi']) && !$command_line)
1323
-		redirectLocation('&ssi=1');
1406
+	if (!isset($_GET['ssi']) && !$command_line) {
1407
+			redirectLocation('&ssi=1');
1408
+	}
1324 1409
 
1325 1410
 	$upcontext['sub_template'] = 'upgrade_complete';
1326 1411
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1336,14 +1421,16 @@  discard block
 block discarded – undo
1336 1421
 	// Are we in maintenance mode?
1337 1422
 	if (isset($upcontext['user']['main']))
1338 1423
 	{
1339
-		if ($command_line)
1340
-			echo ' * ';
1424
+		if ($command_line) {
1425
+					echo ' * ';
1426
+		}
1341 1427
 		$upcontext['removed_maintenance'] = true;
1342 1428
 		$changes['maintenance'] = $upcontext['user']['main'];
1343 1429
 	}
1344 1430
 	// Otherwise if somehow we are in 2 let's go to 1.
1345
-	elseif (!empty($maintenance) && $maintenance == 2)
1346
-		$changes['maintenance'] = 1;
1431
+	elseif (!empty($maintenance) && $maintenance == 2) {
1432
+			$changes['maintenance'] = 1;
1433
+	}
1347 1434
 
1348 1435
 	// Wipe this out...
1349 1436
 	$upcontext['user'] = array();
@@ -1358,9 +1445,9 @@  discard block
 block discarded – undo
1358 1445
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1359 1446
 
1360 1447
 	// Now is the perfect time to fetch the SM files.
1361
-	if ($command_line)
1362
-		cli_scheduled_fetchSMfiles();
1363
-	else
1448
+	if ($command_line) {
1449
+			cli_scheduled_fetchSMfiles();
1450
+	} else
1364 1451
 	{
1365 1452
 		require_once($sourcedir . '/ScheduledTasks.php');
1366 1453
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1368,8 +1455,9 @@  discard block
 block discarded – undo
1368 1455
 	}
1369 1456
 
1370 1457
 	// Log what we've done.
1371
-	if (empty($user_info['id']))
1372
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1458
+	if (empty($user_info['id'])) {
1459
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1460
+	}
1373 1461
 
1374 1462
 	// Log the action manually, so CLI still works.
1375 1463
 	$smcFunc['db_insert']('',
@@ -1388,8 +1476,9 @@  discard block
 block discarded – undo
1388 1476
 
1389 1477
 	// Save the current database version.
1390 1478
 	$server_version = $smcFunc['db_server_info']();
1391
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1392
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1479
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1480
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1481
+	}
1393 1482
 
1394 1483
 	if ($command_line)
1395 1484
 	{
@@ -1401,8 +1490,9 @@  discard block
 block discarded – undo
1401 1490
 
1402 1491
 	// Make sure it says we're done.
1403 1492
 	$upcontext['overall_percent'] = 100;
1404
-	if (isset($upcontext['step_progress']))
1405
-		unset($upcontext['step_progress']);
1493
+	if (isset($upcontext['step_progress'])) {
1494
+			unset($upcontext['step_progress']);
1495
+	}
1406 1496
 
1407 1497
 	$_GET['substep'] = 0;
1408 1498
 	return false;
@@ -1413,8 +1503,9 @@  discard block
 block discarded – undo
1413 1503
 {
1414 1504
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1415 1505
 
1416
-	if (empty($modSettings['time_format']))
1417
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1506
+	if (empty($modSettings['time_format'])) {
1507
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1508
+	}
1418 1509
 
1419 1510
 	// What files do we want to get
1420 1511
 	$request = $smcFunc['db_query']('', '
@@ -1448,8 +1539,9 @@  discard block
 block discarded – undo
1448 1539
 		$file_data = fetch_web_data($url);
1449 1540
 
1450 1541
 		// If we got an error - give up - the site might be down.
1451
-		if ($file_data === false)
1452
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1542
+		if ($file_data === false) {
1543
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1544
+		}
1453 1545
 
1454 1546
 		// Save the file to the database.
1455 1547
 		$smcFunc['db_query']('substring', '
@@ -1491,8 +1583,9 @@  discard block
 block discarded – undo
1491 1583
 	$themeData = array();
1492 1584
 	foreach ($values as $variable => $value)
1493 1585
 	{
1494
-		if (!isset($value) || $value === null)
1495
-			$value = 0;
1586
+		if (!isset($value) || $value === null) {
1587
+					$value = 0;
1588
+		}
1496 1589
 
1497 1590
 		$themeData[] = array(0, 1, $variable, $value);
1498 1591
 	}
@@ -1521,8 +1614,9 @@  discard block
 block discarded – undo
1521 1614
 
1522 1615
 	foreach ($values as $variable => $value)
1523 1616
 	{
1524
-		if (empty($modSettings[$value[0]]))
1525
-			continue;
1617
+		if (empty($modSettings[$value[0]])) {
1618
+					continue;
1619
+		}
1526 1620
 
1527 1621
 		$smcFunc['db_query']('', '
1528 1622
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1608,19 +1702,21 @@  discard block
 block discarded – undo
1608 1702
 	set_error_handler(
1609 1703
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1610 1704
 		{
1611
-			if ($support_js)
1612
-				return true;
1613
-			else
1614
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1705
+			if ($support_js) {
1706
+							return true;
1707
+			} else {
1708
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1709
+			}
1615 1710
 		}
1616 1711
 	);
1617 1712
 
1618 1713
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1619 1714
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1620
-	if ($db_type == 'mysql')
1621
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1622
-	else
1623
-		$db_collation = '';
1715
+	if ($db_type == 'mysql') {
1716
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1717
+	} else {
1718
+			$db_collation = '';
1719
+	}
1624 1720
 
1625 1721
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1626 1722
 
@@ -1632,8 +1728,9 @@  discard block
 block discarded – undo
1632 1728
 	$last_step = '';
1633 1729
 
1634 1730
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1635
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1636
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1731
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1732
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1733
+	}
1637 1734
 
1638 1735
 	// Count the total number of steps within this file - for progress.
1639 1736
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1653,15 +1750,18 @@  discard block
 block discarded – undo
1653 1750
 		$do_current = $substep >= $_GET['substep'];
1654 1751
 
1655 1752
 		// Get rid of any comments in the beginning of the line...
1656
-		if (substr(trim($line), 0, 2) === '/*')
1657
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1753
+		if (substr(trim($line), 0, 2) === '/*') {
1754
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1755
+		}
1658 1756
 
1659 1757
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1660
-		if ($is_debug && !$support_js && $command_line)
1661
-			flush();
1758
+		if ($is_debug && !$support_js && $command_line) {
1759
+					flush();
1760
+		}
1662 1761
 
1663
-		if (trim($line) === '')
1664
-			continue;
1762
+		if (trim($line) === '') {
1763
+					continue;
1764
+		}
1665 1765
 
1666 1766
 		if (trim(substr($line, 0, 3)) === '---')
1667 1767
 		{
@@ -1671,8 +1771,9 @@  discard block
 block discarded – undo
1671 1771
 			if (trim($current_data) != '' && $type !== '}')
1672 1772
 			{
1673 1773
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1674
-				if ($command_line)
1675
-					echo $upcontext['error_message'];
1774
+				if ($command_line) {
1775
+									echo $upcontext['error_message'];
1776
+				}
1676 1777
 			}
1677 1778
 
1678 1779
 			if ($type == ' ')
@@ -1690,17 +1791,18 @@  discard block
 block discarded – undo
1690 1791
 				if ($do_current)
1691 1792
 				{
1692 1793
 					$upcontext['actioned_items'][] = $last_step;
1693
-					if ($command_line)
1694
-						echo ' * ';
1794
+					if ($command_line) {
1795
+											echo ' * ';
1796
+					}
1695 1797
 				}
1696
-			}
1697
-			elseif ($type == '#')
1798
+			} elseif ($type == '#')
1698 1799
 			{
1699 1800
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1700 1801
 
1701 1802
 				$upcontext['current_debug_item_num']++;
1702
-				if (trim($line) != '---#')
1703
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1803
+				if (trim($line) != '---#') {
1804
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1805
+				}
1704 1806
 
1705 1807
 				// Have we already done something?
1706 1808
 				if (isset($_GET['xml']) && $done_something)
@@ -1711,34 +1813,36 @@  discard block
 block discarded – undo
1711 1813
 
1712 1814
 				if ($do_current)
1713 1815
 				{
1714
-					if (trim($line) == '---#' && $command_line)
1715
-						echo ' done.', $endl;
1716
-					elseif ($command_line)
1717
-						echo ' +++ ', rtrim(substr($line, 4));
1718
-					elseif (trim($line) != '---#')
1816
+					if (trim($line) == '---#' && $command_line) {
1817
+											echo ' done.', $endl;
1818
+					} elseif ($command_line) {
1819
+											echo ' +++ ', rtrim(substr($line, 4));
1820
+					} elseif (trim($line) != '---#')
1719 1821
 					{
1720
-						if ($is_debug)
1721
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1822
+						if ($is_debug) {
1823
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1824
+						}
1722 1825
 					}
1723 1826
 				}
1724 1827
 
1725 1828
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1726 1829
 				{
1727
-					if ($command_line)
1728
-						echo ' * ';
1729
-					else
1730
-						$upcontext['actioned_items'][] = $last_step;
1830
+					if ($command_line) {
1831
+											echo ' * ';
1832
+					} else {
1833
+											$upcontext['actioned_items'][] = $last_step;
1834
+					}
1731 1835
 				}
1732 1836
 
1733 1837
 				// Small step - only if we're actually doing stuff.
1734
-				if ($do_current)
1735
-					nextSubstep(++$substep);
1736
-				else
1737
-					$substep++;
1738
-			}
1739
-			elseif ($type == '{')
1740
-				$current_type = 'code';
1741
-			elseif ($type == '}')
1838
+				if ($do_current) {
1839
+									nextSubstep(++$substep);
1840
+				} else {
1841
+									$substep++;
1842
+				}
1843
+			} elseif ($type == '{') {
1844
+							$current_type = 'code';
1845
+			} elseif ($type == '}')
1742 1846
 			{
1743 1847
 				$current_type = 'sql';
1744 1848
 
@@ -1751,8 +1855,9 @@  discard block
 block discarded – undo
1751 1855
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1752 1856
 				{
1753 1857
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1754
-					if ($command_line)
1755
-						echo $upcontext['error_message'];
1858
+					if ($command_line) {
1859
+											echo $upcontext['error_message'];
1860
+					}
1756 1861
 				}
1757 1862
 
1758 1863
 				// Done with code!
@@ -1832,8 +1937,9 @@  discard block
 block discarded – undo
1832 1937
 	$db_unbuffered = false;
1833 1938
 
1834 1939
 	// Failure?!
1835
-	if ($result !== false)
1836
-		return $result;
1940
+	if ($result !== false) {
1941
+			return $result;
1942
+	}
1837 1943
 
1838 1944
 	$db_error_message = $smcFunc['db_error']($db_connection);
1839 1945
 	// If MySQL we do something more clever.
@@ -1861,54 +1967,61 @@  discard block
 block discarded – undo
1861 1967
 			{
1862 1968
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1863 1969
 				$result = mysqli_query($db_connection, $string);
1864
-				if ($result !== false)
1865
-					return $result;
1970
+				if ($result !== false) {
1971
+									return $result;
1972
+				}
1866 1973
 			}
1867
-		}
1868
-		elseif ($mysqli_errno == 2013)
1974
+		} elseif ($mysqli_errno == 2013)
1869 1975
 		{
1870 1976
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1871 1977
 			mysqli_select_db($db_connection, $db_name);
1872 1978
 			if ($db_connection)
1873 1979
 			{
1874 1980
 				$result = mysqli_query($db_connection, $string);
1875
-				if ($result !== false)
1876
-					return $result;
1981
+				if ($result !== false) {
1982
+									return $result;
1983
+				}
1877 1984
 			}
1878 1985
 		}
1879 1986
 		// Duplicate column name... should be okay ;).
1880
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1881
-			return false;
1987
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
1988
+					return false;
1989
+		}
1882 1990
 		// Duplicate insert... make sure it's the proper type of query ;).
1883
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1884
-			return false;
1991
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
1992
+					return false;
1993
+		}
1885 1994
 		// Creating an index on a non-existent column.
1886
-		elseif ($mysqli_errno == 1072)
1887
-			return false;
1888
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1889
-			return false;
1995
+		elseif ($mysqli_errno == 1072) {
1996
+					return false;
1997
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
1998
+					return false;
1999
+		}
1890 2000
 	}
1891 2001
 	// If a table already exists don't go potty.
1892 2002
 	else
1893 2003
 	{
1894 2004
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1895 2005
 		{
1896
-			if (strpos($db_error_message, 'exist') !== false)
1897
-				return true;
1898
-		}
1899
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2006
+			if (strpos($db_error_message, 'exist') !== false) {
2007
+							return true;
2008
+			}
2009
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1900 2010
 		{
1901
-			if (strpos($db_error_message, 'duplicate') !== false)
1902
-				return true;
2011
+			if (strpos($db_error_message, 'duplicate') !== false) {
2012
+							return true;
2013
+			}
1903 2014
 		}
1904 2015
 	}
1905 2016
 
1906 2017
 	// Get the query string so we pass everything.
1907 2018
 	$query_string = '';
1908
-	foreach ($_GET as $k => $v)
1909
-		$query_string .= ';' . $k . '=' . $v;
1910
-	if (strlen($query_string) != 0)
1911
-		$query_string = '?' . substr($query_string, 1);
2019
+	foreach ($_GET as $k => $v) {
2020
+			$query_string .= ';' . $k . '=' . $v;
2021
+	}
2022
+	if (strlen($query_string) != 0) {
2023
+			$query_string = '?' . substr($query_string, 1);
2024
+	}
1912 2025
 
1913 2026
 	if ($command_line)
1914 2027
 	{
@@ -1963,16 +2076,18 @@  discard block
 block discarded – undo
1963 2076
 			{
1964 2077
 				$found |= 1;
1965 2078
 				// Do some checks on the data if we have it set.
1966
-				if (isset($change['col_type']))
1967
-					$found &= $change['col_type'] === $column['type'];
1968
-				if (isset($change['null_allowed']))
1969
-					$found &= $column['null'] == $change['null_allowed'];
1970
-				if (isset($change['default']))
1971
-					$found &= $change['default'] === $column['default'];
2079
+				if (isset($change['col_type'])) {
2080
+									$found &= $change['col_type'] === $column['type'];
2081
+				}
2082
+				if (isset($change['null_allowed'])) {
2083
+									$found &= $column['null'] == $change['null_allowed'];
2084
+				}
2085
+				if (isset($change['default'])) {
2086
+									$found &= $change['default'] === $column['default'];
2087
+				}
1972 2088
 			}
1973 2089
 		}
1974
-	}
1975
-	elseif ($change['type'] === 'index')
2090
+	} elseif ($change['type'] === 'index')
1976 2091
 	{
1977 2092
 		$request = upgrade_query('
1978 2093
 			SHOW INDEX
@@ -1981,9 +2096,10 @@  discard block
 block discarded – undo
1981 2096
 		{
1982 2097
 			$cur_index = array();
1983 2098
 
1984
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1985
-				if ($row['Key_name'] === $change['name'])
2099
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2100
+							if ($row['Key_name'] === $change['name'])
1986 2101
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2102
+			}
1987 2103
 
1988 2104
 			ksort($cur_index, SORT_NUMERIC);
1989 2105
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -1993,14 +2109,17 @@  discard block
 block discarded – undo
1993 2109
 	}
1994 2110
 
1995 2111
 	// If we're trying to add and it's added, we're done.
1996
-	if ($found && in_array($change['method'], array('add', 'change')))
1997
-		return true;
2112
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2113
+			return true;
2114
+	}
1998 2115
 	// Otherwise if we're removing and it wasn't found we're also done.
1999
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2000
-		return true;
2116
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2117
+			return true;
2118
+	}
2001 2119
 	// Otherwise is it just a test?
2002
-	elseif ($is_test)
2003
-		return false;
2120
+	elseif ($is_test) {
2121
+			return false;
2122
+	}
2004 2123
 
2005 2124
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2006 2125
 	$running = false;
@@ -2011,8 +2130,9 @@  discard block
 block discarded – undo
2011 2130
 			SHOW FULL PROCESSLIST');
2012 2131
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2013 2132
 		{
2014
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2015
-				$found = true;
2133
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2134
+							$found = true;
2135
+			}
2016 2136
 		}
2017 2137
 
2018 2138
 		// Can't find it? Then we need to run it fools!
@@ -2024,8 +2144,9 @@  discard block
 block discarded – undo
2024 2144
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2025 2145
 				' . $change['text'], true) !== false;
2026 2146
 
2027
-			if (!$success)
2028
-				return false;
2147
+			if (!$success) {
2148
+							return false;
2149
+			}
2029 2150
 
2030 2151
 			// Return
2031 2152
 			$running = true;
@@ -2067,8 +2188,9 @@  discard block
 block discarded – undo
2067 2188
 			'db_error_skip' => true,
2068 2189
 		)
2069 2190
 	);
2070
-	if ($smcFunc['db_num_rows']($request) === 0)
2071
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2191
+	if ($smcFunc['db_num_rows']($request) === 0) {
2192
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2193
+	}
2072 2194
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2073 2195
 	$smcFunc['db_free_result']($request);
2074 2196
 
@@ -2090,18 +2212,19 @@  discard block
 block discarded – undo
2090 2212
 			)
2091 2213
 		);
2092 2214
 		// No results? Just forget it all together.
2093
-		if ($smcFunc['db_num_rows']($request) === 0)
2094
-			unset($table_row['Collation']);
2095
-		else
2096
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2215
+		if ($smcFunc['db_num_rows']($request) === 0) {
2216
+					unset($table_row['Collation']);
2217
+		} else {
2218
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2219
+		}
2097 2220
 		$smcFunc['db_free_result']($request);
2098 2221
 	}
2099 2222
 
2100 2223
 	if ($column_fix)
2101 2224
 	{
2102 2225
 		// Make sure there are no NULL's left.
2103
-		if ($null_fix)
2104
-			$smcFunc['db_query']('', '
2226
+		if ($null_fix) {
2227
+					$smcFunc['db_query']('', '
2105 2228
 				UPDATE {db_prefix}' . $change['table'] . '
2106 2229
 				SET ' . $change['column'] . ' = {string:default}
2107 2230
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2110,6 +2233,7 @@  discard block
 block discarded – undo
2110 2233
 					'db_error_skip' => true,
2111 2234
 				)
2112 2235
 			);
2236
+		}
2113 2237
 
2114 2238
 		// Do the actual alteration.
2115 2239
 		$smcFunc['db_query']('', '
@@ -2138,8 +2262,9 @@  discard block
 block discarded – undo
2138 2262
 	}
2139 2263
 
2140 2264
 	// Not a column we need to check on?
2141
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2142
-		return;
2265
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2266
+			return;
2267
+	}
2143 2268
 
2144 2269
 	// Break it up you (six|seven).
2145 2270
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2158,13 +2283,13 @@  discard block
 block discarded – undo
2158 2283
 				'new_name' => $temp[2],
2159 2284
 		));
2160 2285
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2161
-		if ($smcFunc['db_num_rows'] != 1)
2162
-			return;
2286
+		if ($smcFunc['db_num_rows'] != 1) {
2287
+					return;
2288
+		}
2163 2289
 
2164 2290
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2165 2291
 		$smcFunc['db_free_result']($request);
2166
-	}
2167
-	else
2292
+	} else
2168 2293
 	{
2169 2294
 		// Do this the old fashion, sure method way.
2170 2295
 		$request = $smcFunc['db_query']('', '
@@ -2175,21 +2300,24 @@  discard block
 block discarded – undo
2175 2300
 		));
2176 2301
 		// Mayday!
2177 2302
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2178
-		if ($smcFunc['db_num_rows'] == 0)
2179
-			return;
2303
+		if ($smcFunc['db_num_rows'] == 0) {
2304
+					return;
2305
+		}
2180 2306
 
2181 2307
 		// Oh where, oh where has my little field gone. Oh where can it be...
2182
-		while ($row = $smcFunc['db_query']($request))
2183
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2308
+		while ($row = $smcFunc['db_query']($request)) {
2309
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2184 2310
 			{
2185 2311
 				$current_type = $row['Type'];
2312
+		}
2186 2313
 				break;
2187 2314
 			}
2188 2315
 	}
2189 2316
 
2190 2317
 	// If this doesn't match, the column may of been altered for a reason.
2191
-	if (trim($current_type) != trim($temp[3]))
2192
-		$temp[3] = $current_type;
2318
+	if (trim($current_type) != trim($temp[3])) {
2319
+			$temp[3] = $current_type;
2320
+	}
2193 2321
 
2194 2322
 	// Piece this back together.
2195 2323
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2201,8 +2329,9 @@  discard block
 block discarded – undo
2201 2329
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2202 2330
 	global $step_progress, $is_debug, $upcontext;
2203 2331
 
2204
-	if ($_GET['substep'] < $substep)
2205
-		$_GET['substep'] = $substep;
2332
+	if ($_GET['substep'] < $substep) {
2333
+			$_GET['substep'] = $substep;
2334
+	}
2206 2335
 
2207 2336
 	if ($command_line)
2208 2337
 	{
@@ -2215,29 +2344,33 @@  discard block
 block discarded – undo
2215 2344
 	}
2216 2345
 
2217 2346
 	@set_time_limit(300);
2218
-	if (function_exists('apache_reset_timeout'))
2219
-		@apache_reset_timeout();
2347
+	if (function_exists('apache_reset_timeout')) {
2348
+			@apache_reset_timeout();
2349
+	}
2220 2350
 
2221
-	if (time() - $start_time <= $timeLimitThreshold)
2222
-		return;
2351
+	if (time() - $start_time <= $timeLimitThreshold) {
2352
+			return;
2353
+	}
2223 2354
 
2224 2355
 	// Do we have some custom step progress stuff?
2225 2356
 	if (!empty($step_progress))
2226 2357
 	{
2227 2358
 		$upcontext['substep_progress'] = 0;
2228 2359
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2229
-		if ($step_progress['current'] > $step_progress['total'])
2230
-			$upcontext['substep_progress'] = 99.9;
2231
-		else
2232
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2360
+		if ($step_progress['current'] > $step_progress['total']) {
2361
+					$upcontext['substep_progress'] = 99.9;
2362
+		} else {
2363
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2364
+		}
2233 2365
 
2234 2366
 		// Make it nicely rounded.
2235 2367
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2236 2368
 	}
2237 2369
 
2238 2370
 	// If this is XML we just exit right away!
2239
-	if (isset($_GET['xml']))
2240
-		return upgradeExit();
2371
+	if (isset($_GET['xml'])) {
2372
+			return upgradeExit();
2373
+	}
2241 2374
 
2242 2375
 	// We're going to pause after this!
2243 2376
 	$upcontext['pause'] = true;
@@ -2245,13 +2378,15 @@  discard block
 block discarded – undo
2245 2378
 	$upcontext['query_string'] = '';
2246 2379
 	foreach ($_GET as $k => $v)
2247 2380
 	{
2248
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2249
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2381
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2382
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2383
+		}
2250 2384
 	}
2251 2385
 
2252 2386
 	// Custom warning?
2253
-	if (!empty($custom_warning))
2254
-		$upcontext['custom_warning'] = $custom_warning;
2387
+	if (!empty($custom_warning)) {
2388
+			$upcontext['custom_warning'] = $custom_warning;
2389
+	}
2255 2390
 
2256 2391
 	upgradeExit();
2257 2392
 }
@@ -2266,25 +2401,26 @@  discard block
 block discarded – undo
2266 2401
 	ob_implicit_flush(true);
2267 2402
 	@set_time_limit(600);
2268 2403
 
2269
-	if (!isset($_SERVER['argv']))
2270
-		$_SERVER['argv'] = array();
2404
+	if (!isset($_SERVER['argv'])) {
2405
+			$_SERVER['argv'] = array();
2406
+	}
2271 2407
 	$_GET['maint'] = 1;
2272 2408
 
2273 2409
 	foreach ($_SERVER['argv'] as $i => $arg)
2274 2410
 	{
2275
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2276
-			$_GET['lang'] = $match[1];
2277
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2278
-			continue;
2279
-		elseif ($arg == '--no-maintenance')
2280
-			$_GET['maint'] = 0;
2281
-		elseif ($arg == '--debug')
2282
-			$is_debug = true;
2283
-		elseif ($arg == '--backup')
2284
-			$_POST['backup'] = 1;
2285
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2286
-			$_GET['conv'] = 1;
2287
-		elseif ($i != 0)
2411
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2412
+					$_GET['lang'] = $match[1];
2413
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2414
+					continue;
2415
+		} elseif ($arg == '--no-maintenance') {
2416
+					$_GET['maint'] = 0;
2417
+		} elseif ($arg == '--debug') {
2418
+					$is_debug = true;
2419
+		} elseif ($arg == '--backup') {
2420
+					$_POST['backup'] = 1;
2421
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2422
+					$_GET['conv'] = 1;
2423
+		} elseif ($i != 0)
2288 2424
 		{
2289 2425
 			echo 'SMF Command-line Upgrader
2290 2426
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2298,10 +2434,12 @@  discard block
 block discarded – undo
2298 2434
 		}
2299 2435
 	}
2300 2436
 
2301
-	if (!php_version_check())
2302
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2303
-	if (!db_version_check())
2304
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2437
+	if (!php_version_check()) {
2438
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2439
+	}
2440
+	if (!db_version_check()) {
2441
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2442
+	}
2305 2443
 
2306 2444
 	// Do some checks to make sure they have proper privileges
2307 2445
 	db_extend('packages');
@@ -2316,34 +2454,39 @@  discard block
 block discarded – undo
2316 2454
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2317 2455
 
2318 2456
 	// Sorry... we need CREATE, ALTER and DROP
2319
-	if (!$create || !$alter || !$drop)
2320
-		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);
2457
+	if (!$create || !$alter || !$drop) {
2458
+			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);
2459
+	}
2321 2460
 
2322 2461
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2323 2462
 		&& @file_exists($sourcedir . '/QueryString.php')
2324 2463
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2325
-	if (!$check && !isset($modSettings['smfVersion']))
2326
-		print_error('Error: Some files are missing or out-of-date.', true);
2464
+	if (!$check && !isset($modSettings['smfVersion'])) {
2465
+			print_error('Error: Some files are missing or out-of-date.', true);
2466
+	}
2327 2467
 
2328 2468
 	// Do a quick version spot check.
2329 2469
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2330 2470
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2331
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2332
-		print_error('Error: Some files have not yet been updated properly.');
2471
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2472
+			print_error('Error: Some files have not yet been updated properly.');
2473
+	}
2333 2474
 
2334 2475
 	// Make sure Settings.php is writable.
2335 2476
 		quickFileWritable($boarddir . '/Settings.php');
2336
-	if (!is_writable($boarddir . '/Settings.php'))
2337
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2477
+	if (!is_writable($boarddir . '/Settings.php')) {
2478
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2479
+	}
2338 2480
 
2339 2481
 	// Make sure Settings_bak.php is writable.
2340 2482
 		quickFileWritable($boarddir . '/Settings_bak.php');
2341
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2342
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2483
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2484
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2485
+	}
2343 2486
 
2344
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2345
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2346
-	elseif (isset($modSettings['agreement']))
2487
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2488
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2489
+	} elseif (isset($modSettings['agreement']))
2347 2490
 	{
2348 2491
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2349 2492
 		fwrite($fp, $modSettings['agreement']);
@@ -2353,31 +2496,36 @@  discard block
 block discarded – undo
2353 2496
 	// Make sure Themes is writable.
2354 2497
 	quickFileWritable($modSettings['theme_dir']);
2355 2498
 
2356
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2357
-		print_error('Error: Unable to obtain write access to "Themes".');
2499
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2500
+			print_error('Error: Unable to obtain write access to "Themes".');
2501
+	}
2358 2502
 
2359 2503
 	// Make sure cache directory exists and is writable!
2360 2504
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2361
-	if (!file_exists($cachedir_temp))
2362
-		@mkdir($cachedir_temp);
2505
+	if (!file_exists($cachedir_temp)) {
2506
+			@mkdir($cachedir_temp);
2507
+	}
2363 2508
 
2364 2509
 	// Make sure the cache temp dir is writable.
2365 2510
 	quickFileWritable($cachedir_temp);
2366 2511
 
2367
-	if (!is_writable($cachedir_temp))
2368
-		print_error('Error: Unable to obtain write access to "cache".', true);
2512
+	if (!is_writable($cachedir_temp)) {
2513
+			print_error('Error: Unable to obtain write access to "cache".', true);
2514
+	}
2369 2515
 
2370
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2371
-		print_error('Error: Unable to find language files!', true);
2372
-	else
2516
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2517
+			print_error('Error: Unable to find language files!', true);
2518
+	} else
2373 2519
 	{
2374 2520
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2375 2521
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2376 2522
 
2377
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2378
-			print_error('Error: Language files out of date.', true);
2379
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2380
-			print_error('Error: Install language is missing for selected language.', true);
2523
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2524
+					print_error('Error: Language files out of date.', true);
2525
+		}
2526
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2527
+					print_error('Error: Install language is missing for selected language.', true);
2528
+		}
2381 2529
 
2382 2530
 		// Otherwise include it!
2383 2531
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2396,8 +2544,9 @@  discard block
 block discarded – undo
2396 2544
 	global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js;
2397 2545
 
2398 2546
 	// Done it already?
2399
-	if (!empty($_POST['utf8_done']))
2400
-		return true;
2547
+	if (!empty($_POST['utf8_done'])) {
2548
+			return true;
2549
+	}
2401 2550
 
2402 2551
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2403 2552
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2410,8 +2559,7 @@  discard block
 block discarded – undo
2410 2559
 		);
2411 2560
 
2412 2561
 		return true;
2413
-	}
2414
-	else
2562
+	} else
2415 2563
 	{
2416 2564
 		$upcontext['page_title'] = 'Converting to UTF8';
2417 2565
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2455,8 +2603,9 @@  discard block
 block discarded – undo
2455 2603
 			)
2456 2604
 		);
2457 2605
 		$db_charsets = array();
2458
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2459
-			$db_charsets[] = $row['Charset'];
2606
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2607
+					$db_charsets[] = $row['Charset'];
2608
+		}
2460 2609
 
2461 2610
 		$smcFunc['db_free_result']($request);
2462 2611
 
@@ -2492,13 +2641,15 @@  discard block
 block discarded – undo
2492 2641
 		// If there's a fulltext index, we need to drop it first...
2493 2642
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2494 2643
 		{
2495
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2496
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2644
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2645
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2497 2646
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2647
+			}
2498 2648
 			$smcFunc['db_free_result']($request);
2499 2649
 
2500
-			if (isset($upcontext['fulltext_index']))
2501
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2650
+			if (isset($upcontext['fulltext_index'])) {
2651
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2652
+			}
2502 2653
 		}
2503 2654
 
2504 2655
 		// Drop it and make a note...
@@ -2688,8 +2839,9 @@  discard block
 block discarded – undo
2688 2839
 			$replace = '%field%';
2689 2840
 
2690 2841
 			// Build a huge REPLACE statement...
2691
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2692
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2842
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2843
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2844
+			}
2693 2845
 		}
2694 2846
 
2695 2847
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2699,9 +2851,10 @@  discard block
 block discarded – undo
2699 2851
 		$upcontext['table_count'] = count($queryTables);
2700 2852
 	
2701 2853
 		// What ones have we already done?
2702
-		foreach ($queryTables as $id => $table)
2703
-			if ($id < $_GET['substep'])
2854
+		foreach ($queryTables as $id => $table) {
2855
+					if ($id < $_GET['substep'])
2704 2856
 				$upcontext['previous_tables'][] = $table;
2857
+		}
2705 2858
 
2706 2859
 		$upcontext['cur_table_num'] = $_GET['substep'];
2707 2860
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2738,8 +2891,9 @@  discard block
 block discarded – undo
2738 2891
 			nextSubstep($substep);
2739 2892
 
2740 2893
 			// Just to make sure it doesn't time out.
2741
-			if (function_exists('apache_reset_timeout'))
2742
-				@apache_reset_timeout();
2894
+			if (function_exists('apache_reset_timeout')) {
2895
+							@apache_reset_timeout();
2896
+			}
2743 2897
 
2744 2898
 			$table_charsets = array();
2745 2899
 
@@ -2760,8 +2914,9 @@  discard block
 block discarded – undo
2760 2914
 					{
2761 2915
 						list($charset) = explode('_', $collation);
2762 2916
 
2763
-						if (!isset($table_charsets[$charset]))
2764
-							$table_charsets[$charset] = array();
2917
+						if (!isset($table_charsets[$charset])) {
2918
+													$table_charsets[$charset] = array();
2919
+						}
2765 2920
 
2766 2921
 						$table_charsets[$charset][] = $column_info;
2767 2922
 					}
@@ -2801,10 +2956,11 @@  discard block
 block discarded – undo
2801 2956
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2802 2957
 				{
2803 2958
 					$update = '';
2804
-					foreach ($table_charsets as $charset => $columns)
2805
-						foreach ($columns as $column)
2959
+					foreach ($table_charsets as $charset => $columns) {
2960
+											foreach ($columns as $column)
2806 2961
 							$update .= '
2807 2962
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
2963
+					}
2808 2964
 
2809 2965
 					$smcFunc['db_query']('', '
2810 2966
 						UPDATE {raw:table_name}
@@ -2829,8 +2985,9 @@  discard block
 block discarded – undo
2829 2985
 			// Now do the actual conversion (if still needed).
2830 2986
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2831 2987
 			{
2832
-				if ($command_line)
2833
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
2988
+				if ($command_line) {
2989
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
2990
+				}
2834 2991
 
2835 2992
 				$smcFunc['db_query']('', '
2836 2993
 					ALTER TABLE {raw:table_name}
@@ -2840,12 +2997,14 @@  discard block
 block discarded – undo
2840 2997
 					)
2841 2998
 				);
2842 2999
 
2843
-				if ($command_line)
2844
-					echo " done.\n";
3000
+				if ($command_line) {
3001
+									echo " done.\n";
3002
+				}
2845 3003
 			}
2846 3004
 			// If this is XML to keep it nice for the user do one table at a time anyway!
2847
-			if (isset($_GET['xml']))
2848
-				return upgradeExit();
3005
+			if (isset($_GET['xml'])) {
3006
+							return upgradeExit();
3007
+			}
2849 3008
 		}
2850 3009
 
2851 3010
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -2874,8 +3033,8 @@  discard block
 block discarded – undo
2874 3033
 		);
2875 3034
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2876 3035
 		{
2877
-			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)
2878
-				$smcFunc['db_query']('', '
3036
+			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) {
3037
+							$smcFunc['db_query']('', '
2879 3038
 					UPDATE {db_prefix}log_actions
2880 3039
 					SET extra = {string:extra}
2881 3040
 					WHERE id_action = {int:current_action}',
@@ -2884,6 +3043,7 @@  discard block
 block discarded – undo
2884 3043
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2885 3044
 					)
2886 3045
 				);
3046
+			}
2887 3047
 		}
2888 3048
 		$smcFunc['db_free_result']($request);
2889 3049
 
@@ -2905,15 +3065,17 @@  discard block
 block discarded – undo
2905 3065
 	// First thing's first - did we already do this?
2906 3066
 	if (!empty($modSettings['json_done']))
2907 3067
 	{
2908
-		if ($command_line)
2909
-			return DeleteUpgrade();
2910
-		else
2911
-			return true;
3068
+		if ($command_line) {
3069
+					return DeleteUpgrade();
3070
+		} else {
3071
+					return true;
3072
+		}
2912 3073
 	}
2913 3074
 
2914 3075
 	// Done it already - js wise?
2915
-	if (!empty($_POST['json_done']))
2916
-		return true;
3076
+	if (!empty($_POST['json_done'])) {
3077
+			return true;
3078
+	}
2917 3079
 
2918 3080
 	// List of tables affected by this function
2919 3081
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2945,12 +3107,14 @@  discard block
 block discarded – undo
2945 3107
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
2946 3108
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2947 3109
 
2948
-	foreach ($keys as $id => $table)
2949
-		if ($id < $_GET['substep'])
3110
+	foreach ($keys as $id => $table) {
3111
+			if ($id < $_GET['substep'])
2950 3112
 			$upcontext['previous_tables'][] = $table;
3113
+	}
2951 3114
 
2952
-	if ($command_line)
2953
-		echo 'Converting data from serialize() to json_encode().';
3115
+	if ($command_line) {
3116
+			echo 'Converting data from serialize() to json_encode().';
3117
+	}
2954 3118
 
2955 3119
 	if (!$support_js || isset($_GET['xml']))
2956 3120
 	{
@@ -2990,8 +3154,9 @@  discard block
 block discarded – undo
2990 3154
 
2991 3155
 				// Loop through and fix these...
2992 3156
 				$new_settings = array();
2993
-				if ($command_line)
2994
-					echo "\n" . 'Fixing some settings...';
3157
+				if ($command_line) {
3158
+									echo "\n" . 'Fixing some settings...';
3159
+				}
2995 3160
 
2996 3161
 				foreach ($serialized_settings as $var)
2997 3162
 				{
@@ -2999,22 +3164,24 @@  discard block
 block discarded – undo
2999 3164
 					{
3000 3165
 						// Attempt to unserialize the setting
3001 3166
 						$temp = @safe_unserialize($modSettings[$var]);
3002
-						if (!$temp && $command_line)
3003
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3004
-						elseif ($temp !== false)
3005
-							$new_settings[$var] = json_encode($temp);
3167
+						if (!$temp && $command_line) {
3168
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3169
+						} elseif ($temp !== false) {
3170
+													$new_settings[$var] = json_encode($temp);
3171
+						}
3006 3172
 					}
3007 3173
 				}
3008 3174
 
3009 3175
 				// Update everything at once
3010
-				if (!function_exists('cache_put_data'))
3011
-					require_once($sourcedir . '/Load.php');
3176
+				if (!function_exists('cache_put_data')) {
3177
+									require_once($sourcedir . '/Load.php');
3178
+				}
3012 3179
 				updateSettings($new_settings, true);
3013 3180
 
3014
-				if ($command_line)
3015
-					echo ' done.';
3016
-			}
3017
-			elseif ($table == 'themes')
3181
+				if ($command_line) {
3182
+									echo ' done.';
3183
+				}
3184
+			} elseif ($table == 'themes')
3018 3185
 			{
3019 3186
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3020 3187
 				$query = $smcFunc['db_query']('', '
@@ -3033,10 +3200,11 @@  discard block
 block discarded – undo
3033 3200
 
3034 3201
 						if ($command_line)
3035 3202
 						{
3036
-							if ($temp === false)
3037
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3038
-							else
3039
-								echo "\n" . 'Fixing admin preferences...';
3203
+							if ($temp === false) {
3204
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3205
+							} else {
3206
+															echo "\n" . 'Fixing admin preferences...';
3207
+							}
3040 3208
 						}
3041 3209
 
3042 3210
 						if ($temp !== false)
@@ -3058,15 +3226,15 @@  discard block
 block discarded – undo
3058 3226
 								)
3059 3227
 							);
3060 3228
 
3061
-							if ($command_line)
3062
-								echo ' done.';
3229
+							if ($command_line) {
3230
+															echo ' done.';
3231
+							}
3063 3232
 						}
3064 3233
 					}
3065 3234
 
3066 3235
 					$smcFunc['db_free_result']($query);
3067 3236
 				}
3068
-			}
3069
-			else
3237
+			} else
3070 3238
 			{
3071 3239
 				// First item is always the key...
3072 3240
 				$key = $info[0];
@@ -3077,8 +3245,7 @@  discard block
 block discarded – undo
3077 3245
 				{
3078 3246
 					$col_select = $info[1];
3079 3247
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3080
-				}
3081
-				else
3248
+				} else
3082 3249
 				{
3083 3250
 					$col_select = implode(', ', $info);
3084 3251
 				}
@@ -3111,8 +3278,7 @@  discard block
 block discarded – undo
3111 3278
 								if ($temp === false && $command_line)
3112 3279
 								{
3113 3280
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3114
-								}
3115
-								else
3281
+								} else
3116 3282
 								{
3117 3283
 									$row[$col] = json_encode($temp);
3118 3284
 
@@ -3137,16 +3303,18 @@  discard block
 block discarded – undo
3137 3303
 						}
3138 3304
 					}
3139 3305
 
3140
-					if ($command_line)
3141
-						echo ' done.';
3306
+					if ($command_line) {
3307
+											echo ' done.';
3308
+					}
3142 3309
 
3143 3310
 					// Free up some memory...
3144 3311
 					$smcFunc['db_free_result']($query);
3145 3312
 				}
3146 3313
 			}
3147 3314
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3148
-			if (isset($_GET['xml']))
3149
-				return upgradeExit();
3315
+			if (isset($_GET['xml'])) {
3316
+							return upgradeExit();
3317
+			}
3150 3318
 		}
3151 3319
 
3152 3320
 		if ($command_line)
@@ -3161,8 +3329,9 @@  discard block
 block discarded – undo
3161 3329
 
3162 3330
 		$_GET['substep'] = 0;
3163 3331
 		// Make sure we move on!
3164
-		if ($command_line)
3165
-			return DeleteUpgrade();
3332
+		if ($command_line) {
3333
+					return DeleteUpgrade();
3334
+		}
3166 3335
 
3167 3336
 		return true;
3168 3337
 	}
@@ -3182,14 +3351,16 @@  discard block
 block discarded – undo
3182 3351
 	global $upcontext, $txt, $settings;
3183 3352
 
3184 3353
 	// Don't call me twice!
3185
-	if (!empty($upcontext['chmod_called']))
3186
-		return;
3354
+	if (!empty($upcontext['chmod_called'])) {
3355
+			return;
3356
+	}
3187 3357
 
3188 3358
 	$upcontext['chmod_called'] = true;
3189 3359
 
3190 3360
 	// Nothing?
3191
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3192
-		return;
3361
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3362
+			return;
3363
+	}
3193 3364
 
3194 3365
 	// Was it a problem with Windows?
3195 3366
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3221,11 +3392,12 @@  discard block
 block discarded – undo
3221 3392
 					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\');
3222 3393
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3223 3394
 
3224
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3225
-		echo '
3395
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3396
+			echo '
3226 3397
 					content.write(\'<hr>\n\t\t\t\');
3227 3398
 					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\');
3228 3399
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3400
+	}
3229 3401
 
3230 3402
 	echo '
3231 3403
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3233,17 +3405,19 @@  discard block
 block discarded – undo
3233 3405
 				}
3234 3406
 			</script>';
3235 3407
 
3236
-	if (!empty($upcontext['chmod']['ftp_error']))
3237
-		echo '
3408
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3409
+			echo '
3238 3410
 			<div class="error_message red">
3239 3411
 				The following error was encountered when trying to connect:<br><br>
3240 3412
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3241 3413
 			</div>
3242 3414
 			<br>';
3415
+	}
3243 3416
 
3244
-	if (empty($upcontext['chmod_in_form']))
3245
-		echo '
3417
+	if (empty($upcontext['chmod_in_form'])) {
3418
+			echo '
3246 3419
 	<form action="', $upcontext['form_url'], '" method="post">';
3420
+	}
3247 3421
 
3248 3422
 	echo '
3249 3423
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3278,10 +3452,11 @@  discard block
 block discarded – undo
3278 3452
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
3279 3453
 	</div>';
3280 3454
 
3281
-	if (empty($upcontext['chmod_in_form']))
3282
-		echo '
3455
+	if (empty($upcontext['chmod_in_form'])) {
3456
+			echo '
3283 3457
 	</form>';
3284
-}
3458
+	}
3459
+	}
3285 3460
 
3286 3461
 function template_upgrade_above()
3287 3462
 {
@@ -3341,9 +3516,10 @@  discard block
 block discarded – undo
3341 3516
 				<h2>', $txt['upgrade_progress'], '</h2>
3342 3517
 				<ul>';
3343 3518
 
3344
-	foreach ($upcontext['steps'] as $num => $step)
3345
-		echo '
3519
+	foreach ($upcontext['steps'] as $num => $step) {
3520
+			echo '
3346 3521
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3522
+	}
3347 3523
 
3348 3524
 	echo '
3349 3525
 					</ul>
@@ -3356,8 +3532,8 @@  discard block
 block discarded – undo
3356 3532
 				</div>
3357 3533
 			</div>';
3358 3534
 
3359
-	if (isset($upcontext['step_progress']))
3360
-		echo '
3535
+	if (isset($upcontext['step_progress'])) {
3536
+			echo '
3361 3537
 				<br>
3362 3538
 				<br>
3363 3539
 				<div id="progress_bar_step">
@@ -3366,6 +3542,7 @@  discard block
 block discarded – undo
3366 3542
 						<span>', $txt['upgrade_step_progress'], '</span>
3367 3543
 					</div>
3368 3544
 				</div>';
3545
+	}
3369 3546
 
3370 3547
 	echo '
3371 3548
 				<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>
@@ -3396,32 +3573,36 @@  discard block
 block discarded – undo
3396 3573
 {
3397 3574
 	global $upcontext, $txt;
3398 3575
 
3399
-	if (!empty($upcontext['pause']))
3400
-		echo '
3576
+	if (!empty($upcontext['pause'])) {
3577
+			echo '
3401 3578
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3402 3579
 
3403 3580
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3404 3581
 								<h3>
3405 3582
 									', $txt['upgrade_paused_overload'], '
3406 3583
 								</h3>';
3584
+	}
3407 3585
 
3408
-	if (!empty($upcontext['custom_warning']))
3409
-		echo '
3586
+	if (!empty($upcontext['custom_warning'])) {
3587
+			echo '
3410 3588
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3411 3589
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3412 3590
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3413 3591
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3414 3592
 								</div>';
3593
+	}
3415 3594
 
3416 3595
 	echo '
3417 3596
 								<div class="righttext" style="margin: 1ex;">';
3418 3597
 
3419
-	if (!empty($upcontext['continue']))
3420
-		echo '
3598
+	if (!empty($upcontext['continue'])) {
3599
+			echo '
3421 3600
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
3422
-	if (!empty($upcontext['skip']))
3423
-		echo '
3601
+	}
3602
+	if (!empty($upcontext['skip'])) {
3603
+			echo '
3424 3604
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
3605
+	}
3425 3606
 
3426 3607
 	echo '
3427 3608
 								</div>
@@ -3471,11 +3652,12 @@  discard block
 block discarded – undo
3471 3652
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3472 3653
 	<smf>';
3473 3654
 
3474
-	if (!empty($upcontext['get_data']))
3475
-		foreach ($upcontext['get_data'] as $k => $v)
3655
+	if (!empty($upcontext['get_data'])) {
3656
+			foreach ($upcontext['get_data'] as $k => $v)
3476 3657
 			echo '
3477 3658
 		<get key="', $k, '">', $v, '</get>';
3478
-}
3659
+	}
3660
+	}
3479 3661
 
3480 3662
 function template_xml_below()
3481 3663
 {
@@ -3516,8 +3698,8 @@  discard block
 block discarded – undo
3516 3698
 	template_chmod();
3517 3699
 
3518 3700
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3519
-	if ($upcontext['is_large_forum'])
3520
-		echo '
3701
+	if ($upcontext['is_large_forum']) {
3702
+			echo '
3521 3703
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3522 3704
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3523 3705
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3525,10 +3707,11 @@  discard block
 block discarded – undo
3525 3707
 				', $txt['upgrade_warning_lots_data'], '
3526 3708
 			</div>
3527 3709
 		</div>';
3710
+	}
3528 3711
 
3529 3712
 	// A warning message?
3530
-	if (!empty($upcontext['warning']))
3531
-		echo '
3713
+	if (!empty($upcontext['warning'])) {
3714
+			echo '
3532 3715
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3533 3716
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3534 3717
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3536,6 +3719,7 @@  discard block
 block discarded – undo
3536 3719
 				', $upcontext['warning'], '
3537 3720
 			</div>
3538 3721
 		</div>';
3722
+	}
3539 3723
 
3540 3724
 	// Paths are incorrect?
3541 3725
 	echo '
@@ -3551,20 +3735,22 @@  discard block
 block discarded – undo
3551 3735
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3552 3736
 	{
3553 3737
 		$ago = time() - $upcontext['started'];
3554
-		if ($ago < 60)
3555
-			$ago = $ago . ' seconds';
3556
-		elseif ($ago < 3600)
3557
-			$ago = (int) ($ago / 60) . ' minutes';
3558
-		else
3559
-			$ago = (int) ($ago / 3600) . ' hours';
3738
+		if ($ago < 60) {
3739
+					$ago = $ago . ' seconds';
3740
+		} elseif ($ago < 3600) {
3741
+					$ago = (int) ($ago / 60) . ' minutes';
3742
+		} else {
3743
+					$ago = (int) ($ago / 3600) . ' hours';
3744
+		}
3560 3745
 
3561 3746
 		$active = time() - $upcontext['updated'];
3562
-		if ($active < 60)
3563
-			$updated = $active . ' seconds';
3564
-		elseif ($active < 3600)
3565
-			$updated = (int) ($active / 60) . ' minutes';
3566
-		else
3567
-			$updated = (int) ($active / 3600) . ' hours';
3747
+		if ($active < 60) {
3748
+					$updated = $active . ' seconds';
3749
+		} elseif ($active < 3600) {
3750
+					$updated = (int) ($active / 60) . ' minutes';
3751
+		} else {
3752
+					$updated = (int) ($active / 3600) . ' hours';
3753
+		}
3568 3754
 
3569 3755
 		echo '
3570 3756
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3573,16 +3759,18 @@  discard block
 block discarded – undo
3573 3759
 			<div style="padding-left: 6ex;">
3574 3760
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3575 3761
 
3576
-		if ($active < 600)
3577
-			echo '
3762
+		if ($active < 600) {
3763
+					echo '
3578 3764
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3765
+		}
3579 3766
 
3580
-		if ($active > $upcontext['inactive_timeout'])
3581
-			echo '
3767
+		if ($active > $upcontext['inactive_timeout']) {
3768
+					echo '
3582 3769
 				<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.';
3583
-		else
3584
-			echo '
3770
+		} else {
3771
+					echo '
3585 3772
 				<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!');
3773
+		}
3586 3774
 
3587 3775
 		echo '
3588 3776
 			</div>
@@ -3598,9 +3786,10 @@  discard block
 block discarded – undo
3598 3786
 					<td>
3599 3787
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
3600 3788
 
3601
-	if (!empty($upcontext['username_incorrect']))
3602
-		echo '
3789
+	if (!empty($upcontext['username_incorrect'])) {
3790
+			echo '
3603 3791
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3792
+	}
3604 3793
 
3605 3794
 	echo '
3606 3795
 					</td>
@@ -3611,9 +3800,10 @@  discard block
 block discarded – undo
3611 3800
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
3612 3801
 						<input type="hidden" name="hash_passwrd" value="">';
3613 3802
 
3614
-	if (!empty($upcontext['password_failed']))
3615
-		echo '
3803
+	if (!empty($upcontext['password_failed'])) {
3804
+			echo '
3616 3805
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3806
+	}
3617 3807
 
3618 3808
 	echo '
3619 3809
 					</td>
@@ -3684,8 +3874,8 @@  discard block
 block discarded – undo
3684 3874
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3685 3875
 
3686 3876
 	// Warning message?
3687
-	if (!empty($upcontext['upgrade_options_warning']))
3688
-		echo '
3877
+	if (!empty($upcontext['upgrade_options_warning'])) {
3878
+			echo '
3689 3879
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3690 3880
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3691 3881
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3693,6 +3883,7 @@  discard block
 block discarded – undo
3693 3883
 				', $upcontext['upgrade_options_warning'], '
3694 3884
 			</div>
3695 3885
 		</div>';
3886
+	}
3696 3887
 
3697 3888
 	echo '
3698 3889
 				<table>
@@ -3735,8 +3926,8 @@  discard block
 block discarded – undo
3735 3926
 						</td>
3736 3927
 					</tr>';
3737 3928
 
3738
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3739
-		echo '
3929
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3930
+			echo '
3740 3931
 					<tr valign="top">
3741 3932
 						<td width="2%">
3742 3933
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -3745,6 +3936,7 @@  discard block
 block discarded – undo
3745 3936
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3746 3937
 						</td>
3747 3938
 					</tr>';
3939
+	}
3748 3940
 
3749 3941
 	echo '
3750 3942
 					<tr valign="top">
@@ -3782,10 +3974,11 @@  discard block
 block discarded – undo
3782 3974
 			</div>';
3783 3975
 
3784 3976
 	// Dont any tables so far?
3785
-	if (!empty($upcontext['previous_tables']))
3786
-		foreach ($upcontext['previous_tables'] as $table)
3977
+	if (!empty($upcontext['previous_tables'])) {
3978
+			foreach ($upcontext['previous_tables'] as $table)
3787 3979
 			echo '
3788 3980
 			<br>Completed Table: &quot;', $table, '&quot;.';
3981
+	}
3789 3982
 
3790 3983
 	echo '
3791 3984
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3822,12 +4015,13 @@  discard block
 block discarded – undo
3822 4015
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3823 4016
 
3824 4017
 		// If debug flood the screen.
3825
-		if ($is_debug)
3826
-			echo '
4018
+		if ($is_debug) {
4019
+					echo '
3827 4020
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3828 4021
 
3829 4022
 				if (document.getElementById(\'debug_section\').scrollHeight)
3830 4023
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4024
+		}
3831 4025
 
3832 4026
 		echo '
3833 4027
 				// Get the next update...
@@ -3860,8 +4054,9 @@  discard block
 block discarded – undo
3860 4054
 {
3861 4055
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3862 4056
 
3863
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3864
-		$is_debug = true;
4057
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4058
+			$is_debug = true;
4059
+	}
3865 4060
 
3866 4061
 	echo '
3867 4062
 		<h3>Executing database changes</h3>
@@ -3876,8 +4071,9 @@  discard block
 block discarded – undo
3876 4071
 	{
3877 4072
 		foreach ($upcontext['actioned_items'] as $num => $item)
3878 4073
 		{
3879
-			if ($num != 0)
3880
-				echo ' Successful!';
4074
+			if ($num != 0) {
4075
+							echo ' Successful!';
4076
+			}
3881 4077
 			echo '<br>' . $item;
3882 4078
 		}
3883 4079
 		if (!empty($upcontext['changes_complete']))
@@ -3890,28 +4086,32 @@  discard block
 block discarded – undo
3890 4086
 				$seconds = intval($active % 60);
3891 4087
 
3892 4088
 				$totalTime = '';
3893
-				if ($hours > 0)
3894
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3895
-				if ($minutes > 0)
3896
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3897
-				if ($seconds > 0)
3898
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4089
+				if ($hours > 0) {
4090
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4091
+				}
4092
+				if ($minutes > 0) {
4093
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4094
+				}
4095
+				if ($seconds > 0) {
4096
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4097
+				}
3899 4098
 			}
3900 4099
 
3901
-			if ($is_debug && !empty($totalTime))
3902
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3903
-			else
3904
-				echo ' Successful!<br><br>';
4100
+			if ($is_debug && !empty($totalTime)) {
4101
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4102
+			} else {
4103
+							echo ' Successful!<br><br>';
4104
+			}
3905 4105
 
3906 4106
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3907 4107
 		}
3908
-	}
3909
-	else
4108
+	} else
3910 4109
 	{
3911 4110
 		// Tell them how many files we have in total.
3912
-		if ($upcontext['file_count'] > 1)
3913
-			echo '
4111
+		if ($upcontext['file_count'] > 1) {
4112
+					echo '
3914 4113
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4114
+		}
3915 4115
 
3916 4116
 		echo '
3917 4117
 		<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>
@@ -3927,19 +4127,23 @@  discard block
 block discarded – undo
3927 4127
 				$seconds = intval($active % 60);
3928 4128
 
3929 4129
 				$totalTime = '';
3930
-				if ($hours > 0)
3931
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3932
-				if ($minutes > 0)
3933
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3934
-				if ($seconds > 0)
3935
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4130
+				if ($hours > 0) {
4131
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4132
+				}
4133
+				if ($minutes > 0) {
4134
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4135
+				}
4136
+				if ($seconds > 0) {
4137
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4138
+				}
3936 4139
 			}
3937 4140
 
3938 4141
 			echo '
3939 4142
 			<br><span id="upgradeCompleted">';
3940 4143
 
3941
-			if (!empty($totalTime))
3942
-				echo 'Completed in ', $totalTime, '<br>';
4144
+			if (!empty($totalTime)) {
4145
+							echo 'Completed in ', $totalTime, '<br>';
4146
+			}
3943 4147
 
3944 4148
 			echo '</span>
3945 4149
 			<div id="debug_section" style="height: 59px; overflow: auto;">
@@ -3976,9 +4180,10 @@  discard block
 block discarded – undo
3976 4180
 			var getData = "";
3977 4181
 			var debugItems = ', $upcontext['debug_items'], ';';
3978 4182
 
3979
-		if ($is_debug)
3980
-			echo '
4183
+		if ($is_debug) {
4184
+					echo '
3981 4185
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4186
+		}
3982 4187
 
3983 4188
 		echo '
3984 4189
 			function getNextItem()
@@ -4018,9 +4223,10 @@  discard block
 block discarded – undo
4018 4223
 						document.getElementById("error_block").style.display = "";
4019 4224
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4020 4225
 
4021
-	if ($is_debug)
4022
-		echo '
4226
+	if ($is_debug) {
4227
+			echo '
4023 4228
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4229
+	}
4024 4230
 
4025 4231
 	echo '
4026 4232
 					}
@@ -4041,9 +4247,10 @@  discard block
 block discarded – undo
4041 4247
 						document.getElementById("error_block").style.display = "";
4042 4248
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4043 4249
 
4044
-	if ($is_debug)
4045
-		echo '
4250
+	if ($is_debug) {
4251
+			echo '
4046 4252
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4253
+	}
4047 4254
 
4048 4255
 	echo '
4049 4256
 					}
@@ -4102,8 +4309,8 @@  discard block
 block discarded – undo
4102 4309
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4103 4310
 				{';
4104 4311
 
4105
-		if ($is_debug)
4106
-			echo '
4312
+		if ($is_debug) {
4313
+					echo '
4107 4314
 					document.getElementById(\'debug_section\').style.display = "none";
4108 4315
 
4109 4316
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4121,6 +4328,7 @@  discard block
 block discarded – undo
4121 4328
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4122 4329
 
4123 4330
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4331
+		}
4124 4332
 
4125 4333
 		echo '
4126 4334
 
@@ -4128,9 +4336,10 @@  discard block
 block discarded – undo
4128 4336
 					document.getElementById(\'contbutt\').disabled = 0;
4129 4337
 					document.getElementById(\'database_done\').value = 1;';
4130 4338
 
4131
-		if ($upcontext['file_count'] > 1)
4132
-			echo '
4339
+		if ($upcontext['file_count'] > 1) {
4340
+					echo '
4133 4341
 					document.getElementById(\'info1\').style.display = "none";';
4342
+		}
4134 4343
 
4135 4344
 		echo '
4136 4345
 					document.getElementById(\'info2\').style.display = "none";
@@ -4143,9 +4352,10 @@  discard block
 block discarded – undo
4143 4352
 					lastItem = 0;
4144 4353
 					prevFile = curFile;';
4145 4354
 
4146
-		if ($is_debug)
4147
-			echo '
4355
+		if ($is_debug) {
4356
+					echo '
4148 4357
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4358
+		}
4149 4359
 
4150 4360
 		echo '
4151 4361
 					getNextItem();
@@ -4153,8 +4363,8 @@  discard block
 block discarded – undo
4153 4363
 				}';
4154 4364
 
4155 4365
 		// If debug scroll the screen.
4156
-		if ($is_debug)
4157
-			echo '
4366
+		if ($is_debug) {
4367
+					echo '
4158 4368
 				if (iLastSubStepProgress == -1)
4159 4369
 				{
4160 4370
 					// Give it consistent dots.
@@ -4173,6 +4383,7 @@  discard block
 block discarded – undo
4173 4383
 
4174 4384
 				if (document.getElementById(\'debug_section\').scrollHeight)
4175 4385
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4386
+		}
4176 4387
 
4177 4388
 		echo '
4178 4389
 				// Update the page.
@@ -4233,9 +4444,10 @@  discard block
 block discarded – undo
4233 4444
 			}';
4234 4445
 
4235 4446
 		// Start things off assuming we've not errored.
4236
-		if (empty($upcontext['error_message']))
4237
-			echo '
4447
+		if (empty($upcontext['error_message'])) {
4448
+					echo '
4238 4449
 			getNextItem();';
4450
+		}
4239 4451
 
4240 4452
 		echo '
4241 4453
 		//# sourceURL=dynamicScript-dbch.js 
@@ -4253,18 +4465,21 @@  discard block
 block discarded – undo
4253 4465
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4254 4466
 	<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>';
4255 4467
 
4256
-	if (!empty($upcontext['error_message']))
4257
-		echo '
4468
+	if (!empty($upcontext['error_message'])) {
4469
+			echo '
4258 4470
 	<error>', $upcontext['error_message'], '</error>';
4471
+	}
4259 4472
 
4260
-	if (!empty($upcontext['error_string']))
4261
-		echo '
4473
+	if (!empty($upcontext['error_string'])) {
4474
+			echo '
4262 4475
 	<sql>', $upcontext['error_string'], '</sql>';
4476
+	}
4263 4477
 
4264
-	if ($is_debug)
4265
-		echo '
4478
+	if ($is_debug) {
4479
+			echo '
4266 4480
 	<curtime>', time(), '</curtime>';
4267
-}
4481
+	}
4482
+	}
4268 4483
 
4269 4484
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4270 4485
 function template_convert_utf8()
@@ -4283,18 +4498,20 @@  discard block
 block discarded – undo
4283 4498
 			</div>';
4284 4499
 
4285 4500
 	// Done any tables so far?
4286
-	if (!empty($upcontext['previous_tables']))
4287
-		foreach ($upcontext['previous_tables'] as $table)
4501
+	if (!empty($upcontext['previous_tables'])) {
4502
+			foreach ($upcontext['previous_tables'] as $table)
4288 4503
 			echo '
4289 4504
 			<br>Completed Table: &quot;', $table, '&quot;.';
4505
+	}
4290 4506
 
4291 4507
 	echo '
4292 4508
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4293 4509
 
4294 4510
 	// If we dropped their index, let's let them know
4295
-	if ($upcontext['dropping_index'])
4296
-		echo '
4511
+	if ($upcontext['dropping_index']) {
4512
+			echo '
4297 4513
 				<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>';
4514
+	}
4298 4515
 
4299 4516
 	// Completion notification
4300 4517
 	echo '
@@ -4331,12 +4548,13 @@  discard block
 block discarded – undo
4331 4548
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4332 4549
 
4333 4550
 		// If debug flood the screen.
4334
-		if ($is_debug)
4335
-			echo '
4551
+		if ($is_debug) {
4552
+					echo '
4336 4553
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4337 4554
 
4338 4555
 				if (document.getElementById(\'debug_section\').scrollHeight)
4339 4556
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4557
+		}
4340 4558
 
4341 4559
 		echo '
4342 4560
 				// Get the next update...
@@ -4384,19 +4602,21 @@  discard block
 block discarded – undo
4384 4602
 			</div>';
4385 4603
 
4386 4604
 	// Dont any tables so far?
4387
-	if (!empty($upcontext['previous_tables']))
4388
-		foreach ($upcontext['previous_tables'] as $table)
4605
+	if (!empty($upcontext['previous_tables'])) {
4606
+			foreach ($upcontext['previous_tables'] as $table)
4389 4607
 			echo '
4390 4608
 			<br>Completed Table: &quot;', $table, '&quot;.';
4609
+	}
4391 4610
 
4392 4611
 	echo '
4393 4612
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4394 4613
 			<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>';
4395 4614
 
4396 4615
 	// Try to make sure substep was reset.
4397
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4398
-		echo '
4616
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4617
+			echo '
4399 4618
 			<input type="hidden" name="substep" id="substep" value="0">';
4619
+	}
4400 4620
 
4401 4621
 	// Continue please!
4402 4622
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4429,12 +4649,13 @@  discard block
 block discarded – undo
4429 4649
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4430 4650
 
4431 4651
 		// If debug flood the screen.
4432
-		if ($is_debug)
4433
-			echo '
4652
+		if ($is_debug) {
4653
+					echo '
4434 4654
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4435 4655
 
4436 4656
 				if (document.getElementById(\'debug_section\').scrollHeight)
4437 4657
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4658
+		}
4438 4659
 
4439 4660
 		echo '
4440 4661
 				// Get the next update...
@@ -4470,8 +4691,8 @@  discard block
 block discarded – undo
4470 4691
 	<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>
4471 4692
 	<form action="', $boardurl, '/index.php">';
4472 4693
 
4473
-	if (!empty($upcontext['can_delete_script']))
4474
-		echo '
4694
+	if (!empty($upcontext['can_delete_script'])) {
4695
+			echo '
4475 4696
 			<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>
4476 4697
 			<script>
4477 4698
 				function doTheDelete(theCheck)
@@ -4483,6 +4704,7 @@  discard block
 block discarded – undo
4483 4704
 				}
4484 4705
 			</script>
4485 4706
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4707
+	}
4486 4708
 
4487 4709
 	$active = time() - $upcontext['started'];
4488 4710
 	$hours = floor($active / 3600);
@@ -4492,16 +4714,20 @@  discard block
 block discarded – undo
4492 4714
 	if ($is_debug)
4493 4715
 	{
4494 4716
 		$totalTime = '';
4495
-		if ($hours > 0)
4496
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4497
-		if ($minutes > 0)
4498
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4499
-		if ($seconds > 0)
4500
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4717
+		if ($hours > 0) {
4718
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4719
+		}
4720
+		if ($minutes > 0) {
4721
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4722
+		}
4723
+		if ($seconds > 0) {
4724
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4725
+		}
4501 4726
 	}
4502 4727
 
4503
-	if ($is_debug && !empty($totalTime))
4504
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4728
+	if ($is_debug && !empty($totalTime)) {
4729
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4730
+	}
4505 4731
 
4506 4732
 	echo '<br>
4507 4733
 			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>
@@ -4528,8 +4754,9 @@  discard block
 block discarded – undo
4528 4754
 
4529 4755
 	$current_substep = $_GET['substep'];
4530 4756
 
4531
-	if (empty($_GET['a']))
4532
-		$_GET['a'] = 0;
4757
+	if (empty($_GET['a'])) {
4758
+			$_GET['a'] = 0;
4759
+	}
4533 4760
 	$step_progress['name'] = 'Converting ips';
4534 4761
 	$step_progress['current'] = $_GET['a'];
4535 4762
 
@@ -4572,16 +4799,19 @@  discard block
 block discarded – undo
4572 4799
 				'empty' => '',
4573 4800
 				'limit' => $limit,
4574 4801
 		));
4575
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4576
-			$arIp[] = $row[$oldCol];
4802
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4803
+					$arIp[] = $row[$oldCol];
4804
+		}
4577 4805
 		$smcFunc['db_free_result']($request);
4578 4806
 
4579 4807
 		// Special case, null ip could keep us in a loop.
4580
-		if (is_null($arIp[0]))
4581
-			unset($arIp[0]);
4808
+		if (is_null($arIp[0])) {
4809
+					unset($arIp[0]);
4810
+		}
4582 4811
 
4583
-		if (empty($arIp))
4584
-			$is_done = true;
4812
+		if (empty($arIp)) {
4813
+					$is_done = true;
4814
+		}
4585 4815
 
4586 4816
 		$updates = array();
4587 4817
 		$cases = array();
@@ -4590,16 +4820,18 @@  discard block
 block discarded – undo
4590 4820
 		{
4591 4821
 			$arIp[$i] = trim($arIp[$i]);
4592 4822
 
4593
-			if (empty($arIp[$i]))
4594
-				continue;
4823
+			if (empty($arIp[$i])) {
4824
+							continue;
4825
+			}
4595 4826
 
4596 4827
 			$updates['ip' . $i] = $arIp[$i];
4597 4828
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4598 4829
 
4599 4830
 			if ($setSize > 0 && $i % $setSize === 0)
4600 4831
 			{
4601
-				if (count($updates) == 1)
4602
-					continue;
4832
+				if (count($updates) == 1) {
4833
+									continue;
4834
+				}
4603 4835
 
4604 4836
 				$updates['whereSet'] = array_values($updates);
4605 4837
 				$smcFunc['db_query']('', '
@@ -4633,8 +4865,7 @@  discard block
 block discarded – undo
4633 4865
 							'ip' => $ip
4634 4866
 					));
4635 4867
 				}
4636
-			}
4637
-			else
4868
+			} else
4638 4869
 			{
4639 4870
 				$updates['whereSet'] = array_values($updates);
4640 4871
 				$smcFunc['db_query']('', '
@@ -4648,9 +4879,9 @@  discard block
 block discarded – undo
4648 4879
 					$updates
4649 4880
 				);
4650 4881
 			}
4882
+		} else {
4883
+					$is_done = true;
4651 4884
 		}
4652
-		else
4653
-			$is_done = true;
4654 4885
 
4655 4886
 		$_GET['a'] += $limit;
4656 4887
 		$step_progress['current'] = $_GET['a'];
@@ -4676,10 +4907,11 @@  discard block
 block discarded – undo
4676 4907
  
4677 4908
  	$columns = $smcFunc['db_list_columns']($targetTable, true);
4678 4909
 
4679
-	if (isset($columns[$column]))
4680
-		return $columns[$column];
4681
-	else
4682
-		return null;
4683
-}
4910
+	if (isset($columns[$column])) {
4911
+			return $columns[$column];
4912
+	} else {
4913
+			return null;
4914
+	}
4915
+	}
4684 4916
 
4685 4917
 ?>
4686 4918
\ 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
@@ -497,6 +497,7 @@
 block discarded – undo
497 497
  * @param string $xml_format The format to use ('atom', 'rss', 'rss2' or empty for plain XML)
498 498
  * @param array $forceCdataKeys A list of keys on which to force cdata wrapping (used by mods, maybe)
499 499
  * @param array $nsKeys Key-value pairs of namespace prefixes to pass to cdata_parse() (used by mods, maybe)
500
+ * @param string $tag
500 501
  */
501 502
 function dumpTags($data, $i, $tag = null, $xml_format = '', $forceCdataKeys = array(), $nsKeys = array())
502 503
 {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 			{
838 838
 				uasort($loaded_attachments, function($a, $b) {
839 839
 					if ($a['filesize'] == $b['filesize'])
840
-					        return 0;
840
+							return 0;
841 841
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
842 842
 				});
843 843
 			}
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			{
1243 1243
 				uasort($loaded_attachments, function($a, $b) {
1244 1244
 					if ($a['filesize'] == $b['filesize'])
1245
-					        return 0;
1245
+							return 0;
1246 1246
 					return ($a['filesize'] < $b['filesize']) ? -1 : 1;
1247 1247
 				});
1248 1248
 			}
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.
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.
Sources/Drafts.php 2 patches
Braces   +75 added lines, -53 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 loadLanguage('Drafts');
21 22
 
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 	global $context, $user_info, $smcFunc, $modSettings, $board;
34 35
 
35 36
 	// can you be, should you be ... here?
36
-	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft']))
37
-		return false;
37
+	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) {
38
+			return false;
39
+	}
38 40
 
39 41
 	// read in what they sent us, if anything
40 42
 	$id_draft = (int) $_POST['id_draft'];
@@ -46,14 +48,16 @@  discard block
 block discarded – undo
46 48
 		$context['draft_saved_on'] = $draft_info['poster_time'];
47 49
 
48 50
 		// since we were called from the autosave function, send something back
49
-		if (!empty($id_draft))
50
-			XmlDraft($id_draft);
51
+		if (!empty($id_draft)) {
52
+					XmlDraft($id_draft);
53
+		}
51 54
 
52 55
 		return true;
53 56
 	}
54 57
 
55
-	if (!isset($_POST['message']))
56
-		$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
58
+	if (!isset($_POST['message'])) {
59
+			$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
60
+	}
57 61
 
58 62
 	// prepare any data from the form
59 63
 	$topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic'];
@@ -66,8 +70,9 @@  discard block
 block discarded – undo
66 70
 
67 71
 	// message and subject still need a bit more work
68 72
 	preparsecode($draft['body']);
69
-	if ($smcFunc['strlen']($draft['subject']) > 100)
70
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
73
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
74
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
75
+	}
71 76
 
72 77
 	// Modifying an existing draft, like hitting the save draft button or autosave enabled?
73 78
 	if (!empty($id_draft) && !empty($draft_info))
@@ -148,9 +153,9 @@  discard block
 block discarded – undo
148 153
 		{
149 154
 			$context['draft_saved'] = true;
150 155
 			$context['id_draft'] = $id_draft;
156
+		} else {
157
+					$post_errors[] = 'draft_not_saved';
151 158
 		}
152
-		else
153
-			$post_errors[] = 'draft_not_saved';
154 159
 
155 160
 		// cleanup
156 161
 		unset($_POST['save_draft']);
@@ -180,8 +185,9 @@  discard block
 block discarded – undo
180 185
 	global $context, $user_info, $smcFunc, $modSettings;
181 186
 
182 187
 	// PM survey says ... can you stay or must you go
183
-	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft']))
184
-		return false;
188
+	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) {
189
+			return false;
190
+	}
185 191
 
186 192
 	// read in what you sent us
187 193
 	$id_pm_draft = (int) $_POST['id_pm_draft'];
@@ -193,8 +199,9 @@  discard block
 block discarded – undo
193 199
 		$context['draft_saved_on'] = $draft_info['poster_time'];
194 200
 
195 201
 		// Send something back to the javascript caller
196
-		if (!empty($id_draft))
197
-			XmlDraft($id_draft);
202
+		if (!empty($id_draft)) {
203
+					XmlDraft($id_draft);
204
+		}
198 205
 
199 206
 		return true;
200 207
 	}
@@ -204,9 +211,9 @@  discard block
 block discarded – undo
204 211
 	{
205 212
 		$recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array();
206 213
 		$recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array();
214
+	} elseif (!empty($draft_info['to_list']) && empty($recipientList)) {
215
+			$recipientList = smf_json_decode($draft_info['to_list'], true);
207 216
 	}
208
-	elseif (!empty($draft_info['to_list']) && empty($recipientList))
209
-		$recipientList = smf_json_decode($draft_info['to_list'], true);
210 217
 
211 218
 	// prepare the data we got from the form
212 219
 	$reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to'];
@@ -215,8 +222,9 @@  discard block
 block discarded – undo
215 222
 
216 223
 	// message and subject always need a bit more work
217 224
 	preparsecode($draft['body']);
218
-	if ($smcFunc['strlen']($draft['subject']) > 100)
219
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
225
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
226
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
227
+	}
220 228
 
221 229
 	// Modifying an existing PM draft?
222 230
 	if (!empty($id_pm_draft) && !empty($draft_info))
@@ -280,9 +288,9 @@  discard block
 block discarded – undo
280 288
 		{
281 289
 			$context['draft_saved'] = true;
282 290
 			$context['id_pm_draft'] = $id_pm_draft;
291
+		} else {
292
+					$post_errors[] = 'draft_not_saved';
283 293
 		}
284
-		else
285
-			$post_errors[] = 'draft_not_saved';
286 294
 	}
287 295
 
288 296
 	// if we were called from the autosave function, send something back
@@ -315,8 +323,9 @@  discard block
 block discarded – undo
315 323
 	$type = (int) $type;
316 324
 
317 325
 	// nothing to read, nothing to do
318
-	if (empty($id_draft))
319
-		return false;
326
+	if (empty($id_draft)) {
327
+			return false;
328
+	}
320 329
 
321 330
 	// load in this draft from the DB
322 331
 	$request = $smcFunc['db_query']('', '
@@ -337,8 +346,9 @@  discard block
 block discarded – undo
337 346
 	);
338 347
 
339 348
 	// no results?
340
-	if (!$smcFunc['db_num_rows']($request))
341
-		return false;
349
+	if (!$smcFunc['db_num_rows']($request)) {
350
+			return false;
351
+	}
342 352
 
343 353
 	// load up the data
344 354
 	$draft_info = $smcFunc['db_fetch_assoc']($request);
@@ -358,8 +368,7 @@  discard block
 block discarded – undo
358 368
 			$context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
359 369
 			$context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : '';
360 370
 			$context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0;
361
-		}
362
-		elseif ($type === 1)
371
+		} elseif ($type === 1)
363 372
 		{
364 373
 			// one of those pm drafts? then set it up like we have an error
365 374
 			$_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
@@ -395,12 +404,14 @@  discard block
 block discarded – undo
395 404
 	global $user_info, $smcFunc;
396 405
 
397 406
 	// Only a single draft.
398
-	if (is_numeric($id_draft))
399
-		$id_draft = array($id_draft);
407
+	if (is_numeric($id_draft)) {
408
+			$id_draft = array($id_draft);
409
+	}
400 410
 
401 411
 	// can't delete nothing
402
-	if (empty($id_draft) || ($check && empty($user_info['id'])))
403
-		return false;
412
+	if (empty($id_draft) || ($check && empty($user_info['id']))) {
413
+			return false;
414
+	}
404 415
 
405 416
 	$smcFunc['db_query']('', '
406 417
 		DELETE FROM {db_prefix}user_drafts
@@ -429,14 +440,16 @@  discard block
 block discarded – undo
429 440
 	global $smcFunc, $scripturl, $context, $txt, $modSettings;
430 441
 
431 442
 	// Permissions
432
-	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id))
433
-		return false;
443
+	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) {
444
+			return false;
445
+	}
434 446
 
435 447
 	$context['drafts'] = array();
436 448
 
437 449
 	// has a specific draft has been selected?  Load it up if there is not a message already in the editor
438
-	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message']))
439
-		ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
450
+	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) {
451
+			ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
452
+	}
440 453
 
441 454
 	// load the drafts this user has available
442 455
 	$request = $smcFunc['db_query']('', '
@@ -459,8 +472,9 @@  discard block
 block discarded – undo
459 472
 	// add them to the draft array for display
460 473
 	while ($row = $smcFunc['db_fetch_assoc']($request))
461 474
 	{
462
-		if (empty($row['subject']))
463
-			$row['subject'] = $txt['no_subject'];
475
+		if (empty($row['subject'])) {
476
+					$row['subject'] = $txt['no_subject'];
477
+		}
464 478
 
465 479
 		// Post drafts
466 480
 		if ($draft_type === 0)
@@ -545,8 +559,9 @@  discard block
 block discarded – undo
545 559
 	}
546 560
 
547 561
 	// Default to 10.
548
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
549
-		$_REQUEST['viewscount'] = 10;
562
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
563
+			$_REQUEST['viewscount'] = 10;
564
+	}
550 565
 
551 566
 	// Get the count of applicable drafts on the boards they can (still) see ...
552 567
 	// @todo .. should we just let them see their drafts even if they have lost board access ?
@@ -611,12 +626,14 @@  discard block
 block discarded – undo
611 626
 	while ($row = $smcFunc['db_fetch_assoc']($request))
612 627
 	{
613 628
 		// Censor....
614
-		if (empty($row['body']))
615
-			$row['body'] = '';
629
+		if (empty($row['body'])) {
630
+					$row['body'] = '';
631
+		}
616 632
 
617 633
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
618
-		if (empty($row['subject']))
619
-			$row['subject'] = $txt['no_subject'];
634
+		if (empty($row['subject'])) {
635
+					$row['subject'] = $txt['no_subject'];
636
+		}
620 637
 
621 638
 		censorText($row['body']);
622 639
 		censorText($row['subject']);
@@ -648,8 +665,9 @@  discard block
 block discarded – undo
648 665
 	$smcFunc['db_free_result']($request);
649 666
 
650 667
 	// If the drafts were retrieved in reverse order, get them right again.
651
-	if ($reverse)
652
-		$context['drafts'] = array_reverse($context['drafts'], true);
668
+	if ($reverse) {
669
+			$context['drafts'] = array_reverse($context['drafts'], true);
670
+	}
653 671
 
654 672
 	// Menu tab
655 673
 	$context[$context['profile_menu_name']]['tab_data'] = array(
@@ -707,8 +725,9 @@  discard block
 block discarded – undo
707 725
 	}
708 726
 
709 727
 	// Default to 10.
710
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
711
-		$_REQUEST['viewscount'] = 10;
728
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
729
+			$_REQUEST['viewscount'] = 10;
730
+	}
712 731
 
713 732
 	// Get the count of applicable drafts
714 733
 	$request = $smcFunc['db_query']('', '
@@ -767,12 +786,14 @@  discard block
 block discarded – undo
767 786
 	while ($row = $smcFunc['db_fetch_assoc']($request))
768 787
 	{
769 788
 		// Censor....
770
-		if (empty($row['body']))
771
-			$row['body'] = '';
789
+		if (empty($row['body'])) {
790
+					$row['body'] = '';
791
+		}
772 792
 
773 793
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
774
-		if (empty($row['subject']))
775
-			$row['subject'] = $txt['no_subject'];
794
+		if (empty($row['subject'])) {
795
+					$row['subject'] = $txt['no_subject'];
796
+		}
776 797
 
777 798
 		censorText($row['body']);
778 799
 		censorText($row['subject']);
@@ -827,8 +848,9 @@  discard block
 block discarded – undo
827 848
 	$smcFunc['db_free_result']($request);
828 849
 
829 850
 	// if the drafts were retrieved in reverse order, then put them in the right order again.
830
-	if ($reverse)
831
-		$context['drafts'] = array_reverse($context['drafts'], true);
851
+	if ($reverse) {
852
+			$context['drafts'] = array_reverse($context['drafts'], true);
853
+	}
832 854
 
833 855
 	// off to the template we go
834 856
 	$context['page_title'] = $txt['drafts'];
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  *
174 174
  * @param string $post_errors A string of info about errors encountered trying to save this draft
175 175
  * @param array $recipientList An array of data about who this PM is being sent to
176
- * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
176
+ * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
177 177
  */
178 178
 function SavePMDraft(&$post_errors, $recipientList)
179 179
 {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
  *
389 389
  * @param int $id_draft The ID of the draft to delete
390 390
  * @param boolean $check Whether or not to check that the draft belongs to the current user
391
- * @return boolean False if it couldn't be deleted (doesn't return anything otherwise)
391
+ * @return false|null False if it couldn't be deleted (doesn't return anything otherwise)
392 392
  */
393 393
 function DeleteDraft($id_draft, $check = true)
394 394
 {
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
  * @param int $member_id ID of the member to show drafts for
423 423
  * @param boolean|integer If $type is 1, this can be set to only load drafts for posts in the specific topic
424 424
  * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts
425
- * @return boolean False if the drafts couldn't be loaded, nothing otherwise
425
+ * @return false|null False if the drafts couldn't be loaded, nothing otherwise
426 426
  */
427 427
 function ShowDrafts($member_id, $topic = false, $draft_type = 0)
428 428
 {
Please login to merge, or discard this patch.