Failed Conditions
Branch v2.1.0 (e76e15)
by Sander
07:59
created

templates/part.admin.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/** @var \OCP\IL10N $l */
3
/** @var array $_ */
4
use \OCP\App;
5
6
script('passman', 'settings-admin');
7
8
$checkVersion = OC::$server->getConfig()->getAppValue('passman', 'check_version', '1') === '1';
9
$AppInstance = new App();
10
$localVersion = $AppInstance->getAppInfo("passman")["version"];
11
if ($checkVersion) {
12
	// get latest master version
13
	$version = false;
14
	$githubVersion = $l->t('Unable to get version info');
15
16
	$url = 'https://raw.githubusercontent.com/nextcloud/passman/master/appinfo/info.xml';
17
	try {
18
		$client = OC::$server->getHTTPClientService()->newClient();
19
		$response = $client->get($url);
20
		$xml = $response->getBody();
21
	} catch (\Exception $e) {
22
		$xml = false;
23
	}
24
25
	if ($xml) {
26
		$loadEntities = libxml_disable_entity_loader(true);
27
		$data = @simplexml_load_string($xml);
28
		libxml_disable_entity_loader($loadEntities);
29
		if ($data !== false) {
30
			$version = (string)$data->version;
31
		} else {
32
			libxml_clear_errors();
33
		}
34
	}
35
36
	if ($version) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $version of type string|false is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
37
		$githubVersion = $version;
38
	}
39
}
40
$ciphers = openssl_get_cipher_methods();
41
?>
42
43
<div id="passwordSharingSettings" class="followup section">
44
	<form name="passman_settings">
45
		<h2><?php p($l->t('Passman Settings')); ?></h2>
46
		<?php
47
		if ($checkVersion) {
48
			p($l->t('Github version:') . ' ' . $githubVersion);
49
			print '<br />';
50
		} ?>
51
		Local version: <?php p($localVersion); ?><br/>
52
		<?php
53
		if ($checkVersion && version_compare($githubVersion, $localVersion) === 1) {
54
			p($l->t('A newer version of passman is available'));
55
		}
56
		?>
57
		<h3><?php p($l->t('Sharing')); ?></h3>
58
		<p>
59
			<input type="checkbox" name="passman_link_sharing_enabled"
60
				   id="passman_link_sharing_enabled" class="checkbox"
61
				   value="1"/>
62
			<label for="passman_link_sharing_enabled">
63
				<?php p($l->t('Allow users on this server to share passwords with a link')); ?>
64
			</label>
65
		</p>
66
67
		<p>
68
			<input type="checkbox" name="passman_sharing_enabled"
69
				   id="passman_sharing_enabled" class="checkbox"
70
				   value="1"/>
71
			<label for="passman_sharing_enabled">
72
				<?php p($l->t('Allow users on this server to share passwords with other users')); ?>
73
			</label>
74
		</p>
75
		<h3><?php p($l->t('General')); ?></h3>
76
		<p>
77
			<input type="checkbox" name="check_version"
78
				   id="passman_check_version" class="checkbox"
79
				   value="0"/>
80
			<label for="passman_check_version">
81
				<?php p($l->t('Check for new versions')); ?>
82
			</label>
83
		</p>
84
		<p>
85
			<input type="checkbox" name="https_check"
86
				   id="passman_https_check" class="checkbox"
87
				   value="0"/>
88
			<label for="passman_https_check">
89
				<?php p($l->t('Enable HTTPS check')); ?>
90
			</label>
91
		</p>
92
		<p>
93
			<input type="checkbox" name="disable_contextmenu"
94
				   id="passman_disable_contextmenu" class="checkbox"
95
				   value="0"/>
96
			<label for="passman_disable_contextmenu">
97
				<?php p($l->t('Disable context menu')); ?>
98
			</label>
99
		</p>
100
		<p>
101
			<input type="checkbox" name="passman_disable_debugger"
102
				   id="passman_disable_debugger" class="checkbox"
103
				   value="0"/>
104
			<label for="passman_disable_debugger">
105
				<?php p($l->t('Disable javascript debugger')); ?>
106
			</label>
107
		</p>
108
		<p>
109
			<label for="vault_key_strength">Minimum vault key strength:</label>
110
			<select name="vault_key_strength" id="vault_key_strength">
111
				<option value="0">
112
					Poor
113
				</option>
114
				<option value="2">
115
					Weak
116
				</option>
117
				<option value="3">
118
					Good
119
				</option>
120
				<option value="4">
121
					Strong
122
				</option>
123
			</select>
124
		</p>
125
	</form>
126
</div>
127