Completed
Pull Request — release-2.1 (#4090)
by Rick
08:20
created
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.
Braces   +152 added lines, -116 removed lines patch added patch discarded remove patch
@@ -40,16 +40,14 @@  discard block
 block discarded – undo
40 40
 				', template_show_upcoming_list('main'), '
41 41
 			</div>
42 42
 		';
43
-	}
44
-	elseif ($context['calendar_view'] == 'view_week')
43
+	} elseif ($context['calendar_view'] == 'view_week')
45 44
 	{
46 45
 		echo '
47 46
 			<div id="main_grid">
48 47
 				', template_show_week_grid('main'), '
49 48
 			</div>
50 49
 		';
51
-	}
52
-	else
50
+	} else
53 51
 	{
54 52
 		echo '
55 53
 			<div id="main_grid">
@@ -75,8 +73,9 @@  discard block
 block discarded – undo
75 73
 	global $context, $scripturl, $txt, $modSettings;
76 74
 
77 75
 	// Bail out if we have nothing to work with
78
-	if (!isset($context['calendar_grid_' . $grid_name]))
79
-		return false;
76
+	if (!isset($context['calendar_grid_' . $grid_name])) {
77
+			return false;
78
+	}
80 79
 
81 80
 	// Protect programmer sanity
82 81
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -113,11 +112,13 @@  discard block
 block discarded – undo
113 112
 					<li class="windowbg">
114 113
 						<b class="event_title">', $event['link'], '</b>';
115 114
 
116
-				if ($event['can_edit'])
117
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
115
+				if ($event['can_edit']) {
116
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
117
+				}
118 118
 
119
-				if ($event['can_export'])
120
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
119
+				if ($event['can_export']) {
120
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
121
+				}
121 122
 
122 123
 				echo '
123 124
 						<br>';
@@ -125,14 +126,14 @@  discard block
 block discarded – undo
125 126
 				if (!empty($event['allday']))
126 127
 				{
127 128
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
128
-				}
129
-				else
129
+				} else
130 130
 				{
131 131
 					// Display event info relative to user's local timezone
132 132
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
133 133
 
134
-					if ($event['start_date_local'] != $event['end_date_local'])
135
-						echo trim($event['end_date_local']) . ', ';
134
+					if ($event['start_date_local'] != $event['end_date_local']) {
135
+											echo trim($event['end_date_local']) . ', ';
136
+					}
136 137
 
137 138
 					echo trim($event['end_time_local']);
138 139
 
@@ -141,23 +142,27 @@  discard block
 block discarded – undo
141 142
 					{
142 143
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
143 144
 
144
-						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
145
-							echo trim($event['start_date_orig']), ', ';
145
+						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
146
+													echo trim($event['start_date_orig']), ', ';
147
+						}
146 148
 
147 149
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
148 150
 
149
-						if ($event['start_date_orig'] != $event['end_date_orig'])
150
-							echo trim($event['end_date_orig']) . ', ';
151
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
152
+													echo trim($event['end_date_orig']) . ', ';
153
+						}
151 154
 
152 155
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
153 156
 					}
154 157
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
155
-					else
156
-						echo ' ', $event['tz_abbrev'], '</time>';
158
+					else {
159
+											echo ' ', $event['tz_abbrev'], '</time>';
160
+					}
157 161
 				}
158 162
 
159
-				if (!empty($event['location']))
160
-					echo '<br>', $event['location'];
163
+				if (!empty($event['location'])) {
164
+									echo '<br>', $event['location'];
165
+				}
161 166
 
162 167
 				echo '
163 168
 					</li>';
@@ -189,8 +194,9 @@  discard block
 block discarded – undo
189 194
 
190 195
 			$birthdays = array();
191 196
 
192
-			foreach ($date as $member)
193
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
197
+			foreach ($date as $member) {
198
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
199
+			}
194 200
 
195 201
 			echo implode(', ', $birthdays);
196 202
 
@@ -221,8 +227,9 @@  discard block
 block discarded – undo
221 227
 			$date_local = $date['date_local'];
222 228
 			unset($date['date_local']);
223 229
 
224
-			foreach ($date as $holiday)
225
-				$holidays[] = $holiday . ' (' . $date_local . ')';
230
+			foreach ($date as $holiday) {
231
+							$holidays[] = $holiday . ' (' . $date_local . ')';
232
+			}
226 233
 		}
227 234
 
228 235
 		echo implode(', ', $holidays);
@@ -245,17 +252,19 @@  discard block
 block discarded – undo
245 252
 	global $context, $settings, $txt, $scripturl, $modSettings;
246 253
 
247 254
 	// If the grid doesn't exist, no point in proceeding.
248
-	if (!isset($context['calendar_grid_' . $grid_name]))
249
-		return false;
255
+	if (!isset($context['calendar_grid_' . $grid_name])) {
256
+			return false;
257
+	}
250 258
 
251 259
 	// A handy little pointer variable.
252 260
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
253 261
 
254 262
 	// Some conditions for whether or not we should show the week links *here*.
255
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
256
-		$show_week_links = true;
257
-	else
258
-		$show_week_links = false;
263
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
264
+			$show_week_links = true;
265
+	} else {
266
+			$show_week_links = false;
267
+	}
259 268
 
260 269
 	// Assuming that we've not disabled it, show the title block!
261 270
 	if (empty($calendar_data['disable_title']))
@@ -294,8 +303,9 @@  discard block
 block discarded – undo
294 303
 	}
295 304
 
296 305
 	// Show the controls on main grids
297
-	if ($is_mini === false)
298
-		template_calendar_top($calendar_data);
306
+	if ($is_mini === false) {
307
+			template_calendar_top($calendar_data);
308
+	}
299 309
 
300 310
 	// Finally, the main calendar table.
301 311
 	echo '<table class="calendar_table">';
@@ -306,8 +316,9 @@  discard block
 block discarded – undo
306 316
 		echo '<tr>';
307 317
 
308 318
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
309
-		if ($show_week_links === true)
310
-			echo '<th>&nbsp;</th>';
319
+		if ($show_week_links === true) {
320
+					echo '<th>&nbsp;</th>';
321
+		}
311 322
 
312 323
 		// Now, loop through each actual day of the week.
313 324
 		foreach ($calendar_data['week_days'] as $day)
@@ -354,27 +365,29 @@  discard block
 block discarded – undo
354 365
 				// Additional classes are given for events, holidays, and birthdays.
355 366
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
356 367
 				{
357
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
358
-						$classes[] = 'events';
359
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
360
-						$classes[] = 'events';
368
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) {
369
+											$classes[] = 'events';
370
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) {
371
+											$classes[] = 'events';
372
+					}
361 373
 				}
362 374
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
363 375
 				{
364
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
365
-						$classes[] = 'holidays';
366
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
367
-						$classes[] = 'holidays';
376
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) {
377
+											$classes[] = 'holidays';
378
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) {
379
+											$classes[] = 'holidays';
380
+					}
368 381
 				}
369 382
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
370 383
 				{
371
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
372
-						$classes[] = 'birthdays';
373
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
374
-						$classes[] = 'birthdays';
384
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) {
385
+											$classes[] = 'birthdays';
386
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) {
387
+											$classes[] = 'birthdays';
388
+					}
375 389
 				}
376
-			}
377
-			else
390
+			} else
378 391
 			{
379 392
 				// Default Classes (either compact or comfortable and disabled).
380 393
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
@@ -392,17 +405,19 @@  discard block
 block discarded – undo
392 405
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
393 406
 
394 407
 				// The actual day number - be it a link, or just plain old text!
395
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
396
-					echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
397
-				else
398
-					echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
408
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
409
+									echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
410
+				} else {
411
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
412
+				}
399 413
 
400 414
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
401 415
 				if ($is_mini === false)
402 416
 				{
403 417
 					// Holidays are always fun, let's show them!
404
-					if (!empty($day['holidays']))
405
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
418
+					if (!empty($day['holidays'])) {
419
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
420
+					}
406 421
 
407 422
 					// Happy Birthday Dear, Member!
408 423
 					if (!empty($day['birthdays']))
@@ -420,14 +435,16 @@  discard block
 block discarded – undo
420 435
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
421 436
 
422 437
 							// 9...10! Let's stop there.
423
-							if ($birthday_count == 10 && $use_js_hide)
424
-								// !!TODO - Inline CSS and JavaScript should be moved.
438
+							if ($birthday_count == 10 && $use_js_hide) {
439
+															// !!TODO - Inline CSS and JavaScript should be moved.
425 440
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
441
+							}
426 442
 
427 443
 							++$birthday_count;
428 444
 						}
429
-						if ($use_js_hide)
430
-							echo '</span>';
445
+						if ($use_js_hide) {
446
+													echo '</span>';
447
+						}
431 448
 
432 449
 						echo '</div>';
433 450
 					}
@@ -437,8 +454,9 @@  discard block
 block discarded – undo
437 454
 					{
438 455
 						// Sort events by start time (all day events will be listed first)
439 456
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
457
+						    if ($a['start_timestamp'] == $b['start_timestamp']) {
458
+						    						        return 0;
459
+						    }
442 460
 						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 461
 						});
444 462
 
@@ -454,17 +472,19 @@  discard block
 block discarded – undo
454 472
 
455 473
 							echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
456 474
 
457
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
458
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
459
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
460
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
461
-							elseif (!empty($event['allday']))
462
-								echo $txt['calendar_allday'];
475
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
476
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
477
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
478
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
479
+							} elseif (!empty($event['allday'])) {
480
+															echo $txt['calendar_allday'];
481
+							}
463 482
 
464 483
 							echo '</span>';
465 484
 
466
-							if (!empty($event['location']))
467
-								echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
485
+							if (!empty($event['location'])) {
486
+															echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
487
+							}
468 488
 
469 489
 							if ($event['can_edit'] || $event['can_export'])
470 490
 							{
@@ -501,10 +521,11 @@  discard block
 block discarded – undo
501 521
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
502 522
 			elseif ($is_mini === false)
503 523
 			{
504
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
505
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
506
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
507
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
524
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
525
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
526
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
527
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
528
+				}
508 529
 			}
509 530
 
510 531
 			// Close this day and increase var count.
@@ -530,8 +551,9 @@  discard block
 block discarded – undo
530 551
 	global $context, $settings, $txt, $scripturl, $modSettings;
531 552
 
532 553
 	// We might have no reason to proceed, if the variable isn't there.
533
-	if (!isset($context['calendar_grid_' . $grid_name]))
534
-		return false;
554
+	if (!isset($context['calendar_grid_' . $grid_name])) {
555
+			return false;
556
+	}
535 557
 
536 558
 	// Handy pointer.
537 559
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -567,8 +589,9 @@  discard block
 block discarded – undo
567 589
 					}
568 590
 
569 591
 					// The Month Title + Week Number...
570
-					if (!empty($calendar_data['week_title']))
571
-							echo $calendar_data['week_title'];
592
+					if (!empty($calendar_data['week_title'])) {
593
+												echo $calendar_data['week_title'];
594
+					}
572 595
 
573 596
 					echo '
574 597
 					</h3>
@@ -607,10 +630,11 @@  discard block
 block discarded – undo
607 630
 						<tr class="days_wrapper">
608 631
 							<td class="', implode(' ', $classes), ' act_day">';
609 632
 							// Should the day number be a link?
610
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
611
-								echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
612
-							else
613
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
633
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
634
+															echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
635
+							} else {
636
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
637
+							}
614 638
 
615 639
 							echo '</td>
616 640
 							<td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">';
@@ -619,8 +643,9 @@  discard block
 block discarded – undo
619 643
 							{
620 644
 								// Sort events by start time (all day events will be listed first)
621 645
 								uasort($day['events'], function($a, $b) {
622
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
623
-								        return 0;
646
+								    if ($a['start_timestamp'] == $b['start_timestamp']) {
647
+								    								        return 0;
648
+								    }
624 649
 								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
625 650
 								});
626 651
 
@@ -632,15 +657,17 @@  discard block
 block discarded – undo
632 657
 
633 658
 									echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
634 659
 
635
-									if (!empty($event['start_time_local']))
636
-										echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
637
-									else
638
-										echo $txt['calendar_allday'];
660
+									if (!empty($event['start_time_local'])) {
661
+																			echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
662
+									} else {
663
+																			echo $txt['calendar_allday'];
664
+									}
639 665
 
640 666
 									echo '</span>';
641 667
 
642
-									if (!empty($event['location']))
643
-										echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
668
+									if (!empty($event['location'])) {
669
+																			echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
670
+									}
644 671
 
645 672
 									if (!empty($event_icons_needed))
646 673
 									{
@@ -677,8 +704,7 @@  discard block
 block discarded – undo
677 704
 									</div>
678 705
 									<br class="clear">';
679 706
 								}
680
-							}
681
-							else
707
+							} else
682 708
 							{
683 709
 								if (!empty($context['can_post']))
684 710
 								{
@@ -691,8 +717,9 @@  discard block
 block discarded – undo
691 717
 							echo '</td>
692 718
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
693 719
 							// Show any holidays!
694
-							if (!empty($day['holidays']))
695
-								echo implode('<br>', $day['holidays']);
720
+							if (!empty($day['holidays'])) {
721
+															echo implode('<br>', $day['holidays']);
722
+							}
696 723
 
697 724
 							echo '</td>
698 725
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">';
@@ -750,8 +777,7 @@  discard block
 block discarded – undo
750 777
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date">
751 778
 				<input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '">
752 779
 			</form>';
753
-	}
754
-	else
780
+	} else
755 781
 	{
756 782
 		echo'
757 783
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
@@ -793,8 +819,9 @@  discard block
 block discarded – undo
793 819
 	echo '
794 820
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">';
795 821
 
796
-	if (!empty($context['event']['new']))
797
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
822
+	if (!empty($context['event']['new'])) {
823
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
824
+	}
798 825
 
799 826
 	// Start the main table.
800 827
 	echo '
@@ -844,9 +871,10 @@  discard block
 block discarded – undo
844 871
 		{
845 872
 			echo '
846 873
 								<optgroup label="', $category['name'], '">';
847
-			foreach ($category['boards'] as $board)
848
-				echo '
874
+			foreach ($category['boards'] as $board) {
875
+							echo '
849 876
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
877
+			}
850 878
 			echo '
851 879
 								</optgroup>';
852 880
 		}
@@ -882,9 +910,10 @@  discard block
 block discarded – undo
882 910
 							<span class="label">', $txt['calendar_timezone'], '</span>
883 911
 							<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
884 912
 
885
-	foreach ($context['all_timezones'] as $tz => $tzname)
886
-		echo '
913
+	foreach ($context['all_timezones'] as $tz => $tzname) {
914
+			echo '
887 915
 								<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
916
+	}
888 917
 
889 918
 	echo '
890 919
 							</select>
@@ -899,9 +928,10 @@  discard block
 block discarded – undo
899 928
 	echo '
900 929
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
901 930
 	// Delete button?
902
-	if (empty($context['event']['new']))
903
-		echo '
931
+	if (empty($context['event']['new'])) {
932
+			echo '
904 933
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
934
+	}
905 935
 
906 936
 	echo '
907 937
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -945,9 +975,10 @@  discard block
 block discarded – undo
945 975
 
946 976
 		foreach ($context['clockicons'] as $t => $v)
947 977
 		{
948
-			foreach ($v as $i)
949
-				echo '
978
+			foreach ($v as $i) {
979
+							echo '
950 980
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
981
+			}
951 982
 		}
952 983
 
953 984
 		echo '
@@ -972,13 +1003,14 @@  discard block
 block discarded – undo
972 1003
 
973 1004
 		foreach ($context['clockicons'] as $t => $v)
974 1005
 		{
975
-			foreach ($v as $i)
976
-				echo '
1006
+			foreach ($v as $i) {
1007
+							echo '
977 1008
 			if (', $t, ' >= ', $i, ')
978 1009
 			{
979 1010
 				turnon.push("', $t, '_', $i, '");
980 1011
 				', $t, ' -= ', $i, ';
981 1012
 			}';
1013
+			}
982 1014
 		}
983 1015
 
984 1016
 		echo '
@@ -1042,9 +1074,10 @@  discard block
 block discarded – undo
1042 1074
 
1043 1075
 	foreach ($context['clockicons'] as $t => $v)
1044 1076
 	{
1045
-		foreach ($v as $i)
1046
-			echo '
1077
+		foreach ($v as $i) {
1078
+					echo '
1047 1079
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1080
+		}
1048 1081
 	}
1049 1082
 
1050 1083
 	echo '
@@ -1061,13 +1094,14 @@  discard block
 block discarded – undo
1061 1094
 
1062 1095
 	foreach ($context['clockicons'] as $t => $v)
1063 1096
 	{
1064
-		foreach ($v as $i)
1065
-			echo '
1097
+		foreach ($v as $i) {
1098
+					echo '
1066 1099
 		if (', $t, ' >= ', $i, ')
1067 1100
 		{
1068 1101
 			turnon.push("', $t, '_', $i, '");
1069 1102
 			', $t, ' -= ', $i, ';
1070 1103
 		}';
1104
+		}
1071 1105
 	}
1072 1106
 
1073 1107
 	echo '
@@ -1126,9 +1160,10 @@  discard block
 block discarded – undo
1126 1160
 
1127 1161
 	foreach ($context['clockicons'] as $t => $v)
1128 1162
 	{
1129
-		foreach ($v as $i)
1130
-			echo '
1163
+		foreach ($v as $i) {
1164
+					echo '
1131 1165
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1166
+		}
1132 1167
 	}
1133 1168
 
1134 1169
 	echo '
@@ -1149,13 +1184,14 @@  discard block
 block discarded – undo
1149 1184
 
1150 1185
 	foreach ($context['clockicons'] as $t => $v)
1151 1186
 	{
1152
-		foreach ($v as $i)
1153
-		echo '
1187
+		foreach ($v as $i) {
1188
+				echo '
1154 1189
 		if (', $t, ' >= ', $i, ')
1155 1190
 		{
1156 1191
 			turnon.push("', $t, '_', $i, '");
1157 1192
 			', $t, ' -= ', $i, ';
1158 1193
 		}';
1194
+		}
1159 1195
 	}
1160 1196
 
1161 1197
 	echo '
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 					{
438 438
 						// Sort events by start time (all day events will be listed first)
439 439
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
442
-						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
440
+							if ($a['start_timestamp'] == $b['start_timestamp'])
441
+								return 0;
442
+							return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 443
 						});
444 444
 
445 445
 						echo '
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
 							{
620 620
 								// Sort events by start time (all day events will be listed first)
621 621
 								uasort($day['events'], function($a, $b) {
622
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
623
-								        return 0;
624
-								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
622
+									if ($a['start_timestamp'] == $b['start_timestamp'])
623
+										return 0;
624
+									return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
625 625
 								});
626 626
 
627 627
 								foreach ($day['events'] as $event)
Please login to merge, or discard this patch.
other/upgrade.php 4 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -388,6 +388,9 @@  discard block
 block discarded – undo
388 388
 }
389 389
 
390 390
 // Used to direct the user to another location.
391
+/**
392
+ * @param string $location
393
+ */
391 394
 function redirectLocation($location, $addForm = true)
392 395
 {
393 396
 	global $upgradeurl, $upcontext, $command_line;
@@ -1560,6 +1563,9 @@  discard block
 block discarded – undo
1560 1563
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
1561 1564
 }
1562 1565
 
1566
+/**
1567
+ * @param string $filename
1568
+ */
1563 1569
 function parse_sql($filename)
1564 1570
 {
1565 1571
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -1594,6 +1600,10 @@  discard block
 block discarded – undo
1594 1600
 
1595 1601
 	// Our custom error handler - does nothing but does stop public errors from XML!
1596 1602
 	set_error_handler(
1603
+
1604
+		/**
1605
+		 * @param string $errno
1606
+		 */
1597 1607
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1598 1608
 		{
1599 1609
 			if ($support_js)
@@ -1840,6 +1850,9 @@  discard block
 block discarded – undo
1840 1850
 	return true;
1841 1851
 }
1842 1852
 
1853
+/**
1854
+ * @param string $string
1855
+ */
1843 1856
 function upgrade_query($string, $unbuffered = false)
1844 1857
 {
1845 1858
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -4495,7 +4508,7 @@  discard block
 block discarded – undo
4495 4508
  * @param int $setSize The amount of entries after which to update the database.
4496 4509
  *
4497 4510
  * newCol needs to be a varbinary(16) null able field
4498
- * @return bool
4511
+ * @return boolean|null
4499 4512
  */
4500 4513
 function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100)
4501 4514
 {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 
83 83
 // The helper is crucial. Include it first thing.
84 84
 if (!file_exists($upgrade_path . '/upgrade-helper.php'))
85
-    die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
85
+	die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
86 86
 
87 87
 require_once($upgrade_path . '/upgrade-helper.php');
88 88
 
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -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 ? '115' : '12') , 'px; overflow: auto;">
4285
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
4286 4286
 			<span id="debuginfo"></span>
4287 4287
 			</div>';
4288 4288
 
@@ -4379,7 +4379,7 @@  discard block
 block discarded – undo
4379 4379
 			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4380 4380
 			<input type="hidden" name="json_done" id="json_done" value="0">
4381 4381
 			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
4382
-			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
4382
+			<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
4383 4383
 			<span id="debuginfo"></span>
4384 4384
 			</div>';
4385 4385
 
Please login to merge, or discard this patch.
Braces   +874 added lines, -642 removed lines patch added patch discarded remove patch
@@ -72,8 +72,9 @@  discard block
 block discarded – undo
72 72
 $upcontext['inactive_timeout'] = 10;
73 73
 
74 74
 // The helper is crucial. Include it first thing.
75
-if (!file_exists($upgrade_path . '/upgrade-helper.php'))
75
+if (!file_exists($upgrade_path . '/upgrade-helper.php')) {
76 76
     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.');
77
+}
77 78
 
78 79
 require_once($upgrade_path . '/upgrade-helper.php');
79 80
 
@@ -97,11 +98,14 @@  discard block
 block discarded – undo
97 98
 	ini_set('default_socket_timeout', 900);
98 99
 }
99 100
 // Clean the upgrade path if this is from the client.
100
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
101
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
101
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
102
+	for ($i = 1;
103
+}
104
+$i < $_SERVER['argc']; $i++)
102 105
 	{
103
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
104
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
106
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
107
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
108
+		}
105 109
 	}
106 110
 
107 111
 // Are we from the client?
@@ -109,16 +113,17 @@  discard block
 block discarded – undo
109 113
 {
110 114
 	$command_line = true;
111 115
 	$disable_security = true;
112
-}
113
-else
116
+} else {
114 117
 	$command_line = false;
118
+}
115 119
 
116 120
 // Load this now just because we can.
117 121
 require_once($upgrade_path . '/Settings.php');
118 122
 
119 123
 // We don't use "-utf8" anymore...  Tweak the entry that may have been loaded by Settings.php
120
-if (isset($language))
124
+if (isset($language)) {
121 125
 	$language = str_ireplace('-utf8', '', $language);
126
+}
122 127
 
123 128
 // Are we logged in?
124 129
 if (isset($upgradeData))
@@ -126,10 +131,12 @@  discard block
 block discarded – undo
126 131
 	$upcontext['user'] = json_decode(base64_decode($upgradeData), true);
127 132
 
128 133
 	// Check for sensible values.
129
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
130
-		$upcontext['user']['started'] = time();
131
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
132
-		$upcontext['user']['updated'] = 0;
134
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
135
+			$upcontext['user']['started'] = time();
136
+	}
137
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
138
+			$upcontext['user']['updated'] = 0;
139
+	}
133 140
 
134 141
 	$upcontext['started'] = $upcontext['user']['started'];
135 142
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -187,8 +194,9 @@  discard block
 block discarded – undo
187 194
 			'db_error_skip' => true,
188 195
 		)
189 196
 	);
190
-	while ($row = $smcFunc['db_fetch_assoc']($request))
191
-		$modSettings[$row['variable']] = $row['value'];
197
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
198
+			$modSettings[$row['variable']] = $row['value'];
199
+	}
192 200
 	$smcFunc['db_free_result']($request);
193 201
 }
194 202
 
@@ -198,10 +206,12 @@  discard block
 block discarded – undo
198 206
 	$modSettings['theme_url'] = 'Themes/default';
199 207
 	$modSettings['images_url'] = 'Themes/default/images';
200 208
 }
201
-if (!isset($settings['default_theme_url']))
209
+if (!isset($settings['default_theme_url'])) {
202 210
 	$settings['default_theme_url'] = $modSettings['theme_url'];
203
-if (!isset($settings['default_theme_dir']))
211
+}
212
+if (!isset($settings['default_theme_dir'])) {
204 213
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
214
+}
205 215
 
206 216
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
207 217
 // Default title...
@@ -219,13 +229,15 @@  discard block
 block discarded – undo
219 229
 	$support_js = $upcontext['upgrade_status']['js'];
220 230
 
221 231
 	// Only set this if the upgrader status says so.
222
-	if (empty($is_debug))
223
-		$is_debug = $upcontext['upgrade_status']['debug'];
232
+	if (empty($is_debug)) {
233
+			$is_debug = $upcontext['upgrade_status']['debug'];
234
+	}
224 235
 
225 236
 	// Load the language.
226
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
227
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
228
-}
237
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
238
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
239
+	}
240
+	}
229 241
 // Set the defaults.
230 242
 else
231 243
 {
@@ -243,15 +255,18 @@  discard block
 block discarded – undo
243 255
 }
244 256
 
245 257
 // If this isn't the first stage see whether they are logging in and resuming.
246
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
258
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
247 259
 	checkLogin();
260
+}
248 261
 
249
-if ($command_line)
262
+if ($command_line) {
250 263
 	cmdStep0();
264
+}
251 265
 
252 266
 // Don't error if we're using xml.
253
-if (isset($_GET['xml']))
267
+if (isset($_GET['xml'])) {
254 268
 	$upcontext['return_error'] = true;
269
+}
255 270
 
256 271
 // Loop through all the steps doing each one as required.
257 272
 $upcontext['overall_percent'] = 0;
@@ -272,9 +287,9 @@  discard block
 block discarded – undo
272 287
 		}
273 288
 
274 289
 		// Call the step and if it returns false that means pause!
275
-		if (function_exists($step[2]) && $step[2]() === false)
276
-			break;
277
-		elseif (function_exists($step[2])) {
290
+		if (function_exists($step[2]) && $step[2]() === false) {
291
+					break;
292
+		} elseif (function_exists($step[2])) {
278 293
 			//Start each new step with this unset, so the 'normal' template is called first
279 294
 			unset($_GET['xml']);
280 295
 			$_GET['substep'] = 0;
@@ -318,17 +333,18 @@  discard block
 block discarded – undo
318 333
 		// This should not happen my dear... HELP ME DEVELOPERS!!
319 334
 		if (!empty($command_line))
320 335
 		{
321
-			if (function_exists('debug_print_backtrace'))
322
-				debug_print_backtrace();
336
+			if (function_exists('debug_print_backtrace')) {
337
+							debug_print_backtrace();
338
+			}
323 339
 
324 340
 			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.';
325 341
 			flush();
326 342
 			die();
327 343
 		}
328 344
 
329
-		if (!isset($_GET['xml']))
330
-			template_upgrade_above();
331
-		else
345
+		if (!isset($_GET['xml'])) {
346
+					template_upgrade_above();
347
+		} else
332 348
 		{
333 349
 			header('Content-Type: text/xml; charset=UTF-8');
334 350
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -350,25 +366,29 @@  discard block
 block discarded – undo
350 366
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
351 367
 
352 368
 			// Custom stuff to pass back?
353
-			if (!empty($upcontext['query_string']))
354
-				$upcontext['form_url'] .= $upcontext['query_string'];
369
+			if (!empty($upcontext['query_string'])) {
370
+							$upcontext['form_url'] .= $upcontext['query_string'];
371
+			}
355 372
 
356 373
 			// Call the appropriate subtemplate
357
-			if (is_callable('template_' . $upcontext['sub_template']))
358
-				call_user_func('template_' . $upcontext['sub_template']);
359
-			else
360
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
374
+			if (is_callable('template_' . $upcontext['sub_template'])) {
375
+							call_user_func('template_' . $upcontext['sub_template']);
376
+			} else {
377
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
378
+			}
361 379
 		}
362 380
 
363 381
 		// Was there an error?
364
-		if (!empty($upcontext['forced_error_message']))
365
-			echo $upcontext['forced_error_message'];
382
+		if (!empty($upcontext['forced_error_message'])) {
383
+					echo $upcontext['forced_error_message'];
384
+		}
366 385
 
367 386
 		// Show the footer.
368
-		if (!isset($_GET['xml']))
369
-			template_upgrade_below();
370
-		else
371
-			template_xml_below();
387
+		if (!isset($_GET['xml'])) {
388
+					template_upgrade_below();
389
+		} else {
390
+					template_xml_below();
391
+		}
372 392
 	}
373 393
 
374 394
 
@@ -380,15 +400,19 @@  discard block
 block discarded – undo
380 400
 		$seconds = intval($active % 60);
381 401
 
382 402
 		$totalTime = '';
383
-		if ($hours > 0)
384
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
385
-		if ($minutes > 0)
386
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
387
-		if ($seconds > 0)
388
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
403
+		if ($hours > 0) {
404
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
405
+		}
406
+		if ($minutes > 0) {
407
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
408
+		}
409
+		if ($seconds > 0) {
410
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
411
+		}
389 412
 
390
-		if (!empty($totalTime))
391
-			echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
413
+		if (!empty($totalTime)) {
414
+					echo "\n" . 'Upgrade completed in ' . $totalTime . "\n";
415
+		}
392 416
 	}
393 417
 
394 418
 	// Bang - gone!
@@ -401,8 +425,9 @@  discard block
 block discarded – undo
401 425
 	global $upgradeurl, $upcontext, $command_line;
402 426
 
403 427
 	// Command line users can't be redirected.
404
-	if ($command_line)
405
-		upgradeExit(true);
428
+	if ($command_line) {
429
+			upgradeExit(true);
430
+	}
406 431
 
407 432
 	// Are we providing the core info?
408 433
 	if ($addForm)
@@ -429,12 +454,14 @@  discard block
 block discarded – undo
429 454
 	define('SMF', 1);
430 455
 
431 456
 	// Start the session.
432
-	if (@ini_get('session.save_handler') == 'user')
433
-		@ini_set('session.save_handler', 'files');
457
+	if (@ini_get('session.save_handler') == 'user') {
458
+			@ini_set('session.save_handler', 'files');
459
+	}
434 460
 	@session_start();
435 461
 
436
-	if (empty($smcFunc))
437
-		$smcFunc = array();
462
+	if (empty($smcFunc)) {
463
+			$smcFunc = array();
464
+	}
438 465
 
439 466
 	// We need this for authentication and some upgrade code
440 467
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -446,32 +473,36 @@  discard block
 block discarded – undo
446 473
 	initialize_inputs();
447 474
 
448 475
 	// Get the database going!
449
-	if (empty($db_type) || $db_type == 'mysqli')
450
-		$db_type = 'mysql';
476
+	if (empty($db_type) || $db_type == 'mysqli') {
477
+			$db_type = 'mysql';
478
+	}
451 479
 
452 480
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
453 481
 	{
454 482
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
455 483
 
456 484
 		// Make the connection...
457
-		if (empty($db_connection))
458
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
459
-		else
460
-			// If we've returned here, ping/reconnect to be safe
485
+		if (empty($db_connection)) {
486
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
487
+		} else {
488
+					// If we've returned here, ping/reconnect to be safe
461 489
 			$smcFunc['db_ping']($db_connection);
490
+		}
462 491
 
463 492
 		// Oh dear god!!
464
-		if ($db_connection === null)
465
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
493
+		if ($db_connection === null) {
494
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
495
+		}
466 496
 
467
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
468
-			$smcFunc['db_query']('', '
497
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
498
+					$smcFunc['db_query']('', '
469 499
 			SET NAMES {string:db_character_set}',
470 500
 			array(
471 501
 				'db_error_skip' => true,
472 502
 				'db_character_set' => $db_character_set,
473 503
 			)
474 504
 		);
505
+		}
475 506
 
476 507
 		// Load the modSettings data...
477 508
 		$request = $smcFunc['db_query']('', '
@@ -482,11 +513,11 @@  discard block
 block discarded – undo
482 513
 			)
483 514
 		);
484 515
 		$modSettings = array();
485
-		while ($row = $smcFunc['db_fetch_assoc']($request))
486
-			$modSettings[$row['variable']] = $row['value'];
516
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
517
+					$modSettings[$row['variable']] = $row['value'];
518
+		}
487 519
 		$smcFunc['db_free_result']($request);
488
-	}
489
-	else
520
+	} else
490 521
 	{
491 522
 		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.');
492 523
 	}
@@ -500,9 +531,10 @@  discard block
 block discarded – undo
500 531
 		cleanRequest();
501 532
 	}
502 533
 
503
-	if (!isset($_GET['substep']))
504
-		$_GET['substep'] = 0;
505
-}
534
+	if (!isset($_GET['substep'])) {
535
+			$_GET['substep'] = 0;
536
+	}
537
+	}
506 538
 
507 539
 function initialize_inputs()
508 540
 {
@@ -532,8 +564,9 @@  discard block
 block discarded – undo
532 564
 		$dh = opendir(dirname(__FILE__));
533 565
 		while ($file = readdir($dh))
534 566
 		{
535
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
536
-				@unlink(dirname(__FILE__) . '/' . $file);
567
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
568
+							@unlink(dirname(__FILE__) . '/' . $file);
569
+			}
537 570
 		}
538 571
 		closedir($dh);
539 572
 
@@ -562,8 +595,9 @@  discard block
 block discarded – undo
562 595
 	$temp = 'upgrade_php?step';
563 596
 	while (strlen($temp) > 4)
564 597
 	{
565
-		if (isset($_GET[$temp]))
566
-			unset($_GET[$temp]);
598
+		if (isset($_GET[$temp])) {
599
+					unset($_GET[$temp]);
600
+		}
567 601
 		$temp = substr($temp, 1);
568 602
 	}
569 603
 
@@ -590,32 +624,39 @@  discard block
 block discarded – undo
590 624
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
591 625
 
592 626
 	// Need legacy scripts?
593
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
594
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
595
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
596
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
597
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
598
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
627
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
628
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
629
+	}
630
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
631
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
632
+	}
633
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
634
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
635
+	}
599 636
 
600 637
 	// We don't need "-utf8" files anymore...
601 638
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
602 639
 
603 640
 	// This needs to exist!
604
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
605
-		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>]');
606
-	else
607
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
641
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
642
+			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>]');
643
+	} else {
644
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
645
+	}
608 646
 
609
-	if (!$check)
610
-		// 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.
647
+	if (!$check) {
648
+			// 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.
611 649
 		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.');
650
+	}
612 651
 
613 652
 	// Do they meet the install requirements?
614
-	if (!php_version_check())
615
-		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.');
653
+	if (!php_version_check()) {
654
+			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
+	}
616 656
 
617
-	if (!db_version_check())
618
-		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.');
657
+	if (!db_version_check()) {
658
+			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
+	}
619 660
 
620 661
 	// Do some checks to make sure they have proper privileges
621 662
 	db_extend('packages');
@@ -630,14 +671,16 @@  discard block
 block discarded – undo
630 671
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
631 672
 
632 673
 	// Sorry... we need CREATE, ALTER and DROP
633
-	if (!$create || !$alter || !$drop)
634
-		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.');
674
+	if (!$create || !$alter || !$drop) {
675
+			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
+	}
635 677
 
636 678
 	// Do a quick version spot check.
637 679
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
638 680
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
639
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
640
-		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.');
681
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
682
+			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
+	}
641 684
 
642 685
 	// What absolutely needs to be writable?
643 686
 	$writable_files = array(
@@ -659,12 +702,13 @@  discard block
 block discarded – undo
659 702
 	quickFileWritable($custom_av_dir);
660 703
 
661 704
 	// Are we good now?
662
-	if (!is_writable($custom_av_dir))
663
-		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));
664
-	elseif ($need_settings_update)
705
+	if (!is_writable($custom_av_dir)) {
706
+			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));
707
+	} elseif ($need_settings_update)
665 708
 	{
666
-		if (!function_exists('cache_put_data'))
667
-			require_once($sourcedir . '/Load.php');
709
+		if (!function_exists('cache_put_data')) {
710
+					require_once($sourcedir . '/Load.php');
711
+		}
668 712
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
669 713
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
670 714
 	}
@@ -673,28 +717,33 @@  discard block
 block discarded – undo
673 717
 
674 718
 	// Check the cache directory.
675 719
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
676
-	if (!file_exists($cachedir_temp))
677
-		@mkdir($cachedir_temp);
678
-	if (!file_exists($cachedir_temp))
679
-		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.');
680
-
681
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
682
-		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>.');
683
-	elseif (!isset($_GET['skiplang']))
720
+	if (!file_exists($cachedir_temp)) {
721
+			@mkdir($cachedir_temp);
722
+	}
723
+	if (!file_exists($cachedir_temp)) {
724
+			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.');
725
+	}
726
+
727
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
728
+			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>.');
729
+	} elseif (!isset($_GET['skiplang']))
684 730
 	{
685 731
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
686 732
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
687 733
 
688
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
689
-			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>]');
734
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
735
+					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
+		}
690 737
 	}
691 738
 
692
-	if (!makeFilesWritable($writable_files))
693
-		return false;
739
+	if (!makeFilesWritable($writable_files)) {
740
+			return false;
741
+	}
694 742
 
695 743
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
696
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
697
-		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.');
744
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
745
+			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
+	}
698 747
 
699 748
 	// Upgrade the agreement.
700 749
 	elseif (isset($modSettings['agreement']))
@@ -705,8 +754,8 @@  discard block
 block discarded – undo
705 754
 	}
706 755
 
707 756
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
708
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
709
-		$upcontext['warning'] = '
757
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
758
+			$upcontext['warning'] = '
710 759
 			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>
711 760
 			<ul>
712 761
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -714,10 +763,12 @@  discard block
 block discarded – undo
714 763
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
715 764
 			</ul>
716 765
 			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.';
766
+	}
717 767
 
718 768
 	// Either we're logged in or we're going to present the login.
719
-	if (checkLogin())
720
-		return true;
769
+	if (checkLogin()) {
770
+			return true;
771
+	}
721 772
 
722 773
 	$upcontext += createToken('login');
723 774
 
@@ -731,15 +782,17 @@  discard block
 block discarded – undo
731 782
 	global $smcFunc, $db_type, $support_js;
732 783
 
733 784
 	// Don't bother if the security is disabled.
734
-	if ($disable_security)
735
-		return true;
785
+	if ($disable_security) {
786
+			return true;
787
+	}
736 788
 
737 789
 	// Are we trying to login?
738 790
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
739 791
 	{
740 792
 		// If we've disabled security pick a suitable name!
741
-		if (empty($_POST['user']))
742
-			$_POST['user'] = 'Administrator';
793
+		if (empty($_POST['user'])) {
794
+					$_POST['user'] = 'Administrator';
795
+		}
743 796
 
744 797
 		// Before 2.0 these column names were different!
745 798
 		$oldDB = false;
@@ -754,16 +807,17 @@  discard block
 block discarded – undo
754 807
 					'db_error_skip' => true,
755 808
 				)
756 809
 			);
757
-			if ($smcFunc['db_num_rows']($request) != 0)
758
-				$oldDB = true;
810
+			if ($smcFunc['db_num_rows']($request) != 0) {
811
+							$oldDB = true;
812
+			}
759 813
 			$smcFunc['db_free_result']($request);
760 814
 		}
761 815
 
762 816
 		// Get what we believe to be their details.
763 817
 		if (!$disable_security)
764 818
 		{
765
-			if ($oldDB)
766
-				$request = $smcFunc['db_query']('', '
819
+			if ($oldDB) {
820
+							$request = $smcFunc['db_query']('', '
767 821
 					SELECT id_member, memberName AS member_name, passwd, id_group,
768 822
 					additionalGroups AS additional_groups, lngfile
769 823
 					FROM {db_prefix}members
@@ -773,8 +827,8 @@  discard block
 block discarded – undo
773 827
 						'db_error_skip' => true,
774 828
 					)
775 829
 				);
776
-			else
777
-				$request = $smcFunc['db_query']('', '
830
+			} else {
831
+							$request = $smcFunc['db_query']('', '
778 832
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
779 833
 					FROM {db_prefix}members
780 834
 					WHERE member_name = {string:member_name}',
@@ -783,6 +837,7 @@  discard block
 block discarded – undo
783 837
 						'db_error_skip' => true,
784 838
 					)
785 839
 				);
840
+			}
786 841
 			if ($smcFunc['db_num_rows']($request) != 0)
787 842
 			{
788 843
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -790,16 +845,17 @@  discard block
 block discarded – undo
790 845
 				$groups = explode(',', $addGroups);
791 846
 				$groups[] = $id_group;
792 847
 
793
-				foreach ($groups as $k => $v)
794
-					$groups[$k] = (int) $v;
848
+				foreach ($groups as $k => $v) {
849
+									$groups[$k] = (int) $v;
850
+				}
795 851
 
796 852
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
797 853
 
798 854
 				// We don't use "-utf8" anymore...
799 855
 				$user_language = str_ireplace('-utf8', '', $user_language);
856
+			} else {
857
+							$upcontext['username_incorrect'] = true;
800 858
 			}
801
-			else
802
-				$upcontext['username_incorrect'] = true;
803 859
 			$smcFunc['db_free_result']($request);
804 860
 		}
805 861
 		$upcontext['username'] = $_POST['user'];
@@ -809,13 +865,14 @@  discard block
 block discarded – undo
809 865
 		{
810 866
 			$upcontext['upgrade_status']['js'] = 1;
811 867
 			$support_js = 1;
868
+		} else {
869
+					$support_js = 0;
812 870
 		}
813
-		else
814
-			$support_js = 0;
815 871
 
816 872
 		// Note down the version we are coming from.
817
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
818
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
873
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
874
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
875
+		}
819 876
 
820 877
 		// Didn't get anywhere?
821 878
 		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']))
@@ -849,15 +906,15 @@  discard block
 block discarded – undo
849 906
 							'db_error_skip' => true,
850 907
 						)
851 908
 					);
852
-					if ($smcFunc['db_num_rows']($request) == 0)
853
-						return throw_error('You need to be an admin to perform an upgrade!');
909
+					if ($smcFunc['db_num_rows']($request) == 0) {
910
+											return throw_error('You need to be an admin to perform an upgrade!');
911
+					}
854 912
 					$smcFunc['db_free_result']($request);
855 913
 				}
856 914
 
857 915
 				$upcontext['user']['id'] = $id_member;
858 916
 				$upcontext['user']['name'] = $name;
859
-			}
860
-			else
917
+			} else
861 918
 			{
862 919
 				$upcontext['user']['id'] = 1;
863 920
 				$upcontext['user']['name'] = 'Administrator';
@@ -873,11 +930,11 @@  discard block
 block discarded – undo
873 930
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
874 931
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
875 932
 
876
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
877
-					$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'] . '.';
878
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
879
-					$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'] . '.';
880
-				else
933
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
934
+									$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'] . '.';
935
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
936
+									$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'] . '.';
937
+				} else
881 938
 				{
882 939
 					// Set this as the new language.
883 940
 					$upcontext['language'] = $user_language;
@@ -921,8 +978,9 @@  discard block
 block discarded – undo
921 978
 	unset($member_columns);
922 979
 
923 980
 	// If we've not submitted then we're done.
924
-	if (empty($_POST['upcont']))
925
-		return false;
981
+	if (empty($_POST['upcont'])) {
982
+			return false;
983
+	}
926 984
 
927 985
 	// Firstly, if they're enabling SM stat collection just do it.
928 986
 	if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats']))
@@ -937,25 +995,26 @@  discard block
 block discarded – undo
937 995
 			fwrite($fp, $out);
938 996
 
939 997
 			$return_data = '';
940
-			while (!feof($fp))
941
-				$return_data .= fgets($fp, 128);
998
+			while (!feof($fp)) {
999
+							$return_data .= fgets($fp, 128);
1000
+			}
942 1001
 
943 1002
 			fclose($fp);
944 1003
 
945 1004
 			// Get the unique site ID.
946 1005
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
947 1006
 
948
-			if (!empty($ID[1]))
949
-				$smcFunc['db_insert']('replace',
1007
+			if (!empty($ID[1])) {
1008
+							$smcFunc['db_insert']('replace',
950 1009
 					$db_prefix . 'settings',
951 1010
 					array('variable' => 'string', 'value' => 'string'),
952 1011
 					array('allow_sm_stats', $ID[1]),
953 1012
 					array('variable')
954 1013
 				);
1014
+			}
955 1015
 		}
956
-	}
957
-	else
958
-		$smcFunc['db_query']('', '
1016
+	} else {
1017
+			$smcFunc['db_query']('', '
959 1018
 			DELETE FROM {db_prefix}settings
960 1019
 			WHERE variable = {string:allow_sm_stats}',
961 1020
 			array(
@@ -963,6 +1022,7 @@  discard block
 block discarded – undo
963 1022
 				'db_error_skip' => true,
964 1023
 			)
965 1024
 		);
1025
+	}
966 1026
 
967 1027
 	// Deleting old karma stuff?
968 1028
 	if (!empty($_POST['delete_karma']))
@@ -977,20 +1037,22 @@  discard block
 block discarded – undo
977 1037
 		);
978 1038
 
979 1039
 		// Cleaning up old karma member settings.
980
-		if ($upcontext['karma_installed']['good'])
981
-			$smcFunc['db_query']('', '
1040
+		if ($upcontext['karma_installed']['good']) {
1041
+					$smcFunc['db_query']('', '
982 1042
 				ALTER TABLE {db_prefix}members
983 1043
 				DROP karma_good',
984 1044
 				array()
985 1045
 			);
1046
+		}
986 1047
 
987 1048
 		// Does karma bad was enable?
988
-		if ($upcontext['karma_installed']['bad'])
989
-			$smcFunc['db_query']('', '
1049
+		if ($upcontext['karma_installed']['bad']) {
1050
+					$smcFunc['db_query']('', '
990 1051
 				ALTER TABLE {db_prefix}members
991 1052
 				DROP karma_bad',
992 1053
 				array()
993 1054
 			);
1055
+		}
994 1056
 
995 1057
 		// Cleaning up old karma permissions.
996 1058
 		$smcFunc['db_query']('', '
@@ -1003,26 +1065,29 @@  discard block
 block discarded – undo
1003 1065
 	}
1004 1066
 
1005 1067
 	// Emptying the error log?
1006
-	if (!empty($_POST['empty_error']))
1007
-		$smcFunc['db_query']('truncate_table', '
1068
+	if (!empty($_POST['empty_error'])) {
1069
+			$smcFunc['db_query']('truncate_table', '
1008 1070
 			TRUNCATE {db_prefix}log_errors',
1009 1071
 			array(
1010 1072
 			)
1011 1073
 		);
1074
+	}
1012 1075
 
1013 1076
 	$changes = array();
1014 1077
 
1015 1078
 	// Add proxy settings.
1016
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1017
-		$changes += array(
1079
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1080
+			$changes += array(
1018 1081
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1019 1082
 			'image_proxy_maxsize' => 5190,
1020 1083
 			'image_proxy_enabled' => 0,
1021 1084
 		);
1085
+	}
1022 1086
 
1023 1087
 	// If we're overriding the language follow it through.
1024
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1025
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1088
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1089
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1090
+	}
1026 1091
 
1027 1092
 	if (!empty($_POST['maint']))
1028 1093
 	{
@@ -1034,30 +1099,34 @@  discard block
 block discarded – undo
1034 1099
 		{
1035 1100
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1036 1101
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1037
-		}
1038
-		else
1102
+		} else
1039 1103
 		{
1040 1104
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1041 1105
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1042 1106
 		}
1043 1107
 	}
1044 1108
 
1045
-	if ($command_line)
1046
-		echo ' * Updating Settings.php...';
1109
+	if ($command_line) {
1110
+			echo ' * Updating Settings.php...';
1111
+	}
1047 1112
 
1048 1113
 	// Fix some old paths.
1049
-	if (substr($boarddir, 0, 1) == '.')
1050
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1114
+	if (substr($boarddir, 0, 1) == '.') {
1115
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1116
+	}
1051 1117
 
1052
-	if (substr($sourcedir, 0, 1) == '.')
1053
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1118
+	if (substr($sourcedir, 0, 1) == '.') {
1119
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1120
+	}
1054 1121
 
1055
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1056
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1122
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1123
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1124
+	}
1057 1125
 
1058 1126
 	// Not had the database type added before?
1059
-	if (empty($db_type))
1060
-		$changes['db_type'] = 'mysql';
1127
+	if (empty($db_type)) {
1128
+			$changes['db_type'] = 'mysql';
1129
+	}
1061 1130
 
1062 1131
 	// If they have a "host:port" setup for the host, split that into separate values
1063 1132
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1068,32 +1137,36 @@  discard block
 block discarded – undo
1068 1137
 		$changes['db_server'] = '\'' . $db_server . '\'';
1069 1138
 
1070 1139
 		// Only set this if we're not using the default port
1071
-		if ($db_port != ini_get('mysqli.default_port'))
1072
-			$changes['db_port'] = (int) $db_port;
1073
-	}
1074
-	elseif (!empty($db_port))
1140
+		if ($db_port != ini_get('mysqli.default_port')) {
1141
+					$changes['db_port'] = (int) $db_port;
1142
+		}
1143
+	} elseif (!empty($db_port))
1075 1144
 	{
1076 1145
 		// If db_port is set and is the same as the default, set it to ''
1077 1146
 		if ($db_type == 'mysql')
1078 1147
 		{
1079
-			if ($db_port == ini_get('mysqli.default_port'))
1080
-				$changes['db_port'] = '\'\'';
1081
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1082
-				$changes['db_port'] = '\'\'';
1148
+			if ($db_port == ini_get('mysqli.default_port')) {
1149
+							$changes['db_port'] = '\'\'';
1150
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1151
+							$changes['db_port'] = '\'\'';
1152
+			}
1083 1153
 		}
1084 1154
 	}
1085 1155
 
1086 1156
 	// Maybe we haven't had this option yet?
1087
-	if (empty($packagesdir))
1088
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1157
+	if (empty($packagesdir)) {
1158
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1159
+	}
1089 1160
 
1090 1161
 	// Add support for $tasksdir var.
1091
-	if (empty($tasksdir))
1092
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1162
+	if (empty($tasksdir)) {
1163
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1164
+	}
1093 1165
 
1094 1166
 	// Make sure we fix the language as well.
1095
-	if (stristr($language, '-utf8'))
1096
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1167
+	if (stristr($language, '-utf8')) {
1168
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1169
+	}
1097 1170
 
1098 1171
 	// @todo Maybe change the cookie name if going to 1.1, too?
1099 1172
 
@@ -1101,8 +1174,9 @@  discard block
 block discarded – undo
1101 1174
 	require_once($sourcedir . '/Subs-Admin.php');
1102 1175
 	updateSettingsFile($changes);
1103 1176
 
1104
-	if ($command_line)
1105
-		echo ' Successful.' . "\n";
1177
+	if ($command_line) {
1178
+			echo ' Successful.' . "\n";
1179
+	}
1106 1180
 
1107 1181
 	// Are we doing debug?
1108 1182
 	if (isset($_POST['debug']))
@@ -1112,8 +1186,9 @@  discard block
 block discarded – undo
1112 1186
 	}
1113 1187
 
1114 1188
 	// If we're not backing up then jump one.
1115
-	if (empty($_POST['backup']))
1116
-		$upcontext['current_step']++;
1189
+	if (empty($_POST['backup'])) {
1190
+			$upcontext['current_step']++;
1191
+	}
1117 1192
 
1118 1193
 	// If we've got here then let's proceed to the next step!
1119 1194
 	return true;
@@ -1128,8 +1203,9 @@  discard block
 block discarded – undo
1128 1203
 	$upcontext['page_title'] = 'Backup Database';
1129 1204
 
1130 1205
 	// Done it already - js wise?
1131
-	if (!empty($_POST['backup_done']))
1132
-		return true;
1206
+	if (!empty($_POST['backup_done'])) {
1207
+			return true;
1208
+	}
1133 1209
 
1134 1210
 	// Some useful stuff here.
1135 1211
 	db_extend();
@@ -1143,9 +1219,10 @@  discard block
 block discarded – undo
1143 1219
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1144 1220
 
1145 1221
 	$table_names = array();
1146
-	foreach ($tables as $table)
1147
-		if (substr($table, 0, 7) !== 'backup_')
1222
+	foreach ($tables as $table) {
1223
+			if (substr($table, 0, 7) !== 'backup_')
1148 1224
 			$table_names[] = $table;
1225
+	}
1149 1226
 
1150 1227
 	$upcontext['table_count'] = count($table_names);
1151 1228
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1155,12 +1232,14 @@  discard block
 block discarded – undo
1155 1232
 	$file_steps = $upcontext['table_count'];
1156 1233
 
1157 1234
 	// What ones have we already done?
1158
-	foreach ($table_names as $id => $table)
1159
-		if ($id < $_GET['substep'])
1235
+	foreach ($table_names as $id => $table) {
1236
+			if ($id < $_GET['substep'])
1160 1237
 			$upcontext['previous_tables'][] = $table;
1238
+	}
1161 1239
 
1162
-	if ($command_line)
1163
-		echo 'Backing Up Tables.';
1240
+	if ($command_line) {
1241
+			echo 'Backing Up Tables.';
1242
+	}
1164 1243
 
1165 1244
 	// If we don't support javascript we backup here.
1166 1245
 	if (!$support_js || isset($_GET['xml']))
@@ -1179,8 +1258,9 @@  discard block
 block discarded – undo
1179 1258
 			backupTable($table_names[$substep]);
1180 1259
 
1181 1260
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1182
-			if (isset($_GET['xml']))
1183
-				return upgradeExit();
1261
+			if (isset($_GET['xml'])) {
1262
+							return upgradeExit();
1263
+			}
1184 1264
 		}
1185 1265
 
1186 1266
 		if ($command_line)
@@ -1213,9 +1293,10 @@  discard block
 block discarded – undo
1213 1293
 
1214 1294
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1215 1295
 
1216
-	if ($command_line)
1217
-		echo ' done.';
1218
-}
1296
+	if ($command_line) {
1297
+			echo ' done.';
1298
+	}
1299
+	}
1219 1300
 
1220 1301
 // Step 2: Everything.
1221 1302
 function DatabaseChanges()
@@ -1224,8 +1305,9 @@  discard block
 block discarded – undo
1224 1305
 	global $upcontext, $support_js, $db_type;
1225 1306
 
1226 1307
 	// Have we just completed this?
1227
-	if (!empty($_POST['database_done']))
1228
-		return true;
1308
+	if (!empty($_POST['database_done'])) {
1309
+			return true;
1310
+	}
1229 1311
 
1230 1312
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1231 1313
 	$upcontext['page_title'] = 'Database Changes';
@@ -1240,15 +1322,16 @@  discard block
 block discarded – undo
1240 1322
 	);
1241 1323
 
1242 1324
 	// How many files are there in total?
1243
-	if (isset($_GET['filecount']))
1244
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1245
-	else
1325
+	if (isset($_GET['filecount'])) {
1326
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1327
+	} else
1246 1328
 	{
1247 1329
 		$upcontext['file_count'] = 0;
1248 1330
 		foreach ($files as $file)
1249 1331
 		{
1250
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1251
-				$upcontext['file_count']++;
1332
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1333
+							$upcontext['file_count']++;
1334
+			}
1252 1335
 		}
1253 1336
 	}
1254 1337
 
@@ -1258,9 +1341,9 @@  discard block
 block discarded – undo
1258 1341
 	$upcontext['cur_file_num'] = 0;
1259 1342
 	foreach ($files as $file)
1260 1343
 	{
1261
-		if ($did_not_do)
1262
-			$did_not_do--;
1263
-		else
1344
+		if ($did_not_do) {
1345
+					$did_not_do--;
1346
+		} else
1264 1347
 		{
1265 1348
 			$upcontext['cur_file_num']++;
1266 1349
 			$upcontext['cur_file_name'] = $file[0];
@@ -1287,12 +1370,13 @@  discard block
 block discarded – undo
1287 1370
 					// Flag to move on to the next.
1288 1371
 					$upcontext['completed_step'] = true;
1289 1372
 					// Did we complete the whole file?
1290
-					if ($nextFile)
1291
-						$upcontext['current_debug_item_num'] = -1;
1373
+					if ($nextFile) {
1374
+											$upcontext['current_debug_item_num'] = -1;
1375
+					}
1292 1376
 					return upgradeExit();
1377
+				} elseif ($support_js) {
1378
+									break;
1293 1379
 				}
1294
-				elseif ($support_js)
1295
-					break;
1296 1380
 			}
1297 1381
 			// Set the progress bar to be right as if we had - even if we hadn't...
1298 1382
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1317,8 +1401,9 @@  discard block
 block discarded – undo
1317 1401
 	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
1318 1402
 
1319 1403
 	// Now it's nice to have some of the basic SMF source files.
1320
-	if (!isset($_GET['ssi']) && !$command_line)
1321
-		redirectLocation('&ssi=1');
1404
+	if (!isset($_GET['ssi']) && !$command_line) {
1405
+			redirectLocation('&ssi=1');
1406
+	}
1322 1407
 
1323 1408
 	$upcontext['sub_template'] = 'upgrade_complete';
1324 1409
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -1334,14 +1419,16 @@  discard block
 block discarded – undo
1334 1419
 	// Are we in maintenance mode?
1335 1420
 	if (isset($upcontext['user']['main']))
1336 1421
 	{
1337
-		if ($command_line)
1338
-			echo ' * ';
1422
+		if ($command_line) {
1423
+					echo ' * ';
1424
+		}
1339 1425
 		$upcontext['removed_maintenance'] = true;
1340 1426
 		$changes['maintenance'] = $upcontext['user']['main'];
1341 1427
 	}
1342 1428
 	// Otherwise if somehow we are in 2 let's go to 1.
1343
-	elseif (!empty($maintenance) && $maintenance == 2)
1344
-		$changes['maintenance'] = 1;
1429
+	elseif (!empty($maintenance) && $maintenance == 2) {
1430
+			$changes['maintenance'] = 1;
1431
+	}
1345 1432
 
1346 1433
 	// Wipe this out...
1347 1434
 	$upcontext['user'] = array();
@@ -1356,9 +1443,9 @@  discard block
 block discarded – undo
1356 1443
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1357 1444
 
1358 1445
 	// Now is the perfect time to fetch the SM files.
1359
-	if ($command_line)
1360
-		cli_scheduled_fetchSMfiles();
1361
-	else
1446
+	if ($command_line) {
1447
+			cli_scheduled_fetchSMfiles();
1448
+	} else
1362 1449
 	{
1363 1450
 		require_once($sourcedir . '/ScheduledTasks.php');
1364 1451
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -1366,8 +1453,9 @@  discard block
 block discarded – undo
1366 1453
 	}
1367 1454
 
1368 1455
 	// Log what we've done.
1369
-	if (empty($user_info['id']))
1370
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1456
+	if (empty($user_info['id'])) {
1457
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1458
+	}
1371 1459
 
1372 1460
 	// Log the action manually, so CLI still works.
1373 1461
 	$smcFunc['db_insert']('',
@@ -1386,8 +1474,9 @@  discard block
 block discarded – undo
1386 1474
 
1387 1475
 	// Save the current database version.
1388 1476
 	$server_version = $smcFunc['db_server_info']();
1389
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1390
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1477
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1478
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1479
+	}
1391 1480
 
1392 1481
 	if ($command_line)
1393 1482
 	{
@@ -1399,8 +1488,9 @@  discard block
 block discarded – undo
1399 1488
 
1400 1489
 	// Make sure it says we're done.
1401 1490
 	$upcontext['overall_percent'] = 100;
1402
-	if (isset($upcontext['step_progress']))
1403
-		unset($upcontext['step_progress']);
1491
+	if (isset($upcontext['step_progress'])) {
1492
+			unset($upcontext['step_progress']);
1493
+	}
1404 1494
 
1405 1495
 	$_GET['substep'] = 0;
1406 1496
 	return false;
@@ -1411,8 +1501,9 @@  discard block
 block discarded – undo
1411 1501
 {
1412 1502
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1413 1503
 
1414
-	if (empty($modSettings['time_format']))
1415
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1504
+	if (empty($modSettings['time_format'])) {
1505
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1506
+	}
1416 1507
 
1417 1508
 	// What files do we want to get
1418 1509
 	$request = $smcFunc['db_query']('', '
@@ -1446,8 +1537,9 @@  discard block
 block discarded – undo
1446 1537
 		$file_data = fetch_web_data($url);
1447 1538
 
1448 1539
 		// If we got an error - give up - the site might be down.
1449
-		if ($file_data === false)
1450
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1540
+		if ($file_data === false) {
1541
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1542
+		}
1451 1543
 
1452 1544
 		// Save the file to the database.
1453 1545
 		$smcFunc['db_query']('substring', '
@@ -1489,8 +1581,9 @@  discard block
 block discarded – undo
1489 1581
 	$themeData = array();
1490 1582
 	foreach ($values as $variable => $value)
1491 1583
 	{
1492
-		if (!isset($value) || $value === null)
1493
-			$value = 0;
1584
+		if (!isset($value) || $value === null) {
1585
+					$value = 0;
1586
+		}
1494 1587
 
1495 1588
 		$themeData[] = array(0, 1, $variable, $value);
1496 1589
 	}
@@ -1519,8 +1612,9 @@  discard block
 block discarded – undo
1519 1612
 
1520 1613
 	foreach ($values as $variable => $value)
1521 1614
 	{
1522
-		if (empty($modSettings[$value[0]]))
1523
-			continue;
1615
+		if (empty($modSettings[$value[0]])) {
1616
+					continue;
1617
+		}
1524 1618
 
1525 1619
 		$smcFunc['db_query']('', '
1526 1620
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1606,19 +1700,21 @@  discard block
 block discarded – undo
1606 1700
 	set_error_handler(
1607 1701
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1608 1702
 		{
1609
-			if ($support_js)
1610
-				return true;
1611
-			else
1612
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1703
+			if ($support_js) {
1704
+							return true;
1705
+			} else {
1706
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1707
+			}
1613 1708
 		}
1614 1709
 	);
1615 1710
 
1616 1711
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1617 1712
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1618
-	if ($db_type == 'mysql')
1619
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1620
-	else
1621
-		$db_collation = '';
1713
+	if ($db_type == 'mysql') {
1714
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1715
+	} else {
1716
+			$db_collation = '';
1717
+	}
1622 1718
 
1623 1719
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1624 1720
 
@@ -1630,8 +1726,9 @@  discard block
 block discarded – undo
1630 1726
 	$last_step = '';
1631 1727
 
1632 1728
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1633
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1634
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1729
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1730
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1731
+	}
1635 1732
 
1636 1733
 	// Count the total number of steps within this file - for progress.
1637 1734
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1651,15 +1748,18 @@  discard block
 block discarded – undo
1651 1748
 		$do_current = $substep >= $_GET['substep'];
1652 1749
 
1653 1750
 		// Get rid of any comments in the beginning of the line...
1654
-		if (substr(trim($line), 0, 2) === '/*')
1655
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1751
+		if (substr(trim($line), 0, 2) === '/*') {
1752
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1753
+		}
1656 1754
 
1657 1755
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1658
-		if ($is_debug && !$support_js && $command_line)
1659
-			flush();
1756
+		if ($is_debug && !$support_js && $command_line) {
1757
+					flush();
1758
+		}
1660 1759
 
1661
-		if (trim($line) === '')
1662
-			continue;
1760
+		if (trim($line) === '') {
1761
+					continue;
1762
+		}
1663 1763
 
1664 1764
 		if (trim(substr($line, 0, 3)) === '---')
1665 1765
 		{
@@ -1669,8 +1769,9 @@  discard block
 block discarded – undo
1669 1769
 			if (trim($current_data) != '' && $type !== '}')
1670 1770
 			{
1671 1771
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1672
-				if ($command_line)
1673
-					echo $upcontext['error_message'];
1772
+				if ($command_line) {
1773
+									echo $upcontext['error_message'];
1774
+				}
1674 1775
 			}
1675 1776
 
1676 1777
 			if ($type == ' ')
@@ -1688,17 +1789,18 @@  discard block
 block discarded – undo
1688 1789
 				if ($do_current)
1689 1790
 				{
1690 1791
 					$upcontext['actioned_items'][] = $last_step;
1691
-					if ($command_line)
1692
-						echo ' * ';
1792
+					if ($command_line) {
1793
+											echo ' * ';
1794
+					}
1693 1795
 				}
1694
-			}
1695
-			elseif ($type == '#')
1796
+			} elseif ($type == '#')
1696 1797
 			{
1697 1798
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1698 1799
 
1699 1800
 				$upcontext['current_debug_item_num']++;
1700
-				if (trim($line) != '---#')
1701
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1801
+				if (trim($line) != '---#') {
1802
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1803
+				}
1702 1804
 
1703 1805
 				// Have we already done something?
1704 1806
 				if (isset($_GET['xml']) && $done_something)
@@ -1709,34 +1811,36 @@  discard block
 block discarded – undo
1709 1811
 
1710 1812
 				if ($do_current)
1711 1813
 				{
1712
-					if (trim($line) == '---#' && $command_line)
1713
-						echo ' done.', $endl;
1714
-					elseif ($command_line)
1715
-						echo ' +++ ', rtrim(substr($line, 4));
1716
-					elseif (trim($line) != '---#')
1814
+					if (trim($line) == '---#' && $command_line) {
1815
+											echo ' done.', $endl;
1816
+					} elseif ($command_line) {
1817
+											echo ' +++ ', rtrim(substr($line, 4));
1818
+					} elseif (trim($line) != '---#')
1717 1819
 					{
1718
-						if ($is_debug)
1719
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1820
+						if ($is_debug) {
1821
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1822
+						}
1720 1823
 					}
1721 1824
 				}
1722 1825
 
1723 1826
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1724 1827
 				{
1725
-					if ($command_line)
1726
-						echo ' * ';
1727
-					else
1728
-						$upcontext['actioned_items'][] = $last_step;
1828
+					if ($command_line) {
1829
+											echo ' * ';
1830
+					} else {
1831
+											$upcontext['actioned_items'][] = $last_step;
1832
+					}
1729 1833
 				}
1730 1834
 
1731 1835
 				// Small step - only if we're actually doing stuff.
1732
-				if ($do_current)
1733
-					nextSubstep(++$substep);
1734
-				else
1735
-					$substep++;
1736
-			}
1737
-			elseif ($type == '{')
1738
-				$current_type = 'code';
1739
-			elseif ($type == '}')
1836
+				if ($do_current) {
1837
+									nextSubstep(++$substep);
1838
+				} else {
1839
+									$substep++;
1840
+				}
1841
+			} elseif ($type == '{') {
1842
+							$current_type = 'code';
1843
+			} elseif ($type == '}')
1740 1844
 			{
1741 1845
 				$current_type = 'sql';
1742 1846
 
@@ -1749,8 +1853,9 @@  discard block
 block discarded – undo
1749 1853
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1750 1854
 				{
1751 1855
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1752
-					if ($command_line)
1753
-						echo $upcontext['error_message'];
1856
+					if ($command_line) {
1857
+											echo $upcontext['error_message'];
1858
+					}
1754 1859
 				}
1755 1860
 
1756 1861
 				// Done with code!
@@ -1830,8 +1935,9 @@  discard block
 block discarded – undo
1830 1935
 	$db_unbuffered = false;
1831 1936
 
1832 1937
 	// Failure?!
1833
-	if ($result !== false)
1834
-		return $result;
1938
+	if ($result !== false) {
1939
+			return $result;
1940
+	}
1835 1941
 
1836 1942
 	$db_error_message = $smcFunc['db_error']($db_connection);
1837 1943
 	// If MySQL we do something more clever.
@@ -1859,54 +1965,61 @@  discard block
 block discarded – undo
1859 1965
 			{
1860 1966
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
1861 1967
 				$result = mysqli_query($db_connection, $string);
1862
-				if ($result !== false)
1863
-					return $result;
1968
+				if ($result !== false) {
1969
+									return $result;
1970
+				}
1864 1971
 			}
1865
-		}
1866
-		elseif ($mysqli_errno == 2013)
1972
+		} elseif ($mysqli_errno == 2013)
1867 1973
 		{
1868 1974
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
1869 1975
 			mysqli_select_db($db_connection, $db_name);
1870 1976
 			if ($db_connection)
1871 1977
 			{
1872 1978
 				$result = mysqli_query($db_connection, $string);
1873
-				if ($result !== false)
1874
-					return $result;
1979
+				if ($result !== false) {
1980
+									return $result;
1981
+				}
1875 1982
 			}
1876 1983
 		}
1877 1984
 		// Duplicate column name... should be okay ;).
1878
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
1879
-			return false;
1985
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
1986
+					return false;
1987
+		}
1880 1988
 		// Duplicate insert... make sure it's the proper type of query ;).
1881
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
1882
-			return false;
1989
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
1990
+					return false;
1991
+		}
1883 1992
 		// Creating an index on a non-existent column.
1884
-		elseif ($mysqli_errno == 1072)
1885
-			return false;
1886
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
1887
-			return false;
1993
+		elseif ($mysqli_errno == 1072) {
1994
+					return false;
1995
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
1996
+					return false;
1997
+		}
1888 1998
 	}
1889 1999
 	// If a table already exists don't go potty.
1890 2000
 	else
1891 2001
 	{
1892 2002
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
1893 2003
 		{
1894
-			if (strpos($db_error_message, 'exist') !== false)
1895
-				return true;
1896
-		}
1897
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2004
+			if (strpos($db_error_message, 'exist') !== false) {
2005
+							return true;
2006
+			}
2007
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
1898 2008
 		{
1899
-			if (strpos($db_error_message, 'duplicate') !== false)
1900
-				return true;
2009
+			if (strpos($db_error_message, 'duplicate') !== false) {
2010
+							return true;
2011
+			}
1901 2012
 		}
1902 2013
 	}
1903 2014
 
1904 2015
 	// Get the query string so we pass everything.
1905 2016
 	$query_string = '';
1906
-	foreach ($_GET as $k => $v)
1907
-		$query_string .= ';' . $k . '=' . $v;
1908
-	if (strlen($query_string) != 0)
1909
-		$query_string = '?' . substr($query_string, 1);
2017
+	foreach ($_GET as $k => $v) {
2018
+			$query_string .= ';' . $k . '=' . $v;
2019
+	}
2020
+	if (strlen($query_string) != 0) {
2021
+			$query_string = '?' . substr($query_string, 1);
2022
+	}
1910 2023
 
1911 2024
 	if ($command_line)
1912 2025
 	{
@@ -1961,16 +2074,18 @@  discard block
 block discarded – undo
1961 2074
 			{
1962 2075
 				$found |= 1;
1963 2076
 				// Do some checks on the data if we have it set.
1964
-				if (isset($change['col_type']))
1965
-					$found &= $change['col_type'] === $column['type'];
1966
-				if (isset($change['null_allowed']))
1967
-					$found &= $column['null'] == $change['null_allowed'];
1968
-				if (isset($change['default']))
1969
-					$found &= $change['default'] === $column['default'];
2077
+				if (isset($change['col_type'])) {
2078
+									$found &= $change['col_type'] === $column['type'];
2079
+				}
2080
+				if (isset($change['null_allowed'])) {
2081
+									$found &= $column['null'] == $change['null_allowed'];
2082
+				}
2083
+				if (isset($change['default'])) {
2084
+									$found &= $change['default'] === $column['default'];
2085
+				}
1970 2086
 			}
1971 2087
 		}
1972
-	}
1973
-	elseif ($change['type'] === 'index')
2088
+	} elseif ($change['type'] === 'index')
1974 2089
 	{
1975 2090
 		$request = upgrade_query('
1976 2091
 			SHOW INDEX
@@ -1979,9 +2094,10 @@  discard block
 block discarded – undo
1979 2094
 		{
1980 2095
 			$cur_index = array();
1981 2096
 
1982
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1983
-				if ($row['Key_name'] === $change['name'])
2097
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2098
+							if ($row['Key_name'] === $change['name'])
1984 2099
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2100
+			}
1985 2101
 
1986 2102
 			ksort($cur_index, SORT_NUMERIC);
1987 2103
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -1991,14 +2107,17 @@  discard block
 block discarded – undo
1991 2107
 	}
1992 2108
 
1993 2109
 	// If we're trying to add and it's added, we're done.
1994
-	if ($found && in_array($change['method'], array('add', 'change')))
1995
-		return true;
2110
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2111
+			return true;
2112
+	}
1996 2113
 	// Otherwise if we're removing and it wasn't found we're also done.
1997
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
1998
-		return true;
2114
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2115
+			return true;
2116
+	}
1999 2117
 	// Otherwise is it just a test?
2000
-	elseif ($is_test)
2001
-		return false;
2118
+	elseif ($is_test) {
2119
+			return false;
2120
+	}
2002 2121
 
2003 2122
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2004 2123
 	$running = false;
@@ -2009,8 +2128,9 @@  discard block
 block discarded – undo
2009 2128
 			SHOW FULL PROCESSLIST');
2010 2129
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2011 2130
 		{
2012
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2013
-				$found = true;
2131
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2132
+							$found = true;
2133
+			}
2014 2134
 		}
2015 2135
 
2016 2136
 		// Can't find it? Then we need to run it fools!
@@ -2022,8 +2142,9 @@  discard block
 block discarded – undo
2022 2142
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2023 2143
 				' . $change['text'], true) !== false;
2024 2144
 
2025
-			if (!$success)
2026
-				return false;
2145
+			if (!$success) {
2146
+							return false;
2147
+			}
2027 2148
 
2028 2149
 			// Return
2029 2150
 			$running = true;
@@ -2065,8 +2186,9 @@  discard block
 block discarded – undo
2065 2186
 			'db_error_skip' => true,
2066 2187
 		)
2067 2188
 	);
2068
-	if ($smcFunc['db_num_rows']($request) === 0)
2069
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2189
+	if ($smcFunc['db_num_rows']($request) === 0) {
2190
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2191
+	}
2070 2192
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2071 2193
 	$smcFunc['db_free_result']($request);
2072 2194
 
@@ -2088,18 +2210,19 @@  discard block
 block discarded – undo
2088 2210
 			)
2089 2211
 		);
2090 2212
 		// No results? Just forget it all together.
2091
-		if ($smcFunc['db_num_rows']($request) === 0)
2092
-			unset($table_row['Collation']);
2093
-		else
2094
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2213
+		if ($smcFunc['db_num_rows']($request) === 0) {
2214
+					unset($table_row['Collation']);
2215
+		} else {
2216
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2217
+		}
2095 2218
 		$smcFunc['db_free_result']($request);
2096 2219
 	}
2097 2220
 
2098 2221
 	if ($column_fix)
2099 2222
 	{
2100 2223
 		// Make sure there are no NULL's left.
2101
-		if ($null_fix)
2102
-			$smcFunc['db_query']('', '
2224
+		if ($null_fix) {
2225
+					$smcFunc['db_query']('', '
2103 2226
 				UPDATE {db_prefix}' . $change['table'] . '
2104 2227
 				SET ' . $change['column'] . ' = {string:default}
2105 2228
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2108,6 +2231,7 @@  discard block
 block discarded – undo
2108 2231
 					'db_error_skip' => true,
2109 2232
 				)
2110 2233
 			);
2234
+		}
2111 2235
 
2112 2236
 		// Do the actual alteration.
2113 2237
 		$smcFunc['db_query']('', '
@@ -2136,8 +2260,9 @@  discard block
 block discarded – undo
2136 2260
 	}
2137 2261
 
2138 2262
 	// Not a column we need to check on?
2139
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2140
-		return;
2263
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2264
+			return;
2265
+	}
2141 2266
 
2142 2267
 	// Break it up you (six|seven).
2143 2268
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2156,13 +2281,13 @@  discard block
 block discarded – undo
2156 2281
 				'new_name' => $temp[2],
2157 2282
 		));
2158 2283
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2159
-		if ($smcFunc['db_num_rows'] != 1)
2160
-			return;
2284
+		if ($smcFunc['db_num_rows'] != 1) {
2285
+					return;
2286
+		}
2161 2287
 
2162 2288
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2163 2289
 		$smcFunc['db_free_result']($request);
2164
-	}
2165
-	else
2290
+	} else
2166 2291
 	{
2167 2292
 		// Do this the old fashion, sure method way.
2168 2293
 		$request = $smcFunc['db_query']('', '
@@ -2173,21 +2298,24 @@  discard block
 block discarded – undo
2173 2298
 		));
2174 2299
 		// Mayday!
2175 2300
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2176
-		if ($smcFunc['db_num_rows'] == 0)
2177
-			return;
2301
+		if ($smcFunc['db_num_rows'] == 0) {
2302
+					return;
2303
+		}
2178 2304
 
2179 2305
 		// Oh where, oh where has my little field gone. Oh where can it be...
2180
-		while ($row = $smcFunc['db_query']($request))
2181
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2306
+		while ($row = $smcFunc['db_query']($request)) {
2307
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2182 2308
 			{
2183 2309
 				$current_type = $row['Type'];
2310
+		}
2184 2311
 				break;
2185 2312
 			}
2186 2313
 	}
2187 2314
 
2188 2315
 	// If this doesn't match, the column may of been altered for a reason.
2189
-	if (trim($current_type) != trim($temp[3]))
2190
-		$temp[3] = $current_type;
2316
+	if (trim($current_type) != trim($temp[3])) {
2317
+			$temp[3] = $current_type;
2318
+	}
2191 2319
 
2192 2320
 	// Piece this back together.
2193 2321
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2199,8 +2327,9 @@  discard block
 block discarded – undo
2199 2327
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2200 2328
 	global $step_progress, $is_debug, $upcontext;
2201 2329
 
2202
-	if ($_GET['substep'] < $substep)
2203
-		$_GET['substep'] = $substep;
2330
+	if ($_GET['substep'] < $substep) {
2331
+			$_GET['substep'] = $substep;
2332
+	}
2204 2333
 
2205 2334
 	if ($command_line)
2206 2335
 	{
@@ -2213,29 +2342,33 @@  discard block
 block discarded – undo
2213 2342
 	}
2214 2343
 
2215 2344
 	@set_time_limit(300);
2216
-	if (function_exists('apache_reset_timeout'))
2217
-		@apache_reset_timeout();
2345
+	if (function_exists('apache_reset_timeout')) {
2346
+			@apache_reset_timeout();
2347
+	}
2218 2348
 
2219
-	if (time() - $start_time <= $timeLimitThreshold)
2220
-		return;
2349
+	if (time() - $start_time <= $timeLimitThreshold) {
2350
+			return;
2351
+	}
2221 2352
 
2222 2353
 	// Do we have some custom step progress stuff?
2223 2354
 	if (!empty($step_progress))
2224 2355
 	{
2225 2356
 		$upcontext['substep_progress'] = 0;
2226 2357
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2227
-		if ($step_progress['current'] > $step_progress['total'])
2228
-			$upcontext['substep_progress'] = 99.9;
2229
-		else
2230
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2358
+		if ($step_progress['current'] > $step_progress['total']) {
2359
+					$upcontext['substep_progress'] = 99.9;
2360
+		} else {
2361
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2362
+		}
2231 2363
 
2232 2364
 		// Make it nicely rounded.
2233 2365
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2234 2366
 	}
2235 2367
 
2236 2368
 	// If this is XML we just exit right away!
2237
-	if (isset($_GET['xml']))
2238
-		return upgradeExit();
2369
+	if (isset($_GET['xml'])) {
2370
+			return upgradeExit();
2371
+	}
2239 2372
 
2240 2373
 	// We're going to pause after this!
2241 2374
 	$upcontext['pause'] = true;
@@ -2243,13 +2376,15 @@  discard block
 block discarded – undo
2243 2376
 	$upcontext['query_string'] = '';
2244 2377
 	foreach ($_GET as $k => $v)
2245 2378
 	{
2246
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2247
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2379
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2380
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2381
+		}
2248 2382
 	}
2249 2383
 
2250 2384
 	// Custom warning?
2251
-	if (!empty($custom_warning))
2252
-		$upcontext['custom_warning'] = $custom_warning;
2385
+	if (!empty($custom_warning)) {
2386
+			$upcontext['custom_warning'] = $custom_warning;
2387
+	}
2253 2388
 
2254 2389
 	upgradeExit();
2255 2390
 }
@@ -2264,25 +2399,26 @@  discard block
 block discarded – undo
2264 2399
 	ob_implicit_flush(true);
2265 2400
 	@set_time_limit(600);
2266 2401
 
2267
-	if (!isset($_SERVER['argv']))
2268
-		$_SERVER['argv'] = array();
2402
+	if (!isset($_SERVER['argv'])) {
2403
+			$_SERVER['argv'] = array();
2404
+	}
2269 2405
 	$_GET['maint'] = 1;
2270 2406
 
2271 2407
 	foreach ($_SERVER['argv'] as $i => $arg)
2272 2408
 	{
2273
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2274
-			$_GET['lang'] = $match[1];
2275
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2276
-			continue;
2277
-		elseif ($arg == '--no-maintenance')
2278
-			$_GET['maint'] = 0;
2279
-		elseif ($arg == '--debug')
2280
-			$is_debug = true;
2281
-		elseif ($arg == '--backup')
2282
-			$_POST['backup'] = 1;
2283
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2284
-			$_GET['conv'] = 1;
2285
-		elseif ($i != 0)
2409
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2410
+					$_GET['lang'] = $match[1];
2411
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2412
+					continue;
2413
+		} elseif ($arg == '--no-maintenance') {
2414
+					$_GET['maint'] = 0;
2415
+		} elseif ($arg == '--debug') {
2416
+					$is_debug = true;
2417
+		} elseif ($arg == '--backup') {
2418
+					$_POST['backup'] = 1;
2419
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2420
+					$_GET['conv'] = 1;
2421
+		} elseif ($i != 0)
2286 2422
 		{
2287 2423
 			echo 'SMF Command-line Upgrader
2288 2424
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2296,10 +2432,12 @@  discard block
 block discarded – undo
2296 2432
 		}
2297 2433
 	}
2298 2434
 
2299
-	if (!php_version_check())
2300
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2301
-	if (!db_version_check())
2302
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2435
+	if (!php_version_check()) {
2436
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2437
+	}
2438
+	if (!db_version_check()) {
2439
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2440
+	}
2303 2441
 
2304 2442
 	// Do some checks to make sure they have proper privileges
2305 2443
 	db_extend('packages');
@@ -2314,34 +2452,39 @@  discard block
 block discarded – undo
2314 2452
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2315 2453
 
2316 2454
 	// Sorry... we need CREATE, ALTER and DROP
2317
-	if (!$create || !$alter || !$drop)
2318
-		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);
2455
+	if (!$create || !$alter || !$drop) {
2456
+			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
+	}
2319 2458
 
2320 2459
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2321 2460
 		&& @file_exists($sourcedir . '/QueryString.php')
2322 2461
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2323
-	if (!$check && !isset($modSettings['smfVersion']))
2324
-		print_error('Error: Some files are missing or out-of-date.', true);
2462
+	if (!$check && !isset($modSettings['smfVersion'])) {
2463
+			print_error('Error: Some files are missing or out-of-date.', true);
2464
+	}
2325 2465
 
2326 2466
 	// Do a quick version spot check.
2327 2467
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2328 2468
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2329
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2330
-		print_error('Error: Some files have not yet been updated properly.');
2469
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2470
+			print_error('Error: Some files have not yet been updated properly.');
2471
+	}
2331 2472
 
2332 2473
 	// Make sure Settings.php is writable.
2333 2474
 		quickFileWritable($boarddir . '/Settings.php');
2334
-	if (!is_writable($boarddir . '/Settings.php'))
2335
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2475
+	if (!is_writable($boarddir . '/Settings.php')) {
2476
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2477
+	}
2336 2478
 
2337 2479
 	// Make sure Settings_bak.php is writable.
2338 2480
 		quickFileWritable($boarddir . '/Settings_bak.php');
2339
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2340
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2481
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2482
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2483
+	}
2341 2484
 
2342
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2343
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2344
-	elseif (isset($modSettings['agreement']))
2485
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2486
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2487
+	} elseif (isset($modSettings['agreement']))
2345 2488
 	{
2346 2489
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2347 2490
 		fwrite($fp, $modSettings['agreement']);
@@ -2351,31 +2494,36 @@  discard block
 block discarded – undo
2351 2494
 	// Make sure Themes is writable.
2352 2495
 	quickFileWritable($modSettings['theme_dir']);
2353 2496
 
2354
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2355
-		print_error('Error: Unable to obtain write access to "Themes".');
2497
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2498
+			print_error('Error: Unable to obtain write access to "Themes".');
2499
+	}
2356 2500
 
2357 2501
 	// Make sure cache directory exists and is writable!
2358 2502
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2359
-	if (!file_exists($cachedir_temp))
2360
-		@mkdir($cachedir_temp);
2503
+	if (!file_exists($cachedir_temp)) {
2504
+			@mkdir($cachedir_temp);
2505
+	}
2361 2506
 
2362 2507
 	// Make sure the cache temp dir is writable.
2363 2508
 	quickFileWritable($cachedir_temp);
2364 2509
 
2365
-	if (!is_writable($cachedir_temp))
2366
-		print_error('Error: Unable to obtain write access to "cache".', true);
2510
+	if (!is_writable($cachedir_temp)) {
2511
+			print_error('Error: Unable to obtain write access to "cache".', true);
2512
+	}
2367 2513
 
2368
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2369
-		print_error('Error: Unable to find language files!', true);
2370
-	else
2514
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2515
+			print_error('Error: Unable to find language files!', true);
2516
+	} else
2371 2517
 	{
2372 2518
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2373 2519
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2374 2520
 
2375
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2376
-			print_error('Error: Language files out of date.', true);
2377
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2378
-			print_error('Error: Install language is missing for selected language.', true);
2521
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2522
+					print_error('Error: Language files out of date.', true);
2523
+		}
2524
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2525
+					print_error('Error: Install language is missing for selected language.', true);
2526
+		}
2379 2527
 
2380 2528
 		// Otherwise include it!
2381 2529
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2394,8 +2542,9 @@  discard block
 block discarded – undo
2394 2542
 	global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js;
2395 2543
 
2396 2544
 	// Done it already?
2397
-	if (!empty($_POST['utf8_done']))
2398
-		return true;
2545
+	if (!empty($_POST['utf8_done'])) {
2546
+			return true;
2547
+	}
2399 2548
 
2400 2549
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2401 2550
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2408,8 +2557,7 @@  discard block
 block discarded – undo
2408 2557
 		);
2409 2558
 
2410 2559
 		return true;
2411
-	}
2412
-	else
2560
+	} else
2413 2561
 	{
2414 2562
 		$upcontext['page_title'] = 'Converting to UTF8';
2415 2563
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2453,8 +2601,9 @@  discard block
 block discarded – undo
2453 2601
 			)
2454 2602
 		);
2455 2603
 		$db_charsets = array();
2456
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2457
-			$db_charsets[] = $row['Charset'];
2604
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2605
+					$db_charsets[] = $row['Charset'];
2606
+		}
2458 2607
 
2459 2608
 		$smcFunc['db_free_result']($request);
2460 2609
 
@@ -2490,13 +2639,15 @@  discard block
 block discarded – undo
2490 2639
 		// If there's a fulltext index, we need to drop it first...
2491 2640
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2492 2641
 		{
2493
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2494
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2642
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2643
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2495 2644
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2645
+			}
2496 2646
 			$smcFunc['db_free_result']($request);
2497 2647
 
2498
-			if (isset($upcontext['fulltext_index']))
2499
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2648
+			if (isset($upcontext['fulltext_index'])) {
2649
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2650
+			}
2500 2651
 		}
2501 2652
 
2502 2653
 		// Drop it and make a note...
@@ -2686,8 +2837,9 @@  discard block
 block discarded – undo
2686 2837
 			$replace = '%field%';
2687 2838
 
2688 2839
 			// Build a huge REPLACE statement...
2689
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2690
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2840
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
2841
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
2842
+			}
2691 2843
 		}
2692 2844
 
2693 2845
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2697,9 +2849,10 @@  discard block
 block discarded – undo
2697 2849
 		$upcontext['table_count'] = count($queryTables);
2698 2850
 	
2699 2851
 		// What ones have we already done?
2700
-		foreach ($queryTables as $id => $table)
2701
-			if ($id < $_GET['substep'])
2852
+		foreach ($queryTables as $id => $table) {
2853
+					if ($id < $_GET['substep'])
2702 2854
 				$upcontext['previous_tables'][] = $table;
2855
+		}
2703 2856
 
2704 2857
 		$upcontext['cur_table_num'] = $_GET['substep'];
2705 2858
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2736,8 +2889,9 @@  discard block
 block discarded – undo
2736 2889
 			nextSubstep($substep);
2737 2890
 
2738 2891
 			// Just to make sure it doesn't time out.
2739
-			if (function_exists('apache_reset_timeout'))
2740
-				@apache_reset_timeout();
2892
+			if (function_exists('apache_reset_timeout')) {
2893
+							@apache_reset_timeout();
2894
+			}
2741 2895
 
2742 2896
 			$table_charsets = array();
2743 2897
 
@@ -2758,8 +2912,9 @@  discard block
 block discarded – undo
2758 2912
 					{
2759 2913
 						list($charset) = explode('_', $collation);
2760 2914
 
2761
-						if (!isset($table_charsets[$charset]))
2762
-							$table_charsets[$charset] = array();
2915
+						if (!isset($table_charsets[$charset])) {
2916
+													$table_charsets[$charset] = array();
2917
+						}
2763 2918
 
2764 2919
 						$table_charsets[$charset][] = $column_info;
2765 2920
 					}
@@ -2799,10 +2954,11 @@  discard block
 block discarded – undo
2799 2954
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2800 2955
 				{
2801 2956
 					$update = '';
2802
-					foreach ($table_charsets as $charset => $columns)
2803
-						foreach ($columns as $column)
2957
+					foreach ($table_charsets as $charset => $columns) {
2958
+											foreach ($columns as $column)
2804 2959
 							$update .= '
2805 2960
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
2961
+					}
2806 2962
 
2807 2963
 					$smcFunc['db_query']('', '
2808 2964
 						UPDATE {raw:table_name}
@@ -2827,8 +2983,9 @@  discard block
 block discarded – undo
2827 2983
 			// Now do the actual conversion (if still needed).
2828 2984
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
2829 2985
 			{
2830
-				if ($command_line)
2831
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
2986
+				if ($command_line) {
2987
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
2988
+				}
2832 2989
 
2833 2990
 				$smcFunc['db_query']('', '
2834 2991
 					ALTER TABLE {raw:table_name}
@@ -2838,12 +2995,14 @@  discard block
 block discarded – undo
2838 2995
 					)
2839 2996
 				);
2840 2997
 
2841
-				if ($command_line)
2842
-					echo " done.\n";
2998
+				if ($command_line) {
2999
+									echo " done.\n";
3000
+				}
2843 3001
 			}
2844 3002
 			// If this is XML to keep it nice for the user do one table at a time anyway!
2845
-			if (isset($_GET['xml']))
2846
-				return upgradeExit();
3003
+			if (isset($_GET['xml'])) {
3004
+							return upgradeExit();
3005
+			}
2847 3006
 		}
2848 3007
 
2849 3008
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -2872,8 +3031,8 @@  discard block
 block discarded – undo
2872 3031
 		);
2873 3032
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2874 3033
 		{
2875
-			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)
2876
-				$smcFunc['db_query']('', '
3034
+			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) {
3035
+							$smcFunc['db_query']('', '
2877 3036
 					UPDATE {db_prefix}log_actions
2878 3037
 					SET extra = {string:extra}
2879 3038
 					WHERE id_action = {int:current_action}',
@@ -2882,6 +3041,7 @@  discard block
 block discarded – undo
2882 3041
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
2883 3042
 					)
2884 3043
 				);
3044
+			}
2885 3045
 		}
2886 3046
 		$smcFunc['db_free_result']($request);
2887 3047
 
@@ -2903,15 +3063,17 @@  discard block
 block discarded – undo
2903 3063
 	// First thing's first - did we already do this?
2904 3064
 	if (!empty($modSettings['json_done']))
2905 3065
 	{
2906
-		if ($command_line)
2907
-			return DeleteUpgrade();
2908
-		else
2909
-			return true;
3066
+		if ($command_line) {
3067
+					return DeleteUpgrade();
3068
+		} else {
3069
+					return true;
3070
+		}
2910 3071
 	}
2911 3072
 
2912 3073
 	// Done it already - js wise?
2913
-	if (!empty($_POST['json_done']))
2914
-		return true;
3074
+	if (!empty($_POST['json_done'])) {
3075
+			return true;
3076
+	}
2915 3077
 
2916 3078
 	// List of tables affected by this function
2917 3079
 	// name => array('key', col1[,col2|true[,col3]])
@@ -2943,12 +3105,14 @@  discard block
 block discarded – undo
2943 3105
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
2944 3106
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
2945 3107
 
2946
-	foreach ($keys as $id => $table)
2947
-		if ($id < $_GET['substep'])
3108
+	foreach ($keys as $id => $table) {
3109
+			if ($id < $_GET['substep'])
2948 3110
 			$upcontext['previous_tables'][] = $table;
3111
+	}
2949 3112
 
2950
-	if ($command_line)
2951
-		echo 'Converting data from serialize() to json_encode().';
3113
+	if ($command_line) {
3114
+			echo 'Converting data from serialize() to json_encode().';
3115
+	}
2952 3116
 
2953 3117
 	if (!$support_js || isset($_GET['xml']))
2954 3118
 	{
@@ -2988,8 +3152,9 @@  discard block
 block discarded – undo
2988 3152
 
2989 3153
 				// Loop through and fix these...
2990 3154
 				$new_settings = array();
2991
-				if ($command_line)
2992
-					echo "\n" . 'Fixing some settings...';
3155
+				if ($command_line) {
3156
+									echo "\n" . 'Fixing some settings...';
3157
+				}
2993 3158
 
2994 3159
 				foreach ($serialized_settings as $var)
2995 3160
 				{
@@ -2997,22 +3162,24 @@  discard block
 block discarded – undo
2997 3162
 					{
2998 3163
 						// Attempt to unserialize the setting
2999 3164
 						$temp = @safe_unserialize($modSettings[$var]);
3000
-						if (!$temp && $command_line)
3001
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3002
-						elseif ($temp !== false)
3003
-							$new_settings[$var] = json_encode($temp);
3165
+						if (!$temp && $command_line) {
3166
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3167
+						} elseif ($temp !== false) {
3168
+													$new_settings[$var] = json_encode($temp);
3169
+						}
3004 3170
 					}
3005 3171
 				}
3006 3172
 
3007 3173
 				// Update everything at once
3008
-				if (!function_exists('cache_put_data'))
3009
-					require_once($sourcedir . '/Load.php');
3174
+				if (!function_exists('cache_put_data')) {
3175
+									require_once($sourcedir . '/Load.php');
3176
+				}
3010 3177
 				updateSettings($new_settings, true);
3011 3178
 
3012
-				if ($command_line)
3013
-					echo ' done.';
3014
-			}
3015
-			elseif ($table == 'themes')
3179
+				if ($command_line) {
3180
+									echo ' done.';
3181
+				}
3182
+			} elseif ($table == 'themes')
3016 3183
 			{
3017 3184
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3018 3185
 				$query = $smcFunc['db_query']('', '
@@ -3031,10 +3198,11 @@  discard block
 block discarded – undo
3031 3198
 
3032 3199
 						if ($command_line)
3033 3200
 						{
3034
-							if ($temp === false)
3035
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3036
-							else
3037
-								echo "\n" . 'Fixing admin preferences...';
3201
+							if ($temp === false) {
3202
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3203
+							} else {
3204
+															echo "\n" . 'Fixing admin preferences...';
3205
+							}
3038 3206
 						}
3039 3207
 
3040 3208
 						if ($temp !== false)
@@ -3056,15 +3224,15 @@  discard block
 block discarded – undo
3056 3224
 								)
3057 3225
 							);
3058 3226
 
3059
-							if ($command_line)
3060
-								echo ' done.';
3227
+							if ($command_line) {
3228
+															echo ' done.';
3229
+							}
3061 3230
 						}
3062 3231
 					}
3063 3232
 
3064 3233
 					$smcFunc['db_free_result']($query);
3065 3234
 				}
3066
-			}
3067
-			else
3235
+			} else
3068 3236
 			{
3069 3237
 				// First item is always the key...
3070 3238
 				$key = $info[0];
@@ -3075,8 +3243,7 @@  discard block
 block discarded – undo
3075 3243
 				{
3076 3244
 					$col_select = $info[1];
3077 3245
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3078
-				}
3079
-				else
3246
+				} else
3080 3247
 				{
3081 3248
 					$col_select = implode(', ', $info);
3082 3249
 				}
@@ -3109,8 +3276,7 @@  discard block
 block discarded – undo
3109 3276
 								if ($temp === false && $command_line)
3110 3277
 								{
3111 3278
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3112
-								}
3113
-								else
3279
+								} else
3114 3280
 								{
3115 3281
 									$row[$col] = json_encode($temp);
3116 3282
 
@@ -3135,16 +3301,18 @@  discard block
 block discarded – undo
3135 3301
 						}
3136 3302
 					}
3137 3303
 
3138
-					if ($command_line)
3139
-						echo ' done.';
3304
+					if ($command_line) {
3305
+											echo ' done.';
3306
+					}
3140 3307
 
3141 3308
 					// Free up some memory...
3142 3309
 					$smcFunc['db_free_result']($query);
3143 3310
 				}
3144 3311
 			}
3145 3312
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3146
-			if (isset($_GET['xml']))
3147
-				return upgradeExit();
3313
+			if (isset($_GET['xml'])) {
3314
+							return upgradeExit();
3315
+			}
3148 3316
 		}
3149 3317
 
3150 3318
 		if ($command_line)
@@ -3159,8 +3327,9 @@  discard block
 block discarded – undo
3159 3327
 
3160 3328
 		$_GET['substep'] = 0;
3161 3329
 		// Make sure we move on!
3162
-		if ($command_line)
3163
-			return DeleteUpgrade();
3330
+		if ($command_line) {
3331
+					return DeleteUpgrade();
3332
+		}
3164 3333
 
3165 3334
 		return true;
3166 3335
 	}
@@ -3180,14 +3349,16 @@  discard block
 block discarded – undo
3180 3349
 	global $upcontext, $txt, $settings;
3181 3350
 
3182 3351
 	// Don't call me twice!
3183
-	if (!empty($upcontext['chmod_called']))
3184
-		return;
3352
+	if (!empty($upcontext['chmod_called'])) {
3353
+			return;
3354
+	}
3185 3355
 
3186 3356
 	$upcontext['chmod_called'] = true;
3187 3357
 
3188 3358
 	// Nothing?
3189
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3190
-		return;
3359
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3360
+			return;
3361
+	}
3191 3362
 
3192 3363
 	// Was it a problem with Windows?
3193 3364
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3219,11 +3390,12 @@  discard block
 block discarded – undo
3219 3390
 					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\');
3220 3391
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3221 3392
 
3222
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3223
-		echo '
3393
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3394
+			echo '
3224 3395
 					content.write(\'<hr>\n\t\t\t\');
3225 3396
 					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\');
3226 3397
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3398
+	}
3227 3399
 
3228 3400
 	echo '
3229 3401
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3231,17 +3403,19 @@  discard block
 block discarded – undo
3231 3403
 				}
3232 3404
 			</script>';
3233 3405
 
3234
-	if (!empty($upcontext['chmod']['ftp_error']))
3235
-		echo '
3406
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3407
+			echo '
3236 3408
 			<div class="error_message red">
3237 3409
 				The following error was encountered when trying to connect:<br><br>
3238 3410
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3239 3411
 			</div>
3240 3412
 			<br>';
3413
+	}
3241 3414
 
3242
-	if (empty($upcontext['chmod_in_form']))
3243
-		echo '
3415
+	if (empty($upcontext['chmod_in_form'])) {
3416
+			echo '
3244 3417
 	<form action="', $upcontext['form_url'], '" method="post">';
3418
+	}
3245 3419
 
3246 3420
 	echo '
3247 3421
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3276,10 +3450,11 @@  discard block
 block discarded – undo
3276 3450
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
3277 3451
 	</div>';
3278 3452
 
3279
-	if (empty($upcontext['chmod_in_form']))
3280
-		echo '
3453
+	if (empty($upcontext['chmod_in_form'])) {
3454
+			echo '
3281 3455
 	</form>';
3282
-}
3456
+	}
3457
+	}
3283 3458
 
3284 3459
 function template_upgrade_above()
3285 3460
 {
@@ -3339,9 +3514,10 @@  discard block
 block discarded – undo
3339 3514
 				<h2>', $txt['upgrade_progress'], '</h2>
3340 3515
 				<ul>';
3341 3516
 
3342
-	foreach ($upcontext['steps'] as $num => $step)
3343
-		echo '
3517
+	foreach ($upcontext['steps'] as $num => $step) {
3518
+			echo '
3344 3519
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3520
+	}
3345 3521
 
3346 3522
 	echo '
3347 3523
 					</ul>
@@ -3354,8 +3530,8 @@  discard block
 block discarded – undo
3354 3530
 				</div>
3355 3531
 			</div>';
3356 3532
 
3357
-	if (isset($upcontext['step_progress']))
3358
-		echo '
3533
+	if (isset($upcontext['step_progress'])) {
3534
+			echo '
3359 3535
 				<br>
3360 3536
 				<br>
3361 3537
 				<div id="progress_bar_step">
@@ -3364,6 +3540,7 @@  discard block
 block discarded – undo
3364 3540
 						<span>', $txt['upgrade_step_progress'], '</span>
3365 3541
 					</div>
3366 3542
 				</div>';
3543
+	}
3367 3544
 
3368 3545
 	echo '
3369 3546
 				<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>
@@ -3394,32 +3571,36 @@  discard block
 block discarded – undo
3394 3571
 {
3395 3572
 	global $upcontext, $txt;
3396 3573
 
3397
-	if (!empty($upcontext['pause']))
3398
-		echo '
3574
+	if (!empty($upcontext['pause'])) {
3575
+			echo '
3399 3576
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
3400 3577
 
3401 3578
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3402 3579
 								<h3>
3403 3580
 									', $txt['upgrade_paused_overload'], '
3404 3581
 								</h3>';
3582
+	}
3405 3583
 
3406
-	if (!empty($upcontext['custom_warning']))
3407
-		echo '
3584
+	if (!empty($upcontext['custom_warning'])) {
3585
+			echo '
3408 3586
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3409 3587
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3410 3588
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3411 3589
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3412 3590
 								</div>';
3591
+	}
3413 3592
 
3414 3593
 	echo '
3415 3594
 								<div class="righttext" style="margin: 1ex;">';
3416 3595
 
3417
-	if (!empty($upcontext['continue']))
3418
-		echo '
3596
+	if (!empty($upcontext['continue'])) {
3597
+			echo '
3419 3598
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
3420
-	if (!empty($upcontext['skip']))
3421
-		echo '
3599
+	}
3600
+	if (!empty($upcontext['skip'])) {
3601
+			echo '
3422 3602
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
3603
+	}
3423 3604
 
3424 3605
 	echo '
3425 3606
 								</div>
@@ -3469,11 +3650,12 @@  discard block
 block discarded – undo
3469 3650
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3470 3651
 	<smf>';
3471 3652
 
3472
-	if (!empty($upcontext['get_data']))
3473
-		foreach ($upcontext['get_data'] as $k => $v)
3653
+	if (!empty($upcontext['get_data'])) {
3654
+			foreach ($upcontext['get_data'] as $k => $v)
3474 3655
 			echo '
3475 3656
 		<get key="', $k, '">', $v, '</get>';
3476
-}
3657
+	}
3658
+	}
3477 3659
 
3478 3660
 function template_xml_below()
3479 3661
 {
@@ -3514,8 +3696,8 @@  discard block
 block discarded – undo
3514 3696
 	template_chmod();
3515 3697
 
3516 3698
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3517
-	if ($upcontext['is_large_forum'])
3518
-		echo '
3699
+	if ($upcontext['is_large_forum']) {
3700
+			echo '
3519 3701
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3520 3702
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3521 3703
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3523,10 +3705,11 @@  discard block
 block discarded – undo
3523 3705
 				', $txt['upgrade_warning_lots_data'], '
3524 3706
 			</div>
3525 3707
 		</div>';
3708
+	}
3526 3709
 
3527 3710
 	// A warning message?
3528
-	if (!empty($upcontext['warning']))
3529
-		echo '
3711
+	if (!empty($upcontext['warning'])) {
3712
+			echo '
3530 3713
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3531 3714
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3532 3715
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3534,6 +3717,7 @@  discard block
 block discarded – undo
3534 3717
 				', $upcontext['warning'], '
3535 3718
 			</div>
3536 3719
 		</div>';
3720
+	}
3537 3721
 
3538 3722
 	// Paths are incorrect?
3539 3723
 	echo '
@@ -3549,20 +3733,22 @@  discard block
 block discarded – undo
3549 3733
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3550 3734
 	{
3551 3735
 		$ago = time() - $upcontext['started'];
3552
-		if ($ago < 60)
3553
-			$ago = $ago . ' seconds';
3554
-		elseif ($ago < 3600)
3555
-			$ago = (int) ($ago / 60) . ' minutes';
3556
-		else
3557
-			$ago = (int) ($ago / 3600) . ' hours';
3736
+		if ($ago < 60) {
3737
+					$ago = $ago . ' seconds';
3738
+		} elseif ($ago < 3600) {
3739
+					$ago = (int) ($ago / 60) . ' minutes';
3740
+		} else {
3741
+					$ago = (int) ($ago / 3600) . ' hours';
3742
+		}
3558 3743
 
3559 3744
 		$active = time() - $upcontext['updated'];
3560
-		if ($active < 60)
3561
-			$updated = $active . ' seconds';
3562
-		elseif ($active < 3600)
3563
-			$updated = (int) ($active / 60) . ' minutes';
3564
-		else
3565
-			$updated = (int) ($active / 3600) . ' hours';
3745
+		if ($active < 60) {
3746
+					$updated = $active . ' seconds';
3747
+		} elseif ($active < 3600) {
3748
+					$updated = (int) ($active / 60) . ' minutes';
3749
+		} else {
3750
+					$updated = (int) ($active / 3600) . ' hours';
3751
+		}
3566 3752
 
3567 3753
 		echo '
3568 3754
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3571,16 +3757,18 @@  discard block
 block discarded – undo
3571 3757
 			<div style="padding-left: 6ex;">
3572 3758
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3573 3759
 
3574
-		if ($active < 600)
3575
-			echo '
3760
+		if ($active < 600) {
3761
+					echo '
3576 3762
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
3763
+		}
3577 3764
 
3578
-		if ($active > $upcontext['inactive_timeout'])
3579
-			echo '
3765
+		if ($active > $upcontext['inactive_timeout']) {
3766
+					echo '
3580 3767
 				<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.';
3581
-		else
3582
-			echo '
3768
+		} else {
3769
+					echo '
3583 3770
 				<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!');
3771
+		}
3584 3772
 
3585 3773
 		echo '
3586 3774
 			</div>
@@ -3596,9 +3784,10 @@  discard block
 block discarded – undo
3596 3784
 					<td>
3597 3785
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
3598 3786
 
3599
-	if (!empty($upcontext['username_incorrect']))
3600
-		echo '
3787
+	if (!empty($upcontext['username_incorrect'])) {
3788
+			echo '
3601 3789
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
3790
+	}
3602 3791
 
3603 3792
 	echo '
3604 3793
 					</td>
@@ -3609,9 +3798,10 @@  discard block
 block discarded – undo
3609 3798
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
3610 3799
 						<input type="hidden" name="hash_passwrd" value="">';
3611 3800
 
3612
-	if (!empty($upcontext['password_failed']))
3613
-		echo '
3801
+	if (!empty($upcontext['password_failed'])) {
3802
+			echo '
3614 3803
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
3804
+	}
3615 3805
 
3616 3806
 	echo '
3617 3807
 					</td>
@@ -3682,8 +3872,8 @@  discard block
 block discarded – undo
3682 3872
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3683 3873
 
3684 3874
 	// Warning message?
3685
-	if (!empty($upcontext['upgrade_options_warning']))
3686
-		echo '
3875
+	if (!empty($upcontext['upgrade_options_warning'])) {
3876
+			echo '
3687 3877
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3688 3878
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3689 3879
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3691,6 +3881,7 @@  discard block
 block discarded – undo
3691 3881
 				', $upcontext['upgrade_options_warning'], '
3692 3882
 			</div>
3693 3883
 		</div>';
3884
+	}
3694 3885
 
3695 3886
 	echo '
3696 3887
 				<table>
@@ -3733,8 +3924,8 @@  discard block
 block discarded – undo
3733 3924
 						</td>
3734 3925
 					</tr>';
3735 3926
 
3736
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3737
-		echo '
3927
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
3928
+			echo '
3738 3929
 					<tr valign="top">
3739 3930
 						<td width="2%">
3740 3931
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -3743,6 +3934,7 @@  discard block
 block discarded – undo
3743 3934
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
3744 3935
 						</td>
3745 3936
 					</tr>';
3937
+	}
3746 3938
 
3747 3939
 	echo '
3748 3940
 					<tr valign="top">
@@ -3780,10 +3972,11 @@  discard block
 block discarded – undo
3780 3972
 			</div>';
3781 3973
 
3782 3974
 	// Dont any tables so far?
3783
-	if (!empty($upcontext['previous_tables']))
3784
-		foreach ($upcontext['previous_tables'] as $table)
3975
+	if (!empty($upcontext['previous_tables'])) {
3976
+			foreach ($upcontext['previous_tables'] as $table)
3785 3977
 			echo '
3786 3978
 			<br>Completed Table: &quot;', $table, '&quot;.';
3979
+	}
3787 3980
 
3788 3981
 	echo '
3789 3982
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -3820,12 +4013,13 @@  discard block
 block discarded – undo
3820 4013
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
3821 4014
 
3822 4015
 		// If debug flood the screen.
3823
-		if ($is_debug)
3824
-			echo '
4016
+		if ($is_debug) {
4017
+					echo '
3825 4018
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
3826 4019
 
3827 4020
 				if (document.getElementById(\'debug_section\').scrollHeight)
3828 4021
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4022
+		}
3829 4023
 
3830 4024
 		echo '
3831 4025
 				// Get the next update...
@@ -3858,8 +4052,9 @@  discard block
 block discarded – undo
3858 4052
 {
3859 4053
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold;
3860 4054
 
3861
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
3862
-		$is_debug = true;
4055
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4056
+			$is_debug = true;
4057
+	}
3863 4058
 
3864 4059
 	echo '
3865 4060
 		<h3>Executing database changes</h3>
@@ -3874,8 +4069,9 @@  discard block
 block discarded – undo
3874 4069
 	{
3875 4070
 		foreach ($upcontext['actioned_items'] as $num => $item)
3876 4071
 		{
3877
-			if ($num != 0)
3878
-				echo ' Successful!';
4072
+			if ($num != 0) {
4073
+							echo ' Successful!';
4074
+			}
3879 4075
 			echo '<br>' . $item;
3880 4076
 		}
3881 4077
 		if (!empty($upcontext['changes_complete']))
@@ -3888,28 +4084,32 @@  discard block
 block discarded – undo
3888 4084
 				$seconds = intval($active % 60);
3889 4085
 
3890 4086
 				$totalTime = '';
3891
-				if ($hours > 0)
3892
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3893
-				if ($minutes > 0)
3894
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3895
-				if ($seconds > 0)
3896
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4087
+				if ($hours > 0) {
4088
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4089
+				}
4090
+				if ($minutes > 0) {
4091
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4092
+				}
4093
+				if ($seconds > 0) {
4094
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4095
+				}
3897 4096
 			}
3898 4097
 
3899
-			if ($is_debug && !empty($totalTime))
3900
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
3901
-			else
3902
-				echo ' Successful!<br><br>';
4098
+			if ($is_debug && !empty($totalTime)) {
4099
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4100
+			} else {
4101
+							echo ' Successful!<br><br>';
4102
+			}
3903 4103
 
3904 4104
 			echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>';
3905 4105
 		}
3906
-	}
3907
-	else
4106
+	} else
3908 4107
 	{
3909 4108
 		// Tell them how many files we have in total.
3910
-		if ($upcontext['file_count'] > 1)
3911
-			echo '
4109
+		if ($upcontext['file_count'] > 1) {
4110
+					echo '
3912 4111
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4112
+		}
3913 4113
 
3914 4114
 		echo '
3915 4115
 		<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>
@@ -3925,19 +4125,23 @@  discard block
 block discarded – undo
3925 4125
 				$seconds = intval($active % 60);
3926 4126
 
3927 4127
 				$totalTime = '';
3928
-				if ($hours > 0)
3929
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
3930
-				if ($minutes > 0)
3931
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
3932
-				if ($seconds > 0)
3933
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4128
+				if ($hours > 0) {
4129
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4130
+				}
4131
+				if ($minutes > 0) {
4132
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4133
+				}
4134
+				if ($seconds > 0) {
4135
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4136
+				}
3934 4137
 			}
3935 4138
 
3936 4139
 			echo '
3937 4140
 			<br><span id="upgradeCompleted">';
3938 4141
 
3939
-			if (!empty($totalTime))
3940
-				echo 'Completed in ', $totalTime, '<br>';
4142
+			if (!empty($totalTime)) {
4143
+							echo 'Completed in ', $totalTime, '<br>';
4144
+			}
3941 4145
 
3942 4146
 			echo '</span>
3943 4147
 			<div id="debug_section" style="height: 59px; overflow: auto;">
@@ -3974,9 +4178,10 @@  discard block
 block discarded – undo
3974 4178
 			var getData = "";
3975 4179
 			var debugItems = ', $upcontext['debug_items'], ';';
3976 4180
 
3977
-		if ($is_debug)
3978
-			echo '
4181
+		if ($is_debug) {
4182
+					echo '
3979 4183
 			var upgradeStartTime = ' . $upcontext['started'] . ';';
4184
+		}
3980 4185
 
3981 4186
 		echo '
3982 4187
 			function getNextItem()
@@ -4016,9 +4221,10 @@  discard block
 block discarded – undo
4016 4221
 						document.getElementById("error_block").style.display = "";
4017 4222
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4018 4223
 
4019
-	if ($is_debug)
4020
-		echo '
4224
+	if ($is_debug) {
4225
+			echo '
4021 4226
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4227
+	}
4022 4228
 
4023 4229
 	echo '
4024 4230
 					}
@@ -4039,9 +4245,10 @@  discard block
 block discarded – undo
4039 4245
 						document.getElementById("error_block").style.display = "";
4040 4246
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4041 4247
 
4042
-	if ($is_debug)
4043
-		echo '
4248
+	if ($is_debug) {
4249
+			echo '
4044 4250
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4251
+	}
4045 4252
 
4046 4253
 	echo '
4047 4254
 					}
@@ -4100,8 +4307,8 @@  discard block
 block discarded – undo
4100 4307
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4101 4308
 				{';
4102 4309
 
4103
-		if ($is_debug)
4104
-			echo '
4310
+		if ($is_debug) {
4311
+					echo '
4105 4312
 					document.getElementById(\'debug_section\').style.display = "none";
4106 4313
 
4107 4314
 					var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4119,6 +4326,7 @@  discard block
 block discarded – undo
4119 4326
 						totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4120 4327
 
4121 4328
 					setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4329
+		}
4122 4330
 
4123 4331
 		echo '
4124 4332
 
@@ -4126,9 +4334,10 @@  discard block
 block discarded – undo
4126 4334
 					document.getElementById(\'contbutt\').disabled = 0;
4127 4335
 					document.getElementById(\'database_done\').value = 1;';
4128 4336
 
4129
-		if ($upcontext['file_count'] > 1)
4130
-			echo '
4337
+		if ($upcontext['file_count'] > 1) {
4338
+					echo '
4131 4339
 					document.getElementById(\'info1\').style.display = "none";';
4340
+		}
4132 4341
 
4133 4342
 		echo '
4134 4343
 					document.getElementById(\'info2\').style.display = "none";
@@ -4141,9 +4350,10 @@  discard block
 block discarded – undo
4141 4350
 					lastItem = 0;
4142 4351
 					prevFile = curFile;';
4143 4352
 
4144
-		if ($is_debug)
4145
-			echo '
4353
+		if ($is_debug) {
4354
+					echo '
4146 4355
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4356
+		}
4147 4357
 
4148 4358
 		echo '
4149 4359
 					getNextItem();
@@ -4151,8 +4361,8 @@  discard block
 block discarded – undo
4151 4361
 				}';
4152 4362
 
4153 4363
 		// If debug scroll the screen.
4154
-		if ($is_debug)
4155
-			echo '
4364
+		if ($is_debug) {
4365
+					echo '
4156 4366
 				if (iLastSubStepProgress == -1)
4157 4367
 				{
4158 4368
 					// Give it consistent dots.
@@ -4171,6 +4381,7 @@  discard block
 block discarded – undo
4171 4381
 
4172 4382
 				if (document.getElementById(\'debug_section\').scrollHeight)
4173 4383
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4384
+		}
4174 4385
 
4175 4386
 		echo '
4176 4387
 				// Update the page.
@@ -4231,9 +4442,10 @@  discard block
 block discarded – undo
4231 4442
 			}';
4232 4443
 
4233 4444
 		// Start things off assuming we've not errored.
4234
-		if (empty($upcontext['error_message']))
4235
-			echo '
4445
+		if (empty($upcontext['error_message'])) {
4446
+					echo '
4236 4447
 			getNextItem();';
4448
+		}
4237 4449
 
4238 4450
 		echo '
4239 4451
 		//# sourceURL=dynamicScript-dbch.js 
@@ -4251,18 +4463,21 @@  discard block
 block discarded – undo
4251 4463
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4252 4464
 	<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>';
4253 4465
 
4254
-	if (!empty($upcontext['error_message']))
4255
-		echo '
4466
+	if (!empty($upcontext['error_message'])) {
4467
+			echo '
4256 4468
 	<error>', $upcontext['error_message'], '</error>';
4469
+	}
4257 4470
 
4258
-	if (!empty($upcontext['error_string']))
4259
-		echo '
4471
+	if (!empty($upcontext['error_string'])) {
4472
+			echo '
4260 4473
 	<sql>', $upcontext['error_string'], '</sql>';
4474
+	}
4261 4475
 
4262
-	if ($is_debug)
4263
-		echo '
4476
+	if ($is_debug) {
4477
+			echo '
4264 4478
 	<curtime>', time(), '</curtime>';
4265
-}
4479
+	}
4480
+	}
4266 4481
 
4267 4482
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4268 4483
 function template_convert_utf8()
@@ -4281,18 +4496,20 @@  discard block
 block discarded – undo
4281 4496
 			</div>';
4282 4497
 
4283 4498
 	// Done any tables so far?
4284
-	if (!empty($upcontext['previous_tables']))
4285
-		foreach ($upcontext['previous_tables'] as $table)
4499
+	if (!empty($upcontext['previous_tables'])) {
4500
+			foreach ($upcontext['previous_tables'] as $table)
4286 4501
 			echo '
4287 4502
 			<br>Completed Table: &quot;', $table, '&quot;.';
4503
+	}
4288 4504
 
4289 4505
 	echo '
4290 4506
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4291 4507
 
4292 4508
 	// If we dropped their index, let's let them know
4293
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index'])
4294
-		echo '
4509
+	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) {
4510
+			echo '
4295 4511
 			<br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>';
4512
+	}
4296 4513
 
4297 4514
 	echo '
4298 4515
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>';
@@ -4328,12 +4545,13 @@  discard block
 block discarded – undo
4328 4545
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4329 4546
 
4330 4547
 		// If debug flood the screen.
4331
-		if ($is_debug)
4332
-			echo '
4548
+		if ($is_debug) {
4549
+					echo '
4333 4550
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4334 4551
 
4335 4552
 				if (document.getElementById(\'debug_section\').scrollHeight)
4336 4553
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4554
+		}
4337 4555
 
4338 4556
 		echo '
4339 4557
 				// Get the next update...
@@ -4378,19 +4596,21 @@  discard block
 block discarded – undo
4378 4596
 			</div>';
4379 4597
 
4380 4598
 	// Dont any tables so far?
4381
-	if (!empty($upcontext['previous_tables']))
4382
-		foreach ($upcontext['previous_tables'] as $table)
4599
+	if (!empty($upcontext['previous_tables'])) {
4600
+			foreach ($upcontext['previous_tables'] as $table)
4383 4601
 			echo '
4384 4602
 			<br>Completed Table: &quot;', $table, '&quot;.';
4603
+	}
4385 4604
 
4386 4605
 	echo '
4387 4606
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4388 4607
 			<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>';
4389 4608
 
4390 4609
 	// Try to make sure substep was reset.
4391
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4392
-		echo '
4610
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4611
+			echo '
4393 4612
 			<input type="hidden" name="substep" id="substep" value="0">';
4613
+	}
4394 4614
 
4395 4615
 	// Continue please!
4396 4616
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4423,12 +4643,13 @@  discard block
 block discarded – undo
4423 4643
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4424 4644
 
4425 4645
 		// If debug flood the screen.
4426
-		if ($is_debug)
4427
-			echo '
4646
+		if ($is_debug) {
4647
+					echo '
4428 4648
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4429 4649
 
4430 4650
 				if (document.getElementById(\'debug_section\').scrollHeight)
4431 4651
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4652
+		}
4432 4653
 
4433 4654
 		echo '
4434 4655
 				// Get the next update...
@@ -4464,8 +4685,8 @@  discard block
 block discarded – undo
4464 4685
 	<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>
4465 4686
 	<form action="', $boardurl, '/index.php">';
4466 4687
 
4467
-	if (!empty($upcontext['can_delete_script']))
4468
-		echo '
4688
+	if (!empty($upcontext['can_delete_script'])) {
4689
+			echo '
4469 4690
 			<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>
4470 4691
 			<script>
4471 4692
 				function doTheDelete(theCheck)
@@ -4477,6 +4698,7 @@  discard block
 block discarded – undo
4477 4698
 				}
4478 4699
 			</script>
4479 4700
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4701
+	}
4480 4702
 
4481 4703
 	$active = time() - $upcontext['started'];
4482 4704
 	$hours = floor($active / 3600);
@@ -4486,16 +4708,20 @@  discard block
 block discarded – undo
4486 4708
 	if ($is_debug)
4487 4709
 	{
4488 4710
 		$totalTime = '';
4489
-		if ($hours > 0)
4490
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4491
-		if ($minutes > 0)
4492
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4493
-		if ($seconds > 0)
4494
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4711
+		if ($hours > 0) {
4712
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4713
+		}
4714
+		if ($minutes > 0) {
4715
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4716
+		}
4717
+		if ($seconds > 0) {
4718
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4719
+		}
4495 4720
 	}
4496 4721
 
4497
-	if ($is_debug && !empty($totalTime))
4498
-		echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4722
+	if ($is_debug && !empty($totalTime)) {
4723
+			echo '<br> Upgrade completed in ', $totalTime, '<br><br>';
4724
+	}
4499 4725
 
4500 4726
 	echo '<br>
4501 4727
 			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>
@@ -4522,8 +4748,9 @@  discard block
 block discarded – undo
4522 4748
 
4523 4749
 	$current_substep = $_GET['substep'];
4524 4750
 
4525
-	if (empty($_GET['a']))
4526
-		$_GET['a'] = 0;
4751
+	if (empty($_GET['a'])) {
4752
+			$_GET['a'] = 0;
4753
+	}
4527 4754
 	$step_progress['name'] = 'Converting ips';
4528 4755
 	$step_progress['current'] = $_GET['a'];
4529 4756
 
@@ -4566,16 +4793,19 @@  discard block
 block discarded – undo
4566 4793
 				'empty' => '',
4567 4794
 				'limit' => $limit,
4568 4795
 		));
4569
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4570
-			$arIp[] = $row[$oldCol];
4796
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
4797
+					$arIp[] = $row[$oldCol];
4798
+		}
4571 4799
 		$smcFunc['db_free_result']($request);
4572 4800
 
4573 4801
 		// Special case, null ip could keep us in a loop.
4574
-		if (is_null($arIp[0]))
4575
-			unset($arIp[0]);
4802
+		if (is_null($arIp[0])) {
4803
+					unset($arIp[0]);
4804
+		}
4576 4805
 
4577
-		if (empty($arIp))
4578
-			$is_done = true;
4806
+		if (empty($arIp)) {
4807
+					$is_done = true;
4808
+		}
4579 4809
 
4580 4810
 		$updates = array();
4581 4811
 		$cases = array();
@@ -4584,16 +4814,18 @@  discard block
 block discarded – undo
4584 4814
 		{
4585 4815
 			$arIp[$i] = trim($arIp[$i]);
4586 4816
 
4587
-			if (empty($arIp[$i]))
4588
-				continue;
4817
+			if (empty($arIp[$i])) {
4818
+							continue;
4819
+			}
4589 4820
 
4590 4821
 			$updates['ip' . $i] = $arIp[$i];
4591 4822
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4592 4823
 
4593 4824
 			if ($setSize > 0 && $i % $setSize === 0)
4594 4825
 			{
4595
-				if (count($updates) == 1)
4596
-					continue;
4826
+				if (count($updates) == 1) {
4827
+									continue;
4828
+				}
4597 4829
 
4598 4830
 				$updates['whereSet'] = array_values($updates);
4599 4831
 				$smcFunc['db_query']('', '
@@ -4627,8 +4859,7 @@  discard block
 block discarded – undo
4627 4859
 							'ip' => $ip
4628 4860
 					));
4629 4861
 				}
4630
-			}
4631
-			else
4862
+			} else
4632 4863
 			{
4633 4864
 				$updates['whereSet'] = array_values($updates);
4634 4865
 				$smcFunc['db_query']('', '
@@ -4642,9 +4873,9 @@  discard block
 block discarded – undo
4642 4873
 					$updates
4643 4874
 				);
4644 4875
 			}
4876
+		} else {
4877
+					$is_done = true;
4645 4878
 		}
4646
-		else
4647
-			$is_done = true;
4648 4879
 
4649 4880
 		$_GET['a'] += $limit;
4650 4881
 		$step_progress['current'] = $_GET['a'];
@@ -4670,10 +4901,11 @@  discard block
 block discarded – undo
4670 4901
  
4671 4902
  	$columns = $smcFunc['db_list_columns']($targetTable, true);
4672 4903
 
4673
-	if (isset($columns[$column]))
4674
-		return $columns[$column];
4675
-	else
4676
-		return null;
4677
-}
4904
+	if (isset($columns[$column])) {
4905
+			return $columns[$column];
4906
+	} else {
4907
+			return null;
4908
+	}
4909
+	}
4678 4910
 
4679 4911
 ?>
4680 4912
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Attachments.php 1 patch
Braces   +297 added lines, -224 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
 /**
21 22
  * Check if the current directory is still valid or not.
@@ -28,22 +29,24 @@  discard block
 block discarded – undo
28 29
 	global $boarddir, $modSettings, $context;
29 30
 
30 31
 	// Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found.
31
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin')
32
-		$doit = true;
33
-	elseif (empty($modSettings['automanage_attachments']))
34
-		return;
35
-	elseif (!isset($_FILES))
36
-		return;
37
-	elseif (isset($_FILES['attachment']))
38
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
32
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') {
33
+			$doit = true;
34
+	} elseif (empty($modSettings['automanage_attachments'])) {
35
+			return;
36
+	} elseif (!isset($_FILES)) {
37
+			return;
38
+	} elseif (isset($_FILES['attachment'])) {
39
+			foreach ($_FILES['attachment']['tmp_name'] as $dummy)
39 40
 			if (!empty($dummy))
40 41
 			{
41 42
 				$doit = true;
43
+	}
42 44
 				break;
43 45
 			}
44 46
 
45
-	if (!isset($doit))
46
-		return;
47
+	if (!isset($doit)) {
48
+			return;
49
+	}
47 50
 
48 51
 	$year = date('Y');
49 52
 	$month = date('m');
@@ -54,21 +57,25 @@  discard block
 block discarded – undo
54 57
 
55 58
 	if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments']))
56 59
 	{
57
-			if (!is_array($modSettings['attachment_basedirectories']))
58
-				$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
60
+			if (!is_array($modSettings['attachment_basedirectories'])) {
61
+							$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
62
+			}
59 63
 			$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
64
+	} else {
65
+			$base_dir = 0;
60 66
 	}
61
-	else
62
-		$base_dir = 0;
63 67
 
64 68
 	if ($modSettings['automanage_attachments'] == 1)
65 69
 	{
66
-		if (!isset($modSettings['last_attachments_directory']))
67
-			$modSettings['last_attachments_directory'] = array();
68
-		if (!is_array($modSettings['last_attachments_directory']))
69
-			$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
70
-		if (!isset($modSettings['last_attachments_directory'][$base_dir]))
71
-			$modSettings['last_attachments_directory'][$base_dir] = 0;
70
+		if (!isset($modSettings['last_attachments_directory'])) {
71
+					$modSettings['last_attachments_directory'] = array();
72
+		}
73
+		if (!is_array($modSettings['last_attachments_directory'])) {
74
+					$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
75
+		}
76
+		if (!isset($modSettings['last_attachments_directory'][$base_dir])) {
77
+					$modSettings['last_attachments_directory'][$base_dir] = 0;
78
+		}
72 79
 	}
73 80
 
74 81
 	$basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
@@ -97,12 +104,14 @@  discard block
 block discarded – undo
97 104
 			$updir = '';
98 105
 	}
99 106
 
100
-	if (!is_array($modSettings['attachmentUploadDir']))
101
-		$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
102
-	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir))
103
-		$outputCreation = automanage_attachments_create_directory($updir);
104
-	elseif (in_array($updir, $modSettings['attachmentUploadDir']))
105
-		$outputCreation = true;
107
+	if (!is_array($modSettings['attachmentUploadDir'])) {
108
+			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
109
+	}
110
+	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) {
111
+			$outputCreation = automanage_attachments_create_directory($updir);
112
+	} elseif (in_array($updir, $modSettings['attachmentUploadDir'])) {
113
+			$outputCreation = true;
114
+	}
106 115
 
107 116
 	if ($outputCreation)
108 117
 	{
@@ -139,8 +148,9 @@  discard block
 block discarded – undo
139 148
 		$count = count($tree);
140 149
 
141 150
 		$directory = attachments_init_dir($tree, $count);
142
-		if ($directory === false)
143
-			return false;
151
+		if ($directory === false) {
152
+					return false;
153
+		}
144 154
 	}
145 155
 
146 156
 	$directory .= DIRECTORY_SEPARATOR . array_shift($tree);
@@ -168,8 +178,9 @@  discard block
 block discarded – undo
168 178
 	}
169 179
 
170 180
 	// Everything seems fine...let's create the .htaccess
171
-	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess'))
172
-		secureDirectory($updir, true);
181
+	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) {
182
+			secureDirectory($updir, true);
183
+	}
173 184
 
174 185
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
175 186
 	$updir = rtrim($updir, $sep);
@@ -201,8 +212,9 @@  discard block
 block discarded – undo
201 212
 {
202 213
 	global $modSettings, $boarddir;
203 214
 
204
-	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1))
205
-		return;
215
+	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) {
216
+			return;
217
+	}
206 218
 
207 219
 	$basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir;
208 220
 	// Just to be sure: I don't want directory separators at the end
@@ -214,13 +226,14 @@  discard block
 block discarded – undo
214 226
 	{
215 227
 		$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
216 228
 		$base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0;
229
+	} else {
230
+			$base_dir = 0;
217 231
 	}
218
-	else
219
-		$base_dir = 0;
220 232
 
221 233
 	// Get the last attachment directory for that base directory
222
-	if (empty($modSettings['last_attachments_directory'][$base_dir]))
223
-		$modSettings['last_attachments_directory'][$base_dir] = 0;
234
+	if (empty($modSettings['last_attachments_directory'][$base_dir])) {
235
+			$modSettings['last_attachments_directory'][$base_dir] = 0;
236
+	}
224 237
 	// And increment it.
225 238
 	$modSettings['last_attachments_directory'][$base_dir]++;
226 239
 
@@ -235,10 +248,10 @@  discard block
 block discarded – undo
235 248
 		$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
236 249
 
237 250
 		return true;
251
+	} else {
252
+			return false;
253
+	}
238 254
 	}
239
-	else
240
-		return false;
241
-}
242 255
 
243 256
 /**
244 257
  * Split a path into a list of all directories and subdirectories
@@ -256,12 +269,13 @@  discard block
 block discarded – undo
256 269
 			* in Windows we need to explode for both \ and /
257 270
 			* while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR)
258 271
 	*/
259
-	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
260
-		$tree = preg_split('#[\\\/]#', $directory);
261
-	else
272
+	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
273
+			$tree = preg_split('#[\\\/]#', $directory);
274
+	} else
262 275
 	{
263
-		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR)
264
-			return false;
276
+		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
277
+					return false;
278
+		}
265 279
 
266 280
 		$tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR));
267 281
 	}
@@ -285,10 +299,11 @@  discard block
 block discarded – undo
285 299
 		 //Better be sure that the first part of the path is actually a drive letter...
286 300
 		 //...even if, I should check this in the admin page...isn't it?
287 301
 		 //...NHAAA Let's leave space for users' complains! :P
288
-		if (preg_match('/^[a-z]:$/i', $tree[0]))
289
-			$directory = array_shift($tree);
290
-		else
291
-			return false;
302
+		if (preg_match('/^[a-z]:$/i', $tree[0])) {
303
+					$directory = array_shift($tree);
304
+		} else {
305
+					return false;
306
+		}
292 307
 
293 308
 		$count--;
294 309
 	}
@@ -303,18 +318,20 @@  discard block
 block discarded – undo
303 318
 	global $context, $modSettings, $smcFunc, $txt, $user_info;
304 319
 
305 320
 	// Make sure we're uploading to the right place.
306
-	if (!empty($modSettings['automanage_attachments']))
307
-		automanage_attachments_check_directory();
321
+	if (!empty($modSettings['automanage_attachments'])) {
322
+			automanage_attachments_check_directory();
323
+	}
308 324
 
309
-	if (!is_array($modSettings['attachmentUploadDir']))
310
-		$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
325
+	if (!is_array($modSettings['attachmentUploadDir'])) {
326
+			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
327
+	}
311 328
 
312 329
 	$context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
313 330
 
314 331
 	// Is the attachments folder actualy there?
315
-	if (!empty($context['dir_creation_error']))
316
-		$initial_error = $context['dir_creation_error'];
317
-	elseif (!is_dir($context['attach_dir']))
332
+	if (!empty($context['dir_creation_error'])) {
333
+			$initial_error = $context['dir_creation_error'];
334
+	} elseif (!is_dir($context['attach_dir']))
318 335
 	{
319 336
 		$initial_error = 'attach_folder_warning';
320 337
 		log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical');
@@ -337,12 +354,12 @@  discard block
 block discarded – undo
337 354
 			);
338 355
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
339 356
 			$smcFunc['db_free_result']($request);
340
-		}
341
-		else
342
-			$context['attachments'] = array(
357
+		} else {
358
+					$context['attachments'] = array(
343 359
 				'quantity' => 0,
344 360
 				'total_size' => 0,
345 361
 			);
362
+		}
346 363
 	}
347 364
 
348 365
 	// Hmm. There are still files in session.
@@ -352,39 +369,44 @@  discard block
 block discarded – undo
352 369
 		// Let's try to keep them. But...
353 370
 		$ignore_temp = true;
354 371
 		// If new files are being added. We can't ignore those
355
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
356
-			if (!empty($dummy))
372
+		foreach ($_FILES['attachment']['tmp_name'] as $dummy) {
373
+					if (!empty($dummy))
357 374
 			{
358 375
 				$ignore_temp = false;
376
+		}
359 377
 				break;
360 378
 			}
361 379
 
362 380
 		// Need to make space for the new files. So, bye bye.
363 381
 		if (!$ignore_temp)
364 382
 		{
365
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
366
-				if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
383
+			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
384
+							if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
367 385
 					unlink($attachment['tmp_name']);
386
+			}
368 387
 
369 388
 			$context['we_are_history'] = $txt['error_temp_attachments_flushed'];
370 389
 			$_SESSION['temp_attachments'] = array();
371 390
 		}
372 391
 	}
373 392
 
374
-	if (!isset($_FILES['attachment']['name']))
375
-		$_FILES['attachment']['tmp_name'] = array();
393
+	if (!isset($_FILES['attachment']['name'])) {
394
+			$_FILES['attachment']['tmp_name'] = array();
395
+	}
376 396
 
377
-	if (!isset($_SESSION['temp_attachments']))
378
-		$_SESSION['temp_attachments'] = array();
397
+	if (!isset($_SESSION['temp_attachments'])) {
398
+			$_SESSION['temp_attachments'] = array();
399
+	}
379 400
 
380 401
 	// Remember where we are at. If it's anywhere at all.
381
-	if (!$ignore_temp)
382
-		$_SESSION['temp_attachments']['post'] = array(
402
+	if (!$ignore_temp) {
403
+			$_SESSION['temp_attachments']['post'] = array(
383 404
 			'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0,
384 405
 			'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0,
385 406
 			'topic' => !empty($topic) ? $topic : 0,
386 407
 			'board' => !empty($board) ? $board : 0,
387 408
 		);
409
+	}
388 410
 
389 411
 	// If we have an initial error, lets just display it.
390 412
 	if (!empty($initial_error))
@@ -392,9 +414,10 @@  discard block
 block discarded – undo
392 414
 		$_SESSION['temp_attachments']['initial_error'] = $initial_error;
393 415
 
394 416
 		// And delete the files 'cos they ain't going nowhere.
395
-		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
396
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
417
+		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
418
+					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
397 419
 				unlink($_FILES['attachment']['tmp_name'][$n]);
420
+		}
398 421
 
399 422
 		$_FILES['attachment']['tmp_name'] = array();
400 423
 	}
@@ -402,21 +425,24 @@  discard block
 block discarded – undo
402 425
 	// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
403 426
 	foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
404 427
 	{
405
-		if ($_FILES['attachment']['name'][$n] == '')
406
-			continue;
428
+		if ($_FILES['attachment']['name'][$n] == '') {
429
+					continue;
430
+		}
407 431
 
408 432
 		// First, let's first check for PHP upload errors.
409 433
 		$errors = array();
410 434
 		if (!empty($_FILES['attachment']['error'][$n]))
411 435
 		{
412
-			if ($_FILES['attachment']['error'][$n] == 2)
413
-				$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
414
-			elseif ($_FILES['attachment']['error'][$n] == 6)
415
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
416
-			else
417
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
418
-			if (empty($errors))
419
-				$errors[] = 'attach_php_error';
436
+			if ($_FILES['attachment']['error'][$n] == 2) {
437
+							$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
438
+			} elseif ($_FILES['attachment']['error'][$n] == 6) {
439
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
440
+			} else {
441
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
442
+			}
443
+			if (empty($errors)) {
444
+							$errors[] = 'attach_php_error';
445
+			}
420 446
 		}
421 447
 
422 448
 		// Try to move and rename the file before doing any more checks on it.
@@ -426,8 +452,9 @@  discard block
 block discarded – undo
426 452
 		{
427 453
 			// The reported MIME type of the attachment might not be reliable.
428 454
 			// Fortunately, PHP 5.3+ lets us easily verify the real MIME type.
429
-			if (function_exists('mime_content_type'))
430
-				$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
455
+			if (function_exists('mime_content_type')) {
456
+							$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
457
+			}
431 458
 
432 459
 			$_SESSION['temp_attachments'][$attachID] = array(
433 460
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -439,16 +466,16 @@  discard block
 block discarded – undo
439 466
 			);
440 467
 
441 468
 			// Move the file to the attachments folder with a temp name for now.
442
-			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
443
-				smf_chmod($destName, 0644);
444
-			else
469
+			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
470
+							smf_chmod($destName, 0644);
471
+			} else
445 472
 			{
446 473
 				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
447
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
448
-					unlink($_FILES['attachment']['tmp_name'][$n]);
474
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
475
+									unlink($_FILES['attachment']['tmp_name'][$n]);
476
+				}
449 477
 			}
450
-		}
451
-		else
478
+		} else
452 479
 		{
453 480
 			$_SESSION['temp_attachments'][$attachID] = array(
454 481
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -456,12 +483,14 @@  discard block
 block discarded – undo
456 483
 				'errors' => $errors,
457 484
 			);
458 485
 
459
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
460
-				unlink($_FILES['attachment']['tmp_name'][$n]);
486
+			if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
487
+							unlink($_FILES['attachment']['tmp_name'][$n]);
488
+			}
461 489
 		}
462 490
 		// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
463
-		if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
464
-			attachmentChecks($attachID);
491
+		if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
492
+					attachmentChecks($attachID);
493
+		}
465 494
 	}
466 495
 	// Mod authors, finally a hook to hang an alternate attachment upload system upon
467 496
 	// Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand())
@@ -488,21 +517,20 @@  discard block
 block discarded – undo
488 517
 	global $modSettings, $context, $sourcedir, $smcFunc;
489 518
 
490 519
 	// No data or missing data .... Not necessarily needed, but in case a mod author missed something.
491
-	if (empty($_SESSION['temp_attachments'][$attachID]))
492
-		$error = '$_SESSION[\'temp_attachments\'][$attachID]';
493
-
494
-	elseif (empty($attachID))
495
-		$error = '$attachID';
496
-
497
-	elseif (empty($context['attachments']))
498
-		$error = '$context[\'attachments\']';
499
-
500
-	elseif (empty($context['attach_dir']))
501
-		$error = '$context[\'attach_dir\']';
520
+	if (empty($_SESSION['temp_attachments'][$attachID])) {
521
+			$error = '$_SESSION[\'temp_attachments\'][$attachID]';
522
+	} elseif (empty($attachID)) {
523
+			$error = '$attachID';
524
+	} elseif (empty($context['attachments'])) {
525
+			$error = '$context[\'attachments\']';
526
+	} elseif (empty($context['attach_dir'])) {
527
+			$error = '$context[\'attach_dir\']';
528
+	}
502 529
 
503 530
 	// Let's get their attention.
504
-	if (!empty($error))
505
-		fatal_lang_error('attach_check_nag', 'debug', array($error));
531
+	if (!empty($error)) {
532
+			fatal_lang_error('attach_check_nag', 'debug', array($error));
533
+	}
506 534
 
507 535
 	// Just in case this slipped by the first checks, we stop it here and now
508 536
 	if ($_SESSION['temp_attachments'][$attachID]['size'] == 0)
@@ -531,8 +559,9 @@  discard block
 block discarded – undo
531 559
 			$size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']);
532 560
 			if (!(empty($size)) && ($size[2] != $old_format))
533 561
 			{
534
-				if (isset($context['validImageTypes'][$size[2]]))
535
-					$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]];
562
+				if (isset($context['validImageTypes'][$size[2]])) {
563
+									$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]];
564
+				}
536 565
 			}
537 566
 		}
538 567
 	}
@@ -586,42 +615,48 @@  discard block
 block discarded – undo
586 615
 				// Or, let the user know that it ain't gonna happen.
587 616
 				else
588 617
 				{
589
-					if (isset($context['dir_creation_error']))
590
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
591
-					else
592
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
618
+					if (isset($context['dir_creation_error'])) {
619
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
620
+					} else {
621
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
622
+					}
593 623
 				}
624
+			} else {
625
+							$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
594 626
 			}
595
-			else
596
-				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
597 627
 		}
598 628
 	}
599 629
 
600 630
 	// Is the file too big?
601 631
 	$context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size'];
602
-	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024)
603
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
632
+	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) {
633
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
634
+	}
604 635
 
605 636
 	// Check the total upload size for this post...
606
-	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024)
607
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
637
+	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) {
638
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
639
+	}
608 640
 
609 641
 	// Have we reached the maximum number of files we are allowed?
610 642
 	$context['attachments']['quantity']++;
611 643
 
612 644
 	// Set a max limit if none exists
613
-	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50)
614
-		$modSettings['attachmentNumPerPostLimit'] = 50;
645
+	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) {
646
+			$modSettings['attachmentNumPerPostLimit'] = 50;
647
+	}
615 648
 
616
-	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit'])
617
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
649
+	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) {
650
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
651
+	}
618 652
 
619 653
 	// File extension check
620 654
 	if (!empty($modSettings['attachmentCheckExtensions']))
621 655
 	{
622 656
 		$allowed = explode(',', strtolower($modSettings['attachmentExtensions']));
623
-		foreach ($allowed as $k => $dummy)
624
-			$allowed[$k] = trim($dummy);
657
+		foreach ($allowed as $k => $dummy) {
658
+					$allowed[$k] = trim($dummy);
659
+		}
625 660
 
626 661
 		if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed))
627 662
 		{
@@ -633,10 +668,12 @@  discard block
 block discarded – undo
633 668
 	// Undo the math if there's an error
634 669
 	if (!empty($_SESSION['temp_attachments'][$attachID]['errors']))
635 670
 	{
636
-		if (isset($context['dir_size']))
637
-			$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
638
-		if (isset($context['dir_files']))
639
-			$context['dir_files']--;
671
+		if (isset($context['dir_size'])) {
672
+					$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
673
+		}
674
+		if (isset($context['dir_files'])) {
675
+					$context['dir_files']--;
676
+		}
640 677
 		$context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
641 678
 		$context['attachments']['quantity']--;
642 679
 		return false;
@@ -668,12 +705,14 @@  discard block
 block discarded – undo
668 705
 	if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width'])
669 706
 	{
670 707
 		// Got a proper mime type?
671
-		if (!empty($size['mime']))
672
-			$attachmentOptions['mime_type'] = $size['mime'];
708
+		if (!empty($size['mime'])) {
709
+					$attachmentOptions['mime_type'] = $size['mime'];
710
+		}
673 711
 
674 712
 		// Otherwise a valid one?
675
-		elseif (isset($context['validImageTypes'][$size[2]]))
676
-			$attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]];
713
+		elseif (isset($context['validImageTypes'][$size[2]])) {
714
+					$attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]];
715
+		}
677 716
 	}
678 717
 
679 718
 	// It is possible we might have a MIME type that isn't actually an image but still have a size.
@@ -685,15 +724,17 @@  discard block
 block discarded – undo
685 724
 	}
686 725
 
687 726
 	// Get the hash if no hash has been given yet.
688
-	if (empty($attachmentOptions['file_hash']))
689
-		$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
727
+	if (empty($attachmentOptions['file_hash'])) {
728
+			$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
729
+	}
690 730
 
691 731
 	// Assuming no-one set the extension let's take a look at it.
692 732
 	if (empty($attachmentOptions['fileext']))
693 733
 	{
694 734
 		$attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : '');
695
-		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name'])
696
-			$attachmentOptions['fileext'] = '';
735
+		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) {
736
+					$attachmentOptions['fileext'] = '';
737
+		}
697 738
 	}
698 739
 
699 740
 	// Last chance to change stuff!
@@ -702,8 +743,9 @@  discard block
 block discarded – undo
702 743
 	// Make sure the folder is valid...
703 744
 	$tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : smf_json_decode($modSettings['attachmentUploadDir'], true);
704 745
 	$folders = array_keys($tmp);
705
-	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders))
706
-		$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
746
+	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) {
747
+			$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
748
+	}
707 749
 
708 750
 	$attachmentOptions['id'] = $smcFunc['db_insert']('',
709 751
 		'{db_prefix}attachments',
@@ -734,8 +776,8 @@  discard block
 block discarded – undo
734 776
 	rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']);
735 777
 
736 778
 	// If it's not approved then add to the approval queue.
737
-	if (!$attachmentOptions['approved'])
738
-		$smcFunc['db_insert']('',
779
+	if (!$attachmentOptions['approved']) {
780
+			$smcFunc['db_insert']('',
739 781
 			'{db_prefix}approval_queue',
740 782
 			array(
741 783
 				'id_attach' => 'int', 'id_msg' => 'int',
@@ -745,9 +787,11 @@  discard block
 block discarded – undo
745 787
 			),
746 788
 			array()
747 789
 		);
790
+	}
748 791
 
749
-	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height'])))
750
-		return true;
792
+	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) {
793
+			return true;
794
+	}
751 795
 
752 796
 	// Like thumbnails, do we?
753 797
 	if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight']))
@@ -758,13 +802,15 @@  discard block
 block discarded – undo
758 802
 			$size = @getimagesize($attachmentOptions['destination'] . '_thumb');
759 803
 			list ($thumb_width, $thumb_height) = $size;
760 804
 
761
-			if (!empty($size['mime']))
762
-				$thumb_mime = $size['mime'];
763
-			elseif (isset($context['validImageTypes'][$size[2]]))
764
-				$thumb_mime = 'image/' . $context['validImageTypes'][$size[2]];
805
+			if (!empty($size['mime'])) {
806
+							$thumb_mime = $size['mime'];
807
+			} elseif (isset($context['validImageTypes'][$size[2]])) {
808
+							$thumb_mime = 'image/' . $context['validImageTypes'][$size[2]];
809
+			}
765 810
 			// Lord only knows how this happened...
766
-			else
767
-				$thumb_mime = '';
811
+			else {
812
+							$thumb_mime = '';
813
+			}
768 814
 
769 815
 			$thumb_filename = $attachmentOptions['name'] . '_thumb';
770 816
 			$thumb_size = filesize($attachmentOptions['destination'] . '_thumb');
@@ -844,15 +890,17 @@  discard block
 block discarded – undo
844 890
 	global $smcFunc;
845 891
 
846 892
 	// Oh, come on!
847
-	if (empty($attachIDs) || empty($msgID))
848
-		return false;
893
+	if (empty($attachIDs) || empty($msgID)) {
894
+			return false;
895
+	}
849 896
 
850 897
 	// "I see what is right and approve, but I do what is wrong."
851 898
 	call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID));
852 899
 
853 900
 	// One last check
854
-	if (empty($attachIDs))
855
-		return false;
901
+	if (empty($attachIDs)) {
902
+			return false;
903
+	}
856 904
 
857 905
 	// Perform.
858 906
 	$smcFunc['db_query']('', '
@@ -882,8 +930,9 @@  discard block
 block discarded – undo
882 930
 	$externalParse = false;
883 931
 
884 932
 	// Meh...
885
-	if (empty($attachID))
886
-		return 'attachments_no_data_loaded';
933
+	if (empty($attachID)) {
934
+			return 'attachments_no_data_loaded';
935
+	}
887 936
 
888 937
 	// Make it easy.
889 938
 	$msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0;
@@ -892,20 +941,23 @@  discard block
 block discarded – undo
892 941
 	$externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID));
893 942
 
894 943
 	// "I am innocent of the blood of this just person: see ye to it."
895
-	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse)))
896
-		return $externalParse;
944
+	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) {
945
+			return $externalParse;
946
+	}
897 947
 
898 948
 	//Are attachments enable?
899
-	if (empty($modSettings['attachmentEnable']))
900
-		return 'attachments_not_enable';
949
+	if (empty($modSettings['attachmentEnable'])) {
950
+			return 'attachments_not_enable';
951
+	}
901 952
 
902 953
 	// Previewing much? no msg ID has been set yet.
903 954
 	if (!empty($context['preview_message']))
904 955
 	{
905 956
 		$allAttachments = getAttachsByMsg(0);
906 957
 
907
-		if (empty($allAttachments[0][$attachID]))
908
-			return 'attachments_no_data_loaded';
958
+		if (empty($allAttachments[0][$attachID])) {
959
+					return 'attachments_no_data_loaded';
960
+		}
909 961
 
910 962
 		$attachLoaded = loadAttachmentContext(0, $allAttachments);
911 963
 
@@ -917,57 +969,66 @@  discard block
 block discarded – undo
917 969
 		$attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>';
918 970
 
919 971
 		// Fix the thumbnail too, if the image has one.
920
-		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb']))
921
-			$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
972
+		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) {
973
+					$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
974
+		}
922 975
 
923 976
 		return $attachContext;
924 977
 	}
925 978
 
926 979
 	// There is always the chance someone else has already done our dirty work...
927 980
 	// If so, all pertinent checks were already done. Hopefully...
928
-	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID]))
929
-		return $context['current_attachments'][$attachID];
981
+	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) {
982
+			return $context['current_attachments'][$attachID];
983
+	}
930 984
 
931 985
 	// If we are lucky enough to be in $board's scope then check it!
932
-	if (!empty($board) && !allowedTo('view_attachments', $board))
933
-		return 'attachments_not_allowed_to_see';
986
+	if (!empty($board) && !allowedTo('view_attachments', $board)) {
987
+			return 'attachments_not_allowed_to_see';
988
+	}
934 989
 
935 990
 	// Get the message info associated with this particular attach ID.
936 991
 	$attachInfo = getAttachMsgInfo($attachID);
937 992
 
938 993
 	// There is always the chance this attachment no longer exists or isn't associated to a message anymore...
939
-	if (empty($attachInfo) || empty($attachInfo['msg']))
940
-		return 'attachments_no_msg_associated';
994
+	if (empty($attachInfo) || empty($attachInfo['msg'])) {
995
+			return 'attachments_no_msg_associated';
996
+	}
941 997
 
942 998
 	// Hold it! got the info now check if you can see this attachment.
943
-	if (!allowedTo('view_attachments', $attachInfo['board']))
944
-		return 'attachments_not_allowed_to_see';
999
+	if (!allowedTo('view_attachments', $attachInfo['board'])) {
1000
+			return 'attachments_not_allowed_to_see';
1001
+	}
945 1002
 
946 1003
 	$allAttachments = getAttachsByMsg($attachInfo['msg']);
947 1004
 	$attachContext = $allAttachments[$attachInfo['msg']][$attachID];
948 1005
 
949 1006
 	// No point in keep going further.
950
-	if (!allowedTo('view_attachments', $attachContext['board']))
951
-		return 'attachments_not_allowed_to_see';
1007
+	if (!allowedTo('view_attachments', $attachContext['board'])) {
1008
+			return 'attachments_not_allowed_to_see';
1009
+	}
952 1010
 
953 1011
 	// Load this particular attach's context.
954
-	if (!empty($attachContext))
955
-		$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1012
+	if (!empty($attachContext)) {
1013
+			$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1014
+	}
956 1015
 
957 1016
 	// One last check, you know, gotta be paranoid...
958
-	else
959
-		return 'attachments_no_data_loaded';
1017
+	else {
1018
+			return 'attachments_no_data_loaded';
1019
+	}
960 1020
 
961 1021
 	// This is the last "if" I promise!
962
-	if (empty($attachLoaded))
963
-		return 'attachments_no_data_loaded';
964
-
965
-	else
966
-		$attachContext = $attachLoaded[$attachID];
1022
+	if (empty($attachLoaded)) {
1023
+			return 'attachments_no_data_loaded';
1024
+	} else {
1025
+			$attachContext = $attachLoaded[$attachID];
1026
+	}
967 1027
 
968 1028
 	// You may or may not want to show this under the post.
969
-	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID]))
970
-		$context['show_attach_under_post'][$attachID] = $attachID;
1029
+	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) {
1030
+			$context['show_attach_under_post'][$attachID] = $attachID;
1031
+	}
971 1032
 
972 1033
 	// Last minute changes?
973 1034
 	call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext));
@@ -987,8 +1048,9 @@  discard block
 block discarded – undo
987 1048
 {
988 1049
 	global $smcFunc, $modSettings;
989 1050
 
990
-	if (empty($attachIDs))
991
-		return array();
1051
+	if (empty($attachIDs)) {
1052
+			return array();
1053
+	}
992 1054
 
993 1055
 	$return = array();
994 1056
 
@@ -1004,11 +1066,12 @@  discard block
 block discarded – undo
1004 1066
 		)
1005 1067
 	);
1006 1068
 
1007
-	if ($smcFunc['db_num_rows']($request) != 1)
1008
-		return array();
1069
+	if ($smcFunc['db_num_rows']($request) != 1) {
1070
+			return array();
1071
+	}
1009 1072
 
1010
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1011
-		$return[$row['id_attach']] = array(
1073
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1074
+			$return[$row['id_attach']] = array(
1012 1075
 			'name' => $smcFunc['htmlspecialchars']($row['filename']),
1013 1076
 			'size' => $row['size'],
1014 1077
 			'attachID' => $row['id_attach'],
@@ -1017,6 +1080,7 @@  discard block
 block discarded – undo
1017 1080
 			'mime_type' => $row['mime_type'],
1018 1081
 			'thumb' => $row['id_thumb'],
1019 1082
 		);
1083
+	}
1020 1084
 	$smcFunc['db_free_result']($request);
1021 1085
 
1022 1086
 	return $return;
@@ -1033,8 +1097,9 @@  discard block
 block discarded – undo
1033 1097
 {
1034 1098
 	global $smcFunc;
1035 1099
 
1036
-	if (empty($attachID))
1037
-		return array();
1100
+	if (empty($attachID)) {
1101
+			return array();
1102
+	}
1038 1103
 
1039 1104
 	$request = $smcFunc['db_query']('', '
1040 1105
 		SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board
@@ -1047,8 +1112,9 @@  discard block
 block discarded – undo
1047 1112
 		)
1048 1113
 	);
1049 1114
 
1050
-	if ($smcFunc['db_num_rows']($request) != 1)
1051
-		return array();
1115
+	if ($smcFunc['db_num_rows']($request) != 1) {
1116
+			return array();
1117
+	}
1052 1118
 
1053 1119
 	$row = $smcFunc['db_fetch_assoc']($request);
1054 1120
 	$smcFunc['db_free_result']($request);
@@ -1089,8 +1155,9 @@  discard block
 block discarded – undo
1089 1155
 		$temp = array();
1090 1156
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1091 1157
 		{
1092
-			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1093
-				continue;
1158
+			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1159
+							continue;
1160
+			}
1094 1161
 
1095 1162
 			$temp[$row['id_attach']] = $row;
1096 1163
 		}
@@ -1119,8 +1186,9 @@  discard block
 block discarded – undo
1119 1186
 {
1120 1187
 	global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc;
1121 1188
 
1122
-	if (empty($attachments) || empty($attachments[$id_msg]))
1123
-		return array();
1189
+	if (empty($attachments) || empty($attachments[$id_msg])) {
1190
+			return array();
1191
+	}
1124 1192
 
1125 1193
 	// Set up the attachment info - based on code by Meriadoc.
1126 1194
 	$attachmentData = array();
@@ -1144,11 +1212,13 @@  discard block
 block discarded – undo
1144 1212
 			);
1145 1213
 
1146 1214
 			// If something is unapproved we'll note it so we can sort them.
1147
-			if (!$attachment['approved'])
1148
-				$have_unapproved = true;
1215
+			if (!$attachment['approved']) {
1216
+							$have_unapproved = true;
1217
+			}
1149 1218
 
1150
-			if (!$attachmentData[$i]['is_image'])
1151
-				continue;
1219
+			if (!$attachmentData[$i]['is_image']) {
1220
+							continue;
1221
+			}
1152 1222
 
1153 1223
 			$attachmentData[$i]['real_width'] = $attachment['width'];
1154 1224
 			$attachmentData[$i]['width'] = $attachment['width'];
@@ -1169,12 +1239,12 @@  discard block
 block discarded – undo
1169 1239
 						// So what folder are we putting this image in?
1170 1240
 						if (!empty($modSettings['currentAttachmentUploadDir']))
1171 1241
 						{
1172
-							if (!is_array($modSettings['attachmentUploadDir']))
1173
-								$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
1242
+							if (!is_array($modSettings['attachmentUploadDir'])) {
1243
+															$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
1244
+							}
1174 1245
 							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
1175 1246
 							$id_folder_thumb = $modSettings['currentAttachmentUploadDir'];
1176
-						}
1177
-						else
1247
+						} else
1178 1248
 						{
1179 1249
 							$path = $modSettings['attachmentUploadDir'];
1180 1250
 							$id_folder_thumb = 1;
@@ -1189,10 +1259,11 @@  discard block
 block discarded – undo
1189 1259
 						$thumb_ext = isset($context['validImageTypes'][$size[2]]) ? $context['validImageTypes'][$size[2]] : '';
1190 1260
 
1191 1261
 						// Figure out the mime type.
1192
-						if (!empty($size['mime']))
1193
-							$thumb_mime = $size['mime'];
1194
-						else
1195
-							$thumb_mime = 'image/' . $thumb_ext;
1262
+						if (!empty($size['mime'])) {
1263
+													$thumb_mime = $size['mime'];
1264
+						} else {
1265
+													$thumb_mime = 'image/' . $thumb_ext;
1266
+						}
1196 1267
 
1197 1268
 						$thumb_filename = $attachment['filename'] . '_thumb';
1198 1269
 						$thumb_hash = getAttachmentFilename($thumb_filename, false, null, true);
@@ -1239,11 +1310,12 @@  discard block
 block discarded – undo
1239 1310
 				}
1240 1311
 			}
1241 1312
 
1242
-			if (!empty($attachment['id_thumb']))
1243
-				$attachmentData[$i]['thumbnail'] = array(
1313
+			if (!empty($attachment['id_thumb'])) {
1314
+							$attachmentData[$i]['thumbnail'] = array(
1244 1315
 					'id' => $attachment['id_thumb'],
1245 1316
 					'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image',
1246 1317
 				);
1318
+			}
1247 1319
 			$attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']);
1248 1320
 
1249 1321
 			// If thumbnails are disabled, check the maximum size of the image.
@@ -1253,30 +1325,31 @@  discard block
 block discarded – undo
1253 1325
 				{
1254 1326
 					$attachmentData[$i]['width'] = $modSettings['max_image_width'];
1255 1327
 					$attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']);
1256
-				}
1257
-				elseif (!empty($modSettings['max_image_width']))
1328
+				} elseif (!empty($modSettings['max_image_width']))
1258 1329
 				{
1259 1330
 					$attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']);
1260 1331
 					$attachmentData[$i]['height'] = $modSettings['max_image_height'];
1261 1332
 				}
1262
-			}
1263
-			elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1333
+			} elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1264 1334
 			{
1265 1335
 				// If the image is too large to show inline, make it a popup.
1266
-				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height'])))
1267
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1268
-				else
1269
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1336
+				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) {
1337
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1338
+				} else {
1339
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1340
+				}
1270 1341
 			}
1271 1342
 
1272
-			if (!$attachmentData[$i]['thumbnail']['has_thumb'])
1273
-				$attachmentData[$i]['downloads']++;
1343
+			if (!$attachmentData[$i]['thumbnail']['has_thumb']) {
1344
+							$attachmentData[$i]['downloads']++;
1345
+			}
1274 1346
 		}
1275 1347
 	}
1276 1348
 
1277 1349
 	// Do we need to instigate a sort?
1278
-	if ($have_unapproved)
1279
-		usort($attachmentData, 'approved_attach_sort');
1350
+	if ($have_unapproved) {
1351
+			usort($attachmentData, 'approved_attach_sort');
1352
+	}
1280 1353
 
1281 1354
 	return $attachmentData;
1282 1355
 }
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.
Themes/default/index.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
 			//In maintenance mode, only login is allowed and don't show OverlayDiv
230 230
 			echo '
231 231
 			<ul class="floatleft welcome">
232
-				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
232
+				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl . '?action=login', 'return true;'), '</li>
233 233
 			</ul>';
234 234
 
235 235
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
Please login to merge, or discard this patch.
Braces   +89 added lines, -61 removed lines patch added patch discarded remove patch
@@ -72,9 +72,10 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Allow css/js files to be disable for this specific theme.
74 74
 	// Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference.
75
-	if (!isset($settings['disable_files']))
76
-		$settings['disable_files'] = array();
77
-}
75
+	if (!isset($settings['disable_files'])) {
76
+			$settings['disable_files'] = array();
77
+	}
78
+	}
78 79
 
79 80
 /**
80 81
  * The main sub template above the content.
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
 		echo '
112 113
 	<meta';
113 114
 
114
-		foreach ($meta_tag as $meta_key => $meta_value)
115
-			echo ' ', $meta_key, '="', $meta_value, '"';
115
+		foreach ($meta_tag as $meta_key => $meta_value) {
116
+					echo ' ', $meta_key, '="', $meta_value, '"';
117
+		}
116 118
 
117 119
 		echo '>';
118 120
 	}
@@ -123,14 +125,16 @@  discard block
 block discarded – undo
123 125
 	<meta name="theme-color" content="#557EA0">';
124 126
 
125 127
 	// Please don't index these Mr Robot.
126
-	if (!empty($context['robot_no_index']))
127
-		echo '
128
+	if (!empty($context['robot_no_index'])) {
129
+			echo '
128 130
 	<meta name="robots" content="noindex">';
131
+	}
129 132
 
130 133
 	// Present a canonical url for search engines to prevent duplicate content in their indices.
131
-	if (!empty($context['canonical_url']))
132
-		echo '
134
+	if (!empty($context['canonical_url'])) {
135
+			echo '
133 136
 	<link rel="canonical" href="', $context['canonical_url'], '">';
137
+	}
134 138
 
135 139
 	// Show all the relative links, such as help, search, contents, and the like.
136 140
 	echo '
@@ -139,10 +143,11 @@  discard block
 block discarded – undo
139 143
 	<link rel="search" href="' . $scripturl . '?action=search">' : '');
140 144
 
141 145
 	// If RSS feeds are enabled, advertise the presence of one.
142
-	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
143
-		echo '
146
+	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) {
147
+			echo '
144 148
 	<link rel="alternate feed" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">
145 149
 	<link rel="alternate feed" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">';
150
+	}
146 151
 
147 152
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
148 153
 	if (!empty($context['links']['next']))
@@ -158,9 +163,10 @@  discard block
 block discarded – undo
158 163
 	}
159 164
 
160 165
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
161
-	if (!empty($context['current_board']))
162
-		echo '
166
+	if (!empty($context['current_board'])) {
167
+			echo '
163 168
 	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
169
+	}
164 170
 
165 171
 	// Output any remaining HTML headers. (from mods, maybe?)
166 172
 	echo $context['html_headers'];
@@ -191,8 +197,9 @@  discard block
 block discarded – undo
191 197
 		<ul class="floatleft" id="top_info">
192 198
 			<li>
193 199
 				<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
194
-					if (!empty($context['user']['avatar']))
195
-						echo $context['user']['avatar']['image'];
200
+					if (!empty($context['user']['avatar'])) {
201
+											echo $context['user']['avatar']['image'];
202
+					}
196 203
 					echo $context['user']['name'], '</a>
197 204
 				<div id="profile_menu" class="top_menu"></div>
198 205
 			</li>';
@@ -220,17 +227,18 @@  discard block
 block discarded – undo
220 227
 	}
221 228
 	// Otherwise they're a guest. Ask them to either register or login.
222 229
 	else
223
-		if (empty($maintenance))
224
-			echo '
230
+		if (empty($maintenance)) {
231
+					echo '
225 232
 			<ul class="floatleft welcome">
226 233
 				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li>
227 234
 			</ul>';
228
-		else
229
-			//In maintenance mode, only login is allowed and don't show OverlayDiv
235
+		} else {
236
+					//In maintenance mode, only login is allowed and don't show OverlayDiv
230 237
 			echo '
231 238
 			<ul class="floatleft welcome">
232 239
 				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
233 240
 			</ul>';
241
+		}
234 242
 
235 243
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
236 244
 	{
@@ -238,9 +246,10 @@  discard block
 block discarded – undo
238 246
 		<form id="languages_form" method="get" class="floatright">
239 247
 			<select id="language_select" name="language" onchange="this.form.submit()">';
240 248
 
241
-		foreach ($context['languages'] as $language)
242
-			echo '
249
+		foreach ($context['languages'] as $language) {
250
+					echo '
243 251
 				<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
252
+		}
244 253
 
245 254
 		echo '
246 255
 			</select>
@@ -264,31 +273,36 @@  discard block
 block discarded – undo
264 273
 				<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
265 274
 
266 275
 		// Can't limit it to a specific topic if we are not in one
267
-		if (!empty($context['current_topic']))
268
-			echo '
276
+		if (!empty($context['current_topic'])) {
277
+					echo '
269 278
 				<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
279
+		}
270 280
 
271 281
 		// Can't limit it to a specific board if we are not in one
272
-		if (!empty($context['current_board']))
273
-			echo '
282
+		if (!empty($context['current_board'])) {
283
+					echo '
274 284
 				<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>';
285
+		}
275 286
 
276 287
 		// Can't search for members if we can't see the memberlist
277
-		if (!empty($context['allow_memberlist']))
278
-			echo '
288
+		if (!empty($context['allow_memberlist'])) {
289
+					echo '
279 290
 				<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
291
+		}
280 292
 
281 293
 		echo '
282 294
 			</select>';
283 295
 
284 296
 		// Search within current topic?
285
-		if (!empty($context['current_topic']))
286
-			echo '
297
+		if (!empty($context['current_topic'])) {
298
+					echo '
287 299
 			<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
300
+		}
288 301
 		// If we're on a certain board, limit it to this board ;).
289
-		elseif (!empty($context['current_board']))
290
-			echo '
302
+		elseif (!empty($context['current_board'])) {
303
+					echo '
291 304
 			<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
305
+		}
292 306
 
293 307
 		echo '
294 308
 			<input type="submit" name="search2" value="', $txt['search'], '" class="button_submit">
@@ -318,12 +332,13 @@  discard block
 block discarded – undo
318 332
 						', $context['current_time'], '
319 333
 					</div>';
320 334
 	// Show a random news item? (or you could pick one from news_lines...)
321
-	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
322
-		echo '
335
+	if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) {
336
+			echo '
323 337
 					<div class="news">
324 338
 						<h2>', $txt['news'], ': </h2>
325 339
 						<p>', $context['random_news_line'], '</p>
326 340
 					</div>';
341
+	}
327 342
 
328 343
 	echo '
329 344
 					<hr class="clear">
@@ -386,9 +401,10 @@  discard block
 block discarded – undo
386 401
 		</ul>';
387 402
 
388 403
 	// Show the load time?
389
-	if ($context['show_load_time'])
390
-		echo '
404
+	if ($context['show_load_time']) {
405
+			echo '
391 406
 		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
407
+	}
392 408
 
393 409
 	echo '
394 410
 	</div>';
@@ -418,19 +434,21 @@  discard block
 block discarded – undo
418 434
 	global $context, $shown_linktree, $scripturl, $txt;
419 435
 
420 436
 	// If linktree is empty, just return - also allow an override.
421
-	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
422
-		return;
437
+	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) {
438
+			return;
439
+	}
423 440
 
424 441
 	echo '
425 442
 				<div class="navigate_section">
426 443
 					<ul>';
427 444
 
428
-	if ($context['user']['is_logged'])
429
-	echo '
445
+	if ($context['user']['is_logged']) {
446
+		echo '
430 447
 						<li class="unread_links">
431 448
 							<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
432 449
 							<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
433 450
 						</li>';
451
+	}
434 452
 
435 453
 	// Each tree item has a URL and name. Some may have extra_before and extra_after.
436 454
 	foreach ($context['linktree'] as $link_num => $tree)
@@ -441,25 +459,29 @@  discard block
 block discarded – undo
441 459
 		// Don't show a separator for the first one.
442 460
 		// Better here. Always points to the next level when the linktree breaks to a second line.
443 461
 		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
444
-		if ($link_num != 0)
445
-			echo '
462
+		if ($link_num != 0) {
463
+					echo '
446 464
 							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
465
+		}
447 466
 
448 467
 		// Show something before the link?
449
-		if (isset($tree['extra_before']))
450
-			echo $tree['extra_before'], ' ';
468
+		if (isset($tree['extra_before'])) {
469
+					echo $tree['extra_before'], ' ';
470
+		}
451 471
 
452 472
 		// Show the link, including a URL if it should have one.
453
-		if (isset($tree['url']))
454
-			echo '
473
+		if (isset($tree['url'])) {
474
+					echo '
455 475
 					<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
456
-		else
457
-			echo '
476
+		} else {
477
+					echo '
458 478
 					<span>' . $tree['name'] . '</span>';
479
+		}
459 480
 
460 481
 		// Show something after the link...?
461
-		if (isset($tree['extra_after']))
462
-			echo ' ', $tree['extra_after'];
482
+		if (isset($tree['extra_after'])) {
483
+					echo ' ', $tree['extra_after'];
484
+		}
463 485
 
464 486
 		echo '
465 487
 						</li>';
@@ -509,13 +531,14 @@  discard block
 block discarded – undo
509 531
 					echo '
510 532
 									<ul>';
511 533
 
512
-					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
513
-						echo '
534
+					foreach ($childbutton['sub_buttons'] as $grandchildbutton) {
535
+											echo '
514 536
 										<li>
515 537
 											<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
516 538
 												', $grandchildbutton['title'], '
517 539
 											</a>
518 540
 										</li>';
541
+					}
519 542
 
520 543
 					echo '
521 544
 									</ul>';
@@ -546,8 +569,9 @@  discard block
 block discarded – undo
546 569
 {
547 570
 	global $context, $txt;
548 571
 
549
-	if (!is_array($strip_options))
550
-		$strip_options = array();
572
+	if (!is_array($strip_options)) {
573
+			$strip_options = array();
574
+	}
551 575
 
552 576
 	// Create the buttons...
553 577
 	$buttons = array();
@@ -556,8 +580,9 @@  discard block
 block discarded – undo
556 580
 		// As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!)
557 581
 		if (!isset($value['test']) || !empty($context[$value['test']]))
558 582
 		{
559
-			if (!isset($value['id']))
560
-				$value['id'] = $key;
583
+			if (!isset($value['id'])) {
584
+							$value['id'] = $key;
585
+			}
561 586
 
562 587
 			$button = '
563 588
 				<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';
@@ -570,13 +595,15 @@  discard block
 block discarded – undo
570 595
 							<div class="overview">';
571 596
 				foreach ($value['sub_buttons'] as $element)
572 597
 				{
573
-					if (isset($element['test']) && empty($context[$element['test']]))
574
-						continue;
598
+					if (isset($element['test']) && empty($context[$element['test']])) {
599
+											continue;
600
+					}
575 601
 
576 602
 					$button .= '
577 603
 								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
578
-					if (isset($txt[$element['text'] . '_desc']))
579
-						$button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>';
604
+					if (isset($txt[$element['text'] . '_desc'])) {
605
+											$button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>';
606
+					}
580 607
 					$button .= '</a>';
581 608
 				}
582 609
 				$button .= '
@@ -590,8 +617,9 @@  discard block
 block discarded – undo
590 617
 	}
591 618
 
592 619
 	// No buttons? No button strip either.
593
-	if (empty($buttons))
594
-		return;
620
+	if (empty($buttons)) {
621
+			return;
622
+	}
595 623
 
596 624
 	echo '
597 625
 		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '>
Please login to merge, or discard this patch.