Passed
Push — master ( abb1fd...21d836 )
by John
26:07 queued 12:38
created
lib/public/Util.php 2 patches
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -57,473 +57,473 @@
 block discarded – undo
57 57
  * @since 4.0.0
58 58
  */
59 59
 class Util {
60
-	/**
61
-	 * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
62
-	 */
63
-	const DEBUG=0;
64
-	/**
65
-	 * @deprecated 14.0.0 use \OCP\ILogger::INFO
66
-	 */
67
-	const INFO=1;
68
-	/**
69
-	 * @deprecated 14.0.0 use \OCP\ILogger::WARN
70
-	 */
71
-	const WARN=2;
72
-	/**
73
-	 * @deprecated 14.0.0 use \OCP\ILogger::ERROR
74
-	 */
75
-	const ERROR=3;
76
-	/**
77
-	 * @deprecated 14.0.0 use \OCP\ILogger::FATAL
78
-	 */
79
-	const FATAL=4;
80
-
81
-	/** \OCP\Share\IManager */
82
-	private static $shareManager;
83
-
84
-	/**
85
-	 * get the current installed version of Nextcloud
86
-	 * @return array
87
-	 * @since 4.0.0
88
-	 */
89
-	public static function getVersion() {
90
-		return \OC_Util::getVersion();
91
-	}
92
-
93
-	/**
94
-	 * @since 17.0.0
95
-	 */
96
-	public static function hasExtendedSupport(): bool {
97
-		try {
98
-			/** @var \OCP\Support\Subscription\IRegistry */
99
-			$subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
100
-			return $subscriptionRegistry->delegateHasExtendedSupport();
101
-		} catch (AppFramework\QueryException $e) {}
102
-		return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
103
-	}
104
-
105
-	/**
106
-	 * Set current update channel
107
-	 * @param string $channel
108
-	 * @since 8.1.0
109
-	 */
110
-	public static function setChannel($channel) {
111
-		\OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
112
-	}
113
-
114
-	/**
115
-	 * Get current update channel
116
-	 * @return string
117
-	 * @since 8.1.0
118
-	 */
119
-	public static function getChannel() {
120
-		return \OC_Util::getChannel();
121
-	}
122
-
123
-	/**
124
-	 * write a message in the log
125
-	 * @param string $app
126
-	 * @param string $message
127
-	 * @param int $level
128
-	 * @since 4.0.0
129
-	 * @deprecated 13.0.0 use log of \OCP\ILogger
130
-	 */
131
-	public static function writeLog( $app, $message, $level ) {
132
-		$context = ['app' => $app];
133
-		\OC::$server->getLogger()->log($level, $message, $context);
134
-	}
135
-
136
-	/**
137
-	 * check if sharing is disabled for the current user
138
-	 *
139
-	 * @return boolean
140
-	 * @since 7.0.0
141
-	 * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
142
-	 */
143
-	public static function isSharingDisabledForUser() {
144
-		if (self::$shareManager === null) {
145
-			self::$shareManager = \OC::$server->getShareManager();
146
-		}
147
-
148
-		$user = \OC::$server->getUserSession()->getUser();
149
-		if ($user !== null) {
150
-			$user = $user->getUID();
151
-		}
152
-
153
-		return self::$shareManager->sharingDisabledForUser($user);
154
-	}
155
-
156
-	/**
157
-	 * get l10n object
158
-	 * @param string $application
159
-	 * @param string|null $language
160
-	 * @return \OCP\IL10N
161
-	 * @since 6.0.0 - parameter $language was added in 8.0.0
162
-	 */
163
-	public static function getL10N($application, $language = null) {
164
-		return \OC::$server->getL10N($application, $language);
165
-	}
166
-
167
-	/**
168
-	 * add a css file
169
-	 * @param string $application
170
-	 * @param string $file
171
-	 * @since 4.0.0
172
-	 */
173
-	public static function addStyle( $application, $file = null ) {
174
-		\OC_Util::addStyle( $application, $file );
175
-	}
176
-
177
-	/**
178
-	 * add a javascript file
179
-	 * @param string $application
180
-	 * @param string $file
181
-	 * @since 4.0.0
182
-	 */
183
-	public static function addScript( $application, $file = null ) {
184
-		\OC_Util::addScript( $application, $file );
185
-	}
186
-
187
-	/**
188
-	 * Add a translation JS file
189
-	 * @param string $application application id
190
-	 * @param string $languageCode language code, defaults to the current locale
191
-	 * @since 8.0.0
192
-	 */
193
-	public static function addTranslations($application, $languageCode = null) {
194
-		\OC_Util::addTranslations($application, $languageCode);
195
-	}
196
-
197
-	/**
198
-	 * Add a custom element to the header
199
-	 * If $text is null then the element will be written as empty element.
200
-	 * So use "" to get a closing tag.
201
-	 * @param string $tag tag name of the element
202
-	 * @param array $attributes array of attributes for the element
203
-	 * @param string $text the text content for the element
204
-	 * @since 4.0.0
205
-	 */
206
-	public static function addHeader($tag, $attributes, $text=null) {
207
-		\OC_Util::addHeader($tag, $attributes, $text);
208
-	}
209
-
210
-	/**
211
-	 * Creates an absolute url to the given app and file.
212
-	 * @param string $app app
213
-	 * @param string $file file
214
-	 * @param array $args array with param=>value, will be appended to the returned url
215
-	 * 	The value of $args will be urlencoded
216
-	 * @return string the url
217
-	 * @since 4.0.0 - parameter $args was added in 4.5.0
218
-	 */
219
-	public static function linkToAbsolute( $app, $file, $args = array() ) {
220
-		$urlGenerator = \OC::$server->getURLGenerator();
221
-		return $urlGenerator->getAbsoluteURL(
222
-			$urlGenerator->linkTo($app, $file, $args)
223
-		);
224
-	}
225
-
226
-	/**
227
-	 * Creates an absolute url for remote use.
228
-	 * @param string $service id
229
-	 * @return string the url
230
-	 * @since 4.0.0
231
-	 */
232
-	public static function linkToRemote( $service ) {
233
-		$urlGenerator = \OC::$server->getURLGenerator();
234
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
235
-		return $urlGenerator->getAbsoluteURL(
236
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
237
-		);
238
-	}
239
-
240
-	/**
241
-	 * Creates an absolute url for public use
242
-	 * @param string $service id
243
-	 * @return string the url
244
-	 * @since 4.5.0
245
-	 * @deprecated 15.0.0 - use OCP\IURLGenerator
246
-	 */
247
-	public static function linkToPublic($service) {
248
-		$urlGenerator = \OC::$server->getURLGenerator();
249
-		if ($service === 'files') {
250
-			return $urlGenerator->getAbsoluteURL('/s');
251
-		}
252
-		return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
253
-	}
254
-
255
-	/**
256
-	 * Returns the server host name without an eventual port number
257
-	 * @return string the server hostname
258
-	 * @since 5.0.0
259
-	 */
260
-	public static function getServerHostName() {
261
-		$host_name = \OC::$server->getRequest()->getServerHost();
262
-		// strip away port number (if existing)
263
-		$colon_pos = strpos($host_name, ':');
264
-		if ($colon_pos != FALSE) {
265
-			$host_name = substr($host_name, 0, $colon_pos);
266
-		}
267
-		return $host_name;
268
-	}
269
-
270
-	/**
271
-	 * Returns the default email address
272
-	 * @param string $user_part the user part of the address
273
-	 * @return string the default email address
274
-	 *
275
-	 * Assembles a default email address (using the server hostname
276
-	 * and the given user part, and returns it
277
-	 * Example: when given lostpassword-noreply as $user_part param,
278
-	 *     and is currently accessed via http(s)://example.com/,
279
-	 *     it would return '[email protected]'
280
-	 *
281
-	 * If the configuration value 'mail_from_address' is set in
282
-	 * config.php, this value will override the $user_part that
283
-	 * is passed to this function
284
-	 * @since 5.0.0
285
-	 */
286
-	public static function getDefaultEmailAddress($user_part) {
287
-		$config = \OC::$server->getConfig();
288
-		$user_part = $config->getSystemValue('mail_from_address', $user_part);
289
-		$host_name = self::getServerHostName();
290
-		$host_name = $config->getSystemValue('mail_domain', $host_name);
291
-		$defaultEmailAddress = $user_part.'@'.$host_name;
292
-
293
-		$mailer = \OC::$server->getMailer();
294
-		if ($mailer->validateMailAddress($defaultEmailAddress)) {
295
-			return $defaultEmailAddress;
296
-		}
297
-
298
-		// in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
299
-		return $user_part.'@localhost.localdomain';
300
-	}
301
-
302
-	/**
303
-	 * Make a human file size (2048 to 2 kB)
304
-	 * @param int $bytes file size in bytes
305
-	 * @return string a human readable file size
306
-	 * @since 4.0.0
307
-	 */
308
-	public static function humanFileSize($bytes) {
309
-		return \OC_Helper::humanFileSize($bytes);
310
-	}
311
-
312
-	/**
313
-	 * Make a computer file size (2 kB to 2048)
314
-	 * @param string $str file size in a fancy format
315
-	 * @return float a file size in bytes
316
-	 *
317
-	 * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
318
-	 * @since 4.0.0
319
-	 */
320
-	public static function computerFileSize($str) {
321
-		return \OC_Helper::computerFileSize($str);
322
-	}
323
-
324
-	/**
325
-	 * connects a function to a hook
326
-	 *
327
-	 * @param string $signalClass class name of emitter
328
-	 * @param string $signalName name of signal
329
-	 * @param string|object $slotClass class name of slot
330
-	 * @param string $slotName name of slot
331
-	 * @return bool
332
-	 *
333
-	 * This function makes it very easy to connect to use hooks.
334
-	 *
335
-	 * TODO: write example
336
-	 * @since 4.0.0
337
-	 */
338
-	static public function connectHook($signalClass, $signalName, $slotClass, $slotName) {
339
-		return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
340
-	}
341
-
342
-	/**
343
-	 * Emits a signal. To get data from the slot use references!
344
-	 * @param string $signalclass class name of emitter
345
-	 * @param string $signalname name of signal
346
-	 * @param array $params default: array() array with additional data
347
-	 * @return bool true if slots exists or false if not
348
-	 *
349
-	 * TODO: write example
350
-	 * @since 4.0.0
351
-	 */
352
-	static public function emitHook($signalclass, $signalname, $params = array()) {
353
-		return \OC_Hook::emit($signalclass, $signalname, $params);
354
-	}
355
-
356
-	/**
357
-	 * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
358
-	 * multiple OC_Template elements which invoke `callRegister`. If the value
359
-	 * would not be cached these unit-tests would fail.
360
-	 * @var string
361
-	 */
362
-	private static $token = '';
363
-
364
-	/**
365
-	 * Register an get/post call. This is important to prevent CSRF attacks
366
-	 * @since 4.5.0
367
-	 */
368
-	public static function callRegister() {
369
-		if(self::$token === '') {
370
-			self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
371
-		}
372
-		return self::$token;
373
-	}
374
-
375
-	/**
376
-	 * Used to sanitize HTML
377
-	 *
378
-	 * This function is used to sanitize HTML and should be applied on any
379
-	 * string or array of strings before displaying it on a web page.
380
-	 *
381
-	 * @param string|array $value
382
-	 * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
383
-	 * @since 4.5.0
384
-	 */
385
-	public static function sanitizeHTML($value) {
386
-		return \OC_Util::sanitizeHTML($value);
387
-	}
388
-
389
-	/**
390
-	 * Public function to encode url parameters
391
-	 *
392
-	 * This function is used to encode path to file before output.
393
-	 * Encoding is done according to RFC 3986 with one exception:
394
-	 * Character '/' is preserved as is.
395
-	 *
396
-	 * @param string $component part of URI to encode
397
-	 * @return string
398
-	 * @since 6.0.0
399
-	 */
400
-	public static function encodePath($component) {
401
-		return \OC_Util::encodePath($component);
402
-	}
403
-
404
-	/**
405
-	 * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
406
-	 *
407
-	 * @param array $input The array to work on
408
-	 * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
409
-	 * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
410
-	 * @return array
411
-	 * @since 4.5.0
412
-	 */
413
-	public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
414
-		return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
415
-	}
416
-
417
-	/**
418
-	 * performs a search in a nested array
419
-	 *
420
-	 * @param array $haystack the array to be searched
421
-	 * @param string $needle the search string
422
-	 * @param mixed $index optional, only search this key name
423
-	 * @return mixed the key of the matching field, otherwise false
424
-	 * @since 4.5.0
425
-	 * @deprecated 15.0.0
426
-	 */
427
-	public static function recursiveArraySearch($haystack, $needle, $index = null) {
428
-		return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
429
-	}
430
-
431
-	/**
432
-	 * calculates the maximum upload size respecting system settings, free space and user quota
433
-	 *
434
-	 * @param string $dir the current folder where the user currently operates
435
-	 * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
436
-	 * @return int number of bytes representing
437
-	 * @since 5.0.0
438
-	 */
439
-	public static function maxUploadFilesize($dir, $free = null) {
440
-		return \OC_Helper::maxUploadFilesize($dir, $free);
441
-	}
442
-
443
-	/**
444
-	 * Calculate free space left within user quota
445
-	 * @param string $dir the current folder where the user currently operates
446
-	 * @return int number of bytes representing
447
-	 * @since 7.0.0
448
-	 */
449
-	public static function freeSpace($dir) {
450
-		return \OC_Helper::freeSpace($dir);
451
-	}
452
-
453
-	/**
454
-	 * Calculate PHP upload limit
455
-	 *
456
-	 * @return int number of bytes representing
457
-	 * @since 7.0.0
458
-	 */
459
-	public static function uploadLimit() {
460
-		return \OC_Helper::uploadLimit();
461
-	}
462
-
463
-	/**
464
-	 * Returns whether the given file name is valid
465
-	 * @param string $file file name to check
466
-	 * @return bool true if the file name is valid, false otherwise
467
-	 * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
468
-	 * @since 7.0.0
469
-	 * @suppress PhanDeprecatedFunction
470
-	 */
471
-	public static function isValidFileName($file) {
472
-		return \OC_Util::isValidFileName($file);
473
-	}
474
-
475
-	/**
476
-	 * Compare two strings to provide a natural sort
477
-	 * @param string $a first string to compare
478
-	 * @param string $b second string to compare
479
-	 * @return int -1 if $b comes before $a, 1 if $a comes before $b
480
-	 * or 0 if the strings are identical
481
-	 * @since 7.0.0
482
-	 */
483
-	public static function naturalSortCompare($a, $b) {
484
-		return \OC\NaturalSort::getInstance()->compare($a, $b);
485
-	}
486
-
487
-	/**
488
-	 * check if a password is required for each public link
489
-	 * @return boolean
490
-	 * @since 7.0.0
491
-	 */
492
-	public static function isPublicLinkPasswordRequired() {
493
-		return \OC_Util::isPublicLinkPasswordRequired();
494
-	}
495
-
496
-	/**
497
-	 * check if share API enforces a default expire date
498
-	 * @return boolean
499
-	 * @since 8.0.0
500
-	 */
501
-	public static function isDefaultExpireDateEnforced() {
502
-		return \OC_Util::isDefaultExpireDateEnforced();
503
-	}
504
-
505
-	protected static $needUpgradeCache = null;
506
-
507
-	/**
508
-	 * Checks whether the current version needs upgrade.
509
-	 *
510
-	 * @return bool true if upgrade is needed, false otherwise
511
-	 * @since 7.0.0
512
-	 */
513
-	public static function needUpgrade() {
514
-		if (!isset(self::$needUpgradeCache)) {
515
-			self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig());
516
-		}
517
-		return self::$needUpgradeCache;
518
-	}
519
-
520
-	/**
521
-	 * is this Internet explorer ?
522
-	 *
523
-	 * @return boolean
524
-	 * @since 14.0.0
525
-	 */
526
-	public static function isIe() {
527
-		return \OC_Util::isIe();
528
-	}
60
+    /**
61
+     * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
62
+     */
63
+    const DEBUG=0;
64
+    /**
65
+     * @deprecated 14.0.0 use \OCP\ILogger::INFO
66
+     */
67
+    const INFO=1;
68
+    /**
69
+     * @deprecated 14.0.0 use \OCP\ILogger::WARN
70
+     */
71
+    const WARN=2;
72
+    /**
73
+     * @deprecated 14.0.0 use \OCP\ILogger::ERROR
74
+     */
75
+    const ERROR=3;
76
+    /**
77
+     * @deprecated 14.0.0 use \OCP\ILogger::FATAL
78
+     */
79
+    const FATAL=4;
80
+
81
+    /** \OCP\Share\IManager */
82
+    private static $shareManager;
83
+
84
+    /**
85
+     * get the current installed version of Nextcloud
86
+     * @return array
87
+     * @since 4.0.0
88
+     */
89
+    public static function getVersion() {
90
+        return \OC_Util::getVersion();
91
+    }
92
+
93
+    /**
94
+     * @since 17.0.0
95
+     */
96
+    public static function hasExtendedSupport(): bool {
97
+        try {
98
+            /** @var \OCP\Support\Subscription\IRegistry */
99
+            $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
100
+            return $subscriptionRegistry->delegateHasExtendedSupport();
101
+        } catch (AppFramework\QueryException $e) {}
102
+        return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
103
+    }
104
+
105
+    /**
106
+     * Set current update channel
107
+     * @param string $channel
108
+     * @since 8.1.0
109
+     */
110
+    public static function setChannel($channel) {
111
+        \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
112
+    }
113
+
114
+    /**
115
+     * Get current update channel
116
+     * @return string
117
+     * @since 8.1.0
118
+     */
119
+    public static function getChannel() {
120
+        return \OC_Util::getChannel();
121
+    }
122
+
123
+    /**
124
+     * write a message in the log
125
+     * @param string $app
126
+     * @param string $message
127
+     * @param int $level
128
+     * @since 4.0.0
129
+     * @deprecated 13.0.0 use log of \OCP\ILogger
130
+     */
131
+    public static function writeLog( $app, $message, $level ) {
132
+        $context = ['app' => $app];
133
+        \OC::$server->getLogger()->log($level, $message, $context);
134
+    }
135
+
136
+    /**
137
+     * check if sharing is disabled for the current user
138
+     *
139
+     * @return boolean
140
+     * @since 7.0.0
141
+     * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
142
+     */
143
+    public static function isSharingDisabledForUser() {
144
+        if (self::$shareManager === null) {
145
+            self::$shareManager = \OC::$server->getShareManager();
146
+        }
147
+
148
+        $user = \OC::$server->getUserSession()->getUser();
149
+        if ($user !== null) {
150
+            $user = $user->getUID();
151
+        }
152
+
153
+        return self::$shareManager->sharingDisabledForUser($user);
154
+    }
155
+
156
+    /**
157
+     * get l10n object
158
+     * @param string $application
159
+     * @param string|null $language
160
+     * @return \OCP\IL10N
161
+     * @since 6.0.0 - parameter $language was added in 8.0.0
162
+     */
163
+    public static function getL10N($application, $language = null) {
164
+        return \OC::$server->getL10N($application, $language);
165
+    }
166
+
167
+    /**
168
+     * add a css file
169
+     * @param string $application
170
+     * @param string $file
171
+     * @since 4.0.0
172
+     */
173
+    public static function addStyle( $application, $file = null ) {
174
+        \OC_Util::addStyle( $application, $file );
175
+    }
176
+
177
+    /**
178
+     * add a javascript file
179
+     * @param string $application
180
+     * @param string $file
181
+     * @since 4.0.0
182
+     */
183
+    public static function addScript( $application, $file = null ) {
184
+        \OC_Util::addScript( $application, $file );
185
+    }
186
+
187
+    /**
188
+     * Add a translation JS file
189
+     * @param string $application application id
190
+     * @param string $languageCode language code, defaults to the current locale
191
+     * @since 8.0.0
192
+     */
193
+    public static function addTranslations($application, $languageCode = null) {
194
+        \OC_Util::addTranslations($application, $languageCode);
195
+    }
196
+
197
+    /**
198
+     * Add a custom element to the header
199
+     * If $text is null then the element will be written as empty element.
200
+     * So use "" to get a closing tag.
201
+     * @param string $tag tag name of the element
202
+     * @param array $attributes array of attributes for the element
203
+     * @param string $text the text content for the element
204
+     * @since 4.0.0
205
+     */
206
+    public static function addHeader($tag, $attributes, $text=null) {
207
+        \OC_Util::addHeader($tag, $attributes, $text);
208
+    }
209
+
210
+    /**
211
+     * Creates an absolute url to the given app and file.
212
+     * @param string $app app
213
+     * @param string $file file
214
+     * @param array $args array with param=>value, will be appended to the returned url
215
+     * 	The value of $args will be urlencoded
216
+     * @return string the url
217
+     * @since 4.0.0 - parameter $args was added in 4.5.0
218
+     */
219
+    public static function linkToAbsolute( $app, $file, $args = array() ) {
220
+        $urlGenerator = \OC::$server->getURLGenerator();
221
+        return $urlGenerator->getAbsoluteURL(
222
+            $urlGenerator->linkTo($app, $file, $args)
223
+        );
224
+    }
225
+
226
+    /**
227
+     * Creates an absolute url for remote use.
228
+     * @param string $service id
229
+     * @return string the url
230
+     * @since 4.0.0
231
+     */
232
+    public static function linkToRemote( $service ) {
233
+        $urlGenerator = \OC::$server->getURLGenerator();
234
+        $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
235
+        return $urlGenerator->getAbsoluteURL(
236
+            $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
237
+        );
238
+    }
239
+
240
+    /**
241
+     * Creates an absolute url for public use
242
+     * @param string $service id
243
+     * @return string the url
244
+     * @since 4.5.0
245
+     * @deprecated 15.0.0 - use OCP\IURLGenerator
246
+     */
247
+    public static function linkToPublic($service) {
248
+        $urlGenerator = \OC::$server->getURLGenerator();
249
+        if ($service === 'files') {
250
+            return $urlGenerator->getAbsoluteURL('/s');
251
+        }
252
+        return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
253
+    }
254
+
255
+    /**
256
+     * Returns the server host name without an eventual port number
257
+     * @return string the server hostname
258
+     * @since 5.0.0
259
+     */
260
+    public static function getServerHostName() {
261
+        $host_name = \OC::$server->getRequest()->getServerHost();
262
+        // strip away port number (if existing)
263
+        $colon_pos = strpos($host_name, ':');
264
+        if ($colon_pos != FALSE) {
265
+            $host_name = substr($host_name, 0, $colon_pos);
266
+        }
267
+        return $host_name;
268
+    }
269
+
270
+    /**
271
+     * Returns the default email address
272
+     * @param string $user_part the user part of the address
273
+     * @return string the default email address
274
+     *
275
+     * Assembles a default email address (using the server hostname
276
+     * and the given user part, and returns it
277
+     * Example: when given lostpassword-noreply as $user_part param,
278
+     *     and is currently accessed via http(s)://example.com/,
279
+     *     it would return '[email protected]'
280
+     *
281
+     * If the configuration value 'mail_from_address' is set in
282
+     * config.php, this value will override the $user_part that
283
+     * is passed to this function
284
+     * @since 5.0.0
285
+     */
286
+    public static function getDefaultEmailAddress($user_part) {
287
+        $config = \OC::$server->getConfig();
288
+        $user_part = $config->getSystemValue('mail_from_address', $user_part);
289
+        $host_name = self::getServerHostName();
290
+        $host_name = $config->getSystemValue('mail_domain', $host_name);
291
+        $defaultEmailAddress = $user_part.'@'.$host_name;
292
+
293
+        $mailer = \OC::$server->getMailer();
294
+        if ($mailer->validateMailAddress($defaultEmailAddress)) {
295
+            return $defaultEmailAddress;
296
+        }
297
+
298
+        // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
299
+        return $user_part.'@localhost.localdomain';
300
+    }
301
+
302
+    /**
303
+     * Make a human file size (2048 to 2 kB)
304
+     * @param int $bytes file size in bytes
305
+     * @return string a human readable file size
306
+     * @since 4.0.0
307
+     */
308
+    public static function humanFileSize($bytes) {
309
+        return \OC_Helper::humanFileSize($bytes);
310
+    }
311
+
312
+    /**
313
+     * Make a computer file size (2 kB to 2048)
314
+     * @param string $str file size in a fancy format
315
+     * @return float a file size in bytes
316
+     *
317
+     * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
318
+     * @since 4.0.0
319
+     */
320
+    public static function computerFileSize($str) {
321
+        return \OC_Helper::computerFileSize($str);
322
+    }
323
+
324
+    /**
325
+     * connects a function to a hook
326
+     *
327
+     * @param string $signalClass class name of emitter
328
+     * @param string $signalName name of signal
329
+     * @param string|object $slotClass class name of slot
330
+     * @param string $slotName name of slot
331
+     * @return bool
332
+     *
333
+     * This function makes it very easy to connect to use hooks.
334
+     *
335
+     * TODO: write example
336
+     * @since 4.0.0
337
+     */
338
+    static public function connectHook($signalClass, $signalName, $slotClass, $slotName) {
339
+        return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
340
+    }
341
+
342
+    /**
343
+     * Emits a signal. To get data from the slot use references!
344
+     * @param string $signalclass class name of emitter
345
+     * @param string $signalname name of signal
346
+     * @param array $params default: array() array with additional data
347
+     * @return bool true if slots exists or false if not
348
+     *
349
+     * TODO: write example
350
+     * @since 4.0.0
351
+     */
352
+    static public function emitHook($signalclass, $signalname, $params = array()) {
353
+        return \OC_Hook::emit($signalclass, $signalname, $params);
354
+    }
355
+
356
+    /**
357
+     * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
358
+     * multiple OC_Template elements which invoke `callRegister`. If the value
359
+     * would not be cached these unit-tests would fail.
360
+     * @var string
361
+     */
362
+    private static $token = '';
363
+
364
+    /**
365
+     * Register an get/post call. This is important to prevent CSRF attacks
366
+     * @since 4.5.0
367
+     */
368
+    public static function callRegister() {
369
+        if(self::$token === '') {
370
+            self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
371
+        }
372
+        return self::$token;
373
+    }
374
+
375
+    /**
376
+     * Used to sanitize HTML
377
+     *
378
+     * This function is used to sanitize HTML and should be applied on any
379
+     * string or array of strings before displaying it on a web page.
380
+     *
381
+     * @param string|array $value
382
+     * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
383
+     * @since 4.5.0
384
+     */
385
+    public static function sanitizeHTML($value) {
386
+        return \OC_Util::sanitizeHTML($value);
387
+    }
388
+
389
+    /**
390
+     * Public function to encode url parameters
391
+     *
392
+     * This function is used to encode path to file before output.
393
+     * Encoding is done according to RFC 3986 with one exception:
394
+     * Character '/' is preserved as is.
395
+     *
396
+     * @param string $component part of URI to encode
397
+     * @return string
398
+     * @since 6.0.0
399
+     */
400
+    public static function encodePath($component) {
401
+        return \OC_Util::encodePath($component);
402
+    }
403
+
404
+    /**
405
+     * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
406
+     *
407
+     * @param array $input The array to work on
408
+     * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
409
+     * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
410
+     * @return array
411
+     * @since 4.5.0
412
+     */
413
+    public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
414
+        return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
415
+    }
416
+
417
+    /**
418
+     * performs a search in a nested array
419
+     *
420
+     * @param array $haystack the array to be searched
421
+     * @param string $needle the search string
422
+     * @param mixed $index optional, only search this key name
423
+     * @return mixed the key of the matching field, otherwise false
424
+     * @since 4.5.0
425
+     * @deprecated 15.0.0
426
+     */
427
+    public static function recursiveArraySearch($haystack, $needle, $index = null) {
428
+        return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
429
+    }
430
+
431
+    /**
432
+     * calculates the maximum upload size respecting system settings, free space and user quota
433
+     *
434
+     * @param string $dir the current folder where the user currently operates
435
+     * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
436
+     * @return int number of bytes representing
437
+     * @since 5.0.0
438
+     */
439
+    public static function maxUploadFilesize($dir, $free = null) {
440
+        return \OC_Helper::maxUploadFilesize($dir, $free);
441
+    }
442
+
443
+    /**
444
+     * Calculate free space left within user quota
445
+     * @param string $dir the current folder where the user currently operates
446
+     * @return int number of bytes representing
447
+     * @since 7.0.0
448
+     */
449
+    public static function freeSpace($dir) {
450
+        return \OC_Helper::freeSpace($dir);
451
+    }
452
+
453
+    /**
454
+     * Calculate PHP upload limit
455
+     *
456
+     * @return int number of bytes representing
457
+     * @since 7.0.0
458
+     */
459
+    public static function uploadLimit() {
460
+        return \OC_Helper::uploadLimit();
461
+    }
462
+
463
+    /**
464
+     * Returns whether the given file name is valid
465
+     * @param string $file file name to check
466
+     * @return bool true if the file name is valid, false otherwise
467
+     * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
468
+     * @since 7.0.0
469
+     * @suppress PhanDeprecatedFunction
470
+     */
471
+    public static function isValidFileName($file) {
472
+        return \OC_Util::isValidFileName($file);
473
+    }
474
+
475
+    /**
476
+     * Compare two strings to provide a natural sort
477
+     * @param string $a first string to compare
478
+     * @param string $b second string to compare
479
+     * @return int -1 if $b comes before $a, 1 if $a comes before $b
480
+     * or 0 if the strings are identical
481
+     * @since 7.0.0
482
+     */
483
+    public static function naturalSortCompare($a, $b) {
484
+        return \OC\NaturalSort::getInstance()->compare($a, $b);
485
+    }
486
+
487
+    /**
488
+     * check if a password is required for each public link
489
+     * @return boolean
490
+     * @since 7.0.0
491
+     */
492
+    public static function isPublicLinkPasswordRequired() {
493
+        return \OC_Util::isPublicLinkPasswordRequired();
494
+    }
495
+
496
+    /**
497
+     * check if share API enforces a default expire date
498
+     * @return boolean
499
+     * @since 8.0.0
500
+     */
501
+    public static function isDefaultExpireDateEnforced() {
502
+        return \OC_Util::isDefaultExpireDateEnforced();
503
+    }
504
+
505
+    protected static $needUpgradeCache = null;
506
+
507
+    /**
508
+     * Checks whether the current version needs upgrade.
509
+     *
510
+     * @return bool true if upgrade is needed, false otherwise
511
+     * @since 7.0.0
512
+     */
513
+    public static function needUpgrade() {
514
+        if (!isset(self::$needUpgradeCache)) {
515
+            self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig());
516
+        }
517
+        return self::$needUpgradeCache;
518
+    }
519
+
520
+    /**
521
+     * is this Internet explorer ?
522
+     *
523
+     * @return boolean
524
+     * @since 14.0.0
525
+     */
526
+    public static function isIe() {
527
+        return \OC_Util::isIe();
528
+    }
529 529
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
62 62
 	 */
63
-	const DEBUG=0;
63
+	const DEBUG = 0;
64 64
 	/**
65 65
 	 * @deprecated 14.0.0 use \OCP\ILogger::INFO
66 66
 	 */
67
-	const INFO=1;
67
+	const INFO = 1;
68 68
 	/**
69 69
 	 * @deprecated 14.0.0 use \OCP\ILogger::WARN
70 70
 	 */
71
-	const WARN=2;
71
+	const WARN = 2;
72 72
 	/**
73 73
 	 * @deprecated 14.0.0 use \OCP\ILogger::ERROR
74 74
 	 */
75
-	const ERROR=3;
75
+	const ERROR = 3;
76 76
 	/**
77 77
 	 * @deprecated 14.0.0 use \OCP\ILogger::FATAL
78 78
 	 */
79
-	const FATAL=4;
79
+	const FATAL = 4;
80 80
 
81 81
 	/** \OCP\Share\IManager */
82 82
 	private static $shareManager;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @since 4.0.0
129 129
 	 * @deprecated 13.0.0 use log of \OCP\ILogger
130 130
 	 */
131
-	public static function writeLog( $app, $message, $level ) {
131
+	public static function writeLog($app, $message, $level) {
132 132
 		$context = ['app' => $app];
133 133
 		\OC::$server->getLogger()->log($level, $message, $context);
134 134
 	}
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @param string $file
171 171
 	 * @since 4.0.0
172 172
 	 */
173
-	public static function addStyle( $application, $file = null ) {
174
-		\OC_Util::addStyle( $application, $file );
173
+	public static function addStyle($application, $file = null) {
174
+		\OC_Util::addStyle($application, $file);
175 175
 	}
176 176
 
177 177
 	/**
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 	 * @param string $file
181 181
 	 * @since 4.0.0
182 182
 	 */
183
-	public static function addScript( $application, $file = null ) {
184
-		\OC_Util::addScript( $application, $file );
183
+	public static function addScript($application, $file = null) {
184
+		\OC_Util::addScript($application, $file);
185 185
 	}
186 186
 
187 187
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param string $text the text content for the element
204 204
 	 * @since 4.0.0
205 205
 	 */
206
-	public static function addHeader($tag, $attributes, $text=null) {
206
+	public static function addHeader($tag, $attributes, $text = null) {
207 207
 		\OC_Util::addHeader($tag, $attributes, $text);
208 208
 	}
209 209
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @return string the url
217 217
 	 * @since 4.0.0 - parameter $args was added in 4.5.0
218 218
 	 */
219
-	public static function linkToAbsolute( $app, $file, $args = array() ) {
219
+	public static function linkToAbsolute($app, $file, $args = array()) {
220 220
 		$urlGenerator = \OC::$server->getURLGenerator();
221 221
 		return $urlGenerator->getAbsoluteURL(
222 222
 			$urlGenerator->linkTo($app, $file, $args)
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 	 * @return string the url
230 230
 	 * @since 4.0.0
231 231
 	 */
232
-	public static function linkToRemote( $service ) {
232
+	public static function linkToRemote($service) {
233 233
 		$urlGenerator = \OC::$server->getURLGenerator();
234
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
234
+		$remoteBase = $urlGenerator->linkTo('', 'remote.php').'/'.$service;
235 235
 		return $urlGenerator->getAbsoluteURL(
236
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
236
+			$remoteBase.(($service[strlen($service) - 1] != '/') ? '/' : '')
237 237
 		);
238 238
 	}
239 239
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @since 4.5.0
367 367
 	 */
368 368
 	public static function callRegister() {
369
-		if(self::$token === '') {
369
+		if (self::$token === '') {
370 370
 			self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
371 371
 		}
372 372
 		return self::$token;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 	 */
513 513
 	public static function needUpgrade() {
514 514
 		if (!isset(self::$needUpgradeCache)) {
515
-			self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig());
515
+			self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
516 516
 		}
517 517
 		return self::$needUpgradeCache;
518 518
 	}
Please login to merge, or discard this patch.
lib/public/Support/Subscription/ISubscription.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -28,17 +28,17 @@
 block discarded – undo
28 28
  */
29 29
 interface ISubscription {
30 30
 
31
-	/**
32
-	 * Indicates if a valid subscription is available
33
-	 *
34
-	 * @since 17.0.0
35
-	 */
36
-	public function hasValidSubscription(): bool;
31
+    /**
32
+     * Indicates if a valid subscription is available
33
+     *
34
+     * @since 17.0.0
35
+     */
36
+    public function hasValidSubscription(): bool;
37 37
 
38
-	/**
39
-	 * Indicates if the subscription has extended support
40
-	 *
41
-	 * @since 17.0.0
42
-	 */
43
-	public function hasExtendedSupport(): bool;
38
+    /**
39
+     * Indicates if the subscription has extended support
40
+     *
41
+     * @since 17.0.0
42
+     */
43
+    public function hasExtendedSupport(): bool;
44 44
 }
Please login to merge, or discard this patch.
lib/public/Support/Subscription/IRegistry.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,35 +30,35 @@
 block discarded – undo
30 30
  */
31 31
 interface IRegistry {
32 32
 
33
-	/**
34
-	 * Register a subscription instance. In case it is called multiple times the
35
-	 * first one is used.
36
-	 *
37
-	 * @param ISubscription $subscription
38
-	 * @throws AlreadyRegisteredException
39
-	 *
40
-	 * @since 17.0.0
41
-	 */
42
-	public function register(ISubscription $subscription): void;
33
+    /**
34
+     * Register a subscription instance. In case it is called multiple times the
35
+     * first one is used.
36
+     *
37
+     * @param ISubscription $subscription
38
+     * @throws AlreadyRegisteredException
39
+     *
40
+     * @since 17.0.0
41
+     */
42
+    public function register(ISubscription $subscription): void;
43 43
 
44
-	/**
45
-	 * Fetches the list of app IDs that are supported by the subscription
46
-	 *
47
-	 * @since 17.0.0
48
-	 */
49
-	public function delegateGetSupportedApps(): array;
44
+    /**
45
+     * Fetches the list of app IDs that are supported by the subscription
46
+     *
47
+     * @since 17.0.0
48
+     */
49
+    public function delegateGetSupportedApps(): array;
50 50
 
51
-	/**
52
-	 * Indicates if a valid subscription is available
53
-	 *
54
-	 * @since 17.0.0
55
-	 */
56
-	public function delegateHasValidSubscription(): bool;
51
+    /**
52
+     * Indicates if a valid subscription is available
53
+     *
54
+     * @since 17.0.0
55
+     */
56
+    public function delegateHasValidSubscription(): bool;
57 57
 
58
-	/**
59
-	 * Indicates if the subscription has extended support
60
-	 *
61
-	 * @since 17.0.0
62
-	 */
63
-	public function delegateHasExtendedSupport(): bool;
58
+    /**
59
+     * Indicates if the subscription has extended support
60
+     *
61
+     * @since 17.0.0
62
+     */
63
+    public function delegateHasExtendedSupport(): bool;
64 64
 }
Please login to merge, or discard this patch.
lib/private/Support/Subscription/Registry.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -30,58 +30,58 @@
 block discarded – undo
30 30
 
31 31
 class Registry implements IRegistry {
32 32
 
33
-	/** @var ISubscription */
34
-	private $subscription = null;
33
+    /** @var ISubscription */
34
+    private $subscription = null;
35 35
 
36
-	/**
37
-	 * Register a subscription instance. In case it is called multiple times the
38
-	 * first one is used.
39
-	 *
40
-	 * @param ISubscription $subscription
41
-	 * @throws AlreadyRegisteredException
42
-	 *
43
-	 * @since 17.0.0
44
-	 */
45
-	public function register(ISubscription $subscription): void {
46
-		if ($this->subscription !== null) {
47
-			throw new AlreadyRegisteredException();
48
-		}
49
-		$this->subscription = $subscription;
50
-	}
36
+    /**
37
+     * Register a subscription instance. In case it is called multiple times the
38
+     * first one is used.
39
+     *
40
+     * @param ISubscription $subscription
41
+     * @throws AlreadyRegisteredException
42
+     *
43
+     * @since 17.0.0
44
+     */
45
+    public function register(ISubscription $subscription): void {
46
+        if ($this->subscription !== null) {
47
+            throw new AlreadyRegisteredException();
48
+        }
49
+        $this->subscription = $subscription;
50
+    }
51 51
 
52
-	/**
53
-	 * Fetches the list of app IDs that are supported by the subscription
54
-	 *
55
-	 * @since 17.0.0
56
-	 */
57
-	public function delegateGetSupportedApps(): array {
58
-		if ($this->subscription instanceof ISupportedApps) {
59
-			return $this->subscription->getSupportedApps();
60
-		}
61
-		return [];
62
-	}
52
+    /**
53
+     * Fetches the list of app IDs that are supported by the subscription
54
+     *
55
+     * @since 17.0.0
56
+     */
57
+    public function delegateGetSupportedApps(): array {
58
+        if ($this->subscription instanceof ISupportedApps) {
59
+            return $this->subscription->getSupportedApps();
60
+        }
61
+        return [];
62
+    }
63 63
 
64
-	/**
65
-	 * Indicates if a valid subscription is available
66
-	 *
67
-	 * @since 17.0.0
68
-	 */
69
-	public function delegateHasValidSubscription(): bool {
70
-		if ($this->subscription instanceof ISubscription) {
71
-			return $this->subscription->hasValidSubscription();
72
-		}
73
-		return false;
74
-	}
64
+    /**
65
+     * Indicates if a valid subscription is available
66
+     *
67
+     * @since 17.0.0
68
+     */
69
+    public function delegateHasValidSubscription(): bool {
70
+        if ($this->subscription instanceof ISubscription) {
71
+            return $this->subscription->hasValidSubscription();
72
+        }
73
+        return false;
74
+    }
75 75
 
76
-	/**
77
-	 * Indicates if the subscription has extended support
78
-	 *
79
-	 * @since 17.0.0
80
-	 */
81
-	public function delegateHasExtendedSupport(): bool {
82
-		if ($this->subscription instanceof ISubscription && method_exists($this->subscription, 'hasExtendedSupport')) {
83
-			return $this->subscription->hasExtendedSupport();
84
-		}
85
-		return false;
86
-	}
76
+    /**
77
+     * Indicates if the subscription has extended support
78
+     *
79
+     * @since 17.0.0
80
+     */
81
+    public function delegateHasExtendedSupport(): bool {
82
+        if ($this->subscription instanceof ISubscription && method_exists($this->subscription, 'hasExtendedSupport')) {
83
+            return $this->subscription->hasExtendedSupport();
84
+        }
85
+        return false;
86
+    }
87 87
 }
Please login to merge, or discard this patch.
core/Controller/OCSController.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -34,123 +34,123 @@
 block discarded – undo
34 34
 
35 35
 class OCSController extends \OCP\AppFramework\OCSController {
36 36
 
37
-	/** @var CapabilitiesManager */
38
-	private $capabilitiesManager;
39
-	/** @var IUserSession */
40
-	private $userSession;
41
-	/** @var IUserManager */
42
-	private $userManager;
43
-	/** @var Manager */
44
-	private $keyManager;
37
+    /** @var CapabilitiesManager */
38
+    private $capabilitiesManager;
39
+    /** @var IUserSession */
40
+    private $userSession;
41
+    /** @var IUserManager */
42
+    private $userManager;
43
+    /** @var Manager */
44
+    private $keyManager;
45 45
 
46
-	/**
47
-	 * OCSController constructor.
48
-	 *
49
-	 * @param string $appName
50
-	 * @param IRequest $request
51
-	 * @param CapabilitiesManager $capabilitiesManager
52
-	 * @param IUserSession $userSession
53
-	 * @param IUserManager $userManager
54
-	 * @param Manager $keyManager
55
-	 */
56
-	public function __construct($appName,
57
-								IRequest $request,
58
-								CapabilitiesManager $capabilitiesManager,
59
-								IUserSession $userSession,
60
-								IUserManager $userManager,
61
-								Manager $keyManager) {
62
-		parent::__construct($appName, $request);
63
-		$this->capabilitiesManager = $capabilitiesManager;
64
-		$this->userSession = $userSession;
65
-		$this->userManager = $userManager;
66
-		$this->keyManager = $keyManager;
67
-	}
46
+    /**
47
+     * OCSController constructor.
48
+     *
49
+     * @param string $appName
50
+     * @param IRequest $request
51
+     * @param CapabilitiesManager $capabilitiesManager
52
+     * @param IUserSession $userSession
53
+     * @param IUserManager $userManager
54
+     * @param Manager $keyManager
55
+     */
56
+    public function __construct($appName,
57
+                                IRequest $request,
58
+                                CapabilitiesManager $capabilitiesManager,
59
+                                IUserSession $userSession,
60
+                                IUserManager $userManager,
61
+                                Manager $keyManager) {
62
+        parent::__construct($appName, $request);
63
+        $this->capabilitiesManager = $capabilitiesManager;
64
+        $this->userSession = $userSession;
65
+        $this->userManager = $userManager;
66
+        $this->keyManager = $keyManager;
67
+    }
68 68
 
69
-	/**
70
-	 * @PublicPage
71
-	 *
72
-	 * @return DataResponse
73
-	 */
74
-	public function getConfig() {
75
-		$data = [
76
-			'version' => '1.7',
77
-			'website' => 'Nextcloud',
78
-			'host' => $this->request->getServerHost(),
79
-			'contact' => '',
80
-			'ssl' => 'false',
81
-		];
69
+    /**
70
+     * @PublicPage
71
+     *
72
+     * @return DataResponse
73
+     */
74
+    public function getConfig() {
75
+        $data = [
76
+            'version' => '1.7',
77
+            'website' => 'Nextcloud',
78
+            'host' => $this->request->getServerHost(),
79
+            'contact' => '',
80
+            'ssl' => 'false',
81
+        ];
82 82
 
83
-		return new DataResponse($data);
84
-	}
83
+        return new DataResponse($data);
84
+    }
85 85
 
86
-	/**
87
-	 * @PublicPage
88
-	 *
89
-	 * @return DataResponse
90
-	 */
91
-	public function getCapabilities() {
92
-		$result = [];
93
-		list($major, $minor, $micro) = \OCP\Util::getVersion();
94
-		$result['version'] = array(
95
-			'major' => $major,
96
-			'minor' => $minor,
97
-			'micro' => $micro,
98
-			'string' => \OC_Util::getVersionString(),
99
-			'edition' => '',
100
-			'extendedSupport' => \OCP\Util::hasExtendedSupport()
101
-		);
86
+    /**
87
+     * @PublicPage
88
+     *
89
+     * @return DataResponse
90
+     */
91
+    public function getCapabilities() {
92
+        $result = [];
93
+        list($major, $minor, $micro) = \OCP\Util::getVersion();
94
+        $result['version'] = array(
95
+            'major' => $major,
96
+            'minor' => $minor,
97
+            'micro' => $micro,
98
+            'string' => \OC_Util::getVersionString(),
99
+            'edition' => '',
100
+            'extendedSupport' => \OCP\Util::hasExtendedSupport()
101
+        );
102 102
 
103
-		if($this->userSession->isLoggedIn()) {
104
-			$result['capabilities'] = $this->capabilitiesManager->getCapabilities();
105
-		} else {
106
-			$result['capabilities'] = $this->capabilitiesManager->getCapabilities(true);
107
-		}
103
+        if($this->userSession->isLoggedIn()) {
104
+            $result['capabilities'] = $this->capabilitiesManager->getCapabilities();
105
+        } else {
106
+            $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true);
107
+        }
108 108
 
109
-		return new DataResponse($result);
110
-	}
109
+        return new DataResponse($result);
110
+    }
111 111
 
112
-	/**
113
-	 * @PublicPage
114
-	 * @BruteForceProtection(action=login)
115
-	 *
116
-	 * @param string $login
117
-	 * @param string $password
118
-	 * @return DataResponse
119
-	 */
120
-	public function personCheck($login = '', $password = '') {
121
-		if ($login !== '' && $password !== '') {
122
-			if ($this->userManager->checkPassword($login, $password)) {
123
-				return new DataResponse([
124
-					'person' => [
125
-						'personid' => $login
126
-					]
127
-				]);
128
-			}
112
+    /**
113
+     * @PublicPage
114
+     * @BruteForceProtection(action=login)
115
+     *
116
+     * @param string $login
117
+     * @param string $password
118
+     * @return DataResponse
119
+     */
120
+    public function personCheck($login = '', $password = '') {
121
+        if ($login !== '' && $password !== '') {
122
+            if ($this->userManager->checkPassword($login, $password)) {
123
+                return new DataResponse([
124
+                    'person' => [
125
+                        'personid' => $login
126
+                    ]
127
+                ]);
128
+            }
129 129
 
130
-			$response = new DataResponse([], 102);
131
-			$response->throttle();
132
-			return $response;
133
-		}
134
-		return new DataResponse([], 101);
135
-	}
130
+            $response = new DataResponse([], 102);
131
+            $response->throttle();
132
+            return $response;
133
+        }
134
+        return new DataResponse([], 101);
135
+    }
136 136
 
137
-	/**
138
-	 * @PublicPage
139
-	 *
140
-	 * @param string $cloudId
141
-	 * @return DataResponse
142
-	 */
143
-	public function getIdentityProof($cloudId) {
144
-		$userObject = $this->userManager->get($cloudId);
137
+    /**
138
+     * @PublicPage
139
+     *
140
+     * @param string $cloudId
141
+     * @return DataResponse
142
+     */
143
+    public function getIdentityProof($cloudId) {
144
+        $userObject = $this->userManager->get($cloudId);
145 145
 
146
-		if($userObject !== null) {
147
-			$key = $this->keyManager->getKey($userObject);
148
-			$data = [
149
-				'public' => $key->getPublic(),
150
-			];
151
-			return new DataResponse($data);
152
-		}
146
+        if($userObject !== null) {
147
+            $key = $this->keyManager->getKey($userObject);
148
+            $data = [
149
+                'public' => $key->getPublic(),
150
+            ];
151
+            return new DataResponse($data);
152
+        }
153 153
 
154
-		return new DataResponse(['User not found'], 404);
155
-	}
154
+        return new DataResponse(['User not found'], 404);
155
+    }
156 156
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 			'extendedSupport' => \OCP\Util::hasExtendedSupport()
101 101
 		);
102 102
 
103
-		if($this->userSession->isLoggedIn()) {
103
+		if ($this->userSession->isLoggedIn()) {
104 104
 			$result['capabilities'] = $this->capabilitiesManager->getCapabilities();
105 105
 		} else {
106 106
 			$result['capabilities'] = $this->capabilitiesManager->getCapabilities(true);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	public function getIdentityProof($cloudId) {
144 144
 		$userObject = $this->userManager->get($cloudId);
145 145
 
146
-		if($userObject !== null) {
146
+		if ($userObject !== null) {
147 147
 			$key = $this->keyManager->getKey($userObject);
148 148
 			$data = [
149 149
 				'public' => $key->getPublic(),
Please login to merge, or discard this patch.
status.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -33,34 +33,34 @@
 block discarded – undo
33 33
 
34 34
 try {
35 35
 
36
-	require_once __DIR__ . '/lib/base.php';
36
+    require_once __DIR__ . '/lib/base.php';
37 37
 
38
-	$systemConfig = \OC::$server->getSystemConfig();
38
+    $systemConfig = \OC::$server->getSystemConfig();
39 39
 
40
-	$installed = (bool) $systemConfig->getValue('installed', false);
41
-	$maintenance = (bool) $systemConfig->getValue('maintenance', false);
42
-	# see core/lib/private/legacy/defaults.php and core/themes/example/defaults.php
43
-	# for description and defaults
44
-	$defaults = new \OCP\Defaults();
45
-	$values = [
46
-		'installed'=>$installed,
47
-		'maintenance' => $maintenance,
48
-		'needsDbUpgrade' => \OCP\Util::needUpgrade(),
49
-		'version'=>implode('.', \OCP\Util::getVersion()),
50
-		'versionstring'=>OC_Util::getVersionString(),
51
-		'edition'=> '',
52
-		'productname'=>$defaults->getName(),
53
-		'extendedSupport' => \OCP\Util::hasExtendedSupport()
54
-	];
55
-	if (OC::$CLI) {
56
-		print_r($values);
57
-	} else {
58
-		header('Access-Control-Allow-Origin: *');
59
-		header('Content-Type: application/json');
60
-		echo json_encode($values);
61
-	}
40
+    $installed = (bool) $systemConfig->getValue('installed', false);
41
+    $maintenance = (bool) $systemConfig->getValue('maintenance', false);
42
+    # see core/lib/private/legacy/defaults.php and core/themes/example/defaults.php
43
+    # for description and defaults
44
+    $defaults = new \OCP\Defaults();
45
+    $values = [
46
+        'installed'=>$installed,
47
+        'maintenance' => $maintenance,
48
+        'needsDbUpgrade' => \OCP\Util::needUpgrade(),
49
+        'version'=>implode('.', \OCP\Util::getVersion()),
50
+        'versionstring'=>OC_Util::getVersionString(),
51
+        'edition'=> '',
52
+        'productname'=>$defaults->getName(),
53
+        'extendedSupport' => \OCP\Util::hasExtendedSupport()
54
+    ];
55
+    if (OC::$CLI) {
56
+        print_r($values);
57
+    } else {
58
+        header('Access-Control-Allow-Origin: *');
59
+        header('Content-Type: application/json');
60
+        echo json_encode($values);
61
+    }
62 62
 
63 63
 } catch (Exception $ex) {
64
-	http_response_code(500);
65
-	\OC::$server->getLogger()->logException($ex, ['app' => 'remote']);
64
+    http_response_code(500);
65
+    \OC::$server->getLogger()->logException($ex, ['app' => 'remote']);
66 66
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@
 block discarded – undo
29 29
  *
30 30
  */
31 31
 
32
-require_once __DIR__ . '/lib/versioncheck.php';
32
+require_once __DIR__.'/lib/versioncheck.php';
33 33
 
34 34
 try {
35 35
 
36
-	require_once __DIR__ . '/lib/base.php';
36
+	require_once __DIR__.'/lib/base.php';
37 37
 
38 38
 	$systemConfig = \OC::$server->getSystemConfig();
39 39
 
Please login to merge, or discard this patch.