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
	 * strtotime() puts out a time stamp so any strtotime 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
		if(strtotime($_POST['expires']) > 0){
242
			if (strtotime("-1 day") > strtotime(date("m/d/Y",strtotime($_POST['expires'])))) {
243
				// Allow items to lie in the past which ends up disabling.
244
			} else {
245
				//convert from any strtotime compatible date to MM/DD/YYYY
246
				$expdate = strtotime($_POST['expires']);
247
				$_POST['expires'] = date("m/d/Y",$expdate);
248
			}
249
		} else {
250
			$input_errors[] = gettext("Invalid expiration date format; use MM/DD/YYYY instead.");
251
		}
252
	}
253

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

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

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

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

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

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

    
282
		$userent['name'] = $_POST['usernamefld'];
283
		$userent['descr'] = $_POST['descr'];
284
		$userent['expires'] = $_POST['expires'];
285
		$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
286
		$userent['ipsecpsk'] = $_POST['ipsecpsk'];
287
		
288
		if($_POST['disabled'])
289
			$userent['disabled'] = true;
290
		else 
291
			unset($userent['disabled']);
292

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

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

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

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

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

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

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

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

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

    
342
		conf_mount_ro();
343
		
344
		pfSenseHeader("system_usermanager.php");
345
	}
346
}
347

    
348
include("head.inc");
349
?>
350

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

    
362
function setall_selected(id) {
363
	selbox = document.getElementById(id);
364
	count = selbox.options.length;
365
	for (index = 0; index<count; index++)
366
		selbox.options[index].selected = true;
367
}
368

    
369
function clear_selected(id) {
370
	selbox = document.getElementById(id);
371
	count = selbox.options.length;
372
	for (index = 0; index<count; index++)
373
		selbox.options[index].selected = false;
374
}
375

    
376
function remove_selected(id) {
377
	selbox = document.getElementById(id);
378
	index = selbox.options.length - 1;
379
	for (; index >= 0; index--)
380
		if (selbox.options[index].selected)
381
			selbox.remove(index);
382
}
383

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

    
398
function move_selected(srcid, dstid) {
399
	copy_selected(srcid, dstid);
400
	remove_selected(srcid);
401
}
402

    
403
function presubmit() {
404
	clear_selected('notgroups');
405
	setall_selected('groups');
406
}
407

    
408
function usercertClicked(obj) {
409
	if (obj.checked) {
410
		document.getElementById("usercertchck").style.display="none";
411
		document.getElementById("usercert").style.display="";
412
	} else {
413
		document.getElementById("usercert").style.display="none";
414
		document.getElementById("usercertchck").style.display="";
415
	}
416
}
417

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

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

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

    
569
						<?php if ($pconfig['uid']): ?>
570

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

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

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

    
698
						<?php		if ($i > 0): ?>
699

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

    
748
						<?php 	endif; endif; ?>
749
						<?php endif; ?>
750

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

    
783
				<?php else: ?>
784

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

    
858
				<?php endif; ?>
859

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