Project

General

Profile

Download (35.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_usermanager.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	part of pfSense
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	All rights reserved.
10

    
11
	Copyright (C) 2008 Shrew Soft Inc.
12
	All rights reserved.
13

    
14
	Copyright (C) 2005 Paul Taylor <paultaylor@winn-dixie.com>.
15
	All rights reserved.
16

    
17
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
18
	All rights reserved.
19

    
20
	Redistribution and use in source and binary forms, with or without
21
	modification, are permitted provided that the following conditions are met:
22

    
23
	1. Redistributions of source code must retain the above copyright notice,
24
	   this list of conditions and the following disclaimer.
25

    
26
	2. Redistributions in binary form must reproduce the above copyright
27
	   notice, this list of conditions and the following disclaimer in the
28
	   documentation and/or other materials provided with the distribution.
29

    
30
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
31
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
32
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
34
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39
	POSSIBILITY OF SUCH DAMAGE.
40
*/
41
/*
42
	pfSense_BUILDER_BINARIES:
43
	pfSense_MODULE:	auth
44
*/
45

    
46
##|+PRIV
47
##|*IDENT=page-system-usermanager
48
##|*NAME=System: User Manager page
49
##|*DESCR=Allow access to the 'System: User Manager' page.
50
##|*MATCH=system_usermanager.php*
51
##|-PRIV
52

    
53
require("certs.inc");
54
require("guiconfig.inc");
55

    
56

    
57
// start admin user code
58
$pgtitle = array(gettext("System"),gettext("User Manager"));
59

    
60
if (isset($_POST['userid']) && is_numericint($_POST['userid']))
61
	$id = $_POST['userid'];
62

    
63
if (!isset($config['system']['user']) || !is_array($config['system']['user']))
64
	$config['system']['user'] = array();
65

    
66
$a_user = &$config['system']['user'];
67

    
68
if (isset($_SERVER['HTTP_REFERER']))
69
	$referer = $_SERVER['HTTP_REFERER'];
70
else
71
	$referer = '/system_usermanager.php';
72

    
73
if (isset($id) && $a_user[$id]) {
74
	$pconfig['usernamefld'] = $a_user[$id]['name'];
75
	$pconfig['descr'] = $a_user[$id]['descr'];
76
	$pconfig['expires'] = $a_user[$id]['expires'];
77
	$pconfig['groups'] = local_user_get_groups($a_user[$id]);
78
	$pconfig['utype'] = $a_user[$id]['scope'];
79
	$pconfig['uid'] = $a_user[$id]['uid'];
80
	$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
81
	$pconfig['priv'] = $a_user[$id]['priv'];
82
	$pconfig['ipsecpsk'] = $a_user[$id]['ipsecpsk'];
83
	$pconfig['disabled'] = isset($a_user[$id]['disabled']);
84
}
85

    
86
if ($_POST['act'] == "deluser") {
87

    
88
	if (!isset($_POST['username']) || !isset($a_user[$id]) || ($_POST['username'] != $a_user[$id]['name'])) {
89
		pfSenseHeader("system_usermanager.php");
90
		exit;
91
	}
92

    
93
	$saved_username = $a_user[$id]['name'];
94

    
95
	if ($a_user[$id]['scope'] != "system") {
96
		conf_mount_rw();
97
		local_user_del($a_user[$id]);
98
		conf_mount_ro();
99
		unset($a_user[$id]);
100
		write_config();
101
		$savemsg = gettext("User") . " {$saved_username} " .
102
				gettext("successfully deleted") . "<br />";
103
	} else {
104
		unset($id);
105
		unset($deletion_errors);
106
		$deletion_errors[] = gettext("User") . " {$saved_username} " .
107
				gettext("is a system user. Deletion is not allowed.");
108
	}
109
}
110
else if ($_POST['act'] == "delpriv") {
111

    
112
	if (!$a_user[$id]) {
113
		pfSenseHeader("system_usermanager.php");
114
		exit;
115
	}
116

    
117
	$privdeleted = $priv_list[$a_user[$id]['priv'][$_POST['privid']]]['name'];
118
	unset($a_user[$id]['priv'][$_POST['privid']]);
119
	local_user_set($a_user[$id]);
120
	write_config();
121
	$_POST['act'] = "edit";
122
	$savemsg = gettext("Privilege")." {$privdeleted} ".
123
				gettext("successfully deleted")."<br />";
124
}
125
else if ($_POST['act'] == "expcert") {
126

    
127
	if (!$a_user[$id]) {
128
		pfSenseHeader("system_usermanager.php");
129
		exit;
130
	}
131

    
132
	$cert =& lookup_cert($a_user[$id]['cert'][$_POST['certid']]);
133

    
134
	$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.crt");
135
	$exp_data = base64_decode($cert['crt']);
136
	$exp_size = strlen($exp_data);
137

    
138
	header("Content-Type: application/octet-stream");
139
	header("Content-Disposition: attachment; filename={$exp_name}");
140
	header("Content-Length: $exp_size");
141
	echo $exp_data;
142
	exit;
143
}
144
else if ($_POST['act'] == "expckey") {
145

    
146
	if (!$a_user[$id]) {
147
		pfSenseHeader("system_usermanager.php");
148
		exit;
149
	}
150

    
151
	$cert =& lookup_cert($a_user[$id]['cert'][$_POST['certid']]);
152

    
153
	$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.key");
154
	$exp_data = base64_decode($cert['prv']);
155
	$exp_size = strlen($exp_data);
156

    
157
	header("Content-Type: application/octet-stream");
158
	header("Content-Disposition: attachment; filename={$exp_name}");
159
	header("Content-Length: $exp_size");
160
	echo $exp_data;
161
	exit;
162
}
163
else if ($_POST['act'] == "delcert") {
164

    
165
	if (!$a_user[$id]) {
166
		pfSenseHeader("system_usermanager.php");
167
		exit;
168
	}
169

    
170
	$certdeleted = lookup_cert($a_user[$id]['cert'][$_POST['certid']]);
171
	$certdeleted = $certdeleted['descr'];
172
	unset($a_user[$id]['cert'][$_POST['certid']]);
173
	write_config();
174
	$_POST['act'] = "edit";
175
	$savemsg = gettext("Certificate")." {$certdeleted} ".
176
				gettext("association removed.")."<br />";
177
}
178
else if ($_POST['act'] == "new") {
179
	/*
180
	 * set this value cause the text field is read only
181
	 * and the user should not be able to mess with this
182
	 * setting.
183
	 */
184
	$pconfig['utype'] = "user";
185
	$pconfig['lifetime'] = 3650;
186
}
187

    
188
if(isset($_POST['dellall_x'])) {
189

    
190
	$del_users = $_POST['delete_check'];
191

    
192
	if(!empty($del_users)) {
193
		foreach($del_users as $userid) {
194
			if (isset($a_user[$userid]) && $a_user[$userid]['scope'] != "system") {
195
				conf_mount_rw();
196
				local_user_del($a_user[$userid]);
197
				conf_mount_ro();
198
				unset($a_user[$userid]);
199
			}
200
		}
201
		$savemsg = gettext("Selected users removed successfully!");
202
		write_config($savemsg);
203
	}
204
}
205

    
206
if ($_POST['save']) {
207
	unset($input_errors);
208
	$pconfig = $_POST;
209

    
210
	/* input validation */
211
	if (isset($id) && ($a_user[$id])) {
212
		$reqdfields = explode(" ", "usernamefld");
213
		$reqdfieldsn = array(gettext("Username"));
214
	} else {
215
		if (empty($_POST['name'])) {
216
			$reqdfields = explode(" ", "usernamefld passwordfld1");
217
			$reqdfieldsn = array(
218
				gettext("Username"),
219
				gettext("Password"));
220
		} else {
221
			$reqdfields = explode(" ", "usernamefld passwordfld1 name caref keylen lifetime");
222
			$reqdfieldsn = array(
223
				gettext("Username"),
224
				gettext("Password"),
225
				gettext("Descriptive name"),
226
				gettext("Certificate authority"),
227
				gettext("Key length"),
228
				gettext("Lifetime"));
229
		}
230
	}
231

    
232
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
233

    
234
	if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld']))
235
		$input_errors[] = gettext("The username contains invalid characters.");
236

    
237
	if (strlen($_POST['usernamefld']) > 16)
238
		$input_errors[] = gettext("The username is longer than 16 characters.");
239

    
240
	if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
241
		$input_errors[] = gettext("The passwords do not match.");
242

    
243
	if (isset($_POST['ipsecpsk']) && !preg_match('/^[[:ascii:]]*$/', $_POST['ipsecpsk']))
244
		$input_errors[] = gettext("IPsec Pre-Shared Key contains invalid characters.");
245

    
246
	if (isset($id) && $a_user[$id])
247
		$oldusername = $a_user[$id]['name'];
248
	else
249
		$oldusername = "";
250
	/* make sure this user name is unique */
251
	if (!$input_errors) {
252
		foreach ($a_user as $userent) {
253
			if ($userent['name'] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
254
				$input_errors[] = gettext("Another entry with the same username already exists.");
255
				break;
256
			}
257
		}
258
	}
259
	/* also make sure it is not reserved */
260
	if (!$input_errors) {
261
		$system_users = explode("\n", file_get_contents("/etc/passwd"));
262
		foreach ($system_users as $s_user) {
263
			$ent = explode(":", $s_user);
264
			if ($ent[0] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
265
				$input_errors[] = gettext("That username is reserved by the system.");
266
				break;
267
			}
268
		}
269
	}
270

    
271
	/*
272
	 * Check for a valid expiration date if one is set at all (valid means,
273
	 * DateTime puts out a time stamp so any DateTime compatible time
274
	 * format may be used. to keep it simple for the enduser, we only
275
	 * claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
276
	 * like "+1 day", which will be converted to MM/DD/YYYY based on "now".
277
	 * Otherwise such an entry would lead to an invalid expiration data.
278
	 */
279
	if ($_POST['expires']){
280
		try {
281
			$expdate = new DateTime($_POST['expires']);
282
			//convert from any DateTime compatible date to MM/DD/YYYY
283
			$_POST['expires'] = $expdate->format("m/d/Y");
284
		} catch ( Exception $ex ) {
285
			$input_errors[] = gettext("Invalid expiration date format; use MM/DD/YYYY instead.");
286
		}
287
	}
288

    
289
	if (!empty($_POST['name'])) {
290
		$ca = lookup_ca($_POST['caref']);
291
		if (!$ca)
292
			$input_errors[] = gettext("Invalid internal Certificate Authority") . "\n";
293
	}
294

    
295
	/* if this is an AJAX caller then handle via JSON */
296
	if (isAjax() && is_array($input_errors)) {
297
		input_errors2Ajax($input_errors);
298
		exit;
299
	}
300

    
301
	if (!$input_errors) {
302
		conf_mount_rw();
303
		$userent = array();
304
		if (isset($id) && $a_user[$id])
305
			$userent = $a_user[$id];
306

    
307
		isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system";
308

    
309
		/* the user name was modified */
310
		if (!empty($_POST['oldusername']) && ($_POST['usernamefld'] <> $_POST['oldusername'])) {
311
			$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
312
			local_user_del($userent);
313
		}
314

    
315
		/* the user password was modified */
316
		if ($_POST['passwordfld1'])
317
			local_user_set_password($userent, $_POST['passwordfld1']);
318

    
319
		$userent['name'] = $_POST['usernamefld'];
320
		$userent['descr'] = $_POST['descr'];
321
		$userent['expires'] = $_POST['expires'];
322
		$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
323
		$userent['ipsecpsk'] = $_POST['ipsecpsk'];
324

    
325
		if($_POST['disabled'])
326
			$userent['disabled'] = true;
327
		else
328
			unset($userent['disabled']);
329

    
330
		if (isset($id) && $a_user[$id])
331
			$a_user[$id] = $userent;
332
		else {
333
			if (!empty($_POST['name'])) {
334
				$cert = array();
335
				$cert['refid'] = uniqid();
336
				$userent['cert'] = array();
337

    
338
				$cert['descr'] = $_POST['name'];
339

    
340
				$subject = cert_get_subject_array($ca['crt']);
341

    
342
				$dn = array(
343
					'countryName' => $subject[0]['v'],
344
					'stateOrProvinceName' => $subject[1]['v'],
345
					'localityName' => $subject[2]['v'],
346
					'organizationName' => $subject[3]['v'],
347
					'emailAddress' => $subject[4]['v'],
348
					'commonName' => $userent['name']);
349

    
350
				cert_create($cert, $_POST['caref'], $_POST['keylen'],
351
					(int)$_POST['lifetime'], $dn);
352

    
353
				if (!is_array($config['cert']))
354
					$config['cert'] = array();
355
				$config['cert'][] = $cert;
356
				$userent['cert'][] = $cert['refid'];
357
			}
358
			$userent['uid'] = $config['system']['nextuid']++;
359
			/* Add the user to All Users group. */
360
			foreach ($config['system']['group'] as $gidx => $group) {
361
				if ($group['name'] == "all") {
362
					if (!is_array($config['system']['group'][$gidx]['member']))
363
						$config['system']['group'][$gidx]['member'] = array();
364
					$config['system']['group'][$gidx]['member'][] = $userent['uid'];
365
					break;
366
				}
367
			}
368

    
369
			$a_user[] = $userent;
370
		}
371

    
372
		/* Add user to groups so PHP can see the memberships properly or else the user's shell account does not get proper permissions (if applicable) See #5152. */
373
		local_user_set_groups($userent,$_POST['groups']);
374
		local_user_set($userent);
375
		/* Add user to groups again to ensure they are set everywhere, otherwise the user may not appear to be a member of the group. See commit:5372d26d9d25d751d16865ed9d46869d3b0ec5e1. */
376
		local_user_set_groups($userent,$_POST['groups']);
377
		write_config();
378

    
379
		if(is_dir("/etc/inc/privhooks"))
380
			run_plugins("/etc/inc/privhooks");
381

    
382
		conf_mount_ro();
383

    
384
		pfSenseHeader("system_usermanager.php");
385
	}
386
}
387

    
388
$closehead = false;
389
include("head.inc");
390
?>
391

    
392
<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
393
<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui-1.11.1.css" />
394

    
395
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
396
<script type="text/javascript">
397
//<![CDATA[
398
	jQuery(function() {
399
		jQuery( "#expires" ).datepicker( { dateFormat: 'mm/dd/yy', changeYear: true, yearRange: "+0:+100" } );
400
	});
401
//]]>
402
</script>
403
</head>
404

    
405
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
406
<?php include("fbegin.inc"); ?>
407

    
408
<script type="text/javascript">
409
//<![CDATA[
410

    
411
function setall_selected(id) {
412
	selbox = document.getElementById(id);
413
	count = selbox.options.length;
414
	for (index = 0; index<count; index++)
415
		selbox.options[index].selected = true;
416
}
417

    
418
function delete_empty(id) {
419
	selbox = document.getElementById(id);
420
	count = selbox.options.length;
421
	for (index = 0; index<count; index++)
422
		if (selbox.options[index].value == '')
423
			selbox.remove(index);
424
}
425

    
426
function clear_selected(id) {
427
	selbox = document.getElementById(id);
428
	count = selbox.options.length;
429
	for (index = 0; index<count; index++)
430
		selbox.options[index].selected = false;
431
}
432

    
433
function remove_selected(id) {
434
	selbox = document.getElementById(id);
435
	index = selbox.options.length - 1;
436
	for (; index >= 0; index--)
437
		if (selbox.options[index].selected)
438
			selbox.remove(index);
439
}
440

    
441
function copy_selected(srcid, dstid) {
442
	src_selbox = document.getElementById(srcid);
443
	dst_selbox = document.getElementById(dstid);
444
	count = dst_selbox.options.length;
445
	for (index = count - 1; index >= 0; index--) {
446
		if (dst_selbox.options[index].value == '') {
447
			dst_selbox.remove(index);
448
		}
449
	}
450
	count = src_selbox.options.length;
451
	for (index = 0; index < count; index++) {
452
		if (src_selbox.options[index].selected) {
453
			option = document.createElement('option');
454
			option.text = src_selbox.options[index].text;
455
			option.value = src_selbox.options[index].value;
456
			dst_selbox.add(option, null);
457
		}
458
	}
459
}
460

    
461
function move_selected(srcid, dstid) {
462
	copy_selected(srcid, dstid);
463
	remove_selected(srcid);
464
}
465

    
466
function presubmit() {
467
	delete_empty('groups');
468
	delete_empty('notgroups');
469
	clear_selected('notgroups');
470
	setall_selected('groups');
471
}
472

    
473
function usercertClicked(obj) {
474
	if (obj.checked) {
475
		document.getElementById("usercertchck").style.display="none";
476
		document.getElementById("usercert").style.display="";
477
	} else {
478
		document.getElementById("usercert").style.display="none";
479
		document.getElementById("usercertchck").style.display="";
480
	}
481
}
482

    
483
function sshkeyClicked(obj) {
484
	if (obj.checked) {
485
		document.getElementById("sshkeychck").style.display="none";
486
		document.getElementById("sshkey").style.display="";
487
	} else {
488
		document.getElementById("sshkey").style.display="none";
489
		document.getElementById("sshkeychck").style.display="";
490
	}
491
}
492
//]]>
493
</script>
494
<?php
495
	if ($input_errors)
496
		print_input_errors($input_errors);
497
	if ($deletion_errors)
498
		print_input_errors($deletion_errors);
499
	if ($savemsg)
500
		print_info_box($savemsg);
501
?>
502
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="user manager">
503
	<tr>
504
		<td>
505
<?php
506
			$tab_array = array();
507
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
508
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
509
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
510
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
511
			display_top_tabs($tab_array);
512
?>
513
		</td>
514
	</tr>
515
	<tr>
516
		<td id="mainarea">
517
			<div class="tabcont">
518
<?php
519
			if ($_POST['act'] == "new" || $_POST['act'] == "edit" || $input_errors):
520
?>
521
				<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
522
					<input type="hidden" id="act" name="act" value="" />
523
					<input type="hidden" id="userid" name="userid" value="<?=(isset($id) ? $id : '');?>" />
524
					<input type="hidden" id="privid" name="privid" value="" />
525
					<input type="hidden" id="certid" name="certid" value="" />
526
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
527
<?php
528
						$ro = "";
529
						if ($pconfig['utype'] == "system")
530
							$ro = "readonly=\"readonly\"";
531
?>
532
						<tr>
533
							<td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
534
							<td width="78%" class="vtable">
535
								<strong><?=strtoupper(htmlspecialchars($pconfig['utype']));?></strong>
536
								<input name="utype" type="hidden" value="<?=htmlspecialchars($pconfig['utype'])?>" />
537
							</td>
538
						</tr>
539
						<tr>
540
							<td width="22%" valign="top" class="vncell"><?=gettext("Disabled");?></td>
541
							<td width="78%" class="vtable">
542
								<input name="disabled" type="checkbox" id="disabled" <?php if($pconfig['disabled']) echo "checked=\"checked\""; ?> />
543
							</td>
544
						</tr>
545
						<tr>
546
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
547
							<td width="78%" class="vtable">
548
								<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" maxlength="16" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?> />
549
								<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
550
							</td>
551
						</tr>
552
						<tr>
553
							<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
554
							<td width="78%" class="vtable">
555
								<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
556
							</td>
557
						</tr>
558
						<tr>
559
							<td width="78%" class="vtable">
560
								<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
561
							</td>
562
						</tr>
563
						<tr>
564
							<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
565
							<td width="78%" class="vtable">
566
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>" <?=$ro;?> />
567
								<br />
568
								<?=gettext("User's full name, for your own information only");?>
569
							</td>
570
						</tr>
571
						<tr>
572
							<td width="22%" valign="top" class="vncell"><?=gettext("Expiration date"); ?></td>
573
							<td width="78%" class="vtable">
574
								<input name="expires" type="text" class="formfld unknown" id="expires" size="10" value="<?=htmlspecialchars($pconfig['expires']);?>" />
575
								<br />
576
								<span class="vexpl"><?=gettext("Leave blank if the account shouldn't expire, otherwise enter the expiration date in the following format: mm/dd/yyyy"); ?></span></td>
577
						</tr>
578
						<tr>
579
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
580
							<td width="78%" class="vtable" align="center">
581
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="group membership">
582
									<tr>
583
										<td align="center" width="50%">
584
											<strong><?=gettext("Not Member Of"); ?></strong><br />
585
											<br />
586
											<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onchange="clear_selected('groups')" multiple="multiple">
587
<?php
588
												$rowIndex = 0;
589
												foreach ($config['system']['group'] as $group):
590
													if ($group['gid'] == 1998) /* all users group */
591
														continue;
592
													if (is_array($pconfig['groups']) && in_array($group['name'],$pconfig['groups']))
593
														continue;
594
													$rowIndex++;
595
?>
596
												<option value="<?=$group['name'];?>" <?=$selected;?>>
597
													<?=htmlspecialchars($group['name']);?>
598
												</option>
599
<?php
600
												endforeach;
601
												if ($rowIndex == 0)
602
													echo "<option></option>";
603
?>
604
											</select>
605
											<br />
606
										</td>
607
										<td>
608
											<br />
609
											<a href="javascript:move_selected('notgroups','groups')">
610
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="<?=gettext("Add Groups"); ?>" alt="<?=gettext("Add Groups"); ?>" width="17" height="17" border="0" />
611
											</a>
612
											<br /><br />
613
											<a href="javascript:move_selected('groups','notgroups')">
614
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="<?=gettext("Remove Groups"); ?>" alt="<?=gettext("Remove Groups"); ?>" width="17" height="17" border="0" />
615
											</a>
616
										</td>
617
										<td align="center" width="50%">
618
											<strong><?=gettext("Member Of"); ?></strong><br />
619
											<br />
620
											<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onchange="clear_selected('notgroups')" multiple="multiple">
621
<?php
622
												$rowIndex = 0;
623
												if (is_array($pconfig['groups'])):
624
													foreach ($config['system']['group'] as $group):
625
														if ($group['gid'] == 1998) /* all users group */
626
															continue;
627
														if (!in_array($group['name'],$pconfig['groups']))
628
															continue;
629
														$rowIndex++;
630
?>
631
												<option value="<?=$group['name'];?>">
632
													<?=htmlspecialchars($group['name']);?>
633
												</option>
634
<?php
635
													endforeach;
636
												endif;
637
												if ($rowIndex == 0)
638
													echo "<option></option>";
639
?>
640
											</select>
641
											<br />
642
										</td>
643
									</tr>
644
								</table>
645
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
646
							</td>
647
						</tr>
648
<?php
649
					if (isset($pconfig['uid'])):
650
?>
651
						<tr>
652
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
653
							<td width="78%" class="vtable">
654
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="privileges">
655
									<tr>
656
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
657
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
658
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
659
										<td class="list"></td>
660
									</tr>
661
<?php
662
							$privdesc = get_user_privdesc($a_user[$id]);
663
							if(is_array($privdesc)):
664
								$i = 0;
665
								foreach ($privdesc as $priv):
666
									$group = false;
667
									if ($priv['group'])
668
										$group = $priv['group'];
669
?>
670
									<tr>
671
										<td class="listlr"><?=$group;?></td>
672
										<td class="listr">
673
											<?=htmlspecialchars($priv['name']);?>
674
										</td>
675
										<td class="listbg">
676
											<?=htmlspecialchars($priv['descr']);?>
677
										</td>
678
										<td valign="middle" class="list nowrap">
679
<?php
680
										if (!$group):
681
?>
682
											<input type="image" name="delpriv[]" width="17" height="17" border="0"
683
												src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif"
684
												onclick="document.getElementById('privid').value='<?=$i;?>';
685
													document.getElementById('userid').value='<?=$id;?>';
686
													document.getElementById('act').value='<?php echo "delpriv";?>';
687
													return confirm('<?=gettext("Do you really want to delete this privilege?");?>');"
688
												title="<?=gettext("delete privilege");?>" />
689
<?php
690
										endif;
691
?>
692
										</td>
693
									</tr>
694
<?php
695
										/* can only delete user priv indexes */
696
										if (!$group)
697
											$i++;
698
								endforeach;
699
							endif;
700
?>
701
									<tr>
702
										<td class="list" colspan="3"></td>
703
										<td class="list">
704
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
705
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" />
706
											</a>
707
										</td>
708
									</tr>
709
								</table>
710
							</td>
711
						</tr>
712
						<tr>
713
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
714
							<td width="78%" class="vtable">
715
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="certificates">
716
									<tr>
717
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
718
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
719
										<td class="list"></td>
720
									</tr>
721
<?php
722
							$a_cert = $a_user[$id]['cert'];
723
							if(is_array($a_cert)):
724
								$i = 0;
725
								foreach ($a_cert as $certref):
726
									$cert = lookup_cert($certref);
727
									$ca = lookup_ca($cert['caref']);
728
?>
729
									<tr>
730
										<td class="listlr">
731
											<?=htmlspecialchars($cert['descr']);?>
732
<?php
733
										if (is_cert_revoked($cert)):
734
?>
735
											(<b>Revoked</b>)
736
<?php
737
										endif;
738
?>
739
										</td>
740
										<td class="listr">
741
											<?=htmlspecialchars($ca['descr']);?>
742
										</td>
743
										<td valign="middle" class="list nowrap">
744
											<input type="image" name="expckey[]" width="17" height="17" border="0"
745
												src="/themes/<?=$g['theme'];?>/images/icons/icon_down.gif"
746
												onclick="document.getElementById('certid').value='<?=$i;?>';
747
													document.getElementById('userid').value='<?=$id;?>';
748
													document.getElementById('act').value='<?php echo "expckey";?>';"
749
												title="<?=gettext("export private key");?>" />
750
											<input type="image" name="expcert[]" width="17" height="17" border="0"
751
												src="/themes/<?=$g['theme'];?>/images/icons/icon_down.gif"
752
												onclick="document.getElementById('certid').value='<?=$i;?>';
753
													document.getElementById('userid').value='<?=$id;?>';
754
													document.getElementById('act').value='<?php echo "expcert";?>';"
755
												title="<?=gettext("export cert");?>" />
756
											<input type="image" name="delcert[]" width="17" height="17" border="0"
757
												src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif"
758
												onclick="document.getElementById('certid').value='<?=$i;?>';
759
													document.getElementById('userid').value='<?=$id;?>';
760
													document.getElementById('act').value='<?php echo "delcert";?>';
761
													return confirm('<?=gettext("Do you really want to remove this certificate association?") .'\n'. gettext("(Certificate will not be deleted)");?>')"
762
												title="<?=gettext("delete cert");?>" />
763
										</td>
764
									</tr>
765
<?php
766
									$i++;
767
								endforeach;
768
							endif;
769
?>
770
									<tr>
771
										<td class="list" colspan="2"></td>
772
										<td class="list">
773
											<a href="system_certmanager.php?act=new&amp;userid=<?=$id?>">
774
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" />
775
											</a>
776
										</td>
777
									</tr>
778
								</table>
779
							</td>
780
						</tr>
781

    
782
<?php
783
					else:
784
						if (is_array($config['ca']) && count($config['ca']) > 0):
785
							$i = 0;
786
							foreach( $config['ca'] as $ca) {
787
								if (!$ca['prv'])
788
									continue;
789
								$i++;
790
							}
791
?>
792

    
793
						<tr id="usercertchck">
794
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
795
							<td width="78%" class="vtable">
796
							<input type="checkbox" onclick="javascript:usercertClicked(this)" /> <?=gettext("Click to create a user certificate."); ?>
797
							</td>
798
						</tr>
799

    
800
<?php
801
							if ($i > 0):
802
?>
803
						<tr id="usercert" style="display:none">
804
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
805
							<td width="78%" class="vtable">
806
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="certificate">
807
									<tr>
808
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
809
										<td width="78%" class="vtable">
810
											<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" />
811
										</td>
812
									</tr>
813
									<tr>
814
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
815
										<td width="78%" class="vtable">
816
											<select name='caref' id='caref' class="formselect" onchange='internalca_change()'>
817
<?php
818
											$rowIndex = 0;
819
											foreach( $config['ca'] as $ca):
820
												if (!$ca['prv'])
821
													continue;
822
												$rowIndex++;
823
?>
824
												<option value="<?=$ca['refid'];?>"><?=htmlspecialchars($ca['descr']);?></option>
825
<?php
826
											endforeach;
827
											if ($rowIndex == 0)
828
												echo "<option></option>";
829
?>
830
											</select>
831
										</td>
832
									</tr>
833
									<tr>
834
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
835
										<td width="78%" class="vtable">
836
											<select name='keylen' class="formselect">
837
<?php
838
											$cert_keylens = array( "2048", "512", "1024", "4096");
839
											foreach( $cert_keylens as $len):
840
?>
841
												<option value="<?=$len;?>"><?=$len;?></option>
842
<?php
843
											endforeach;
844
											if (!count($cert_keylens))
845
												echo "<option></option>";
846
?>
847
											</select>
848
											bits
849
										</td>
850
									</tr>
851
									<tr>
852
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
853
										<td width="78%" class="vtable">
854
											<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>" />days
855
										</td>
856
									</tr>
857
								</table>
858
							</td>
859
						</tr>
860
<?php
861
							endif;
862
						endif;
863
					endif;
864
?>
865
						<tr id="sshkeychck" <?php if(!empty($pconfig['authorizedkeys'])) echo 'style="display:none"'; ?>>
866
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
867
							<td width="78%" class="vtable">
868
								<input type="checkbox" onclick="javascript:sshkeyClicked(this)" /> <?=gettext("Click to paste an authorized key."); ?>
869
							</td>
870
						</tr>
871
						<tr id="sshkey" <?php if(empty($pconfig['authorizedkeys'])) echo 'style="display:none"'; ?>>
872
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
873
							<td width="78%" class="vtable">
874
								<script type="text/javascript">
875
								//<![CDATA[
876
								window.onload=function(){
877
									document.getElementById("authorizedkeys").wrap='off';
878
								}
879
								//]]>
880
								</script>
881
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
882
								<br />
883
								<?=gettext("Paste an authorized keys file here.");?>
884
							</td>
885
						</tr>
886
						<tr id="ipsecpskrow">
887
							<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Pre-Shared Key");?></td>
888
							<td width="78%" class="vtable">
889
								<input name="ipsecpsk" type="text" class="formfld unknown" id="ipsecpsk" size="65" value="<?=htmlspecialchars($pconfig['ipsecpsk']);?>" />
890
							</td>
891
						</tr>
892
						<tr>
893
							<td width="22%" valign="top">&nbsp;</td>
894
							<td width="78%">
895
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
896
								<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
897
								<?php if (isset($id) && $a_user[$id]): ?>
898
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
899
								<?php endif;?>
900
							</td>
901
						</tr>
902
					</table>
903
				</form>
904
<?php
905
			else:
906
?>
907
				<form action="system_usermanager.php" method="post" name="iform2" id="iform2">
908
					<input type="hidden" id="act" name="act" value="" />
909
					<input type="hidden" id="userid" name="userid" value="<?=(isset($id) ? $id : '');?>" />
910
					<input type="hidden" id="username" name="username" value="" />
911
					<input type="hidden" id="privid" name="privid" value="" />
912
					<input type="hidden" id="certid" name="certid" value="" />
913
					<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
914
						<thead>
915
							<tr>
916
								<th width="5%" class="list">&nbsp;</th>
917
								<th width="25%" class="listhdrr"><?=gettext("Username"); ?></th>
918
								<th width="25%" class="listhdrr"><?=gettext("Full name"); ?></th>
919
								<th width="5%" class="listhdrr"><?=gettext("Disabled"); ?></th>
920
								<th width="25%" class="listhdrr"><?=gettext("Groups"); ?></th>
921
								<th width="10%" class="list"></th>
922
							</tr>
923
						</thead>
924
						<tfoot>
925
							<tr>
926
								<td class="list" colspan="5"></td>
927
								<td class="list">
928
									<input type="image" name="addcert" width="17" height="17" border="0"
929
										src="/themes/<?=$g['theme'];?>/images/icons/icon_plus.gif"
930
										onclick="document.getElementById('act').value='<?php echo "new";?>';"
931
										title="<?=gettext("add user");?>" />
932
									<input type="image" src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" name="dellall" title="<?=gettext('Delete selected users')?>" onClick="return confirm('<?=gettext("Do you really want to delete selected Users?");?>')" />
933
								</td>
934
							</tr>
935
							<tr>
936
								<td colspan="5">
937
									<p>
938
										<?=gettext("Additional users can be added here. User permissions for accessing " .
939
										"the webConfigurator can be assigned directly or inherited from group memberships. " .
940
										"An icon that appears grey indicates that it is a system defined object. " .
941
										"Some system object properties can be modified but they cannot be deleted."); ?>
942
										<br /><br />
943
										<?=gettext("Accounts created here are also used for other parts of the system " .
944
										"such as OpenVPN, IPsec, and Captive Portal.");?>
945
									</p>
946
								</td>
947
							</tr>
948
						</tfoot>
949
						<tbody>
950
<?php
951
						$i = 0;
952
						foreach($a_user as $userent):
953
?>
954
								<tr ondblclick="document.getElementById('act').value='<?php echo "edit";?>';
955
									document.getElementById('userid').value='<?=$i;?>';
956
									document.iform2.submit();" id="fr<?=$i?>">
957
								<td class="list" id="frd<?=$i?>">
958
								<?php if($userent['scope'] != "system") : ?>
959
									<input type="checkbox" id="frc<?=$i?>" onclick="fr_bgcolor(<?=$i?>)" name="delete_check[]" value="<?=$i?>" />
960
								<?php endif; ?>
961
								</td>
962
								<td class="listlr" id="frd<?=$i?>" onclick="fr_toggle('<?=$i;?>')">
963
									<table border="0" cellpadding="0" cellspacing="0" summary="icons">
964
										<tr>
965
											<td align="left" valign="middle">
966
<?php
967
												if($userent['scope'] != "user")
968
													$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
969
												else
970
													$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
971
?>
972
												<img src="<?=$usrimg;?>" alt="<?=gettext("User"); ?>" title="<?=gettext("User"); ?>" border="0" height="16" width="16" />
973
											</td>
974
											<td align="left" valign="middle">
975
												<?=htmlspecialchars($userent['name']);?>
976
											</td>
977
										</tr>
978
									</table>
979
								</td>
980
								<td class="listr" id="frd<?=$i?>" onclick="fr_toggle('<?=$i;?>')"><?=htmlspecialchars($userent['descr']);?>&nbsp;</td>
981
								<td class="listr" id="frd<?=$i?>" onclick="fr_toggle('<?=$i;?>')"><?php if(isset($userent['disabled'])) echo "*"; ?></td>
982
								<td class="listbg" onclick="fr_toggle('<?=$i;?>')">
983
									<?=implode(",",local_user_get_groups($userent));?>
984
									&nbsp;
985
								</td>
986
								<td valign="middle" class="list nowrap">
987
									<input type="image" name="edituser[]" width="17" height="17" border="0"
988
										src="/themes/<?=$g['theme'];?>/images/icons/icon_e.gif"
989
										onclick="document.getElementById('userid').value='<?=$i;?>';
990
											document.getElementById('act').value='<?php echo "edit";?>';"
991
										title="<?=gettext("edit user");?>" />
992
<?php
993
								if($userent['scope'] != "system"):
994
?>
995
									&nbsp;
996
									<input type="image" name="deluser[]" width="17" height="17" border="0"
997
										src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif"
998
										onclick="document.getElementById('userid').value='<?=$i;?>';
999
											document.getElementById('username').value='<?=$userent['name'];?>';
1000
											document.getElementById('act').value='<?php echo "deluser";?>';
1001
											return confirm('<?=gettext("Do you really want to delete this user?");?>');"
1002
										title="<?=gettext("delete user");?>" />
1003
<?php
1004
								endif;
1005
?>
1006
								</td>
1007
							</tr>
1008
<?php
1009
							$i++;
1010
						endforeach;
1011
?>
1012
						</tbody>
1013
					</table>
1014
				</form>
1015
<?php
1016
			endif;
1017
?>
1018
			</div>
1019
		</td>
1020
	</tr>
1021
</table>
1022
<?php include("fend.inc");?>
1023
</body>
1024
</html>
(225-225/252)