Project

General

Profile

Download (33.2 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
52 45ee90ed Matthew Grooms
if (isAllowedPage("system_usermanager")) {
53 31b53653 Scott Ullrich
54 45ee90ed Matthew Grooms
	// start admin user code
55
	$pgtitle = array("System","User Manager");
56 fab7ff44 Bill Marquette
57 45ee90ed Matthew Grooms
	$id = $_GET['id'];
58
	if (isset($_POST['id']))
59
		$id = $_POST['id'];
60 1df17ba9 Scott Ullrich
61 7e4a4513 Scott Ullrich
	if (!is_array($config['system']['user'])) 
62
		$config['system']['user'] = array();
63 1df17ba9 Scott Ullrich
64 6b07c15a Matthew Grooms
	$a_user = &$config['system']['user'];
65 45ee90ed Matthew Grooms
66 6b07c15a Matthew Grooms
	if ($_GET['act'] == "deluser") {
67 45ee90ed Matthew Grooms
68 58fdb8ad Matthew Grooms
		if (!$a_user[$id]) {
69 6b07c15a Matthew Grooms
			pfSenseHeader("system_usermanager.php");
70
			exit;
71 45ee90ed Matthew Grooms
		}
72
73 58fdb8ad Matthew Grooms
		local_user_del($a_user[$id]);
74
		$userdeleted = $a_user[$id]['name'];
75
		unset($a_user[$id]);
76 6b07c15a Matthew Grooms
		write_config();
77
		$savemsg = gettext("User")." {$userdeleted} ".
78
					gettext("successfully deleted")."<br/>";
79
	}
80
81
	if ($_GET['act'] == "delpriv") {
82
83 58fdb8ad Matthew Grooms
		if (!$a_user[$id]) {
84 6b07c15a Matthew Grooms
			pfSenseHeader("system_usermanager.php");
85
			exit;
86 45ee90ed Matthew Grooms
		}
87 6b07c15a Matthew Grooms
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 45ee90ed Matthew Grooms
	}
95
96 93823b10 Matthew Grooms
	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 58fdb8ad Matthew Grooms
	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 45ee90ed Matthew Grooms
	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 0092b3bd mgrooms
			$pconfig['expires'] = $a_user[$id]['expires'];
156 659fa7f2 Matthew Grooms
			$pconfig['groups'] = local_user_get_groups($a_user[$id]);
157 45ee90ed Matthew Grooms
			$pconfig['utype'] = $a_user[$id]['scope'];
158
			$pconfig['uid'] = $a_user[$id]['uid'];
159
			$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
160 6b07c15a Matthew Grooms
			$pconfig['priv'] = $a_user[$id]['priv'];
161 b4bfd25d sullrich
			$pconfig['disabled'] = isset($a_user[$id]['disabled']);
162 45ee90ed Matthew Grooms
		}
163
	}
164
165
	if ($_GET['act'] == "new") {
166
		/*
167
		 * set this value cause the text field is read only
168
		 * and the user should not be able to mess with this
169
		 * setting.
170
		 */
171
		$pconfig['utype'] = "user";
172 13646069 Ermal
		$pconfig['lifetime'] = 3650;
173 45ee90ed Matthew Grooms
	}
174
175
	if ($_POST) {
176 dff1a09d Scott Ullrich
		conf_mount_rw();
177 45ee90ed Matthew Grooms
		unset($input_errors);
178
		$pconfig = $_POST;
179
180
		/* input validation */
181
		if (isset($id) && ($a_user[$id])) {
182
			$reqdfields = explode(" ", "usernamefld");
183
			$reqdfieldsn = explode(",", "Username");
184
		} else {
185 c9794c06 Ermal
			if (empty($_POST['name'])) {
186
				$reqdfields = explode(" ", "usernamefld passwordfld1");
187
				$reqdfieldsn = explode(",", "Username,Password");
188
			} else {
189
				$reqdfields = explode(" ", "usernamefld passwordfld1 name caref keylen lifetime");
190
				$reqdfieldsn = explode(",", "Username,Password,Descriptive name,Certificate authority,Key length,Lifetime");
191
192
			}
193 45ee90ed Matthew Grooms
		}
194
195
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
196
197
		if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld']))
198
			$input_errors[] = gettext("The username contains invalid characters.");
199
200
		if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
201
			$input_errors[] = gettext("The passwords do not match.");
202
203
		/* make sure this user name is unique */
204
		if (!$input_errors && !(isset($id) && $a_user[$id])) {
205
			foreach ($a_user as $userent) {
206
				if ($userent['name'] == $_POST['usernamefld']) {
207
					$input_errors[] = gettext("Another entry with the same username already exists.");
208
					break;
209
				}
210 58664cc9 Scott Ullrich
			}
211 7e4a4513 Scott Ullrich
		}
212 1df17ba9 Scott Ullrich
213 0092b3bd mgrooms
		/*
214
		 * Check for a valid expirationdate if one is set at all (valid means,
215
		 * strtotime() puts out a time stamp so any strtotime compatible time
216
		 * format may be used. to keep it simple for the enduser, we only
217
		 * claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
218
		 * like "+1 day", which will be converted to MM/DD/YYYY based on "now".
219
		 * Otherwhise such an entry would lead to an invalid expiration data.
220
		 */
221
		if ($_POST['expires']){
222
			if(strtotime($_POST['expires']) > 0){
223
				if (strtotime("-1 day") > strtotime(date("m/d/Y",strtotime($_POST['expires'])))) {
224 0a82fa9b sullrich
					// Allow items to lie in the past which ends up disabling.
225 0092b3bd mgrooms
				} else {
226
					//convert from any strtotime compatible date to MM/DD/YYYY
227
					$expdate = strtotime($_POST['expires']);
228
					$_POST['expires'] = date("m/d/Y",$expdate);
229
				}
230
			} else {
231
				$input_errors[] = "Invalid expiration date format; use MM/DD/YYYY instead.";
232
			}
233
		}
234
235 c9794c06 Ermal
		if (!empty($_POST['name'])) {
236
			$ca = lookup_ca($_POST['caref']);
237
        		if (!$ca)
238
                		$input_errors[] = "Invalid internal Certificate Authority\n";
239
		}
240
241 45ee90ed Matthew Grooms
		/* if this is an AJAX caller then handle via JSON */
242
		if (isAjax() && is_array($input_errors)) {
243
			input_errors2Ajax($input_errors);
244
			exit;
245
		}
246 1df17ba9 Scott Ullrich
247 45ee90ed Matthew Grooms
		if (!$input_errors) {
248
			$userent = array();
249
			if (isset($id) && $a_user[$id])
250
				$userent = $a_user[$id];
251 1df17ba9 Scott Ullrich
252 fb1266d3 Matthew Grooms
			isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system";
253
254 659fa7f2 Matthew Grooms
			/* the user name was modified */
255 45ee90ed Matthew Grooms
			if ($_POST['usernamefld'] <> $_POST['oldusername'])
256
				$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
257 7e4a4513 Scott Ullrich
258 659fa7f2 Matthew Grooms
			/* the user password was mofified */
259
			if ($_POST['passwordfld1'])
260
				local_user_set_password($userent, $_POST['passwordfld1']);
261
262 45ee90ed Matthew Grooms
			$userent['name'] = $_POST['usernamefld'];
263
			$userent['fullname'] = $_POST['fullname'];
264 0092b3bd mgrooms
			$userent['expires'] = $_POST['expires'];
265 fb1266d3 Matthew Grooms
			$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
266 b4bfd25d sullrich
			
267
			if($_POST['disabled'])
268
				$userent['disabled'] = true;
269
			else 
270
				unset($userent['disabled']);
271 1df17ba9 Scott Ullrich
272 45ee90ed Matthew Grooms
			if (isset($id) && $a_user[$id])
273
				$a_user[$id] = $userent;
274
			else {
275 c9794c06 Ermal
				if (!empty($_POST['name'])) {
276
					$cert = array();
277
                        		$userent['cert'] = array();
278
279
            				$cert['name'] = $_POST['name'];
280
281
                			$subject = cert_get_subject_array($ca['crt']);
282
283
                			$dn = array(
284
                        			'countryName' => $subject[0]['v'],
285
                        			'stateOrProvinceName' => $subject[1]['v'],
286
                        			'localityName' => $subject[2]['v'],
287
                        			'organizationName' => $subject[3]['v'],
288
                        			'emailAddress' => $subject[4]['v'],
289
                        			'commonName' => $userent['name']);
290
291
					cert_create($cert, $_POST['caref'], $_POST['keylen'],
292
						(int)$_POST['lifetime'], $dn);
293
294
					$userent['cert'][] = $cert;
295
				}
296 45ee90ed Matthew Grooms
				$userent['uid'] = $config['system']['nextuid']++;
297
				$a_user[] = $userent;
298
			}
299 1df17ba9 Scott Ullrich
300 659fa7f2 Matthew Grooms
			local_user_set($userent);
301
			local_user_set_groups($userent,$_POST['groups']);
302 45ee90ed Matthew Grooms
			write_config();
303 1df17ba9 Scott Ullrich
304 970db70b Scott Ullrich
			if(is_dir("/etc/inc/privhooks"))
305
				run_plugins("/etc/inc/privhooks");
306
307 dff1a09d Scott Ullrich
			conf_mount_ro();
308
			
309 45ee90ed Matthew Grooms
			pfSenseHeader("system_usermanager.php");
310
		}
311
	}
312 fab7ff44 Bill Marquette
313 45ee90ed Matthew Grooms
	include("head.inc");
314 1df17ba9 Scott Ullrich
?>
315 fab7ff44 Bill Marquette
316 1df17ba9 Scott Ullrich
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
317 6b07c15a Matthew Grooms
<?php include("fbegin.inc"); ?>
318 0092b3bd mgrooms
<!--
319
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
320
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
321
//For this script, visit http://www.javascriptkit.com
322
// -->
323 9344dd7b mgrooms
<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js"></script>
324 6b07c15a Matthew Grooms
<script language="JavaScript">
325
<!--
326
327
function setall_selected(id) {
328
	selbox = document.getElementById(id);
329
	count = selbox.options.length;
330
	for (index = 0; index<count; index++)
331
		selbox.options[index].selected = true;
332
}
333
334
function clear_selected(id) {
335
	selbox = document.getElementById(id);
336
	count = selbox.options.length;
337
	for (index = 0; index<count; index++)
338
		selbox.options[index].selected = false;
339
}
340
341
function remove_selected(id) {
342
	selbox = document.getElementById(id);
343
	index = selbox.options.length - 1;
344
	for (; index >= 0; index--)
345
		if (selbox.options[index].selected)
346
			selbox.remove(index);
347
}
348
349
function copy_selected(srcid, dstid) {
350
	src_selbox = document.getElementById(srcid);
351
	dst_selbox = document.getElementById(dstid);
352
	count = src_selbox.options.length;
353
	for (index = 0; index < count; index++) {
354
		if (src_selbox.options[index].selected) {
355
			option = document.createElement('option');
356
			option.text = src_selbox.options[index].text;
357
			option.value = src_selbox.options[index].value;
358
			dst_selbox.add(option, null);
359
		}
360
	}
361
}
362
363
function move_selected(srcid, dstid) {
364
	copy_selected(srcid, dstid);
365
	remove_selected(srcid);
366
}
367
368
function presubmit() {
369
	clear_selected('notgroups');
370
	setall_selected('groups');
371
}
372
373 c9794c06 Ermal
function usercertClicked(obj) {
374
	if (obj.checked) {
375
		document.getElementById("usercertchck").style.display="none";
376
		document.getElementById("usercert").style.display="";
377
	} else {
378
		document.getElementById("usercert").style.display="none";
379
		document.getElementById("usercertchck").style.display="";
380
	}
381
}
382
383
function sshkeyClicked(obj) {
384
        if (obj.checked) {
385
                document.getElementById("sshkeychck").style.display="none";
386
                document.getElementById("sshkey").style.display="";
387
        } else {
388
                document.getElementById("sshkey").style.display="none";
389
                document.getElementById("sshkeychck").style.display="";
390
        }
391
}
392 6b07c15a Matthew Grooms
//-->
393
</script>
394 1df17ba9 Scott Ullrich
<?php
395 45ee90ed Matthew Grooms
	if ($input_errors)
396
		print_input_errors($input_errors);
397
	if ($savemsg)
398
		print_info_box($savemsg);
399 1df17ba9 Scott Ullrich
?>
400 45ee90ed Matthew Grooms
<table width="100%" border="0" cellpadding="0" cellspacing="0">
401
	<tr>
402 e30001cf Matthew Grooms
		<td>
403 45ee90ed Matthew Grooms
		<?php
404
			$tab_array = array();
405
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
406 6b07c15a Matthew Grooms
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
407 45ee90ed Matthew Grooms
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
408 d799787e Matthew Grooms
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
409 45ee90ed Matthew Grooms
			display_top_tabs($tab_array);
410
		?>
411
		</td>
412
	</tr>
413
	<tr>
414 e30001cf Matthew Grooms
		<td id="mainarea">
415
			<div class="tabcont">
416
417
				<?php if ($_GET['act'] == "new" || $_GET['act'] == "edit" || $input_errors): ?>
418
419
				<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
420
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
421
						<?php
422
							$ro = "";
423
							if ($pconfig['utype'] == "system")
424
								$ro = "readonly = \"readonly\"";
425
						?>
426
	                    <tr>
427
	                        <td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
428
	                        <td width="78%" class="vtable">
429
	                            <strong><?=strtoupper($pconfig['utype']);?></strong>
430
								<input name="utype" type="hidden" value="<?=$pconfig['utype']?>"/>
431
	                        </td>
432
	                    </tr>
433 b4bfd25d sullrich
						<tr>
434 2afddcb1 sullrich
							<td width="22%" valign="top" class="vncell"><?=gettext("Disabled");?></td>
435 b4bfd25d sullrich
							<td width="78%" class="vtable">
436
								<input name="disabled" type="checkbox" id="disabled" <?php if($pconfig['disabled']) echo "CHECKED"; ?>>
437
							</td>
438
						</tr>
439 e30001cf Matthew Grooms
						<tr>
440
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
441
							<td width="78%" class="vtable">
442
								<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
443
								<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
444
							</td>
445
						</tr>
446
						<tr>
447
							<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
448
							<td width="78%" class="vtable">
449
								<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
450
							</td>
451
						</tr>
452
						<tr>
453
							<td width="78%" class="vtable">
454
								<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
455
							</td>
456
						</tr>
457
						<tr>
458
							<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
459
							<td width="78%" class="vtable">
460
								<input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<?=htmlspecialchars($pconfig['fullname']);?>" <?=$ro;?>/>
461
								<br/>
462
								<?=gettext("User's full name, for your own information only");?>
463
							</td>
464
						</tr>
465 0092b3bd mgrooms
						<tr>
466
							<td width="22%" valign="top" class="vncell">Expiration date</td>
467
							<td width="78%" class="vtable">
468
								<input name="expires" type="text" class="formfld unknown" id="expires" size="10" value="<?=$pconfig['expires'];?>">
469
								<a href="javascript:NewCal('expires','mmddyyyy')">
470
									<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_cal.gif" width="16" height="16" border="0" alt="Pick a date">
471
								</a>
472
								<br>
473
								<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>
474
						</tr>
475 e30001cf Matthew Grooms
						<tr>
476
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
477
							<td width="78%" class="vtable" align="center">
478
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
479
									<tr>
480
										<td align="center" width="50%">
481
											<strong>Not Member Of</strong><br/>
482
											<br/>
483
											<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onChange="clear_selected('groups')" multiple>
484
												<?php
485
													foreach ($config['system']['group'] as $group):
486
														if ($group['gid'] == 1998) /* all users group */
487
															continue;
488
														if (in_array($group['name'],$pconfig['groups']))
489
															continue;
490
												?>
491
												<option value="<?=$group['name'];?>" <?=$selected;?>>
492
													<?=htmlspecialchars($group['name']);?>
493
												</option>
494
												<?php endforeach; ?>
495
											</select>
496
											<br/>
497
										</td>
498
										<td>
499
											<br/>
500
											<a href="javascript:move_selected('notgroups','groups')">
501
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="Add Groups" alt="Add Groups" width="17" height="17" border="0" />
502
											</a>
503
											<br/><br/>
504
											<a href="javascript:move_selected('groups','notgroups')">
505
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="Remove Groups" alt="Remove Groups" width="17" height="17" border="0" />
506
											</a>
507
										</td>
508
										<td align="center" width="50%">
509
											<strong>Member Of</strong><br/>
510
											<br/>
511
											<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onChange="clear_selected('nogroups')" multiple>
512
												<?php
513
													foreach ($config['system']['group'] as $group):
514
														if ($group['gid'] == 1998) /* all users group */
515
															continue;
516
														if (!in_array($group['name'],$pconfig['groups']))
517
															continue;
518
												?>
519
												<option value="<?=$group['name'];?>">
520
													<?=htmlspecialchars($group['name']);?>
521
												</option>
522
												<?php endforeach; ?>
523
											</select>
524
											<br/>
525
										</td>
526
									</tr>
527
								</table>
528
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
529
							</td>
530
						</tr>
531
532
						<?php if ($pconfig['uid']): ?>
533
534
						<tr>
535
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
536
							<td width="78%" class="vtable">
537
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
538
									<tr>
539
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
540
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
541
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
542
										<td class="list"></td>
543
									</tr>
544
									<?php
545
											
546
										$privdesc = get_user_privdesc($a_user[$id]);
547
										if(is_array($privdesc)):
548
											$i = 0;
549
											foreach ($privdesc as $priv):
550
											$group = false;
551
											if ($priv['group'])
552
												$group = $priv['group'];
553
									?>
554
									<tr>
555
										<td class="listlr"><?=$group;?></td>
556
										<td class="listr">
557
											<?=htmlspecialchars($priv['name']);?>
558
										</td>
559
										<td class="listbg">
560
												<?=htmlspecialchars($priv['descr']);?>
561
										</td>
562
										<td valign="middle" nowrap class="list">
563
											<?php if (!$group): ?>
564
											<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
565
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
566
											</a>
567
											<?php endif; ?>
568
										</td>
569
									</tr>
570
									<?php
571
											/* can only delete user priv indexes */
572
											if (!$group)
573
												$i++;
574
											endforeach;
575
										endif;
576
									?>
577
									<tr>
578
										<td class="list" colspan="3"></td>
579
										<td class="list">
580
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
581
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
582
											</a>
583
										</td>
584
									</tr>
585
								</table>
586
							</td>
587
						</tr>
588
						<tr>
589
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
590
							<td width="78%" class="vtable">
591
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
592
									<tr>
593
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
594
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
595
										<td class="list"></td>
596
									</tr>
597
									<?php
598
										
599
										$a_cert = $a_user[$id]['cert'];
600
										if(is_array($a_cert)):
601
											$i = 0;
602
											foreach ($a_cert as $cert):
603
						                        $ca = lookup_ca($cert['caref']);
604
									?>
605
									<tr>
606
										<td class="listlr">
607
											<?=htmlspecialchars($cert['name']);?>
608
										</td>
609
										<td class="listr">
610
											<?=htmlspecialchars($ca['name']);?>
611
										</td>
612
										<td valign="middle" nowrap class="list">
613
											<a href="system_usermanager.php?act=expckey&id=<?=$id;?>&certid=<?=$i;?>">
614
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export private key" alt="export private key" width="17" height="17" border="0" />
615
											</a>
616
											<a href="system_usermanager.php?act=expcert&id=<?=$id;?>&certid=<?=$i;?>">
617
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export cert" alt="export cert" width="17" height="17" border="0" />
618
											</a>
619
											<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this certificate?");?>')">
620
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete cert" />
621
											</a>
622
										</td>
623
									</tr>
624
									<?php
625
												$i++;
626
											endforeach;
627
										endif;
628
									?>
629
									<tr>
630
										<td class="list" colspan="2"></td>
631
										<td class="list">
632
											<a href="system_usermanager_addcert.php?userid=<?=$id?>">
633
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
634
											</a>
635
										</td>
636
									</tr>
637
								</table>
638
							</td>
639
						</tr>
640 45ee90ed Matthew Grooms
641 c9794c06 Ermal
						<?php else : ?>
642
						<?php 	if (is_array($config['system']['ca']) && count($config['system']['ca']) > 0): ?>
643
						<?php		$i = 0; foreach( $config['system']['ca'] as $ca) {
644
                                                                        	if (!$ca['prv'])
645
                                                                                	continue;
646
										$i++;
647
									}
648
						?>
649
650
						<tr id="usercertchck" name="usercertchck" >
651
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
652
                                                	<td width="78%" class="vtable">
653
							<input type="checkbox" onClick="javascript:usercertClicked(this)"> Click to create a user certificate.
654
							</td>
655
						</tr>
656
657
						<?php		if ($i > 0): ?>
658
659
						<tr id="usercert" name="usercert" style="display:none">
660
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
661
                                                	<td width="78%" class="vtable">
662 d0412d85 Ermal
							<table width="100%" border="0" cellpadding="6" cellspacing="0">
663 c9794c06 Ermal
							<tr>
664
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
665
                                                        	<td width="78%" class="vtable">
666
                                                                	<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
667
                                                        	</td>
668
                                                	</tr>
669
                                                	<tr>
670
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
671
                                                        	<td width="78%" class="vtable">
672
                                                                	<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
673
                                                                <?php
674
                                                                        foreach( $config['system']['ca'] as $ca):
675
                                                                        if (!$ca['prv'])
676
                                                                                continue;
677
                                                                ?>
678
                                                                        <option value="<?=$ca['refid'];?>"><?=$ca['name'];?></option>
679
                                                                <?php endforeach; ?>
680
                                                                	</select>
681
                                                        	</td>
682
                                                	</tr>
683
                                                	<tr>
684
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
685
                                                        	<td width="78%" class="vtable">
686
                                                                	<select name='keylen' class="formselect">
687
                                                                <?php
688 3b4b9ff3 Ermal
									$cert_keylens = array( "2048", "512", "1024", "4096");
689 c9794c06 Ermal
                                                                        foreach( $cert_keylens as $len):
690
                                                                ?>
691
                                                                        <option value="<?=$len;?>"><?=$len;?></option>
692
                                                                <?php endforeach; ?>
693
                                                                	</select>
694
                                                                	bits
695
                                                        	</td>
696
                                                	</tr>
697
							<tr>
698
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
699
                                                        	<td width="78%" class="vtable">
700
                                                                	<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>days
701
                                                        	</td>
702
                                                	</tr>
703
						</table>
704
							</td>
705
						</tr>
706
707
						<?php 	endif; endif; ?>
708 e30001cf Matthew Grooms
						<?php endif; ?>
709 45ee90ed Matthew Grooms
710 c9794c06 Ermal
						<tr id="sshkeychck" name="sshkeychck" >
711
                                                        <td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
712
                                                        <td width="78%" class="vtable">
713 095a63da Chris Buechler
                                                        <input type="checkbox" onClick="javascript:sshkeyClicked(this)"> Click to paste an authorized key.
714 c9794c06 Ermal
                                                        </td>
715
                                                </tr>
716
						<tr id="sshkey" name="sshkey" style="display:none">
717 e30001cf Matthew Grooms
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
718
							<td width="78%" class="vtable">
719
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
720
								<br/>
721
								<?=gettext("Paste an authorized keys file here.");?>
722
							</td>
723
						</tr>
724
						<tr>
725
							<td width="22%" valign="top">&nbsp;</td>
726
							<td width="78%">
727
								<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
728
								<?php if (isset($id) && $a_user[$id]): ?>
729
								<input name="id" type="hidden" value="<?=$id;?>" />
730
								<?php endif;?>
731
							</td>
732
						</tr>
733
					</table>
734
				</form>
735
736
				<?php else: ?>
737
738
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
739 45ee90ed Matthew Grooms
					<tr>
740 e30001cf Matthew Grooms
						<td width="25%" class="listhdrr">Username</td>
741
						<td width="25%" class="listhdrr">Full name</td>
742 b4bfd25d sullrich
						<td width="5%" class="listhdrr">Disabled</td>
743
						<td width="25%" class="listhdrr">Groups</td>
744 e30001cf Matthew Grooms
						<td width="10%" class="list"></td>
745 45ee90ed Matthew Grooms
					</tr>
746 e30001cf Matthew Grooms
					<?php
747
						$i = 0;
748
						foreach($a_user as $userent):
749
					?>
750
					<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
751
						<td class="listlr">
752
							<table border="0" cellpadding="0" cellspacing="0">
753 6b07c15a Matthew Grooms
								<tr>
754 e30001cf Matthew Grooms
									<td align="left" valign="center">
755
										<?php
756
											if($userent['scope'] != "user")
757
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
758
											else
759
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
760
										?>
761
										<img src="<?=$usrimg;?>" alt="User" title="User" border="0" height="16" width="16" />
762 6b07c15a Matthew Grooms
									</td>
763 e30001cf Matthew Grooms
									<td align="left" valign="middle">
764
										<?=htmlspecialchars($userent['name']);?>
765 6b07c15a Matthew Grooms
									</td>
766
								</tr>
767
							</table>
768 45ee90ed Matthew Grooms
						</td>
769 e30001cf Matthew Grooms
						<td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
770 b4bfd25d sullrich
						<td class="listr"><?php if(isset($userent['disabled'])) echo "*"; ?></td>
771 e30001cf Matthew Grooms
						<td class="listbg">
772
								<?=implode(",",local_user_get_groups($userent));?>
773
							&nbsp;
774 45ee90ed Matthew Grooms
						</td>
775 e30001cf Matthew Grooms
						<td valign="middle" nowrap class="list">
776
							<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
777
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="edit user" alt="edit user" width="17" height="17" border="0" />
778
							</a>
779
							<?php if($userent['scope'] != "system"): ?>
780
							&nbsp;
781
							<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
782
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete user" alt="delete user" width="17" height="17" border="0" />
783
							</a>
784
							<?php endif; ?>
785 58fdb8ad Matthew Grooms
						</td>
786
					</tr>
787 e30001cf Matthew Grooms
					<?php
788
							$i++;
789
						endforeach;
790
					?>
791 fb1266d3 Matthew Grooms
					<tr>
792 b4bfd25d sullrich
						<td class="list" colspan="4"></td>
793 e30001cf Matthew Grooms
						<td class="list">
794
							<a href="system_usermanager.php?act=new">
795
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add user" alt="add user" width="17" height="17" border="0" />
796
							</a>
797 fb1266d3 Matthew Grooms
						</td>
798
					</tr>
799 45ee90ed Matthew Grooms
					<tr>
800 b4bfd25d sullrich
						<td colspan="4">
801 e30001cf Matthew Grooms
							<p>
802
								<?=gettext("Additional webConfigurator users can be added here.");?>
803 062d7db5 Chris Buechler
								<?=gettext("User permissions can be assigned directly or inherited from group memberships.");?>
804 e30001cf Matthew Grooms
								<?=gettext("An icon that appears grey indicates that it is a system defined object.");?>
805
								<?=gettext("Some system object properties can be modified but they cannot be deleted.");?>
806
							</p>
807 45ee90ed Matthew Grooms
						</td>
808
					</tr>
809
				</table>
810
811 e30001cf Matthew Grooms
				<?php endif; ?>
812 45ee90ed Matthew Grooms
813 e30001cf Matthew Grooms
			</div>
814 45ee90ed Matthew Grooms
		</td>
815
	</tr>
816 1df17ba9 Scott Ullrich
</table>
817 45ee90ed Matthew Grooms
<?php include("fend.inc");?>
818
</body>
819
820 1df17ba9 Scott Ullrich
<?php
821
822 45ee90ed Matthew Grooms
	// end admin user code
823
824
} else {
825
826
	// start normal user code
827 6b07c15a Matthew Grooms
828 45ee90ed Matthew Grooms
	$pgtitle = array("System","User Password");
829
830
	if (isset($_POST['save'])) {
831
		unset($input_errors);
832
833
		/* input validation */
834
		$reqdfields = explode(" ", "passwordfld1");
835
		$reqdfieldsn = explode(",", "Password");
836 1df17ba9 Scott Ullrich
837 45ee90ed Matthew Grooms
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
838 1df17ba9 Scott Ullrich
839 45ee90ed Matthew Grooms
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
840
			$input_errors[] = "The passwords do not match.";
841 1df17ba9 Scott Ullrich
842 45ee90ed Matthew Grooms
		if (!$input_errors) {
843
			// all values are okay --> saving changes
844
			$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['password'] = crypt(trim($_POST['passwordfld1']));
845 1df17ba9 Scott Ullrich
846 45ee90ed Matthew Grooms
			write_config();
847
			$savemsg = "Password successfully changed<br />";
848
		}
849
	}
850
851 4494cf6a Chris Buechler
	/* determine if user is not local to system */
852 45ee90ed Matthew Grooms
	$islocal = false;
853
	foreach($config['system']['user'] as $user) 
854
		if($user['name'] == $_SESSION['Username'])
855
			$islocal = true;
856 fab7ff44 Bill Marquette
?>
857 1df17ba9 Scott Ullrich
858 45ee90ed Matthew Grooms
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
859 1df17ba9 Scott Ullrich
<?php
860
    include("head.inc");
861 45ee90ed Matthew Grooms
	include("fbegin.inc");
862
	if ($input_errors)
863
		print_input_errors($input_errors);
864
	if ($savemsg)
865
		print_info_box($savemsg);
866
867
	if($islocal == false) {
868
		echo "Sorry, you cannot change the password for a LDAP user.";
869
		include("fend.inc");
870
		exit;
871
	}
872 1df17ba9 Scott Ullrich
?>
873 e30001cf Matthew Grooms
<div id="mainarea">
874
	<div class="tabcont">
875
		<form action="system_usermanager.php" method="post" name="iform" id="iform">
876
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
877
				<tr>
878
					<td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s Password</td>
879
				</tr>
880
				<tr>
881
					<td width="22%" valign="top" class="vncell" rowspan="2">Password</td>
882
					<td width="78%" class="vtable">
883
						<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
884
					</td>
885
				</tr>
886
				<tr>
887
					<td width="78%" class="vtable">
888
						<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
889
						&nbsp;<?=gettext("(confirmation)");?>
890
						<br/>
891
						<span class="vexpl">
892
							<?=gettext("Select a new password");?>
893
						</span>
894
					</td>
895
				</tr>
896
				<tr>
897
					<td width="22%" valign="top">&nbsp;</td>
898
					<td width="78%">
899
						<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
900
					</td>
901
				</tr>
902
			</table>
903
		</form>
904
	</div>
905
</div>
906 45ee90ed Matthew Grooms
<?php include("fend.inc");?>
907
</body>
908 82e913df Scott Ullrich
909 1df17ba9 Scott Ullrich
<?php
910
911 6b07c15a Matthew Grooms
} // end of normal user code
912 45ee90ed Matthew Grooms
913
?>