Project

General

Profile

Download (34.4 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
if (isAllowedPage("system_usermanager")) {
53

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

    
57
	$id = $_GET['id'];
58
	if (isset($_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 ($_GET['act'] == "deluser") {
67

    
68
		if (!$a_user[$id]) {
69
			pfSenseHeader("system_usermanager.php");
70
			exit;
71
		}
72

    
73
		local_user_del($a_user[$id]);
74
		$userdeleted = $a_user[$id]['name'];
75
		unset($a_user[$id]);
76
		write_config();
77
		$savemsg = gettext("User")." {$userdeleted} ".
78
					gettext("successfully deleted")."<br/>";
79
	}
80

    
81
	if ($_GET['act'] == "delpriv") {
82

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

    
88
		$privdeleted = $priv_list[$a_user[$id]['priv'][$_GET['privid']]]['name'];
89
		unset($a_user[$id]['priv'][$_GET['privid']]);
90
		write_config();
91
		$_GET['act'] = "edit";
92
		$savemsg = gettext("Privilege")." {$privdeleted} ".
93
					gettext("successfully deleted")."<br/>";
94
	}
95

    
96
	if ($_GET['act'] == "expcert") {
97

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

    
103
		$cert =& $a_user[$id]['cert'][$_GET['certid']];
104

    
105
		$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['name']}.crt");
106
		$exp_data = base64_decode($cert['crt']);
107
		$exp_size = strlen($exp_data);
108

    
109
		header("Content-Type: application/octet-stream");
110
		header("Content-Disposition: attachment; filename={$exp_name}");
111
		header("Content-Length: $exp_size");
112
		echo $exp_data;
113
		exit;
114
	}
115

    
116
	if ($_GET['act'] == "expckey") {
117

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

    
123
		$cert =& $a_user[$id]['cert'][$_GET['certid']];
124

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

    
129
		header("Content-Type: application/octet-stream");
130
		header("Content-Disposition: attachment; filename={$exp_name}");
131
		header("Content-Length: $exp_size");
132
		echo $exp_data;
133
		exit;
134
	}
135

    
136
	if ($_GET['act'] == "delcert") {
137

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

    
143
		$certdeleted = $a_user[$id]['cert'][$_GET['certid']]['name'];
144
		unset($a_user[$id]['cert'][$_GET['certid']]);
145
		write_config();
146
		$_GET['act'] = "edit";
147
		$savemsg = gettext("Certificate")." {$certdeleted} ".
148
					gettext("successfully deleted")."<br/>";
149
	}
150

    
151
	if ($_GET['act'] == "edit") {
152
		if (isset($id) && $a_user[$id]) {
153
			$pconfig['usernamefld'] = $a_user[$id]['name'];
154
			$pconfig['fullname'] = $a_user[$id]['fullname'];
155
			$pconfig['expires'] = $a_user[$id]['expires'];
156
			$pconfig['groups'] = local_user_get_groups($a_user[$id]);
157
			$pconfig['utype'] = $a_user[$id]['scope'];
158
			$pconfig['uid'] = $a_user[$id]['uid'];
159
			$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
160
			$pconfig['priv'] = $a_user[$id]['priv'];
161
			$pconfig['ipsecpsk'] = $a_user[$id]['ipsecpsk'];
162
			$pconfig['disabled'] = isset($a_user[$id]['disabled']);
163
		}
164
	}
165

    
166
	if ($_GET['act'] == "new") {
167
		/*
168
		 * set this value cause the text field is read only
169
		 * and the user should not be able to mess with this
170
		 * setting.
171
		 */
172
		$pconfig['utype'] = "user";
173
		$pconfig['lifetime'] = 3650;
174
	}
175

    
176
	if ($_POST) {
177
		conf_mount_rw();
178
		unset($input_errors);
179
		$pconfig = $_POST;
180

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

    
203
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
204

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

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

    
211
		/* make sure this user name is unique */
212
		if (!$input_errors && !(isset($id) && $a_user[$id])) {
213
			foreach ($a_user as $userent) {
214
				if ($userent['name'] == $_POST['usernamefld']) {
215
					$input_errors[] = gettext("Another entry with the same username already exists.");
216
					break;
217
				}
218
			}
219
		}
220

    
221
		/*
222
		 * Check for a valid expirationdate if one is set at all (valid means,
223
		 * strtotime() puts out a time stamp so any strtotime compatible time
224
		 * format may be used. to keep it simple for the enduser, we only
225
		 * claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
226
		 * like "+1 day", which will be converted to MM/DD/YYYY based on "now".
227
		 * Otherwhise such an entry would lead to an invalid expiration data.
228
		 */
229
		if ($_POST['expires']){
230
			if(strtotime($_POST['expires']) > 0){
231
				if (strtotime("-1 day") > strtotime(date("m/d/Y",strtotime($_POST['expires'])))) {
232
					// Allow items to lie in the past which ends up disabling.
233
				} else {
234
					//convert from any strtotime compatible date to MM/DD/YYYY
235
					$expdate = strtotime($_POST['expires']);
236
					$_POST['expires'] = date("m/d/Y",$expdate);
237
				}
238
			} else {
239
				$input_errors[] = gettext("Invalid expiration date format; use MM/DD/YYYY instead.");
240
			}
241
		}
242

    
243
		if (!empty($_POST['name'])) {
244
			$ca = lookup_ca($_POST['caref']);
245
        		if (!$ca)
246
                		$input_errors[] = gettext("Invalid internal Certificate Authority") . "\n";
247
		}
248

    
249
		/* if this is an AJAX caller then handle via JSON */
250
		if (isAjax() && is_array($input_errors)) {
251
			input_errors2Ajax($input_errors);
252
			exit;
253
		}
254

    
255
		if (!$input_errors) {
256
			$userent = array();
257
			if (isset($id) && $a_user[$id])
258
				$userent = $a_user[$id];
259

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

    
262
			/* the user name was modified */
263
			if ($_POST['usernamefld'] <> $_POST['oldusername'])
264
				$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
265

    
266
			/* the user password was mofified */
267
			if ($_POST['passwordfld1'])
268
				local_user_set_password($userent, $_POST['passwordfld1']);
269

    
270
			$userent['name'] = $_POST['usernamefld'];
271
			$userent['fullname'] = $_POST['fullname'];
272
			$userent['expires'] = $_POST['expires'];
273
			$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
274
			$userent['ipsecpsk'] = $_POST['ipsecpsk'];
275
			
276
			if($_POST['disabled'])
277
				$userent['disabled'] = true;
278
			else 
279
				unset($userent['disabled']);
280

    
281
			if (isset($id) && $a_user[$id])
282
				$a_user[$id] = $userent;
283
			else {
284
				if (!empty($_POST['name'])) {
285
					$cert = array();
286
                        		$userent['cert'] = array();
287

    
288
            				$cert['name'] = $_POST['name'];
289

    
290
                			$subject = cert_get_subject_array($ca['crt']);
291

    
292
                			$dn = array(
293
                        			'countryName' => $subject[0]['v'],
294
                        			'stateOrProvinceName' => $subject[1]['v'],
295
                        			'localityName' => $subject[2]['v'],
296
                        			'organizationName' => $subject[3]['v'],
297
                        			'emailAddress' => $subject[4]['v'],
298
                        			'commonName' => $userent['name']);
299

    
300
					cert_create($cert, $_POST['caref'], $_POST['keylen'],
301
						(int)$_POST['lifetime'], $dn);
302

    
303
					$userent['cert'][] = $cert;
304
				}
305
				$userent['uid'] = $config['system']['nextuid']++;
306
				$a_user[] = $userent;
307
			}
308

    
309
			local_user_set($userent);
310
			local_user_set_groups($userent,$_POST['groups']);
311
			write_config();
312

    
313
			if(is_dir("/etc/inc/privhooks"))
314
				run_plugins("/etc/inc/privhooks");
315

    
316
			conf_mount_ro();
317
			
318
			pfSenseHeader("system_usermanager.php");
319
		}
320
	}
321

    
322
	include("head.inc");
323
?>
324

    
325
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
326
<?php include("fbegin.inc"); ?>
327
<!--
328
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
329
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
330
//For this script, visit http://www.javascriptkit.com
331
// -->
332
<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js"></script>
333
<script language="JavaScript">
334
<!--
335

    
336
function setall_selected(id) {
337
	selbox = document.getElementById(id);
338
	count = selbox.options.length;
339
	for (index = 0; index<count; index++)
340
		selbox.options[index].selected = true;
341
}
342

    
343
function clear_selected(id) {
344
	selbox = document.getElementById(id);
345
	count = selbox.options.length;
346
	for (index = 0; index<count; index++)
347
		selbox.options[index].selected = false;
348
}
349

    
350
function remove_selected(id) {
351
	selbox = document.getElementById(id);
352
	index = selbox.options.length - 1;
353
	for (; index >= 0; index--)
354
		if (selbox.options[index].selected)
355
			selbox.remove(index);
356
}
357

    
358
function copy_selected(srcid, dstid) {
359
	src_selbox = document.getElementById(srcid);
360
	dst_selbox = document.getElementById(dstid);
361
	count = src_selbox.options.length;
362
	for (index = 0; index < count; index++) {
363
		if (src_selbox.options[index].selected) {
364
			option = document.createElement('option');
365
			option.text = src_selbox.options[index].text;
366
			option.value = src_selbox.options[index].value;
367
			dst_selbox.add(option, null);
368
		}
369
	}
370
}
371

    
372
function move_selected(srcid, dstid) {
373
	copy_selected(srcid, dstid);
374
	remove_selected(srcid);
375
}
376

    
377
function presubmit() {
378
	clear_selected('notgroups');
379
	setall_selected('groups');
380
}
381

    
382
function usercertClicked(obj) {
383
	if (obj.checked) {
384
		document.getElementById("usercertchck").style.display="none";
385
		document.getElementById("usercert").style.display="";
386
	} else {
387
		document.getElementById("usercert").style.display="none";
388
		document.getElementById("usercertchck").style.display="";
389
	}
390
}
391

    
392
function sshkeyClicked(obj) {
393
        if (obj.checked) {
394
                document.getElementById("sshkeychck").style.display="none";
395
                document.getElementById("sshkey").style.display="";
396
        } else {
397
                document.getElementById("sshkey").style.display="none";
398
                document.getElementById("sshkeychck").style.display="";
399
        }
400
}
401
//-->
402
</script>
403
<?php
404
	if ($input_errors)
405
		print_input_errors($input_errors);
406
	if ($savemsg)
407
		print_info_box($savemsg);
408
?>
409
<table width="100%" border="0" cellpadding="0" cellspacing="0">
410
	<tr>
411
		<td>
412
		<?php
413
			$tab_array = array();
414
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
415
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
416
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
417
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
418
			display_top_tabs($tab_array);
419
		?>
420
		</td>
421
	</tr>
422
	<tr>
423
		<td id="mainarea">
424
			<div class="tabcont">
425

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

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

    
541
						<?php if ($pconfig['uid']): ?>
542

    
543
						<tr>
544
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
545
							<td width="78%" class="vtable">
546
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
547
									<tr>
548
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
549
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
550
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
551
										<td class="list"></td>
552
									</tr>
553
									<?php
554
											
555
										$privdesc = get_user_privdesc($a_user[$id]);
556
										if(is_array($privdesc)):
557
											$i = 0;
558
											foreach ($privdesc as $priv):
559
											$group = false;
560
											if ($priv['group'])
561
												$group = $priv['group'];
562
									?>
563
									<tr>
564
										<td class="listlr"><?=$group;?></td>
565
										<td class="listr">
566
											<?=htmlspecialchars($priv['name']);?>
567
										</td>
568
										<td class="listbg">
569
												<?=htmlspecialchars($priv['descr']);?>
570
										</td>
571
										<td valign="middle" nowrap class="list">
572
											<?php if (!$group): ?>
573
											<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
574
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
575
											</a>
576
											<?php endif; ?>
577
										</td>
578
									</tr>
579
									<?php
580
											/* can only delete user priv indexes */
581
											if (!$group)
582
												$i++;
583
											endforeach;
584
										endif;
585
									?>
586
									<tr>
587
										<td class="list" colspan="3"></td>
588
										<td class="list">
589
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
590
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
591
											</a>
592
										</td>
593
									</tr>
594
								</table>
595
							</td>
596
						</tr>
597
						<tr>
598
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
599
							<td width="78%" class="vtable">
600
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
601
									<tr>
602
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
603
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
604
										<td class="list"></td>
605
									</tr>
606
									<?php
607
										
608
										$a_cert = $a_user[$id]['cert'];
609
										if(is_array($a_cert)):
610
											$i = 0;
611
											foreach ($a_cert as $cert):
612
						                        $ca = lookup_ca($cert['caref']);
613
									?>
614
									<tr>
615
										<td class="listlr">
616
											<?=htmlspecialchars($cert['name']);?>
617
										</td>
618
										<td class="listr">
619
											<?=htmlspecialchars($ca['name']);?>
620
										</td>
621
										<td valign="middle" nowrap class="list">
622
											<a href="system_usermanager.php?act=expckey&id=<?=$id;?>&certid=<?=$i;?>">
623
												<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" />
624
											</a>
625
											<a href="system_usermanager.php?act=expcert&id=<?=$id;?>&certid=<?=$i;?>">
626
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export cert"); ?>" alt="<?=gettext("export cert"); ?>" width="17" height="17" border="0" />
627
											</a>
628
											<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this certificate?");?>')">
629
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="<?=gettext("delete cert");?>" />
630
											</a>
631
										</td>
632
									</tr>
633
									<?php
634
												$i++;
635
											endforeach;
636
										endif;
637
									?>
638
									<tr>
639
										<td class="list" colspan="2"></td>
640
										<td class="list">
641
											<a href="system_usermanager_addcert.php?userid=<?=$id?>">
642
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
643
											</a>
644
										</td>
645
									</tr>
646
								</table>
647
							</td>
648
						</tr>
649

    
650
						<?php else : ?>
651
						<?php 	if (is_array($config['system']['ca']) && count($config['system']['ca']) > 0): ?>
652
						<?php		$i = 0; foreach( $config['system']['ca'] as $ca) {
653
                                                                        	if (!$ca['prv'])
654
                                                                                	continue;
655
										$i++;
656
									}
657
						?>
658

    
659
						<tr id="usercertchck" name="usercertchck" >
660
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
661
                                                	<td width="78%" class="vtable">
662
							<input type="checkbox" onClick="javascript:usercertClicked(this)"> <?=gettext("Click to create a user certificate."); ?>
663
							</td>
664
						</tr>
665

    
666
						<?php		if ($i > 0): ?>
667

    
668
						<tr id="usercert" name="usercert" style="display:none">
669
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
670
                                                	<td width="78%" class="vtable">
671
							<table width="100%" border="0" cellpadding="6" cellspacing="0">
672
							<tr>
673
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
674
                                                        	<td width="78%" class="vtable">
675
                                                                	<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
676
                                                        	</td>
677
                                                	</tr>
678
                                                	<tr>
679
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
680
                                                        	<td width="78%" class="vtable">
681
                                                                	<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
682
                                                                <?php
683
                                                                        foreach( $config['system']['ca'] as $ca):
684
                                                                        if (!$ca['prv'])
685
                                                                                continue;
686
                                                                ?>
687
                                                                        <option value="<?=$ca['refid'];?>"><?=$ca['name'];?></option>
688
                                                                <?php endforeach; ?>
689
                                                                	</select>
690
                                                        	</td>
691
                                                	</tr>
692
                                                	<tr>
693
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
694
                                                        	<td width="78%" class="vtable">
695
                                                                	<select name='keylen' class="formselect">
696
                                                                <?php
697
									$cert_keylens = array( "2048", "512", "1024", "4096");
698
                                                                        foreach( $cert_keylens as $len):
699
                                                                ?>
700
                                                                        <option value="<?=$len;?>"><?=$len;?></option>
701
                                                                <?php endforeach; ?>
702
                                                                	</select>
703
                                                                	bits
704
                                                        	</td>
705
                                                	</tr>
706
							<tr>
707
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
708
                                                        	<td width="78%" class="vtable">
709
                                                                	<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>days
710
                                                        	</td>
711
                                                	</tr>
712
						</table>
713
							</td>
714
						</tr>
715

    
716
						<?php 	endif; endif; ?>
717
						<?php endif; ?>
718

    
719
						<tr id="sshkeychck" name="sshkeychck" >
720
                                                        <td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
721
                                                        <td width="78%" class="vtable">
722
                                                        <input type="checkbox" onClick="javascript:sshkeyClicked(this)"> <?=gettext("Click to paste an authorized key."); ?>
723
                                                        </td>
724
                                                </tr>
725
						<tr id="sshkey" name="sshkey" style="display:none">
726
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
727
							<td width="78%" class="vtable">
728
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
729
								<br/>
730
								<?=gettext("Paste an authorized keys file here.");?>
731
							</td>
732
						</tr>
733
						<tr id="ipsecpskrow" name="ipsecpskrow">
734
							<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Pre-Shared Key");?></td>
735
							<td width="78%" class="vtable">
736
								<input name="ipsecpsk" type="text" class="formfld unknown" id="ipsecpsk" size="65" value="<?=htmlspecialchars($pconfig['ipsecpsk']);?>">
737
							</td>
738
						</tr>
739
						<tr>
740
							<td width="22%" valign="top">&nbsp;</td>
741
							<td width="78%">
742
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
743
								<?php if (isset($id) && $a_user[$id]): ?>
744
								<input name="id" type="hidden" value="<?=$id;?>" />
745
								<?php endif;?>
746
							</td>
747
						</tr>
748
					</table>
749
				</form>
750

    
751
				<?php else: ?>
752

    
753
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
754
					<tr>
755
						<td width="25%" class="listhdrr"><?=gettext("Username"); ?></td>
756
						<td width="25%" class="listhdrr"><?=gettext("Full name"); ?></td>
757
						<td width="5%" class="listhdrr"><?=gettext("Disabled"); ?></td>
758
						<td width="25%" class="listhdrr"><?=gettext("Groups"); ?></td>
759
						<td width="10%" class="list"></td>
760
					</tr>
761
					<?php
762
						$i = 0;
763
						foreach($a_user as $userent):
764
					?>
765
					<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
766
						<td class="listlr">
767
							<table border="0" cellpadding="0" cellspacing="0">
768
								<tr>
769
									<td align="left" valign="center">
770
										<?php
771
											if($userent['scope'] != "user")
772
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
773
											else
774
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
775
										?>
776
										<img src="<?=$usrimg;?>" alt="<?=gettext("User"); ?>" title="<?=gettext("User"); ?>" border="0" height="16" width="16" />
777
									</td>
778
									<td align="left" valign="middle">
779
										<?=htmlspecialchars($userent['name']);?>
780
									</td>
781
								</tr>
782
							</table>
783
						</td>
784
						<td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
785
						<td class="listr"><?php if(isset($userent['disabled'])) echo "*"; ?></td>
786
						<td class="listbg">
787
								<?=implode(",",local_user_get_groups($userent));?>
788
							&nbsp;
789
						</td>
790
						<td valign="middle" nowrap class="list">
791
							<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
792
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit user"); ?>" alt="<?=gettext("edit user"); ?>" width="17" height="17" border="0" />
793
							</a>
794
							<?php if($userent['scope'] != "system"): ?>
795
							&nbsp;
796
							<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
797
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete user"); ?>" alt="<?=gettext("delete user"); ?>" width="17" height="17" border="0" />
798
							</a>
799
							<?php endif; ?>
800
						</td>
801
					</tr>
802
					<?php
803
							$i++;
804
						endforeach;
805
					?>
806
					<tr>
807
						<td class="list" colspan="4"></td>
808
						<td class="list">
809
							<a href="system_usermanager.php?act=new">
810
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add user"); ?>" alt="<?=gettext("add user"); ?>" width="17" height="17" border="0" />
811
							</a>
812
						</td>
813
					</tr>
814
					<tr>
815
						<td colspan="4">
816
							<p>
817
								<?=gettext("Additional webConfigurator users can be added here.
818
								User permissions can be assigned directly or inherited from group memberships.
819
								An icon that appears grey indicates that it is a system defined object. 
820
								Some system object properties can be modified but they cannot be deleted."); ?>
821
							</p>
822
						</td>
823
					</tr>
824
				</table>
825

    
826
				<?php endif; ?>
827

    
828
			</div>
829
		</td>
830
	</tr>
831
</table>
832
<?php include("fend.inc");?>
833
</body>
834

    
835
<?php
836

    
837
	// end admin user code
838

    
839
} else {
840

    
841
	// start normal user code
842

    
843
	$pgtitle = array(gettext("System"),gettext("User Password"));
844

    
845
	if (isset($_POST['save'])) {
846
		unset($input_errors);
847

    
848
		/* input validation */
849
		$reqdfields = explode(" ", "passwordfld1");
850
		$reqdfieldsn = array(gettext("Password"));
851

    
852
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
853

    
854
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
855
			$input_errors[] = gettext("The passwords do not match.");
856

    
857
		if (!$input_errors) {
858
			// all values are okay --> saving changes
859
			$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['password'] = crypt(trim($_POST['passwordfld1']));
860

    
861
			write_config();
862
			$savemsg = gettext("Password successfully changed") . "<br />";
863
		}
864
	}
865

    
866
	/* determine if user is not local to system */
867
	$islocal = false;
868
	foreach($config['system']['user'] as $user) 
869
		if($user['name'] == $_SESSION['Username'])
870
			$islocal = true;
871
?>
872

    
873
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
874
<?php
875
    include("head.inc");
876
	include("fbegin.inc");
877
	if ($input_errors)
878
		print_input_errors($input_errors);
879
	if ($savemsg)
880
		print_info_box($savemsg);
881

    
882
	if($islocal == false) {
883
		echo gettext("Sorry, you cannot change the password for a LDAP user.");
884
		include("fend.inc");
885
		exit;
886
	}
887
?>
888
<div id="mainarea">
889
	<div class="tabcont">
890
		<form action="system_usermanager.php" method="post" name="iform" id="iform">
891
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
892
				<tr>
893
					<td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s <?=gettext("Password"); ?></td>
894
				</tr>
895
				<tr>
896
					<td width="22%" valign="top" class="vncell" rowspan="2"><?=gettext("Password"); ?></td>
897
					<td width="78%" class="vtable">
898
						<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
899
					</td>
900
				</tr>
901
				<tr>
902
					<td width="78%" class="vtable">
903
						<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
904
						&nbsp;<?=gettext("(confirmation)");?>
905
						<br/>
906
						<span class="vexpl">
907
							<?=gettext("Select a new password");?>
908
						</span>
909
					</td>
910
				</tr>
911
				<tr>
912
					<td width="22%" valign="top">&nbsp;</td>
913
					<td width="78%">
914
						<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
915
					</td>
916
				</tr>
917
			</table>
918
		</form>
919
	</div>
920
</div>
921
<?php include("fend.inc");?>
922
</body>
923

    
924
<?php
925

    
926
} // end of normal user code
927

    
928
?>
(193-193/221)