forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_user.php
More file actions
293 lines (288 loc) · 15.8 KB
/
edit_user.php
File metadata and controls
293 lines (288 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!-- Begin toolbar -->
<div class="toolbar">
<div class="toolbar-inner">
<div class="toolbar-buttons">
<a class="button button-secondary" id="btn-back" href="/list/user/"><i class="fas fa-arrow-left status-icon blue"></i><?=_('Back');?></a>
<?php
if (($_SESSION['userContext'] === 'admin') && (!isset($_SESSION['look'])) && ($_SESSION['user'] !== $v_username)) {
$ssh_key_url = "/list/key/?user=".htmlentities($user_plain)."&token=".$_SESSION['token']."";
$log_url = "/list/log/?user=".htmlentities($user_plain)."&token=".$_SESSION['token']."";
$keys_url = "/list/access-key/?user=".htmlentities($user_plain)."&token=".$_SESSION['token']."";
} else {
$ssh_key_url = "/list/key/";
$log_url = "/list/log/";
$keys_url = "/list/access-key/";
}
?>
<a href="<?=$ssh_key_url; ?>" class="button button-secondary" id="btn-create" title="<?=_('Manage SSH keys');?>"><i class="fas fa-key status-icon orange"></i><?=_('Manage SSH keys');?></a>
<?php if (($_SESSION['userContext'] == 'admin') || ($_SESSION['userContext'] !== 'admin') && ($_SESSION['POLICY_USER_VIEW_LOGS'] !== 'no')) {?>
<a href="<?=$log_url; ?>" class="button button-secondary" id="btn-create" title="<?=_('Logs');?>"><i class="fas fa-clock-rotate-left status-icon maroon"></i><?=_('Logs');?></a>
<?php } ?>
<?php
$api_status = (!empty($_SESSION['API_SYSTEM']) && is_numeric($_SESSION['API_SYSTEM'])) ? $_SESSION['API_SYSTEM'] : 0;
if (($user_plain == 'admin' && $api_status > 0) || ($user_plain != 'admin' && $api_status > 1)) { ?>
<a href="<?=$keys_url; ?>" class="button button-secondary" id="btn-create" title="<?=_('Access Keys');?>"><i class="fas fa-key status-icon purple"></i><?=_('Access Keys');?></a>
<?php } ?>
</div>
<div class="toolbar-buttons">
<?php if (($_SESSION['user'] == $v_username) || (isset($_SESSION['look']))) {?>
<!-- Do not show delete button for currently logged in user-->
<?} else {?>
<a href="/login/?loginas=<?=htmlentities($v_username)?>&token=<?=$_SESSION['token']?>" class="button button-secondary" id="btn-create" title="<?=_('login as');?>"><i class="fas fa-right-to-bracket status-icon maroon"></i><?=_('login as');?></a>
<a class="data-controls do_delete button button-secondary button-danger">
<i class="do_delete fas fa-circle-xmark status-icon red"></i>
<?=_('Delete');?>
<input type="hidden" name="delete_url" value="/delete/user/?user=<?=htmlentities($v_username)?>&token=<?=$_SESSION['token']?>">
<div class="dialog js-confirm-dialog-delete" title="<?=_('Confirmation');?>">
<p><?=sprintf(_('DELETE_USER_CONFIRMATION'),htmlentities($v_username))?></p>
</div>
</a>
<?php } ?>
<a href="#" class="button" data-action="submit" data-id="vstobjects"><i class="fas fa-floppy-disk status-icon purple"></i> <?=_('Save');?></a>
</div>
</div>
</div>
<!-- End toolbar -->
<div class="l-center animate__animated animate__fadeIn">
<form id="vstobjects" method="post" name="v_edit_user" class="<?=$v_status?>">
<input type="hidden" name="token" value="<?=$_SESSION['token']?>">
<input type="hidden" name="save" value="save">
<div class="form-container">
<h1 class="form-title"><?=_('Editing User');?></h1>
<?php show_alert_message($_SESSION);?>
<div class="u-mb10">
<label for="v_user" class="form-label"><?=_('Username');?></label>
<input type="text" class="form-control" name="v_user" id="v_user" value="<?=htmlentities(trim($v_username, "'"))?>" disabled>
<input type="hidden" name="v_username" value="<?=htmlentities(trim($v_username, "'"))?>">
</div>
<div class="u-mb10">
<label for="v_name" class="form-label"><?=_('Contact');?></label>
<input type="text" class="form-control" name="v_name" id="v_name" value="<?=htmlentities(trim($v_name, "'"))?>" <?php if (($_SESSION['userContext'] !=='admin' ) && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !=='yes' )) { echo 'disabled' ; }?> >
<?php if (($_SESSION['userContext'] !== 'admin') && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !== 'yes')) {?>
<input type="hidden" name="v_name" value="<?=htmlentities(trim($v_name, "'"))?>">
<?php } ?>
</div>
<div class="u-mb10">
<label for="v_email" class="form-label"><?=_('Email');?></label>
<input type="email" class="form-control" name="v_email" id="v_email" value="<?=htmlentities(trim($v_email, "'"))?>" <?php if (($_SESSION['userContext'] !=='admin' ) && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !=='yes' )) { echo 'disabled' ; }?>>
<?php if (($_SESSION['userContext'] !== 'admin') && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !== 'yes')) {?>
<input type="hidden" name="v_email" value="<?=htmlentities(trim($v_email, "'"))?>">
<?php } ?>
</div>
<div class="u-mb10">
<label for="v_password" class="form-label">
<?=_('Password');?>
<a href="javascript:applyRandomString();" title="<?=_('generate');?>" class="u-ml5"><i class="fas fa-arrows-rotate status-icon green icon-large"></i></a>
</label>
<div class="u-pos-relative u-mb10">
<input type="text" class="form-control js-password-input" name="v_password" id="v_password" value="<?=htmlentities(trim($v_password, "'"))?>">
<meter max="4" class="password-meter"></meter>
</div>
</div>
<div id="password-details" class="u-mb20">
<p class="u-mb10"><?=_('Your password must have at least');?>:</p>
<ul class="u-list-bulleted u-mb10">
<li><?=_('8 characters long');?></li>
<li><?=_('1 uppercase & 1 lowercase character');?></li>
<li><?=_('1 number');?></li>
</ul>
<?php if ($_SESSION['userContext'] === 'admin') {?>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="v_login_disabled" id="v_login_disabled" onclick="javascript:elementHideShow('password-options');elementHideShow('password-options-ip');" <?php if ($v_login_disabled === "yes") echo 'checked' ?>>
<label for="v_login_disabled">
<?=_('Do not allow user to log in to Control Panel');?>
</label>
</div>
<?php } ?>
<div id="password-options" style="<?php if ($v_login_disabled === 'yes') { echo 'display: none;'; } else { echo 'display: block;'; }?>">
<div class="form-check u-mt15">
<input class="form-check-input" type="checkbox" name="v_twofa" id="v_twofa" <?php if(!empty($v_twofa)) echo 'checked' ?>>
<label for="v_twofa">
<?=_('Enable 2FA');?>
</label>
</div>
<?php if (!empty($v_twofa)) { ?>
<p class="u-mb10"><?=_('2FA Reset Code:').' '.$v_twofa; ?></p>
<p class="u-mb10"><?=_('Please scan the code below in your 2FA application:');?></p>
<div><img class="qr-code" src="<?=htmlentities($v_qrcode); ?>" alt=""></div>
<?php } ?>
</div>
<div id="password-options-ip" style="<?php if ($v_login_disabled === 'yes') { echo 'display: none;'; } else { echo 'display: block;'; }?>">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="v_login_use_iplist" id="v_login_use_iplist" onclick="javascript:elementHideShow('ip-allowlist')" <?php if ($v_login_use_iplist === "yes") echo 'checked' ?>>
<label for="v_login_use_iplist">
<?=_('Use IP address allow list for login attempts');?>
</label>
</div>
</div>
<div id="ip-allowlist" class="u-mt10" style="<?php if ($v_login_use_iplist === 'yes') { echo 'display: block;'; } else { echo 'display: none;'; } ?>">
<input type="text" class="form-control" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>" placeholder="<?=_('Example: 127.0.0.1,192.168.1.100');?>">
</div>
</div>
<div class="u-mb10">
<label for="v_language" class="form-label"><?=_('Language');?></label>
<select class="form-select" name="v_language" id="v_language">
<?php
foreach ($languages as $key => $value) {
echo "\n\t\t\t\t\t\t\t\t\t<option value=\"".$key."\"";
$skey = "'".$key."'";
if (( $key == $v_language ) || ( $skey == $v_language)){
echo 'selected' ;
}
if (( $key == detect_user_language() ) && (empty($v_language))){
echo 'selected' ;
}
echo ">".htmlentities($value)."</option>\n";
}
?>
</select>
</div>
<?php if ($v_username == 'admin') {?>
<!-- Hide option to change 'admin' user's role-->
<?php } else { ?>
<?php if (($_SESSION['userContext'] === 'admin') && ($_SESSION['user'] != $v_username)) {?>
<div class="u-mb10">
<label for="v_role" class="form-label"><?=_('Role');?></label>
<select class="form-select" name="v_role" id="v_role">
<option value="user"><?=_('User');?>
<option value="admin" <?php if($v_role == "admin" ){ echo "selected"; } ?>><?=_('Administrator');?>
<option value="dns-cluster" <?php if($v_role == "dns-cluster" ){ echo "selected"; } ?>><?=_('DNS Sync user');?>
</select>
</div>
<?php } ?>
<?php } ?>
<?php if ($_SESSION['POLICY_USER_CHANGE_THEME'] !== 'no') {?>
<div class="u-mb10">
<label for="v_user_theme" class="form-label"><?=_('Theme') ?></label>
<select class="form-select" name="v_user_theme" id="v_user_theme">
<?php
foreach ($themes as $key => $value) {
echo "\t\t\t\t<option value=\"".$value."\"";
if ((!empty($_SESSION['userTheme'])) && ( $value == $v_user_theme )) {
echo ' selected' ;
}
if ((empty($v_user_theme) && (!empty($_SESSION['THEME']))) && ( $value == $_SESSION['THEME'] )) {
echo ' selected' ;
}
echo ">".$value."</option>\n";
}
?>
</select>
</div>
<?php } ?>
<div class="u-mb10">
<label for="v_sort_order" class="form-label"><?=_('Default list sort order');?></label>
<select class="form-select" name="v_sort_order" id="v_sort_order">
<option value='date' <?php if($v_sort_order === 'date') echo 'selected' ?>><?=_('Date');?></option>
<option value='name' <?php if($v_sort_order === 'name') echo 'selected' ?>><?=_('Name');?></option>
</select>
</div>
<?php if ($_SESSION['userContext'] === 'admin') {?>
<div class="u-mb20">
<label for="v_package" class="form-label"><?=_('Package');?></label>
<select class="form-select" name="v_package" id="v_package">
<?php
foreach ($packages as $key => $value) {
echo "\n\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($key)."\"";
$skey = "'".$key."'";
if (( $key == $v_package ) || ( $skey == $v_package)){
echo 'selected' ;
}
echo ">".htmlentities($key)."</option>\n";
}
?>
</select>
</div>
<div class="u-mb20">
<a href="javascript:elementHideShow('advanced-opts');" class="button button-secondary"><?=_('Advanced options');?></a>
</div>
<div id="advanced-opts" style="display: none;">
<div class="u-mb10">
<label for="v_shell" class="form-label"><?=_('SSH Access');?></label>
<select class="form-select" name="v_shell" id="v_shell">
<?php
foreach ($shells as $key => $value) {
echo "\t\t\t\t<option value=\"".htmlentities($value)."\"";
$svalue = "'".$value."'";
if (( $value == $v_shell ) || ($svalue == $v_shell )){
echo 'selected' ;
}
echo ">".htmlentities($value)."</option>\n";
}
?>
</select>
</div>
<div class="u-mb10">
<label for="v_phpcli" class="form-label"><?=_('PHP CLI Version');?></label>
<select class="form-select" name="v_phpcli" id="v_phpcli">
<?php
foreach ($php_versions as $key => $value) {
$php = explode('-',$value);
echo "\t\t\t\t<option value=\"".$value."\"";
$svalue = "'".$value."'";
if ((!empty($v_phpcli)) && ( $value == $v_phpcli ) || ($svalue == $v_phpcli)){
echo ' selected' ;
}
if ((empty($v_phpcli)) && ($value == DEFAULT_PHP_VERSION)){
echo ' selected' ;
}
echo ">".htmlentities($value)."</option>\n";
}
?>
</select>
</div>
<?php if ((isset($_SESSION['DNS_SYSTEM'])) && (!empty($_SESSION['DNS_SYSTEM']))) {?>
<p class="form-label u-mb10"><?=_('Default Name Servers');?></p>
<div class="u-mb5">
<input type="text" class="form-control" name="v_ns1" value="<?=htmlentities(trim($v_ns1, "'"))?>">
</div>
<div class="u-mb5">
<input type="text" class="form-control" name="v_ns2" value="<?=htmlentities(trim($v_ns2, "'"))?>">
</div>
<?php
if($v_ns3) {
echo '<div class="u-side-by-side u-mb5">
<input type="text" class="form-control" name="v_ns3" value="'.htmlentities(trim($v_ns3, "'")).'">
<span class="js-remove-ns u-ml10"><i class="fas fa-trash status-icon dim red"></i></span>
</div>';
}
if($v_ns4) {
echo '<div class="u-side-by-side u-mb5">
<input type="text" class="form-control" name="v_ns4" value="'.htmlentities(trim($v_ns4, "'")).'">
<span class="js-remove-ns u-ml10"><i class="fas fa-trash status-icon dim red"></i></span>
</div>';
}
if($v_ns5) {
echo '<div class="u-side-by-side u-mb5">
<input type="text" class="form-control" name="v_ns5" value="'.htmlentities(trim($v_ns5, "'")).'">
<span class="js-remove-ns u-ml10"><i class="fas fa-trash status-icon dim red"></i></span>
</div>';
}
if($v_ns6) {
echo '<div class="u-side-by-side u-mb5">
<input type="text" class="form-control" name="v_ns6" value="'.htmlentities(trim($v_ns6, "'")).'">
<span class="js-remove-ns u-ml10"><i class="fas fa-trash status-icon dim red"></i></span>
</div>';
}
if($v_ns7) {
echo '<div class="u-side-by-side u-mb5">
<input type="text" class="form-control" name="v_ns7" value="'.htmlentities(trim($v_ns7, "'")).'">
<span class="js-remove-ns u-ml10"><i class="fas fa-trash status-icon dim red"></i></span>
</div>';
}
if($v_ns8) {
echo '<div class="u-side-by-side u-mb5">
<input type="text" class="form-control" name="v_ns8" value="'.htmlentities(trim($v_ns8, "'")).'">
<span class="js-remove-ns u-ml10"><i class="fas fa-trash status-icon dim red"></i></span>
</div>';
}
?>
<div class="u-pt18 js-add-ns" <?php if ($v_ns8) echo 'style="display:none;"'; ?>>
<span class="js-add-ns-button additional-control add"><?=_('Add one more Name Server');?></span>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</form>
</div>