Project

General

Profile

Download (35.1 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-2014 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
	conf_mount_rw();
94
	local_user_del($a_user[$id]);
95
	conf_mount_ro();
96
	$userdeleted = $a_user[$id]['name'];
97
	unset($a_user[$id]);
98
	write_config();
99
	$savemsg = gettext("User")." {$userdeleted} ".
100
				gettext("successfully deleted")."<br />";
101
}
102
else if ($_POST['act'] == "delpriv") {
103

    
104
	if (!$a_user[$id]) {
105
		pfSenseHeader("system_usermanager.php");
106
		exit;
107
	}
108

    
109
	$privdeleted = $priv_list[$a_user[$id]['priv'][$_POST['privid']]]['name'];
110
	unset($a_user[$id]['priv'][$_POST['privid']]);
111
	local_user_set($a_user[$id]);
112
	write_config();
113
	$_POST['act'] = "edit";
114
	$savemsg = gettext("Privilege")." {$privdeleted} ".
115
				gettext("successfully deleted")."<br />";
116
}
117
else if ($_POST['act'] == "expcert") {
118

    
119
	if (!$a_user[$id]) {
120
		pfSenseHeader("system_usermanager.php");
121
		exit;
122
	}
123

    
124
	$cert =& lookup_cert($a_user[$id]['cert'][$_POST['certid']]);
125

    
126
	$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.crt");
127
	$exp_data = base64_decode($cert['crt']);
128
	$exp_size = strlen($exp_data);
129

    
130
	header("Content-Type: application/octet-stream");
131
	header("Content-Disposition: attachment; filename={$exp_name}");
132
	header("Content-Length: $exp_size");
133
	echo $exp_data;
134
	exit;
135
}
136
else if ($_POST['act'] == "expckey") {
137

    
138
	if (!$a_user[$id]) {
139
		pfSenseHeader("system_usermanager.php");
140
		exit;
141
	}
142

    
143
	$cert =& lookup_cert($a_user[$id]['cert'][$_POST['certid']]);
144

    
145
	$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.key");
146
	$exp_data = base64_decode($cert['prv']);
147
	$exp_size = strlen($exp_data);
148

    
149
	header("Content-Type: application/octet-stream");
150
	header("Content-Disposition: attachment; filename={$exp_name}");
151
	header("Content-Length: $exp_size");
152
	echo $exp_data;
153
	exit;
154
}
155
else if ($_POST['act'] == "delcert") {
156

    
157
	if (!$a_user[$id]) {
158
		pfSenseHeader("system_usermanager.php");
159
		exit;
160
	}
161

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

    
180
if(isset($_POST['dellall_x'])) {
181

    
182
	$del_users = $_POST['delete_check'];
183

    
184
	if(!empty($del_users)) {
185
		foreach($del_users as $userid) {
186
			if (isset($a_user[$userid]) && $a_user[$userid]['scope'] != "system") {
187
				conf_mount_rw();
188
				local_user_del($a_user[$userid]);
189
				conf_mount_ro();
190
				unset($a_user[$userid]);
191
			}
192
		}
193
		$savemsg = gettext("Selected users removed successfully!");
194
		write_config($savemsg);
195
	}
196
}
197

    
198
if ($_POST['save']) {
199
	unset($input_errors);
200
	$pconfig = $_POST;
201

    
202
	/* input validation */
203
	if (isset($id) && ($a_user[$id])) {
204
		$reqdfields = explode(" ", "usernamefld");
205
		$reqdfieldsn = array(gettext("Username"));
206
	} else {
207
		if (empty($_POST['name'])) {
208
			$reqdfields = explode(" ", "usernamefld passwordfld1");
209
			$reqdfieldsn = array(
210
				gettext("Username"),
211
				gettext("Password"));
212
		} else {
213
			$reqdfields = explode(" ", "usernamefld passwordfld1 name caref keylen lifetime");
214
			$reqdfieldsn = array(
215
				gettext("Username"),
216
				gettext("Password"),
217
				gettext("Descriptive name"),
218
				gettext("Certificate authority"),
219
				gettext("Key length"),
220
				gettext("Lifetime"));
221
		}
222
	}
223

    
224
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
225

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

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

    
232
	if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
233
		$input_errors[] = gettext("The passwords do not match.");
234

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

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

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

    
281
	if (!empty($_POST['name'])) {
282
		$ca = lookup_ca($_POST['caref']);
283
		if (!$ca)
284
			$input_errors[] = gettext("Invalid internal Certificate Authority") . "\n";
285
	}
286

    
287
	/* if this is an AJAX caller then handle via JSON */
288
	if (isAjax() && is_array($input_errors)) {
289
		input_errors2Ajax($input_errors);
290
		exit;
291
	}
292

    
293
	if (!$input_errors) {
294
		conf_mount_rw();
295
		$userent = array();
296
		if (isset($id) && $a_user[$id])
297
			$userent = $a_user[$id];
298

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

    
301
		/* the user name was modified */
302
		if ($_POST['usernamefld'] <> $_POST['oldusername']) {
303
			$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
304
			local_user_del($userent);
305
		}
306

    
307
		/* the user password was mofified */
308
		if ($_POST['passwordfld1'])
309
			local_user_set_password($userent, $_POST['passwordfld1']);
310

    
311
		$userent['name'] = $_POST['usernamefld'];
312
		$userent['descr'] = $_POST['descr'];
313
		$userent['expires'] = $_POST['expires'];
314
		$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
315
		$userent['ipsecpsk'] = $_POST['ipsecpsk'];
316

    
317
		if($_POST['disabled'])
318
			$userent['disabled'] = true;
319
		else
320
			unset($userent['disabled']);
321

    
322
		if (isset($id) && $a_user[$id])
323
			$a_user[$id] = $userent;
324
		else {
325
			if (!empty($_POST['name'])) {
326
				$cert = array();
327
				$cert['refid'] = uniqid();
328
				$userent['cert'] = array();
329

    
330
				$cert['descr'] = $_POST['name'];
331

    
332
				$subject = cert_get_subject_array($ca['crt']);
333

    
334
				$dn = array(
335
					'countryName' => $subject[0]['v'],
336
					'stateOrProvinceName' => $subject[1]['v'],
337
					'localityName' => $subject[2]['v'],
338
					'organizationName' => $subject[3]['v'],
339
					'emailAddress' => $subject[4]['v'],
340
					'commonName' => $userent['name']);
341

    
342
				cert_create($cert, $_POST['caref'], $_POST['keylen'],
343
					(int)$_POST['lifetime'], $dn);
344

    
345
				if (!is_array($config['cert']))
346
					$config['cert'] = array();
347
				$config['cert'][] = $cert;
348
				$userent['cert'][] = $cert['refid'];
349
			}
350
			$userent['uid'] = $config['system']['nextuid']++;
351
			/* Add the user to All Users group. */
352
			foreach ($config['system']['group'] as $gidx => $group) {
353
				if ($group['name'] == "all") {
354
					if (!is_array($config['system']['group'][$gidx]['member']))
355
						$config['system']['group'][$gidx]['member'] = array();
356
					$config['system']['group'][$gidx]['member'][] = $userent['uid'];
357
					break;
358
				}
359
			}
360

    
361
			$a_user[] = $userent;
362
		}
363

    
364
		local_user_set_groups($userent,$_POST['groups']);
365
		local_user_set($userent);
366
		write_config();
367

    
368
		if(is_dir("/etc/inc/privhooks"))
369
			run_plugins("/etc/inc/privhooks");
370

    
371
		conf_mount_ro();
372

    
373
		pfSenseHeader("system_usermanager.php");
374
	}
375
}
376

    
377
$closehead = false;
378
include("head.inc");
379
?>
380

    
381
<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
382
<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui-1.11.1.css" />
383

    
384
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
385
<script type="text/javascript">
386
//<![CDATA[
387
	jQuery(function() {
388
		jQuery( "#expires" ).datepicker( { dateFormat: 'mm/dd/yy', changeYear: true, yearRange: "+0:+100" } );
389
	});
390
//]]>
391
</script>
392
</head>
393

    
394
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
395
<?php include("fbegin.inc"); ?>
396

    
397
<script type="text/javascript">
398
//<![CDATA[
399

    
400
function setall_selected(id) {
401
	selbox = document.getElementById(id);
402
	count = selbox.options.length;
403
	for (index = 0; index<count; index++)
404
		selbox.options[index].selected = true;
405
}
406

    
407
function delete_empty(id) {
408
	selbox = document.getElementById(id);
409
	count = selbox.options.length;
410
	for (index = 0; index<count; index++)
411
		if (selbox.options[index].value == '')
412
			selbox.remove(index);
413
}
414

    
415
function clear_selected(id) {
416
	selbox = document.getElementById(id);
417
	count = selbox.options.length;
418
	for (index = 0; index<count; index++)
419
		selbox.options[index].selected = false;
420
}
421

    
422
function remove_selected(id) {
423
	selbox = document.getElementById(id);
424
	index = selbox.options.length - 1;
425
	for (; index >= 0; index--)
426
		if (selbox.options[index].selected)
427
			selbox.remove(index);
428
}
429

    
430
function copy_selected(srcid, dstid) {
431
	src_selbox = document.getElementById(srcid);
432
	dst_selbox = document.getElementById(dstid);
433
	count = dst_selbox.options.length;
434
	for (index = count - 1; index >= 0; index--) {
435
		if (dst_selbox.options[index].value == '') {
436
			dst_selbox.remove(index);
437
		}
438
	}
439
	count = src_selbox.options.length;
440
	for (index = 0; index < count; index++) {
441
		if (src_selbox.options[index].selected) {
442
			option = document.createElement('option');
443
			option.text = src_selbox.options[index].text;
444
			option.value = src_selbox.options[index].value;
445
			dst_selbox.add(option, null);
446
		}
447
	}
448
}
449

    
450
function move_selected(srcid, dstid) {
451
	copy_selected(srcid, dstid);
452
	remove_selected(srcid);
453
}
454

    
455
function presubmit() {
456
	delete_empty('groups');
457
	delete_empty('notgroups');
458
	clear_selected('notgroups');
459
	setall_selected('groups');
460
}
461

    
462
function usercertClicked(obj) {
463
	if (obj.checked) {
464
		document.getElementById("usercertchck").style.display="none";
465
		document.getElementById("usercert").style.display="";
466
	} else {
467
		document.getElementById("usercert").style.display="none";
468
		document.getElementById("usercertchck").style.display="";
469
	}
470
}
471

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

    
769
<?php
770
					else:
771
						if (is_array($config['ca']) && count($config['ca']) > 0):
772
							$i = 0;
773
							foreach( $config['ca'] as $ca) {
774
								if (!$ca['prv'])
775
									continue;
776
								$i++;
777
							}
778
?>
779

    
780
						<tr id="usercertchck">
781
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
782
							<td width="78%" class="vtable">
783
							<input type="checkbox" onclick="javascript:usercertClicked(this)" /> <?=gettext("Click to create a user certificate."); ?>
784
							</td>
785
						</tr>
786

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