Completed
Push — stable10 ( b85e94...1e5021 )
by
unknown
23:18 queued 12:32
created
lib/private/legacy/response.php 3 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	*/
48 48
 	static public function enableCaching($cache_time = null) {
49 49
 		if (is_numeric($cache_time)) {
50
-			header('Pragma: public');// enable caching in IE
50
+			header('Pragma: public'); // enable caching in IE
51 51
 			if ($cache_time > 0) {
52 52
 				self::setExpiresHeader('PT'.$cache_time.'S');
53 53
 				header('Cache-Control: max-age='.$cache_time.', must-revalidate');
@@ -78,29 +78,29 @@  discard block
 block discarded – undo
78 78
 	*/
79 79
 	static public function setStatus($status) {
80 80
 		$protocol = \OC::$server->getRequest()->getHttpProtocol();
81
-		switch($status) {
81
+		switch ($status) {
82 82
 			case self::STATUS_NOT_MODIFIED:
83
-				$status = $status . ' Not Modified';
83
+				$status = $status.' Not Modified';
84 84
 				break;
85 85
 			case self::STATUS_TEMPORARY_REDIRECT:
86 86
 				if ($protocol == 'HTTP/1.1') {
87
-					$status = $status . ' Temporary Redirect';
87
+					$status = $status.' Temporary Redirect';
88 88
 					break;
89 89
 				} else {
90 90
 					$status = self::STATUS_FOUND;
91 91
 					// fallthrough
92 92
 				}
93 93
 			case self::STATUS_FOUND;
94
-				$status = $status . ' Found';
94
+				$status = $status.' Found';
95 95
 				break;
96 96
 			case self::STATUS_NOT_FOUND;
97
-				$status = $status . ' Not Found';
97
+				$status = $status.' Not Found';
98 98
 				break;
99 99
 			case self::STATUS_INTERNAL_SERVER_ERROR;
100
-				$status = $status . ' Internal Server Error';
100
+				$status = $status.' Internal Server Error';
101 101
 				break;
102 102
 			case self::STATUS_SERVICE_UNAVAILABLE;
103
-				$status = $status . ' Service Unavailable';
103
+				$status = $status.' Service Unavailable';
104 104
 				break;
105 105
 		}
106 106
 		header($protocol.' '.$status);
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
 	 * @param string $filename file name
181 181
 	 * @param string $type disposition type, either 'attachment' or 'inline'
182 182
 	 */
183
-	static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
183
+	static public function setContentDispositionHeader($filename, $type = 'attachment') {
184 184
 		if (\OC::$server->getRequest()->isUserAgent(
185 185
 			[
186 186
 				\OC\AppFramework\Http\Request::USER_AGENT_IE,
187 187
 				\OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
188 188
 				\OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
189 189
 			])) {
190
-			header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' );
190
+			header('Content-Disposition: '.rawurlencode($type).'; filename="'.rawurlencode($filename).'"');
191 191
 		} else {
192
-			header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename )
193
-												 . '; filename="' . rawurlencode( $filename ) . '"' );
192
+			header('Content-Disposition: '.rawurlencode($type).'; filename*=UTF-8\'\''.rawurlencode($filename)
193
+												 . '; filename="'.rawurlencode($filename).'"');
194 194
 		}
195 195
 	}
196 196
 
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 			. 'font-src \'self\' data:; '
255 255
 			. 'media-src *; ' 
256 256
 			. 'connect-src *';
257
-		header('Content-Security-Policy:' . $policy);
257
+		header('Content-Security-Policy:'.$policy);
258 258
 
259 259
 		// Send fallback headers for installations that don't have the possibility to send
260 260
 		// custom headers on the webserver side
261
-		if(getenv('modHeadersAvailable') !== 'true') {
261
+		if (getenv('modHeadersAvailable') !== 'true') {
262 262
 			header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
263 263
 			header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE
264 264
 			header('X-Frame-Options: Sameorigin'); // Disallow iFraming from other domains
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,13 +51,11 @@  discard block
 block discarded – undo
51 51
 			if ($cache_time > 0) {
52 52
 				self::setExpiresHeader('PT'.$cache_time.'S');
53 53
 				header('Cache-Control: max-age='.$cache_time.', must-revalidate');
54
-			}
55
-			else {
54
+			} else {
56 55
 				self::setExpiresHeader(0);
57 56
 				header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
58 57
 			}
59
-		}
60
-		else {
58
+		} else {
61 59
 			header('Cache-Control: cache');
62 60
 			header('Pragma: cache');
63 61
 		}
@@ -228,8 +226,7 @@  discard block
 block discarded – undo
228 226
 
229 227
 			self::setContentLengthHeader(filesize($filepath));
230 228
 			fpassthru($fp);
231
-		}
232
-		else {
229
+		} else {
233 230
 			self::setStatus(self::STATUS_NOT_FOUND);
234 231
 		}
235 232
 	}
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -29,242 +29,242 @@
 block discarded – undo
29 29
  */
30 30
 
31 31
 class OC_Response {
32
-	const STATUS_FOUND = 304;
33
-	const STATUS_NOT_MODIFIED = 304;
34
-	const STATUS_TEMPORARY_REDIRECT = 307;
35
-	const STATUS_BAD_REQUEST = 400;
36
-	const STATUS_NOT_FOUND = 404;
37
-	const STATUS_INTERNAL_SERVER_ERROR = 500;
38
-	const STATUS_SERVICE_UNAVAILABLE = 503;
32
+    const STATUS_FOUND = 304;
33
+    const STATUS_NOT_MODIFIED = 304;
34
+    const STATUS_TEMPORARY_REDIRECT = 307;
35
+    const STATUS_BAD_REQUEST = 400;
36
+    const STATUS_NOT_FOUND = 404;
37
+    const STATUS_INTERNAL_SERVER_ERROR = 500;
38
+    const STATUS_SERVICE_UNAVAILABLE = 503;
39 39
 
40
-	/**
41
-	* Enable response caching by sending correct HTTP headers
42
-	* @param integer $cache_time time to cache the response
43
-	*  >0		cache time in seconds
44
-	*  0 and <0	enable default browser caching
45
-	*  null		cache indefinitely
46
-	*/
47
-	static public function enableCaching($cache_time = null) {
48
-		if (is_numeric($cache_time)) {
49
-			header('Pragma: public');// enable caching in IE
50
-			if ($cache_time > 0) {
51
-				self::setExpiresHeader('PT'.$cache_time.'S');
52
-				header('Cache-Control: max-age='.$cache_time.', must-revalidate');
53
-			}
54
-			else {
55
-				self::setExpiresHeader(0);
56
-				header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
57
-			}
58
-		}
59
-		else {
60
-			header('Cache-Control: cache');
61
-			header('Pragma: cache');
62
-		}
40
+    /**
41
+     * Enable response caching by sending correct HTTP headers
42
+     * @param integer $cache_time time to cache the response
43
+     *  >0		cache time in seconds
44
+     *  0 and <0	enable default browser caching
45
+     *  null		cache indefinitely
46
+     */
47
+    static public function enableCaching($cache_time = null) {
48
+        if (is_numeric($cache_time)) {
49
+            header('Pragma: public');// enable caching in IE
50
+            if ($cache_time > 0) {
51
+                self::setExpiresHeader('PT'.$cache_time.'S');
52
+                header('Cache-Control: max-age='.$cache_time.', must-revalidate');
53
+            }
54
+            else {
55
+                self::setExpiresHeader(0);
56
+                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
57
+            }
58
+        }
59
+        else {
60
+            header('Cache-Control: cache');
61
+            header('Pragma: cache');
62
+        }
63 63
 
64
-	}
64
+    }
65 65
 
66
-	/**
67
-	* disable browser caching
68
-	* @see enableCaching with cache_time = 0
69
-	*/
70
-	static public function disableCaching() {
71
-		self::enableCaching(0);
72
-	}
66
+    /**
67
+     * disable browser caching
68
+     * @see enableCaching with cache_time = 0
69
+     */
70
+    static public function disableCaching() {
71
+        self::enableCaching(0);
72
+    }
73 73
 
74
-	/**
75
-	* Set response status
76
-	* @param int $status a HTTP status code, see also the STATUS constants
77
-	*/
78
-	static public function setStatus($status) {
79
-		$protocol = \OC::$server->getRequest()->getHttpProtocol();
80
-		switch($status) {
81
-			case self::STATUS_NOT_MODIFIED:
82
-				$status = $status . ' Not Modified';
83
-				break;
84
-			case self::STATUS_TEMPORARY_REDIRECT:
85
-				if ($protocol == 'HTTP/1.1') {
86
-					$status = $status . ' Temporary Redirect';
87
-					break;
88
-				} else {
89
-					$status = self::STATUS_FOUND;
90
-					// fallthrough
91
-				}
92
-			case self::STATUS_FOUND;
93
-				$status = $status . ' Found';
94
-				break;
95
-			case self::STATUS_NOT_FOUND;
96
-				$status = $status . ' Not Found';
97
-				break;
98
-			case self::STATUS_INTERNAL_SERVER_ERROR;
99
-				$status = $status . ' Internal Server Error';
100
-				break;
101
-			case self::STATUS_SERVICE_UNAVAILABLE;
102
-				$status = $status . ' Service Unavailable';
103
-				break;
104
-		}
105
-		header($protocol.' '.$status);
106
-	}
74
+    /**
75
+     * Set response status
76
+     * @param int $status a HTTP status code, see also the STATUS constants
77
+     */
78
+    static public function setStatus($status) {
79
+        $protocol = \OC::$server->getRequest()->getHttpProtocol();
80
+        switch($status) {
81
+            case self::STATUS_NOT_MODIFIED:
82
+                $status = $status . ' Not Modified';
83
+                break;
84
+            case self::STATUS_TEMPORARY_REDIRECT:
85
+                if ($protocol == 'HTTP/1.1') {
86
+                    $status = $status . ' Temporary Redirect';
87
+                    break;
88
+                } else {
89
+                    $status = self::STATUS_FOUND;
90
+                    // fallthrough
91
+                }
92
+            case self::STATUS_FOUND;
93
+                $status = $status . ' Found';
94
+                break;
95
+            case self::STATUS_NOT_FOUND;
96
+                $status = $status . ' Not Found';
97
+                break;
98
+            case self::STATUS_INTERNAL_SERVER_ERROR;
99
+                $status = $status . ' Internal Server Error';
100
+                break;
101
+            case self::STATUS_SERVICE_UNAVAILABLE;
102
+                $status = $status . ' Service Unavailable';
103
+                break;
104
+        }
105
+        header($protocol.' '.$status);
106
+    }
107 107
 
108
-	/**
109
-	* Send redirect response
110
-	* @param string $location to redirect to
111
-	*/
112
-	static public function redirect($location) {
113
-		self::setStatus(self::STATUS_TEMPORARY_REDIRECT);
114
-		header('Location: '.$location);
115
-	}
108
+    /**
109
+     * Send redirect response
110
+     * @param string $location to redirect to
111
+     */
112
+    static public function redirect($location) {
113
+        self::setStatus(self::STATUS_TEMPORARY_REDIRECT);
114
+        header('Location: '.$location);
115
+    }
116 116
 
117
-	/**
118
-	* Set response expire time
119
-	* @param string|DateTime $expires date-time when the response expires
120
-	*  string for DateInterval from now
121
-	*  DateTime object when to expire response
122
-	*/
123
-	static public function setExpiresHeader($expires) {
124
-		if (is_string($expires) && $expires[0] == 'P') {
125
-			$interval = $expires;
126
-			$expires = new DateTime('now');
127
-			$expires->add(new DateInterval($interval));
128
-		}
129
-		if ($expires instanceof DateTime) {
130
-			$expires->setTimezone(new DateTimeZone('GMT'));
131
-			$expires = $expires->format(DateTime::RFC2822);
132
-		}
133
-		header('Expires: '.$expires);
134
-	}
117
+    /**
118
+     * Set response expire time
119
+     * @param string|DateTime $expires date-time when the response expires
120
+     *  string for DateInterval from now
121
+     *  DateTime object when to expire response
122
+     */
123
+    static public function setExpiresHeader($expires) {
124
+        if (is_string($expires) && $expires[0] == 'P') {
125
+            $interval = $expires;
126
+            $expires = new DateTime('now');
127
+            $expires->add(new DateInterval($interval));
128
+        }
129
+        if ($expires instanceof DateTime) {
130
+            $expires->setTimezone(new DateTimeZone('GMT'));
131
+            $expires = $expires->format(DateTime::RFC2822);
132
+        }
133
+        header('Expires: '.$expires);
134
+    }
135 135
 
136
-	/**
137
-	* Checks and set ETag header, when the request matches sends a
138
-	* 'not modified' response
139
-	* @param string $etag token to use for modification check
140
-	*/
141
-	static public function setETagHeader($etag) {
142
-		if (empty($etag)) {
143
-			return;
144
-		}
145
-		$etag = '"'.$etag.'"';
146
-		if (isset($_SERVER['HTTP_IF_NONE_MATCH']) &&
147
-		    trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
148
-			self::setStatus(self::STATUS_NOT_MODIFIED);
149
-			exit;
150
-		}
151
-		header('ETag: '.$etag);
152
-	}
136
+    /**
137
+     * Checks and set ETag header, when the request matches sends a
138
+     * 'not modified' response
139
+     * @param string $etag token to use for modification check
140
+     */
141
+    static public function setETagHeader($etag) {
142
+        if (empty($etag)) {
143
+            return;
144
+        }
145
+        $etag = '"'.$etag.'"';
146
+        if (isset($_SERVER['HTTP_IF_NONE_MATCH']) &&
147
+            trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
148
+            self::setStatus(self::STATUS_NOT_MODIFIED);
149
+            exit;
150
+        }
151
+        header('ETag: '.$etag);
152
+    }
153 153
 
154
-	/**
155
-	* Checks and set Last-Modified header, when the request matches sends a
156
-	* 'not modified' response
157
-	* @param int|DateTime|string $lastModified time when the response was last modified
158
-	*/
159
-	static public function setLastModifiedHeader($lastModified) {
160
-		if (empty($lastModified)) {
161
-			return;
162
-		}
163
-		if (is_int($lastModified)) {
164
-			$lastModified = gmdate(DateTime::RFC2822, $lastModified);
165
-		}
166
-		if ($lastModified instanceof DateTime) {
167
-			$lastModified = $lastModified->format(DateTime::RFC2822);
168
-		}
169
-		if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
170
-		    trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {
171
-			self::setStatus(self::STATUS_NOT_MODIFIED);
172
-			exit;
173
-		}
174
-		header('Last-Modified: '.$lastModified);
175
-	}
154
+    /**
155
+     * Checks and set Last-Modified header, when the request matches sends a
156
+     * 'not modified' response
157
+     * @param int|DateTime|string $lastModified time when the response was last modified
158
+     */
159
+    static public function setLastModifiedHeader($lastModified) {
160
+        if (empty($lastModified)) {
161
+            return;
162
+        }
163
+        if (is_int($lastModified)) {
164
+            $lastModified = gmdate(DateTime::RFC2822, $lastModified);
165
+        }
166
+        if ($lastModified instanceof DateTime) {
167
+            $lastModified = $lastModified->format(DateTime::RFC2822);
168
+        }
169
+        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
170
+            trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {
171
+            self::setStatus(self::STATUS_NOT_MODIFIED);
172
+            exit;
173
+        }
174
+        header('Last-Modified: '.$lastModified);
175
+    }
176 176
 
177
-	/**
178
-	 * Sets the content disposition header (with possible workarounds)
179
-	 * @param string $filename file name
180
-	 * @param string $type disposition type, either 'attachment' or 'inline'
181
-	 */
182
-	static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
183
-		if (\OC::$server->getRequest()->isUserAgent(
184
-			[
185
-				\OC\AppFramework\Http\Request::USER_AGENT_IE,
186
-				\OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
187
-				\OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
188
-			])) {
189
-			header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' );
190
-		} else {
191
-			header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename )
192
-												 . '; filename="' . rawurlencode( $filename ) . '"' );
193
-		}
194
-	}
177
+    /**
178
+     * Sets the content disposition header (with possible workarounds)
179
+     * @param string $filename file name
180
+     * @param string $type disposition type, either 'attachment' or 'inline'
181
+     */
182
+    static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
183
+        if (\OC::$server->getRequest()->isUserAgent(
184
+            [
185
+                \OC\AppFramework\Http\Request::USER_AGENT_IE,
186
+                \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
187
+                \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
188
+            ])) {
189
+            header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' );
190
+        } else {
191
+            header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename )
192
+                                                    . '; filename="' . rawurlencode( $filename ) . '"' );
193
+        }
194
+    }
195 195
 
196
-	/**
197
-	 * Sets the content length header (with possible workarounds)
198
-	 * @param string|int|float $length Length to be sent
199
-	 */
200
-	static public function setContentLengthHeader($length) {
201
-		if (PHP_INT_SIZE === 4) {
202
-			if ($length > PHP_INT_MAX && stripos(PHP_SAPI, 'apache') === 0) {
203
-				// Apache PHP SAPI casts Content-Length headers to PHP integers.
204
-				// This enforces a limit of PHP_INT_MAX (2147483647 on 32-bit
205
-				// platforms). So, if the length is greater than PHP_INT_MAX,
206
-				// we just do not send a Content-Length header to prevent
207
-				// bodies from being received incompletely.
208
-				return;
209
-			}
210
-			// Convert signed integer or float to unsigned base-10 string.
211
-			$lfh = new \OC\LargeFileHelper;
212
-			$length = $lfh->formatUnsignedInteger($length);
213
-		}
214
-		header('Content-Length: '.$length);
215
-	}
196
+    /**
197
+     * Sets the content length header (with possible workarounds)
198
+     * @param string|int|float $length Length to be sent
199
+     */
200
+    static public function setContentLengthHeader($length) {
201
+        if (PHP_INT_SIZE === 4) {
202
+            if ($length > PHP_INT_MAX && stripos(PHP_SAPI, 'apache') === 0) {
203
+                // Apache PHP SAPI casts Content-Length headers to PHP integers.
204
+                // This enforces a limit of PHP_INT_MAX (2147483647 on 32-bit
205
+                // platforms). So, if the length is greater than PHP_INT_MAX,
206
+                // we just do not send a Content-Length header to prevent
207
+                // bodies from being received incompletely.
208
+                return;
209
+            }
210
+            // Convert signed integer or float to unsigned base-10 string.
211
+            $lfh = new \OC\LargeFileHelper;
212
+            $length = $lfh->formatUnsignedInteger($length);
213
+        }
214
+        header('Content-Length: '.$length);
215
+    }
216 216
 
217
-	/**
218
-	 * Send file as response, checking and setting caching headers
219
-	 * @param string $filepath of file to send
220
-	 * @deprecated 8.1.0 - Use \OCP\AppFramework\Http\StreamResponse or another AppFramework controller instead
221
-	 */
222
-	static public function sendFile($filepath) {
223
-		$fp = fopen($filepath, 'rb');
224
-		if ($fp) {
225
-			self::setLastModifiedHeader(filemtime($filepath));
226
-			self::setETagHeader(md5_file($filepath));
217
+    /**
218
+     * Send file as response, checking and setting caching headers
219
+     * @param string $filepath of file to send
220
+     * @deprecated 8.1.0 - Use \OCP\AppFramework\Http\StreamResponse or another AppFramework controller instead
221
+     */
222
+    static public function sendFile($filepath) {
223
+        $fp = fopen($filepath, 'rb');
224
+        if ($fp) {
225
+            self::setLastModifiedHeader(filemtime($filepath));
226
+            self::setETagHeader(md5_file($filepath));
227 227
 
228
-			self::setContentLengthHeader(filesize($filepath));
229
-			fpassthru($fp);
230
-		}
231
-		else {
232
-			self::setStatus(self::STATUS_NOT_FOUND);
233
-		}
234
-	}
228
+            self::setContentLengthHeader(filesize($filepath));
229
+            fpassthru($fp);
230
+        }
231
+        else {
232
+            self::setStatus(self::STATUS_NOT_FOUND);
233
+        }
234
+    }
235 235
 
236
-	/**
237
-	 * This function adds some security related headers to all requests served via base.php
238
-	 * The implementation of this function has to happen here to ensure that all third-party
239
-	 * components (e.g. SabreDAV) also benefit from this headers.
240
-	 */
241
-	public static function addSecurityHeaders() {
242
-		/**
243
-		 * FIXME: Content Security Policy for legacy ownCloud components. This
244
-		 * can be removed once \OCP\AppFramework\Http\Response from the AppFramework
245
-		 * is used everywhere.
246
-		 * @see \OCP\AppFramework\Http\Response::getHeaders
247
-		 */
248
-		$policy = 'default-src \'self\'; '
249
-			. 'script-src \'self\' \'unsafe-eval\'; '
250
-			. 'style-src \'self\' \'unsafe-inline\'; '
251
-			. 'frame-src *; '
252
-			. 'img-src * data: blob:; '
253
-			. 'font-src \'self\' data:; '
254
-			. 'media-src *; ' 
255
-			. 'connect-src *';
256
-		header('Content-Security-Policy:' . $policy);
236
+    /**
237
+     * This function adds some security related headers to all requests served via base.php
238
+     * The implementation of this function has to happen here to ensure that all third-party
239
+     * components (e.g. SabreDAV) also benefit from this headers.
240
+     */
241
+    public static function addSecurityHeaders() {
242
+        /**
243
+         * FIXME: Content Security Policy for legacy ownCloud components. This
244
+         * can be removed once \OCP\AppFramework\Http\Response from the AppFramework
245
+         * is used everywhere.
246
+         * @see \OCP\AppFramework\Http\Response::getHeaders
247
+         */
248
+        $policy = 'default-src \'self\'; '
249
+            . 'script-src \'self\' \'unsafe-eval\'; '
250
+            . 'style-src \'self\' \'unsafe-inline\'; '
251
+            . 'frame-src *; '
252
+            . 'img-src * data: blob:; '
253
+            . 'font-src \'self\' data:; '
254
+            . 'media-src *; ' 
255
+            . 'connect-src *';
256
+        header('Content-Security-Policy:' . $policy);
257 257
 
258
-		// Send fallback headers for installations that don't have the possibility to send
259
-		// custom headers on the webserver side
260
-		if(getenv('modHeadersAvailable') !== 'true') {
261
-			header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
262
-			header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE
263
-			header('X-Frame-Options: Sameorigin'); // Disallow iFraming from other domains
264
-			header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag
265
-			header('X-Download-Options: noopen'); // https://msdn.microsoft.com/en-us/library/jj542450(v=vs.85).aspx
266
-			header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
267
-		}
268
-	}
258
+        // Send fallback headers for installations that don't have the possibility to send
259
+        // custom headers on the webserver side
260
+        if(getenv('modHeadersAvailable') !== 'true') {
261
+            header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
262
+            header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE
263
+            header('X-Frame-Options: Sameorigin'); // Disallow iFraming from other domains
264
+            header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag
265
+            header('X-Download-Options: noopen'); // https://msdn.microsoft.com/en-us/library/jj542450(v=vs.85).aspx
266
+            header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
267
+        }
268
+    }
269 269
 
270 270
 }
Please login to merge, or discard this patch.
lib/private/legacy/db/statementwrapper.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -36,88 +36,88 @@
 block discarded – undo
36 36
  * @method array fetchAll(integer $fetchMode = null);
37 37
  */
38 38
 class OC_DB_StatementWrapper {
39
-	/**
40
-	 * @var \Doctrine\DBAL\Driver\Statement
41
-	 */
42
-	private $statement = null;
43
-	private $isManipulation = false;
44
-	private $lastArguments = array();
39
+    /**
40
+     * @var \Doctrine\DBAL\Driver\Statement
41
+     */
42
+    private $statement = null;
43
+    private $isManipulation = false;
44
+    private $lastArguments = array();
45 45
 
46
-	/**
47
-	 * @param boolean $isManipulation
48
-	 */
49
-	public function __construct($statement, $isManipulation) {
50
-		$this->statement = $statement;
51
-		$this->isManipulation = $isManipulation;
52
-	}
46
+    /**
47
+     * @param boolean $isManipulation
48
+     */
49
+    public function __construct($statement, $isManipulation) {
50
+        $this->statement = $statement;
51
+        $this->isManipulation = $isManipulation;
52
+    }
53 53
 
54
-	/**
55
-	 * pass all other function directly to the \Doctrine\DBAL\Driver\Statement
56
-	 */
57
-	public function __call($name,$arguments) {
58
-		return call_user_func_array(array($this->statement,$name), $arguments);
59
-	}
54
+    /**
55
+     * pass all other function directly to the \Doctrine\DBAL\Driver\Statement
56
+     */
57
+    public function __call($name,$arguments) {
58
+        return call_user_func_array(array($this->statement,$name), $arguments);
59
+    }
60 60
 
61
-	/**
62
-	 * make execute return the result instead of a bool
63
-	 *
64
-	 * @param array $input
65
-	 * @return \OC_DB_StatementWrapper|int
66
-	 */
67
-	public function execute($input=array()) {
68
-		if(\OC::$server->getSystemConfig()->getValue( "log_query", false)) {
69
-			$params_str = str_replace("\n", " ", var_export($input, true));
70
-			\OCP\Util::writeLog('core', 'DB execute with arguments : '.$params_str, \OCP\Util::DEBUG);
71
-		}
72
-		$this->lastArguments = $input;
73
-		if (count($input) > 0) {
74
-			$result = $this->statement->execute($input);
75
-		} else {
76
-			$result = $this->statement->execute();
77
-		}
61
+    /**
62
+     * make execute return the result instead of a bool
63
+     *
64
+     * @param array $input
65
+     * @return \OC_DB_StatementWrapper|int
66
+     */
67
+    public function execute($input=array()) {
68
+        if(\OC::$server->getSystemConfig()->getValue( "log_query", false)) {
69
+            $params_str = str_replace("\n", " ", var_export($input, true));
70
+            \OCP\Util::writeLog('core', 'DB execute with arguments : '.$params_str, \OCP\Util::DEBUG);
71
+        }
72
+        $this->lastArguments = $input;
73
+        if (count($input) > 0) {
74
+            $result = $this->statement->execute($input);
75
+        } else {
76
+            $result = $this->statement->execute();
77
+        }
78 78
 
79
-		if ($result === false) {
80
-			return false;
81
-		}
82
-		if ($this->isManipulation) {
83
-			$count = $this->statement->rowCount();
84
-			return $count;
85
-		} else {
86
-			return $this;
87
-		}
88
-	}
79
+        if ($result === false) {
80
+            return false;
81
+        }
82
+        if ($this->isManipulation) {
83
+            $count = $this->statement->rowCount();
84
+            return $count;
85
+        } else {
86
+            return $this;
87
+        }
88
+    }
89 89
 
90
-	/**
91
-	 * provide an alias for fetch
92
-	 *
93
-	 * @return mixed
94
-	 */
95
-	public function fetchRow() {
96
-		return $this->statement->fetch();
97
-	}
90
+    /**
91
+     * provide an alias for fetch
92
+     *
93
+     * @return mixed
94
+     */
95
+    public function fetchRow() {
96
+        return $this->statement->fetch();
97
+    }
98 98
 
99
-	/**
100
-	 * Provide a simple fetchOne.
101
-	 *
102
-	 * fetch single column from the next row
103
-	 * @param int $column the column number to fetch
104
-	 * @return string
105
-	 */
106
-	public function fetchOne($column = 0) {
107
-		return $this->statement->fetchColumn($column);
108
-	}
99
+    /**
100
+     * Provide a simple fetchOne.
101
+     *
102
+     * fetch single column from the next row
103
+     * @param int $column the column number to fetch
104
+     * @return string
105
+     */
106
+    public function fetchOne($column = 0) {
107
+        return $this->statement->fetchColumn($column);
108
+    }
109 109
 
110
-	/**
111
-	 * Binds a PHP variable to a corresponding named or question mark placeholder in the
112
-	 * SQL statement that was use to prepare the statement.
113
-	 *
114
-	 * @param mixed $column Either the placeholder name or the 1-indexed placeholder index
115
-	 * @param mixed $variable The variable to bind
116
-	 * @param integer|null $type one of the  PDO::PARAM_* constants
117
-	 * @param integer|null $length max length when using an OUT bind
118
-	 * @return boolean
119
-	 */
120
-	public function bindParam($column, &$variable, $type = null, $length = null){
121
-		return $this->statement->bindParam($column, $variable, $type, $length);
122
-	}
110
+    /**
111
+     * Binds a PHP variable to a corresponding named or question mark placeholder in the
112
+     * SQL statement that was use to prepare the statement.
113
+     *
114
+     * @param mixed $column Either the placeholder name or the 1-indexed placeholder index
115
+     * @param mixed $variable The variable to bind
116
+     * @param integer|null $type one of the  PDO::PARAM_* constants
117
+     * @param integer|null $length max length when using an OUT bind
118
+     * @return boolean
119
+     */
120
+    public function bindParam($column, &$variable, $type = null, $length = null){
121
+        return $this->statement->bindParam($column, $variable, $type, $length);
122
+    }
123 123
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * pass all other function directly to the \Doctrine\DBAL\Driver\Statement
56 56
 	 */
57
-	public function __call($name,$arguments) {
58
-		return call_user_func_array(array($this->statement,$name), $arguments);
57
+	public function __call($name, $arguments) {
58
+		return call_user_func_array(array($this->statement, $name), $arguments);
59 59
 	}
60 60
 
61 61
 	/**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 * @param array $input
65 65
 	 * @return \OC_DB_StatementWrapper|int
66 66
 	 */
67
-	public function execute($input=array()) {
68
-		if(\OC::$server->getSystemConfig()->getValue( "log_query", false)) {
67
+	public function execute($input = array()) {
68
+		if (\OC::$server->getSystemConfig()->getValue("log_query", false)) {
69 69
 			$params_str = str_replace("\n", " ", var_export($input, true));
70 70
 			\OCP\Util::writeLog('core', 'DB execute with arguments : '.$params_str, \OCP\Util::DEBUG);
71 71
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param integer|null $length max length when using an OUT bind
118 118
 	 * @return boolean
119 119
 	 */
120
-	public function bindParam($column, &$variable, $type = null, $length = null){
120
+	public function bindParam($column, &$variable, $type = null, $length = null) {
121 121
 		return $this->statement->bindParam($column, $variable, $type, $length);
122 122
 	}
123 123
 }
Please login to merge, or discard this patch.
lib/private/legacy/image.php 3 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -224,8 +224,9 @@
 block discarded – undo
224 224
 	 */
225 225
 	private function _output($filePath = null, $mimeType = null) {
226 226
 		if ($filePath) {
227
-			if (!file_exists(dirname($filePath)))
228
-				mkdir(dirname($filePath), 0777, true);
227
+			if (!file_exists(dirname($filePath))) {
228
+							mkdir(dirname($filePath), 0777, true);
229
+			}
229 230
 			if (!is_writable(dirname($filePath))) {
230 231
 				$this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', array('app' => 'core'));
231 232
 				return false;
Please login to merge, or discard this patch.
Indentation   +1021 added lines, -1021 removed lines patch added patch discarded remove patch
@@ -40,512 +40,512 @@  discard block
 block discarded – undo
40 40
  * Class for basic image manipulation
41 41
  */
42 42
 class OC_Image implements \OCP\IImage {
43
-	/** @var false|resource */
44
-	protected $resource = false; // tmp resource.
45
-	/** @var int */
46
-	protected $imageType = IMAGETYPE_PNG; // Default to png if file type isn't evident.
47
-	/** @var string */
48
-	protected $mimeType = 'image/png'; // Default to png
49
-	/** @var int */
50
-	protected $bitDepth = 24;
51
-	/** @var null|string */
52
-	protected $filePath = null;
53
-	/** @var finfo */
54
-	private $fileInfo;
55
-	/** @var \OCP\ILogger */
56
-	private $logger;
43
+    /** @var false|resource */
44
+    protected $resource = false; // tmp resource.
45
+    /** @var int */
46
+    protected $imageType = IMAGETYPE_PNG; // Default to png if file type isn't evident.
47
+    /** @var string */
48
+    protected $mimeType = 'image/png'; // Default to png
49
+    /** @var int */
50
+    protected $bitDepth = 24;
51
+    /** @var null|string */
52
+    protected $filePath = null;
53
+    /** @var finfo */
54
+    private $fileInfo;
55
+    /** @var \OCP\ILogger */
56
+    private $logger;
57 57
 
58
-	/**
59
-	 * Get mime type for an image file.
60
-	 *
61
-	 * @param string|null $filePath The path to a local image file.
62
-	 * @return string The mime type if the it could be determined, otherwise an empty string.
63
-	 */
64
-	static public function getMimeTypeForFile($filePath) {
65
-		// exif_imagetype throws "read error!" if file is less than 12 byte
66
-		if ($filePath !== null && filesize($filePath) > 11) {
67
-			$imageType = exif_imagetype($filePath);
68
-		} else {
69
-			$imageType = false;
70
-		}
71
-		return $imageType ? image_type_to_mime_type($imageType) : '';
72
-	}
58
+    /**
59
+     * Get mime type for an image file.
60
+     *
61
+     * @param string|null $filePath The path to a local image file.
62
+     * @return string The mime type if the it could be determined, otherwise an empty string.
63
+     */
64
+    static public function getMimeTypeForFile($filePath) {
65
+        // exif_imagetype throws "read error!" if file is less than 12 byte
66
+        if ($filePath !== null && filesize($filePath) > 11) {
67
+            $imageType = exif_imagetype($filePath);
68
+        } else {
69
+            $imageType = false;
70
+        }
71
+        return $imageType ? image_type_to_mime_type($imageType) : '';
72
+    }
73 73
 
74
-	/**
75
-	 * Constructor.
76
-	 *
77
-	 * @param resource|string $imageRef The path to a local file, a base64 encoded string or a resource created by
78
-	 * an imagecreate* function.
79
-	 * @param \OCP\ILogger $logger
80
-	 */
81
-	public function __construct($imageRef = null, $logger = null) {
82
-		$this->logger = $logger;
83
-		if (is_null($logger)) {
84
-			$this->logger = \OC::$server->getLogger();
85
-		}
74
+    /**
75
+     * Constructor.
76
+     *
77
+     * @param resource|string $imageRef The path to a local file, a base64 encoded string or a resource created by
78
+     * an imagecreate* function.
79
+     * @param \OCP\ILogger $logger
80
+     */
81
+    public function __construct($imageRef = null, $logger = null) {
82
+        $this->logger = $logger;
83
+        if (is_null($logger)) {
84
+            $this->logger = \OC::$server->getLogger();
85
+        }
86 86
 
87
-		if (!extension_loaded('gd') || !function_exists('gd_info')) {
88
-			$this->logger->error(__METHOD__ . '(): GD module not installed', array('app' => 'core'));
89
-			return false;
90
-		}
87
+        if (!extension_loaded('gd') || !function_exists('gd_info')) {
88
+            $this->logger->error(__METHOD__ . '(): GD module not installed', array('app' => 'core'));
89
+            return false;
90
+        }
91 91
 
92
-		if (\OC_Util::fileInfoLoaded()) {
93
-			$this->fileInfo = new finfo(FILEINFO_MIME_TYPE);
94
-		}
92
+        if (\OC_Util::fileInfoLoaded()) {
93
+            $this->fileInfo = new finfo(FILEINFO_MIME_TYPE);
94
+        }
95 95
 
96
-		if (!is_null($imageRef)) {
97
-			$this->load($imageRef);
98
-		}
99
-	}
96
+        if (!is_null($imageRef)) {
97
+            $this->load($imageRef);
98
+        }
99
+    }
100 100
 
101
-	/**
102
-	 * Determine whether the object contains an image resource.
103
-	 *
104
-	 * @return bool
105
-	 */
106
-	public function valid() { // apparently you can't name a method 'empty'...
107
-		return is_resource($this->resource);
108
-	}
101
+    /**
102
+     * Determine whether the object contains an image resource.
103
+     *
104
+     * @return bool
105
+     */
106
+    public function valid() { // apparently you can't name a method 'empty'...
107
+        return is_resource($this->resource);
108
+    }
109 109
 
110
-	/**
111
-	 * Returns the MIME type of the image or an empty string if no image is loaded.
112
-	 *
113
-	 * @return string
114
-	 */
115
-	public function mimeType() {
116
-		return $this->valid() ? $this->mimeType : '';
117
-	}
110
+    /**
111
+     * Returns the MIME type of the image or an empty string if no image is loaded.
112
+     *
113
+     * @return string
114
+     */
115
+    public function mimeType() {
116
+        return $this->valid() ? $this->mimeType : '';
117
+    }
118 118
 
119
-	/**
120
-	 * Returns the width of the image or -1 if no image is loaded.
121
-	 *
122
-	 * @return int
123
-	 */
124
-	public function width() {
125
-		return $this->valid() ? imagesx($this->resource) : -1;
126
-	}
119
+    /**
120
+     * Returns the width of the image or -1 if no image is loaded.
121
+     *
122
+     * @return int
123
+     */
124
+    public function width() {
125
+        return $this->valid() ? imagesx($this->resource) : -1;
126
+    }
127 127
 
128
-	/**
129
-	 * Returns the height of the image or -1 if no image is loaded.
130
-	 *
131
-	 * @return int
132
-	 */
133
-	public function height() {
134
-		return $this->valid() ? imagesy($this->resource) : -1;
135
-	}
128
+    /**
129
+     * Returns the height of the image or -1 if no image is loaded.
130
+     *
131
+     * @return int
132
+     */
133
+    public function height() {
134
+        return $this->valid() ? imagesy($this->resource) : -1;
135
+    }
136 136
 
137
-	/**
138
-	 * Returns the width when the image orientation is top-left.
139
-	 *
140
-	 * @return int
141
-	 */
142
-	public function widthTopLeft() {
143
-		$o = $this->getOrientation();
144
-		$this->logger->debug('OC_Image->widthTopLeft() Orientation: ' . $o, array('app' => 'core'));
145
-		switch ($o) {
146
-			case -1:
147
-			case 1:
148
-			case 2: // Not tested
149
-			case 3:
150
-			case 4: // Not tested
151
-				return $this->width();
152
-			case 5: // Not tested
153
-			case 6:
154
-			case 7: // Not tested
155
-			case 8:
156
-				return $this->height();
157
-		}
158
-		return $this->width();
159
-	}
137
+    /**
138
+     * Returns the width when the image orientation is top-left.
139
+     *
140
+     * @return int
141
+     */
142
+    public function widthTopLeft() {
143
+        $o = $this->getOrientation();
144
+        $this->logger->debug('OC_Image->widthTopLeft() Orientation: ' . $o, array('app' => 'core'));
145
+        switch ($o) {
146
+            case -1:
147
+            case 1:
148
+            case 2: // Not tested
149
+            case 3:
150
+            case 4: // Not tested
151
+                return $this->width();
152
+            case 5: // Not tested
153
+            case 6:
154
+            case 7: // Not tested
155
+            case 8:
156
+                return $this->height();
157
+        }
158
+        return $this->width();
159
+    }
160 160
 
161
-	/**
162
-	 * Returns the height when the image orientation is top-left.
163
-	 *
164
-	 * @return int
165
-	 */
166
-	public function heightTopLeft() {
167
-		$o = $this->getOrientation();
168
-		$this->logger->debug('OC_Image->heightTopLeft() Orientation: ' . $o, array('app' => 'core'));
169
-		switch ($o) {
170
-			case -1:
171
-			case 1:
172
-			case 2: // Not tested
173
-			case 3:
174
-			case 4: // Not tested
175
-				return $this->height();
176
-			case 5: // Not tested
177
-			case 6:
178
-			case 7: // Not tested
179
-			case 8:
180
-				return $this->width();
181
-		}
182
-		return $this->height();
183
-	}
161
+    /**
162
+     * Returns the height when the image orientation is top-left.
163
+     *
164
+     * @return int
165
+     */
166
+    public function heightTopLeft() {
167
+        $o = $this->getOrientation();
168
+        $this->logger->debug('OC_Image->heightTopLeft() Orientation: ' . $o, array('app' => 'core'));
169
+        switch ($o) {
170
+            case -1:
171
+            case 1:
172
+            case 2: // Not tested
173
+            case 3:
174
+            case 4: // Not tested
175
+                return $this->height();
176
+            case 5: // Not tested
177
+            case 6:
178
+            case 7: // Not tested
179
+            case 8:
180
+                return $this->width();
181
+        }
182
+        return $this->height();
183
+    }
184 184
 
185
-	/**
186
-	 * Outputs the image.
187
-	 *
188
-	 * @param string $mimeType
189
-	 * @return bool
190
-	 */
191
-	public function show($mimeType = null) {
192
-		if ($mimeType === null) {
193
-			$mimeType = $this->mimeType();
194
-		}
195
-		header('Content-Type: ' . $mimeType);
196
-		return $this->_output(null, $mimeType);
197
-	}
185
+    /**
186
+     * Outputs the image.
187
+     *
188
+     * @param string $mimeType
189
+     * @return bool
190
+     */
191
+    public function show($mimeType = null) {
192
+        if ($mimeType === null) {
193
+            $mimeType = $this->mimeType();
194
+        }
195
+        header('Content-Type: ' . $mimeType);
196
+        return $this->_output(null, $mimeType);
197
+    }
198 198
 
199
-	/**
200
-	 * Saves the image.
201
-	 *
202
-	 * @param string $filePath
203
-	 * @param string $mimeType
204
-	 * @return bool
205
-	 */
199
+    /**
200
+     * Saves the image.
201
+     *
202
+     * @param string $filePath
203
+     * @param string $mimeType
204
+     * @return bool
205
+     */
206 206
 
207
-	public function save($filePath = null, $mimeType = null) {
208
-		if ($mimeType === null) {
209
-			$mimeType = $this->mimeType();
210
-		}
211
-		if ($filePath === null && $this->filePath === null) {
212
-			$this->logger->error(__METHOD__ . '(): called with no path.', array('app' => 'core'));
213
-			return false;
214
-		} elseif ($filePath === null && $this->filePath !== null) {
215
-			$filePath = $this->filePath;
216
-		}
217
-		return $this->_output($filePath, $mimeType);
218
-	}
207
+    public function save($filePath = null, $mimeType = null) {
208
+        if ($mimeType === null) {
209
+            $mimeType = $this->mimeType();
210
+        }
211
+        if ($filePath === null && $this->filePath === null) {
212
+            $this->logger->error(__METHOD__ . '(): called with no path.', array('app' => 'core'));
213
+            return false;
214
+        } elseif ($filePath === null && $this->filePath !== null) {
215
+            $filePath = $this->filePath;
216
+        }
217
+        return $this->_output($filePath, $mimeType);
218
+    }
219 219
 
220
-	/**
221
-	 * Outputs/saves the image.
222
-	 *
223
-	 * @param string $filePath
224
-	 * @param string $mimeType
225
-	 * @return bool
226
-	 * @throws Exception
227
-	 */
228
-	private function _output($filePath = null, $mimeType = null) {
229
-		if ($filePath) {
230
-			if (!file_exists(dirname($filePath)))
231
-				mkdir(dirname($filePath), 0777, true);
232
-			if (!is_writable(dirname($filePath))) {
233
-				$this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', array('app' => 'core'));
234
-				return false;
235
-			} elseif (is_writable(dirname($filePath)) && file_exists($filePath) && !is_writable($filePath)) {
236
-				$this->logger->error(__METHOD__ . '(): File \'' . $filePath . '\' is not writable.', array('app' => 'core'));
237
-				return false;
238
-			}
239
-		}
240
-		if (!$this->valid()) {
241
-			return false;
242
-		}
220
+    /**
221
+     * Outputs/saves the image.
222
+     *
223
+     * @param string $filePath
224
+     * @param string $mimeType
225
+     * @return bool
226
+     * @throws Exception
227
+     */
228
+    private function _output($filePath = null, $mimeType = null) {
229
+        if ($filePath) {
230
+            if (!file_exists(dirname($filePath)))
231
+                mkdir(dirname($filePath), 0777, true);
232
+            if (!is_writable(dirname($filePath))) {
233
+                $this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', array('app' => 'core'));
234
+                return false;
235
+            } elseif (is_writable(dirname($filePath)) && file_exists($filePath) && !is_writable($filePath)) {
236
+                $this->logger->error(__METHOD__ . '(): File \'' . $filePath . '\' is not writable.', array('app' => 'core'));
237
+                return false;
238
+            }
239
+        }
240
+        if (!$this->valid()) {
241
+            return false;
242
+        }
243 243
 
244
-		$imageType = $this->imageType;
245
-		if ($mimeType !== null) {
246
-			switch ($mimeType) {
247
-				case 'image/gif':
248
-					$imageType = IMAGETYPE_GIF;
249
-					break;
250
-				case 'image/jpeg':
251
-					$imageType = IMAGETYPE_JPEG;
252
-					break;
253
-				case 'image/png':
254
-					$imageType = IMAGETYPE_PNG;
255
-					break;
256
-				case 'image/x-xbitmap':
257
-					$imageType = IMAGETYPE_XBM;
258
-					break;
259
-				case 'image/bmp':
260
-				case 'image/x-ms-bmp':
261
-					$imageType = IMAGETYPE_BMP;
262
-					break;
263
-				default:
264
-					throw new Exception('\OC_Image::_output(): "' . $mimeType . '" is not supported when forcing a specific output format');
265
-			}
266
-		}
244
+        $imageType = $this->imageType;
245
+        if ($mimeType !== null) {
246
+            switch ($mimeType) {
247
+                case 'image/gif':
248
+                    $imageType = IMAGETYPE_GIF;
249
+                    break;
250
+                case 'image/jpeg':
251
+                    $imageType = IMAGETYPE_JPEG;
252
+                    break;
253
+                case 'image/png':
254
+                    $imageType = IMAGETYPE_PNG;
255
+                    break;
256
+                case 'image/x-xbitmap':
257
+                    $imageType = IMAGETYPE_XBM;
258
+                    break;
259
+                case 'image/bmp':
260
+                case 'image/x-ms-bmp':
261
+                    $imageType = IMAGETYPE_BMP;
262
+                    break;
263
+                default:
264
+                    throw new Exception('\OC_Image::_output(): "' . $mimeType . '" is not supported when forcing a specific output format');
265
+            }
266
+        }
267 267
 
268
-		switch ($imageType) {
269
-			case IMAGETYPE_GIF:
270
-				$retVal = imagegif($this->resource, $filePath);
271
-				break;
272
-			case IMAGETYPE_JPEG:
273
-				$retVal = imagejpeg($this->resource, $filePath);
274
-				break;
275
-			case IMAGETYPE_PNG:
276
-				$retVal = imagepng($this->resource, $filePath);
277
-				break;
278
-			case IMAGETYPE_XBM:
279
-				if (function_exists('imagexbm')) {
280
-					$retVal = imagexbm($this->resource, $filePath);
281
-				} else {
282
-					throw new Exception('\OC_Image::_output(): imagexbm() is not supported.');
283
-				}
268
+        switch ($imageType) {
269
+            case IMAGETYPE_GIF:
270
+                $retVal = imagegif($this->resource, $filePath);
271
+                break;
272
+            case IMAGETYPE_JPEG:
273
+                $retVal = imagejpeg($this->resource, $filePath);
274
+                break;
275
+            case IMAGETYPE_PNG:
276
+                $retVal = imagepng($this->resource, $filePath);
277
+                break;
278
+            case IMAGETYPE_XBM:
279
+                if (function_exists('imagexbm')) {
280
+                    $retVal = imagexbm($this->resource, $filePath);
281
+                } else {
282
+                    throw new Exception('\OC_Image::_output(): imagexbm() is not supported.');
283
+                }
284 284
 
285
-				break;
286
-			case IMAGETYPE_WBMP:
287
-				$retVal = imagewbmp($this->resource, $filePath);
288
-				break;
289
-			case IMAGETYPE_BMP:
290
-				$retVal = imagebmp($this->resource, $filePath, $this->bitDepth);
291
-				break;
292
-			default:
293
-				$retVal = imagepng($this->resource, $filePath);
294
-		}
295
-		return $retVal;
296
-	}
285
+                break;
286
+            case IMAGETYPE_WBMP:
287
+                $retVal = imagewbmp($this->resource, $filePath);
288
+                break;
289
+            case IMAGETYPE_BMP:
290
+                $retVal = imagebmp($this->resource, $filePath, $this->bitDepth);
291
+                break;
292
+            default:
293
+                $retVal = imagepng($this->resource, $filePath);
294
+        }
295
+        return $retVal;
296
+    }
297 297
 
298
-	/**
299
-	 * Prints the image when called as $image().
300
-	 */
301
-	public function __invoke() {
302
-		return $this->show();
303
-	}
298
+    /**
299
+     * Prints the image when called as $image().
300
+     */
301
+    public function __invoke() {
302
+        return $this->show();
303
+    }
304 304
 
305
-	/**
306
-	 * @return resource Returns the image resource in any.
307
-	 */
308
-	public function resource() {
309
-		return $this->resource;
310
-	}
305
+    /**
306
+     * @return resource Returns the image resource in any.
307
+     */
308
+    public function resource() {
309
+        return $this->resource;
310
+    }
311 311
 
312
-	/**
313
-	 * @return null|string Returns the raw image data.
314
-	 */
315
-	public function data() {
316
-		if (!$this->valid()) {
317
-			return null;
318
-		}
319
-		ob_start();
320
-		switch ($this->mimeType) {
321
-			case "image/png":
322
-				$res = imagepng($this->resource);
323
-				break;
324
-			case "image/jpeg":
325
-				$res = imagejpeg($this->resource);
326
-				break;
327
-			case "image/gif":
328
-				$res = imagegif($this->resource);
329
-				break;
330
-			default:
331
-				$res = imagepng($this->resource);
332
-				$this->logger->info('OC_Image->data. Could not guess mime-type, defaulting to png', array('app' => 'core'));
333
-				break;
334
-		}
335
-		if (!$res) {
336
-			$this->logger->error('OC_Image->data. Error getting image data.', array('app' => 'core'));
337
-		}
338
-		return ob_get_clean();
339
-	}
312
+    /**
313
+     * @return null|string Returns the raw image data.
314
+     */
315
+    public function data() {
316
+        if (!$this->valid()) {
317
+            return null;
318
+        }
319
+        ob_start();
320
+        switch ($this->mimeType) {
321
+            case "image/png":
322
+                $res = imagepng($this->resource);
323
+                break;
324
+            case "image/jpeg":
325
+                $res = imagejpeg($this->resource);
326
+                break;
327
+            case "image/gif":
328
+                $res = imagegif($this->resource);
329
+                break;
330
+            default:
331
+                $res = imagepng($this->resource);
332
+                $this->logger->info('OC_Image->data. Could not guess mime-type, defaulting to png', array('app' => 'core'));
333
+                break;
334
+        }
335
+        if (!$res) {
336
+            $this->logger->error('OC_Image->data. Error getting image data.', array('app' => 'core'));
337
+        }
338
+        return ob_get_clean();
339
+    }
340 340
 
341
-	/**
342
-	 * @return string - base64 encoded, which is suitable for embedding in a VCard.
343
-	 */
344
-	function __toString() {
345
-		return base64_encode($this->data());
346
-	}
341
+    /**
342
+     * @return string - base64 encoded, which is suitable for embedding in a VCard.
343
+     */
344
+    function __toString() {
345
+        return base64_encode($this->data());
346
+    }
347 347
 
348
-	/**
349
-	 * (I'm open for suggestions on better method name ;)
350
-	 * Get the orientation based on EXIF data.
351
-	 *
352
-	 * @return int The orientation or -1 if no EXIF data is available.
353
-	 */
354
-	public function getOrientation() {
355
-		if ($this->imageType !== IMAGETYPE_JPEG) {
356
-			$this->logger->debug('OC_Image->fixOrientation() Image is not a JPEG.', array('app' => 'core'));
357
-			return -1;
358
-		}
359
-		if (!is_callable('exif_read_data')) {
360
-			$this->logger->debug('OC_Image->fixOrientation() Exif module not enabled.', array('app' => 'core'));
361
-			return -1;
362
-		}
363
-		if (!$this->valid()) {
364
-			$this->logger->debug('OC_Image->fixOrientation() No image loaded.', array('app' => 'core'));
365
-			return -1;
366
-		}
367
-		if (is_null($this->filePath) || !is_readable($this->filePath)) {
368
-			$this->logger->debug('OC_Image->fixOrientation() No readable file path set.', array('app' => 'core'));
369
-			return -1;
370
-		}
371
-		$exif = @exif_read_data($this->filePath, 'IFD0');
372
-		if (!$exif) {
373
-			return -1;
374
-		}
375
-		if (!isset($exif['Orientation'])) {
376
-			return -1;
377
-		}
378
-		return $exif['Orientation'];
379
-	}
348
+    /**
349
+     * (I'm open for suggestions on better method name ;)
350
+     * Get the orientation based on EXIF data.
351
+     *
352
+     * @return int The orientation or -1 if no EXIF data is available.
353
+     */
354
+    public function getOrientation() {
355
+        if ($this->imageType !== IMAGETYPE_JPEG) {
356
+            $this->logger->debug('OC_Image->fixOrientation() Image is not a JPEG.', array('app' => 'core'));
357
+            return -1;
358
+        }
359
+        if (!is_callable('exif_read_data')) {
360
+            $this->logger->debug('OC_Image->fixOrientation() Exif module not enabled.', array('app' => 'core'));
361
+            return -1;
362
+        }
363
+        if (!$this->valid()) {
364
+            $this->logger->debug('OC_Image->fixOrientation() No image loaded.', array('app' => 'core'));
365
+            return -1;
366
+        }
367
+        if (is_null($this->filePath) || !is_readable($this->filePath)) {
368
+            $this->logger->debug('OC_Image->fixOrientation() No readable file path set.', array('app' => 'core'));
369
+            return -1;
370
+        }
371
+        $exif = @exif_read_data($this->filePath, 'IFD0');
372
+        if (!$exif) {
373
+            return -1;
374
+        }
375
+        if (!isset($exif['Orientation'])) {
376
+            return -1;
377
+        }
378
+        return $exif['Orientation'];
379
+    }
380 380
 
381
-	/**
382
-	 * (I'm open for suggestions on better method name ;)
383
-	 * Fixes orientation based on EXIF data.
384
-	 *
385
-	 * @return bool.
386
-	 */
387
-	public function fixOrientation() {
388
-		$o = $this->getOrientation();
389
-		$this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, array('app' => 'core'));
390
-		$rotate = 0;
391
-		$flip = false;
392
-		switch ($o) {
393
-			case -1:
394
-				return false; //Nothing to fix
395
-			case 1:
396
-				$rotate = 0;
397
-				break;
398
-			case 2:
399
-				$rotate = 0;
400
-				$flip = true;
401
-				break;
402
-			case 3:
403
-				$rotate = 180;
404
-				break;
405
-			case 4:
406
-				$rotate = 180;
407
-				$flip = true;
408
-				break;
409
-			case 5:
410
-				$rotate = 90;
411
-				$flip = true;
412
-				break;
413
-			case 6:
414
-				$rotate = 270;
415
-				break;
416
-			case 7:
417
-				$rotate = 270;
418
-				$flip = true;
419
-				break;
420
-			case 8:
421
-				$rotate = 90;
422
-				break;
423
-		}
424
-		if($flip && function_exists('imageflip')) {
425
-			imageflip($this->resource, IMG_FLIP_HORIZONTAL);
426
-		}
427
-		if ($rotate) {
428
-			$res = imagerotate($this->resource, $rotate, 0);
429
-			if ($res) {
430
-				if (imagealphablending($res, true)) {
431
-					if (imagesavealpha($res, true)) {
432
-						imagedestroy($this->resource);
433
-						$this->resource = $res;
434
-						return true;
435
-					} else {
436
-						$this->logger->debug('OC_Image->fixOrientation() Error during alpha-saving', array('app' => 'core'));
437
-						return false;
438
-					}
439
-				} else {
440
-					$this->logger->debug('OC_Image->fixOrientation() Error during alpha-blending', array('app' => 'core'));
441
-					return false;
442
-				}
443
-			} else {
444
-				$this->logger->debug('OC_Image->fixOrientation() Error during orientation fixing', array('app' => 'core'));
445
-				return false;
446
-			}
447
-		}
448
-		return false;
449
-	}
381
+    /**
382
+     * (I'm open for suggestions on better method name ;)
383
+     * Fixes orientation based on EXIF data.
384
+     *
385
+     * @return bool.
386
+     */
387
+    public function fixOrientation() {
388
+        $o = $this->getOrientation();
389
+        $this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, array('app' => 'core'));
390
+        $rotate = 0;
391
+        $flip = false;
392
+        switch ($o) {
393
+            case -1:
394
+                return false; //Nothing to fix
395
+            case 1:
396
+                $rotate = 0;
397
+                break;
398
+            case 2:
399
+                $rotate = 0;
400
+                $flip = true;
401
+                break;
402
+            case 3:
403
+                $rotate = 180;
404
+                break;
405
+            case 4:
406
+                $rotate = 180;
407
+                $flip = true;
408
+                break;
409
+            case 5:
410
+                $rotate = 90;
411
+                $flip = true;
412
+                break;
413
+            case 6:
414
+                $rotate = 270;
415
+                break;
416
+            case 7:
417
+                $rotate = 270;
418
+                $flip = true;
419
+                break;
420
+            case 8:
421
+                $rotate = 90;
422
+                break;
423
+        }
424
+        if($flip && function_exists('imageflip')) {
425
+            imageflip($this->resource, IMG_FLIP_HORIZONTAL);
426
+        }
427
+        if ($rotate) {
428
+            $res = imagerotate($this->resource, $rotate, 0);
429
+            if ($res) {
430
+                if (imagealphablending($res, true)) {
431
+                    if (imagesavealpha($res, true)) {
432
+                        imagedestroy($this->resource);
433
+                        $this->resource = $res;
434
+                        return true;
435
+                    } else {
436
+                        $this->logger->debug('OC_Image->fixOrientation() Error during alpha-saving', array('app' => 'core'));
437
+                        return false;
438
+                    }
439
+                } else {
440
+                    $this->logger->debug('OC_Image->fixOrientation() Error during alpha-blending', array('app' => 'core'));
441
+                    return false;
442
+                }
443
+            } else {
444
+                $this->logger->debug('OC_Image->fixOrientation() Error during orientation fixing', array('app' => 'core'));
445
+                return false;
446
+            }
447
+        }
448
+        return false;
449
+    }
450 450
 
451
-	/**
452
-	 * Loads an image from a local file, a base64 encoded string or a resource created by an imagecreate* function.
453
-	 *
454
-	 * @param resource|string $imageRef The path to a local file, a base64 encoded string or a resource created by an imagecreate* function or a file resource (file handle    ).
455
-	 * @return resource|false An image resource or false on error
456
-	 */
457
-	public function load($imageRef) {
458
-		if (is_resource($imageRef)) {
459
-			if (get_resource_type($imageRef) == 'gd') {
460
-				$this->resource = $imageRef;
461
-				return $this->resource;
462
-			} elseif (in_array(get_resource_type($imageRef), array('file', 'stream'))) {
463
-				return $this->loadFromFileHandle($imageRef);
464
-			}
465
-		} elseif ($this->loadFromBase64($imageRef) !== false) {
466
-			return $this->resource;
467
-		} elseif ($this->loadFromFile($imageRef) !== false) {
468
-			return $this->resource;
469
-		} elseif ($this->loadFromData($imageRef) !== false) {
470
-			return $this->resource;
471
-		}
472
-		$this->logger->debug(__METHOD__ . '(): could not load anything. Giving up!', array('app' => 'core'));
473
-		return false;
474
-	}
451
+    /**
452
+     * Loads an image from a local file, a base64 encoded string or a resource created by an imagecreate* function.
453
+     *
454
+     * @param resource|string $imageRef The path to a local file, a base64 encoded string or a resource created by an imagecreate* function or a file resource (file handle    ).
455
+     * @return resource|false An image resource or false on error
456
+     */
457
+    public function load($imageRef) {
458
+        if (is_resource($imageRef)) {
459
+            if (get_resource_type($imageRef) == 'gd') {
460
+                $this->resource = $imageRef;
461
+                return $this->resource;
462
+            } elseif (in_array(get_resource_type($imageRef), array('file', 'stream'))) {
463
+                return $this->loadFromFileHandle($imageRef);
464
+            }
465
+        } elseif ($this->loadFromBase64($imageRef) !== false) {
466
+            return $this->resource;
467
+        } elseif ($this->loadFromFile($imageRef) !== false) {
468
+            return $this->resource;
469
+        } elseif ($this->loadFromData($imageRef) !== false) {
470
+            return $this->resource;
471
+        }
472
+        $this->logger->debug(__METHOD__ . '(): could not load anything. Giving up!', array('app' => 'core'));
473
+        return false;
474
+    }
475 475
 
476
-	/**
477
-	 * Loads an image from an open file handle.
478
-	 * It is the responsibility of the caller to position the pointer at the correct place and to close the handle again.
479
-	 *
480
-	 * @param resource $handle
481
-	 * @return resource|false An image resource or false on error
482
-	 */
483
-	public function loadFromFileHandle($handle) {
484
-		$contents = stream_get_contents($handle);
485
-		if ($this->loadFromData($contents)) {
486
-			return $this->resource;
487
-		}
488
-		return false;
489
-	}
476
+    /**
477
+     * Loads an image from an open file handle.
478
+     * It is the responsibility of the caller to position the pointer at the correct place and to close the handle again.
479
+     *
480
+     * @param resource $handle
481
+     * @return resource|false An image resource or false on error
482
+     */
483
+    public function loadFromFileHandle($handle) {
484
+        $contents = stream_get_contents($handle);
485
+        if ($this->loadFromData($contents)) {
486
+            return $this->resource;
487
+        }
488
+        return false;
489
+    }
490 490
 
491
-	/**
492
-	 * Loads an image from a local file.
493
-	 *
494
-	 * @param bool|string $imagePath The path to a local file.
495
-	 * @return bool|resource An image resource or false on error
496
-	 */
497
-	public function loadFromFile($imagePath = false) {
498
-		// exif_imagetype throws "read error!" if file is less than 12 byte
499
-		if (!@is_file($imagePath) || !file_exists($imagePath) || filesize($imagePath) < 12 || !is_readable($imagePath)) {
500
-			return false;
501
-		}
502
-		$iType = exif_imagetype($imagePath);
503
-		switch ($iType) {
504
-			case IMAGETYPE_GIF:
505
-				if (imagetypes() & IMG_GIF) {
506
-					$this->resource = imagecreatefromgif($imagePath);
507
-					// Preserve transparency
508
-					imagealphablending($this->resource, true);
509
-					imagesavealpha($this->resource, true);
510
-				} else {
511
-					$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, array('app' => 'core'));
512
-				}
513
-				break;
514
-			case IMAGETYPE_JPEG:
515
-				if (imagetypes() & IMG_JPG) {
516
-					$this->resource = imagecreatefromjpeg($imagePath);
517
-				} else {
518
-					$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
519
-				}
520
-				break;
521
-			case IMAGETYPE_PNG:
522
-				if (imagetypes() & IMG_PNG) {
523
-					$this->resource = imagecreatefrompng($imagePath);
524
-					// Preserve transparency
525
-					imagealphablending($this->resource, true);
526
-					imagesavealpha($this->resource, true);
527
-				} else {
528
-					$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, array('app' => 'core'));
529
-				}
530
-				break;
531
-			case IMAGETYPE_XBM:
532
-				if (imagetypes() & IMG_XPM) {
533
-					$this->resource = imagecreatefromxbm($imagePath);
534
-				} else {
535
-					$this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, array('app' => 'core'));
536
-				}
537
-				break;
538
-			case IMAGETYPE_WBMP:
539
-				if (imagetypes() & IMG_WBMP) {
540
-					$this->resource = imagecreatefromwbmp($imagePath);
541
-				} else {
542
-					$this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, array('app' => 'core'));
543
-				}
544
-				break;
545
-			case IMAGETYPE_BMP:
546
-				$this->resource = $this->imagecreatefrombmp($imagePath);
547
-				break;
548
-			/*
491
+    /**
492
+     * Loads an image from a local file.
493
+     *
494
+     * @param bool|string $imagePath The path to a local file.
495
+     * @return bool|resource An image resource or false on error
496
+     */
497
+    public function loadFromFile($imagePath = false) {
498
+        // exif_imagetype throws "read error!" if file is less than 12 byte
499
+        if (!@is_file($imagePath) || !file_exists($imagePath) || filesize($imagePath) < 12 || !is_readable($imagePath)) {
500
+            return false;
501
+        }
502
+        $iType = exif_imagetype($imagePath);
503
+        switch ($iType) {
504
+            case IMAGETYPE_GIF:
505
+                if (imagetypes() & IMG_GIF) {
506
+                    $this->resource = imagecreatefromgif($imagePath);
507
+                    // Preserve transparency
508
+                    imagealphablending($this->resource, true);
509
+                    imagesavealpha($this->resource, true);
510
+                } else {
511
+                    $this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, array('app' => 'core'));
512
+                }
513
+                break;
514
+            case IMAGETYPE_JPEG:
515
+                if (imagetypes() & IMG_JPG) {
516
+                    $this->resource = imagecreatefromjpeg($imagePath);
517
+                } else {
518
+                    $this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
519
+                }
520
+                break;
521
+            case IMAGETYPE_PNG:
522
+                if (imagetypes() & IMG_PNG) {
523
+                    $this->resource = imagecreatefrompng($imagePath);
524
+                    // Preserve transparency
525
+                    imagealphablending($this->resource, true);
526
+                    imagesavealpha($this->resource, true);
527
+                } else {
528
+                    $this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, array('app' => 'core'));
529
+                }
530
+                break;
531
+            case IMAGETYPE_XBM:
532
+                if (imagetypes() & IMG_XPM) {
533
+                    $this->resource = imagecreatefromxbm($imagePath);
534
+                } else {
535
+                    $this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, array('app' => 'core'));
536
+                }
537
+                break;
538
+            case IMAGETYPE_WBMP:
539
+                if (imagetypes() & IMG_WBMP) {
540
+                    $this->resource = imagecreatefromwbmp($imagePath);
541
+                } else {
542
+                    $this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, array('app' => 'core'));
543
+                }
544
+                break;
545
+            case IMAGETYPE_BMP:
546
+                $this->resource = $this->imagecreatefrombmp($imagePath);
547
+                break;
548
+            /*
549 549
 			case IMAGETYPE_TIFF_II: // (intel byte order)
550 550
 				break;
551 551
 			case IMAGETYPE_TIFF_MM: // (motorola byte order)
@@ -569,580 +569,580 @@  discard block
 block discarded – undo
569 569
 			case IMAGETYPE_PSD:
570 570
 				break;
571 571
 			*/
572
-			default:
572
+            default:
573 573
 
574
-				// this is mostly file created from encrypted file
575
-				$this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents(\OC\Files\Filesystem::getLocalPath($imagePath)));
576
-				$iType = IMAGETYPE_PNG;
577
-				$this->logger->debug('OC_Image->loadFromFile, Default', array('app' => 'core'));
578
-				break;
579
-		}
580
-		if ($this->valid()) {
581
-			$this->imageType = $iType;
582
-			$this->mimeType = image_type_to_mime_type($iType);
583
-			$this->filePath = $imagePath;
584
-		}
585
-		return $this->resource;
586
-	}
574
+                // this is mostly file created from encrypted file
575
+                $this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents(\OC\Files\Filesystem::getLocalPath($imagePath)));
576
+                $iType = IMAGETYPE_PNG;
577
+                $this->logger->debug('OC_Image->loadFromFile, Default', array('app' => 'core'));
578
+                break;
579
+        }
580
+        if ($this->valid()) {
581
+            $this->imageType = $iType;
582
+            $this->mimeType = image_type_to_mime_type($iType);
583
+            $this->filePath = $imagePath;
584
+        }
585
+        return $this->resource;
586
+    }
587 587
 
588
-	/**
589
-	 * Loads an image from a string of data.
590
-	 *
591
-	 * @param string $str A string of image data as read from a file.
592
-	 * @return bool|resource An image resource or false on error
593
-	 */
594
-	public function loadFromData($str) {
595
-		if (is_resource($str)) {
596
-			return false;
597
-		}
598
-		$this->resource = @imagecreatefromstring($str);
599
-		if ($this->fileInfo) {
600
-			$this->mimeType = $this->fileInfo->buffer($str);
601
-		}
602
-		if (is_resource($this->resource)) {
603
-			imagealphablending($this->resource, false);
604
-			imagesavealpha($this->resource, true);
605
-		}
588
+    /**
589
+     * Loads an image from a string of data.
590
+     *
591
+     * @param string $str A string of image data as read from a file.
592
+     * @return bool|resource An image resource or false on error
593
+     */
594
+    public function loadFromData($str) {
595
+        if (is_resource($str)) {
596
+            return false;
597
+        }
598
+        $this->resource = @imagecreatefromstring($str);
599
+        if ($this->fileInfo) {
600
+            $this->mimeType = $this->fileInfo->buffer($str);
601
+        }
602
+        if (is_resource($this->resource)) {
603
+            imagealphablending($this->resource, false);
604
+            imagesavealpha($this->resource, true);
605
+        }
606 606
 
607
-		if (!$this->resource) {
608
-			$this->logger->debug('OC_Image->loadFromFile, could not load', array('app' => 'core'));
609
-			return false;
610
-		}
611
-		return $this->resource;
612
-	}
607
+        if (!$this->resource) {
608
+            $this->logger->debug('OC_Image->loadFromFile, could not load', array('app' => 'core'));
609
+            return false;
610
+        }
611
+        return $this->resource;
612
+    }
613 613
 
614
-	/**
615
-	 * Loads an image from a base64 encoded string.
616
-	 *
617
-	 * @param string $str A string base64 encoded string of image data.
618
-	 * @return bool|resource An image resource or false on error
619
-	 */
620
-	public function loadFromBase64($str) {
621
-		if (!is_string($str)) {
622
-			return false;
623
-		}
624
-		$data = base64_decode($str);
625
-		if ($data) { // try to load from string data
626
-			$this->resource = @imagecreatefromstring($data);
627
-			if ($this->fileInfo) {
628
-				$this->mimeType = $this->fileInfo->buffer($data);
629
-			}
630
-			if (!$this->resource) {
631
-				$this->logger->debug('OC_Image->loadFromBase64, could not load', array('app' => 'core'));
632
-				return false;
633
-			}
634
-			return $this->resource;
635
-		} else {
636
-			return false;
637
-		}
638
-	}
614
+    /**
615
+     * Loads an image from a base64 encoded string.
616
+     *
617
+     * @param string $str A string base64 encoded string of image data.
618
+     * @return bool|resource An image resource or false on error
619
+     */
620
+    public function loadFromBase64($str) {
621
+        if (!is_string($str)) {
622
+            return false;
623
+        }
624
+        $data = base64_decode($str);
625
+        if ($data) { // try to load from string data
626
+            $this->resource = @imagecreatefromstring($data);
627
+            if ($this->fileInfo) {
628
+                $this->mimeType = $this->fileInfo->buffer($data);
629
+            }
630
+            if (!$this->resource) {
631
+                $this->logger->debug('OC_Image->loadFromBase64, could not load', array('app' => 'core'));
632
+                return false;
633
+            }
634
+            return $this->resource;
635
+        } else {
636
+            return false;
637
+        }
638
+    }
639 639
 
640
-	/**
641
-	 * Create a new image from file or URL
642
-	 *
643
-	 * @link http://www.programmierer-forum.de/function-imagecreatefrombmp-laeuft-mit-allen-bitraten-t143137.htm
644
-	 * @version 1.00
645
-	 * @param string $fileName <p>
646
-	 * Path to the BMP image.
647
-	 * </p>
648
-	 * @return bool|resource an image resource identifier on success, <b>FALSE</b> on errors.
649
-	 */
650
-	private function imagecreatefrombmp($fileName) {
651
-		if (!($fh = fopen($fileName, 'rb'))) {
652
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, array('app' => 'core'));
653
-			return false;
654
-		}
655
-		// read file header
656
-		$meta = unpack('vtype/Vfilesize/Vreserved/Voffset', fread($fh, 14));
657
-		// check for bitmap
658
-		if ($meta['type'] != 19778) {
659
-			fclose($fh);
660
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
661
-			return false;
662
-		}
663
-		// read image header
664
-		$meta += unpack('Vheadersize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vcolors/Vimportant', fread($fh, 40));
665
-		// read additional 16bit header
666
-		if ($meta['bits'] == 16) {
667
-			$meta += unpack('VrMask/VgMask/VbMask', fread($fh, 12));
668
-		}
669
-		// set bytes and padding
670
-		$meta['bytes'] = $meta['bits'] / 8;
671
-		$this->bitDepth = $meta['bits']; //remember the bit depth for the imagebmp call
672
-		$meta['decal'] = 4 - (4 * (($meta['width'] * $meta['bytes'] / 4) - floor($meta['width'] * $meta['bytes'] / 4)));
673
-		if ($meta['decal'] == 4) {
674
-			$meta['decal'] = 0;
675
-		}
676
-		// obtain imagesize
677
-		if ($meta['imagesize'] < 1) {
678
-			$meta['imagesize'] = $meta['filesize'] - $meta['offset'];
679
-			// in rare cases filesize is equal to offset so we need to read physical size
680
-			if ($meta['imagesize'] < 1) {
681
-				$meta['imagesize'] = @filesize($fileName) - $meta['offset'];
682
-				if ($meta['imagesize'] < 1) {
683
-					fclose($fh);
684
-					$this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
685
-					return false;
686
-				}
687
-			}
688
-		}
689
-		// calculate colors
690
-		$meta['colors'] = !$meta['colors'] ? pow(2, $meta['bits']) : $meta['colors'];
691
-		// read color palette
692
-		$palette = array();
693
-		if ($meta['bits'] < 16) {
694
-			$palette = unpack('l' . $meta['colors'], fread($fh, $meta['colors'] * 4));
695
-			// in rare cases the color value is signed
696
-			if ($palette[1] < 0) {
697
-				foreach ($palette as $i => $color) {
698
-					$palette[$i] = $color + 16777216;
699
-				}
700
-			}
701
-		}
702
-		// create gd image
703
-		$im = imagecreatetruecolor($meta['width'], $meta['height']);
704
-		if ($im == false) {
705
-			fclose($fh);
706
-			$this->logger->warning(
707
-				'imagecreatefrombmp: imagecreatetruecolor failed for file "' . $fileName . '" with dimensions ' . $meta['width'] . 'x' . $meta['height'],
708
-				array('app' => 'core'));
709
-			return false;
710
-		}
640
+    /**
641
+     * Create a new image from file or URL
642
+     *
643
+     * @link http://www.programmierer-forum.de/function-imagecreatefrombmp-laeuft-mit-allen-bitraten-t143137.htm
644
+     * @version 1.00
645
+     * @param string $fileName <p>
646
+     * Path to the BMP image.
647
+     * </p>
648
+     * @return bool|resource an image resource identifier on success, <b>FALSE</b> on errors.
649
+     */
650
+    private function imagecreatefrombmp($fileName) {
651
+        if (!($fh = fopen($fileName, 'rb'))) {
652
+            $this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, array('app' => 'core'));
653
+            return false;
654
+        }
655
+        // read file header
656
+        $meta = unpack('vtype/Vfilesize/Vreserved/Voffset', fread($fh, 14));
657
+        // check for bitmap
658
+        if ($meta['type'] != 19778) {
659
+            fclose($fh);
660
+            $this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
661
+            return false;
662
+        }
663
+        // read image header
664
+        $meta += unpack('Vheadersize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vcolors/Vimportant', fread($fh, 40));
665
+        // read additional 16bit header
666
+        if ($meta['bits'] == 16) {
667
+            $meta += unpack('VrMask/VgMask/VbMask', fread($fh, 12));
668
+        }
669
+        // set bytes and padding
670
+        $meta['bytes'] = $meta['bits'] / 8;
671
+        $this->bitDepth = $meta['bits']; //remember the bit depth for the imagebmp call
672
+        $meta['decal'] = 4 - (4 * (($meta['width'] * $meta['bytes'] / 4) - floor($meta['width'] * $meta['bytes'] / 4)));
673
+        if ($meta['decal'] == 4) {
674
+            $meta['decal'] = 0;
675
+        }
676
+        // obtain imagesize
677
+        if ($meta['imagesize'] < 1) {
678
+            $meta['imagesize'] = $meta['filesize'] - $meta['offset'];
679
+            // in rare cases filesize is equal to offset so we need to read physical size
680
+            if ($meta['imagesize'] < 1) {
681
+                $meta['imagesize'] = @filesize($fileName) - $meta['offset'];
682
+                if ($meta['imagesize'] < 1) {
683
+                    fclose($fh);
684
+                    $this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
685
+                    return false;
686
+                }
687
+            }
688
+        }
689
+        // calculate colors
690
+        $meta['colors'] = !$meta['colors'] ? pow(2, $meta['bits']) : $meta['colors'];
691
+        // read color palette
692
+        $palette = array();
693
+        if ($meta['bits'] < 16) {
694
+            $palette = unpack('l' . $meta['colors'], fread($fh, $meta['colors'] * 4));
695
+            // in rare cases the color value is signed
696
+            if ($palette[1] < 0) {
697
+                foreach ($palette as $i => $color) {
698
+                    $palette[$i] = $color + 16777216;
699
+                }
700
+            }
701
+        }
702
+        // create gd image
703
+        $im = imagecreatetruecolor($meta['width'], $meta['height']);
704
+        if ($im == false) {
705
+            fclose($fh);
706
+            $this->logger->warning(
707
+                'imagecreatefrombmp: imagecreatetruecolor failed for file "' . $fileName . '" with dimensions ' . $meta['width'] . 'x' . $meta['height'],
708
+                array('app' => 'core'));
709
+            return false;
710
+        }
711 711
 
712
-		$data = fread($fh, $meta['imagesize']);
713
-		$p = 0;
714
-		$vide = chr(0);
715
-		$y = $meta['height'] - 1;
716
-		$error = 'imagecreatefrombmp: ' . $fileName . ' has not enough data!';
717
-		// loop through the image data beginning with the lower left corner
718
-		while ($y >= 0) {
719
-			$x = 0;
720
-			while ($x < $meta['width']) {
721
-				switch ($meta['bits']) {
722
-					case 32:
723
-					case 24:
724
-						if (!($part = substr($data, $p, 3))) {
725
-							$this->logger->warning($error, array('app' => 'core'));
726
-							return $im;
727
-						}
728
-						$color = @unpack('V', $part . $vide);
729
-						break;
730
-					case 16:
731
-						if (!($part = substr($data, $p, 2))) {
732
-							fclose($fh);
733
-							$this->logger->warning($error, array('app' => 'core'));
734
-							return $im;
735
-						}
736
-						$color = @unpack('v', $part);
737
-						$color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3);
738
-						break;
739
-					case 8:
740
-						$color = @unpack('n', $vide . substr($data, $p, 1));
741
-						$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
742
-						break;
743
-					case 4:
744
-						$color = @unpack('n', $vide . substr($data, floor($p), 1));
745
-						$color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
746
-						$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
747
-						break;
748
-					case 1:
749
-						$color = @unpack('n', $vide . substr($data, floor($p), 1));
750
-						switch (($p * 8) % 8) {
751
-							case 0:
752
-								$color[1] = $color[1] >> 7;
753
-								break;
754
-							case 1:
755
-								$color[1] = ($color[1] & 0x40) >> 6;
756
-								break;
757
-							case 2:
758
-								$color[1] = ($color[1] & 0x20) >> 5;
759
-								break;
760
-							case 3:
761
-								$color[1] = ($color[1] & 0x10) >> 4;
762
-								break;
763
-							case 4:
764
-								$color[1] = ($color[1] & 0x8) >> 3;
765
-								break;
766
-							case 5:
767
-								$color[1] = ($color[1] & 0x4) >> 2;
768
-								break;
769
-							case 6:
770
-								$color[1] = ($color[1] & 0x2) >> 1;
771
-								break;
772
-							case 7:
773
-								$color[1] = ($color[1] & 0x1);
774
-								break;
775
-						}
776
-						$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
777
-						break;
778
-					default:
779
-						fclose($fh);
780
-						$this->logger->warning('imagecreatefrombmp: ' . $fileName . ' has ' . $meta['bits'] . ' bits and this is not supported!', array('app' => 'core'));
781
-						return false;
782
-				}
783
-				imagesetpixel($im, $x, $y, $color[1]);
784
-				$x++;
785
-				$p += $meta['bytes'];
786
-			}
787
-			$y--;
788
-			$p += $meta['decal'];
789
-		}
790
-		fclose($fh);
791
-		return $im;
792
-	}
712
+        $data = fread($fh, $meta['imagesize']);
713
+        $p = 0;
714
+        $vide = chr(0);
715
+        $y = $meta['height'] - 1;
716
+        $error = 'imagecreatefrombmp: ' . $fileName . ' has not enough data!';
717
+        // loop through the image data beginning with the lower left corner
718
+        while ($y >= 0) {
719
+            $x = 0;
720
+            while ($x < $meta['width']) {
721
+                switch ($meta['bits']) {
722
+                    case 32:
723
+                    case 24:
724
+                        if (!($part = substr($data, $p, 3))) {
725
+                            $this->logger->warning($error, array('app' => 'core'));
726
+                            return $im;
727
+                        }
728
+                        $color = @unpack('V', $part . $vide);
729
+                        break;
730
+                    case 16:
731
+                        if (!($part = substr($data, $p, 2))) {
732
+                            fclose($fh);
733
+                            $this->logger->warning($error, array('app' => 'core'));
734
+                            return $im;
735
+                        }
736
+                        $color = @unpack('v', $part);
737
+                        $color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3);
738
+                        break;
739
+                    case 8:
740
+                        $color = @unpack('n', $vide . substr($data, $p, 1));
741
+                        $color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
742
+                        break;
743
+                    case 4:
744
+                        $color = @unpack('n', $vide . substr($data, floor($p), 1));
745
+                        $color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
746
+                        $color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
747
+                        break;
748
+                    case 1:
749
+                        $color = @unpack('n', $vide . substr($data, floor($p), 1));
750
+                        switch (($p * 8) % 8) {
751
+                            case 0:
752
+                                $color[1] = $color[1] >> 7;
753
+                                break;
754
+                            case 1:
755
+                                $color[1] = ($color[1] & 0x40) >> 6;
756
+                                break;
757
+                            case 2:
758
+                                $color[1] = ($color[1] & 0x20) >> 5;
759
+                                break;
760
+                            case 3:
761
+                                $color[1] = ($color[1] & 0x10) >> 4;
762
+                                break;
763
+                            case 4:
764
+                                $color[1] = ($color[1] & 0x8) >> 3;
765
+                                break;
766
+                            case 5:
767
+                                $color[1] = ($color[1] & 0x4) >> 2;
768
+                                break;
769
+                            case 6:
770
+                                $color[1] = ($color[1] & 0x2) >> 1;
771
+                                break;
772
+                            case 7:
773
+                                $color[1] = ($color[1] & 0x1);
774
+                                break;
775
+                        }
776
+                        $color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
777
+                        break;
778
+                    default:
779
+                        fclose($fh);
780
+                        $this->logger->warning('imagecreatefrombmp: ' . $fileName . ' has ' . $meta['bits'] . ' bits and this is not supported!', array('app' => 'core'));
781
+                        return false;
782
+                }
783
+                imagesetpixel($im, $x, $y, $color[1]);
784
+                $x++;
785
+                $p += $meta['bytes'];
786
+            }
787
+            $y--;
788
+            $p += $meta['decal'];
789
+        }
790
+        fclose($fh);
791
+        return $im;
792
+    }
793 793
 
794
-	/**
795
-	 * Resizes the image preserving ratio.
796
-	 *
797
-	 * @param integer $maxSize The maximum size of either the width or height.
798
-	 * @return bool
799
-	 */
800
-	public function resize($maxSize) {
801
-		if (!$this->valid()) {
802
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
803
-			return false;
804
-		}
805
-		$widthOrig = imageSX($this->resource);
806
-		$heightOrig = imageSY($this->resource);
807
-		$ratioOrig = $widthOrig / $heightOrig;
794
+    /**
795
+     * Resizes the image preserving ratio.
796
+     *
797
+     * @param integer $maxSize The maximum size of either the width or height.
798
+     * @return bool
799
+     */
800
+    public function resize($maxSize) {
801
+        if (!$this->valid()) {
802
+            $this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
803
+            return false;
804
+        }
805
+        $widthOrig = imageSX($this->resource);
806
+        $heightOrig = imageSY($this->resource);
807
+        $ratioOrig = $widthOrig / $heightOrig;
808 808
 
809
-		if ($ratioOrig > 1) {
810
-			$newHeight = round($maxSize / $ratioOrig);
811
-			$newWidth = $maxSize;
812
-		} else {
813
-			$newWidth = round($maxSize * $ratioOrig);
814
-			$newHeight = $maxSize;
815
-		}
809
+        if ($ratioOrig > 1) {
810
+            $newHeight = round($maxSize / $ratioOrig);
811
+            $newWidth = $maxSize;
812
+        } else {
813
+            $newWidth = round($maxSize * $ratioOrig);
814
+            $newHeight = $maxSize;
815
+        }
816 816
 
817
-		$this->preciseResize(round($newWidth), round($newHeight));
818
-		return true;
819
-	}
817
+        $this->preciseResize(round($newWidth), round($newHeight));
818
+        return true;
819
+    }
820 820
 
821
-	/**
822
-	 * @param int $width
823
-	 * @param int $height
824
-	 * @return bool
825
-	 */
826
-	public function preciseResize($width, $height) {
827
-		if (!$this->valid()) {
828
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
829
-			return false;
830
-		}
831
-		$widthOrig = imageSX($this->resource);
832
-		$heightOrig = imageSY($this->resource);
833
-		$process = imagecreatetruecolor($width, $height);
821
+    /**
822
+     * @param int $width
823
+     * @param int $height
824
+     * @return bool
825
+     */
826
+    public function preciseResize($width, $height) {
827
+        if (!$this->valid()) {
828
+            $this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
829
+            return false;
830
+        }
831
+        $widthOrig = imageSX($this->resource);
832
+        $heightOrig = imageSY($this->resource);
833
+        $process = imagecreatetruecolor($width, $height);
834 834
 
835
-		if ($process == false) {
836
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
837
-			imagedestroy($process);
838
-			return false;
839
-		}
835
+        if ($process == false) {
836
+            $this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
837
+            imagedestroy($process);
838
+            return false;
839
+        }
840 840
 
841
-		// preserve transparency
842
-		if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
843
-			imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127));
844
-			imagealphablending($process, false);
845
-			imagesavealpha($process, true);
846
-		}
841
+        // preserve transparency
842
+        if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
843
+            imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127));
844
+            imagealphablending($process, false);
845
+            imagesavealpha($process, true);
846
+        }
847 847
 
848
-		imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
849
-		if ($process == false) {
850
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image', array('app' => 'core'));
851
-			imagedestroy($process);
852
-			return false;
853
-		}
854
-		imagedestroy($this->resource);
855
-		$this->resource = $process;
856
-		return true;
857
-	}
848
+        imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
849
+        if ($process == false) {
850
+            $this->logger->error(__METHOD__ . '(): Error re-sampling process image', array('app' => 'core'));
851
+            imagedestroy($process);
852
+            return false;
853
+        }
854
+        imagedestroy($this->resource);
855
+        $this->resource = $process;
856
+        return true;
857
+    }
858 858
 
859
-	/**
860
-	 * Crops the image to the middle square. If the image is already square it just returns.
861
-	 *
862
-	 * @param int $size maximum size for the result (optional)
863
-	 * @return bool for success or failure
864
-	 */
865
-	public function centerCrop($size = 0) {
866
-		if (!$this->valid()) {
867
-			$this->logger->error('OC_Image->centerCrop, No image loaded', array('app' => 'core'));
868
-			return false;
869
-		}
870
-		$widthOrig = imageSX($this->resource);
871
-		$heightOrig = imageSY($this->resource);
872
-		if ($widthOrig === $heightOrig and $size == 0) {
873
-			return true;
874
-		}
875
-		$ratioOrig = $widthOrig / $heightOrig;
876
-		$width = $height = min($widthOrig, $heightOrig);
859
+    /**
860
+     * Crops the image to the middle square. If the image is already square it just returns.
861
+     *
862
+     * @param int $size maximum size for the result (optional)
863
+     * @return bool for success or failure
864
+     */
865
+    public function centerCrop($size = 0) {
866
+        if (!$this->valid()) {
867
+            $this->logger->error('OC_Image->centerCrop, No image loaded', array('app' => 'core'));
868
+            return false;
869
+        }
870
+        $widthOrig = imageSX($this->resource);
871
+        $heightOrig = imageSY($this->resource);
872
+        if ($widthOrig === $heightOrig and $size == 0) {
873
+            return true;
874
+        }
875
+        $ratioOrig = $widthOrig / $heightOrig;
876
+        $width = $height = min($widthOrig, $heightOrig);
877 877
 
878
-		if ($ratioOrig > 1) {
879
-			$x = ($widthOrig / 2) - ($width / 2);
880
-			$y = 0;
881
-		} else {
882
-			$y = ($heightOrig / 2) - ($height / 2);
883
-			$x = 0;
884
-		}
885
-		if ($size > 0) {
886
-			$targetWidth = $size;
887
-			$targetHeight = $size;
888
-		} else {
889
-			$targetWidth = $width;
890
-			$targetHeight = $height;
891
-		}
892
-		$process = imagecreatetruecolor($targetWidth, $targetHeight);
893
-		if ($process == false) {
894
-			$this->logger->error('OC_Image->centerCrop, Error creating true color image', array('app' => 'core'));
895
-			imagedestroy($process);
896
-			return false;
897
-		}
878
+        if ($ratioOrig > 1) {
879
+            $x = ($widthOrig / 2) - ($width / 2);
880
+            $y = 0;
881
+        } else {
882
+            $y = ($heightOrig / 2) - ($height / 2);
883
+            $x = 0;
884
+        }
885
+        if ($size > 0) {
886
+            $targetWidth = $size;
887
+            $targetHeight = $size;
888
+        } else {
889
+            $targetWidth = $width;
890
+            $targetHeight = $height;
891
+        }
892
+        $process = imagecreatetruecolor($targetWidth, $targetHeight);
893
+        if ($process == false) {
894
+            $this->logger->error('OC_Image->centerCrop, Error creating true color image', array('app' => 'core'));
895
+            imagedestroy($process);
896
+            return false;
897
+        }
898 898
 
899
-		// preserve transparency
900
-		if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
901
-			imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127));
902
-			imagealphablending($process, false);
903
-			imagesavealpha($process, true);
904
-		}
899
+        // preserve transparency
900
+        if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
901
+            imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127));
902
+            imagealphablending($process, false);
903
+            imagesavealpha($process, true);
904
+        }
905 905
 
906
-		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
907
-		if ($process == false) {
908
-			$this->logger->error('OC_Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, array('app' => 'core'));
909
-			imagedestroy($process);
910
-			return false;
911
-		}
912
-		imagedestroy($this->resource);
913
-		$this->resource = $process;
914
-		return true;
915
-	}
906
+        imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
907
+        if ($process == false) {
908
+            $this->logger->error('OC_Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, array('app' => 'core'));
909
+            imagedestroy($process);
910
+            return false;
911
+        }
912
+        imagedestroy($this->resource);
913
+        $this->resource = $process;
914
+        return true;
915
+    }
916 916
 
917
-	/**
918
-	 * Crops the image from point $x$y with dimension $wx$h.
919
-	 *
920
-	 * @param int $x Horizontal position
921
-	 * @param int $y Vertical position
922
-	 * @param int $w Width
923
-	 * @param int $h Height
924
-	 * @return bool for success or failure
925
-	 */
926
-	public function crop($x, $y, $w, $h) {
927
-		if (!$this->valid()) {
928
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
929
-			return false;
930
-		}
931
-		$process = imagecreatetruecolor($w, $h);
932
-		if ($process == false) {
933
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
934
-			imagedestroy($process);
935
-			return false;
936
-		}
917
+    /**
918
+     * Crops the image from point $x$y with dimension $wx$h.
919
+     *
920
+     * @param int $x Horizontal position
921
+     * @param int $y Vertical position
922
+     * @param int $w Width
923
+     * @param int $h Height
924
+     * @return bool for success or failure
925
+     */
926
+    public function crop($x, $y, $w, $h) {
927
+        if (!$this->valid()) {
928
+            $this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
929
+            return false;
930
+        }
931
+        $process = imagecreatetruecolor($w, $h);
932
+        if ($process == false) {
933
+            $this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
934
+            imagedestroy($process);
935
+            return false;
936
+        }
937 937
 
938
-		// preserve transparency
939
-		if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
940
-			imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127));
941
-			imagealphablending($process, false);
942
-			imagesavealpha($process, true);
943
-		}
938
+        // preserve transparency
939
+        if ($this->imageType == IMAGETYPE_GIF or $this->imageType == IMAGETYPE_PNG) {
940
+            imagecolortransparent($process, imagecolorallocatealpha($process, 0, 0, 0, 127));
941
+            imagealphablending($process, false);
942
+            imagesavealpha($process, true);
943
+        }
944 944
 
945
-		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $w, $h, $w, $h);
946
-		if ($process == false) {
947
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image ' . $w . 'x' . $h, array('app' => 'core'));
948
-			imagedestroy($process);
949
-			return false;
950
-		}
951
-		imagedestroy($this->resource);
952
-		$this->resource = $process;
953
-		return true;
954
-	}
945
+        imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $w, $h, $w, $h);
946
+        if ($process == false) {
947
+            $this->logger->error(__METHOD__ . '(): Error re-sampling process image ' . $w . 'x' . $h, array('app' => 'core'));
948
+            imagedestroy($process);
949
+            return false;
950
+        }
951
+        imagedestroy($this->resource);
952
+        $this->resource = $process;
953
+        return true;
954
+    }
955 955
 
956
-	/**
957
-	 * Resizes the image to fit within a boundary while preserving ratio.
958
-	 *
959
-	 * Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up
960
-	 *
961
-	 * @param integer $maxWidth
962
-	 * @param integer $maxHeight
963
-	 * @return bool
964
-	 */
965
-	public function fitIn($maxWidth, $maxHeight) {
966
-		if (!$this->valid()) {
967
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
968
-			return false;
969
-		}
970
-		$widthOrig = imageSX($this->resource);
971
-		$heightOrig = imageSY($this->resource);
972
-		$ratio = $widthOrig / $heightOrig;
956
+    /**
957
+     * Resizes the image to fit within a boundary while preserving ratio.
958
+     *
959
+     * Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up
960
+     *
961
+     * @param integer $maxWidth
962
+     * @param integer $maxHeight
963
+     * @return bool
964
+     */
965
+    public function fitIn($maxWidth, $maxHeight) {
966
+        if (!$this->valid()) {
967
+            $this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
968
+            return false;
969
+        }
970
+        $widthOrig = imageSX($this->resource);
971
+        $heightOrig = imageSY($this->resource);
972
+        $ratio = $widthOrig / $heightOrig;
973 973
 
974
-		$newWidth = min($maxWidth, $ratio * $maxHeight);
975
-		$newHeight = min($maxHeight, $maxWidth / $ratio);
974
+        $newWidth = min($maxWidth, $ratio * $maxHeight);
975
+        $newHeight = min($maxHeight, $maxWidth / $ratio);
976 976
 
977
-		$this->preciseResize(round($newWidth), round($newHeight));
978
-		return true;
979
-	}
977
+        $this->preciseResize(round($newWidth), round($newHeight));
978
+        return true;
979
+    }
980 980
 
981
-	/**
982
-	 * Shrinks larger images to fit within specified boundaries while preserving ratio.
983
-	 *
984
-	 * @param integer $maxWidth
985
-	 * @param integer $maxHeight
986
-	 * @return bool
987
-	 */
988
-	public function scaleDownToFit($maxWidth, $maxHeight) {
989
-		if (!$this->valid()) {
990
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
991
-			return false;
992
-		}
993
-		$widthOrig = imageSX($this->resource);
994
-		$heightOrig = imageSY($this->resource);
981
+    /**
982
+     * Shrinks larger images to fit within specified boundaries while preserving ratio.
983
+     *
984
+     * @param integer $maxWidth
985
+     * @param integer $maxHeight
986
+     * @return bool
987
+     */
988
+    public function scaleDownToFit($maxWidth, $maxHeight) {
989
+        if (!$this->valid()) {
990
+            $this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
991
+            return false;
992
+        }
993
+        $widthOrig = imageSX($this->resource);
994
+        $heightOrig = imageSY($this->resource);
995 995
 
996
-		if ($widthOrig > $maxWidth || $heightOrig > $maxHeight) {
997
-			return $this->fitIn($maxWidth, $maxHeight);
998
-		}
996
+        if ($widthOrig > $maxWidth || $heightOrig > $maxHeight) {
997
+            return $this->fitIn($maxWidth, $maxHeight);
998
+        }
999 999
 
1000
-		return false;
1001
-	}
1000
+        return false;
1001
+    }
1002 1002
 
1003
-	/**
1004
-	 * Destroys the current image and resets the object
1005
-	 */
1006
-	public function destroy() {
1007
-		if ($this->valid()) {
1008
-			imagedestroy($this->resource);
1009
-		}
1010
-		$this->resource = null;
1011
-	}
1003
+    /**
1004
+     * Destroys the current image and resets the object
1005
+     */
1006
+    public function destroy() {
1007
+        if ($this->valid()) {
1008
+            imagedestroy($this->resource);
1009
+        }
1010
+        $this->resource = null;
1011
+    }
1012 1012
 
1013
-	public function __destruct() {
1014
-		$this->destroy();
1015
-	}
1013
+    public function __destruct() {
1014
+        $this->destroy();
1015
+    }
1016 1016
 }
1017 1017
 
1018 1018
 if (!function_exists('imagebmp')) {
1019
-	/**
1020
-	 * Output a BMP image to either the browser or a file
1021
-	 *
1022
-	 * @link http://www.ugia.cn/wp-data/imagebmp.php
1023
-	 * @author legend <[email protected]>
1024
-	 * @link http://www.programmierer-forum.de/imagebmp-gute-funktion-gefunden-t143716.htm
1025
-	 * @author mgutt <[email protected]>
1026
-	 * @version 1.00
1027
-	 * @param string $fileName [optional] <p>The path to save the file to.</p>
1028
-	 * @param int $bit [optional] <p>Bit depth, (default is 24).</p>
1029
-	 * @param int $compression [optional]
1030
-	 * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
1031
-	 */
1032
-	function imagebmp($im, $fileName = '', $bit = 24, $compression = 0) {
1033
-		if (!in_array($bit, array(1, 4, 8, 16, 24, 32))) {
1034
-			$bit = 24;
1035
-		} else if ($bit == 32) {
1036
-			$bit = 24;
1037
-		}
1038
-		$bits = pow(2, $bit);
1039
-		imagetruecolortopalette($im, true, $bits);
1040
-		$width = imagesx($im);
1041
-		$height = imagesy($im);
1042
-		$colorsNum = imagecolorstotal($im);
1043
-		$rgbQuad = '';
1044
-		if ($bit <= 8) {
1045
-			for ($i = 0; $i < $colorsNum; $i++) {
1046
-				$colors = imagecolorsforindex($im, $i);
1047
-				$rgbQuad .= chr($colors['blue']) . chr($colors['green']) . chr($colors['red']) . "\0";
1048
-			}
1049
-			$bmpData = '';
1050
-			if ($compression == 0 || $bit < 8) {
1051
-				$compression = 0;
1052
-				$extra = '';
1053
-				$padding = 4 - ceil($width / (8 / $bit)) % 4;
1054
-				if ($padding % 4 != 0) {
1055
-					$extra = str_repeat("\0", $padding);
1056
-				}
1057
-				for ($j = $height - 1; $j >= 0; $j--) {
1058
-					$i = 0;
1059
-					while ($i < $width) {
1060
-						$bin = 0;
1061
-						$limit = $width - $i < 8 / $bit ? (8 / $bit - $width + $i) * $bit : 0;
1062
-						for ($k = 8 - $bit; $k >= $limit; $k -= $bit) {
1063
-							$index = imagecolorat($im, $i, $j);
1064
-							$bin |= $index << $k;
1065
-							$i++;
1066
-						}
1067
-						$bmpData .= chr($bin);
1068
-					}
1069
-					$bmpData .= $extra;
1070
-				}
1071
-			} // RLE8
1072
-			else if ($compression == 1 && $bit == 8) {
1073
-				for ($j = $height - 1; $j >= 0; $j--) {
1074
-					$lastIndex = "\0";
1075
-					$sameNum = 0;
1076
-					for ($i = 0; $i <= $width; $i++) {
1077
-						$index = imagecolorat($im, $i, $j);
1078
-						if ($index !== $lastIndex || $sameNum > 255) {
1079
-							if ($sameNum != 0) {
1080
-								$bmpData .= chr($sameNum) . chr($lastIndex);
1081
-							}
1082
-							$lastIndex = $index;
1083
-							$sameNum = 1;
1084
-						} else {
1085
-							$sameNum++;
1086
-						}
1087
-					}
1088
-					$bmpData .= "\0\0";
1089
-				}
1090
-				$bmpData .= "\0\1";
1091
-			}
1092
-			$sizeQuad = strlen($rgbQuad);
1093
-			$sizeData = strlen($bmpData);
1094
-		} else {
1095
-			$extra = '';
1096
-			$padding = 4 - ($width * ($bit / 8)) % 4;
1097
-			if ($padding % 4 != 0) {
1098
-				$extra = str_repeat("\0", $padding);
1099
-			}
1100
-			$bmpData = '';
1101
-			for ($j = $height - 1; $j >= 0; $j--) {
1102
-				for ($i = 0; $i < $width; $i++) {
1103
-					$index = imagecolorat($im, $i, $j);
1104
-					$colors = imagecolorsforindex($im, $index);
1105
-					if ($bit == 16) {
1106
-						$bin = 0 << $bit;
1107
-						$bin |= ($colors['red'] >> 3) << 10;
1108
-						$bin |= ($colors['green'] >> 3) << 5;
1109
-						$bin |= $colors['blue'] >> 3;
1110
-						$bmpData .= pack("v", $bin);
1111
-					} else {
1112
-						$bmpData .= pack("c*", $colors['blue'], $colors['green'], $colors['red']);
1113
-					}
1114
-				}
1115
-				$bmpData .= $extra;
1116
-			}
1117
-			$sizeQuad = 0;
1118
-			$sizeData = strlen($bmpData);
1119
-			$colorsNum = 0;
1120
-		}
1121
-		$fileHeader = 'BM' . pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1122
-		$infoHeader = pack('V3v2V*', 0x28, $width, $height, 1, $bit, $compression, $sizeData, 0, 0, $colorsNum, 0);
1123
-		if ($fileName != '') {
1124
-			$fp = fopen($fileName, 'wb');
1125
-			fwrite($fp, $fileHeader . $infoHeader . $rgbQuad . $bmpData);
1126
-			fclose($fp);
1127
-			return true;
1128
-		}
1129
-		echo $fileHeader . $infoHeader . $rgbQuad . $bmpData;
1130
-		return true;
1131
-	}
1019
+    /**
1020
+     * Output a BMP image to either the browser or a file
1021
+     *
1022
+     * @link http://www.ugia.cn/wp-data/imagebmp.php
1023
+     * @author legend <[email protected]>
1024
+     * @link http://www.programmierer-forum.de/imagebmp-gute-funktion-gefunden-t143716.htm
1025
+     * @author mgutt <[email protected]>
1026
+     * @version 1.00
1027
+     * @param string $fileName [optional] <p>The path to save the file to.</p>
1028
+     * @param int $bit [optional] <p>Bit depth, (default is 24).</p>
1029
+     * @param int $compression [optional]
1030
+     * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
1031
+     */
1032
+    function imagebmp($im, $fileName = '', $bit = 24, $compression = 0) {
1033
+        if (!in_array($bit, array(1, 4, 8, 16, 24, 32))) {
1034
+            $bit = 24;
1035
+        } else if ($bit == 32) {
1036
+            $bit = 24;
1037
+        }
1038
+        $bits = pow(2, $bit);
1039
+        imagetruecolortopalette($im, true, $bits);
1040
+        $width = imagesx($im);
1041
+        $height = imagesy($im);
1042
+        $colorsNum = imagecolorstotal($im);
1043
+        $rgbQuad = '';
1044
+        if ($bit <= 8) {
1045
+            for ($i = 0; $i < $colorsNum; $i++) {
1046
+                $colors = imagecolorsforindex($im, $i);
1047
+                $rgbQuad .= chr($colors['blue']) . chr($colors['green']) . chr($colors['red']) . "\0";
1048
+            }
1049
+            $bmpData = '';
1050
+            if ($compression == 0 || $bit < 8) {
1051
+                $compression = 0;
1052
+                $extra = '';
1053
+                $padding = 4 - ceil($width / (8 / $bit)) % 4;
1054
+                if ($padding % 4 != 0) {
1055
+                    $extra = str_repeat("\0", $padding);
1056
+                }
1057
+                for ($j = $height - 1; $j >= 0; $j--) {
1058
+                    $i = 0;
1059
+                    while ($i < $width) {
1060
+                        $bin = 0;
1061
+                        $limit = $width - $i < 8 / $bit ? (8 / $bit - $width + $i) * $bit : 0;
1062
+                        for ($k = 8 - $bit; $k >= $limit; $k -= $bit) {
1063
+                            $index = imagecolorat($im, $i, $j);
1064
+                            $bin |= $index << $k;
1065
+                            $i++;
1066
+                        }
1067
+                        $bmpData .= chr($bin);
1068
+                    }
1069
+                    $bmpData .= $extra;
1070
+                }
1071
+            } // RLE8
1072
+            else if ($compression == 1 && $bit == 8) {
1073
+                for ($j = $height - 1; $j >= 0; $j--) {
1074
+                    $lastIndex = "\0";
1075
+                    $sameNum = 0;
1076
+                    for ($i = 0; $i <= $width; $i++) {
1077
+                        $index = imagecolorat($im, $i, $j);
1078
+                        if ($index !== $lastIndex || $sameNum > 255) {
1079
+                            if ($sameNum != 0) {
1080
+                                $bmpData .= chr($sameNum) . chr($lastIndex);
1081
+                            }
1082
+                            $lastIndex = $index;
1083
+                            $sameNum = 1;
1084
+                        } else {
1085
+                            $sameNum++;
1086
+                        }
1087
+                    }
1088
+                    $bmpData .= "\0\0";
1089
+                }
1090
+                $bmpData .= "\0\1";
1091
+            }
1092
+            $sizeQuad = strlen($rgbQuad);
1093
+            $sizeData = strlen($bmpData);
1094
+        } else {
1095
+            $extra = '';
1096
+            $padding = 4 - ($width * ($bit / 8)) % 4;
1097
+            if ($padding % 4 != 0) {
1098
+                $extra = str_repeat("\0", $padding);
1099
+            }
1100
+            $bmpData = '';
1101
+            for ($j = $height - 1; $j >= 0; $j--) {
1102
+                for ($i = 0; $i < $width; $i++) {
1103
+                    $index = imagecolorat($im, $i, $j);
1104
+                    $colors = imagecolorsforindex($im, $index);
1105
+                    if ($bit == 16) {
1106
+                        $bin = 0 << $bit;
1107
+                        $bin |= ($colors['red'] >> 3) << 10;
1108
+                        $bin |= ($colors['green'] >> 3) << 5;
1109
+                        $bin |= $colors['blue'] >> 3;
1110
+                        $bmpData .= pack("v", $bin);
1111
+                    } else {
1112
+                        $bmpData .= pack("c*", $colors['blue'], $colors['green'], $colors['red']);
1113
+                    }
1114
+                }
1115
+                $bmpData .= $extra;
1116
+            }
1117
+            $sizeQuad = 0;
1118
+            $sizeData = strlen($bmpData);
1119
+            $colorsNum = 0;
1120
+        }
1121
+        $fileHeader = 'BM' . pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1122
+        $infoHeader = pack('V3v2V*', 0x28, $width, $height, 1, $bit, $compression, $sizeData, 0, 0, $colorsNum, 0);
1123
+        if ($fileName != '') {
1124
+            $fp = fopen($fileName, 'wb');
1125
+            fwrite($fp, $fileHeader . $infoHeader . $rgbQuad . $bmpData);
1126
+            fclose($fp);
1127
+            return true;
1128
+        }
1129
+        echo $fileHeader . $infoHeader . $rgbQuad . $bmpData;
1130
+        return true;
1131
+    }
1132 1132
 }
1133 1133
 
1134 1134
 if (!function_exists('exif_imagetype')) {
1135
-	/**
1136
-	 * Workaround if exif_imagetype does not exist
1137
-	 *
1138
-	 * @link http://www.php.net/manual/en/function.exif-imagetype.php#80383
1139
-	 * @param string $fileName
1140
-	 * @return string|boolean
1141
-	 */
1142
-	function exif_imagetype($fileName) {
1143
-		if (($info = getimagesize($fileName)) !== false) {
1144
-			return $info[2];
1145
-		}
1146
-		return false;
1147
-	}
1135
+    /**
1136
+     * Workaround if exif_imagetype does not exist
1137
+     *
1138
+     * @link http://www.php.net/manual/en/function.exif-imagetype.php#80383
1139
+     * @param string $fileName
1140
+     * @return string|boolean
1141
+     */
1142
+    function exif_imagetype($fileName) {
1143
+        if (($info = getimagesize($fileName)) !== false) {
1144
+            return $info[2];
1145
+        }
1146
+        return false;
1147
+    }
1148 1148
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		}
86 86
 
87 87
 		if (!extension_loaded('gd') || !function_exists('gd_info')) {
88
-			$this->logger->error(__METHOD__ . '(): GD module not installed', array('app' => 'core'));
88
+			$this->logger->error(__METHOD__.'(): GD module not installed', array('app' => 'core'));
89 89
 			return false;
90 90
 		}
91 91
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function widthTopLeft() {
143 143
 		$o = $this->getOrientation();
144
-		$this->logger->debug('OC_Image->widthTopLeft() Orientation: ' . $o, array('app' => 'core'));
144
+		$this->logger->debug('OC_Image->widthTopLeft() Orientation: '.$o, array('app' => 'core'));
145 145
 		switch ($o) {
146 146
 			case -1:
147 147
 			case 1:
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function heightTopLeft() {
167 167
 		$o = $this->getOrientation();
168
-		$this->logger->debug('OC_Image->heightTopLeft() Orientation: ' . $o, array('app' => 'core'));
168
+		$this->logger->debug('OC_Image->heightTopLeft() Orientation: '.$o, array('app' => 'core'));
169 169
 		switch ($o) {
170 170
 			case -1:
171 171
 			case 1:
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		if ($mimeType === null) {
193 193
 			$mimeType = $this->mimeType();
194 194
 		}
195
-		header('Content-Type: ' . $mimeType);
195
+		header('Content-Type: '.$mimeType);
196 196
 		return $this->_output(null, $mimeType);
197 197
 	}
198 198
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$mimeType = $this->mimeType();
210 210
 		}
211 211
 		if ($filePath === null && $this->filePath === null) {
212
-			$this->logger->error(__METHOD__ . '(): called with no path.', array('app' => 'core'));
212
+			$this->logger->error(__METHOD__.'(): called with no path.', array('app' => 'core'));
213 213
 			return false;
214 214
 		} elseif ($filePath === null && $this->filePath !== null) {
215 215
 			$filePath = $this->filePath;
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 			if (!file_exists(dirname($filePath)))
231 231
 				mkdir(dirname($filePath), 0777, true);
232 232
 			if (!is_writable(dirname($filePath))) {
233
-				$this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', array('app' => 'core'));
233
+				$this->logger->error(__METHOD__.'(): Directory \''.dirname($filePath).'\' is not writable.', array('app' => 'core'));
234 234
 				return false;
235 235
 			} elseif (is_writable(dirname($filePath)) && file_exists($filePath) && !is_writable($filePath)) {
236
-				$this->logger->error(__METHOD__ . '(): File \'' . $filePath . '\' is not writable.', array('app' => 'core'));
236
+				$this->logger->error(__METHOD__.'(): File \''.$filePath.'\' is not writable.', array('app' => 'core'));
237 237
 				return false;
238 238
 			}
239 239
 		}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 					$imageType = IMAGETYPE_BMP;
262 262
 					break;
263 263
 				default:
264
-					throw new Exception('\OC_Image::_output(): "' . $mimeType . '" is not supported when forcing a specific output format');
264
+					throw new Exception('\OC_Image::_output(): "'.$mimeType.'" is not supported when forcing a specific output format');
265 265
 			}
266 266
 		}
267 267
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 */
387 387
 	public function fixOrientation() {
388 388
 		$o = $this->getOrientation();
389
-		$this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, array('app' => 'core'));
389
+		$this->logger->debug('OC_Image->fixOrientation() Orientation: '.$o, array('app' => 'core'));
390 390
 		$rotate = 0;
391 391
 		$flip = false;
392 392
 		switch ($o) {
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 				$rotate = 90;
422 422
 				break;
423 423
 		}
424
-		if($flip && function_exists('imageflip')) {
424
+		if ($flip && function_exists('imageflip')) {
425 425
 			imageflip($this->resource, IMG_FLIP_HORIZONTAL);
426 426
 		}
427 427
 		if ($rotate) {
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		} elseif ($this->loadFromData($imageRef) !== false) {
470 470
 			return $this->resource;
471 471
 		}
472
-		$this->logger->debug(__METHOD__ . '(): could not load anything. Giving up!', array('app' => 'core'));
472
+		$this->logger->debug(__METHOD__.'(): could not load anything. Giving up!', array('app' => 'core'));
473 473
 		return false;
474 474
 	}
475 475
 
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 					imagealphablending($this->resource, true);
509 509
 					imagesavealpha($this->resource, true);
510 510
 				} else {
511
-					$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, array('app' => 'core'));
511
+					$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: '.$imagePath, array('app' => 'core'));
512 512
 				}
513 513
 				break;
514 514
 			case IMAGETYPE_JPEG:
515 515
 				if (imagetypes() & IMG_JPG) {
516 516
 					$this->resource = imagecreatefromjpeg($imagePath);
517 517
 				} else {
518
-					$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
518
+					$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: '.$imagePath, array('app' => 'core'));
519 519
 				}
520 520
 				break;
521 521
 			case IMAGETYPE_PNG:
@@ -525,21 +525,21 @@  discard block
 block discarded – undo
525 525
 					imagealphablending($this->resource, true);
526 526
 					imagesavealpha($this->resource, true);
527 527
 				} else {
528
-					$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, array('app' => 'core'));
528
+					$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: '.$imagePath, array('app' => 'core'));
529 529
 				}
530 530
 				break;
531 531
 			case IMAGETYPE_XBM:
532 532
 				if (imagetypes() & IMG_XPM) {
533 533
 					$this->resource = imagecreatefromxbm($imagePath);
534 534
 				} else {
535
-					$this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, array('app' => 'core'));
535
+					$this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: '.$imagePath, array('app' => 'core'));
536 536
 				}
537 537
 				break;
538 538
 			case IMAGETYPE_WBMP:
539 539
 				if (imagetypes() & IMG_WBMP) {
540 540
 					$this->resource = imagecreatefromwbmp($imagePath);
541 541
 				} else {
542
-					$this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, array('app' => 'core'));
542
+					$this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: '.$imagePath, array('app' => 'core'));
543 543
 				}
544 544
 				break;
545 545
 			case IMAGETYPE_BMP:
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 	 */
650 650
 	private function imagecreatefrombmp($fileName) {
651 651
 		if (!($fh = fopen($fileName, 'rb'))) {
652
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, array('app' => 'core'));
652
+			$this->logger->warning('imagecreatefrombmp: Can not open '.$fileName, array('app' => 'core'));
653 653
 			return false;
654 654
 		}
655 655
 		// read file header
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		// check for bitmap
658 658
 		if ($meta['type'] != 19778) {
659 659
 			fclose($fh);
660
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
660
+			$this->logger->warning('imagecreatefrombmp: Can not open '.$fileName.' is not a bitmap!', array('app' => 'core'));
661 661
 			return false;
662 662
 		}
663 663
 		// read image header
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 				$meta['imagesize'] = @filesize($fileName) - $meta['offset'];
682 682
 				if ($meta['imagesize'] < 1) {
683 683
 					fclose($fh);
684
-					$this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
684
+					$this->logger->warning('imagecreatefrombmp: Can not obtain file size of '.$fileName.' is not a bitmap!', array('app' => 'core'));
685 685
 					return false;
686 686
 				}
687 687
 			}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		// read color palette
692 692
 		$palette = array();
693 693
 		if ($meta['bits'] < 16) {
694
-			$palette = unpack('l' . $meta['colors'], fread($fh, $meta['colors'] * 4));
694
+			$palette = unpack('l'.$meta['colors'], fread($fh, $meta['colors'] * 4));
695 695
 			// in rare cases the color value is signed
696 696
 			if ($palette[1] < 0) {
697 697
 				foreach ($palette as $i => $color) {
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		if ($im == false) {
705 705
 			fclose($fh);
706 706
 			$this->logger->warning(
707
-				'imagecreatefrombmp: imagecreatetruecolor failed for file "' . $fileName . '" with dimensions ' . $meta['width'] . 'x' . $meta['height'],
707
+				'imagecreatefrombmp: imagecreatetruecolor failed for file "'.$fileName.'" with dimensions '.$meta['width'].'x'.$meta['height'],
708 708
 				array('app' => 'core'));
709 709
 			return false;
710 710
 		}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 		$p = 0;
714 714
 		$vide = chr(0);
715 715
 		$y = $meta['height'] - 1;
716
-		$error = 'imagecreatefrombmp: ' . $fileName . ' has not enough data!';
716
+		$error = 'imagecreatefrombmp: '.$fileName.' has not enough data!';
717 717
 		// loop through the image data beginning with the lower left corner
718 718
 		while ($y >= 0) {
719 719
 			$x = 0;
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 							$this->logger->warning($error, array('app' => 'core'));
726 726
 							return $im;
727 727
 						}
728
-						$color = @unpack('V', $part . $vide);
728
+						$color = @unpack('V', $part.$vide);
729 729
 						break;
730 730
 					case 16:
731 731
 						if (!($part = substr($data, $p, 2))) {
@@ -737,16 +737,16 @@  discard block
 block discarded – undo
737 737
 						$color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3);
738 738
 						break;
739 739
 					case 8:
740
-						$color = @unpack('n', $vide . substr($data, $p, 1));
740
+						$color = @unpack('n', $vide.substr($data, $p, 1));
741 741
 						$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
742 742
 						break;
743 743
 					case 4:
744
-						$color = @unpack('n', $vide . substr($data, floor($p), 1));
744
+						$color = @unpack('n', $vide.substr($data, floor($p), 1));
745 745
 						$color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
746 746
 						$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
747 747
 						break;
748 748
 					case 1:
749
-						$color = @unpack('n', $vide . substr($data, floor($p), 1));
749
+						$color = @unpack('n', $vide.substr($data, floor($p), 1));
750 750
 						switch (($p * 8) % 8) {
751 751
 							case 0:
752 752
 								$color[1] = $color[1] >> 7;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 						break;
778 778
 					default:
779 779
 						fclose($fh);
780
-						$this->logger->warning('imagecreatefrombmp: ' . $fileName . ' has ' . $meta['bits'] . ' bits and this is not supported!', array('app' => 'core'));
780
+						$this->logger->warning('imagecreatefrombmp: '.$fileName.' has '.$meta['bits'].' bits and this is not supported!', array('app' => 'core'));
781 781
 						return false;
782 782
 				}
783 783
 				imagesetpixel($im, $x, $y, $color[1]);
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 	 */
800 800
 	public function resize($maxSize) {
801 801
 		if (!$this->valid()) {
802
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
802
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
803 803
 			return false;
804 804
 		}
805 805
 		$widthOrig = imageSX($this->resource);
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 	 */
826 826
 	public function preciseResize($width, $height) {
827 827
 		if (!$this->valid()) {
828
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
828
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
829 829
 			return false;
830 830
 		}
831 831
 		$widthOrig = imageSX($this->resource);
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		$process = imagecreatetruecolor($width, $height);
834 834
 
835 835
 		if ($process == false) {
836
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
836
+			$this->logger->error(__METHOD__.'(): Error creating true color image', array('app' => 'core'));
837 837
 			imagedestroy($process);
838 838
 			return false;
839 839
 		}
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 
848 848
 		imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
849 849
 		if ($process == false) {
850
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image', array('app' => 'core'));
850
+			$this->logger->error(__METHOD__.'(): Error re-sampling process image', array('app' => 'core'));
851 851
 			imagedestroy($process);
852 852
 			return false;
853 853
 		}
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 
906 906
 		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
907 907
 		if ($process == false) {
908
-			$this->logger->error('OC_Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, array('app' => 'core'));
908
+			$this->logger->error('OC_Image->centerCrop, Error re-sampling process image '.$width.'x'.$height, array('app' => 'core'));
909 909
 			imagedestroy($process);
910 910
 			return false;
911 911
 		}
@@ -925,12 +925,12 @@  discard block
 block discarded – undo
925 925
 	 */
926 926
 	public function crop($x, $y, $w, $h) {
927 927
 		if (!$this->valid()) {
928
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
928
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
929 929
 			return false;
930 930
 		}
931 931
 		$process = imagecreatetruecolor($w, $h);
932 932
 		if ($process == false) {
933
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
933
+			$this->logger->error(__METHOD__.'(): Error creating true color image', array('app' => 'core'));
934 934
 			imagedestroy($process);
935 935
 			return false;
936 936
 		}
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 
945 945
 		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $w, $h, $w, $h);
946 946
 		if ($process == false) {
947
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image ' . $w . 'x' . $h, array('app' => 'core'));
947
+			$this->logger->error(__METHOD__.'(): Error re-sampling process image '.$w.'x'.$h, array('app' => 'core'));
948 948
 			imagedestroy($process);
949 949
 			return false;
950 950
 		}
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 	 */
965 965
 	public function fitIn($maxWidth, $maxHeight) {
966 966
 		if (!$this->valid()) {
967
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
967
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
968 968
 			return false;
969 969
 		}
970 970
 		$widthOrig = imageSX($this->resource);
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 	 */
988 988
 	public function scaleDownToFit($maxWidth, $maxHeight) {
989 989
 		if (!$this->valid()) {
990
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
990
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
991 991
 			return false;
992 992
 		}
993 993
 		$widthOrig = imageSX($this->resource);
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 		if ($bit <= 8) {
1045 1045
 			for ($i = 0; $i < $colorsNum; $i++) {
1046 1046
 				$colors = imagecolorsforindex($im, $i);
1047
-				$rgbQuad .= chr($colors['blue']) . chr($colors['green']) . chr($colors['red']) . "\0";
1047
+				$rgbQuad .= chr($colors['blue']).chr($colors['green']).chr($colors['red'])."\0";
1048 1048
 			}
1049 1049
 			$bmpData = '';
1050 1050
 			if ($compression == 0 || $bit < 8) {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 						$index = imagecolorat($im, $i, $j);
1078 1078
 						if ($index !== $lastIndex || $sameNum > 255) {
1079 1079
 							if ($sameNum != 0) {
1080
-								$bmpData .= chr($sameNum) . chr($lastIndex);
1080
+								$bmpData .= chr($sameNum).chr($lastIndex);
1081 1081
 							}
1082 1082
 							$lastIndex = $index;
1083 1083
 							$sameNum = 1;
@@ -1118,15 +1118,15 @@  discard block
 block discarded – undo
1118 1118
 			$sizeData = strlen($bmpData);
1119 1119
 			$colorsNum = 0;
1120 1120
 		}
1121
-		$fileHeader = 'BM' . pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1121
+		$fileHeader = 'BM'.pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1122 1122
 		$infoHeader = pack('V3v2V*', 0x28, $width, $height, 1, $bit, $compression, $sizeData, 0, 0, $colorsNum, 0);
1123 1123
 		if ($fileName != '') {
1124 1124
 			$fp = fopen($fileName, 'wb');
1125
-			fwrite($fp, $fileHeader . $infoHeader . $rgbQuad . $bmpData);
1125
+			fwrite($fp, $fileHeader.$infoHeader.$rgbQuad.$bmpData);
1126 1126
 			fclose($fp);
1127 1127
 			return true;
1128 1128
 		}
1129
-		echo $fileHeader . $infoHeader . $rgbQuad . $bmpData;
1129
+		echo $fileHeader.$infoHeader.$rgbQuad.$bmpData;
1130 1130
 		return true;
1131 1131
 	}
1132 1132
 }
Please login to merge, or discard this patch.
lib/private/legacy/l10n/string.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,13 +56,13 @@
 block discarded – undo
56 56
 		$translations = $this->l10n->getTranslations();
57 57
 
58 58
 		$text = $this->text;
59
-		if(array_key_exists($this->text, $translations)) {
60
-			if(is_array($translations[$this->text])) {
59
+		if (array_key_exists($this->text, $translations)) {
60
+			if (is_array($translations[$this->text])) {
61 61
 				$fn = $this->l10n->getPluralFormFunction();
62 62
 				$id = $fn($this->count);
63 63
 				$text = $translations[$this->text][$id];
64 64
 			}
65
-			else{
65
+			else {
66 66
 				$text = $translations[$this->text];
67 67
 			}
68 68
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@
 block discarded – undo
61 61
 				$fn = $this->l10n->getPluralFormFunction();
62 62
 				$id = $fn($this->count);
63 63
 				$text = $translations[$this->text][$id];
64
-			}
65
-			else{
64
+			} else{
66 65
 				$text = $translations[$this->text];
67 66
 			}
68 67
 		}
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,53 +27,53 @@
 block discarded – undo
27 27
  */
28 28
 
29 29
 class OC_L10N_String implements JsonSerializable {
30
-	/** @var \OC_L10N|\OC\L10N\L10N */
31
-	protected $l10n;
30
+    /** @var \OC_L10N|\OC\L10N\L10N */
31
+    protected $l10n;
32 32
 
33
-	/** @var string */
34
-	protected $text;
33
+    /** @var string */
34
+    protected $text;
35 35
 
36
-	/** @var array */
37
-	protected $parameters;
36
+    /** @var array */
37
+    protected $parameters;
38 38
 
39
-	/** @var integer */
40
-	protected $count;
39
+    /** @var integer */
40
+    protected $count;
41 41
 
42
-	/**
43
-	 * @param \OC_L10N|\OC\L10N\L10N $l10n
44
-	 * @param string|string[] $text
45
-	 * @param array $parameters
46
-	 * @param int $count
47
-	 */
48
-	public function __construct($l10n, $text, $parameters, $count = 1) {
49
-		$this->l10n = $l10n;
50
-		$this->text = $text;
51
-		$this->parameters = $parameters;
52
-		$this->count = $count;
53
-	}
42
+    /**
43
+     * @param \OC_L10N|\OC\L10N\L10N $l10n
44
+     * @param string|string[] $text
45
+     * @param array $parameters
46
+     * @param int $count
47
+     */
48
+    public function __construct($l10n, $text, $parameters, $count = 1) {
49
+        $this->l10n = $l10n;
50
+        $this->text = $text;
51
+        $this->parameters = $parameters;
52
+        $this->count = $count;
53
+    }
54 54
 
55
-	public function __toString() {
56
-		$translations = $this->l10n->getTranslations();
55
+    public function __toString() {
56
+        $translations = $this->l10n->getTranslations();
57 57
 
58
-		$text = $this->text;
59
-		if(array_key_exists($this->text, $translations)) {
60
-			if(is_array($translations[$this->text])) {
61
-				$fn = $this->l10n->getPluralFormFunction();
62
-				$id = $fn($this->count);
63
-				$text = $translations[$this->text][$id];
64
-			}
65
-			else{
66
-				$text = $translations[$this->text];
67
-			}
68
-		}
58
+        $text = $this->text;
59
+        if(array_key_exists($this->text, $translations)) {
60
+            if(is_array($translations[$this->text])) {
61
+                $fn = $this->l10n->getPluralFormFunction();
62
+                $id = $fn($this->count);
63
+                $text = $translations[$this->text][$id];
64
+            }
65
+            else{
66
+                $text = $translations[$this->text];
67
+            }
68
+        }
69 69
 
70
-		// Replace %n first (won't interfere with vsprintf)
71
-		$text = str_replace('%n', $this->count, $text);
72
-		return vsprintf($text, $this->parameters);
73
-	}
70
+        // Replace %n first (won't interfere with vsprintf)
71
+        $text = str_replace('%n', $this->count, $text);
72
+        return vsprintf($text, $this->parameters);
73
+    }
74 74
 
75 75
 
76
-	public function jsonSerialize() {
77
-		return $this->__toString();
78
-	}
76
+    public function jsonSerialize() {
77
+        return $this->__toString();
78
+    }
79 79
 }
Please login to merge, or discard this patch.
lib/private/legacy/filechunking.php 2 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -30,156 +30,156 @@
 block discarded – undo
30 30
 
31 31
 
32 32
 class OC_FileChunking {
33
-	protected $info;
34
-	protected $cache;
35
-
36
-	/**
37
-	 * TTL of chunks
38
-	 *
39
-	 * @var int
40
-	 */
41
-	protected $ttl;
42
-
43
-	static public function decodeName($name) {
44
-		preg_match('/(?P<name>.*)-chunking-(?P<transferid>\d+)-(?P<chunkcount>\d+)-(?P<index>\d+)/', $name, $matches);
45
-		return $matches;
46
-	}
47
-
48
-	/**
49
-	 * @param string[] $info
50
-	 */
51
-	public function __construct($info) {
52
-		$this->info = $info;
53
-		$this->ttl = \OC::$server->getConfig()->getSystemValue('cache_chunk_gc_ttl', 86400);
54
-	}
55
-
56
-	public function getPrefix() {
57
-		$name = $this->info['name'];
58
-		$transferid = $this->info['transferid'];
59
-
60
-		return $name.'-chunking-'.$transferid.'-';
61
-	}
62
-
63
-	protected function getCache() {
64
-		if (!isset($this->cache)) {
65
-			$this->cache = new \OC\Cache\File();
66
-		}
67
-		return $this->cache;
68
-	}
69
-
70
-	/**
71
-	 * Stores the given $data under the given $key - the number of stored bytes is returned
72
-	 *
73
-	 * @param string $index
74
-	 * @param resource $data
75
-	 * @return int
76
-	 */
77
-	public function store($index, $data) {
78
-		$cache = $this->getCache();
79
-		$name = $this->getPrefix().$index;
80
-		$cache->set($name, $data, $this->ttl);
81
-
82
-		return $cache->size($name);
83
-	}
84
-
85
-	public function isComplete() {
86
-		$prefix = $this->getPrefix();
87
-		$cache = $this->getCache();
88
-		$chunkcount = (int)$this->info['chunkcount'];
89
-
90
-		for($i=($chunkcount-1); $i >= 0; $i--) {
91
-			if (!$cache->hasKey($prefix.$i)) {
92
-				return false;
93
-			}
94
-		}
95
-
96
-		return true;
97
-	}
98
-
99
-	/**
100
-	 * Assembles the chunks into the file specified by the path.
101
-	 * Chunks are deleted afterwards.
102
-	 *
103
-	 * @param resource $f target path
104
-	 *
105
-	 * @return integer assembled file size
106
-	 *
107
-	 * @throws \OC\InsufficientStorageException when file could not be fully
108
-	 * assembled due to lack of free space
109
-	 */
110
-	public function assemble($f) {
111
-		$cache = $this->getCache();
112
-		$prefix = $this->getPrefix();
113
-		$count = 0;
114
-		for ($i = 0; $i < $this->info['chunkcount']; $i++) {
115
-			$chunk = $cache->get($prefix.$i);
116
-			// remove after reading to directly save space
117
-			$cache->remove($prefix.$i);
118
-			$count += fwrite($f, $chunk);
119
-			// let php release the memory to work around memory exhausted error with php 5.6
120
-			$chunk = null;
121
-		}
122
-
123
-		return $count;
124
-	}
125
-
126
-	/**
127
-	 * Returns the size of the chunks already present
128
-	 * @return integer size in bytes
129
-	 */
130
-	public function getCurrentSize() {
131
-		$cache = $this->getCache();
132
-		$prefix = $this->getPrefix();
133
-		$total = 0;
134
-		for ($i = 0; $i < $this->info['chunkcount']; $i++) {
135
-			$total += $cache->size($prefix.$i);
136
-		}
137
-		return $total;
138
-	}
139
-
140
-	/**
141
-	 * Removes all chunks which belong to this transmission
142
-	 */
143
-	public function cleanup() {
144
-		$cache = $this->getCache();
145
-		$prefix = $this->getPrefix();
146
-		for($i=0; $i < $this->info['chunkcount']; $i++) {
147
-			$cache->remove($prefix.$i);
148
-		}
149
-	}
150
-
151
-	/**
152
-	 * Removes one specific chunk
153
-	 * @param string $index
154
-	 */
155
-	public function remove($index) {
156
-		$cache = $this->getCache();
157
-		$prefix = $this->getPrefix();
158
-		$cache->remove($prefix.$index);
159
-	}
160
-
161
-	/**
162
-	 * Assembles the chunks into the file specified by the path.
163
-	 * Also triggers the relevant hooks and proxies.
164
-	 *
165
-	 * @param \OC\Files\Storage\Storage $storage storage
166
-	 * @param string $path target path relative to the storage
167
-	 * @return bool true on success or false if file could not be created
168
-	 *
169
-	 * @throws \OC\ServerNotAvailableException
170
-	 */
171
-	public function file_assemble($storage, $path) {
172
-		// use file_put_contents as method because that best matches what this function does
173
-		if (\OC\Files\Filesystem::isValidPath($path)) {
174
-			$target = $storage->fopen($path, 'w');
175
-			if ($target) {
176
-				$count = $this->assemble($target);
177
-				fclose($target);
178
-				return $count > 0;
179
-			} else {
180
-				return false;
181
-			}
182
-		}
183
-		return false;
184
-	}
33
+    protected $info;
34
+    protected $cache;
35
+
36
+    /**
37
+     * TTL of chunks
38
+     *
39
+     * @var int
40
+     */
41
+    protected $ttl;
42
+
43
+    static public function decodeName($name) {
44
+        preg_match('/(?P<name>.*)-chunking-(?P<transferid>\d+)-(?P<chunkcount>\d+)-(?P<index>\d+)/', $name, $matches);
45
+        return $matches;
46
+    }
47
+
48
+    /**
49
+     * @param string[] $info
50
+     */
51
+    public function __construct($info) {
52
+        $this->info = $info;
53
+        $this->ttl = \OC::$server->getConfig()->getSystemValue('cache_chunk_gc_ttl', 86400);
54
+    }
55
+
56
+    public function getPrefix() {
57
+        $name = $this->info['name'];
58
+        $transferid = $this->info['transferid'];
59
+
60
+        return $name.'-chunking-'.$transferid.'-';
61
+    }
62
+
63
+    protected function getCache() {
64
+        if (!isset($this->cache)) {
65
+            $this->cache = new \OC\Cache\File();
66
+        }
67
+        return $this->cache;
68
+    }
69
+
70
+    /**
71
+     * Stores the given $data under the given $key - the number of stored bytes is returned
72
+     *
73
+     * @param string $index
74
+     * @param resource $data
75
+     * @return int
76
+     */
77
+    public function store($index, $data) {
78
+        $cache = $this->getCache();
79
+        $name = $this->getPrefix().$index;
80
+        $cache->set($name, $data, $this->ttl);
81
+
82
+        return $cache->size($name);
83
+    }
84
+
85
+    public function isComplete() {
86
+        $prefix = $this->getPrefix();
87
+        $cache = $this->getCache();
88
+        $chunkcount = (int)$this->info['chunkcount'];
89
+
90
+        for($i=($chunkcount-1); $i >= 0; $i--) {
91
+            if (!$cache->hasKey($prefix.$i)) {
92
+                return false;
93
+            }
94
+        }
95
+
96
+        return true;
97
+    }
98
+
99
+    /**
100
+     * Assembles the chunks into the file specified by the path.
101
+     * Chunks are deleted afterwards.
102
+     *
103
+     * @param resource $f target path
104
+     *
105
+     * @return integer assembled file size
106
+     *
107
+     * @throws \OC\InsufficientStorageException when file could not be fully
108
+     * assembled due to lack of free space
109
+     */
110
+    public function assemble($f) {
111
+        $cache = $this->getCache();
112
+        $prefix = $this->getPrefix();
113
+        $count = 0;
114
+        for ($i = 0; $i < $this->info['chunkcount']; $i++) {
115
+            $chunk = $cache->get($prefix.$i);
116
+            // remove after reading to directly save space
117
+            $cache->remove($prefix.$i);
118
+            $count += fwrite($f, $chunk);
119
+            // let php release the memory to work around memory exhausted error with php 5.6
120
+            $chunk = null;
121
+        }
122
+
123
+        return $count;
124
+    }
125
+
126
+    /**
127
+     * Returns the size of the chunks already present
128
+     * @return integer size in bytes
129
+     */
130
+    public function getCurrentSize() {
131
+        $cache = $this->getCache();
132
+        $prefix = $this->getPrefix();
133
+        $total = 0;
134
+        for ($i = 0; $i < $this->info['chunkcount']; $i++) {
135
+            $total += $cache->size($prefix.$i);
136
+        }
137
+        return $total;
138
+    }
139
+
140
+    /**
141
+     * Removes all chunks which belong to this transmission
142
+     */
143
+    public function cleanup() {
144
+        $cache = $this->getCache();
145
+        $prefix = $this->getPrefix();
146
+        for($i=0; $i < $this->info['chunkcount']; $i++) {
147
+            $cache->remove($prefix.$i);
148
+        }
149
+    }
150
+
151
+    /**
152
+     * Removes one specific chunk
153
+     * @param string $index
154
+     */
155
+    public function remove($index) {
156
+        $cache = $this->getCache();
157
+        $prefix = $this->getPrefix();
158
+        $cache->remove($prefix.$index);
159
+    }
160
+
161
+    /**
162
+     * Assembles the chunks into the file specified by the path.
163
+     * Also triggers the relevant hooks and proxies.
164
+     *
165
+     * @param \OC\Files\Storage\Storage $storage storage
166
+     * @param string $path target path relative to the storage
167
+     * @return bool true on success or false if file could not be created
168
+     *
169
+     * @throws \OC\ServerNotAvailableException
170
+     */
171
+    public function file_assemble($storage, $path) {
172
+        // use file_put_contents as method because that best matches what this function does
173
+        if (\OC\Files\Filesystem::isValidPath($path)) {
174
+            $target = $storage->fopen($path, 'w');
175
+            if ($target) {
176
+                $count = $this->assemble($target);
177
+                fclose($target);
178
+                return $count > 0;
179
+            } else {
180
+                return false;
181
+            }
182
+        }
183
+        return false;
184
+    }
185 185
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	public function isComplete() {
86 86
 		$prefix = $this->getPrefix();
87 87
 		$cache = $this->getCache();
88
-		$chunkcount = (int)$this->info['chunkcount'];
88
+		$chunkcount = (int) $this->info['chunkcount'];
89 89
 
90
-		for($i=($chunkcount-1); $i >= 0; $i--) {
90
+		for ($i = ($chunkcount - 1); $i >= 0; $i--) {
91 91
 			if (!$cache->hasKey($prefix.$i)) {
92 92
 				return false;
93 93
 			}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	public function cleanup() {
144 144
 		$cache = $this->getCache();
145 145
 		$prefix = $this->getPrefix();
146
-		for($i=0; $i < $this->info['chunkcount']; $i++) {
146
+		for ($i = 0; $i < $this->info['chunkcount']; $i++) {
147 147
 			$cache->remove($prefix.$i);
148 148
 		}
149 149
 	}
Please login to merge, or discard this patch.
lib/private/legacy/group.php 1 patch
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -50,253 +50,253 @@
 block discarded – undo
50 50
  */
51 51
 class OC_Group {
52 52
 
53
-	/**
54
-	 * @return \OC\Group\Manager
55
-	 * @deprecated Use \OC::$server->getGroupManager();
56
-	 */
57
-	public static function getManager() {
58
-		return \OC::$server->getGroupManager();
59
-	}
53
+    /**
54
+     * @return \OC\Group\Manager
55
+     * @deprecated Use \OC::$server->getGroupManager();
56
+     */
57
+    public static function getManager() {
58
+        return \OC::$server->getGroupManager();
59
+    }
60 60
 
61
-	/**
62
-	 * @return \OC\User\Manager
63
-	 * @deprecated Use \OC::$server->getUserManager()
64
-	 */
65
-	private static function getUserManager() {
66
-		return \OC::$server->getUserManager();
67
-	}
61
+    /**
62
+     * @return \OC\User\Manager
63
+     * @deprecated Use \OC::$server->getUserManager()
64
+     */
65
+    private static function getUserManager() {
66
+        return \OC::$server->getUserManager();
67
+    }
68 68
 
69
-	/**
70
-	 * set the group backend
71
-	 * @param \OC\Group\Backend $backend  The backend to use for user management
72
-	 * @return bool
73
-	 */
74
-	public static function useBackend($backend) {
75
-		self::getManager()->addBackend($backend);
76
-		return true;
77
-	}
69
+    /**
70
+     * set the group backend
71
+     * @param \OC\Group\Backend $backend  The backend to use for user management
72
+     * @return bool
73
+     */
74
+    public static function useBackend($backend) {
75
+        self::getManager()->addBackend($backend);
76
+        return true;
77
+    }
78 78
 
79
-	/**
80
-	 * remove all used backends
81
-	 */
82
-	public static function clearBackends() {
83
-		self::getManager()->clearBackends();
84
-	}
79
+    /**
80
+     * remove all used backends
81
+     */
82
+    public static function clearBackends() {
83
+        self::getManager()->clearBackends();
84
+    }
85 85
 
86
-	/**
87
-	 * Try to create a new group
88
-	 * @param string $gid The name of the group to create
89
-	 * @return bool
90
-	 *
91
-	 * Tries to create a new group. If the group name already exists, false will
92
-	 * be returned. Basic checking of Group name
93
-	 * @deprecated Use \OC::$server->getGroupManager()->createGroup() instead
94
-	 */
95
-	public static function createGroup($gid) {
96
-		if (self::getManager()->createGroup($gid)) {
97
-			return true;
98
-		} else {
99
-			return false;
100
-		}
101
-	}
86
+    /**
87
+     * Try to create a new group
88
+     * @param string $gid The name of the group to create
89
+     * @return bool
90
+     *
91
+     * Tries to create a new group. If the group name already exists, false will
92
+     * be returned. Basic checking of Group name
93
+     * @deprecated Use \OC::$server->getGroupManager()->createGroup() instead
94
+     */
95
+    public static function createGroup($gid) {
96
+        if (self::getManager()->createGroup($gid)) {
97
+            return true;
98
+        } else {
99
+            return false;
100
+        }
101
+    }
102 102
 
103
-	/**
104
-	 * delete a group
105
-	 * @param string $gid gid of the group to delete
106
-	 * @return bool
107
-	 *
108
-	 * Deletes a group and removes it from the group_user-table
109
-	 * @deprecated Use \OC::$server->getGroupManager()->delete() instead
110
-	 */
111
-	public static function deleteGroup($gid) {
112
-		$group = self::getManager()->get($gid);
113
-		if ($group) {
114
-			if ($group->delete()) {
115
-				return true;
116
-			}
117
-		}
118
-		return false;
119
-	}
103
+    /**
104
+     * delete a group
105
+     * @param string $gid gid of the group to delete
106
+     * @return bool
107
+     *
108
+     * Deletes a group and removes it from the group_user-table
109
+     * @deprecated Use \OC::$server->getGroupManager()->delete() instead
110
+     */
111
+    public static function deleteGroup($gid) {
112
+        $group = self::getManager()->get($gid);
113
+        if ($group) {
114
+            if ($group->delete()) {
115
+                return true;
116
+            }
117
+        }
118
+        return false;
119
+    }
120 120
 
121
-	/**
122
-	 * is user in group?
123
-	 * @param string $uid uid of the user
124
-	 * @param string $gid gid of the group
125
-	 * @return bool
126
-	 *
127
-	 * Checks whether the user is member of a group or not.
128
-	 * @deprecated Use \OC::$server->getGroupManager->inGroup($user);
129
-	 */
130
-	public static function inGroup($uid, $gid) {
131
-		$group = self::getManager()->get($gid);
132
-		$user = self::getUserManager()->get($uid);
133
-		if ($group and $user) {
134
-			return $group->inGroup($user);
135
-		}
136
-		return false;
137
-	}
121
+    /**
122
+     * is user in group?
123
+     * @param string $uid uid of the user
124
+     * @param string $gid gid of the group
125
+     * @return bool
126
+     *
127
+     * Checks whether the user is member of a group or not.
128
+     * @deprecated Use \OC::$server->getGroupManager->inGroup($user);
129
+     */
130
+    public static function inGroup($uid, $gid) {
131
+        $group = self::getManager()->get($gid);
132
+        $user = self::getUserManager()->get($uid);
133
+        if ($group and $user) {
134
+            return $group->inGroup($user);
135
+        }
136
+        return false;
137
+    }
138 138
 
139
-	/**
140
-	 * Add a user to a group
141
-	 * @param string $uid Name of the user to add to group
142
-	 * @param string $gid Name of the group in which add the user
143
-	 * @return bool
144
-	 *
145
-	 * Adds a user to a group.
146
-	 * @deprecated Use \OC::$server->getGroupManager->addUser();
147
-	 */
148
-	public static function addToGroup($uid, $gid) {
149
-		$group = self::getManager()->get($gid);
150
-		$user = self::getUserManager()->get($uid);
151
-		if ($group and $user) {
152
-			$group->addUser($user);
153
-			return true;
154
-		} else {
155
-			return false;
156
-		}
157
-	}
139
+    /**
140
+     * Add a user to a group
141
+     * @param string $uid Name of the user to add to group
142
+     * @param string $gid Name of the group in which add the user
143
+     * @return bool
144
+     *
145
+     * Adds a user to a group.
146
+     * @deprecated Use \OC::$server->getGroupManager->addUser();
147
+     */
148
+    public static function addToGroup($uid, $gid) {
149
+        $group = self::getManager()->get($gid);
150
+        $user = self::getUserManager()->get($uid);
151
+        if ($group and $user) {
152
+            $group->addUser($user);
153
+            return true;
154
+        } else {
155
+            return false;
156
+        }
157
+    }
158 158
 
159
-	/**
160
-	 * Removes a user from a group
161
-	 * @param string $uid Name of the user to remove from group
162
-	 * @param string $gid Name of the group from which remove the user
163
-	 * @return bool
164
-	 *
165
-	 * removes the user from a group.
166
-	 */
167
-	public static function removeFromGroup($uid, $gid) {
168
-		$group = self::getManager()->get($gid);
169
-		$user = self::getUserManager()->get($uid);
170
-		if ($group and $user) {
171
-			OC_Hook::emit("OC_Group", "pre_removeFromGroup", array("run" => true, "uid" => $uid, "gid" => $gid));
172
-			$group->removeUser($user);
173
-			OC_Hook::emit("OC_User", "post_removeFromGroup", array("uid" => $uid, "gid" => $gid));
174
-			return true;
175
-		} else {
176
-			return false;
177
-		}
178
-	}
159
+    /**
160
+     * Removes a user from a group
161
+     * @param string $uid Name of the user to remove from group
162
+     * @param string $gid Name of the group from which remove the user
163
+     * @return bool
164
+     *
165
+     * removes the user from a group.
166
+     */
167
+    public static function removeFromGroup($uid, $gid) {
168
+        $group = self::getManager()->get($gid);
169
+        $user = self::getUserManager()->get($uid);
170
+        if ($group and $user) {
171
+            OC_Hook::emit("OC_Group", "pre_removeFromGroup", array("run" => true, "uid" => $uid, "gid" => $gid));
172
+            $group->removeUser($user);
173
+            OC_Hook::emit("OC_User", "post_removeFromGroup", array("uid" => $uid, "gid" => $gid));
174
+            return true;
175
+        } else {
176
+            return false;
177
+        }
178
+    }
179 179
 
180
-	/**
181
-	 * Get all groups a user belongs to
182
-	 * @param string $uid Name of the user
183
-	 * @return array an array of group names
184
-	 *
185
-	 * This function fetches all groups a user belongs to. It does not check
186
-	 * if the user exists at all.
187
-	 * @deprecated Use \OC::$server->getGroupManager->getUserGroupIds($user)
188
-	 */
189
-	public static function getUserGroups($uid) {
190
-		$user = self::getUserManager()->get($uid);
191
-		if ($user) {
192
-			return self::getManager()->getUserGroupIds($user);
193
-		} else {
194
-			return array();
195
-		}
196
-	}
180
+    /**
181
+     * Get all groups a user belongs to
182
+     * @param string $uid Name of the user
183
+     * @return array an array of group names
184
+     *
185
+     * This function fetches all groups a user belongs to. It does not check
186
+     * if the user exists at all.
187
+     * @deprecated Use \OC::$server->getGroupManager->getUserGroupIds($user)
188
+     */
189
+    public static function getUserGroups($uid) {
190
+        $user = self::getUserManager()->get($uid);
191
+        if ($user) {
192
+            return self::getManager()->getUserGroupIds($user);
193
+        } else {
194
+            return array();
195
+        }
196
+    }
197 197
 
198
-	/**
199
-	 * get a list of all groups
200
-	 * @param string $search
201
-	 * @param int|null $limit
202
-	 * @param int|null $offset
203
-	 * @return array an array of group names
204
-	 *
205
-	 * Returns a list with all groups
206
-	 */
207
-	public static function getGroups($search = '', $limit = null, $offset = null) {
208
-		$groups = self::getManager()->search($search, $limit, $offset);
209
-		$groupIds = array();
210
-		foreach ($groups as $group) {
211
-			$groupIds[] = $group->getGID();
212
-		}
213
-		return $groupIds;
214
-	}
198
+    /**
199
+     * get a list of all groups
200
+     * @param string $search
201
+     * @param int|null $limit
202
+     * @param int|null $offset
203
+     * @return array an array of group names
204
+     *
205
+     * Returns a list with all groups
206
+     */
207
+    public static function getGroups($search = '', $limit = null, $offset = null) {
208
+        $groups = self::getManager()->search($search, $limit, $offset);
209
+        $groupIds = array();
210
+        foreach ($groups as $group) {
211
+            $groupIds[] = $group->getGID();
212
+        }
213
+        return $groupIds;
214
+    }
215 215
 
216
-	/**
217
-	 * check if a group exists
218
-	 *
219
-	 * @param string $gid
220
-	 * @return bool
221
-	 * @deprecated Use \OC::$server->getGroupManager->groupExists($gid)
222
-	 */
223
-	public static function groupExists($gid) {
224
-		return self::getManager()->groupExists($gid);
225
-	}
216
+    /**
217
+     * check if a group exists
218
+     *
219
+     * @param string $gid
220
+     * @return bool
221
+     * @deprecated Use \OC::$server->getGroupManager->groupExists($gid)
222
+     */
223
+    public static function groupExists($gid) {
224
+        return self::getManager()->groupExists($gid);
225
+    }
226 226
 
227
-	/**
228
-	 * get a list of all users in a group
229
-	 * @param string $gid
230
-	 * @param string $search
231
-	 * @param int $limit
232
-	 * @param int $offset
233
-	 * @return array an array of user ids
234
-	 */
235
-	public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
236
-		$group = self::getManager()->get($gid);
237
-		if ($group) {
238
-			$users = $group->searchUsers($search, $limit, $offset);
239
-			$userIds = array();
240
-			foreach ($users as $user) {
241
-				$userIds[] = $user->getUID();
242
-			}
243
-			return $userIds;
244
-		} else {
245
-			return array();
246
-		}
247
-	}
227
+    /**
228
+     * get a list of all users in a group
229
+     * @param string $gid
230
+     * @param string $search
231
+     * @param int $limit
232
+     * @param int $offset
233
+     * @return array an array of user ids
234
+     */
235
+    public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
236
+        $group = self::getManager()->get($gid);
237
+        if ($group) {
238
+            $users = $group->searchUsers($search, $limit, $offset);
239
+            $userIds = array();
240
+            foreach ($users as $user) {
241
+                $userIds[] = $user->getUID();
242
+            }
243
+            return $userIds;
244
+        } else {
245
+            return array();
246
+        }
247
+    }
248 248
 
249
-	/**
250
-	 * get a list of all users in several groups
251
-	 * @param string[] $gids
252
-	 * @param string $search
253
-	 * @param int $limit
254
-	 * @param int $offset
255
-	 * @return array an array of user ids
256
-	 */
257
-	public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) {
258
-		$users = array();
259
-		foreach ($gids as $gid) {
260
-			// TODO Need to apply limits to groups as total
261
-			$users = array_merge(array_diff(self::usersInGroup($gid, $search, $limit, $offset), $users), $users);
262
-		}
263
-		return $users;
264
-	}
249
+    /**
250
+     * get a list of all users in several groups
251
+     * @param string[] $gids
252
+     * @param string $search
253
+     * @param int $limit
254
+     * @param int $offset
255
+     * @return array an array of user ids
256
+     */
257
+    public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) {
258
+        $users = array();
259
+        foreach ($gids as $gid) {
260
+            // TODO Need to apply limits to groups as total
261
+            $users = array_merge(array_diff(self::usersInGroup($gid, $search, $limit, $offset), $users), $users);
262
+        }
263
+        return $users;
264
+    }
265 265
 
266
-	/**
267
-	 * get a list of all display names in a group
268
-	 * @param string $gid
269
-	 * @param string $search
270
-	 * @param int $limit
271
-	 * @param int $offset
272
-	 * @return array an array of display names (value) and user ids(key)
273
-	 * @deprecated Use \OC::$server->getGroupManager->displayNamesInGroup($gid, $search, $limit, $offset)
274
-	 */
275
-	public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
276
-		return self::getManager()->displayNamesInGroup($gid, $search, $limit, $offset);
277
-	}
266
+    /**
267
+     * get a list of all display names in a group
268
+     * @param string $gid
269
+     * @param string $search
270
+     * @param int $limit
271
+     * @param int $offset
272
+     * @return array an array of display names (value) and user ids(key)
273
+     * @deprecated Use \OC::$server->getGroupManager->displayNamesInGroup($gid, $search, $limit, $offset)
274
+     */
275
+    public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
276
+        return self::getManager()->displayNamesInGroup($gid, $search, $limit, $offset);
277
+    }
278 278
 
279
-	/**
280
-	 * get a list of all display names in several groups
281
-	 * @param array $gids
282
-	 * @param string $search
283
-	 * @param int $limit
284
-	 * @param int $offset
285
-	 * @return array an array of display names (Key) user ids (value)
286
-	 */
287
-	public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
288
-		$displayNames = array();
289
-		foreach ($gids as $gid) {
290
-			// TODO Need to apply limits to groups as total
291
-			$diff = array_diff(
292
-				self::displayNamesInGroup($gid, $search, $limit, $offset),
293
-				$displayNames
294
-			);
295
-			if ($diff) {
296
-				// A fix for LDAP users. array_merge loses keys...
297
-				$displayNames = $diff + $displayNames;
298
-			}
299
-		}
300
-		return $displayNames;
301
-	}
279
+    /**
280
+     * get a list of all display names in several groups
281
+     * @param array $gids
282
+     * @param string $search
283
+     * @param int $limit
284
+     * @param int $offset
285
+     * @return array an array of display names (Key) user ids (value)
286
+     */
287
+    public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
288
+        $displayNames = array();
289
+        foreach ($gids as $gid) {
290
+            // TODO Need to apply limits to groups as total
291
+            $diff = array_diff(
292
+                self::displayNamesInGroup($gid, $search, $limit, $offset),
293
+                $displayNames
294
+            );
295
+            if ($diff) {
296
+                // A fix for LDAP users. array_merge loses keys...
297
+                $displayNames = $diff + $displayNames;
298
+            }
299
+        }
300
+        return $displayNames;
301
+    }
302 302
 }
Please login to merge, or discard this patch.
lib/private/legacy/user/backend.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,27 +31,27 @@
 block discarded – undo
31 31
  * error code for functions not provided by the user backend
32 32
  * @deprecated Use \OC_User_Backend::NOT_IMPLEMENTED instead
33 33
  */
34
-define('OC_USER_BACKEND_NOT_IMPLEMENTED',   -501);
34
+define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
35 35
 
36 36
 /**
37 37
  * actions that user backends can define
38 38
  */
39 39
 /** @deprecated Use \OC_User_Backend::CREATE_USER instead */
40
-define('OC_USER_BACKEND_CREATE_USER',       1 << 0);
40
+define('OC_USER_BACKEND_CREATE_USER', 1 << 0);
41 41
 /** @deprecated Use \OC_User_Backend::SET_PASSWORD instead */
42
-define('OC_USER_BACKEND_SET_PASSWORD',      1 << 4);
42
+define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4);
43 43
 /** @deprecated Use \OC_User_Backend::CHECK_PASSWORD instead */
44
-define('OC_USER_BACKEND_CHECK_PASSWORD',    1 << 8);
44
+define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8);
45 45
 /** @deprecated Use \OC_User_Backend::GET_HOME instead */
46
-define('OC_USER_BACKEND_GET_HOME',          1 << 12);
46
+define('OC_USER_BACKEND_GET_HOME', 1 << 12);
47 47
 /** @deprecated Use \OC_User_Backend::GET_DISPLAYNAME instead */
48
-define('OC_USER_BACKEND_GET_DISPLAYNAME',   1 << 16);
48
+define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16);
49 49
 /** @deprecated Use \OC_User_Backend::SET_DISPLAYNAME instead */
50
-define('OC_USER_BACKEND_SET_DISPLAYNAME',   1 << 20);
50
+define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20);
51 51
 /** @deprecated Use \OC_User_Backend::PROVIDE_AVATAR instead */
52
-define('OC_USER_BACKEND_PROVIDE_AVATAR',    1 << 24);
52
+define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24);
53 53
 /** @deprecated Use \OC_User_Backend::COUNT_USERS instead */
54
-define('OC_USER_BACKEND_COUNT_USERS',       1 << 28);
54
+define('OC_USER_BACKEND_COUNT_USERS', 1 << 28);
55 55
 
56 56
 /**
57 57
  * Abstract base class for user management. Provides methods for querying backend
Please login to merge, or discard this patch.
lib/private/legacy/defaults.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		$this->defaultLogoClaim = '';
66 66
 		$this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
67 67
 
68
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
68
+		$themePath = OC::$SERVERROOT.'/themes/'.OC_Util::getTheme().'/defaults.php';
69 69
 		if (file_exists($themePath)) {
70 70
 			// prevent defaults.php from printing output
71 71
 			ob_start();
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 		if ($this->themeExist('getShortFooter')) {
240 240
 			$footer = $this->theme->getShortFooter();
241 241
 		} else {
242
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
-				' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
-				' – ' . $this->getSlogan();
242
+			$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
243
+				' rel="noreferrer">'.$this->getEntity().'</a>'.
244
+				' – '.$this->getSlogan();
245 245
 		}
246 246
 
247 247
 		return $footer;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		if ($this->themeExist('buildDocLinkToKey')) {
269 269
 			return $this->theme->buildDocLinkToKey($key);
270 270
 		}
271
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
271
+		return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key;
272 272
 	}
273 273
 
274 274
 	/**
Please login to merge, or discard this patch.
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -31,256 +31,256 @@
 block discarded – undo
31 31
  */
32 32
 class OC_Defaults {
33 33
 
34
-	private $theme;
35
-	private $l;
34
+    private $theme;
35
+    private $l;
36 36
 
37
-	private $defaultEntity;
38
-	private $defaultName;
39
-	private $defaultTitle;
40
-	private $defaultBaseUrl;
41
-	private $defaultSyncClientUrl;
42
-	private $defaultiOSClientUrl;
43
-	private $defaultiTunesAppId;
44
-	private $defaultAndroidClientUrl;
45
-	private $defaultDocBaseUrl;
46
-	private $defaultDocVersion;
47
-	private $defaultSlogan;
48
-	private $defaultLogoClaim;
49
-	private $defaultMailHeaderColor;
37
+    private $defaultEntity;
38
+    private $defaultName;
39
+    private $defaultTitle;
40
+    private $defaultBaseUrl;
41
+    private $defaultSyncClientUrl;
42
+    private $defaultiOSClientUrl;
43
+    private $defaultiTunesAppId;
44
+    private $defaultAndroidClientUrl;
45
+    private $defaultDocBaseUrl;
46
+    private $defaultDocVersion;
47
+    private $defaultSlogan;
48
+    private $defaultLogoClaim;
49
+    private $defaultMailHeaderColor;
50 50
 
51
-	function __construct() {
52
-		$this->l = \OC::$server->getL10N('lib');
51
+    function __construct() {
52
+        $this->l = \OC::$server->getL10N('lib');
53 53
 
54
-		$this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
55
-		$this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
56
-		$this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
57
-		$this->defaultBaseUrl = 'https://nextcloud.com';
58
-		$this->defaultSyncClientUrl = 'https://nextcloud.com/install';
59
-		$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
60
-		$this->defaultiTunesAppId = '1125420102';
61
-		$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
62
-		$this->defaultDocBaseUrl = 'https://docs.nextcloud.org';
63
-		$this->defaultDocVersion = '10'; // used to generate doc links
64
-		$this->defaultSlogan = $this->l->t('a safe home for all your data');
65
-		$this->defaultLogoClaim = '';
66
-		$this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
54
+        $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
55
+        $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
56
+        $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
57
+        $this->defaultBaseUrl = 'https://nextcloud.com';
58
+        $this->defaultSyncClientUrl = 'https://nextcloud.com/install';
59
+        $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
60
+        $this->defaultiTunesAppId = '1125420102';
61
+        $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
62
+        $this->defaultDocBaseUrl = 'https://docs.nextcloud.org';
63
+        $this->defaultDocVersion = '10'; // used to generate doc links
64
+        $this->defaultSlogan = $this->l->t('a safe home for all your data');
65
+        $this->defaultLogoClaim = '';
66
+        $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
67 67
 
68
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
69
-		if (file_exists($themePath)) {
70
-			// prevent defaults.php from printing output
71
-			ob_start();
72
-			require_once $themePath;
73
-			ob_end_clean();
74
-			if (class_exists('OC_Theme')) {
75
-				$this->theme = new OC_Theme();
76
-			}
77
-		}
78
-	}
68
+        $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
69
+        if (file_exists($themePath)) {
70
+            // prevent defaults.php from printing output
71
+            ob_start();
72
+            require_once $themePath;
73
+            ob_end_clean();
74
+            if (class_exists('OC_Theme')) {
75
+                $this->theme = new OC_Theme();
76
+            }
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * @param string $method
82
-	 */
83
-	private function themeExist($method) {
84
-		if (isset($this->theme) && method_exists($this->theme, $method)) {
85
-			return true;
86
-		}
87
-		return false;
88
-	}
80
+    /**
81
+     * @param string $method
82
+     */
83
+    private function themeExist($method) {
84
+        if (isset($this->theme) && method_exists($this->theme, $method)) {
85
+            return true;
86
+        }
87
+        return false;
88
+    }
89 89
 
90
-	/**
91
-	 * Returns the base URL
92
-	 * @return string URL
93
-	 */
94
-	public function getBaseUrl() {
95
-		if ($this->themeExist('getBaseUrl')) {
96
-			return $this->theme->getBaseUrl();
97
-		} else {
98
-			return $this->defaultBaseUrl;
99
-		}
100
-	}
90
+    /**
91
+     * Returns the base URL
92
+     * @return string URL
93
+     */
94
+    public function getBaseUrl() {
95
+        if ($this->themeExist('getBaseUrl')) {
96
+            return $this->theme->getBaseUrl();
97
+        } else {
98
+            return $this->defaultBaseUrl;
99
+        }
100
+    }
101 101
 
102
-	/**
103
-	 * Returns the URL where the sync clients are listed
104
-	 * @return string URL
105
-	 */
106
-	public function getSyncClientUrl() {
107
-		if ($this->themeExist('getSyncClientUrl')) {
108
-			return $this->theme->getSyncClientUrl();
109
-		} else {
110
-			return $this->defaultSyncClientUrl;
111
-		}
112
-	}
102
+    /**
103
+     * Returns the URL where the sync clients are listed
104
+     * @return string URL
105
+     */
106
+    public function getSyncClientUrl() {
107
+        if ($this->themeExist('getSyncClientUrl')) {
108
+            return $this->theme->getSyncClientUrl();
109
+        } else {
110
+            return $this->defaultSyncClientUrl;
111
+        }
112
+    }
113 113
 
114
-	/**
115
-	 * Returns the URL to the App Store for the iOS Client
116
-	 * @return string URL
117
-	 */
118
-	public function getiOSClientUrl() {
119
-		if ($this->themeExist('getiOSClientUrl')) {
120
-			return $this->theme->getiOSClientUrl();
121
-		} else {
122
-			return $this->defaultiOSClientUrl;
123
-		}
124
-	}
114
+    /**
115
+     * Returns the URL to the App Store for the iOS Client
116
+     * @return string URL
117
+     */
118
+    public function getiOSClientUrl() {
119
+        if ($this->themeExist('getiOSClientUrl')) {
120
+            return $this->theme->getiOSClientUrl();
121
+        } else {
122
+            return $this->defaultiOSClientUrl;
123
+        }
124
+    }
125 125
 
126
-	/**
127
-	 * Returns the AppId for the App Store for the iOS Client
128
-	 * @return string AppId
129
-	 */
130
-	public function getiTunesAppId() {
131
-		if ($this->themeExist('getiTunesAppId')) {
132
-			return $this->theme->getiTunesAppId();
133
-		} else {
134
-			return $this->defaultiTunesAppId;
135
-		}
136
-	}
126
+    /**
127
+     * Returns the AppId for the App Store for the iOS Client
128
+     * @return string AppId
129
+     */
130
+    public function getiTunesAppId() {
131
+        if ($this->themeExist('getiTunesAppId')) {
132
+            return $this->theme->getiTunesAppId();
133
+        } else {
134
+            return $this->defaultiTunesAppId;
135
+        }
136
+    }
137 137
 
138
-	/**
139
-	 * Returns the URL to Google Play for the Android Client
140
-	 * @return string URL
141
-	 */
142
-	public function getAndroidClientUrl() {
143
-		if ($this->themeExist('getAndroidClientUrl')) {
144
-			return $this->theme->getAndroidClientUrl();
145
-		} else {
146
-			return $this->defaultAndroidClientUrl;
147
-		}
148
-	}
138
+    /**
139
+     * Returns the URL to Google Play for the Android Client
140
+     * @return string URL
141
+     */
142
+    public function getAndroidClientUrl() {
143
+        if ($this->themeExist('getAndroidClientUrl')) {
144
+            return $this->theme->getAndroidClientUrl();
145
+        } else {
146
+            return $this->defaultAndroidClientUrl;
147
+        }
148
+    }
149 149
 
150
-	/**
151
-	 * Returns the documentation URL
152
-	 * @return string URL
153
-	 */
154
-	public function getDocBaseUrl() {
155
-		if ($this->themeExist('getDocBaseUrl')) {
156
-			return $this->theme->getDocBaseUrl();
157
-		} else {
158
-			return $this->defaultDocBaseUrl;
159
-		}
160
-	}
150
+    /**
151
+     * Returns the documentation URL
152
+     * @return string URL
153
+     */
154
+    public function getDocBaseUrl() {
155
+        if ($this->themeExist('getDocBaseUrl')) {
156
+            return $this->theme->getDocBaseUrl();
157
+        } else {
158
+            return $this->defaultDocBaseUrl;
159
+        }
160
+    }
161 161
 
162
-	/**
163
-	 * Returns the title
164
-	 * @return string title
165
-	 */
166
-	public function getTitle() {
167
-		if ($this->themeExist('getTitle')) {
168
-			return $this->theme->getTitle();
169
-		} else {
170
-			return $this->defaultTitle;
171
-		}
172
-	}
162
+    /**
163
+     * Returns the title
164
+     * @return string title
165
+     */
166
+    public function getTitle() {
167
+        if ($this->themeExist('getTitle')) {
168
+            return $this->theme->getTitle();
169
+        } else {
170
+            return $this->defaultTitle;
171
+        }
172
+    }
173 173
 
174
-	/**
175
-	 * Returns the short name of the software
176
-	 * @return string title
177
-	 */
178
-	public function getName() {
179
-		if ($this->themeExist('getName')) {
180
-			return $this->theme->getName();
181
-		} else {
182
-			return $this->defaultName;
183
-		}
184
-	}
174
+    /**
175
+     * Returns the short name of the software
176
+     * @return string title
177
+     */
178
+    public function getName() {
179
+        if ($this->themeExist('getName')) {
180
+            return $this->theme->getName();
181
+        } else {
182
+            return $this->defaultName;
183
+        }
184
+    }
185 185
 
186
-	/**
187
-	 * Returns the short name of the software containing HTML strings
188
-	 * @return string title
189
-	 */
190
-	public function getHTMLName() {
191
-		if ($this->themeExist('getHTMLName')) {
192
-			return $this->theme->getHTMLName();
193
-		} else {
194
-			return $this->defaultName;
195
-		}
196
-	}
186
+    /**
187
+     * Returns the short name of the software containing HTML strings
188
+     * @return string title
189
+     */
190
+    public function getHTMLName() {
191
+        if ($this->themeExist('getHTMLName')) {
192
+            return $this->theme->getHTMLName();
193
+        } else {
194
+            return $this->defaultName;
195
+        }
196
+    }
197 197
 
198
-	/**
199
-	 * Returns entity (e.g. company name) - used for footer, copyright
200
-	 * @return string entity name
201
-	 */
202
-	public function getEntity() {
203
-		if ($this->themeExist('getEntity')) {
204
-			return $this->theme->getEntity();
205
-		} else {
206
-			return $this->defaultEntity;
207
-		}
208
-	}
198
+    /**
199
+     * Returns entity (e.g. company name) - used for footer, copyright
200
+     * @return string entity name
201
+     */
202
+    public function getEntity() {
203
+        if ($this->themeExist('getEntity')) {
204
+            return $this->theme->getEntity();
205
+        } else {
206
+            return $this->defaultEntity;
207
+        }
208
+    }
209 209
 
210
-	/**
211
-	 * Returns slogan
212
-	 * @return string slogan
213
-	 */
214
-	public function getSlogan() {
215
-		if ($this->themeExist('getSlogan')) {
216
-			return $this->theme->getSlogan();
217
-		} else {
218
-			return $this->defaultSlogan;
219
-		}
220
-	}
210
+    /**
211
+     * Returns slogan
212
+     * @return string slogan
213
+     */
214
+    public function getSlogan() {
215
+        if ($this->themeExist('getSlogan')) {
216
+            return $this->theme->getSlogan();
217
+        } else {
218
+            return $this->defaultSlogan;
219
+        }
220
+    }
221 221
 
222
-	/**
223
-	 * Returns logo claim
224
-	 * @return string logo claim
225
-	 */
226
-	public function getLogoClaim() {
227
-		if ($this->themeExist('getLogoClaim')) {
228
-			return $this->theme->getLogoClaim();
229
-		} else {
230
-			return $this->defaultLogoClaim;
231
-		}
232
-	}
222
+    /**
223
+     * Returns logo claim
224
+     * @return string logo claim
225
+     */
226
+    public function getLogoClaim() {
227
+        if ($this->themeExist('getLogoClaim')) {
228
+            return $this->theme->getLogoClaim();
229
+        } else {
230
+            return $this->defaultLogoClaim;
231
+        }
232
+    }
233 233
 
234
-	/**
235
-	 * Returns short version of the footer
236
-	 * @return string short footer
237
-	 */
238
-	public function getShortFooter() {
239
-		if ($this->themeExist('getShortFooter')) {
240
-			$footer = $this->theme->getShortFooter();
241
-		} else {
242
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
-				' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
-				' – ' . $this->getSlogan();
245
-		}
234
+    /**
235
+     * Returns short version of the footer
236
+     * @return string short footer
237
+     */
238
+    public function getShortFooter() {
239
+        if ($this->themeExist('getShortFooter')) {
240
+            $footer = $this->theme->getShortFooter();
241
+        } else {
242
+            $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
+                ' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
+                ' – ' . $this->getSlogan();
245
+        }
246 246
 
247
-		return $footer;
248
-	}
247
+        return $footer;
248
+    }
249 249
 
250
-	/**
251
-	 * Returns long version of the footer
252
-	 * @return string long footer
253
-	 */
254
-	public function getLongFooter() {
255
-		if ($this->themeExist('getLongFooter')) {
256
-			$footer = $this->theme->getLongFooter();
257
-		} else {
258
-			$footer = $this->getShortFooter();
259
-		}
250
+    /**
251
+     * Returns long version of the footer
252
+     * @return string long footer
253
+     */
254
+    public function getLongFooter() {
255
+        if ($this->themeExist('getLongFooter')) {
256
+            $footer = $this->theme->getLongFooter();
257
+        } else {
258
+            $footer = $this->getShortFooter();
259
+        }
260 260
 
261
-		return $footer;
262
-	}
261
+        return $footer;
262
+    }
263 263
 
264
-	/**
265
-	 * @param string $key
266
-	 */
267
-	public function buildDocLinkToKey($key) {
268
-		if ($this->themeExist('buildDocLinkToKey')) {
269
-			return $this->theme->buildDocLinkToKey($key);
270
-		}
271
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
272
-	}
264
+    /**
265
+     * @param string $key
266
+     */
267
+    public function buildDocLinkToKey($key) {
268
+        if ($this->themeExist('buildDocLinkToKey')) {
269
+            return $this->theme->buildDocLinkToKey($key);
270
+        }
271
+        return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
272
+    }
273 273
 
274
-	/**
275
-	 * Returns mail header color
276
-	 * @return string
277
-	 */
278
-	public function getMailHeaderColor() {
279
-		if ($this->themeExist('getMailHeaderColor')) {
280
-			return $this->theme->getMailHeaderColor();
281
-		} else {
282
-			return $this->defaultMailHeaderColor;
283
-		}
284
-	}
274
+    /**
275
+     * Returns mail header color
276
+     * @return string
277
+     */
278
+    public function getMailHeaderColor() {
279
+        if ($this->themeExist('getMailHeaderColor')) {
280
+            return $this->theme->getMailHeaderColor();
281
+        } else {
282
+            return $this->defaultMailHeaderColor;
283
+        }
284
+    }
285 285
 
286 286
 }
Please login to merge, or discard this patch.
lib/private/legacy/ocs.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
  * Class to handle open collaboration services API requests
31 31
  */
32 32
 class OC_OCS {
33
-	/**
34
-	 * Called when a not existing OCS endpoint has been called
35
-	 */
36
-	public static function notFound() {
37
-		$format = \OC::$server->getRequest()->getParam('format', 'xml');
38
-		$txt='Invalid query, please check the syntax. API specifications are here:'
39
-			.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
40
-		OC_API::respond(new OC_OCS_Result(null, API::RESPOND_NOT_FOUND, $txt), $format);
41
-	}
33
+    /**
34
+     * Called when a not existing OCS endpoint has been called
35
+     */
36
+    public static function notFound() {
37
+        $format = \OC::$server->getRequest()->getParam('format', 'xml');
38
+        $txt='Invalid query, please check the syntax. API specifications are here:'
39
+            .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
40
+        OC_API::respond(new OC_OCS_Result(null, API::RESPOND_NOT_FOUND, $txt), $format);
41
+    }
42 42
 
43 43
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	 */
36 36
 	public static function notFound() {
37 37
 		$format = \OC::$server->getRequest()->getParam('format', 'xml');
38
-		$txt='Invalid query, please check the syntax. API specifications are here:'
38
+		$txt = 'Invalid query, please check the syntax. API specifications are here:'
39 39
 			.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
40 40
 		OC_API::respond(new OC_OCS_Result(null, API::RESPOND_NOT_FOUND, $txt), $format);
41 41
 	}
Please login to merge, or discard this patch.