Projet

Général

Profil

Télécharger (31,3 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / system_usermanager.php @ 4c291f4c

1
<?php
2
/* $Id$ */
3
/*
4
	system_usermanager.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2008 Shrew Soft Inc.
8
	All rights reserved.
9

    
10
	Copyright (C) 2005 Paul Taylor <paultaylor@winn-dixie.com>.
11
	All rights reserved.
12

    
13
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
14
	All rights reserved.
15

    
16
	Redistribution and use in source and binary forms, with or without
17
	modification, are permitted provided that the following conditions are met:
18

    
19
	1. Redistributions of source code must retain the above copyright notice,
20
	   this list of conditions and the following disclaimer.
21

    
22
	2. Redistributions in binary form must reproduce the above copyright
23
	   notice, this list of conditions and the following disclaimer in the
24
	   documentation and/or other materials provided with the distribution.
25

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

    
42
##|+PRIV
43
##|*IDENT=page-system-usermanager
44
##|*NAME=System: User Manager page
45
##|*DESCR=Allow access to the 'System: User Manager' page.
46
##|*MATCH=system_usermanager.php*
47
##|-PRIV
48

    
49
require("certs.inc");
50
require("guiconfig.inc");
51

    
52

    
53
// start admin user code
54
$pgtitle = array(gettext("System"),gettext("User Manager"));
55

    
56
if (is_numericint($_GET['id']))
57
	$id = $_GET['id'];
58
if (isset($_POST['id']) && is_numericint($_POST['id']))
59
	$id = $_POST['id'];
60

    
61
if (!is_array($config['system']['user']))
62
	$config['system']['user'] = array();
63

    
64
$a_user = &$config['system']['user'];
65

    
66
if (isset($id) && $a_user[$id]) {
67
	$pconfig['usernamefld'] = $a_user[$id]['name'];
68
	$pconfig['descr'] = $a_user[$id]['descr'];
69
	$pconfig['expires'] = $a_user[$id]['expires'];
70
	$pconfig['groups'] = local_user_get_groups($a_user[$id]);
71
	$pconfig['utype'] = $a_user[$id]['scope'];
72
	$pconfig['uid'] = $a_user[$id]['uid'];
73
	$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
74
	$pconfig['priv'] = $a_user[$id]['priv'];
75
	$pconfig['ipsecpsk'] = $a_user[$id]['ipsecpsk'];
76
	$pconfig['disabled'] = isset($a_user[$id]['disabled']);
77
}
78

    
79
if ($_GET['act'] == "deluser") {
80

    
81
	if (!$a_user[$id]) {
82
		pfSenseHeader("system_usermanager.php");
83
		exit;
84
	}
85

    
86
	conf_mount_rw();
87
	local_user_del($a_user[$id]);
88
	conf_mount_ro();
89
	$userdeleted = $a_user[$id]['name'];
90
	unset($a_user[$id]);
91
	write_config();
92
	$savemsg = gettext("User")." {$userdeleted} ".
93
				gettext("successfully deleted")."<br />";
94
}
95
else if ($_GET['act'] == "delpriv") {
96

    
97
	if (!$a_user[$id]) {
98
		pfSenseHeader("system_usermanager.php");
99
		exit;
100
	}
101

    
102
	$privdeleted = $priv_list[$a_user[$id]['priv'][$_GET['privid']]]['name'];
103
	unset($a_user[$id]['priv'][$_GET['privid']]);
104
	local_user_set($a_user[$id]);
105
	write_config();
106
	$_GET['act'] = "edit";
107
	$savemsg = gettext("Privilege")." {$privdeleted} ".
108
				gettext("successfully deleted")."<br />";
109
}
110
else if ($_GET['act'] == "expcert") {
111

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

    
117
	$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
118

    
119
	$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.crt");
120
	$exp_data = base64_decode($cert['crt']);
121
	$exp_size = strlen($exp_data);
122

    
123
	header("Content-Type: application/octet-stream");
124
	header("Content-Disposition: attachment; filename={$exp_name}");
125
	header("Content-Length: $exp_size");
126
	echo $exp_data;
127
	exit;
128
}
129
else if ($_GET['act'] == "expckey") {
130

    
131
	if (!$a_user[$id]) {
132
		pfSenseHeader("system_usermanager.php");
133
		exit;
134
	}
135

    
136
	$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
137

    
138
	$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.key");
139
	$exp_data = base64_decode($cert['prv']);
140
	$exp_size = strlen($exp_data);
141

    
142
	header("Content-Type: application/octet-stream");
143
	header("Content-Disposition: attachment; filename={$exp_name}");
144
	header("Content-Length: $exp_size");
145
	echo $exp_data;
146
	exit;
147
}
148
else if ($_GET['act'] == "delcert") {
149

    
150
	if (!$a_user[$id]) {
151
		pfSenseHeader("system_usermanager.php");
152
		exit;
153
	}
154

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

    
173
if ($_POST) {
174
	unset($input_errors);
175
	$pconfig = $_POST;
176

    
177
	/* input validation */
178
	if (isset($id) && ($a_user[$id])) {
179
		$reqdfields = explode(" ", "usernamefld");
180
		$reqdfieldsn = array(gettext("Username"));
181
	} else {
182
		if (empty($_POST['name'])) {
183
			$reqdfields = explode(" ", "usernamefld passwordfld1");
184
			$reqdfieldsn = array(
185
				gettext("Username"),
186
				gettext("Password"));
187
		} else {
188
			$reqdfields = explode(" ", "usernamefld passwordfld1 name caref keylen lifetime");
189
			$reqdfieldsn = array(
190
				gettext("Username"),
191
				gettext("Password"),
192
				gettext("Descriptive name"),
193
				gettext("Certificate authority"),
194
				gettext("Key length"),
195
				gettext("Lifetime"));
196
		}
197
	}
198

    
199
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
200

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

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

    
207
	if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
208
		$input_errors[] = gettext("The passwords do not match.");
209

    
210
	if (isset($id) && $a_user[$id])
211
		$oldusername = $a_user[$id]['name'];
212
	else
213
		$oldusername = "";
214
	/* make sure this user name is unique */
215
	if (!$input_errors) {
216
		foreach ($a_user as $userent) {
217
			if ($userent['name'] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
218
				$input_errors[] = gettext("Another entry with the same username already exists.");
219
				break;
220
			}
221
		}
222
	}
223
	/* also make sure it is not reserved */
224
	if (!$input_errors) {
225
		$system_users = explode("\n", file_get_contents("/etc/passwd"));
226
		foreach ($system_users as $s_user) {
227
			$ent = explode(":", $s_user);
228
			if ($ent[0] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
229
				$input_errors[] = gettext("That username is reserved by the system.");
230
				break;
231
			}
232
		}
233
	}
234

    
235
	/*
236
	 * Check for a valid expirationdate if one is set at all (valid means,
237
	 * DateTime puts out a time stamp so any DateTime compatible time
238
	 * format may be used. to keep it simple for the enduser, we only
239
	 * claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
240
	 * like "+1 day", which will be converted to MM/DD/YYYY based on "now".
241
	 * Otherwhise such an entry would lead to an invalid expiration data.
242
	 */
243
	if ($_POST['expires']){
244
		try {
245
			$expdate = new DateTime($_POST['expires']);
246
			//convert from any DateTime compatible date to MM/DD/YYYY
247
			$_POST['expires'] = $expdate->format("m/d/Y");
248
		} catch ( Exception $ex ) {
249
			$input_errors[] = gettext("Invalid expiration date format; use MM/DD/YYYY instead.");
250
		}
251
	}
252

    
253
	if (!empty($_POST['name'])) {
254
		$ca = lookup_ca($_POST['caref']);
255
		if (!$ca)
256
			$input_errors[] = gettext("Invalid internal Certificate Authority") . "\n";
257
	}
258

    
259
	/* if this is an AJAX caller then handle via JSON */
260
	if (isAjax() && is_array($input_errors)) {
261
		input_errors2Ajax($input_errors);
262
		exit;
263
	}
264

    
265
	if (!$input_errors) {
266
		conf_mount_rw();
267
		$userent = array();
268
		if (isset($id) && $a_user[$id])
269
			$userent = $a_user[$id];
270

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

    
273
		/* the user name was modified */
274
		if ($_POST['usernamefld'] <> $_POST['oldusername']) {
275
			$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
276
			local_user_del($userent);
277
		}
278

    
279
		/* the user password was mofified */
280
		if ($_POST['passwordfld1'])
281
			local_user_set_password($userent, $_POST['passwordfld1']);
282

    
283
		$userent['name'] = $_POST['usernamefld'];
284
		$userent['descr'] = $_POST['descr'];
285
		$userent['expires'] = $_POST['expires'];
286
		$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
287
		$userent['ipsecpsk'] = $_POST['ipsecpsk'];
288

    
289
		if($_POST['disabled'])
290
			$userent['disabled'] = true;
291
		else
292
			unset($userent['disabled']);
293

    
294
		if (isset($id) && $a_user[$id])
295
			$a_user[$id] = $userent;
296
		else {
297
			if (!empty($_POST['name'])) {
298
				$cert = array();
299
				$cert['refid'] = uniqid();
300
				$userent['cert'] = array();
301

    
302
				$cert['descr'] = $_POST['name'];
303

    
304
				$subject = cert_get_subject_array($ca['crt']);
305

    
306
				$dn = array(
307
					'countryName' => $subject[0]['v'],
308
					'stateOrProvinceName' => $subject[1]['v'],
309
					'localityName' => $subject[2]['v'],
310
					'organizationName' => $subject[3]['v'],
311
					'emailAddress' => $subject[4]['v'],
312
					'commonName' => $userent['name']);
313

    
314
				cert_create($cert, $_POST['caref'], $_POST['keylen'],
315
					(int)$_POST['lifetime'], $dn);
316

    
317
				if (!is_array($config['cert']))
318
					$config['cert'] = array();
319
				$config['cert'][] = $cert;
320
				$userent['cert'][] = $cert['refid'];
321
			}
322
			$userent['uid'] = $config['system']['nextuid']++;
323
			/* Add the user to All Users group. */
324
			foreach ($config['system']['group'] as $gidx => $group) {
325
				if ($group['name'] == "all") {
326
					if (!is_array($config['system']['group'][$gidx]['member']))
327
						$config['system']['group'][$gidx]['member'] = array();
328
					$config['system']['group'][$gidx]['member'][] = $userent['uid'];
329
					break;
330
				}
331
			}
332

    
333
			$a_user[] = $userent;
334
		}
335

    
336
		local_user_set_groups($userent,$_POST['groups']);
337
		local_user_set($userent);
338
		write_config();
339

    
340
		if(is_dir("/etc/inc/privhooks"))
341
			run_plugins("/etc/inc/privhooks");
342

    
343
		conf_mount_ro();
344

    
345
		pfSenseHeader("system_usermanager.php");
346
	}
347
}
348

    
349
$closehead = false;
350
include("head.inc");
351
?>
352

    
353
<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
354
<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui.custom.css" />
355

    
356
<script type="text/javascript">
357
//<![CDATA[
358
	jQuery(function() {
359
		jQuery( "#expires" ).datepicker( { dateFormat: 'mm/dd/yy', changeYear: true, yearRange: "+0:+100" } );
360
	});
361
//]]>
362
</script>
363
</head>
364

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

    
368
<script type="text/javascript">
369
//<![CDATA[
370

    
371
function setall_selected(id) {
372
	selbox = document.getElementById(id);
373
	count = selbox.options.length;
374
	for (index = 0; index<count; index++)
375
		selbox.options[index].selected = true;
376
}
377

    
378
function clear_selected(id) {
379
	selbox = document.getElementById(id);
380
	count = selbox.options.length;
381
	for (index = 0; index<count; index++)
382
		selbox.options[index].selected = false;
383
}
384

    
385
function remove_selected(id) {
386
	selbox = document.getElementById(id);
387
	index = selbox.options.length - 1;
388
	for (; index >= 0; index--)
389
		if (selbox.options[index].selected)
390
			selbox.remove(index);
391
}
392

    
393
function copy_selected(srcid, dstid) {
394
	src_selbox = document.getElementById(srcid);
395
	dst_selbox = document.getElementById(dstid);
396
	count = dst_selbox.options.length;
397
	for (index = count - 1; index >= 0; index--) {
398
		if (dst_selbox.options[index].value == '') {
399
			dst_selbox.remove(index);
400
		}
401
	}
402
	count = src_selbox.options.length;
403
	for (index = 0; index < count; index++) {
404
		if (src_selbox.options[index].selected) {
405
			option = document.createElement('option');
406
			option.text = src_selbox.options[index].text;
407
			option.value = src_selbox.options[index].value;
408
			dst_selbox.add(option, null);
409
		}
410
	}
411
}
412

    
413
function move_selected(srcid, dstid) {
414
	copy_selected(srcid, dstid);
415
	remove_selected(srcid);
416
}
417

    
418
function presubmit() {
419
	clear_selected('notgroups');
420
	setall_selected('groups');
421
}
422

    
423
function usercertClicked(obj) {
424
	if (obj.checked) {
425
		document.getElementById("usercertchck").style.display="none";
426
		document.getElementById("usercert").style.display="";
427
	} else {
428
		document.getElementById("usercert").style.display="none";
429
		document.getElementById("usercertchck").style.display="";
430
	}
431
}
432

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

    
712
<?php
713
					else:
714
						if (is_array($config['ca']) && count($config['ca']) > 0):
715
							$i = 0;
716
							foreach( $config['ca'] as $ca) {
717
								if (!$ca['prv'])
718
									continue;
719
								$i++;
720
							}
721
?>
722

    
723
						<tr id="usercertchck">
724
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
725
							<td width="78%" class="vtable">
726
							<input type="checkbox" onclick="javascript:usercertClicked(this)" /> <?=gettext("Click to create a user certificate."); ?>
727
							</td>
728
						</tr>
729

    
730
<?php
731
							if ($i > 0):
732
?>
733
						<tr id="usercert" style="display:none">
734
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
735
							<td width="78%" class="vtable">
736
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="certificate">
737
									<tr>
738
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
739
										<td width="78%" class="vtable">
740
											<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" />
741
										</td>
742
									</tr>
743
									<tr>
744
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
745
										<td width="78%" class="vtable">
746
											<select name='caref' id='caref' class="formselect" onchange='internalca_change()'>
747
<?php
748
											$rowIndex = 0;
749
											foreach( $config['ca'] as $ca):
750
												if (!$ca['prv'])
751
													continue;
752
												$rowIndex++;
753
?>
754
												<option value="<?=$ca['refid'];?>"><?=$ca['descr'];?></option>
755
<?php
756
											endforeach;
757
											if ($rowIndex == 0)
758
												echo "<option></option>";
759
?>
760
											</select>
761
										</td>
762
									</tr>
763
									<tr>
764
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
765
										<td width="78%" class="vtable">
766
											<select name='keylen' class="formselect">
767
<?php
768
											$cert_keylens = array( "2048", "512", "1024", "4096");
769
											foreach( $cert_keylens as $len):
770
?>
771
												<option value="<?=$len;?>"><?=$len;?></option>
772
<?php
773
											endforeach;
774
											if (!count($cert_keylens))
775
												echo "<option></option>";
776
?>
777
											</select>
778
											bits
779
										</td>
780
									</tr>
781
									<tr>
782
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
783
										<td width="78%" class="vtable">
784
											<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>" />days
785
										</td>
786
									</tr>
787
								</table>
788
							</td>
789
						</tr>
790
<?php
791
							endif;
792
						endif;
793
					endif;
794
?>
795
						<tr id="sshkeychck" <?php if(!empty($pconfig['authorizedkeys'])) echo 'style="display:none"'; ?>>
796
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
797
							<td width="78%" class="vtable">
798
								<input type="checkbox" onclick="javascript:sshkeyClicked(this)" /> <?=gettext("Click to paste an authorized key."); ?>
799
							</td>
800
						</tr>
801
						<tr id="sshkey" <?php if(empty($pconfig['authorizedkeys'])) echo 'style="display:none"'; ?>>
802
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
803
							<td width="78%" class="vtable">
804
								<script type="text/javascript">
805
								//<![CDATA[
806
								window.onload=function(){
807
									document.getElementById("authorizedkeys").wrap='off';
808
								}
809
								//]]>
810
								</script>
811
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
812
								<br />
813
								<?=gettext("Paste an authorized keys file here.");?>
814
							</td>
815
						</tr>
816
						<tr id="ipsecpskrow">
817
							<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Pre-Shared Key");?></td>
818
							<td width="78%" class="vtable">
819
								<input name="ipsecpsk" type="text" class="formfld unknown" id="ipsecpsk" size="65" value="<?=htmlspecialchars($pconfig['ipsecpsk']);?>" />
820
							</td>
821
						</tr>
822
						<tr>
823
							<td width="22%" valign="top">&nbsp;</td>
824
							<td width="78%">
825
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
826
								<?php if (isset($id) && $a_user[$id]): ?>
827
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
828
								<?php endif;?>
829
							</td>
830
						</tr>
831
					</table>
832
				</form>
833
<?php
834
			else:
835
?>
836
				<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
837
					<thead>
838
						<tr>
839
							<th width="25%" class="listhdrr"><?=gettext("Username"); ?></th>
840
							<th width="25%" class="listhdrr"><?=gettext("Full name"); ?></th>
841
							<th width="5%" class="listhdrr"><?=gettext("Disabled"); ?></th>
842
							<th width="25%" class="listhdrr"><?=gettext("Groups"); ?></th>
843
							<th width="10%" class="list"></th>
844
						</tr>
845
					</thead>
846
					<tfoot>
847
						<tr>
848
							<td class="list" colspan="4"></td>
849
							<td class="list">
850
								<a href="system_usermanager.php?act=new">
851
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add user"); ?>" alt="<?=gettext("add user"); ?>" width="17" height="17" border="0" />
852
								</a>
853
							</td>
854
						</tr>
855
						<tr>
856
							<td colspan="4">
857
								<p>
858
									<?=gettext("Additional users can be added here. User permissions for accessing " .
859
									"the webConfigurator can be assigned directly or inherited from group memberships. " .
860
									"An icon that appears grey indicates that it is a system defined object. " .
861
									"Some system object properties can be modified but they cannot be deleted."); ?>
862
									<br /><br />
863
									<?=gettext("Accounts created here are also used for other parts of the system " .
864
									"such as OpenVPN, IPsec, and Captive Portal.");?>
865
								</p>
866
							</td>
867
						</tr>
868
					</tfoot>
869
					<tbody>
870
<?php
871
					$i = 0;
872
					foreach($a_user as $userent):
873
?>
874
						<tr ondblclick="document.location='system_usermanager.php?act=edit&amp;id=<?=$i;?>'">
875
							<td class="listlr">
876
								<table border="0" cellpadding="0" cellspacing="0" summary="icons">
877
									<tr>
878
										<td align="left" valign="middle">
879
<?php
880
											if($userent['scope'] != "user")
881
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
882
											else
883
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
884
?>
885
											<img src="<?=$usrimg;?>" alt="<?=gettext("User"); ?>" title="<?=gettext("User"); ?>" border="0" height="16" width="16" />
886
										</td>
887
										<td align="left" valign="middle">
888
											<?=htmlspecialchars($userent['name']);?>
889
										</td>
890
									</tr>
891
								</table>
892
							</td>
893
							<td class="listr"><?=htmlspecialchars($userent['descr']);?>&nbsp;</td>
894
							<td class="listr"><?php if(isset($userent['disabled'])) echo "*"; ?></td>
895
							<td class="listbg">
896
								<?=implode(",",local_user_get_groups($userent));?>
897
								&nbsp;
898
							</td>
899
							<td valign="middle" class="list nowrap">
900
								<a href="system_usermanager.php?act=edit&amp;id=<?=$i;?>">
901
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit user"); ?>" alt="<?=gettext("edit user"); ?>" width="17" height="17" border="0" />
902
								</a>
903
<?php
904
							if($userent['scope'] != "system"):
905
?>
906
								&nbsp;
907
								<a href="system_usermanager.php?act=deluser&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
908
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete user"); ?>" alt="<?=gettext("delete user"); ?>" width="17" height="17" border="0" />
909
								</a>
910
<?php
911
							endif;
912
?>
913
							</td>
914
						</tr>
915
<?php
916
						$i++;
917
					endforeach;
918
?>
919
					</tbody>
920
				</table>
921
<?php
922
			endif;
923
?>
924
			</div>
925
		</td>
926
	</tr>
927
</table>
928
<?php include("fend.inc");?>
929
</body>
930
</html>
(228-228/255)