Completed
Pull Request — release-2.1 (#3835)
by Martyn
09:20
created
Sources/ReCaptcha/RequestMethod/Curl.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -32,43 +32,43 @@
 block discarded – undo
32 32
 class Curl
33 33
 {
34 34
 
35
-    /**
36
-     * @see http://php.net/curl_init
37
-     * @param string $url
38
-     * @return resource cURL handle
39
-     */
40
-    public function init($url = null)
41
-    {
42
-        return curl_init($url);
43
-    }
35
+	/**
36
+	 * @see http://php.net/curl_init
37
+	 * @param string $url
38
+	 * @return resource cURL handle
39
+	 */
40
+	public function init($url = null)
41
+	{
42
+		return curl_init($url);
43
+	}
44 44
 
45
-    /**
46
-     * @see http://php.net/curl_setopt_array
47
-     * @param resource $ch
48
-     * @param array $options
49
-     * @return bool
50
-     */
51
-    public function setoptArray($ch, array $options)
52
-    {
53
-        return curl_setopt_array($ch, $options);
54
-    }
45
+	/**
46
+	 * @see http://php.net/curl_setopt_array
47
+	 * @param resource $ch
48
+	 * @param array $options
49
+	 * @return bool
50
+	 */
51
+	public function setoptArray($ch, array $options)
52
+	{
53
+		return curl_setopt_array($ch, $options);
54
+	}
55 55
 
56
-    /**
57
-     * @see http://php.net/curl_exec
58
-     * @param resource $ch
59
-     * @return mixed
60
-     */
61
-    public function exec($ch)
62
-    {
63
-        return curl_exec($ch);
64
-    }
56
+	/**
57
+	 * @see http://php.net/curl_exec
58
+	 * @param resource $ch
59
+	 * @return mixed
60
+	 */
61
+	public function exec($ch)
62
+	{
63
+		return curl_exec($ch);
64
+	}
65 65
 
66
-    /**
67
-     * @see http://php.net/curl_close
68
-     * @param resource $ch
69
-     */
70
-    public function close($ch)
71
-    {
72
-        curl_close($ch);
73
-    }
66
+	/**
67
+	 * @see http://php.net/curl_close
68
+	 * @param resource $ch
69
+	 */
70
+	public function close($ch)
71
+	{
72
+		curl_close($ch);
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/Response.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -31,72 +31,72 @@
 block discarded – undo
31 31
  */
32 32
 class Response
33 33
 {
34
-    /**
35
-     * Succes or failure.
36
-     * @var boolean
37
-     */
38
-    private $success = false;
34
+	/**
35
+	 * Succes or failure.
36
+	 * @var boolean
37
+	 */
38
+	private $success = false;
39 39
 
40
-    /**
41
-     * Error code strings.
42
-     * @var array
43
-     */
44
-    private $errorCodes = array();
40
+	/**
41
+	 * Error code strings.
42
+	 * @var array
43
+	 */
44
+	private $errorCodes = array();
45 45
 
46
-    /**
47
-     * Build the response from the expected JSON returned by the service.
48
-     *
49
-     * @param string $json
50
-     * @return \ReCaptcha\Response
51
-     */
52
-    public static function fromJson($json)
53
-    {
54
-        $responseData = json_decode($json, true);
46
+	/**
47
+	 * Build the response from the expected JSON returned by the service.
48
+	 *
49
+	 * @param string $json
50
+	 * @return \ReCaptcha\Response
51
+	 */
52
+	public static function fromJson($json)
53
+	{
54
+		$responseData = json_decode($json, true);
55 55
 
56
-        if (!$responseData) {
57
-            return new Response(false, array('invalid-json'));
58
-        }
56
+		if (!$responseData) {
57
+			return new Response(false, array('invalid-json'));
58
+		}
59 59
 
60
-        if (isset($responseData['success']) && $responseData['success'] == true) {
61
-            return new Response(true);
62
-        }
60
+		if (isset($responseData['success']) && $responseData['success'] == true) {
61
+			return new Response(true);
62
+		}
63 63
 
64
-        if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
65
-            return new Response(false, $responseData['error-codes']);
66
-        }
64
+		if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
65
+			return new Response(false, $responseData['error-codes']);
66
+		}
67 67
 
68
-        return new Response(false);
69
-    }
68
+		return new Response(false);
69
+	}
70 70
 
71
-    /**
72
-     * Constructor.
73
-     *
74
-     * @param boolean $success
75
-     * @param array $errorCodes
76
-     */
77
-    public function __construct($success, array $errorCodes = array())
78
-    {
79
-        $this->success = $success;
80
-        $this->errorCodes = $errorCodes;
81
-    }
71
+	/**
72
+	 * Constructor.
73
+	 *
74
+	 * @param boolean $success
75
+	 * @param array $errorCodes
76
+	 */
77
+	public function __construct($success, array $errorCodes = array())
78
+	{
79
+		$this->success = $success;
80
+		$this->errorCodes = $errorCodes;
81
+	}
82 82
 
83
-    /**
84
-     * Is success?
85
-     *
86
-     * @return boolean
87
-     */
88
-    public function isSuccess()
89
-    {
90
-        return $this->success;
91
-    }
83
+	/**
84
+	 * Is success?
85
+	 *
86
+	 * @return boolean
87
+	 */
88
+	public function isSuccess()
89
+	{
90
+		return $this->success;
91
+	}
92 92
 
93
-    /**
94
-     * Get error codes.
95
-     *
96
-     * @return array
97
-     */
98
-    public function getErrorCodes()
99
-    {
100
-        return $this->errorCodes;
101
-    }
93
+	/**
94
+	 * Get error codes.
95
+	 *
96
+	 * @return array
97
+	 */
98
+	public function getErrorCodes()
99
+	{
100
+		return $this->errorCodes;
101
+	}
102 102
 }
Please login to merge, or discard this patch.
Sources/ReCaptcha/ReCaptcha.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -31,67 +31,67 @@
 block discarded – undo
31 31
  */
32 32
 class ReCaptcha
33 33
 {
34
-    /**
35
-     * Version of this client library.
36
-     * @const string
37
-     */
38
-    const VERSION = 'php_1.1.2';
34
+	/**
35
+	 * Version of this client library.
36
+	 * @const string
37
+	 */
38
+	const VERSION = 'php_1.1.2';
39 39
 
40
-    /**
41
-     * Shared secret for the site.
42
-     * @var type string
43
-     */
44
-    private $secret;
40
+	/**
41
+	 * Shared secret for the site.
42
+	 * @var type string
43
+	 */
44
+	private $secret;
45 45
 
46
-    /**
47
-     * Method used to communicate  with service. Defaults to POST request.
48
-     * @var RequestMethod
49
-     */
50
-    private $requestMethod;
46
+	/**
47
+	 * Method used to communicate  with service. Defaults to POST request.
48
+	 * @var RequestMethod
49
+	 */
50
+	private $requestMethod;
51 51
 
52
-    /**
53
-     * Create a configured instance to use the reCAPTCHA service.
54
-     *
55
-     * @param string $secret shared secret between site and reCAPTCHA server.
56
-     * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
-     */
58
-    public function __construct($secret, RequestMethod $requestMethod = null)
59
-    {
60
-        if (empty($secret)) {
61
-            throw new \RuntimeException('No secret provided');
62
-        }
52
+	/**
53
+	 * Create a configured instance to use the reCAPTCHA service.
54
+	 *
55
+	 * @param string $secret shared secret between site and reCAPTCHA server.
56
+	 * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
57
+	 */
58
+	public function __construct($secret, RequestMethod $requestMethod = null)
59
+	{
60
+		if (empty($secret)) {
61
+			throw new \RuntimeException('No secret provided');
62
+		}
63 63
 
64
-        if (!is_string($secret)) {
65
-            throw new \RuntimeException('The provided secret must be a string');
66
-        }
64
+		if (!is_string($secret)) {
65
+			throw new \RuntimeException('The provided secret must be a string');
66
+		}
67 67
 
68
-        $this->secret = $secret;
68
+		$this->secret = $secret;
69 69
 
70
-        if (!is_null($requestMethod)) {
71
-            $this->requestMethod = $requestMethod;
72
-        } else {
73
-            $this->requestMethod = new RequestMethod\Post();
74
-        }
75
-    }
70
+		if (!is_null($requestMethod)) {
71
+			$this->requestMethod = $requestMethod;
72
+		} else {
73
+			$this->requestMethod = new RequestMethod\Post();
74
+		}
75
+	}
76 76
 
77
-    /**
78
-     * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
-     * CAPTCHA test.
80
-     *
81
-     * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
-     * @param string $remoteIp The end user's IP address.
83
-     * @return Response Response from the service.
84
-     */
85
-    public function verify($response, $remoteIp = null)
86
-    {
87
-        // Discard empty solution submissions
88
-        if (empty($response)) {
89
-            $recaptchaResponse = new Response(false, array('missing-input-response'));
90
-            return $recaptchaResponse;
91
-        }
77
+	/**
78
+	 * Calls the reCAPTCHA siteverify API to verify whether the user passes
79
+	 * CAPTCHA test.
80
+	 *
81
+	 * @param string $response The value of 'g-recaptcha-response' in the submitted form.
82
+	 * @param string $remoteIp The end user's IP address.
83
+	 * @return Response Response from the service.
84
+	 */
85
+	public function verify($response, $remoteIp = null)
86
+	{
87
+		// Discard empty solution submissions
88
+		if (empty($response)) {
89
+			$recaptchaResponse = new Response(false, array('missing-input-response'));
90
+			return $recaptchaResponse;
91
+		}
92 92
 
93
-        $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
-        $rawResponse = $this->requestMethod->submit($params);
95
-        return Response::fromJson($rawResponse);
96
-    }
93
+		$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
94
+		$rawResponse = $this->requestMethod->submit($params);
95
+		return Response::fromJson($rawResponse);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Sources/CacheAPI-sqlite.php 1 patch
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.
proxy.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@
 block discarded – undo
110 110
 
111 111
 		// Right, image not cached? Simply redirect, then.
112 112
 		if (!$this->checkRequest())
113
-		    redirectexit($request);
113
+			redirectexit($request);
114 114
 
115 115
 		// Make sure we're serving an image
116 116
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
Please login to merge, or discard this patch.
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -63,26 +63,31 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function checkRequest()
65 65
 	{
66
-		if (!$this->enabled)
67
-			return false;
66
+		if (!$this->enabled) {
67
+					return false;
68
+		}
68 69
 
69 70
 		// Try to create the image cache directory if it doesn't exist
70
-		if (!file_exists($this->cache))
71
-			if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
71
+		if (!file_exists($this->cache)) {
72
+					if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
72 73
 				return false;
74
+		}
73 75
 
74
-		if (empty($_GET['hash']) || empty($_GET['request']))
75
-			return false;
76
+		if (empty($_GET['hash']) || empty($_GET['request'])) {
77
+					return false;
78
+		}
76 79
 
77 80
 		$hash = $_GET['hash'];
78 81
 		$request = $_GET['request'];
79 82
 
80
-		if (md5($request . $this->secret) != $hash)
81
-			return false;
83
+		if (md5($request . $this->secret) != $hash) {
84
+					return false;
85
+		}
82 86
 
83 87
 		// Attempt to cache the request if it doesn't exist
84
-		if (!$this->isCached($request))
85
-			return $this->cacheImage($request);
88
+		if (!$this->isCached($request)) {
89
+					return $this->cacheImage($request);
90
+		}
86 91
 
87 92
 		return true;
88 93
 	}
@@ -103,19 +108,22 @@  discard block
 block discarded – undo
103 108
 		if (!$cached || time() - $cached['time'] > (5 * 86400))
104 109
 		{
105 110
 			@unlink($cached_file);
106
-			if ($this->checkRequest())
107
-				$this->serve();
111
+			if ($this->checkRequest()) {
112
+							$this->serve();
113
+			}
108 114
 			redirectexit($request);
109 115
 		}
110 116
 
111 117
 		// Right, image not cached? Simply redirect, then.
112
-		if (!$this->checkRequest())
113
-		    redirectexit($request);
118
+		if (!$this->checkRequest()) {
119
+				    redirectexit($request);
120
+		}
114 121
 
115 122
 		// Make sure we're serving an image
116 123
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
117
-		if ($contentParts[0] != 'image')
118
-			exit;
124
+		if ($contentParts[0] != 'image') {
125
+					exit;
126
+		}
119 127
 
120 128
 		header('Content-type: ' . $cached['content_type']);
121 129
 		header('Content-length: ' . $cached['size']);
@@ -161,19 +169,22 @@  discard block
 block discarded – undo
161 169
 		$request = $curl->get_url_data($request);
162 170
 		$response = $request->result();
163 171
 
164
-		if (empty($response))
165
-			return false;
172
+		if (empty($response)) {
173
+					return false;
174
+		}
166 175
 
167 176
 		$headers = $response['headers'];
168 177
 
169 178
 		// Make sure the url is returning an image
170 179
 		$contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : '');
171
-		if ($contentParts[0] != 'image')
172
-			return false;
180
+		if ($contentParts[0] != 'image') {
181
+					return false;
182
+		}
173 183
 
174 184
 		// Validate the filesize
175
-		if ($response['size'] > ($this->maxSize * 1024))
176
-			return false;
185
+		if ($response['size'] > ($this->maxSize * 1024)) {
186
+					return false;
187
+		}
177 188
 
178 189
 		return file_put_contents($dest, json_encode(array(
179 190
 			'content_type' => $headers['content-type'],
Please login to merge, or discard this patch.
Sources/Subs-Calendar.php 1 patch
Braces   +217 added lines, -157 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
  * Get all birthdays within the given time range.
@@ -61,10 +62,11 @@  discard block
 block discarded – undo
61 62
 	$bday = array();
62 63
 	while ($row = $smcFunc['db_fetch_assoc']($result))
63 64
 	{
64
-		if ($year_low != $year_high)
65
-			$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
66
-		else
67
-			$age_year = $year_low;
65
+		if ($year_low != $year_high) {
66
+					$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
67
+		} else {
68
+					$age_year = $year_low;
69
+		}
68 70
 
69 71
 		$bday[$age_year . substr($row['birthdate'], 4)][] = array(
70 72
 			'id' => $row['id_member'],
@@ -78,8 +80,9 @@  discard block
 block discarded – undo
78 80
 	ksort($bday);
79 81
 
80 82
 	// Set is_last, so the themes know when to stop placing separators.
81
-	foreach ($bday as $mday => $array)
82
-		$bday[$mday][count($array) - 1]['is_last'] = true;
83
+	foreach ($bday as $mday => $array) {
84
+			$bday[$mday][count($array) - 1]['is_last'] = true;
85
+	}
83 86
 
84 87
 	return $bday;
85 88
 }
@@ -127,8 +130,9 @@  discard block
 block discarded – undo
127 130
 	while ($row = $smcFunc['db_fetch_assoc']($result))
128 131
 	{
129 132
 		// If the attached topic is not approved then for the moment pretend it doesn't exist
130
-		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved'])
131
-			continue;
133
+		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) {
134
+					continue;
135
+		}
132 136
 
133 137
 		// Force a censor of the title - as often these are used by others.
134 138
 		censorText($row['title'], $use_permissions ? false : true);
@@ -137,8 +141,9 @@  discard block
 block discarded – undo
137 141
 		list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
138 142
 
139 143
 		// Sanity check
140
-		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
141
-			continue;
144
+		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
145
+					continue;
146
+		}
142 147
 
143 148
 		// Get set up for the loop
144 149
 		$start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz));
@@ -202,8 +207,8 @@  discard block
 block discarded – undo
202 207
 			);
203 208
 
204 209
 			// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
205
-			if ($use_permissions)
206
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
210
+			if ($use_permissions) {
211
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
207 212
 					'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
208 213
 					'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
209 214
 					'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')),
@@ -211,9 +216,10 @@  discard block
 block discarded – undo
211 216
 					'can_export' => !empty($modSettings['cal_export']) ? true : false,
212 217
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
213 218
 				));
219
+			}
214 220
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
215
-			else
216
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
221
+			else {
222
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
217 223
 					'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
218 224
 					'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
219 225
 					'can_edit' => false,
@@ -223,6 +229,7 @@  discard block
 block discarded – undo
223 229
 					'poster' => $row['id_member'],
224 230
 					'allowed_groups' => explode(',', $row['member_groups']),
225 231
 				));
232
+			}
226 233
 
227 234
 			date_add($cal_date, date_interval_create_from_date_string('1 day'));
228 235
 		}
@@ -232,8 +239,9 @@  discard block
 block discarded – undo
232 239
 	// If we're doing normal contextual data, go through and make things clear to the templates ;).
233 240
 	if ($use_permissions)
234 241
 	{
235
-		foreach ($events as $mday => $array)
236
-			$events[$mday][count($array) - 1]['is_last'] = true;
242
+		foreach ($events as $mday => $array) {
243
+					$events[$mday][count($array) - 1]['is_last'] = true;
244
+		}
237 245
 	}
238 246
 
239 247
 	ksort($events);
@@ -253,11 +261,12 @@  discard block
 block discarded – undo
253 261
 	global $smcFunc;
254 262
 
255 263
 	// Get the lowest and highest dates for "all years".
256
-	if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
257
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
264
+	if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
265
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
258 266
 			OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}';
259
-	else
260
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
267
+	} else {
268
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
269
+	}
261 270
 
262 271
 	// Find some holidays... ;).
263 272
 	$result = $smcFunc['db_query']('', '
@@ -277,10 +286,11 @@  discard block
 block discarded – undo
277 286
 	$holidays = array();
278 287
 	while ($row = $smcFunc['db_fetch_assoc']($result))
279 288
 	{
280
-		if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
281
-			$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
282
-		else
283
-			$event_year = substr($low_date, 0, 4);
289
+		if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
290
+					$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
291
+		} else {
292
+					$event_year = substr($low_date, 0, 4);
293
+		}
284 294
 
285 295
 		$holidays[$event_year . substr($row['event_date'], 4)][] = $row['title'];
286 296
 	}
@@ -306,10 +316,12 @@  discard block
 block discarded – undo
306 316
 	isAllowedTo('calendar_post');
307 317
 
308 318
 	// No board?  No topic?!?
309
-	if (empty($board))
310
-		fatal_lang_error('missing_board_id', false);
311
-	if (empty($topic))
312
-		fatal_lang_error('missing_topic_id', false);
319
+	if (empty($board)) {
320
+			fatal_lang_error('missing_board_id', false);
321
+	}
322
+	if (empty($topic)) {
323
+			fatal_lang_error('missing_topic_id', false);
324
+	}
313 325
 
314 326
 	// Administrator, Moderator, or owner.  Period.
315 327
 	if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
@@ -327,12 +339,14 @@  discard block
 block discarded – undo
327 339
 		if ($row = $smcFunc['db_fetch_assoc']($result))
328 340
 		{
329 341
 			// Not the owner of the topic.
330
-			if ($row['id_member_started'] != $user_info['id'])
331
-				fatal_lang_error('not_your_topic', 'user');
342
+			if ($row['id_member_started'] != $user_info['id']) {
343
+							fatal_lang_error('not_your_topic', 'user');
344
+			}
332 345
 		}
333 346
 		// Topic/Board doesn't exist.....
334
-		else
335
-			fatal_lang_error('calendar_no_topic', 'general');
347
+		else {
348
+					fatal_lang_error('calendar_no_topic', 'general');
349
+		}
336 350
 		$smcFunc['db_free_result']($result);
337 351
 	}
338 352
 }
@@ -420,14 +434,16 @@  discard block
 block discarded – undo
420 434
 	if (!empty($calendarOptions['start_day']))
421 435
 	{
422 436
 		$nShift -= $calendarOptions['start_day'];
423
-		if ($nShift < 0)
424
-			$nShift = 7 + $nShift;
437
+		if ($nShift < 0) {
438
+					$nShift = 7 + $nShift;
439
+		}
425 440
 	}
426 441
 
427 442
 	// Number of rows required to fit the month.
428 443
 	$nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7);
429
-	if (($month_info['last_day']['day_of_month'] + $nShift) % 7)
430
-		$nRows++;
444
+	if (($month_info['last_day']['day_of_month'] + $nShift) % 7) {
445
+			$nRows++;
446
+	}
431 447
 
432 448
 	// Fetch the arrays for birthdays, posted events, and holidays.
433 449
 	$bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array();
@@ -440,8 +456,9 @@  discard block
 block discarded – undo
440 456
 	{
441 457
 		$calendarGrid['week_days'][] = $count;
442 458
 		$count++;
443
-		if ($count == 7)
444
-			$count = 0;
459
+		if ($count == 7) {
460
+					$count = 0;
461
+		}
445 462
 	}
446 463
 
447 464
 	// Iterate through each week.
@@ -458,8 +475,9 @@  discard block
 block discarded – undo
458 475
 		{
459 476
 			$nDay = ($nRow * 7) + $nCol - $nShift + 1;
460 477
 
461
-			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month'])
462
-				$nDay = 0;
478
+			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) {
479
+							$nDay = 0;
480
+			}
463 481
 
464 482
 			$date = sprintf('%04d-%02d-%02d', $year, $month, $nDay);
465 483
 
@@ -477,8 +495,9 @@  discard block
 block discarded – undo
477 495
 	}
478 496
 
479 497
 	// What is the last day of the month?
480
-	if ($is_previous === true)
481
-		$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
498
+	if ($is_previous === true) {
499
+			$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
500
+	}
482 501
 
483 502
 	// We'll use the shift in the template.
484 503
 	$calendarGrid['shift'] = $nShift;
@@ -512,8 +531,9 @@  discard block
 block discarded – undo
512 531
 	{
513 532
 		// Here we offset accordingly to get things to the real start of a week.
514 533
 		$date_diff = $day_of_week - $calendarOptions['start_day'];
515
-		if ($date_diff < 0)
516
-			$date_diff += 7;
534
+		if ($date_diff < 0) {
535
+					$date_diff += 7;
536
+		}
517 537
 		$new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400;
518 538
 		$day = (int) strftime('%d', $new_timestamp);
519 539
 		$month = (int) strftime('%m', $new_timestamp);
@@ -643,18 +663,20 @@  discard block
 block discarded – undo
643 663
 	{
644 664
 		foreach ($date_events as $event_key => $event_val)
645 665
 		{
646
-			if (in_array($event_val['id'], $temp))
647
-				unset($calendarGrid['events'][$date][$event_key]);
648
-			else
649
-				$temp[] = $event_val['id'];
666
+			if (in_array($event_val['id'], $temp)) {
667
+							unset($calendarGrid['events'][$date][$event_key]);
668
+			} else {
669
+							$temp[] = $event_val['id'];
670
+			}
650 671
 		}
651 672
 	}
652 673
 
653 674
 	// Give birthdays and holidays a friendly format, without the year
654
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
655
-		$date_format = '%b %d';
656
-	else
657
-		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
675
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
676
+			$date_format = '%b %d';
677
+	} else {
678
+			$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
679
+	}
658 680
 
659 681
 	foreach (array('birthdays', 'holidays') as $type)
660 682
 	{
@@ -762,8 +784,9 @@  discard block
 block discarded – undo
762 784
 	// Holidays between now and now + days.
763 785
 	for ($i = $now; $i < $now + $days_for_index; $i += 86400)
764 786
 	{
765
-		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)]))
766
-			$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
787
+		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) {
788
+					$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
789
+		}
767 790
 	}
768 791
 
769 792
 	// Happy Birthday, guys and gals!
@@ -772,8 +795,9 @@  discard block
 block discarded – undo
772 795
 		$loop_date = strftime('%Y-%m-%d', $i);
773 796
 		if (isset($cached_data['birthdays'][$loop_date]))
774 797
 		{
775
-			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
776
-				$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
798
+			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) {
799
+							$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
800
+			}
777 801
 			$return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]);
778 802
 		}
779 803
 	}
@@ -785,8 +809,9 @@  discard block
 block discarded – undo
785 809
 		$loop_date = strftime('%Y-%m-%d', $i);
786 810
 
787 811
 		// No events today? Check the next day.
788
-		if (empty($cached_data['events'][$loop_date]))
789
-			continue;
812
+		if (empty($cached_data['events'][$loop_date])) {
813
+					continue;
814
+		}
790 815
 
791 816
 		// Loop through all events to add a few last-minute values.
792 817
 		foreach ($cached_data['events'][$loop_date] as $ev => $event)
@@ -799,9 +824,9 @@  discard block
 block discarded – undo
799 824
 			{
800 825
 				unset($cached_data['events'][$loop_date][$ev]);
801 826
 				continue;
827
+			} else {
828
+							$duplicates[$this_event['topic'] . $this_event['title']] = true;
802 829
 			}
803
-			else
804
-				$duplicates[$this_event['topic'] . $this_event['title']] = true;
805 830
 
806 831
 			// Might be set to true afterwards, depending on the permissions.
807 832
 			$this_event['can_edit'] = false;
@@ -809,15 +834,18 @@  discard block
 block discarded – undo
809 834
 			$this_event['date'] = $loop_date;
810 835
 		}
811 836
 
812
-		if (!empty($cached_data['events'][$loop_date]))
813
-			$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
837
+		if (!empty($cached_data['events'][$loop_date])) {
838
+					$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
839
+		}
814 840
 	}
815 841
 
816 842
 	// Mark the last item so that a list separator can be used in the template.
817
-	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++)
818
-		$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
819
-	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++)
820
-		$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
843
+	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) {
844
+			$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
845
+	}
846
+	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) {
847
+			$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
848
+	}
821 849
 
822 850
 	return array(
823 851
 		'data' => $return_data,
@@ -865,37 +893,46 @@  discard block
 block discarded – undo
865 893
 		if (isset($_POST['start_date']))
866 894
 		{
867 895
 			$d = date_parse($_POST['start_date']);
868
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
869
-				fatal_lang_error('invalid_date', false);
870
-			if (empty($d['year']))
871
-				fatal_lang_error('event_year_missing', false);
872
-			if (empty($d['month']))
873
-				fatal_lang_error('event_month_missing', false);
874
-		}
875
-		elseif (isset($_POST['start_datetime']))
896
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
897
+							fatal_lang_error('invalid_date', false);
898
+			}
899
+			if (empty($d['year'])) {
900
+							fatal_lang_error('event_year_missing', false);
901
+			}
902
+			if (empty($d['month'])) {
903
+							fatal_lang_error('event_month_missing', false);
904
+			}
905
+		} elseif (isset($_POST['start_datetime']))
876 906
 		{
877 907
 			$d = date_parse($_POST['start_datetime']);
878
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
879
-				fatal_lang_error('invalid_date', false);
880
-			if (empty($d['year']))
881
-				fatal_lang_error('event_year_missing', false);
882
-			if (empty($d['month']))
883
-				fatal_lang_error('event_month_missing', false);
908
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
909
+							fatal_lang_error('invalid_date', false);
910
+			}
911
+			if (empty($d['year'])) {
912
+							fatal_lang_error('event_year_missing', false);
913
+			}
914
+			if (empty($d['month'])) {
915
+							fatal_lang_error('event_month_missing', false);
916
+			}
884 917
 		}
885 918
 		// The 2.0 way
886 919
 		else
887 920
 		{
888 921
 			// No month?  No year?
889
-			if (!isset($_POST['month']))
890
-				fatal_lang_error('event_month_missing', false);
891
-			if (!isset($_POST['year']))
892
-				fatal_lang_error('event_year_missing', false);
922
+			if (!isset($_POST['month'])) {
923
+							fatal_lang_error('event_month_missing', false);
924
+			}
925
+			if (!isset($_POST['year'])) {
926
+							fatal_lang_error('event_year_missing', false);
927
+			}
893 928
 
894 929
 			// Check the month and year...
895
-			if ($_POST['month'] < 1 || $_POST['month'] > 12)
896
-				fatal_lang_error('invalid_month', false);
897
-			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear'])
898
-				fatal_lang_error('invalid_year', false);
930
+			if ($_POST['month'] < 1 || $_POST['month'] > 12) {
931
+							fatal_lang_error('invalid_month', false);
932
+			}
933
+			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) {
934
+							fatal_lang_error('invalid_year', false);
935
+			}
899 936
 		}
900 937
 	}
901 938
 
@@ -905,8 +942,9 @@  discard block
 block discarded – undo
905 942
 	// If they want to us to calculate an end date, make sure it will fit in an acceptable range.
906 943
 	if (isset($_POST['span']))
907 944
 	{
908
-		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan']))
909
-			fatal_lang_error('invalid_days_numb', false);
945
+		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) {
946
+					fatal_lang_error('invalid_days_numb', false);
947
+		}
910 948
 	}
911 949
 
912 950
 	// There is no need to validate the following values if we are just deleting the event.
@@ -916,24 +954,29 @@  discard block
 block discarded – undo
916 954
 		if (empty($_POST['start_date']) && empty($_POST['start_datetime']))
917 955
 		{
918 956
 			// No day?
919
-			if (!isset($_POST['day']))
920
-				fatal_lang_error('event_day_missing', false);
957
+			if (!isset($_POST['day'])) {
958
+							fatal_lang_error('event_day_missing', false);
959
+			}
921 960
 
922 961
 			// Bad day?
923
-			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year']))
924
-				fatal_lang_error('invalid_date', false);
962
+			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) {
963
+							fatal_lang_error('invalid_date', false);
964
+			}
925 965
 		}
926 966
 
927
-		if (!isset($_POST['evtitle']) && !isset($_POST['subject']))
928
-			fatal_lang_error('event_title_missing', false);
929
-		elseif (!isset($_POST['evtitle']))
930
-			$_POST['evtitle'] = $_POST['subject'];
967
+		if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) {
968
+					fatal_lang_error('event_title_missing', false);
969
+		} elseif (!isset($_POST['evtitle'])) {
970
+					$_POST['evtitle'] = $_POST['subject'];
971
+		}
931 972
 
932 973
 		// No title?
933
-		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
934
-			fatal_lang_error('no_event_title', false);
935
-		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
936
-			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
974
+		if ($smcFunc['htmltrim']($_POST['evtitle']) === '') {
975
+					fatal_lang_error('no_event_title', false);
976
+		}
977
+		if ($smcFunc['strlen']($_POST['evtitle']) > 100) {
978
+					$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
979
+		}
937 980
 		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
938 981
 	}
939 982
 }
@@ -960,8 +1003,9 @@  discard block
 block discarded – undo
960 1003
 	);
961 1004
 
962 1005
 	// No results, return false.
963
-	if ($smcFunc['db_num_rows'] === 0)
964
-		return false;
1006
+	if ($smcFunc['db_num_rows'] === 0) {
1007
+			return false;
1008
+	}
965 1009
 
966 1010
 	// Grab the results and return.
967 1011
 	list ($poster) = $smcFunc['db_fetch_row']($request);
@@ -1095,8 +1139,9 @@  discard block
 block discarded – undo
1095 1139
 	call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters));
1096 1140
 
1097 1141
 	$column_clauses = array();
1098
-	foreach ($event_columns as $col => $crit)
1099
-		$column_clauses[] = $col . ' = ' . $crit;
1142
+	foreach ($event_columns as $col => $crit) {
1143
+			$column_clauses[] = $col . ' = ' . $crit;
1144
+	}
1100 1145
 
1101 1146
 	$smcFunc['db_query']('', '
1102 1147
 		UPDATE {db_prefix}calendar
@@ -1181,8 +1226,9 @@  discard block
 block discarded – undo
1181 1226
 	);
1182 1227
 
1183 1228
 	// If nothing returned, we are in poo, poo.
1184
-	if ($smcFunc['db_num_rows']($request) === 0)
1185
-		return false;
1229
+	if ($smcFunc['db_num_rows']($request) === 0) {
1230
+			return false;
1231
+	}
1186 1232
 
1187 1233
 	$row = $smcFunc['db_fetch_assoc']($request);
1188 1234
 	$smcFunc['db_free_result']($request);
@@ -1190,8 +1236,9 @@  discard block
 block discarded – undo
1190 1236
 	list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
1191 1237
 
1192 1238
 	// Sanity check
1193
-	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
1194
-		return false;
1239
+	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
1240
+			return false;
1241
+	}
1195 1242
 
1196 1243
 	$return_value = array(
1197 1244
 		'boards' => array(),
@@ -1328,24 +1375,27 @@  discard block
 block discarded – undo
1328 1375
 
1329 1376
 	// Set $span, in case we need it
1330 1377
 	$span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0);
1331
-	if ($span > 0)
1332
-		$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1378
+	if ($span > 0) {
1379
+			$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1380
+	}
1333 1381
 
1334 1382
 	// Define the timezone for this event, falling back to the default if not provided
1335
-	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1336
-		$tz = $eventOptions['tz'];
1337
-	elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1338
-		$tz = $_POST['tz'];
1339
-	else
1340
-		$tz = getUserTimezone();
1383
+	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1384
+			$tz = $eventOptions['tz'];
1385
+	} elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1386
+			$tz = $_POST['tz'];
1387
+	} else {
1388
+			$tz = getUserTimezone();
1389
+	}
1341 1390
 
1342 1391
 	// Is this supposed to be an all day event, or should it have specific start and end times?
1343
-	if (isset($eventOptions['allday']))
1344
-		$allday = $eventOptions['allday'];
1345
-	elseif (empty($_POST['allday']))
1346
-		$allday = false;
1347
-	else
1348
-		$allday = true;
1392
+	if (isset($eventOptions['allday'])) {
1393
+			$allday = $eventOptions['allday'];
1394
+	} elseif (empty($_POST['allday'])) {
1395
+			$allday = false;
1396
+	} else {
1397
+			$allday = true;
1398
+	}
1349 1399
 
1350 1400
 	// Input might come as individual parameters...
1351 1401
 	$start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null);
@@ -1372,10 +1422,12 @@  discard block
 block discarded – undo
1372 1422
 	$end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null);
1373 1423
 
1374 1424
 	// If the date and time were given in separate strings, combine them
1375
-	if (empty($start_string) && isset($start_date_string))
1376
-		$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1377
-	if (empty($end_string) && isset($end_date_string))
1378
-		$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1425
+	if (empty($start_string) && isset($start_date_string)) {
1426
+			$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1427
+	}
1428
+	if (empty($end_string) && isset($end_date_string)) {
1429
+			$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1430
+	}
1379 1431
 
1380 1432
 	// If some form of string input was given, override individually defined options with it
1381 1433
 	if (isset($start_string))
@@ -1466,10 +1518,11 @@  discard block
 block discarded – undo
1466 1518
 	if ($start_object >= $end_object)
1467 1519
 	{
1468 1520
 		$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1469
-		if ($span > 0)
1470
-			date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1471
-		else
1472
-			date_add($end_object, date_interval_create_from_date_string('1 hour'));
1521
+		if ($span > 0) {
1522
+					date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1523
+		} else {
1524
+					date_add($end_object, date_interval_create_from_date_string('1 hour'));
1525
+		}
1473 1526
 	}
1474 1527
 
1475 1528
 	// Is $end_object too late?
@@ -1482,9 +1535,9 @@  discard block
 block discarded – undo
1482 1535
 			{
1483 1536
 				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1484 1537
 				date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days'));
1538
+			} else {
1539
+							$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1485 1540
 			}
1486
-			else
1487
-				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1488 1541
 		}
1489 1542
 	}
1490 1543
 
@@ -1497,8 +1550,7 @@  discard block
 block discarded – undo
1497 1550
 		$start_time = null;
1498 1551
 		$end_time = null;
1499 1552
 		$tz = null;
1500
-	}
1501
-	else
1553
+	} else
1502 1554
 	{
1503 1555
 		$start_time = date_format($start_object, 'H:i:s');
1504 1556
 		$end_time = date_format($end_object, 'H:i:s');
@@ -1519,16 +1571,18 @@  discard block
 block discarded – undo
1519 1571
 	require_once($sourcedir . '/Subs.php');
1520 1572
 
1521 1573
 	// First, try to create a better date format, ignoring the "time" elements.
1522
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1523
-		$date_format = '%F';
1524
-	else
1525
-		$date_format = $matches[0];
1574
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1575
+			$date_format = '%F';
1576
+	} else {
1577
+			$date_format = $matches[0];
1578
+	}
1526 1579
 
1527 1580
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1528
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1529
-		$time_format = '%k:%M';
1530
-	else
1531
-		$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1581
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1582
+			$time_format = '%k:%M';
1583
+	} else {
1584
+			$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1585
+	}
1532 1586
 
1533 1587
 	// Should this be an all day event?
1534 1588
 	$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
@@ -1537,8 +1591,9 @@  discard block
 block discarded – undo
1537 1591
 	$span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d');
1538 1592
 
1539 1593
 	// We need to have a defined timezone in the steps below
1540
-	if (empty($row['timezone']))
1541
-		$row['timezone'] = getUserTimezone();
1594
+	if (empty($row['timezone'])) {
1595
+			$row['timezone'] = getUserTimezone();
1596
+	}
1542 1597
 
1543 1598
 	// Get most of the standard date information for the start and end datetimes
1544 1599
 	$start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''));
@@ -1582,8 +1637,9 @@  discard block
 block discarded – undo
1582 1637
 		$tz_location = timezone_location_get(timezone_open($row['timezone']));
1583 1638
 
1584 1639
 		// Kazakstan
1585
-		if ($tz_location['country_code'] == 'KZ')
1586
-			$tz_abbrev = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tz_abbrev);
1640
+		if ($tz_location['country_code'] == 'KZ') {
1641
+					$tz_abbrev = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tz_abbrev);
1642
+		}
1587 1643
 
1588 1644
 		// Russia likes to experiment with time zones
1589 1645
 		if ($tz_location['country_code'] == 'RU')
@@ -1594,8 +1650,9 @@  discard block
 block discarded – undo
1594 1650
 		}
1595 1651
 
1596 1652
 		// Still no good? We'll just mark it as a UTC offset
1597
-		if (strspn($tz_abbrev, '+-') > 0)
1598
-			$tz_abbrev = 'UTC' . $tz_abbrev;
1653
+		if (strspn($tz_abbrev, '+-') > 0) {
1654
+					$tz_abbrev = 'UTC' . $tz_abbrev;
1655
+		}
1599 1656
 	}
1600 1657
 
1601 1658
 	return array($start, $end, $allday, $span, $tz, $tz_abbrev);
@@ -1611,8 +1668,9 @@  discard block
 block discarded – undo
1611 1668
 {
1612 1669
 	global $smcFunc, $context, $sourcedir, $user_info, $modSettings;
1613 1670
 
1614
-	if (is_null($id_member) && $user_info['is_guest'] == false)
1615
-		$id_member = $context['user']['id'];
1671
+	if (is_null($id_member) && $user_info['is_guest'] == false) {
1672
+			$id_member = $context['user']['id'];
1673
+	}
1616 1674
 
1617 1675
 	if (isset($id_member))
1618 1676
 	{
@@ -1628,8 +1686,9 @@  discard block
 block discarded – undo
1628 1686
 		$smcFunc['db_free_result']($request);
1629 1687
 	}
1630 1688
 
1631
-	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1632
-		$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1689
+	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1690
+			$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1691
+	}
1633 1692
 
1634 1693
 	return $timezone;
1635 1694
 }
@@ -1658,8 +1717,9 @@  discard block
 block discarded – undo
1658 1717
 		)
1659 1718
 	);
1660 1719
 	$holidays = array();
1661
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1662
-		$holidays[] = $row;
1720
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1721
+			$holidays[] = $row;
1722
+	}
1663 1723
 	$smcFunc['db_free_result']($request);
1664 1724
 
1665 1725
 	return $holidays;
Please login to merge, or discard this patch.
Sources/minify/data/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/data/js/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.