Completed
Pull Request — release-2.1 (#3761)
by Rick
10:12 queued 03:10
created
Sources/CacheAPI-smf.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@
 block discarded – undo
180 180
 	 *
181 181
 	 * @access public
182 182
 	 * @param string $dir A valid path
183
-	 * @return boolean If this was successful or not.
183
+	 * @return boolean|null If this was successful or not.
184 184
 	 */
185 185
 	public function setCachedir($dir = null)
186 186
 	{
Please login to merge, or discard this patch.
Braces   +36 added lines, -26 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
  * Our Cache API class
@@ -43,8 +44,9 @@  discard block
 block discarded – undo
43 44
 	{
44 45
 		$supported = is_writable($this->cachedir);
45 46
 
46
-		if ($test)
47
-			return $supported;
47
+		if ($test) {
48
+					return $supported;
49
+		}
48 50
 		return parent::isSupported() && $supported;
49 51
 	}
50 52
 
@@ -61,11 +63,13 @@  discard block
 block discarded – undo
61 63
 		{
62 64
 			// Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds
63 65
 			// causing newer files to take effect a while later.
64
-			if (function_exists('opcache_invalidate'))
65
-				opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
66
+			if (function_exists('opcache_invalidate')) {
67
+							opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
68
+			}
66 69
 
67
-			if (function_exists('apc_delete_file'))
68
-				@apc_delete_file($cachedir . '/data_' . $key . '.php');
70
+			if (function_exists('apc_delete_file')) {
71
+							@apc_delete_file($cachedir . '/data_' . $key . '.php');
72
+			}
69 73
 
70 74
 			// php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
71 75
 			@include($cachedir . '/data_' . $key . '.php');
@@ -89,16 +93,18 @@  discard block
 block discarded – undo
89 93
 
90 94
 		// Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds
91 95
 		// causing newer files to take effect a while later.
92
-		if (function_exists('opcache_invalidate'))
93
-			opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
96
+		if (function_exists('opcache_invalidate')) {
97
+					opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
98
+		}
94 99
 
95
-		if (function_exists('apc_delete_file'))
96
-			@apc_delete_file($cachedir . '/data_' . $key . '.php');
100
+		if (function_exists('apc_delete_file')) {
101
+					@apc_delete_file($cachedir . '/data_' . $key . '.php');
102
+		}
97 103
 
98 104
 		// Otherwise custom cache?
99
-		if ($value === null)
100
-			@unlink($cachedir . '/data_' . $key . '.php');
101
-		else
105
+		if ($value === null) {
106
+					@unlink($cachedir . '/data_' . $key . '.php');
107
+		} else
102 108
 		{
103 109
 			$cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>';
104 110
 
@@ -109,9 +115,9 @@  discard block
 block discarded – undo
109 115
 			{
110 116
 				@unlink($cachedir . '/data_' . $key . '.php');
111 117
 				return false;
118
+			} else {
119
+							return true;
112 120
 			}
113
-			else
114
-				return true;
115 121
 		}
116 122
 	}
117 123
 
@@ -123,15 +129,17 @@  discard block
 block discarded – undo
123 129
 		$cachedir = $this->cachedir;
124 130
 
125 131
 		// No directory = no game.
126
-		if (!is_dir($cachedir))
127
-			return;
132
+		if (!is_dir($cachedir)) {
133
+					return;
134
+		}
128 135
 
129 136
 		// Remove the files in SMF's own disk cache, if any
130 137
 		$dh = opendir($cachedir);
131 138
 		while ($file = readdir($dh))
132 139
 		{
133
-			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
134
-				@unlink($cachedir . '/' . $file);
140
+			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
141
+							@unlink($cachedir . '/' . $file);
142
+			}
135 143
 		}
136 144
 		closedir($dh);
137 145
 
@@ -165,8 +173,9 @@  discard block
 block discarded – undo
165 173
 		$config_vars[] = $txt['cache_smf_settings'];
166 174
 		$config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir');
167 175
 
168
-		if (!isset($context['settings_post_javascript']))
169
-			$context['settings_post_javascript'] = '';
176
+		if (!isset($context['settings_post_javascript'])) {
177
+					$context['settings_post_javascript'] = '';
178
+		}
170 179
 
171 180
 		$context['settings_post_javascript'] .= '
172 181
 			$("#cache_accelerator").change(function (e) {
@@ -187,10 +196,11 @@  discard block
 block discarded – undo
187 196
 		global $cachedir;
188 197
 
189 198
 		// If its invalid, use SMF's.
190
-		if (is_null($dir) || !is_writable($dir))
191
-			$this->cachedir = $cachedir;
192
-		else
193
-			$this->cachedir = $dir;
199
+		if (is_null($dir) || !is_writable($dir)) {
200
+					$this->cachedir = $cachedir;
201
+		} else {
202
+					$this->cachedir = $dir;
203
+		}
194 204
 	}
195 205
 
196 206
 	/**
Please login to merge, or discard this patch.
Sources/Class-CurlFetchWeb.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	* Start the curl object
63 63
 	* - allow for user override values
64 64
 	*
65
-	* @param array $options An array of cURL options
65
+	* @param integer[] $options An array of cURL options
66 66
 	* @param int $max_redirect Maximum number of redirects
67 67
 	* @return void
68 68
 	*/
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	*  - calls set_options to set the curl opts array values based on the defaults and user input
82 82
 	*
83 83
 	* @param string $url the site we are going to fetch
84
-	* @param array $post_data any post data as form name => value
85
-	* @return object An instance of the curl_fetch_web_data class
84
+	* @param string $post_data any post data as form name => value
85
+	* @return curl_fetch_web_data An instance of the curl_fetch_web_data class
86 86
 	*/
87 87
 	public function get_url_data($url, $post_data = array())
88 88
 	{
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	*
107 107
 	* @param string $url The site to fetch
108 108
 	* @param bool $redirect Whether or not this was a redirect request
109
-	* @return void|bool Sets various properties of the class or returns false if the URL isn't specified
109
+	* @return false|null Sets various properties of the class or returns false if the URL isn't specified
110 110
 	*/
111 111
 	private function curl_request($url, $redirect = false)
112 112
 	{
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	);
60 60
 
61 61
 	/**
62
-	* Start the curl object
63
-	* - allow for user override values
64
-	*
65
-	* @param array $options An array of cURL options
66
-	* @param int $max_redirect Maximum number of redirects
67
-	* @return void
68
-	*/
62
+	 * Start the curl object
63
+	 * - allow for user override values
64
+	 *
65
+	 * @param array $options An array of cURL options
66
+	 * @param int $max_redirect Maximum number of redirects
67
+	 * @return void
68
+	 */
69 69
 	public function __construct($options = array(), $max_redirect = 3)
70 70
 	{
71 71
 		// Initialize class variables
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Main calling function,
78
-	*  - will request the page data from a given $url
79
-	*  - optionally will post data to the page form if post data is supplied
80
-	*  - passed arrays will be converted to a post string joined with &'s
81
-	*  - calls set_options to set the curl opts array values based on the defaults and user input
82
-	*
83
-	* @param string $url the site we are going to fetch
84
-	* @param array $post_data any post data as form name => value
85
-	* @return object An instance of the curl_fetch_web_data class
86
-	*/
77
+	 * Main calling function,
78
+	 *  - will request the page data from a given $url
79
+	 *  - optionally will post data to the page form if post data is supplied
80
+	 *  - passed arrays will be converted to a post string joined with &'s
81
+	 *  - calls set_options to set the curl opts array values based on the defaults and user input
82
+	 *
83
+	 * @param string $url the site we are going to fetch
84
+	 * @param array $post_data any post data as form name => value
85
+	 * @return object An instance of the curl_fetch_web_data class
86
+	 */
87 87
 	public function get_url_data($url, $post_data = array())
88 88
 	{
89 89
 		// POSTing some data perhaps?
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	/**
103
-	* Makes the actual cURL call
104
-	*  - stores responses (url, code, error, headers, body) in the response array
105
-	*  - detects 301, 302, 307 codes and will redirect to the given response header location
106
-	*
107
-	* @param string $url The site to fetch
108
-	* @param bool $redirect Whether or not this was a redirect request
109
-	* @return void|bool Sets various properties of the class or returns false if the URL isn't specified
110
-	*/
103
+	 * Makes the actual cURL call
104
+	 *  - stores responses (url, code, error, headers, body) in the response array
105
+	 *  - detects 301, 302, 307 codes and will redirect to the given response header location
106
+	 *
107
+	 * @param string $url The site to fetch
108
+	 * @param bool $redirect Whether or not this was a redirect request
109
+	 * @return void|bool Sets various properties of the class or returns false if the URL isn't specified
110
+	 */
111 111
 	private function curl_request($url, $redirect = false)
112 112
 	{
113 113
 		// we do have a url I hope
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 	}
160 160
 
161 161
 	/**
162
-	* Used if being redirected to ensure we have a fully qualified address
163
-	*
164
-	* @param string $last_url The URL we went to
165
-	* @param string $new_url The URL we were redirected to
166
-	* @return string The new URL that was in the HTTP header
167
-	*/
162
+	 * Used if being redirected to ensure we have a fully qualified address
163
+	 *
164
+	 * @param string $last_url The URL we went to
165
+	 * @param string $new_url The URL we were redirected to
166
+	 * @return string The new URL that was in the HTTP header
167
+	 */
168 168
 	private function get_redirect_url($last_url = '', $new_url = '')
169 169
 	{
170 170
 		// Get the elements for these urls
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Used to return the results to the calling program
186
-	*  - called as ->result() will return the full final array
187
-	*  - called as ->result('body') to just return the page source of the result
188
-	*
189
-	* @param string $area Used to return an area such as body, header, error
190
-	* @return string The response
191
-	*/
185
+	 * Used to return the results to the calling program
186
+	 *  - called as ->result() will return the full final array
187
+	 *  - called as ->result('body') to just return the page source of the result
188
+	 *
189
+	 * @param string $area Used to return an area such as body, header, error
190
+	 * @return string The response
191
+	 */
192 192
 	public function result($area = '')
193 193
 	{
194 194
 		$max_result = count($this->response) - 1;
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Will return all results from all loops (redirects)
205
-	*  - Can be called as ->result_raw(x) where x is a specific loop results.
206
-	*  - Call as ->result_raw() for everything.
207
-	*
208
-	* @param string $response_number Which response we want to get
209
-	* @return array|string The entire response array or just the specified response
210
-	*/
204
+	 * Will return all results from all loops (redirects)
205
+	 *  - Can be called as ->result_raw(x) where x is a specific loop results.
206
+	 *  - Call as ->result_raw() for everything.
207
+	 *
208
+	 * @param string $response_number Which response we want to get
209
+	 * @return array|string The entire response array or just the specified response
210
+	 */
211 211
 	public function result_raw($response_number = '')
212 212
 	{
213 213
 		if (!is_numeric($response_number))
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 	}
221 221
 
222 222
 	/**
223
-	* Takes supplied POST data and url encodes it
224
-	*  - forms the date (for post) in to a string var=xyz&var2=abc&var3=123
225
-	*  - drops vars with @ since we don't support sending files (uploading)
226
-	*
227
-	* @param array|string $post_data The raw POST data
228
-	* @return string A string of post data
229
-	*/
223
+	 * Takes supplied POST data and url encodes it
224
+	 *  - forms the date (for post) in to a string var=xyz&var2=abc&var3=123
225
+	 *  - drops vars with @ since we don't support sending files (uploading)
226
+	 *
227
+	 * @param array|string $post_data The raw POST data
228
+	 * @return string A string of post data
229
+	 */
230 230
 	private function build_post_data($post_data)
231 231
 	{
232 232
 		if (is_array($post_data))
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	}
246 246
 
247 247
 	/**
248
-	* Sets the final cURL options for the current call
249
-	*  - overwrites our default values with user supplied ones or appends new user ones to what we have
250
-	*  - sets the callback function now that $this is existing
251
-	* @return void
252
-	*/
248
+	 * Sets the final cURL options for the current call
249
+	 *  - overwrites our default values with user supplied ones or appends new user ones to what we have
250
+	 *  - sets the callback function now that $this is existing
251
+	 * @return void
252
+	 */
253 253
 	private function set_options()
254 254
 	{
255 255
 		// Callback to parse the returned headers, if any
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 
276 276
 	/**
277
-	* Called to initiate a redirect from a 301, 302 or 307 header
278
-	*  - resets the cURL options for the loop, sets the referrer flag
279
-	*
280
-	* @param string $target_url The URL we want to redirect to
281
-	* @param string $referer_url The URL that we're redirecting from
282
-	*/
277
+	 * Called to initiate a redirect from a 301, 302 or 307 header
278
+	 *  - resets the cURL options for the loop, sets the referrer flag
279
+	 *
280
+	 * @param string $target_url The URL we want to redirect to
281
+	 * @param string $referer_url The URL that we're redirecting from
282
+	 */
283 283
 	private function redirect($target_url, $referer_url)
284 284
 	{
285 285
 		// no no I last saw that over there ... really, 301, 302, 307
@@ -289,13 +289,13 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 
291 291
 	/**
292
-	* Callback function to parse returned headers
293
-	*  - lowercases everything to make it consistent
294
-	*
295
-	* @param type $cr Not sure what this is used for?
296
-	* @param string $header The header
297
-	* @return int The length of the header
298
-	*/
292
+	 * Callback function to parse returned headers
293
+	 *  - lowercases everything to make it consistent
294
+	 *
295
+	 * @param type $cr Not sure what this is used for?
296
+	 * @param string $header The header
297
+	 * @return int The length of the header
298
+	 */
299 299
 	private function header_callback($cr, $header)
300 300
 	{
301 301
 		$_header = trim($header);
Please login to merge, or discard this patch.
Braces   +30 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
  * @version 2.1 Beta 3
11 11
  */
12 12
 
13
-if (!defined('SMF'))
13
+if (!defined('SMF')) {
14 14
 	die('No direct access...');
15
+}
15 16
 
16 17
 /**
17 18
  * Class curl_fetch_web_data
@@ -87,10 +88,11 @@  discard block
 block discarded – undo
87 88
 	public function get_url_data($url, $post_data = array())
88 89
 	{
89 90
 		// POSTing some data perhaps?
90
-		if (!empty($post_data) && is_array($post_data))
91
-			$this->post_data = $this->build_post_data($post_data);
92
-		elseif (!empty($post_data))
93
-			$this->post_data = trim($post_data);
91
+		if (!empty($post_data) && is_array($post_data)) {
92
+					$this->post_data = $this->build_post_data($post_data);
93
+		} elseif (!empty($post_data)) {
94
+					$this->post_data = trim($post_data);
95
+		}
94 96
 
95 97
 		// set the options and get it
96 98
 		$this->set_options();
@@ -111,10 +113,11 @@  discard block
 block discarded – undo
111 113
 	private function curl_request($url, $redirect = false)
112 114
 	{
113 115
 		// we do have a url I hope
114
-		if ($url == '')
115
-			return false;
116
-		else
117
-			$this->options[CURLOPT_URL] = $url;
116
+		if ($url == '') {
117
+					return false;
118
+		} else {
119
+					$this->options[CURLOPT_URL] = $url;
120
+		}
118 121
 
119 122
 		// if we have not already been redirected, set it up so we can if needed
120 123
 		if (!$redirect)
@@ -194,10 +197,11 @@  discard block
 block discarded – undo
194 197
 		$max_result = count($this->response) - 1;
195 198
 
196 199
 		// just return a specifed area or the entire result?
197
-		if ($area == '')
198
-			return $this->response[$max_result];
199
-		else
200
-			return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
200
+		if ($area == '') {
201
+					return $this->response[$max_result];
202
+		} else {
203
+					return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
204
+		}
201 205
 	}
202 206
 
203 207
 	/**
@@ -210,9 +214,9 @@  discard block
 block discarded – undo
210 214
 	*/
211 215
 	public function result_raw($response_number = '')
212 216
 	{
213
-		if (!is_numeric($response_number))
214
-			return $this->response;
215
-		else
217
+		if (!is_numeric($response_number)) {
218
+					return $this->response;
219
+		} else
216 220
 		{
217 221
 			$response_number = min($response_number, count($this->response) - 1);
218 222
 			return $this->response[$response_number];
@@ -234,13 +238,14 @@  discard block
 block discarded – undo
234 238
 			$postvars = array();
235 239
 
236 240
 			// build the post data, drop ones with leading @'s since those can be used to send files, we don't support that.
237
-			foreach ($post_data as $name => $value)
238
-				$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
241
+			foreach ($post_data as $name => $value) {
242
+							$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
243
+			}
239 244
 
240 245
 			return implode('&', $postvars);
246
+		} else {
247
+					return $post_data;
241 248
 		}
242
-		else
243
-			return $post_data;
244 249
 
245 250
 	}
246 251
 
@@ -261,9 +266,9 @@  discard block
 block discarded – undo
261 266
 			$keys = array_merge(array_keys($this->default_options), array_keys($this->user_options));
262 267
 			$vals = array_merge($this->default_options, $this->user_options);
263 268
 			$this->options = array_combine($keys, $vals);
269
+		} else {
270
+					$this->options = $this->default_options;
264 271
 		}
265
-		else
266
-			$this->options = $this->default_options;
267 272
 
268 273
 		// POST data options, here we don't allow any overide
269 274
 		if (isset($this->post_data))
@@ -302,8 +307,9 @@  discard block
 block discarded – undo
302 307
 		$temp = explode(': ', $_header, 2);
303 308
 
304 309
 		// set proper headers only
305
-		if (isset($temp[0]) && isset($temp[1]))
306
-			$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
310
+		if (isset($temp[0]) && isset($temp[1])) {
311
+					$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
312
+		}
307 313
 
308 314
 		// return the length of what was passed unless you want a Failed writing header error ;)
309 315
 		return strlen($header);
Please login to merge, or discard this patch.
Sources/Class-Graphics.php 3 patches
Doc Comments   +28 added lines patch added patch discarded remove patch
@@ -44,6 +44,10 @@  discard block
 block discarded – undo
44 44
 		$this->Buf   = range(0, 279);
45 45
 	}
46 46
 
47
+	/**
48
+	 * @param string $data
49
+	 * @param integer $datLen
50
+	 */
47 51
 	public function decompress($data, &$datLen)
48 52
 	{
49 53
 		$stLen  = strlen($data);
@@ -63,6 +67,11 @@  discard block
 block discarded – undo
63 67
 		return $ret;
64 68
 	}
65 69
 
70
+	/**
71
+	 * @param boolean $bInit
72
+	 *
73
+	 * @return integer
74
+	 */
66 75
 	public function LZWCommand(&$data, $bInit)
67 76
 	{
68 77
 		if ($bInit)
@@ -253,6 +262,10 @@  discard block
 block discarded – undo
253 262
 		unset($this->m_nColors, $this->m_arColors);
254 263
 	}
255 264
 
265
+	/**
266
+	 * @param string $lpData
267
+	 * @param integer $num
268
+	 */
256 269
 	public function load($lpData, $num)
257 270
 	{
258 271
 		$this->m_nColors  = 0;
@@ -324,6 +337,9 @@  discard block
 block discarded – undo
324 337
 		unset($this->m_bSorted, $this->m_nTableSize, $this->m_nBgColor, $this->m_nPixelRatio, $this->m_colorTable);
325 338
 	}
326 339
 
340
+	/**
341
+	 * @param integer $hdrLen
342
+	 */
327 343
 	public function load($lpData, &$hdrLen)
328 344
 	{
329 345
 		$hdrLen = 0;
@@ -370,6 +386,10 @@  discard block
 block discarded – undo
370 386
 		unset($this->m_bInterlace, $this->m_bSorted, $this->m_nTableSize, $this->m_colorTable);
371 387
 	}
372 388
 
389
+	/**
390
+	 * @param string $lpData
391
+	 * @param integer $hdrLen
392
+	 */
373 393
 	public function load($lpData, &$hdrLen)
374 394
 	{
375 395
 		$hdrLen = 0;
@@ -412,6 +432,10 @@  discard block
 block discarded – undo
412 432
 		$this->m_lzw = new gif_lzw_compression();
413 433
 	}
414 434
 
435
+	/**
436
+	 * @param string $data
437
+	 * @param integer $datLen
438
+	 */
415 439
 	public function load($data, &$datLen)
416 440
 	{
417 441
 		$datLen = 0;
@@ -464,6 +488,10 @@  discard block
 block discarded – undo
464 488
 		return false;
465 489
 	}
466 490
 
491
+	/**
492
+	 * @param string $data
493
+	 * @param integer $extLen
494
+	 */
467 495
 	public function skipExt(&$data, &$extLen)
468 496
 	{
469 497
 		$extLen = 0;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 		$this->MAX_LZW_BITS = 12;
39 39
 		unset($this->Next, $this->Vals, $this->Stack, $this->Buf);
40 40
 
41
-		$this->Next  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
42
-		$this->Vals  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
41
+		$this->Next  = range(0, (1 << $this->MAX_LZW_BITS) - 1);
42
+		$this->Vals  = range(0, (1 << $this->MAX_LZW_BITS) - 1);
43 43
 		$this->Stack = range(0, (1 << ($this->MAX_LZW_BITS + 1)) - 1);
44 44
 		$this->Buf   = range(0, 279);
45 45
 	}
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 		for ($i = 0; $i < $this->m_nColors; $i++)
279 279
 		{
280 280
 			$ret .=
281
-				chr(($this->m_arColors[$i] & 0x000000FF))       . // R
282
-				chr(($this->m_arColors[$i] & 0x0000FF00) >>  8) . // G
283
-				chr(($this->m_arColors[$i] & 0x00FF0000) >> 16);  // B
281
+				chr(($this->m_arColors[$i] & 0x000000FF)) . // R
282
+				chr(($this->m_arColors[$i] & 0x0000FF00) >> 8) . // G
283
+				chr(($this->m_arColors[$i] & 0x00FF0000) >> 16); // B
284 284
 		}
285 285
 
286 286
 		return $ret;
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	{
291 291
 		$rgb  = intval($rgb) & 0xFFFFFF;
292 292
 		$r1   = ($rgb & 0x0000FF);
293
-		$g1   = ($rgb & 0x00FF00) >>  8;
293
+		$g1   = ($rgb & 0x00FF00) >> 8;
294 294
 		$b1   = ($rgb & 0xFF0000) >> 16;
295 295
 		$idx  = -1;
296 296
 
297 297
 		for ($i = 0; $i < $this->m_nColors; $i++)
298 298
 		{
299 299
 			$r2 = ($this->m_arColors[$i] & 0x000000FF);
300
-			$g2 = ($this->m_arColors[$i] & 0x0000FF00) >>  8;
300
+			$g2 = ($this->m_arColors[$i] & 0x0000FF00) >> 8;
301 301
 			$b2 = ($this->m_arColors[$i] & 0x00FF0000) >> 16;
302 302
 			$d  = abs($r2 - $r1) + abs($g2 - $g1) + abs($b2 - $b1);
303 303
 
Please login to merge, or discard this patch.
Braces   +90 added lines, -62 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
  * @version 2.1 Beta 3
20 20
  */
21 21
 
22
-if (!defined('SMF'))
22
+if (!defined('SMF')) {
23 23
 	die('No direct access...');
24
+}
24 25
 
25 26
 /**
26 27
  * Class gif_lzw_compression
@@ -52,13 +53,15 @@  discard block
 block discarded – undo
52 53
 
53 54
 		$this->LZWCommand($data, true);
54 55
 
55
-		while (($iIndex = $this->LZWCommand($data, false)) >= 0)
56
-			$ret .= chr($iIndex);
56
+		while (($iIndex = $this->LZWCommand($data, false)) >= 0) {
57
+					$ret .= chr($iIndex);
58
+		}
57 59
 
58 60
 		$datLen = $stLen - strlen($data);
59 61
 
60
-		if ($iIndex != -2)
61
-			return false;
62
+		if ($iIndex != -2) {
63
+					return false;
64
+		}
62 65
 
63 66
 		return $ret;
64 67
 	}
@@ -140,8 +143,9 @@  discard block
 block discarded – undo
140 143
 				return $this->FirstCode;
141 144
 			}
142 145
 
143
-			if ($Code == $this->EndCode)
144
-				return -2;
146
+			if ($Code == $this->EndCode) {
147
+							return -2;
148
+			}
145 149
 
146 150
 			$InCode = $Code;
147 151
 			if ($Code >= $this->MaxCode)
@@ -156,8 +160,10 @@  discard block
 block discarded – undo
156 160
 				$this->Stack[$this->sp] = $this->Vals[$Code];
157 161
 				$this->sp++;
158 162
 
159
-				if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error!
163
+				if ($Code == $this->Next[$Code]) {
164
+					// Circular table entry, big GIF Error!
160 165
 					return -1;
166
+				}
161 167
 
162 168
 				$Code = $this->Next[$Code];
163 169
 			}
@@ -207,8 +213,9 @@  discard block
 block discarded – undo
207 213
 			if ($this->Done)
208 214
 			{
209 215
 				// Ran off the end of my bits...
210
-				if ($this->CurBit >= $this->LastBit)
211
-					return 0;
216
+				if ($this->CurBit >= $this->LastBit) {
217
+									return 0;
218
+				}
212 219
 
213 220
 				return -1;
214 221
 			}
@@ -221,13 +228,14 @@  discard block
 block discarded – undo
221 228
 
222 229
 			if ($count)
223 230
 			{
224
-				for ($i = 0; $i < $count; $i++)
225
-					$this->Buf[2 + $i] = ord($data{$i});
231
+				for ($i = 0; $i < $count; $i++) {
232
+									$this->Buf[2 + $i] = ord($data{$i});
233
+				}
226 234
 
227 235
 				$data = substr($data, $count);
236
+			} else {
237
+							$this->Done = 1;
228 238
 			}
229
-			else
230
-				$this->Done = 1;
231 239
 
232 240
 			$this->LastByte = 2 + $count;
233 241
 			$this->CurBit = ($this->CurBit - $this->LastBit) + 16;
@@ -235,8 +243,9 @@  discard block
 block discarded – undo
235 243
 		}
236 244
 
237 245
 		$iRet = 0;
238
-		for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++)
239
-			$iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j;
246
+		for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) {
247
+					$iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j;
248
+		}
240 249
 
241 250
 		$this->CurBit += $this->CodeSize;
242 251
 		return $iRet;
@@ -261,8 +270,9 @@  discard block
 block discarded – undo
261 270
 		for ($i = 0; $i < $num; $i++)
262 271
 		{
263 272
 			$rgb = substr($lpData, $i * 3, 3);
264
-			if (strlen($rgb) < 3)
265
-				return false;
273
+			if (strlen($rgb) < 3) {
274
+							return false;
275
+			}
266 276
 
267 277
 			$this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]);
268 278
 			$this->m_nColors++;
@@ -329,13 +339,15 @@  discard block
 block discarded – undo
329 339
 		$hdrLen = 0;
330 340
 
331 341
 		$this->m_lpVer = substr($lpData, 0, 6);
332
-		if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a'))
333
-			return false;
342
+		if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) {
343
+					return false;
344
+		}
334 345
 
335 346
 		list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4)));
336 347
 
337
-		if (!$this->m_nWidth || !$this->m_nHeight)
338
-			return false;
348
+		if (!$this->m_nWidth || !$this->m_nHeight) {
349
+					return false;
350
+		}
339 351
 
340 352
 		$b = ord(substr($lpData, 10, 1));
341 353
 		$this->m_bGlobalClr  = ($b & 0x80) ? true : false;
@@ -349,8 +361,9 @@  discard block
 block discarded – undo
349 361
 		if ($this->m_bGlobalClr)
350 362
 		{
351 363
 			$this->m_colorTable = new gif_color_table();
352
-			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize))
353
-				return false;
364
+			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
365
+							return false;
366
+			}
354 367
 
355 368
 			$hdrLen += 3 * $this->m_nTableSize;
356 369
 		}
@@ -377,8 +390,9 @@  discard block
 block discarded – undo
377 390
 		// Get the width/height/etc. from the header.
378 391
 		list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8)));
379 392
 
380
-		if (!$this->m_nWidth || !$this->m_nHeight)
381
-			return false;
393
+		if (!$this->m_nWidth || !$this->m_nHeight) {
394
+					return false;
395
+		}
382 396
 
383 397
 		$b = ord($lpData[8]);
384 398
 		$this->m_bLocalClr  = ($b & 0x80) ? true : false;
@@ -390,8 +404,9 @@  discard block
 block discarded – undo
390 404
 		if ($this->m_bLocalClr)
391 405
 		{
392 406
 			$this->m_colorTable = new gif_color_table();
393
-			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize))
394
-				return false;
407
+			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
408
+							return false;
409
+			}
395 410
 
396 411
 			$hdrLen += 3 * $this->m_nTableSize;
397 412
 		}
@@ -427,8 +442,9 @@  discard block
 block discarded – undo
427 442
 			// Extension...
428 443
 				case 0x21:
429 444
 					$len = 0;
430
-					if (!$this->skipExt($data, $len))
431
-						return false;
445
+					if (!$this->skipExt($data, $len)) {
446
+											return false;
447
+					}
432 448
 
433 449
 					$datLen += $len;
434 450
 					break;
@@ -437,22 +453,25 @@  discard block
 block discarded – undo
437 453
 				case 0x2C:
438 454
 					// Load the header and color table.
439 455
 					$len = 0;
440
-					if (!$this->m_gih->load($data, $len))
441
-						return false;
456
+					if (!$this->m_gih->load($data, $len)) {
457
+											return false;
458
+					}
442 459
 
443 460
 					$data = substr($data, $len);
444 461
 					$datLen += $len;
445 462
 
446 463
 					// Decompress the data, and ride on home ;).
447 464
 					$len = 0;
448
-					if (!($this->m_data = $this->m_lzw->decompress($data, $len)))
449
-						return false;
465
+					if (!($this->m_data = $this->m_lzw->decompress($data, $len))) {
466
+											return false;
467
+					}
450 468
 
451 469
 					$data = substr($data, $len);
452 470
 					$datLen += $len;
453 471
 
454
-					if ($this->m_gih->m_bInterlace)
455
-						$this->deInterlace();
472
+					if ($this->m_gih->m_bInterlace) {
473
+											$this->deInterlace();
474
+					}
456 475
 
457 476
 					return true;
458 477
 
@@ -572,17 +591,20 @@  discard block
 block discarded – undo
572 591
 
573 592
 	public function loadFile($filename, $iIndex)
574 593
 	{
575
-		if ($iIndex < 0)
576
-			return false;
594
+		if ($iIndex < 0) {
595
+					return false;
596
+		}
577 597
 
578 598
 		$this->data = @file_get_contents($filename);
579
-		if ($this->data === false)
580
-			return false;
599
+		if ($this->data === false) {
600
+					return false;
601
+		}
581 602
 
582 603
 		// Tell the header to load up....
583 604
 		$len = 0;
584
-		if (!$this->header->load($this->data, $len))
585
-			return false;
605
+		if (!$this->header->load($this->data, $len)) {
606
+					return false;
607
+		}
586 608
 
587 609
 		$this->data = substr($this->data, $len);
588 610
 
@@ -590,8 +612,9 @@  discard block
 block discarded – undo
590 612
 		for ($j = 0; $j <= $iIndex; $j++)
591 613
 		{
592 614
 			$imgLen = 0;
593
-			if (!$this->image->load($this->data, $imgLen))
594
-				return false;
615
+			if (!$this->image->load($this->data, $imgLen)) {
616
+							return false;
617
+			}
595 618
 
596 619
 			$this->data = substr($this->data, $imgLen);
597 620
 		}
@@ -602,8 +625,9 @@  discard block
 block discarded – undo
602 625
 
603 626
 	public function get_png_data($background_color)
604 627
 	{
605
-		if (!$this->loaded)
606
-			return false;
628
+		if (!$this->loaded) {
629
+					return false;
630
+		}
607 631
 
608 632
 		// Prepare the color table.
609 633
 		if ($this->image->m_gih->m_bLocalClr)
@@ -611,25 +635,26 @@  discard block
 block discarded – undo
611 635
 			$colors = $this->image->m_gih->m_nTableSize;
612 636
 			$pal = $this->image->m_gih->m_colorTable->toString();
613 637
 
614
-			if ($background_color != -1)
615
-				$background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color);
616
-		}
617
-		elseif ($this->header->m_bGlobalClr)
638
+			if ($background_color != -1) {
639
+							$background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color);
640
+			}
641
+		} elseif ($this->header->m_bGlobalClr)
618 642
 		{
619 643
 			$colors = $this->header->m_nTableSize;
620 644
 			$pal = $this->header->m_colorTable->toString();
621 645
 
622
-			if ($background_color != -1)
623
-				$background_color = $this->header->m_colorTable->colorIndex($background_color);
624
-		}
625
-		else
646
+			if ($background_color != -1) {
647
+							$background_color = $this->header->m_colorTable->colorIndex($background_color);
648
+			}
649
+		} else
626 650
 		{
627 651
 			$colors = 0;
628 652
 			$background_color = -1;
629 653
 		}
630 654
 
631
-		if ($background_color == -1)
632
-			$background_color = $this->header->m_nBgColor;
655
+		if ($background_color == -1) {
656
+					$background_color = $this->header->m_nBgColor;
657
+		}
633 658
 
634 659
 		$data = &$this->image->m_data;
635 660
 		$header = &$this->image->m_gih;
@@ -645,11 +670,13 @@  discard block
 block discarded – undo
645 670
 			for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++)
646 671
 			{
647 672
 				// Is this in the proper range?  If so, get the specific pixel data...
648
-				if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight))
649
-					$bmp .= $data{$i};
673
+				if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) {
674
+									$bmp .= $data{$i};
675
+				}
650 676
 				// Otherwise, this is background...
651
-				else
652
-					$bmp .= chr($background_color);
677
+				else {
678
+									$bmp .= chr($background_color);
679
+				}
653 680
 			}
654 681
 		}
655 682
 
@@ -678,8 +705,9 @@  discard block
 block discarded – undo
678 705
 			$tmp = 'tRNS';
679 706
 
680 707
 			// Stick each color on - full transparency or none.
681
-			for ($i = 0; $i < $colors; $i++)
682
-				$tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF";
708
+			for ($i = 0; $i < $colors; $i++) {
709
+							$tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF";
710
+			}
683 711
 
684 712
 			$out .= $tmp . pack('N', smf_crc32($tmp));
685 713
 		}
Please login to merge, or discard this patch.
Sources/Class-Package.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * of elements, an array of xmlArray's is returned for use with foreach.
258 258
 	 * Example use:
259 259
 	 *  foreach ($xml->set('html/body/p') as $p)
260
-	 * @param $path string The path to search for.
260
+	 * @param string $path string The path to search for.
261 261
 	 * @return array An array of xmlArray objects
262 262
 	 */
263 263
 	public function set($path)
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 	 * Changes a files atrributes (chmod)
856 856
 	 *
857 857
 	 * @param string $ftp_file The file to CHMOD
858
-	 * @param int|string $chmod The value for the CHMOD operation
858
+	 * @param integer $chmod The value for the CHMOD operation
859 859
 	 * @return boolean Whether or not the operation was successful
860 860
 	 */
861 861
 	public function chmod($ftp_file, $chmod)
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 	 *
1026 1026
 	 * @param string $ftp_path The path to the directory
1027 1027
 	 * @param bool $search Whether or not to get a recursive directory listing
1028
-	 * @return string|boolean The results of the command or false if unsuccessful
1028
+	 * @return false|string The results of the command or false if unsuccessful
1029 1029
 	 */
1030 1030
 	public function list_dir($ftp_path = '', $search = false)
1031 1031
 	{
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	 *
1071 1071
 	 * @param string $file The name of a file
1072 1072
 	 * @param string $listing A directory listing or null to generate one
1073
-	 * @return string|boolean The name of the file or false if it wasn't found
1073
+	 * @return string|false The name of the file or false if it wasn't found
1074 1074
 	 */
1075 1075
 	public function locate($file, $listing = null)
1076 1076
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 		if (!$this->connection)
794 794
 		{
795 795
 			$this->error = 'bad_server';
796
-            		$this->last_message = 'Invalid Server';
796
+					$this->last_message = 'Invalid Server';
797 797
 			return;
798 798
 		}
799 799
 
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 		if (!$this->check_response(220))
802 802
 		{
803 803
 			$this->error = 'bad_response';
804
-		        $this->last_message = 'Bad Response';
804
+				$this->last_message = 'Bad Response';
805 805
 			return;
806 806
 		}
807 807
 
Please login to merge, or discard this patch.
Braces   +266 added lines, -199 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
  * Class xmlArray
@@ -65,8 +66,9 @@  discard block
 block discarded – undo
65 66
 		}
66 67
 
67 68
 		// Is the input an array? (ie. passed from file()?)
68
-		if (is_array($data))
69
-			$data = implode('', $data);
69
+		if (is_array($data)) {
70
+					$data = implode('', $data);
71
+		}
70 72
 
71 73
 		// Remove any xml declaration or doctype, and parse out comments and CDATA.
72 74
 		$data = preg_replace('/<!--.*?-->/s', '', $this->_to_cdata(preg_replace(array('/^<\?xml.+?\?' . '>/is', '/<!DOCTYPE[^>]+?' . '>/s'), '', $data)));
@@ -101,8 +103,9 @@  discard block
 block discarded – undo
101 103
 		// Get the element, in array form.
102 104
 		$array = $this->path($path);
103 105
 
104
-		if ($array === false)
105
-			return false;
106
+		if ($array === false) {
107
+					return false;
108
+		}
106 109
 
107 110
 		// Getting elements into this is a bit complicated...
108 111
 		if ($get_elements && !is_string($array))
@@ -113,8 +116,9 @@  discard block
 block discarded – undo
113 116
 			foreach ($array->array as $val)
114 117
 			{
115 118
 				// Skip the name and any attributes.
116
-				if (is_array($val))
117
-					$temp .= $this->_xml($val, null);
119
+				if (is_array($val)) {
120
+									$temp .= $this->_xml($val, null);
121
+				}
118 122
 			}
119 123
 
120 124
 			// Just get the XML data and then take out the CDATAs.
@@ -156,32 +160,35 @@  discard block
 block discarded – undo
156 160
 			elseif (substr($el, 0, 1) == '@')
157 161
 			{
158 162
 				// It simplifies things if the attribute is already there ;).
159
-				if (isset($array[$el]))
160
-					return $array[$el];
161
-				else
163
+				if (isset($array[$el])) {
164
+									return $array[$el];
165
+				} else
162 166
 				{
163 167
 					$trace = debug_backtrace();
164 168
 					$i = 0;
165
-					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
166
-						$i++;
169
+					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
170
+											$i++;
171
+					}
167 172
 					$debug = ' (from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'] . ')';
168 173
 
169 174
 					// Cause an error.
170
-					if ($this->debug_level & E_NOTICE)
171
-						trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
175
+					if ($this->debug_level & E_NOTICE) {
176
+											trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
177
+					}
172 178
 					return false;
173 179
 				}
180
+			} else {
181
+							$lvl = null;
174 182
 			}
175
-			else
176
-				$lvl = null;
177 183
 
178 184
 			// Find this element.
179 185
 			$array = $this->_path($array, $el, $lvl);
180 186
 		}
181 187
 
182 188
 		// Clean up after $lvl, for $return_full.
183
-		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']'))
184
-			$array = array('name' => $el . '[]', $array);
189
+		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) {
190
+					$array = array('name' => $el . '[]', $array);
191
+		}
185 192
 
186 193
 		// Create the right type of class...
187 194
 		$newClass = get_class($this);
@@ -216,10 +223,11 @@  discard block
 block discarded – undo
216 223
 				$el = substr($el, 0, strpos($el, '['));
217 224
 			}
218 225
 			// Find an attribute.
219
-			elseif (substr($el, 0, 1) == '@')
220
-				return isset($array[$el]);
221
-			else
222
-				$lvl = null;
226
+			elseif (substr($el, 0, 1) == '@') {
227
+							return isset($array[$el]);
228
+			} else {
229
+							$lvl = null;
230
+			}
223 231
 
224 232
 			// Find this element.
225 233
 			$array = $this->_path($array, $el, $lvl, true);
@@ -244,8 +252,9 @@  discard block
 block discarded – undo
244 252
 		$i = 0;
245 253
 		foreach ($temp->array as $item)
246 254
 		{
247
-			if (is_array($item))
248
-				$i++;
255
+			if (is_array($item)) {
256
+							$i++;
257
+			}
249 258
 		}
250 259
 
251 260
 		return $i;
@@ -269,8 +278,9 @@  discard block
 block discarded – undo
269 278
 		foreach ($xml->array as $val)
270 279
 		{
271 280
 			// Skip these, they aren't elements.
272
-			if (!is_array($val) || $val['name'] == '!')
273
-				continue;
281
+			if (!is_array($val) || $val['name'] == '!') {
282
+							continue;
283
+			}
274 284
 
275 285
 			// Create the right type of class...
276 286
 			$newClass = get_class($this);
@@ -297,14 +307,16 @@  discard block
 block discarded – undo
297 307
 			$path = $this->path($path);
298 308
 
299 309
 			// The path was not found
300
-			if ($path === false)
301
-				return false;
310
+			if ($path === false) {
311
+							return false;
312
+			}
302 313
 
303 314
 			$path = $path->array;
304 315
 		}
305 316
 		// Just use the current array.
306
-		else
307
-			$path = $this->array;
317
+		else {
318
+					$path = $this->array;
319
+		}
308 320
 
309 321
 		// Add the xml declaration to the front.
310 322
 		return '<?xml version="1.0"?' . '>' . $this->_xml($path, 0);
@@ -326,14 +338,16 @@  discard block
 block discarded – undo
326 338
 			$path = $this->path($path);
327 339
 
328 340
 			// The path was not found
329
-			if ($path === false)
330
-				return false;
341
+			if ($path === false) {
342
+							return false;
343
+			}
331 344
 
332 345
 			$path = $path->array;
333 346
 		}
334 347
 		// No, so just use the current array.
335
-		else
336
-			$path = $this->array;
348
+		else {
349
+					$path = $this->array;
350
+		}
337 351
 
338 352
 		return $this->_array($path);
339 353
 	}
@@ -355,8 +369,9 @@  discard block
 block discarded – undo
355 369
 		{
356 370
 			// Find and remove the next tag.
357 371
 			preg_match('/\A<([\w\-:]+)((?:\s+.+?)?)([\s]?\/)?' . '>/', $data, $match);
358
-			if (isset($match[0]))
359
-				$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
372
+			if (isset($match[0])) {
373
+							$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
374
+			}
360 375
 
361 376
 			// Didn't find a tag?  Keep looping....
362 377
 			if (!isset($match[1]) || $match[1] == '')
@@ -367,11 +382,12 @@  discard block
 block discarded – undo
367 382
 					$text_value = $this->_from_cdata($data);
368 383
 					$data = '';
369 384
 
370
-					if ($text_value != '')
371
-						$current[] = array(
385
+					if ($text_value != '') {
386
+											$current[] = array(
372 387
 							'name' => '!',
373 388
 							'value' => $text_value
374 389
 						);
390
+					}
375 391
 				}
376 392
 				// If the < isn't immediately next to the current position... more data.
377 393
 				elseif (strpos($data, '<') > 0)
@@ -379,11 +395,12 @@  discard block
 block discarded – undo
379 395
 					$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<')));
380 396
 					$data = substr($data, strpos($data, '<'));
381 397
 
382
-					if ($text_value != '')
383
-						$current[] = array(
398
+					if ($text_value != '') {
399
+											$current[] = array(
384 400
 							'name' => '!',
385 401
 							'value' => $text_value
386 402
 						);
403
+					}
387 404
 				}
388 405
 				// If we're looking at a </something> with no start, kill it.
389 406
 				elseif (strpos($data, '<') !== false && strpos($data, '<') == 0)
@@ -393,22 +410,23 @@  discard block
 block discarded – undo
393 410
 						$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<', 1)));
394 411
 						$data = substr($data, strpos($data, '<', 1));
395 412
 
396
-						if ($text_value != '')
397
-							$current[] = array(
413
+						if ($text_value != '') {
414
+													$current[] = array(
398 415
 								'name' => '!',
399 416
 								'value' => $text_value
400 417
 							);
401
-					}
402
-					else
418
+						}
419
+					} else
403 420
 					{
404 421
 						$text_value = $this->_from_cdata($data);
405 422
 						$data = '';
406 423
 
407
-						if ($text_value != '')
408
-							$current[] = array(
424
+						if ($text_value != '') {
425
+													$current[] = array(
409 426
 								'name' => '!',
410 427
 								'value' => $text_value
411 428
 							);
429
+						}
412 430
 					}
413 431
 				}
414 432
 
@@ -425,8 +443,9 @@  discard block
 block discarded – undo
425 443
 			{
426 444
 				// Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way.
427 445
 				$last_tag_end = strpos($data, '</' . $match[1]. '>');
428
-				if ($last_tag_end === false)
429
-					continue;
446
+				if ($last_tag_end === false) {
447
+									continue;
448
+				}
430 449
 
431 450
 				$offset = 0;
432 451
 				while (1 == 1)
@@ -434,16 +453,17 @@  discard block
 block discarded – undo
434 453
 					// Where is the next start tag?
435 454
 					$next_tag_start = strpos($data, '<' . $match[1], $offset);
436 455
 					// If the next start tag is after the last end tag then we've found the right close.
437
-					if ($next_tag_start === false || $next_tag_start > $last_tag_end)
438
-						break;
456
+					if ($next_tag_start === false || $next_tag_start > $last_tag_end) {
457
+											break;
458
+					}
439 459
 
440 460
 					// If not then find the next ending tag.
441 461
 					$next_tag_end = strpos($data, '</' . $match[1]. '>', $offset);
442 462
 
443 463
 					// Didn't find one? Then just use the last and sod it.
444
-					if ($next_tag_end === false)
445
-						break;
446
-					else
464
+					if ($next_tag_end === false) {
465
+											break;
466
+					} else
447 467
 					{
448 468
 						$last_tag_end = $next_tag_end;
449 469
 						$offset = $next_tag_start + 1;
@@ -457,16 +477,17 @@  discard block
 block discarded – undo
457 477
 				if (!empty($inner_match))
458 478
 				{
459 479
 					// Parse the inner data.
460
-					if (strpos($inner_match, '<') !== false)
461
-						$el += $this->_parse($inner_match);
462
-					elseif (trim($inner_match) != '')
480
+					if (strpos($inner_match, '<') !== false) {
481
+											$el += $this->_parse($inner_match);
482
+					} elseif (trim($inner_match) != '')
463 483
 					{
464 484
 						$text_value = $this->_from_cdata($inner_match);
465
-						if ($text_value != '')
466
-							$el[] = array(
485
+						if ($text_value != '') {
486
+													$el[] = array(
467 487
 								'name' => '!',
468 488
 								'value' => $text_value
469 489
 							);
490
+						}
470 491
 					}
471 492
 				}
472 493
 			}
@@ -478,8 +499,9 @@  discard block
 block discarded – undo
478 499
 				preg_match_all('/([\w:]+)="(.+?)"/', $match[2], $attr, PREG_SET_ORDER);
479 500
 
480 501
 				// Set them as @attribute-name.
481
-				foreach ($attr as $match_attr)
482
-					$el['@' . $match_attr[1]] = $match_attr[2];
502
+				foreach ($attr as $match_attr) {
503
+									$el['@' . $match_attr[1]] = $match_attr[2];
504
+				}
483 505
 			}
484 506
 		}
485 507
 
@@ -503,16 +525,18 @@  discard block
 block discarded – undo
503 525
 		if (is_array($array) && !isset($array['name']))
504 526
 		{
505 527
 			$temp = '';
506
-			foreach ($array as $val)
507
-				$temp .= $this->_xml($val, $indent);
528
+			foreach ($array as $val) {
529
+							$temp .= $this->_xml($val, $indent);
530
+			}
508 531
 			return $temp;
509 532
 		}
510 533
 
511 534
 		// This is just text!
512
-		if ($array['name'] == '!')
513
-			return $indentation . '<![CDATA[' . $array['value'] . ']]>';
514
-		elseif (substr($array['name'], -2) == '[]')
515
-			$array['name'] = substr($array['name'], 0, -2);
535
+		if ($array['name'] == '!') {
536
+					return $indentation . '<![CDATA[' . $array['value'] . ']]>';
537
+		} elseif (substr($array['name'], -2) == '[]') {
538
+					$array['name'] = substr($array['name'], 0, -2);
539
+		}
516 540
 
517 541
 		// Start the element.
518 542
 		$output = $indentation . '<' . $array['name'];
@@ -523,9 +547,9 @@  discard block
 block discarded – undo
523 547
 		// Run through and recursively output all the elements or attrbutes inside this.
524 548
 		foreach ($array as $k => $v)
525 549
 		{
526
-			if (substr($k, 0, 1) == '@')
527
-				$output .= ' ' . substr($k, 1) . '="' . $v . '"';
528
-			elseif (is_array($v))
550
+			if (substr($k, 0, 1) == '@') {
551
+							$output .= ' ' . substr($k, 1) . '="' . $v . '"';
552
+			} elseif (is_array($v))
529 553
 			{
530 554
 				$output_el .= $this->_xml($v, $indent === null ? null : $indent + 1);
531 555
 				$inside_elements = true;
@@ -533,10 +557,11 @@  discard block
 block discarded – undo
533 557
 		}
534 558
 
535 559
 		// Indent, if necessary.... then close the tag.
536
-		if ($inside_elements)
537
-			$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
538
-		else
539
-			$output .= ' />';
560
+		if ($inside_elements) {
561
+					$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
562
+		} else {
563
+					$output .= ' />';
564
+		}
540 565
 
541 566
 		return $output;
542 567
 	}
@@ -553,19 +578,22 @@  discard block
 block discarded – undo
553 578
 		$text = '';
554 579
 		foreach ($array as $value)
555 580
 		{
556
-			if (!is_array($value) || !isset($value['name']))
557
-				continue;
581
+			if (!is_array($value) || !isset($value['name'])) {
582
+							continue;
583
+			}
558 584
 
559
-			if ($value['name'] == '!')
560
-				$text .= $value['value'];
561
-			else
562
-				$return[$value['name']] = $this->_array($value);
585
+			if ($value['name'] == '!') {
586
+							$text .= $value['value'];
587
+			} else {
588
+							$return[$value['name']] = $this->_array($value);
589
+			}
563 590
 		}
564 591
 
565
-		if (empty($return))
566
-			return $text;
567
-		else
568
-			return $return;
592
+		if (empty($return)) {
593
+					return $text;
594
+		} else {
595
+					return $return;
596
+		}
569 597
 	}
570 598
 
571 599
 	/**
@@ -583,24 +611,28 @@  discard block
 block discarded – undo
583 611
 		foreach ($parts as $part)
584 612
 		{
585 613
 			// Handle XML comments.
586
-			if (!$inCdata && $part === '<!--')
587
-				$inComment = true;
588
-			if ($inComment && $part === '-->')
589
-				$inComment = false;
590
-			elseif ($inComment)
591
-				continue;
614
+			if (!$inCdata && $part === '<!--') {
615
+							$inComment = true;
616
+			}
617
+			if ($inComment && $part === '-->') {
618
+							$inComment = false;
619
+			} elseif ($inComment) {
620
+							continue;
621
+			}
592 622
 
593 623
 			// Handle Cdata blocks.
594
-			elseif (!$inComment && $part === '<![CDATA[')
595
-				$inCdata = true;
596
-			elseif ($inCdata && $part === ']]>')
597
-				$inCdata = false;
598
-			elseif ($inCdata)
599
-				$output .= htmlentities($part, ENT_QUOTES);
624
+			elseif (!$inComment && $part === '<![CDATA[') {
625
+							$inCdata = true;
626
+			} elseif ($inCdata && $part === ']]>') {
627
+							$inCdata = false;
628
+			} elseif ($inCdata) {
629
+							$output .= htmlentities($part, ENT_QUOTES);
630
+			}
600 631
 
601 632
 			// Everything else is kept as is.
602
-			else
603
-				$output .= $part;
633
+			else {
634
+							$output .= $part;
635
+			}
604 636
 		}
605 637
 
606 638
 		return $output;
@@ -635,22 +667,26 @@  discard block
 block discarded – undo
635 667
 	protected function _fetch($array)
636 668
 	{
637 669
 		// Don't return anything if this is just a string.
638
-		if (is_string($array))
639
-			return '';
670
+		if (is_string($array)) {
671
+					return '';
672
+		}
640 673
 
641 674
 		$temp = '';
642 675
 		foreach ($array as $text)
643 676
 		{
644 677
 			// This means it's most likely an attribute or the name itself.
645
-			if (!isset($text['name']))
646
-				continue;
678
+			if (!isset($text['name'])) {
679
+							continue;
680
+			}
647 681
 
648 682
 			// This is text!
649
-			if ($text['name'] == '!')
650
-				$temp .= $text['value'];
683
+			if ($text['name'] == '!') {
684
+							$temp .= $text['value'];
685
+			}
651 686
 			// Another element - dive in ;).
652
-			else
653
-				$temp .= $this->_fetch($text);
687
+			else {
688
+							$temp .= $this->_fetch($text);
689
+			}
654 690
 		}
655 691
 
656 692
 		// Return all the bits and pieces we've put together.
@@ -669,12 +705,14 @@  discard block
 block discarded – undo
669 705
 	protected function _path($array, $path, $level, $no_error = false)
670 706
 	{
671 707
 		// Is $array even an array?  It might be false!
672
-		if (!is_array($array))
673
-			return false;
708
+		if (!is_array($array)) {
709
+					return false;
710
+		}
674 711
 
675 712
 		// Asking for *no* path?
676
-		if ($path == '' || $path == '.')
677
-			return $array;
713
+		if ($path == '' || $path == '.') {
714
+					return $array;
715
+		}
678 716
 		$paths = explode('|', $path);
679 717
 
680 718
 		// A * means all elements of any name.
@@ -685,16 +723,18 @@  discard block
 block discarded – undo
685 723
 		// Check each element.
686 724
 		foreach ($array as $value)
687 725
 		{
688
-			if (!is_array($value) || $value['name'] === '!')
689
-				continue;
726
+			if (!is_array($value) || $value['name'] === '!') {
727
+							continue;
728
+			}
690 729
 
691 730
 			if ($show_all || in_array($value['name'], $paths))
692 731
 			{
693 732
 				// Skip elements before "the one".
694
-				if ($level !== null && $level > 0)
695
-					$level--;
696
-				else
697
-					$results[] = $value;
733
+				if ($level !== null && $level > 0) {
734
+									$level--;
735
+				} else {
736
+									$results[] = $value;
737
+				}
698 738
 			}
699 739
 		}
700 740
 
@@ -703,21 +743,25 @@  discard block
 block discarded – undo
703 743
 		{
704 744
 			$trace = debug_backtrace();
705 745
 			$i = 0;
706
-			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
707
-				$i++;
746
+			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
747
+							$i++;
748
+			}
708 749
 			$debug = ' from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'];
709 750
 
710 751
 			// Cause an error.
711
-			if ($this->debug_level & E_NOTICE && !$no_error)
712
-				trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
752
+			if ($this->debug_level & E_NOTICE && !$no_error) {
753
+							trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
754
+			}
713 755
 			return false;
714 756
 		}
715 757
 		// Only one result.
716
-		elseif (count($results) == 1 || $level !== null)
717
-			return $results[0];
758
+		elseif (count($results) == 1 || $level !== null) {
759
+					return $results[0];
760
+		}
718 761
 		// Return the result set.
719
-		else
720
-			return $results + array('name' => $path . '[]');
762
+		else {
763
+					return $results + array('name' => $path . '[]');
764
+		}
721 765
 	}
722 766
 }
723 767
 
@@ -764,8 +808,9 @@  discard block
 block discarded – undo
764 808
 		$this->error = false;
765 809
 		$this->pasv = array();
766 810
 
767
-		if ($ftp_server !== null)
768
-			$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
811
+		if ($ftp_server !== null) {
812
+					$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
813
+		}
769 814
 	}
770 815
 
771 816
 	/**
@@ -778,14 +823,16 @@  discard block
 block discarded – undo
778 823
 	 */
779 824
 	public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
780 825
 	{
781
-		if (strpos($ftp_server, 'ftp://') === 0)
782
-			$ftp_server = substr($ftp_server, 6);
783
-		elseif (strpos($ftp_server, 'ftps://') === 0)
784
-			$ftp_server = 'ssl://' . substr($ftp_server, 7);
785
-		if (strpos($ftp_server, 'http://') === 0)
786
-			$ftp_server = substr($ftp_server, 7);
787
-		elseif (strpos($ftp_server, 'https://') === 0)
788
-			$ftp_server = substr($ftp_server, 8);
826
+		if (strpos($ftp_server, 'ftp://') === 0) {
827
+					$ftp_server = substr($ftp_server, 6);
828
+		} elseif (strpos($ftp_server, 'ftps://') === 0) {
829
+					$ftp_server = 'ssl://' . substr($ftp_server, 7);
830
+		}
831
+		if (strpos($ftp_server, 'http://') === 0) {
832
+					$ftp_server = substr($ftp_server, 7);
833
+		} elseif (strpos($ftp_server, 'https://') === 0) {
834
+					$ftp_server = substr($ftp_server, 8);
835
+		}
789 836
 		$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
790 837
 
791 838
 		// Connect to the FTP server.
@@ -834,12 +881,14 @@  discard block
 block discarded – undo
834 881
 	 */
835 882
 	public function chdir($ftp_path)
836 883
 	{
837
-		if (!is_resource($this->connection))
838
-			return false;
884
+		if (!is_resource($this->connection)) {
885
+					return false;
886
+		}
839 887
 
840 888
 		// No slash on the end, please...
841
-		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/')
842
-			$ftp_path = substr($ftp_path, 0, -1);
889
+		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') {
890
+					$ftp_path = substr($ftp_path, 0, -1);
891
+		}
843 892
 
844 893
 		fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
845 894
 		if (!$this->check_response(250))
@@ -860,11 +909,13 @@  discard block
 block discarded – undo
860 909
 	 */
861 910
 	public function chmod($ftp_file, $chmod)
862 911
 	{
863
-		if (!is_resource($this->connection))
864
-			return false;
912
+		if (!is_resource($this->connection)) {
913
+					return false;
914
+		}
865 915
 
866
-		if ($ftp_file == '')
867
-			$ftp_file = '.';
916
+		if ($ftp_file == '') {
917
+					$ftp_file = '.';
918
+		}
868 919
 
869 920
 		// Do we have a file or a dir?
870 921
 		$is_dir = is_dir($ftp_file);
@@ -880,9 +931,7 @@  discard block
 block discarded – undo
880 931
 			{
881 932
 				$is_writable = true;
882 933
 				break;
883
-			}
884
-
885
-			else
934
+			} else
886 935
 			{
887 936
 				// Convert the chmod value from octal (0777) to text ("777").
888 937
 				fwrite($this->connection, 'SITE CHMOD ' . decoct($val) . ' ' . $ftp_file . "\r\n");
@@ -905,8 +954,9 @@  discard block
 block discarded – undo
905 954
 	public function unlink($ftp_file)
906 955
 	{
907 956
 		// We are actually connected, right?
908
-		if (!is_resource($this->connection))
909
-			return false;
957
+		if (!is_resource($this->connection)) {
958
+					return false;
959
+		}
910 960
 
911 961
 		// Delete file X.
912 962
 		fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
@@ -935,9 +985,9 @@  discard block
 block discarded – undo
935 985
 	{
936 986
 		// Wait for a response that isn't continued with -, but don't wait too long.
937 987
 		$time = time();
938
-		do
939
-			$this->last_message = fgets($this->connection, 1024);
940
-		while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
988
+		do {
989
+					$this->last_message = fgets($this->connection, 1024);
990
+		} while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
941 991
 
942 992
 		// Was the desired response returned?
943 993
 		return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
@@ -951,15 +1001,16 @@  discard block
 block discarded – undo
951 1001
 	public function passive()
952 1002
 	{
953 1003
 		// We can't create a passive data connection without a primary one first being there.
954
-		if (!is_resource($this->connection))
955
-			return false;
1004
+		if (!is_resource($this->connection)) {
1005
+					return false;
1006
+		}
956 1007
 
957 1008
 		// Request a passive connection - this means, we'll talk to you, you don't talk to us.
958 1009
 		@fwrite($this->connection, 'PASV' . "\r\n");
959 1010
 		$time = time();
960
-		do
961
-			$response = fgets($this->connection, 1024);
962
-		while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
1011
+		do {
1012
+					$response = fgets($this->connection, 1024);
1013
+		} while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
963 1014
 
964 1015
 		// If it's not 227, we weren't given an IP and port, which means it failed.
965 1016
 		if (strpos($response, '227 ') !== 0)
@@ -990,12 +1041,14 @@  discard block
 block discarded – undo
990 1041
 	public function create_file($ftp_file)
991 1042
 	{
992 1043
 		// First, we have to be connected... very important.
993
-		if (!is_resource($this->connection))
994
-			return false;
1044
+		if (!is_resource($this->connection)) {
1045
+					return false;
1046
+		}
995 1047
 
996 1048
 		// I'd like one passive mode, please!
997
-		if (!$this->passive())
998
-			return false;
1049
+		if (!$this->passive()) {
1050
+					return false;
1051
+		}
999 1052
 
1000 1053
 		// Seems logical enough, so far...
1001 1054
 		fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
@@ -1030,12 +1083,14 @@  discard block
 block discarded – undo
1030 1083
 	public function list_dir($ftp_path = '', $search = false)
1031 1084
 	{
1032 1085
 		// Are we even connected...?
1033
-		if (!is_resource($this->connection))
1034
-			return false;
1086
+		if (!is_resource($this->connection)) {
1087
+					return false;
1088
+		}
1035 1089
 
1036 1090
 		// Passive... non-agressive...
1037
-		if (!$this->passive())
1038
-			return false;
1091
+		if (!$this->passive()) {
1092
+					return false;
1093
+		}
1039 1094
 
1040 1095
 		// Get the listing!
1041 1096
 		fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
@@ -1051,8 +1106,9 @@  discard block
 block discarded – undo
1051 1106
 
1052 1107
 		// Read in the file listing.
1053 1108
 		$data = '';
1054
-		while (!feof($fp))
1055
-			$data .= fread($fp, 4096);
1109
+		while (!feof($fp)) {
1110
+					$data .= fread($fp, 4096);
1111
+		}
1056 1112
 		fclose($fp);
1057 1113
 
1058 1114
 		// Everything go okay?
@@ -1074,21 +1130,23 @@  discard block
 block discarded – undo
1074 1130
 	 */
1075 1131
 	public function locate($file, $listing = null)
1076 1132
 	{
1077
-		if ($listing === null)
1078
-			$listing = $this->list_dir('', true);
1133
+		if ($listing === null) {
1134
+					$listing = $this->list_dir('', true);
1135
+		}
1079 1136
 		$listing = explode("\n", $listing);
1080 1137
 
1081 1138
 		@fwrite($this->connection, 'PWD' . "\r\n");
1082 1139
 		$time = time();
1083
-		do
1084
-			$response = fgets($this->connection, 1024);
1085
-		while ($response[3] != ' ' && time() - $time < 5);
1140
+		do {
1141
+					$response = fgets($this->connection, 1024);
1142
+		} while ($response[3] != ' ' && time() - $time < 5);
1086 1143
 
1087 1144
 		// Check for 257!
1088
-		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
1089
-			$current_dir = strtr($match[1], array('""' => '"'));
1090
-		else
1091
-			$current_dir = '';
1145
+		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) {
1146
+					$current_dir = strtr($match[1], array('""' => '"'));
1147
+		} else {
1148
+					$current_dir = '';
1149
+		}
1092 1150
 
1093 1151
 		for ($i = 0, $n = count($listing); $i < $n; $i++)
1094 1152
 		{
@@ -1101,12 +1159,15 @@  discard block
 block discarded – undo
1101 1159
 			// Okay, this file's name is:
1102 1160
 			$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
1103 1161
 
1104
-			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
1105
-				return $listing[$i];
1106
-			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
1107
-				return $listing[$i];
1108
-			if (basename($listing[$i]) == $file || $listing[$i] == $file)
1109
-				return $listing[$i];
1162
+			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) {
1163
+							return $listing[$i];
1164
+			}
1165
+			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) {
1166
+							return $listing[$i];
1167
+			}
1168
+			if (basename($listing[$i]) == $file || $listing[$i] == $file) {
1169
+							return $listing[$i];
1170
+			}
1110 1171
 		}
1111 1172
 
1112 1173
 		return false;
@@ -1121,8 +1182,9 @@  discard block
 block discarded – undo
1121 1182
 	public function create_dir($ftp_dir)
1122 1183
 	{
1123 1184
 		// We must be connected to the server to do something.
1124
-		if (!is_resource($this->connection))
1125
-			return false;
1185
+		if (!is_resource($this->connection)) {
1186
+					return false;
1187
+		}
1126 1188
 
1127 1189
 		// Make this new beautiful directory!
1128 1190
 		fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
@@ -1154,35 +1216,40 @@  discard block
 block discarded – undo
1154 1216
 
1155 1217
 				$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
1156 1218
 
1157
-				if (substr($path, -1) == '/')
1158
-					$path = substr($path, 0, -1);
1219
+				if (substr($path, -1) == '/') {
1220
+									$path = substr($path, 0, -1);
1221
+				}
1159 1222
 
1160
-				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
1161
-					$path .= dirname($_SERVER['PHP_SELF']);
1223
+				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) {
1224
+									$path .= dirname($_SERVER['PHP_SELF']);
1225
+				}
1226
+			} elseif (strpos($filesystem_path, '/var/www/') === 0) {
1227
+							$path = substr($filesystem_path, 8);
1228
+			} else {
1229
+							$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1162 1230
 			}
1163
-			elseif (strpos($filesystem_path, '/var/www/') === 0)
1164
-				$path = substr($filesystem_path, 8);
1165
-			else
1166
-				$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1231
+		} else {
1232
+					$path = '';
1167 1233
 		}
1168
-		else
1169
-			$path = '';
1170 1234
 
1171 1235
 		if (is_resource($this->connection) && $this->list_dir($path) == '')
1172 1236
 		{
1173 1237
 			$data = $this->list_dir('', true);
1174 1238
 
1175
-			if ($lookup_file === null)
1176
-				$lookup_file = $_SERVER['PHP_SELF'];
1239
+			if ($lookup_file === null) {
1240
+							$lookup_file = $_SERVER['PHP_SELF'];
1241
+			}
1177 1242
 
1178 1243
 			$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
1179
-			if ($found_path == false)
1180
-				$found_path = dirname($this->locate(basename($lookup_file)));
1181
-			if ($found_path != false)
1182
-				$path = $found_path;
1244
+			if ($found_path == false) {
1245
+							$found_path = dirname($this->locate(basename($lookup_file)));
1246
+			}
1247
+			if ($found_path != false) {
1248
+							$path = $found_path;
1249
+			}
1250
+		} elseif (is_resource($this->connection)) {
1251
+					$found_path = true;
1183 1252
 		}
1184
-		elseif (is_resource($this->connection))
1185
-			$found_path = true;
1186 1253
 
1187 1254
 		return array($username, $path, isset($found_path));
1188 1255
 	}
Please login to merge, or discard this patch.
Sources/Class-SearchAPI.php 1 patch
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,6 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param array $wordsSearch Search words
57 57
 	 * @param array $wordsExclude Words to exclude
58 58
 	 * @param bool $isExcluded Whether the specfied word should be excluded
59
+	 * @return void
59 60
 	 */
60 61
 	public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, $isExcluded);
61 62
 
@@ -130,7 +131,7 @@  discard block
 block discarded – undo
130 131
 	 * @param array $excludedIndexWords Indexed words that should be excluded
131 132
 	 * @param array $participants
132 133
 	 * @param array $searchArray
133
-	 * @return mixed
134
+	 * @return integer
134 135
 	 */
135 136
 	public function searchQuery(array $query_params, array $searchWords, array $excludedIndexWords, array &$participants, array &$searchArray);
136 137
 }
Please login to merge, or discard this patch.
Sources/Class-TOTP.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Generate the timestamp for the calculation
281 281
 	 *
282
-	 * @return integer Timestamp
282
+	 * @return double Timestamp
283 283
 	 */
284 284
 	public function generateTimestamp()
285 285
 	{
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * Truncate the given hash down to just what we need
291 291
 	 *
292 292
 	 * @param string $hash Hash to truncate
293
-	 * @return string Truncated hash value
293
+	 * @return integer Truncated hash value
294 294
 	 */
295 295
 	public function truncateHash($hash)
296 296
 	{
Please login to merge, or discard this patch.
Sources/DbPackages-postgresql.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -518,7 +518,7 @@
 block discarded – undo
518 518
  * @param array $parameters Not used?
519 519
  * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated.
520 520
  * @param string $error
521
- * @return boolean Whether or not the operation was successful
521
+ * @return false|null Whether or not the operation was successful
522 522
  */
523 523
 function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
524 524
 {
Please login to merge, or discard this patch.
Braces   +110 added lines, -86 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
  * Add the file functions to the $smcFunc array.
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
 		'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages',
53 54
 		'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys',
54 55
 		'themes', 'topics');
55
-	foreach ($reservedTables as $k => $table_name)
56
-		$reservedTables[$k] = strtolower($db_prefix . $table_name);
56
+	foreach ($reservedTables as $k => $table_name) {
57
+			$reservedTables[$k] = strtolower($db_prefix . $table_name);
58
+	}
57 59
 
58 60
 	// We in turn may need the extra stuff.
59 61
 	db_extend('extra');
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
103 105
 
104 106
 	// First - no way do we touch SMF tables.
105
-	if (in_array(strtolower($table_name), $reservedTables))
106
-		return false;
107
+	if (in_array(strtolower($table_name), $reservedTables)) {
108
+			return false;
109
+	}
107 110
 
108 111
 	// Log that we'll want to remove this on uninstall.
109 112
 	$db_package_log[] = array('remove_table', $table_name);
@@ -113,10 +116,11 @@  discard block
 block discarded – undo
113 116
 	if (in_array($full_table_name, $tables))
114 117
 	{
115 118
 		// This is a sad day... drop the table? If not, return false (error) by default.
116
-		if ($if_exists == 'overwrite')
117
-			$smcFunc['db_drop_table']($table_name);
118
-		else
119
-			return $if_exists == 'ignore';
119
+		if ($if_exists == 'overwrite') {
120
+					$smcFunc['db_drop_table']($table_name);
121
+		} else {
122
+					return $if_exists == 'ignore';
123
+		}
120 124
 	}
121 125
 
122 126
 	// If we've got this far - good news - no table exists. We can build our own!
@@ -134,17 +138,18 @@  discard block
 block discarded – undo
134 138
 				)
135 139
 			);
136 140
 			$default = 'default nextval(\'' . $table_name . '_seq\')';
141
+		} elseif (isset($column['default']) && $column['default'] !== null) {
142
+					$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
143
+		} else {
144
+					$default = '';
137 145
 		}
138
-		elseif (isset($column['default']) && $column['default'] !== null)
139
-			$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
140
-		else
141
-			$default = '';
142 146
 
143 147
 		// Sort out the size...
144 148
 		$column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
145 149
 		list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']);
146
-		if ($size !== null)
147
-			$type = $type . '(' . $size . ')';
150
+		if ($size !== null) {
151
+					$type = $type . '(' . $size . ')';
152
+		}
148 153
 
149 154
 		// Now just put it together!
150 155
 		$table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ',';
@@ -157,19 +162,21 @@  discard block
 block discarded – undo
157 162
 		$columns = implode(',', $index['columns']);
158 163
 
159 164
 		// Primary goes in the table...
160
-		if (isset($index['type']) && $index['type'] == 'primary')
161
-			$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
162
-		else
165
+		if (isset($index['type']) && $index['type'] == 'primary') {
166
+					$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
167
+		} else
163 168
 		{
164
-			if (empty($index['name']))
165
-				$index['name'] = implode('_', $index['columns']);
169
+			if (empty($index['name'])) {
170
+							$index['name'] = implode('_', $index['columns']);
171
+			}
166 172
 			$index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')';
167 173
 		}
168 174
 	}
169 175
 
170 176
 	// No trailing commas!
171
-	if (substr($table_query, -1) == ',')
172
-		$table_query = substr($table_query, 0, -1);
177
+	if (substr($table_query, -1) == ',') {
178
+			$table_query = substr($table_query, 0, -1);
179
+	}
173 180
 
174 181
 	$table_query .= ')';
175 182
 
@@ -180,12 +187,13 @@  discard block
 block discarded – undo
180 187
 		)
181 188
 	);
182 189
 	// And the indexes...
183
-	foreach ($index_queries as $query)
184
-		$smcFunc['db_query']('', $query,
190
+	foreach ($index_queries as $query) {
191
+			$smcFunc['db_query']('', $query,
185 192
 		array(
186 193
 			'security_override' => true,
187 194
 		)
188 195
 	);
196
+	}
189 197
 
190 198
 	// Go, go power rangers!
191 199
 	$smcFunc['db_transaction']('commit');
@@ -213,8 +221,9 @@  discard block
 block discarded – undo
213 221
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
214 222
 
215 223
 	// God no - dropping one of these = bad.
216
-	if (in_array(strtolower($table_name), $reservedTables))
217
-		return false;
224
+	if (in_array(strtolower($table_name), $reservedTables)) {
225
+			return false;
226
+	}
218 227
 
219 228
 	// Does it exist?
220 229
 	if (in_array($full_table_name, $smcFunc['db_list_tables']()))
@@ -272,21 +281,24 @@  discard block
 block discarded – undo
272 281
 
273 282
 	// Does it exist - if so don't add it again!
274 283
 	$columns = $smcFunc['db_list_columns']($table_name, false);
275
-	foreach ($columns as $column)
276
-		if ($column == $column_info['name'])
284
+	foreach ($columns as $column) {
285
+			if ($column == $column_info['name'])
277 286
 		{
278 287
 			// If we're going to overwrite then use change column.
279 288
 			if ($if_exists == 'update')
280 289
 				return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
281
-			else
282
-				return false;
290
+	}
291
+			else {
292
+							return false;
293
+			}
283 294
 		}
284 295
 
285 296
 	// Get the specifics...
286 297
 	$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
287 298
 	list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
288
-	if ($size !== null)
289
-		$type = $type . '(' . $size . ')';
299
+	if ($size !== null) {
300
+			$type = $type . '(' . $size . ')';
301
+	}
290 302
 
291 303
 	// Now add the thing!
292 304
 	$query = '
@@ -301,11 +313,12 @@  discard block
 block discarded – undo
301 313
 	// If there's more attributes they need to be done via a change on PostgreSQL.
302 314
 	unset($column_info['type'], $column_info['size']);
303 315
 
304
-	if (count($column_info) != 1)
305
-		return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
306
-	else
307
-		return true;
308
-}
316
+	if (count($column_info) != 1) {
317
+			return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
318
+	} else {
319
+			return true;
320
+	}
321
+	}
309 322
 
310 323
 /**
311 324
  * Removes a column.
@@ -324,8 +337,8 @@  discard block
 block discarded – undo
324 337
 
325 338
 	// Does it exist?
326 339
 	$columns = $smcFunc['db_list_columns']($table_name, true);
327
-	foreach ($columns as $column)
328
-		if ($column['name'] == $column_name)
340
+	foreach ($columns as $column) {
341
+			if ($column['name'] == $column_name)
329 342
 		{
330 343
 			// If there is an auto we need remove it!
331 344
 			if ($column['auto'])
@@ -335,6 +348,7 @@  discard block
 block discarded – undo
335 348
 						'security_override' => true,
336 349
 					)
337 350
 				);
351
+	}
338 352
 
339 353
 			$smcFunc['db_query']('', '
340 354
 				ALTER TABLE ' . $table_name . '
@@ -369,13 +383,15 @@  discard block
 block discarded – undo
369 383
 	// Check it does exist!
370 384
 	$columns = $smcFunc['db_list_columns']($table_name, true);
371 385
 	$old_info = null;
372
-	foreach ($columns as $column)
373
-		if ($column['name'] == $old_column)
386
+	foreach ($columns as $column) {
387
+			if ($column['name'] == $old_column)
374 388
 			$old_info = $column;
389
+	}
375 390
 
376 391
 	// Nothing?
377
-	if ($old_info == null)
378
-		return false;
392
+	if ($old_info == null) {
393
+			return false;
394
+	}
379 395
 
380 396
 	// Now we check each bit individually and ALTER as required.
381 397
 	if (isset($column_info['name']) && $column_info['name'] != $old_column)
@@ -432,8 +448,9 @@  discard block
 block discarded – undo
432 448
 	{
433 449
 		$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
434 450
 		list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
435
-		if ($size !== null)
436
-			$type = $type . '(' . $size . ')';
451
+		if ($size !== null) {
452
+					$type = $type . '(' . $size . ')';
453
+		}
437 454
 
438 455
 		// The alter is a pain.
439 456
 		$smcFunc['db_transaction']('begin');
@@ -527,21 +544,23 @@  discard block
 block discarded – undo
527 544
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
528 545
 
529 546
 	// No columns = no index.
530
-	if (empty($index_info['columns']))
531
-		return false;
547
+	if (empty($index_info['columns'])) {
548
+			return false;
549
+	}
532 550
 	$columns = implode(',', $index_info['columns']);
533 551
 
534 552
 	// No name - make it up!
535 553
 	if (empty($index_info['name']))
536 554
 	{
537 555
 		// No need for primary.
538
-		if (isset($index_info['type']) && $index_info['type'] == 'primary')
539
-			$index_info['name'] = '';
540
-		else
541
-			$index_info['name'] = $table_name . implode('_', $index_info['columns']);
556
+		if (isset($index_info['type']) && $index_info['type'] == 'primary') {
557
+					$index_info['name'] = '';
558
+		} else {
559
+					$index_info['name'] = $table_name . implode('_', $index_info['columns']);
560
+		}
561
+	} else {
562
+			$index_info['name'] = $table_name . $index_info['name'];
542 563
 	}
543
-	else
544
-		$index_info['name'] = $table_name . $index_info['name'];
545 564
 
546 565
 	// Log that we are going to want to remove this!
547 566
 	$db_package_log[] = array('remove_index', $table_name, $index_info['name']);
@@ -554,10 +573,11 @@  discard block
 block discarded – undo
554 573
 		if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary'))
555 574
 		{
556 575
 			// If we want to overwrite simply remove the current one then continue.
557
-			if ($if_exists != 'update' || $index['type'] == 'primary')
558
-				return false;
559
-			else
560
-				$smcFunc['db_remove_index']($table_name, $index_info['name']);
576
+			if ($if_exists != 'update' || $index['type'] == 'primary') {
577
+							return false;
578
+			} else {
579
+							$smcFunc['db_remove_index']($table_name, $index_info['name']);
580
+			}
561 581
 		}
562 582
 	}
563 583
 
@@ -571,8 +591,7 @@  discard block
 block discarded – undo
571 591
 				'security_override' => true,
572 592
 			)
573 593
 		);
574
-	}
575
-	else
594
+	} else
576 595
 	{
577 596
 		$smcFunc['db_query']('', '
578 597
 			CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')',
@@ -600,8 +619,9 @@  discard block
 block discarded – undo
600 619
 
601 620
 	// Better exist!
602 621
 	$indexes = $smcFunc['db_list_indexes']($table_name, true);
603
-	if ($index_name != 'primary')
604
-		$index_name = $table_name . '_' . $index_name;
622
+	if ($index_name != 'primary') {
623
+			$index_name = $table_name . '_' . $index_name;
624
+	}
605 625
 
606 626
 	foreach ($indexes as $index)
607 627
 	{
@@ -665,8 +685,7 @@  discard block
 block discarded – undo
665 685
 			'datetime' => 'timestamp without time zone',
666 686
 			'timestamp' => 'timestamp without time zone',
667 687
 		);
668
-	}
669
-	else
688
+	} else
670 689
 	{
671 690
 		$types = array(
672 691
 			'character varying' => 'varchar',
@@ -682,14 +701,16 @@  discard block
 block discarded – undo
682 701
 	// Got it? Change it!
683 702
 	if (isset($types[$type_name]))
684 703
 	{
685
-		if ($type_name == 'tinytext')
686
-			$type_size = 255;
704
+		if ($type_name == 'tinytext') {
705
+					$type_size = 255;
706
+		}
687 707
 		$type_name = $types[$type_name];
688 708
 	}
689 709
 
690 710
 	// Only char fields got size
691
-	if (strpos($type_name, 'char') === false)
692
-			$type_size = null;
711
+	if (strpos($type_name, 'char') === false) {
712
+				$type_size = null;
713
+	}
693 714
 
694 715
 
695 716
 	return array($type_name, $type_size);
@@ -744,8 +765,7 @@  discard block
 block discarded – undo
744 765
 		if (!$detail)
745 766
 		{
746 767
 			$columns[] = $row['column_name'];
747
-		}
748
-		else
768
+		} else
749 769
 		{
750 770
 			$auto = false;
751 771
 			// What is the default?
@@ -753,11 +773,11 @@  discard block
 block discarded – undo
753 773
 			{
754 774
 				$default = null;
755 775
 				$auto = true;
776
+			} elseif (trim($row['column_default']) != '') {
777
+							$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
778
+			} else {
779
+							$default = null;
756 780
 			}
757
-			elseif (trim($row['column_default']) != '')
758
-				$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
759
-			else
760
-				$default = null;
761 781
 
762 782
 			// Make the type generic.
763 783
 			list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true);
@@ -808,26 +828,30 @@  discard block
 block discarded – undo
808 828
 	while ($row = $smcFunc['db_fetch_assoc']($result))
809 829
 	{
810 830
 		// Try get the columns that make it up.
811
-		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0)
812
-			continue;
831
+		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) {
832
+					continue;
833
+		}
813 834
 
814 835
 		$columns = explode(',', $matches[1]);
815 836
 
816
-		if (empty($columns))
817
-			continue;
837
+		if (empty($columns)) {
838
+					continue;
839
+		}
818 840
 
819
-		foreach ($columns as $k => $v)
820
-			$columns[$k] = trim($v);
841
+		foreach ($columns as $k => $v) {
842
+					$columns[$k] = trim($v);
843
+		}
821 844
 
822 845
 		// Fix up the name to be consistent cross databases
823
-		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1)
824
-			$row['name'] = 'PRIMARY';
825
-		else
826
-			$row['name'] = str_replace($table_name . '_', '', $row['name']);
846
+		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) {
847
+					$row['name'] = 'PRIMARY';
848
+		} else {
849
+					$row['name'] = str_replace($table_name . '_', '', $row['name']);
850
+		}
827 851
 
828
-		if (!$detail)
829
-			$indexes[] = $row['name'];
830
-		else
852
+		if (!$detail) {
853
+					$indexes[] = $row['name'];
854
+		} else
831 855
 		{
832 856
 			$indexes[$row['name']] = array(
833 857
 				'name' => $row['name'],
Please login to merge, or discard this patch.
Sources/Drafts.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @param string $post_errors A string of info about errors encountered trying to save this draft
177 177
  * @param array $recipientList An array of data about who this PM is being sent to
178
- * @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
178
+ * @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
179 179
  */
180 180
 function SavePMDraft(&$post_errors, $recipientList)
181 181
 {
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
  *
394 394
  * @param int $id_draft The ID of the draft to delete
395 395
  * @param boolean $check Whether or not to check that the draft belongs to the current user
396
- * @return boolean False if it couldn't be deleted (doesn't return anything otherwise)
396
+ * @return false|null False if it couldn't be deleted (doesn't return anything otherwise)
397 397
  */
398 398
 function DeleteDraft($id_draft, $check = true)
399 399
 {
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
  * @param int $member_id ID of the member to show drafts for
428 428
  * @param boolean|integer If $type is 1, this can be set to only load drafts for posts in the specific topic
429 429
  * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts
430
- * @return boolean False if the drafts couldn't be loaded, nothing otherwise
430
+ * @return false|null False if the drafts couldn't be loaded, nothing otherwise
431 431
  */
432 432
 function ShowDrafts($member_id, $topic = false, $draft_type = 0)
433 433
 {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
  * Allows for the deleting and loading/editing of drafts
512 512
  *
513 513
  * @param type $memID
514
- * @param type $draft_type
514
+ * @param integer $draft_type
515 515
  */
516 516
 function showProfileDrafts($memID, $draft_type = 0)
517 517
 {
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
  * Uses the showpmdraft template
665 665
  * Allows for the deleting and loading/editing of drafts
666 666
  *
667
- * @param type $memID
667
+ * @param integer $memID
668 668
  */
669 669
 function showPMDrafts($memID = -1)
670 670
 {
Please login to merge, or discard this patch.
Braces   +81 added lines, -57 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) && $draft_info['id_member'] == $user_info['id'])
@@ -150,9 +155,9 @@  discard block
 block discarded – undo
150 155
 		{
151 156
 			$context['draft_saved'] = true;
152 157
 			$context['id_draft'] = $id_draft;
158
+		} else {
159
+					$post_errors[] = 'draft_not_saved';
153 160
 		}
154
-		else
155
-			$post_errors[] = 'draft_not_saved';
156 161
 
157 162
 		// cleanup
158 163
 		unset($_POST['save_draft']);
@@ -182,8 +187,9 @@  discard block
 block discarded – undo
182 187
 	global $context, $user_info, $smcFunc, $modSettings;
183 188
 
184 189
 	// PM survey says ... can you stay or must you go
185
-	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft']))
186
-		return false;
190
+	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) {
191
+			return false;
192
+	}
187 193
 
188 194
 	// read in what you sent us
189 195
 	$id_pm_draft = (int) $_POST['id_pm_draft'];
@@ -195,8 +201,9 @@  discard block
 block discarded – undo
195 201
 		$context['draft_saved_on'] = $draft_info['poster_time'];
196 202
 
197 203
 		// Send something back to the javascript caller
198
-		if (!empty($id_draft))
199
-			XmlDraft($id_draft);
204
+		if (!empty($id_draft)) {
205
+					XmlDraft($id_draft);
206
+		}
200 207
 
201 208
 		return true;
202 209
 	}
@@ -206,9 +213,9 @@  discard block
 block discarded – undo
206 213
 	{
207 214
 		$recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array();
208 215
 		$recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array();
216
+	} elseif (!empty($draft_info['to_list']) && empty($recipientList)) {
217
+			$recipientList = smf_json_decode($draft_info['to_list'], true);
209 218
 	}
210
-	elseif (!empty($draft_info['to_list']) && empty($recipientList))
211
-		$recipientList = smf_json_decode($draft_info['to_list'], true);
212 219
 
213 220
 	// prepare the data we got from the form
214 221
 	$reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to'];
@@ -217,8 +224,9 @@  discard block
 block discarded – undo
217 224
 
218 225
 	// message and subject always need a bit more work
219 226
 	preparsecode($draft['body']);
220
-	if ($smcFunc['strlen']($draft['subject']) > 100)
221
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
227
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
228
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
229
+	}
222 230
 
223 231
 	// Modifying an existing PM draft?
224 232
 	if (!empty($id_pm_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id'])
@@ -284,9 +292,9 @@  discard block
 block discarded – undo
284 292
 		{
285 293
 			$context['draft_saved'] = true;
286 294
 			$context['id_pm_draft'] = $id_pm_draft;
295
+		} else {
296
+					$post_errors[] = 'draft_not_saved';
287 297
 		}
288
-		else
289
-			$post_errors[] = 'draft_not_saved';
290 298
 	}
291 299
 
292 300
 	// if we were called from the autosave function, send something back
@@ -319,8 +327,9 @@  discard block
 block discarded – undo
319 327
 	$type = (int) $type;
320 328
 
321 329
 	// nothing to read, nothing to do
322
-	if (empty($id_draft))
323
-		return false;
330
+	if (empty($id_draft)) {
331
+			return false;
332
+	}
324 333
 
325 334
 	// load in this draft from the DB
326 335
 	$request = $smcFunc['db_query']('', '
@@ -341,8 +350,9 @@  discard block
 block discarded – undo
341 350
 	);
342 351
 
343 352
 	// no results?
344
-	if (!$smcFunc['db_num_rows']($request))
345
-		return false;
353
+	if (!$smcFunc['db_num_rows']($request)) {
354
+			return false;
355
+	}
346 356
 
347 357
 	// load up the data
348 358
 	$draft_info = $smcFunc['db_fetch_assoc']($request);
@@ -363,8 +373,7 @@  discard block
 block discarded – undo
363 373
 			$context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
364 374
 			$context['board'] = !empty($draft_info['board_id']) ? $draft_info['id_board'] : '';
365 375
 			$context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0;
366
-		}
367
-		elseif ($type === 1)
376
+		} elseif ($type === 1)
368 377
 		{
369 378
 			// one of those pm drafts? then set it up like we have an error
370 379
 			$_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
@@ -400,12 +409,14 @@  discard block
 block discarded – undo
400 409
 	global $user_info, $smcFunc;
401 410
 
402 411
 	// Only a single draft.
403
-	if (is_numeric($id_draft))
404
-		$id_draft = array($id_draft);
412
+	if (is_numeric($id_draft)) {
413
+			$id_draft = array($id_draft);
414
+	}
405 415
 
406 416
 	// can't delete nothing
407
-	if (empty($id_draft) || ($check && empty($user_info['id'])))
408
-		return false;
417
+	if (empty($id_draft) || ($check && empty($user_info['id']))) {
418
+			return false;
419
+	}
409 420
 
410 421
 	$smcFunc['db_query']('', '
411 422
 		DELETE FROM {db_prefix}user_drafts
@@ -434,14 +445,16 @@  discard block
 block discarded – undo
434 445
 	global $smcFunc, $scripturl, $context, $txt, $modSettings;
435 446
 
436 447
 	// Permissions
437
-	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id))
438
-		return false;
448
+	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) {
449
+			return false;
450
+	}
439 451
 
440 452
 	$context['drafts'] = array();
441 453
 
442 454
 	// has a specific draft has been selected?  Load it up if there is not a message already in the editor
443
-	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message']))
444
-		ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
455
+	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) {
456
+			ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
457
+	}
445 458
 
446 459
 	// load the drafts this user has available
447 460
 	$request = $smcFunc['db_query']('', '
@@ -464,23 +477,26 @@  discard block
 block discarded – undo
464 477
 	// add them to the draft array for display
465 478
 	while ($row = $smcFunc['db_fetch_assoc']($request))
466 479
 	{
467
-		if (empty($row['subject']))
468
-			$row['subject'] = $txt['no_subject'];
480
+		if (empty($row['subject'])) {
481
+					$row['subject'] = $txt['no_subject'];
482
+		}
469 483
 
470 484
 		// Post drafts
471
-		if ($draft_type === 0)
472
-			$context['drafts'][] = array(
485
+		if ($draft_type === 0) {
486
+					$context['drafts'][] = array(
473 487
 				'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)),
474 488
 				'poster_time' => timeformat($row['poster_time']),
475 489
 				'link' => '<a href="' . $scripturl . '?action=post;board=' . $row['id_board'] . ';' . (!empty($row['id_topic']) ? 'topic='. $row['id_topic'] .'.0;' : '') . 'id_draft=' . $row['id_draft'] . '">' . $row['subject'] . '</a>',
476 490
 			);
491
+		}
477 492
 		// PM drafts
478
-		elseif ($draft_type === 1)
479
-			$context['drafts'][] = array(
493
+		elseif ($draft_type === 1) {
494
+					$context['drafts'][] = array(
480 495
 				'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)),
481 496
 				'poster_time' => timeformat($row['poster_time']),
482 497
 				'link' => '<a href="' . $scripturl . '?action=pm;sa=send;id_draft=' . $row['id_draft'] . '">' . (!empty($row['subject']) ? $row['subject'] : $txt['drafts_none']) . '</a>',
483 498
 			);
499
+		}
484 500
 	}
485 501
 	$smcFunc['db_free_result']($request);
486 502
 }
@@ -544,8 +560,9 @@  discard block
 block discarded – undo
544 560
 	}
545 561
 
546 562
 	// Default to 10.
547
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
548
-		$_REQUEST['viewscount'] = 10;
563
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
564
+			$_REQUEST['viewscount'] = 10;
565
+	}
549 566
 
550 567
 	// Get the count of applicable drafts on the boards they can (still) see ...
551 568
 	// @todo .. should we just let them see their drafts even if they have lost board access ?
@@ -610,12 +627,14 @@  discard block
 block discarded – undo
610 627
 	while ($row = $smcFunc['db_fetch_assoc']($request))
611 628
 	{
612 629
 		// Censor....
613
-		if (empty($row['body']))
614
-			$row['body'] = '';
630
+		if (empty($row['body'])) {
631
+					$row['body'] = '';
632
+		}
615 633
 
616 634
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
617
-		if (empty($row['subject']))
618
-			$row['subject'] = $txt['no_subject'];
635
+		if (empty($row['subject'])) {
636
+					$row['subject'] = $txt['no_subject'];
637
+		}
619 638
 
620 639
 		censorText($row['body']);
621 640
 		censorText($row['subject']);
@@ -647,8 +666,9 @@  discard block
 block discarded – undo
647 666
 	$smcFunc['db_free_result']($request);
648 667
 
649 668
 	// If the drafts were retrieved in reverse order, get them right again.
650
-	if ($reverse)
651
-		$context['drafts'] = array_reverse($context['drafts'], true);
669
+	if ($reverse) {
670
+			$context['drafts'] = array_reverse($context['drafts'], true);
671
+	}
652 672
 
653 673
 	// Menu tab
654 674
 	$context[$context['profile_menu_name']]['tab_data'] = array(
@@ -706,8 +726,9 @@  discard block
 block discarded – undo
706 726
 	}
707 727
 
708 728
 	// Default to 10.
709
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
710
-		$_REQUEST['viewscount'] = 10;
729
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
730
+			$_REQUEST['viewscount'] = 10;
731
+	}
711 732
 
712 733
 	// Get the count of applicable drafts
713 734
 	$request = $smcFunc['db_query']('', '
@@ -766,12 +787,14 @@  discard block
 block discarded – undo
766 787
 	while ($row = $smcFunc['db_fetch_assoc']($request))
767 788
 	{
768 789
 		// Censor....
769
-		if (empty($row['body']))
770
-			$row['body'] = '';
790
+		if (empty($row['body'])) {
791
+					$row['body'] = '';
792
+		}
771 793
 
772 794
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
773
-		if (empty($row['subject']))
774
-			$row['subject'] = $txt['no_subject'];
795
+		if (empty($row['subject'])) {
796
+					$row['subject'] = $txt['no_subject'];
797
+		}
775 798
 
776 799
 		censorText($row['body']);
777 800
 		censorText($row['subject']);
@@ -826,8 +849,9 @@  discard block
 block discarded – undo
826 849
 	$smcFunc['db_free_result']($request);
827 850
 
828 851
 	// if the drafts were retrieved in reverse order, then put them in the right order again.
829
-	if ($reverse)
830
-		$context['drafts'] = array_reverse($context['drafts'], true);
852
+	if ($reverse) {
853
+			$context['drafts'] = array_reverse($context['drafts'], true);
854
+	}
831 855
 
832 856
 	// off to the template we go
833 857
 	$context['page_title'] = $txt['drafts'];
Please login to merge, or discard this patch.
Sources/Errors.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -475,7 +475,7 @@
 block discarded – undo
475 475
  * Used by fatal_error(), fatal_lang_error()
476 476
  *
477 477
  * @param string $error The error
478
- * @param array $sprintf An array of data to be sprintf()'d into the specified message
478
+ * @param boolean $sprintf An array of data to be sprintf()'d into the specified message
479 479
  */
480 480
 function log_error_online($error, $sprintf = array())
481 481
 {
Please login to merge, or discard this patch.
Braces   +117 added lines, -83 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 3
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Log an error, if the error logging is enabled.
@@ -36,8 +37,9 @@  discard block
 block discarded – undo
36 37
 	static $tried_hook = false;
37 38
 
38 39
 	// Check if error logging is actually on.
39
-	if (empty($modSettings['enableErrorLogging']))
40
-		return $error_message;
40
+	if (empty($modSettings['enableErrorLogging'])) {
41
+			return $error_message;
42
+	}
41 43
 
42 44
 	// Basically, htmlspecialchars it minus &. (for entities!)
43 45
 	$error_message = strtr($error_message, array('<' => '&lt;', '>' => '&gt;', '"' => '&quot;'));
@@ -45,22 +47,26 @@  discard block
 block discarded – undo
45 47
 
46 48
 	// Add a file and line to the error message?
47 49
 	// Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line
48
-	if ($file == null)
49
-		$file = '';
50
-	else
51
-		// Window style slashes don't play well, lets convert them to the unix style.
50
+	if ($file == null) {
51
+			$file = '';
52
+	} else {
53
+			// Window style slashes don't play well, lets convert them to the unix style.
52 54
 		$file = str_replace('\\', '/', $file);
55
+	}
53 56
 
54
-	if ($line == null)
55
-		$line = 0;
56
-	else
57
-		$line = (int) $line;
57
+	if ($line == null) {
58
+			$line = 0;
59
+	} else {
60
+			$line = (int) $line;
61
+	}
58 62
 
59 63
 	// Just in case there's no id_member or IP set yet.
60
-	if (empty($user_info['id']))
61
-		$user_info['id'] = 0;
62
-	if (empty($user_info['ip']))
63
-		$user_info['ip'] = '';
64
+	if (empty($user_info['id'])) {
65
+			$user_info['id'] = 0;
66
+	}
67
+	if (empty($user_info['ip'])) {
68
+			$user_info['ip'] = '';
69
+	}
64 70
 
65 71
 	// Find the best query string we can...
66 72
 	$query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING'];
@@ -69,8 +75,9 @@  discard block
 block discarded – undo
69 75
 	$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));
70 76
 
71 77
 	// Just so we know what board error messages are from.
72
-	if (isset($_POST['board']) && !isset($_GET['board']))
73
-		$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
78
+	if (isset($_POST['board']) && !isset($_GET['board'])) {
79
+			$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
80
+	}
74 81
 
75 82
 	// What types of categories do we have?
76 83
 	$known_error_types = array(
@@ -132,12 +139,14 @@  discard block
 block discarded – undo
132 139
 	global $txt;
133 140
 
134 141
 	// Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all
135
-	if (!empty($status))
136
-		send_http_status($status);
142
+	if (!empty($status)) {
143
+			send_http_status($status);
144
+	}
137 145
 
138 146
 	// We don't have $txt yet, but that's okay...
139
-	if (empty($txt))
140
-		die($error);
147
+	if (empty($txt)) {
148
+			die($error);
149
+	}
141 150
 
142 151
 	log_error_online($error, false);
143 152
 	setup_fatal_error_context($log ? log_error($error, $log) : $error);
@@ -164,8 +173,9 @@  discard block
 block discarded – undo
164 173
 	static $fatal_error_called = false;
165 174
 
166 175
 	// Send the status header - set this to 0 or false if you don't want to send one at all
167
-	if (!empty($status))
168
-		send_http_status($status);
176
+	if (!empty($status)) {
177
+			send_http_status($status);
178
+	}
169 179
 
170 180
 	// Try to load a theme if we don't have one.
171 181
 	if (empty($context['theme_loaded']) && empty($fatal_error_called))
@@ -175,8 +185,9 @@  discard block
 block discarded – undo
175 185
 	}
176 186
 
177 187
 	// If we have no theme stuff we can't have the language file...
178
-	if (empty($context['theme_loaded']))
179
-		die($error);
188
+	if (empty($context['theme_loaded'])) {
189
+			die($error);
190
+	}
180 191
 
181 192
 	$reload_lang_file = true;
182 193
 	// Log the error in the forum's language, but don't waste the time if we aren't logging
@@ -212,8 +223,9 @@  discard block
 block discarded – undo
212 223
 	global $settings, $modSettings, $db_show_debug;
213 224
 
214 225
 	// Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.)
215
-	if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging'])))
216
-		return;
226
+	if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) {
227
+			return;
228
+	}
217 229
 
218 230
 	if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename']))
219 231
 	{
@@ -221,19 +233,22 @@  discard block
 block discarded – undo
221 233
 		$count = count($array);
222 234
 		for ($i = 0; $i < $count; $i++)
223 235
 		{
224
-			if ($array[$i]['function'] != 'loadSubTemplate')
225
-				continue;
236
+			if ($array[$i]['function'] != 'loadSubTemplate') {
237
+							continue;
238
+			}
226 239
 
227 240
 			// This is a bug in PHP, with eval, it seems!
228
-			if (empty($array[$i]['args']))
229
-				$i++;
241
+			if (empty($array[$i]['args'])) {
242
+							$i++;
243
+			}
230 244
 			break;
231 245
 		}
232 246
 
233
-		if (isset($array[$i]) && !empty($array[$i]['args']))
234
-			$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
235
-		else
236
-			$file = realpath($settings['current_include_filename']) . ' (eval?)';
247
+		if (isset($array[$i]) && !empty($array[$i]['args'])) {
248
+					$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
249
+		} else {
250
+					$file = realpath($settings['current_include_filename']) . ' (eval?)';
251
+		}
237 252
 	}
238 253
 
239 254
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -242,8 +257,9 @@  discard block
 block discarded – undo
242 257
 		if ($error_level % 255 != E_ERROR)
243 258
 		{
244 259
 			$temporary = ob_get_contents();
245
-			if (substr($temporary, -2) == '="')
246
-				echo '"';
260
+			if (substr($temporary, -2) == '="') {
261
+							echo '"';
262
+			}
247 263
 		}
248 264
 
249 265
 		// Debugging!  This should look like a PHP error message.
@@ -259,23 +275,27 @@  discard block
 block discarded – undo
259 275
 	call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line));
260 276
 
261 277
 	// Dying on these errors only causes MORE problems (blank pages!)
262
-	if ($file == 'Unknown')
263
-		return;
278
+	if ($file == 'Unknown') {
279
+			return;
280
+	}
264 281
 
265 282
 	// If this is an E_ERROR or E_USER_ERROR.... die.  Violently so.
266
-	if ($error_level % 255 == E_ERROR)
267
-		obExit(false);
268
-	else
269
-		return;
283
+	if ($error_level % 255 == E_ERROR) {
284
+			obExit(false);
285
+	} else {
286
+			return;
287
+	}
270 288
 
271 289
 	// If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die.  Violently so.
272
-	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING)
273
-		fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
290
+	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) {
291
+			fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
292
+	}
274 293
 
275 294
 	// We should NEVER get to this point.  Any fatal error MUST quit, or very bad things can happen.
276
-	if ($error_level % 255 == E_ERROR)
277
-		die('No direct access...');
278
-}
295
+	if ($error_level % 255 == E_ERROR) {
296
+			die('No direct access...');
297
+	}
298
+	}
279 299
 
280 300
 /**
281 301
  * It is called by {@link fatal_error()} and {@link fatal_lang_error()}.
@@ -291,24 +311,28 @@  discard block
 block discarded – undo
291 311
 
292 312
 	// Attempt to prevent a recursive loop.
293 313
 	++$level;
294
-	if ($level > 1)
295
-		return false;
314
+	if ($level > 1) {
315
+			return false;
316
+	}
296 317
 
297 318
 	// Maybe they came from dlattach or similar?
298
-	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded']))
299
-		loadTheme();
319
+	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) {
320
+			loadTheme();
321
+	}
300 322
 
301 323
 	// Don't bother indexing errors mate...
302 324
 	$context['robot_no_index'] = true;
303 325
 
304
-	if (!isset($context['error_title']))
305
-		$context['error_title'] = $txt['error_occured'];
326
+	if (!isset($context['error_title'])) {
327
+			$context['error_title'] = $txt['error_occured'];
328
+	}
306 329
 	$context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message;
307 330
 
308 331
 	$context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : '';
309 332
 
310
-	if (empty($context['page_title']))
311
-		$context['page_title'] = $context['error_title'];
333
+	if (empty($context['page_title'])) {
334
+			$context['page_title'] = $context['error_title'];
335
+	}
312 336
 
313 337
 	loadTemplate('Errors');
314 338
 	$context['sub_template'] = 'fatal_error';
@@ -316,23 +340,26 @@  discard block
 block discarded – undo
316 340
 	// If this is SSI, what do they want us to do?
317 341
 	if (SMF == 'SSI')
318 342
 	{
319
-		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method))
320
-			$ssi_on_error_method();
321
-		elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
322
-			loadSubTemplate('fatal_error');
343
+		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) {
344
+					$ssi_on_error_method();
345
+		} elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
346
+					loadSubTemplate('fatal_error');
347
+		}
323 348
 
324 349
 		// No layers?
325
-		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
326
-			exit;
350
+		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
351
+					exit;
352
+		}
327 353
 	}
328 354
 	// Alternatively from the cron call?
329 355
 	elseif (SMF == 'BACKGROUND')
330 356
 	{
331 357
 		// We can't rely on even having language files available.
332
-		if (defined('FROM_CLI') && FROM_CLI)
333
-			echo 'cron error: ', $context['error_message'];
334
-		else
335
-			echo 'An error occurred. More information may be available in your logs.';
358
+		if (defined('FROM_CLI') && FROM_CLI) {
359
+					echo 'cron error: ', $context['error_message'];
360
+		} else {
361
+					echo 'An error occurred. More information may be available in your logs.';
362
+		}
336 363
 		exit;
337 364
 	}
338 365
 
@@ -360,8 +387,8 @@  discard block
 block discarded – undo
360 387
 
361 388
 	set_fatal_error_headers();
362 389
 
363
-	if (!empty($maintenance))
364
-		echo '<!DOCTYPE html>
390
+	if (!empty($maintenance)) {
391
+			echo '<!DOCTYPE html>
365 392
 <html>
366 393
 	<head>
367 394
 		<meta name="robots" content="noindex">
@@ -372,6 +399,7 @@  discard block
 block discarded – undo
372 399
 		', $mmessage, '
373 400
 	</body>
374 401
 </html>';
402
+	}
375 403
 
376 404
 	die();
377 405
 }
@@ -393,15 +421,17 @@  discard block
 block discarded – undo
393 421
 	// For our purposes, we're gonna want this on if at all possible.
394 422
 	$modSettings['cache_enable'] = '1';
395 423
 
396
-	if (($temp = cache_get_data('db_last_error', 600)) !== null)
397
-		$db_last_error = max($db_last_error, $temp);
424
+	if (($temp = cache_get_data('db_last_error', 600)) !== null) {
425
+			$db_last_error = max($db_last_error, $temp);
426
+	}
398 427
 
399 428
 	if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send))
400 429
 	{
401 430
 		// Avoid writing to the Settings.php file if at all possible; use shared memory instead.
402 431
 		cache_put_data('db_last_error', time(), 600);
403
-		if (($temp = cache_get_data('db_last_error', 600)) === null)
404
-			logLastDatabaseError();
432
+		if (($temp = cache_get_data('db_last_error', 600)) === null) {
433
+					logLastDatabaseError();
434
+		}
405 435
 
406 436
 		// Language files aren't loaded yet :(.
407 437
 		$db_error = @$smcFunc['db_error']($db_connection);
@@ -482,12 +512,14 @@  discard block
 block discarded – undo
482 512
 	global $smcFunc, $user_info, $modSettings;
483 513
 
484 514
 	// Don't bother if Who's Online is disabled.
485
-	if (empty($modSettings['who_enabled']))
486
-		return;
515
+	if (empty($modSettings['who_enabled'])) {
516
+			return;
517
+	}
487 518
 
488 519
 	// Maybe they came from SSI or similar where sessions are not recorded?
489
-	if (SMF == 'SSI' || SMF == 'BACKGROUND')
490
-		return;
520
+	if (SMF == 'SSI' || SMF == 'BACKGROUND') {
521
+			return;
522
+	}
491 523
 
492 524
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
493 525
 
@@ -506,8 +538,9 @@  discard block
 block discarded – undo
506 538
 		$url = smf_json_decode($url, true);
507 539
 		$url['error'] = $error;
508 540
 
509
-		if (!empty($sprintf))
510
-			$url['error_params'] = $sprintf;
541
+		if (!empty($sprintf)) {
542
+					$url['error_params'] = $sprintf;
543
+		}
511 544
 
512 545
 		$smcFunc['db_query']('', '
513 546
 			UPDATE {db_prefix}log_online
@@ -538,10 +571,11 @@  discard block
 block discarded – undo
538 571
 
539 572
 	$protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
540 573
 
541
-	if (!isset($statuses[$code]))
542
-		header($protocol . ' 500 Internal Server Error');
543
-	else
544
-		header($protocol . ' ' . $code . ' ' . $statuses[$code]);
545
-}
574
+	if (!isset($statuses[$code])) {
575
+			header($protocol . ' 500 Internal Server Error');
576
+	} else {
577
+			header($protocol . ' ' . $code . ' ' . $statuses[$code]);
578
+	}
579
+	}
546 580
 
547 581
 ?>
548 582
\ No newline at end of file
Please login to merge, or discard this patch.