Completed
Push — stable8 ( f0fddd...5d5dda )
by
unknown
27:14
created

checksetup.php ➔ isUrandomAvailable()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 3
eloc 7
nc 3
nop 0
dl 0
loc 10
rs 9.4285
1
<?php
2
/**
3
 * Copyright (c) 2014, Vincent Petry <[email protected]>
4
 * This file is licensed under the Affero General Public License version 3 or later.
5
 * See the COPYING-README file.
6
 */
7
8
OCP\JSON::checkAdminUser();
9
OCP\JSON::callCheck();
10
11
\OC::$server->getSession()->close();
12
13
/**
14
 * Whether /dev/urandom is available to the PHP controller
15
 *
16
 * @return bool
17
 */
18
function isUrandomAvailable() {
19
	if(@file_exists('/dev/urandom')) {
20
		$file = fopen('/dev/urandom', 'rb');
21
		if($file) {
22
			fclose($file);
23
			return true;
24
		}
25
	}
26
	return false;
27
}
28
29
// no warning when has_internet_connection is false in the config
30
$hasInternet = true;
31
if (OC_Util::isInternetConnectionEnabled()) {
32
	$hasInternet = OC_Util::isInternetConnectionWorking();
33
}
34
35
OCP\JSON::success(
36
	array (
37
		'serverHasInternetConnection' => $hasInternet,
38
		'dataDirectoryProtected' => OC_Util::isHtaccessWorking(),
39
		'hasCurlInstalled' => function_exists('curl_init'),
40
		'isUrandomAvailable' => isUrandomAvailable(),
41
		'securityDocs' => \OC::$server->getURLGenerator()->linkToDocs('admin-security'),
42
	)
43
);
44