Project

General

Profile

Download (26.4 KB) Statistics
| Branch: | Tag: | Revision:
1 1df17ba9 Scott Ullrich
<?php
2
/* $Id$ */
3 fab7ff44 Bill Marquette
/*
4 1df17ba9 Scott Ullrich
    system_usermanager.php
5
    part of m0n0wall (http://m0n0.ch/wall)
6
7 6b07c15a Matthew Grooms
    Copyright (C) 2008 Shrew Soft Inc.
8
    All rights reserved.
9
10 1df17ba9 Scott Ullrich
    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 fab7ff44 Bill Marquette
*/
37 1d333258 Scott Ullrich
/*
38
	pfSense_BUILDER_BINARIES:	
39
	pfSense_MODULE:	auth
40
*/
41 fab7ff44 Bill Marquette
42 6b07c15a Matthew Grooms
##|+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 ead24d63 sullrich
require("certs.inc");
50 fab7ff44 Bill Marquette
require("guiconfig.inc");
51 ead24d63 sullrich
require("priv.defs.inc");
52 5092a6fb sullrich
require("priv.inc");
53 fab7ff44 Bill Marquette
54 45ee90ed Matthew Grooms
if (isAllowedPage("system_usermanager")) {
55 31b53653 Scott Ullrich
56 45ee90ed Matthew Grooms
	// start admin user code
57
	$pgtitle = array("System","User Manager");
58 fab7ff44 Bill Marquette
59 45ee90ed Matthew Grooms
	$id = $_GET['id'];
60
	if (isset($_POST['id']))
61
		$id = $_POST['id'];
62 1df17ba9 Scott Ullrich
63 7e4a4513 Scott Ullrich
	if (!is_array($config['system']['user'])) 
64
		$config['system']['user'] = array();
65 1df17ba9 Scott Ullrich
66 6b07c15a Matthew Grooms
	$a_user = &$config['system']['user'];
67 45ee90ed Matthew Grooms
68 6b07c15a Matthew Grooms
	if ($_GET['act'] == "deluser") {
69 45ee90ed Matthew Grooms
70 58fdb8ad Matthew Grooms
		if (!$a_user[$id]) {
71 6b07c15a Matthew Grooms
			pfSenseHeader("system_usermanager.php");
72
			exit;
73 45ee90ed Matthew Grooms
		}
74
75 58fdb8ad Matthew Grooms
		local_user_del($a_user[$id]);
76
		$userdeleted = $a_user[$id]['name'];
77
		unset($a_user[$id]);
78 6b07c15a Matthew Grooms
		write_config();
79
		$savemsg = gettext("User")." {$userdeleted} ".
80
					gettext("successfully deleted")."<br/>";
81
	}
82
83
	if ($_GET['act'] == "delpriv") {
84
85 58fdb8ad Matthew Grooms
		if (!$a_user[$id]) {
86 6b07c15a Matthew Grooms
			pfSenseHeader("system_usermanager.php");
87
			exit;
88 45ee90ed Matthew Grooms
		}
89 6b07c15a Matthew Grooms
90
		$privdeleted = $priv_list[$a_user[$id]['priv'][$_GET['privid']]]['name'];
91
		unset($a_user[$id]['priv'][$_GET['privid']]);
92
		write_config();
93
		$_GET['act'] = "edit";
94
		$savemsg = gettext("Privilege")." {$privdeleted} ".
95
					gettext("successfully deleted")."<br/>";
96 45ee90ed Matthew Grooms
	}
97
98 93823b10 Matthew Grooms
	if ($_GET['act'] == "expcert") {
99
100
		if (!$a_user[$id]) {
101
			pfSenseHeader("system_usermanager.php");
102
			exit;
103
		}
104
105
		$cert =& $a_user[$id]['cert'][$_GET['certid']];
106
107
		$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['name']}.crt");
108
		$exp_data = base64_decode($cert['crt']);
109
		$exp_size = strlen($exp_data);
110
111
		header("Content-Type: application/octet-stream");
112
		header("Content-Disposition: attachment; filename={$exp_name}");
113
		header("Content-Length: $exp_size");
114
		echo $exp_data;
115
		exit;
116
	}
117
118
	if ($_GET['act'] == "expckey") {
119
120
		if (!$a_user[$id]) {
121
			pfSenseHeader("system_usermanager.php");
122
			exit;
123
		}
124
125
		$cert =& $a_user[$id]['cert'][$_GET['certid']];
126
127
		$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['name']}.key");
128
		$exp_data = base64_decode($cert['prv']);
129
		$exp_size = strlen($exp_data);
130
131
		header("Content-Type: application/octet-stream");
132
		header("Content-Disposition: attachment; filename={$exp_name}");
133
		header("Content-Length: $exp_size");
134
		echo $exp_data;
135
		exit;
136
	}
137
138 58fdb8ad Matthew Grooms
	if ($_GET['act'] == "delcert") {
139
140
		if (!$a_user[$id]) {
141
			pfSenseHeader("system_usermanager.php");
142
			exit;
143
		}
144
145
		$certdeleted = $a_user[$id]['cert'][$_GET['certid']]['name'];
146
		unset($a_user[$id]['cert'][$_GET['certid']]);
147
		write_config();
148
		$_GET['act'] = "edit";
149
		$savemsg = gettext("Certificate")." {$certdeleted} ".
150
					gettext("successfully deleted")."<br/>";
151
	}
152
153 45ee90ed Matthew Grooms
	if ($_GET['act'] == "edit") {
154
		if (isset($id) && $a_user[$id]) {
155
			$pconfig['usernamefld'] = $a_user[$id]['name'];
156
			$pconfig['fullname'] = $a_user[$id]['fullname'];
157 0092b3bd mgrooms
			$pconfig['expires'] = $a_user[$id]['expires'];
158 659fa7f2 Matthew Grooms
			$pconfig['groups'] = local_user_get_groups($a_user[$id]);
159 45ee90ed Matthew Grooms
			$pconfig['utype'] = $a_user[$id]['scope'];
160
			$pconfig['uid'] = $a_user[$id]['uid'];
161
			$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
162 6b07c15a Matthew Grooms
			$pconfig['priv'] = $a_user[$id]['priv'];
163 b4bfd25d sullrich
			$pconfig['disabled'] = isset($a_user[$id]['disabled']);
164 45ee90ed Matthew Grooms
		}
165
	}
166
167
	if ($_GET['act'] == "new") {
168
		/*
169
		 * set this value cause the text field is read only
170
		 * and the user should not be able to mess with this
171
		 * setting.
172
		 */
173
		$pconfig['utype'] = "user";
174
	}
175
176
	if ($_POST) {
177 dff1a09d Scott Ullrich
		conf_mount_rw();
178 45ee90ed Matthew Grooms
		unset($input_errors);
179
		$pconfig = $_POST;
180
181
		/* input validation */
182
		if (isset($id) && ($a_user[$id])) {
183
			$reqdfields = explode(" ", "usernamefld");
184
			$reqdfieldsn = explode(",", "Username");
185
		} else {
186
			$reqdfields = explode(" ", "usernamefld passwordfld1");
187
			$reqdfieldsn = explode(",", "Username,Password");
188
		}
189
190
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
191
192
		if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld']))
193
			$input_errors[] = gettext("The username contains invalid characters.");
194
195
		if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
196
			$input_errors[] = gettext("The passwords do not match.");
197
198
		/* make sure this user name is unique */
199
		if (!$input_errors && !(isset($id) && $a_user[$id])) {
200
			foreach ($a_user as $userent) {
201
				if ($userent['name'] == $_POST['usernamefld']) {
202
					$input_errors[] = gettext("Another entry with the same username already exists.");
203
					break;
204
				}
205 58664cc9 Scott Ullrich
			}
206 7e4a4513 Scott Ullrich
		}
207 1df17ba9 Scott Ullrich
208 0092b3bd mgrooms
		/*
209
		 * Check for a valid expirationdate if one is set at all (valid means,
210
		 * strtotime() puts out a time stamp so any strtotime compatible time
211
		 * format may be used. to keep it simple for the enduser, we only
212
		 * claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
213
		 * like "+1 day", which will be converted to MM/DD/YYYY based on "now".
214
		 * Otherwhise such an entry would lead to an invalid expiration data.
215
		 */
216
		if ($_POST['expires']){
217
			if(strtotime($_POST['expires']) > 0){
218
				if (strtotime("-1 day") > strtotime(date("m/d/Y",strtotime($_POST['expires'])))) {
219 0a82fa9b sullrich
					// Allow items to lie in the past which ends up disabling.
220 0092b3bd mgrooms
				} else {
221
					//convert from any strtotime compatible date to MM/DD/YYYY
222
					$expdate = strtotime($_POST['expires']);
223
					$_POST['expires'] = date("m/d/Y",$expdate);
224
				}
225
			} else {
226
				$input_errors[] = "Invalid expiration date format; use MM/DD/YYYY instead.";
227
			}
228
		}
229
230 fb1266d3 Matthew Grooms
		if (isset($config['system']['ssh']['sshdkeyonly']) && empty($_POST['authorizedkeys']))
231 45ee90ed Matthew Grooms
			$input_errors[] = gettext("You must provide an authorized key otherwise you won't be able to login into this system.");
232 1df17ba9 Scott Ullrich
233 45ee90ed Matthew Grooms
		/* if this is an AJAX caller then handle via JSON */
234
		if (isAjax() && is_array($input_errors)) {
235
			input_errors2Ajax($input_errors);
236
			exit;
237
		}
238 1df17ba9 Scott Ullrich
239 45ee90ed Matthew Grooms
		if (!$input_errors) {
240
			$userent = array();
241
			if (isset($id) && $a_user[$id])
242
				$userent = $a_user[$id];
243 1df17ba9 Scott Ullrich
244 fb1266d3 Matthew Grooms
			isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system";
245
246 659fa7f2 Matthew Grooms
			/* the user name was modified */
247 45ee90ed Matthew Grooms
			if ($_POST['usernamefld'] <> $_POST['oldusername'])
248
				$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
249 7e4a4513 Scott Ullrich
250 659fa7f2 Matthew Grooms
			/* the user password was mofified */
251
			if ($_POST['passwordfld1'])
252
				local_user_set_password($userent, $_POST['passwordfld1']);
253
254 45ee90ed Matthew Grooms
			$userent['name'] = $_POST['usernamefld'];
255
			$userent['fullname'] = $_POST['fullname'];
256 0092b3bd mgrooms
			$userent['expires'] = $_POST['expires'];
257 fb1266d3 Matthew Grooms
			$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
258 b4bfd25d sullrich
			
259
			if($_POST['disabled'])
260
				$userent['disabled'] = true;
261
			else 
262
				unset($userent['disabled']);
263 1df17ba9 Scott Ullrich
264 45ee90ed Matthew Grooms
			if (isset($id) && $a_user[$id])
265
				$a_user[$id] = $userent;
266
			else {
267
				$userent['uid'] = $config['system']['nextuid']++;
268
				$a_user[] = $userent;
269
			}
270 1df17ba9 Scott Ullrich
271 659fa7f2 Matthew Grooms
			local_user_set($userent);
272
			local_user_set_groups($userent,$_POST['groups']);
273 45ee90ed Matthew Grooms
			write_config();
274 1df17ba9 Scott Ullrich
275 dff1a09d Scott Ullrich
			conf_mount_ro();
276
			
277 45ee90ed Matthew Grooms
			pfSenseHeader("system_usermanager.php");
278
		}
279
	}
280 fab7ff44 Bill Marquette
281 45ee90ed Matthew Grooms
	include("head.inc");
282 1df17ba9 Scott Ullrich
?>
283 fab7ff44 Bill Marquette
284 1df17ba9 Scott Ullrich
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
285 6b07c15a Matthew Grooms
<?php include("fbegin.inc"); ?>
286 0092b3bd mgrooms
<!--
287
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
288
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
289
//For this script, visit http://www.javascriptkit.com
290
// -->
291 9344dd7b mgrooms
<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js"></script>
292 6b07c15a Matthew Grooms
<script language="JavaScript">
293
<!--
294
295
function setall_selected(id) {
296
	selbox = document.getElementById(id);
297
	count = selbox.options.length;
298
	for (index = 0; index<count; index++)
299
		selbox.options[index].selected = true;
300
}
301
302
function clear_selected(id) {
303
	selbox = document.getElementById(id);
304
	count = selbox.options.length;
305
	for (index = 0; index<count; index++)
306
		selbox.options[index].selected = false;
307
}
308
309
function remove_selected(id) {
310
	selbox = document.getElementById(id);
311
	index = selbox.options.length - 1;
312
	for (; index >= 0; index--)
313
		if (selbox.options[index].selected)
314
			selbox.remove(index);
315
}
316
317
function copy_selected(srcid, dstid) {
318
	src_selbox = document.getElementById(srcid);
319
	dst_selbox = document.getElementById(dstid);
320
	count = src_selbox.options.length;
321
	for (index = 0; index < count; index++) {
322
		if (src_selbox.options[index].selected) {
323
			option = document.createElement('option');
324
			option.text = src_selbox.options[index].text;
325
			option.value = src_selbox.options[index].value;
326
			dst_selbox.add(option, null);
327
		}
328
	}
329
}
330
331
function move_selected(srcid, dstid) {
332
	copy_selected(srcid, dstid);
333
	remove_selected(srcid);
334
}
335
336
function presubmit() {
337
	clear_selected('notgroups');
338
	setall_selected('groups');
339
}
340
341
//-->
342
</script>
343 1df17ba9 Scott Ullrich
<?php
344 45ee90ed Matthew Grooms
	if ($input_errors)
345
		print_input_errors($input_errors);
346
	if ($savemsg)
347
		print_info_box($savemsg);
348 1df17ba9 Scott Ullrich
?>
349 45ee90ed Matthew Grooms
<table width="100%" border="0" cellpadding="0" cellspacing="0">
350
	<tr>
351 e30001cf Matthew Grooms
		<td>
352 45ee90ed Matthew Grooms
		<?php
353
			$tab_array = array();
354
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
355 6b07c15a Matthew Grooms
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
356 45ee90ed Matthew Grooms
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
357 d799787e Matthew Grooms
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
358 45ee90ed Matthew Grooms
			display_top_tabs($tab_array);
359
		?>
360
		</td>
361
	</tr>
362
	<tr>
363 e30001cf Matthew Grooms
		<td id="mainarea">
364
			<div class="tabcont">
365
366
				<?php if ($_GET['act'] == "new" || $_GET['act'] == "edit" || $input_errors): ?>
367
368
				<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
369
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
370
						<?php
371
							$ro = "";
372
							if ($pconfig['utype'] == "system")
373
								$ro = "readonly = \"readonly\"";
374
						?>
375
	                    <tr>
376
	                        <td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
377
	                        <td width="78%" class="vtable">
378
	                            <strong><?=strtoupper($pconfig['utype']);?></strong>
379
								<input name="utype" type="hidden" value="<?=$pconfig['utype']?>"/>
380
	                        </td>
381
	                    </tr>
382 b4bfd25d sullrich
						<tr>
383 2afddcb1 sullrich
							<td width="22%" valign="top" class="vncell"><?=gettext("Disabled");?></td>
384 b4bfd25d sullrich
							<td width="78%" class="vtable">
385
								<input name="disabled" type="checkbox" id="disabled" <?php if($pconfig['disabled']) echo "CHECKED"; ?>>
386
							</td>
387
						</tr>
388 e30001cf Matthew Grooms
						<tr>
389
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
390
							<td width="78%" class="vtable">
391
								<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
392
								<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
393
							</td>
394
						</tr>
395
						<tr>
396
							<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
397
							<td width="78%" class="vtable">
398
								<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
399
							</td>
400
						</tr>
401
						<tr>
402
							<td width="78%" class="vtable">
403
								<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
404
							</td>
405
						</tr>
406
						<tr>
407
							<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
408
							<td width="78%" class="vtable">
409
								<input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<?=htmlspecialchars($pconfig['fullname']);?>" <?=$ro;?>/>
410
								<br/>
411
								<?=gettext("User's full name, for your own information only");?>
412
							</td>
413
						</tr>
414 0092b3bd mgrooms
						<tr>
415
							<td width="22%" valign="top" class="vncell">Expiration date</td>
416
							<td width="78%" class="vtable">
417
								<input name="expires" type="text" class="formfld unknown" id="expires" size="10" value="<?=$pconfig['expires'];?>">
418
								<a href="javascript:NewCal('expires','mmddyyyy')">
419
									<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_cal.gif" width="16" height="16" border="0" alt="Pick a date">
420
								</a>
421
								<br>
422
								<span class="vexpl">Leave blank if the account shouldn't expire, otherwise enter the expiration date in the following format: mm/dd/yyyy</span></td>
423
						</tr>
424 e30001cf Matthew Grooms
						<tr>
425
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
426
							<td width="78%" class="vtable" align="center">
427
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
428
									<tr>
429
										<td align="center" width="50%">
430
											<strong>Not Member Of</strong><br/>
431
											<br/>
432
											<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onChange="clear_selected('groups')" multiple>
433
												<?php
434
													foreach ($config['system']['group'] as $group):
435
														if ($group['gid'] == 1998) /* all users group */
436
															continue;
437
														if (in_array($group['name'],$pconfig['groups']))
438
															continue;
439
												?>
440
												<option value="<?=$group['name'];?>" <?=$selected;?>>
441
													<?=htmlspecialchars($group['name']);?>
442
												</option>
443
												<?php endforeach; ?>
444
											</select>
445
											<br/>
446
										</td>
447
										<td>
448
											<br/>
449
											<a href="javascript:move_selected('notgroups','groups')">
450
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="Add Groups" alt="Add Groups" width="17" height="17" border="0" />
451
											</a>
452
											<br/><br/>
453
											<a href="javascript:move_selected('groups','notgroups')">
454
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="Remove Groups" alt="Remove Groups" width="17" height="17" border="0" />
455
											</a>
456
										</td>
457
										<td align="center" width="50%">
458
											<strong>Member Of</strong><br/>
459
											<br/>
460
											<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onChange="clear_selected('nogroups')" multiple>
461
												<?php
462
													foreach ($config['system']['group'] as $group):
463
														if ($group['gid'] == 1998) /* all users group */
464
															continue;
465
														if (!in_array($group['name'],$pconfig['groups']))
466
															continue;
467
												?>
468
												<option value="<?=$group['name'];?>">
469
													<?=htmlspecialchars($group['name']);?>
470
												</option>
471
												<?php endforeach; ?>
472
											</select>
473
											<br/>
474
										</td>
475
									</tr>
476
								</table>
477
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
478
							</td>
479
						</tr>
480
481
						<?php if ($pconfig['uid']): ?>
482
483
						<tr>
484
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
485
							<td width="78%" class="vtable">
486
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
487
									<tr>
488
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
489
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
490
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
491
										<td class="list"></td>
492
									</tr>
493
									<?php
494
											
495
										$privdesc = get_user_privdesc($a_user[$id]);
496
										if(is_array($privdesc)):
497
											$i = 0;
498
											foreach ($privdesc as $priv):
499
											$group = false;
500
											if ($priv['group'])
501
												$group = $priv['group'];
502
									?>
503
									<tr>
504
										<td class="listlr"><?=$group;?></td>
505
										<td class="listr">
506
											<?=htmlspecialchars($priv['name']);?>
507
										</td>
508
										<td class="listbg">
509
												<?=htmlspecialchars($priv['descr']);?>
510
										</td>
511
										<td valign="middle" nowrap class="list">
512
											<?php if (!$group): ?>
513
											<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
514
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
515
											</a>
516
											<?php endif; ?>
517
										</td>
518
									</tr>
519
									<?php
520
											/* can only delete user priv indexes */
521
											if (!$group)
522
												$i++;
523
											endforeach;
524
										endif;
525
									?>
526
									<tr>
527
										<td class="list" colspan="3"></td>
528
										<td class="list">
529
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
530
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
531
											</a>
532
										</td>
533
									</tr>
534
								</table>
535
							</td>
536
						</tr>
537
						<tr>
538
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
539
							<td width="78%" class="vtable">
540
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
541
									<tr>
542
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
543
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
544
										<td class="list"></td>
545
									</tr>
546
									<?php
547
										
548
										$a_cert = $a_user[$id]['cert'];
549
										if(is_array($a_cert)):
550
											$i = 0;
551
											foreach ($a_cert as $cert):
552
						                        $ca = lookup_ca($cert['caref']);
553
									?>
554
									<tr>
555
										<td class="listlr">
556
											<?=htmlspecialchars($cert['name']);?>
557
										</td>
558
										<td class="listr">
559
											<?=htmlspecialchars($ca['name']);?>
560
										</td>
561
										<td valign="middle" nowrap class="list">
562
											<a href="system_usermanager.php?act=expckey&id=<?=$id;?>&certid=<?=$i;?>">
563
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export private key" alt="export private key" width="17" height="17" border="0" />
564
											</a>
565
											<a href="system_usermanager.php?act=expcert&id=<?=$id;?>&certid=<?=$i;?>">
566
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export cert" alt="export cert" width="17" height="17" border="0" />
567
											</a>
568
											<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this certificate?");?>')">
569
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete cert" />
570
											</a>
571
										</td>
572
									</tr>
573
									<?php
574
												$i++;
575
											endforeach;
576
										endif;
577
									?>
578
									<tr>
579
										<td class="list" colspan="2"></td>
580
										<td class="list">
581
											<a href="system_usermanager_addcert.php?userid=<?=$id?>">
582
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
583
											</a>
584
										</td>
585
									</tr>
586
								</table>
587
							</td>
588
						</tr>
589 45ee90ed Matthew Grooms
590 e30001cf Matthew Grooms
						<?php endif; ?>
591 45ee90ed Matthew Grooms
592 e30001cf Matthew Grooms
						<tr>
593
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
594
							<td width="78%" class="vtable">
595
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
596
								<br/>
597
								<?=gettext("Paste an authorized keys file here.");?>
598
							</td>
599
						</tr>
600
						<tr>
601
							<td width="22%" valign="top">&nbsp;</td>
602
							<td width="78%">
603
								<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
604
								<?php if (isset($id) && $a_user[$id]): ?>
605
								<input name="id" type="hidden" value="<?=$id;?>" />
606
								<?php endif;?>
607
							</td>
608
						</tr>
609
					</table>
610
				</form>
611
612
				<?php else: ?>
613
614
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
615 45ee90ed Matthew Grooms
					<tr>
616 e30001cf Matthew Grooms
						<td width="25%" class="listhdrr">Username</td>
617
						<td width="25%" class="listhdrr">Full name</td>
618 b4bfd25d sullrich
						<td width="5%" class="listhdrr">Disabled</td>
619
						<td width="25%" class="listhdrr">Groups</td>
620 e30001cf Matthew Grooms
						<td width="10%" class="list"></td>
621 45ee90ed Matthew Grooms
					</tr>
622 e30001cf Matthew Grooms
					<?php
623
						$i = 0;
624
						foreach($a_user as $userent):
625
					?>
626
					<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
627
						<td class="listlr">
628
							<table border="0" cellpadding="0" cellspacing="0">
629 6b07c15a Matthew Grooms
								<tr>
630 e30001cf Matthew Grooms
									<td align="left" valign="center">
631
										<?php
632
											if($userent['scope'] != "user")
633
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
634
											else
635
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
636
										?>
637
										<img src="<?=$usrimg;?>" alt="User" title="User" border="0" height="16" width="16" />
638 6b07c15a Matthew Grooms
									</td>
639 e30001cf Matthew Grooms
									<td align="left" valign="middle">
640
										<?=htmlspecialchars($userent['name']);?>
641 6b07c15a Matthew Grooms
									</td>
642
								</tr>
643
							</table>
644 45ee90ed Matthew Grooms
						</td>
645 e30001cf Matthew Grooms
						<td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
646 b4bfd25d sullrich
						<td class="listr"><?php if(isset($userent['disabled'])) echo "*"; ?></td>
647 e30001cf Matthew Grooms
						<td class="listbg">
648
								<?=implode(",",local_user_get_groups($userent));?>
649
							&nbsp;
650 45ee90ed Matthew Grooms
						</td>
651 e30001cf Matthew Grooms
						<td valign="middle" nowrap class="list">
652
							<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
653
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="edit user" alt="edit user" width="17" height="17" border="0" />
654
							</a>
655
							<?php if($userent['scope'] != "system"): ?>
656
							&nbsp;
657
							<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
658
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete user" alt="delete user" width="17" height="17" border="0" />
659
							</a>
660
							<?php endif; ?>
661 58fdb8ad Matthew Grooms
						</td>
662
					</tr>
663 e30001cf Matthew Grooms
					<?php
664
							$i++;
665
						endforeach;
666
					?>
667 fb1266d3 Matthew Grooms
					<tr>
668 b4bfd25d sullrich
						<td class="list" colspan="4"></td>
669 e30001cf Matthew Grooms
						<td class="list">
670
							<a href="system_usermanager.php?act=new">
671
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add user" alt="add user" width="17" height="17" border="0" />
672
							</a>
673 fb1266d3 Matthew Grooms
						</td>
674
					</tr>
675 45ee90ed Matthew Grooms
					<tr>
676 b4bfd25d sullrich
						<td colspan="4">
677 e30001cf Matthew Grooms
							<p>
678
								<?=gettext("Additional webConfigurator users can be added here.");?>
679
								<?=gettext("User permissions can be assinged diretly or inherited from group memberships.");?>
680
								<?=gettext("An icon that appears grey indicates that it is a system defined object.");?>
681
								<?=gettext("Some system object properties can be modified but they cannot be deleted.");?>
682
							</p>
683 45ee90ed Matthew Grooms
						</td>
684
					</tr>
685
				</table>
686
687 e30001cf Matthew Grooms
				<?php endif; ?>
688 45ee90ed Matthew Grooms
689 e30001cf Matthew Grooms
			</div>
690 45ee90ed Matthew Grooms
		</td>
691
	</tr>
692 1df17ba9 Scott Ullrich
</table>
693 45ee90ed Matthew Grooms
<?php include("fend.inc");?>
694
</body>
695
696 1df17ba9 Scott Ullrich
<?php
697
698 45ee90ed Matthew Grooms
	// end admin user code
699
700
} else {
701
702
	// start normal user code
703 6b07c15a Matthew Grooms
704 45ee90ed Matthew Grooms
	$pgtitle = array("System","User Password");
705
706
	if (isset($_POST['save'])) {
707
		unset($input_errors);
708
709
		/* input validation */
710
		$reqdfields = explode(" ", "passwordfld1");
711
		$reqdfieldsn = explode(",", "Password");
712 1df17ba9 Scott Ullrich
713 45ee90ed Matthew Grooms
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
714 1df17ba9 Scott Ullrich
715 45ee90ed Matthew Grooms
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
716
			$input_errors[] = "The passwords do not match.";
717 1df17ba9 Scott Ullrich
718 45ee90ed Matthew Grooms
		if (!$input_errors) {
719
			// all values are okay --> saving changes
720
			$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['password'] = crypt(trim($_POST['passwordfld1']));
721 1df17ba9 Scott Ullrich
722 45ee90ed Matthew Grooms
			write_config();
723
			$savemsg = "Password successfully changed<br />";
724
		}
725
	}
726
727 4494cf6a Chris Buechler
	/* determine if user is not local to system */
728 45ee90ed Matthew Grooms
	$islocal = false;
729
	foreach($config['system']['user'] as $user) 
730
		if($user['name'] == $_SESSION['Username'])
731
			$islocal = true;
732 fab7ff44 Bill Marquette
?>
733 1df17ba9 Scott Ullrich
734 45ee90ed Matthew Grooms
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
735 1df17ba9 Scott Ullrich
<?php
736
    include("head.inc");
737 45ee90ed Matthew Grooms
	include("fbegin.inc");
738
	if ($input_errors)
739
		print_input_errors($input_errors);
740
	if ($savemsg)
741
		print_info_box($savemsg);
742
743
	if($islocal == false) {
744
		echo "Sorry, you cannot change the password for a LDAP user.";
745
		include("fend.inc");
746
		exit;
747
	}
748 1df17ba9 Scott Ullrich
?>
749 e30001cf Matthew Grooms
<div id="mainarea">
750
	<div class="tabcont">
751
		<form action="system_usermanager.php" method="post" name="iform" id="iform">
752
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
753
				<tr>
754
					<td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s Password</td>
755
				</tr>
756
				<tr>
757
					<td width="22%" valign="top" class="vncell" rowspan="2">Password</td>
758
					<td width="78%" class="vtable">
759
						<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
760
					</td>
761
				</tr>
762
				<tr>
763
					<td width="78%" class="vtable">
764
						<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
765
						&nbsp;<?=gettext("(confirmation)");?>
766
						<br/>
767
						<span class="vexpl">
768
							<?=gettext("Select a new password");?>
769
						</span>
770
					</td>
771
				</tr>
772
				<tr>
773
					<td width="22%" valign="top">&nbsp;</td>
774
					<td width="78%">
775
						<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
776
					</td>
777
				</tr>
778
			</table>
779
		</form>
780
	</div>
781
</div>
782 45ee90ed Matthew Grooms
<?php include("fend.inc");?>
783
</body>
784 82e913df Scott Ullrich
785 1df17ba9 Scott Ullrich
<?php
786
787 6b07c15a Matthew Grooms
} // end of normal user code
788 45ee90ed Matthew Grooms
789
?>