Project

General

Profile

Download (33 KB) Statistics
| Branch: | Tag: | Revision:
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
$id = $_GET['id'];
57
if (isset($_POST['id']))
58
	$id = $_POST['id'];
59

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

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

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

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

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

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

    
94
	if (!$a_user[$id]) {
95
		pfSenseHeader("system_usermanager.php");
96
		exit;
97
	}
98

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

    
109
	if (!$a_user[$id]) {
110
		pfSenseHeader("system_usermanager.php");
111
		exit;
112
	}
113

    
114
	$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
115

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

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

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

    
133
	$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
134

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

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

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

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

    
170
if ($_POST) {
171
	unset($input_errors);
172
	$pconfig = $_POST;
173

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

    
196
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
197

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

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

    
204
	if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
205
		$input_errors[] = gettext("The passwords do not match.");
206

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

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

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

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

    
262
	if (!$input_errors) {
263
		conf_mount_rw();
264
		$userent = array();
265
		if (isset($id) && $a_user[$id])
266
			$userent = $a_user[$id];
267

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

    
270
		/* the user name was modified */
271
		if ($_POST['usernamefld'] <> $_POST['oldusername'])
272
			$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
273

    
274
		/* the user password was mofified */
275
		if ($_POST['passwordfld1'])
276
			local_user_set_password($userent, $_POST['passwordfld1']);
277

    
278
		$userent['name'] = $_POST['usernamefld'];
279
		$userent['descr'] = $_POST['descr'];
280
		$userent['expires'] = $_POST['expires'];
281
		$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
282
		$userent['ipsecpsk'] = $_POST['ipsecpsk'];
283
		
284
		if($_POST['disabled'])
285
			$userent['disabled'] = true;
286
		else 
287
			unset($userent['disabled']);
288

    
289
		if (isset($id) && $a_user[$id])
290
			$a_user[$id] = $userent;
291
		else {
292
			if (!empty($_POST['name'])) {
293
				$cert = array();
294
				$cert['refid'] = uniqid();
295
                       		$userent['cert'] = array();
296

    
297
				$cert['descr'] = $_POST['name'];
298

    
299
               			$subject = cert_get_subject_array($ca['crt']);
300

    
301
               			$dn = array(
302
                       			'countryName' => $subject[0]['v'],
303
                       			'stateOrProvinceName' => $subject[1]['v'],
304
                       			'localityName' => $subject[2]['v'],
305
                       			'organizationName' => $subject[3]['v'],
306
                       			'emailAddress' => $subject[4]['v'],
307
                       			'commonName' => $userent['name']);
308

    
309
				cert_create($cert, $_POST['caref'], $_POST['keylen'],
310
					(int)$_POST['lifetime'], $dn);
311

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

    
328
			$a_user[] = $userent;
329
		}
330

    
331
		local_user_set_groups($userent,$_POST['groups']);
332
		local_user_set($userent);
333
		write_config();
334

    
335
		if(is_dir("/etc/inc/privhooks"))
336
			run_plugins("/etc/inc/privhooks");
337

    
338
		conf_mount_ro();
339
		
340
		pfSenseHeader("system_usermanager.php");
341
	}
342
}
343

    
344
include("head.inc");
345
?>
346

    
347
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
348
<?php include("fbegin.inc"); ?>
349
<!--
350
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
351
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
352
//For this script, visit http://www.javascriptkit.com
353
// -->
354
<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js"></script>
355
<script language="JavaScript">
356
<!--
357

    
358
function setall_selected(id) {
359
	selbox = document.getElementById(id);
360
	count = selbox.options.length;
361
	for (index = 0; index<count; index++)
362
		selbox.options[index].selected = true;
363
}
364

    
365
function clear_selected(id) {
366
	selbox = document.getElementById(id);
367
	count = selbox.options.length;
368
	for (index = 0; index<count; index++)
369
		selbox.options[index].selected = false;
370
}
371

    
372
function remove_selected(id) {
373
	selbox = document.getElementById(id);
374
	index = selbox.options.length - 1;
375
	for (; index >= 0; index--)
376
		if (selbox.options[index].selected)
377
			selbox.remove(index);
378
}
379

    
380
function copy_selected(srcid, dstid) {
381
	src_selbox = document.getElementById(srcid);
382
	dst_selbox = document.getElementById(dstid);
383
	count = src_selbox.options.length;
384
	for (index = 0; index < count; index++) {
385
		if (src_selbox.options[index].selected) {
386
			option = document.createElement('option');
387
			option.text = src_selbox.options[index].text;
388
			option.value = src_selbox.options[index].value;
389
			dst_selbox.add(option, null);
390
		}
391
	}
392
}
393

    
394
function move_selected(srcid, dstid) {
395
	copy_selected(srcid, dstid);
396
	remove_selected(srcid);
397
}
398

    
399
function presubmit() {
400
	clear_selected('notgroups');
401
	setall_selected('groups');
402
}
403

    
404
function usercertClicked(obj) {
405
	if (obj.checked) {
406
		document.getElementById("usercertchck").style.display="none";
407
		document.getElementById("usercert").style.display="";
408
	} else {
409
		document.getElementById("usercert").style.display="none";
410
		document.getElementById("usercertchck").style.display="";
411
	}
412
}
413

    
414
function sshkeyClicked(obj) {
415
        if (obj.checked) {
416
                document.getElementById("sshkeychck").style.display="none";
417
                document.getElementById("sshkey").style.display="";
418
        } else {
419
                document.getElementById("sshkey").style.display="none";
420
                document.getElementById("sshkeychck").style.display="";
421
        }
422
}
423
//-->
424
</script>
425
<?php
426
	if ($input_errors)
427
		print_input_errors($input_errors);
428
	if ($savemsg)
429
		print_info_box($savemsg);
430
?>
431
<table width="100%" border="0" cellpadding="0" cellspacing="0">
432
	<tr>
433
		<td>
434
		<?php
435
			$tab_array = array();
436
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
437
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
438
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
439
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
440
			display_top_tabs($tab_array);
441
		?>
442
		</td>
443
	</tr>
444
	<tr>
445
		<td id="mainarea">
446
			<div class="tabcont">
447

    
448
				<?php if ($_GET['act'] == "new" || $_GET['act'] == "edit" || $input_errors): ?>
449

    
450
				<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
451
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
452
						<?php
453
							$ro = "";
454
							if ($pconfig['utype'] == "system")
455
								$ro = "readonly = \"readonly\"";
456
						?>
457
	                    <tr>
458
	                        <td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
459
	                        <td width="78%" class="vtable">
460
	                            <strong><?=strtoupper($pconfig['utype']);?></strong>
461
								<input name="utype" type="hidden" value="<?=htmlspecialchars($pconfig['utype'])?>"/>
462
	                        </td>
463
	                    </tr>
464
						<tr>
465
							<td width="22%" valign="top" class="vncell"><?=gettext("Disabled");?></td>
466
							<td width="78%" class="vtable">
467
								<input name="disabled" type="checkbox" id="disabled" <?php if($pconfig['disabled']) echo "CHECKED"; ?>>
468
							</td>
469
						</tr>
470
						<tr>
471
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
472
							<td width="78%" class="vtable">
473
								<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" maxlength="16" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
474
								<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
475
							</td>
476
						</tr>
477
						<tr>
478
							<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
479
							<td width="78%" class="vtable">
480
								<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
481
							</td>
482
						</tr>
483
						<tr>
484
							<td width="78%" class="vtable">
485
								<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
486
							</td>
487
						</tr>
488
						<tr>
489
							<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
490
							<td width="78%" class="vtable">
491
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>" <?=$ro;?>/>
492
								<br/>
493
								<?=gettext("User's full name, for your own information only");?>
494
							</td>
495
						</tr>
496
						<tr>
497
							<td width="22%" valign="top" class="vncell"><?=gettext("Expiration date"); ?></td>
498
							<td width="78%" class="vtable">
499
								<input name="expires" type="text" class="formfld unknown" id="expires" size="10" value="<?=htmlspecialchars($pconfig['expires']);?>">
500
								<a href="javascript:NewCal('expires','mmddyyyy')">
501
									<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_cal.gif" width="16" height="16" border="0" alt="<?=gettext("Pick a date");?>">
502
								</a>
503
								<br>
504
								<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>
505
						</tr>
506
						<tr>
507
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
508
							<td width="78%" class="vtable" align="center">
509
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
510
									<tr>
511
										<td align="center" width="50%">
512
											<strong><?=gettext("Not Member Of"); ?></strong><br/>
513
											<br/>
514
											<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onChange="clear_selected('groups')" multiple>
515
												<?php
516
													foreach ($config['system']['group'] as $group):
517
														if ($group['gid'] == 1998) /* all users group */
518
															continue;
519
														if (is_array($pconfig['groups']) && in_array($group['name'],$pconfig['groups']))
520
															continue;
521
												?>
522
												<option value="<?=$group['name'];?>" <?=$selected;?>>
523
													<?=htmlspecialchars($group['name']);?>
524
												</option>
525
												<?php endforeach; ?>
526
											</select>
527
											<br/>
528
										</td>
529
										<td>
530
											<br/>
531
											<a href="javascript:move_selected('notgroups','groups')">
532
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="<?=gettext("Add Groups"); ?>" alt="<?=gettext("Add Groups"); ?>" width="17" height="17" border="0" />
533
											</a>
534
											<br/><br/>
535
											<a href="javascript:move_selected('groups','notgroups')">
536
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="<?=gettext("Remove Groups"); ?>" alt="<?=gettext("Remove Groups"); ?>" width="17" height="17" border="0" />
537
											</a>
538
										</td>
539
										<td align="center" width="50%">
540
											<strong><?=gettext("Member Of"); ?></strong><br/>
541
											<br/>
542
											<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onChange="clear_selected('nogroups')" multiple>
543
												<?php
544
												if (is_array($pconfig['groups'])) {
545
													foreach ($config['system']['group'] as $group):
546
														if ($group['gid'] == 1998) /* all users group */
547
															continue;
548
														if (!in_array($group['name'],$pconfig['groups']))
549
															continue;
550
												?>
551
												<option value="<?=$group['name'];?>">
552
													<?=htmlspecialchars($group['name']);?>
553
												</option>
554
												<?php endforeach;
555
												} ?>
556
											</select>
557
											<br/>
558
										</td>
559
									</tr>
560
								</table>
561
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
562
							</td>
563
						</tr>
564

    
565
						<?php if (isset($pconfig['uid'])): ?>
566

    
567
						<tr>
568
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
569
							<td width="78%" class="vtable">
570
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
571
									<tr>
572
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
573
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
574
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
575
										<td class="list"></td>
576
									</tr>
577
									<?php
578
											
579
										$privdesc = get_user_privdesc($a_user[$id]);
580
										if(is_array($privdesc)):
581
											$i = 0;
582
											foreach ($privdesc as $priv):
583
											$group = false;
584
											if ($priv['group'])
585
												$group = $priv['group'];
586
									?>
587
									<tr>
588
										<td class="listlr"><?=$group;?></td>
589
										<td class="listr">
590
											<?=htmlspecialchars($priv['name']);?>
591
										</td>
592
										<td class="listbg">
593
												<?=htmlspecialchars($priv['descr']);?>
594
										</td>
595
										<td valign="middle" nowrap class="list">
596
											<?php if (!$group): ?>
597
											<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
598
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
599
											</a>
600
											<?php endif; ?>
601
										</td>
602
									</tr>
603
									<?php
604
											/* can only delete user priv indexes */
605
											if (!$group)
606
												$i++;
607
											endforeach;
608
										endif;
609
									?>
610
									<tr>
611
										<td class="list" colspan="3"></td>
612
										<td class="list">
613
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
614
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
615
											</a>
616
										</td>
617
									</tr>
618
								</table>
619
							</td>
620
						</tr>
621
						<tr>
622
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
623
							<td width="78%" class="vtable">
624
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
625
									<tr>
626
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
627
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
628
										<td class="list"></td>
629
									</tr>
630
									<?php
631
										
632
										$a_cert = $a_user[$id]['cert'];
633
										if(is_array($a_cert)):
634
											$i = 0;
635
											foreach ($a_cert as $certref):
636
												$cert = lookup_cert($certref);
637
												$ca = lookup_ca($cert['caref']);
638
									?>
639
									<tr>
640
										<td class="listlr">
641
											<?=htmlspecialchars($cert['descr']);?>
642
											<?php if (is_cert_revoked($cert)): ?>
643
											(<b>Revoked</b>)
644
											<?php endif; ?>
645
										</td>
646
										<td class="listr">
647
											<?=htmlspecialchars($ca['descr']);?>
648
										</td>
649
										<td valign="middle" nowrap class="list">
650
											<a href="system_usermanager.php?act=expckey&id=<?=$id;?>&certid=<?=$i;?>">
651
												<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" />
652
											</a>
653
											<a href="system_usermanager.php?act=expcert&id=<?=$id;?>&certid=<?=$i;?>">
654
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export cert"); ?>" alt="<?=gettext("export cert"); ?>" width="17" height="17" border="0" />
655
											</a>
656
											<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to remove this certificate association?") .'\n'. gettext("(Certificate will not be deleted)");?>')">
657
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="<?=gettext("delete cert");?>" />
658
											</a>
659
										</td>
660
									</tr>
661
									<?php
662
												$i++;
663
											endforeach;
664
										endif;
665
									?>
666
									<tr>
667
										<td class="list" colspan="2"></td>
668
										<td class="list">
669
											<a href="system_certmanager.php?act=new&userid=<?=$id?>">
670
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
671
											</a>
672
										</td>
673
									</tr>
674
								</table>
675
							</td>
676
						</tr>
677

    
678
						<?php else : ?>
679
						<?php 	if (is_array($config['ca']) && count($config['ca']) > 0): ?>
680
						<?php		$i = 0; foreach( $config['ca'] as $ca) {
681
                                                                        	if (!$ca['prv'])
682
                                                                                	continue;
683
										$i++;
684
									}
685
						?>
686

    
687
						<tr id="usercertchck" name="usercertchck" >
688
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
689
                                                	<td width="78%" class="vtable">
690
							<input type="checkbox" onClick="javascript:usercertClicked(this)"> <?=gettext("Click to create a user certificate."); ?>
691
							</td>
692
						</tr>
693

    
694
						<?php		if ($i > 0): ?>
695

    
696
						<tr id="usercert" name="usercert" style="display:none">
697
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
698
                                                	<td width="78%" class="vtable">
699
							<table width="100%" border="0" cellpadding="6" cellspacing="0">
700
							<tr>
701
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
702
                                                        	<td width="78%" class="vtable">
703
									<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
704
                                                        	</td>
705
                                                	</tr>
706
                                                	<tr>
707
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
708
                                                        	<td width="78%" class="vtable">
709
                                                                	<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
710
                                                                <?php
711
                                                                        foreach( $config['ca'] as $ca):
712
                                                                        if (!$ca['prv'])
713
                                                                                continue;
714
                                                                ?>
715
                                                                        <option value="<?=$ca['refid'];?>"><?=$ca['descr'];?></option>
716
                                                                <?php endforeach; ?>
717
                                                                	</select>
718
                                                        	</td>
719
                                                	</tr>
720
                                                	<tr>
721
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
722
                                                        	<td width="78%" class="vtable">
723
                                                                	<select name='keylen' class="formselect">
724
                                                                <?php
725
									$cert_keylens = array( "2048", "512", "1024", "4096");
726
                                                                        foreach( $cert_keylens as $len):
727
                                                                ?>
728
                                                                        <option value="<?=$len;?>"><?=$len;?></option>
729
                                                                <?php endforeach; ?>
730
                                                                	</select>
731
                                                                	bits
732
                                                        	</td>
733
                                                	</tr>
734
							<tr>
735
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
736
                                                        	<td width="78%" class="vtable">
737
                                                                	<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>days
738
                                                        	</td>
739
                                                	</tr>
740
						</table>
741
							</td>
742
						</tr>
743

    
744
						<?php 	endif; endif; ?>
745
						<?php endif; ?>
746

    
747
						<tr id="sshkeychck" name="sshkeychck" >
748
                                                        <td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
749
                                                        <td width="78%" class="vtable">
750
                                                        <input type="checkbox" onClick="javascript:sshkeyClicked(this)"> <?=gettext("Click to paste an authorized key."); ?>
751
                                                        </td>
752
                                                </tr>
753
						<tr id="sshkey" name="sshkey" style="display:none">
754
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
755
							<td width="78%" class="vtable">
756
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
757
								<br/>
758
								<?=gettext("Paste an authorized keys file here.");?>
759
							</td>
760
						</tr>
761
						<tr id="ipsecpskrow" name="ipsecpskrow">
762
							<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Pre-Shared Key");?></td>
763
							<td width="78%" class="vtable">
764
								<input name="ipsecpsk" type="text" class="formfld unknown" id="ipsecpsk" size="65" value="<?=htmlspecialchars($pconfig['ipsecpsk']);?>">
765
							</td>
766
						</tr>
767
						<tr>
768
							<td width="22%" valign="top">&nbsp;</td>
769
							<td width="78%">
770
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
771
								<?php if (isset($id) && $a_user[$id]): ?>
772
								<input name="id" type="hidden" value="<?=$id;?>" />
773
								<?php endif;?>
774
							</td>
775
						</tr>
776
					</table>
777
				</form>
778

    
779
				<?php else: ?>
780

    
781
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
782
					<tr>
783
						<td width="25%" class="listhdrr"><?=gettext("Username"); ?></td>
784
						<td width="25%" class="listhdrr"><?=gettext("Full name"); ?></td>
785
						<td width="5%" class="listhdrr"><?=gettext("Disabled"); ?></td>
786
						<td width="25%" class="listhdrr"><?=gettext("Groups"); ?></td>
787
						<td width="10%" class="list"></td>
788
					</tr>
789
					<?php
790
						$i = 0;
791
						foreach($a_user as $userent):
792
					?>
793
					<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
794
						<td class="listlr">
795
							<table border="0" cellpadding="0" cellspacing="0">
796
								<tr>
797
									<td align="left" valign="center">
798
										<?php
799
											if($userent['scope'] != "user")
800
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
801
											else
802
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
803
										?>
804
										<img src="<?=$usrimg;?>" alt="<?=gettext("User"); ?>" title="<?=gettext("User"); ?>" border="0" height="16" width="16" />
805
									</td>
806
									<td align="left" valign="middle">
807
										<?=htmlspecialchars($userent['name']);?>
808
									</td>
809
								</tr>
810
							</table>
811
						</td>
812
						<td class="listr"><?=htmlspecialchars($userent['descr']);?>&nbsp;</td>
813
						<td class="listr"><?php if(isset($userent['disabled'])) echo "*"; ?></td>
814
						<td class="listbg">
815
								<?=implode(",",local_user_get_groups($userent));?>
816
							&nbsp;
817
						</td>
818
						<td valign="middle" nowrap class="list">
819
							<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
820
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit user"); ?>" alt="<?=gettext("edit user"); ?>" width="17" height="17" border="0" />
821
							</a>
822
							<?php if($userent['scope'] != "system"): ?>
823
							&nbsp;
824
							<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
825
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete user"); ?>" alt="<?=gettext("delete user"); ?>" width="17" height="17" border="0" />
826
							</a>
827
							<?php endif; ?>
828
						</td>
829
					</tr>
830
					<?php
831
							$i++;
832
						endforeach;
833
					?>
834
					<tr>
835
						<td class="list" colspan="4"></td>
836
						<td class="list">
837
							<a href="system_usermanager.php?act=new">
838
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add user"); ?>" alt="<?=gettext("add user"); ?>" width="17" height="17" border="0" />
839
							</a>
840
						</td>
841
					</tr>
842
					<tr>
843
						<td colspan="4">
844
							<p>
845
								<?=gettext("Additional users can be added here. User permissions for accessing " .
846
								"the webConfigurator can be assigned directly or inherited from group memberships. " .
847
								"An icon that appears grey indicates that it is a system defined object. " .
848
								"Some system object properties can be modified but they cannot be deleted."); ?>
849
								<br/><br/>
850
								<?=gettext("Accounts created here are also used for other parts of the system " .
851
								"such as OpenVPN, IPsec, and Captive Portal.");?>
852
							</p>
853
						</td>
854
					</tr>
855
				</table>
856

    
857
				<?php endif; ?>
858

    
859
			</div>
860
		</td>
861
	</tr>
862
</table>
863
<?php include("fend.inc");?>
864
</body>
865
</html>
(212-212/239)