Projet

Général

Profil

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

univnautes / usr / local / www / system_usermanager.php @ 7c2d0050

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($_SERVER['HTTP_REFERER']))
67
	$referer = $_SERVER['HTTP_REFERER'];
68
else
69
	$referer = '/system_usermanager.php';
70

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

    
84
if ($_GET['act'] == "deluser") {
85

    
86
	if (!$a_user[$id]) {
87
		pfSenseHeader("system_usermanager.php");
88
		exit;
89
	}
90

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

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

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

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

    
122
	$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
123

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

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

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

    
141
	$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
142

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

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

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

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

    
178
if ($_POST) {
179
	unset($input_errors);
180
	$pconfig = $_POST;
181

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

    
204
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
205

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

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

    
212
	if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
213
		$input_errors[] = gettext("The passwords do not match.");
214

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

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

    
258
	if (!empty($_POST['name'])) {
259
		$ca = lookup_ca($_POST['caref']);
260
		if (!$ca)
261
			$input_errors[] = gettext("Invalid internal Certificate Authority") . "\n";
262
	}
263

    
264
	/* if this is an AJAX caller then handle via JSON */
265
	if (isAjax() && is_array($input_errors)) {
266
		input_errors2Ajax($input_errors);
267
		exit;
268
	}
269

    
270
	if (!$input_errors) {
271
		conf_mount_rw();
272
		$userent = array();
273
		if (isset($id) && $a_user[$id])
274
			$userent = $a_user[$id];
275

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

    
278
		/* the user name was modified */
279
		if ($_POST['usernamefld'] <> $_POST['oldusername']) {
280
			$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
281
			local_user_del($userent);
282
		}
283

    
284
		/* the user password was mofified */
285
		if ($_POST['passwordfld1'])
286
			local_user_set_password($userent, $_POST['passwordfld1']);
287

    
288
		$userent['name'] = $_POST['usernamefld'];
289
		$userent['descr'] = $_POST['descr'];
290
		$userent['expires'] = $_POST['expires'];
291
		$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
292
		$userent['ipsecpsk'] = $_POST['ipsecpsk'];
293

    
294
		if($_POST['disabled'])
295
			$userent['disabled'] = true;
296
		else
297
			unset($userent['disabled']);
298

    
299
		if (isset($id) && $a_user[$id])
300
			$a_user[$id] = $userent;
301
		else {
302
			if (!empty($_POST['name'])) {
303
				$cert = array();
304
				$cert['refid'] = uniqid();
305
				$userent['cert'] = array();
306

    
307
				$cert['descr'] = $_POST['name'];
308

    
309
				$subject = cert_get_subject_array($ca['crt']);
310

    
311
				$dn = array(
312
					'countryName' => $subject[0]['v'],
313
					'stateOrProvinceName' => $subject[1]['v'],
314
					'localityName' => $subject[2]['v'],
315
					'organizationName' => $subject[3]['v'],
316
					'emailAddress' => $subject[4]['v'],
317
					'commonName' => $userent['name']);
318

    
319
				cert_create($cert, $_POST['caref'], $_POST['keylen'],
320
					(int)$_POST['lifetime'], $dn);
321

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

    
338
			$a_user[] = $userent;
339
		}
340

    
341
		local_user_set_groups($userent,$_POST['groups']);
342
		local_user_set($userent);
343
		write_config();
344

    
345
		if(is_dir("/etc/inc/privhooks"))
346
			run_plugins("/etc/inc/privhooks");
347

    
348
		conf_mount_ro();
349

    
350
		pfSenseHeader("system_usermanager.php");
351
	}
352
}
353

    
354
$closehead = false;
355
include("head.inc");
356
?>
357

    
358
<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
359
<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui.custom.css" />
360

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

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

    
373
<script type="text/javascript">
374
//<![CDATA[
375

    
376
function setall_selected(id) {
377
	selbox = document.getElementById(id);
378
	count = selbox.options.length;
379
	for (index = 0; index<count; index++)
380
		selbox.options[index].selected = true;
381
}
382

    
383
function clear_selected(id) {
384
	selbox = document.getElementById(id);
385
	count = selbox.options.length;
386
	for (index = 0; index<count; index++)
387
		selbox.options[index].selected = false;
388
}
389

    
390
function remove_selected(id) {
391
	selbox = document.getElementById(id);
392
	index = selbox.options.length - 1;
393
	for (; index >= 0; index--)
394
		if (selbox.options[index].selected)
395
			selbox.remove(index);
396
}
397

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

    
418
function move_selected(srcid, dstid) {
419
	copy_selected(srcid, dstid);
420
	remove_selected(srcid);
421
}
422

    
423
function presubmit() {
424
	clear_selected('notgroups');
425
	setall_selected('groups');
426
}
427

    
428
function usercertClicked(obj) {
429
	if (obj.checked) {
430
		document.getElementById("usercertchck").style.display="none";
431
		document.getElementById("usercert").style.display="";
432
	} else {
433
		document.getElementById("usercert").style.display="none";
434
		document.getElementById("usercertchck").style.display="";
435
	}
436
}
437

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

    
717
<?php
718
					else:
719
						if (is_array($config['ca']) && count($config['ca']) > 0):
720
							$i = 0;
721
							foreach( $config['ca'] as $ca) {
722
								if (!$ca['prv'])
723
									continue;
724
								$i++;
725
							}
726
?>
727

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

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