Project

General

Profile

Download (34.7 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
		unset($input_errors);
178
		$pconfig = $_POST;
179

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

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

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

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

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

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

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

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

    
254
		if (!$input_errors) {
255
			conf_mount_rw();
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
				/* Add the user to All Users group. */
307
				if (!is_array($config['system']['group']['member']))
308
					$config['system']['group']['member'] = array();
309
				foreach ($config['system']['group'] as $gidx => $group) {
310
					if ($group['name'] == "all") {
311
						$config['system']['group'][$gidx]['member'][] = $userent['uid'];
312
						break;
313
					}
314
				}
315

    
316
				$a_user[] = $userent;
317
			}
318

    
319
			local_user_set($userent);
320
			local_user_set_groups($userent,$_POST['groups']);
321
			write_config();
322

    
323
			if(is_dir("/etc/inc/privhooks"))
324
				run_plugins("/etc/inc/privhooks");
325

    
326
			conf_mount_ro();
327
			
328
			pfSenseHeader("system_usermanager.php");
329
		}
330
	}
331

    
332
	include("head.inc");
333
?>
334

    
335
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
336
<?php include("fbegin.inc"); ?>
337
<!--
338
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
339
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
340
//For this script, visit http://www.javascriptkit.com
341
// -->
342
<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js"></script>
343
<script language="JavaScript">
344
<!--
345

    
346
function setall_selected(id) {
347
	selbox = document.getElementById(id);
348
	count = selbox.options.length;
349
	for (index = 0; index<count; index++)
350
		selbox.options[index].selected = true;
351
}
352

    
353
function clear_selected(id) {
354
	selbox = document.getElementById(id);
355
	count = selbox.options.length;
356
	for (index = 0; index<count; index++)
357
		selbox.options[index].selected = false;
358
}
359

    
360
function remove_selected(id) {
361
	selbox = document.getElementById(id);
362
	index = selbox.options.length - 1;
363
	for (; index >= 0; index--)
364
		if (selbox.options[index].selected)
365
			selbox.remove(index);
366
}
367

    
368
function copy_selected(srcid, dstid) {
369
	src_selbox = document.getElementById(srcid);
370
	dst_selbox = document.getElementById(dstid);
371
	count = src_selbox.options.length;
372
	for (index = 0; index < count; index++) {
373
		if (src_selbox.options[index].selected) {
374
			option = document.createElement('option');
375
			option.text = src_selbox.options[index].text;
376
			option.value = src_selbox.options[index].value;
377
			dst_selbox.add(option, null);
378
		}
379
	}
380
}
381

    
382
function move_selected(srcid, dstid) {
383
	copy_selected(srcid, dstid);
384
	remove_selected(srcid);
385
}
386

    
387
function presubmit() {
388
	clear_selected('notgroups');
389
	setall_selected('groups');
390
}
391

    
392
function usercertClicked(obj) {
393
	if (obj.checked) {
394
		document.getElementById("usercertchck").style.display="none";
395
		document.getElementById("usercert").style.display="";
396
	} else {
397
		document.getElementById("usercert").style.display="none";
398
		document.getElementById("usercertchck").style.display="";
399
	}
400
}
401

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

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

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

    
551
						<?php if ($pconfig['uid']): ?>
552

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

    
660
						<?php else : ?>
661
						<?php 	if (is_array($config['system']['ca']) && count($config['system']['ca']) > 0): ?>
662
						<?php		$i = 0; foreach( $config['system']['ca'] as $ca) {
663
                                                                        	if (!$ca['prv'])
664
                                                                                	continue;
665
										$i++;
666
									}
667
						?>
668

    
669
						<tr id="usercertchck" name="usercertchck" >
670
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
671
                                                	<td width="78%" class="vtable">
672
							<input type="checkbox" onClick="javascript:usercertClicked(this)"> <?=gettext("Click to create a user certificate."); ?>
673
							</td>
674
						</tr>
675

    
676
						<?php		if ($i > 0): ?>
677

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

    
726
						<?php 	endif; endif; ?>
727
						<?php endif; ?>
728

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

    
761
				<?php else: ?>
762

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

    
836
				<?php endif; ?>
837

    
838
			</div>
839
		</td>
840
	</tr>
841
</table>
842
<?php include("fend.inc");?>
843
</body>
844

    
845
<?php
846

    
847
	// end admin user code
848

    
849
} else {
850

    
851
	// start normal user code
852

    
853
	$pgtitle = array(gettext("System"),gettext("User Password"));
854

    
855
	if (isset($_POST['save'])) {
856
		unset($input_errors);
857

    
858
		/* input validation */
859
		$reqdfields = explode(" ", "passwordfld1");
860
		$reqdfieldsn = array(gettext("Password"));
861

    
862
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
863

    
864
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
865
			$input_errors[] = gettext("The passwords do not match.");
866

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

    
871
			write_config();
872
			$savemsg = gettext("Password successfully changed") . "<br />";
873
		}
874
	}
875

    
876
	/* determine if user is not local to system */
877
	$islocal = false;
878
	foreach($config['system']['user'] as $user) 
879
		if($user['name'] == $_SESSION['Username'])
880
			$islocal = true;
881
?>
882

    
883
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
884
<?php
885
    include("head.inc");
886
	include("fbegin.inc");
887
	if ($input_errors)
888
		print_input_errors($input_errors);
889
	if ($savemsg)
890
		print_info_box($savemsg);
891

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

    
934
<?php
935

    
936
} // end of normal user code
937

    
938
?>
(193-193/221)