Project

General

Profile

Download (25.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
##|+PRIV
39
##|*IDENT=page-system-usermanager
40
##|*NAME=System: User Manager page
41
##|*DESCR=Allow access to the 'System: User Manager' page.
42
##|*MATCH=system_usermanager.php*
43
##|-PRIV
44

    
45

    
46
require("guiconfig.inc");
47

    
48
if (isAllowedPage("system_usermanager")) {
49

    
50
	// start admin user code
51
	$pgtitle = array("System","User Manager");
52

    
53
	$id = $_GET['id'];
54
	if (isset($_POST['id']))
55
		$id = $_POST['id'];
56

    
57
	if (!is_array($config['system']['user'])) 
58
		$config['system']['user'] = array();
59

    
60
	admin_users_sort();
61
	$a_user = &$config['system']['user'];
62

    
63
	if ($_GET['act'] == "deluser") {
64

    
65
		if (!$a_user[$id]) {
66
			pfSenseHeader("system_usermanager.php");
67
			exit;
68
		}
69

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

    
78
	if ($_GET['act'] == "delpriv") {
79

    
80
		if (!$a_user[$id]) {
81
			pfSenseHeader("system_usermanager.php");
82
			exit;
83
		}
84

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

    
93
	if ($_GET['act'] == "expcert") {
94

    
95
		if (!$a_user[$id]) {
96
			pfSenseHeader("system_usermanager.php");
97
			exit;
98
		}
99

    
100
		$cert =& $a_user[$id]['cert'][$_GET['certid']];
101

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

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

    
113
	if ($_GET['act'] == "expckey") {
114

    
115
		if (!$a_user[$id]) {
116
			pfSenseHeader("system_usermanager.php");
117
			exit;
118
		}
119

    
120
		$cert =& $a_user[$id]['cert'][$_GET['certid']];
121

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

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

    
133
	if ($_GET['act'] == "delcert") {
134

    
135
		if (!$a_user[$id]) {
136
			pfSenseHeader("system_usermanager.php");
137
			exit;
138
		}
139

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

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

    
161
	if ($_GET['act'] == "new") {
162
		/*
163
		 * set this value cause the text field is read only
164
		 * and the user should not be able to mess with this
165
		 * setting.
166
		 */
167
		$pconfig['utype'] = "user";
168
	}
169

    
170
	if ($_POST) {
171
		conf_mount_rw();
172
		unset($input_errors);
173
		$pconfig = $_POST;
174

    
175
		/* input validation */
176
		if (isset($id) && ($a_user[$id])) {
177
			$reqdfields = explode(" ", "usernamefld");
178
			$reqdfieldsn = explode(",", "Username");
179
		} else {
180
			$reqdfields = explode(" ", "usernamefld passwordfld1");
181
			$reqdfieldsn = explode(",", "Username,Password");
182
		}
183

    
184
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
185

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

    
189
		if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
190
			$input_errors[] = gettext("The passwords do not match.");
191

    
192
		/* make sure this user name is unique */
193
		if (!$input_errors && !(isset($id) && $a_user[$id])) {
194
			foreach ($a_user as $userent) {
195
				if ($userent['name'] == $_POST['usernamefld']) {
196
					$input_errors[] = gettext("Another entry with the same username already exists.");
197
					break;
198
				}
199
			}
200
		}
201

    
202
		/*
203
		 * Check for a valid expirationdate if one is set at all (valid means,
204
		 * strtotime() puts out a time stamp so any strtotime compatible time
205
		 * format may be used. to keep it simple for the enduser, we only
206
		 * claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
207
		 * like "+1 day", which will be converted to MM/DD/YYYY based on "now".
208
		 * Otherwhise such an entry would lead to an invalid expiration data.
209
		 */
210
		if ($_POST['expires']){
211
			if(strtotime($_POST['expires']) > 0){
212
				if (strtotime("-1 day") > strtotime(date("m/d/Y",strtotime($_POST['expires'])))) {
213
					$input_errors[] = "The expiration date lies in the past.";
214
				} else {
215
					//convert from any strtotime compatible date to MM/DD/YYYY
216
					$expdate = strtotime($_POST['expires']);
217
					$_POST['expires'] = date("m/d/Y",$expdate);
218
				}
219
			} else {
220
				$input_errors[] = "Invalid expiration date format; use MM/DD/YYYY instead.";
221
			}
222
		}
223

    
224
		if (isset($config['system']['ssh']['sshdkeyonly']) && empty($_POST['authorizedkeys']))
225
			$input_errors[] = gettext("You must provide an authorized key otherwise you won't be able to login into this system.");
226

    
227
		/* if this is an AJAX caller then handle via JSON */
228
		if (isAjax() && is_array($input_errors)) {
229
			input_errors2Ajax($input_errors);
230
			exit;
231
		}
232

    
233
		if (!$input_errors) {
234
			$userent = array();
235
			if (isset($id) && $a_user[$id])
236
				$userent = $a_user[$id];
237

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

    
240
			/* the user name was modified */
241
			if ($_POST['usernamefld'] <> $_POST['oldusername'])
242
				$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
243

    
244
			/* the user password was mofified */
245
			if ($_POST['passwordfld1'])
246
				local_user_set_password($userent, $_POST['passwordfld1']);
247

    
248
			$userent['name'] = $_POST['usernamefld'];
249
			$userent['fullname'] = $_POST['fullname'];
250
			$userent['expires'] = $_POST['expires'];
251
			$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
252

    
253
			if (isset($id) && $a_user[$id])
254
				$a_user[$id] = $userent;
255
			else {
256
				$userent['uid'] = $config['system']['nextuid']++;
257
				$a_user[] = $userent;
258
			}
259

    
260
			local_user_set($userent);
261
			local_user_set_groups($userent,$_POST['groups']);
262
			write_config();
263

    
264
			conf_mount_ro();
265
			
266
			pfSenseHeader("system_usermanager.php");
267
		}
268
	}
269

    
270
	include("head.inc");
271
?>
272

    
273
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
274
<?php include("fbegin.inc"); ?>
275
<!--
276
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
277
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
278
//For this script, visit http://www.javascriptkit.com
279
// -->
280
<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js"></script>
281
<script language="JavaScript">
282
<!--
283

    
284
function setall_selected(id) {
285
	selbox = document.getElementById(id);
286
	count = selbox.options.length;
287
	for (index = 0; index<count; index++)
288
		selbox.options[index].selected = true;
289
}
290

    
291
function clear_selected(id) {
292
	selbox = document.getElementById(id);
293
	count = selbox.options.length;
294
	for (index = 0; index<count; index++)
295
		selbox.options[index].selected = false;
296
}
297

    
298
function remove_selected(id) {
299
	selbox = document.getElementById(id);
300
	index = selbox.options.length - 1;
301
	for (; index >= 0; index--)
302
		if (selbox.options[index].selected)
303
			selbox.remove(index);
304
}
305

    
306
function copy_selected(srcid, dstid) {
307
	src_selbox = document.getElementById(srcid);
308
	dst_selbox = document.getElementById(dstid);
309
	count = src_selbox.options.length;
310
	for (index = 0; index < count; index++) {
311
		if (src_selbox.options[index].selected) {
312
			option = document.createElement('option');
313
			option.text = src_selbox.options[index].text;
314
			option.value = src_selbox.options[index].value;
315
			dst_selbox.add(option, null);
316
		}
317
	}
318
}
319

    
320
function move_selected(srcid, dstid) {
321
	copy_selected(srcid, dstid);
322
	remove_selected(srcid);
323
}
324

    
325
function presubmit() {
326
	clear_selected('notgroups');
327
	setall_selected('groups');
328
}
329

    
330
//-->
331
</script>
332
<?php
333
	if ($input_errors)
334
		print_input_errors($input_errors);
335
	if ($savemsg)
336
		print_info_box($savemsg);
337
?>
338
<table width="100%" border="0" cellpadding="0" cellspacing="0">
339
	<tr>
340
		<td>
341
		<?php
342
			$tab_array = array();
343
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
344
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
345
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
346
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
347
			display_top_tabs($tab_array);
348
		?>
349
		</td>
350
	</tr>
351
	<tr>
352
		<td id="mainarea">
353
			<div class="tabcont">
354

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

    
357
				<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
358
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
359
						<?php
360
							$ro = "";
361
							if ($pconfig['utype'] == "system")
362
								$ro = "readonly = \"readonly\"";
363
						?>
364
	                    <tr>
365
	                        <td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
366
	                        <td width="78%" class="vtable">
367
	                            <strong><?=strtoupper($pconfig['utype']);?></strong>
368
								<input name="utype" type="hidden" value="<?=$pconfig['utype']?>"/>
369
	                        </td>
370
	                    </tr>
371
						<tr>
372
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
373
							<td width="78%" class="vtable">
374
								<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
375
								<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
376
							</td>
377
						</tr>
378
						<tr>
379
							<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
380
							<td width="78%" class="vtable">
381
								<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
382
							</td>
383
						</tr>
384
						<tr>
385
							<td width="78%" class="vtable">
386
								<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
387
							</td>
388
						</tr>
389
						<tr>
390
							<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
391
							<td width="78%" class="vtable">
392
								<input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<?=htmlspecialchars($pconfig['fullname']);?>" <?=$ro;?>/>
393
								<br/>
394
								<?=gettext("User's full name, for your own information only");?>
395
							</td>
396
						</tr>
397
						<tr>
398
							<td width="22%" valign="top" class="vncell">Expiration date</td>
399
							<td width="78%" class="vtable">
400
								<input name="expires" type="text" class="formfld unknown" id="expires" size="10" value="<?=$pconfig['expires'];?>">
401
								<a href="javascript:NewCal('expires','mmddyyyy')">
402
									<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_cal.gif" width="16" height="16" border="0" alt="Pick a date">
403
								</a>
404
								<br>
405
								<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>
406
						</tr>
407
						<tr>
408
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
409
							<td width="78%" class="vtable" align="center">
410
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
411
									<tr>
412
										<td align="center" width="50%">
413
											<strong>Not Member Of</strong><br/>
414
											<br/>
415
											<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onChange="clear_selected('groups')" multiple>
416
												<?php
417
													foreach ($config['system']['group'] as $group):
418
														if ($group['gid'] == 1998) /* all users group */
419
															continue;
420
														if (in_array($group['name'],$pconfig['groups']))
421
															continue;
422
												?>
423
												<option value="<?=$group['name'];?>" <?=$selected;?>>
424
													<?=htmlspecialchars($group['name']);?>
425
												</option>
426
												<?php endforeach; ?>
427
											</select>
428
											<br/>
429
										</td>
430
										<td>
431
											<br/>
432
											<a href="javascript:move_selected('notgroups','groups')">
433
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="Add Groups" alt="Add Groups" width="17" height="17" border="0" />
434
											</a>
435
											<br/><br/>
436
											<a href="javascript:move_selected('groups','notgroups')">
437
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="Remove Groups" alt="Remove Groups" width="17" height="17" border="0" />
438
											</a>
439
										</td>
440
										<td align="center" width="50%">
441
											<strong>Member Of</strong><br/>
442
											<br/>
443
											<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onChange="clear_selected('nogroups')" multiple>
444
												<?php
445
													foreach ($config['system']['group'] as $group):
446
														if ($group['gid'] == 1998) /* all users group */
447
															continue;
448
														if (!in_array($group['name'],$pconfig['groups']))
449
															continue;
450
												?>
451
												<option value="<?=$group['name'];?>">
452
													<?=htmlspecialchars($group['name']);?>
453
												</option>
454
												<?php endforeach; ?>
455
											</select>
456
											<br/>
457
										</td>
458
									</tr>
459
								</table>
460
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
461
							</td>
462
						</tr>
463

    
464
						<?php if ($pconfig['uid']): ?>
465

    
466
						<tr>
467
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
468
							<td width="78%" class="vtable">
469
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
470
									<tr>
471
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
472
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
473
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
474
										<td class="list"></td>
475
									</tr>
476
									<?php
477
											
478
										$privdesc = get_user_privdesc($a_user[$id]);
479
										if(is_array($privdesc)):
480
											$i = 0;
481
											foreach ($privdesc as $priv):
482
											$group = false;
483
											if ($priv['group'])
484
												$group = $priv['group'];
485
									?>
486
									<tr>
487
										<td class="listlr"><?=$group;?></td>
488
										<td class="listr">
489
											<?=htmlspecialchars($priv['name']);?>
490
										</td>
491
										<td class="listbg">
492
												<?=htmlspecialchars($priv['descr']);?>
493
										</td>
494
										<td valign="middle" nowrap class="list">
495
											<?php if (!$group): ?>
496
											<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
497
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
498
											</a>
499
											<?php endif; ?>
500
										</td>
501
									</tr>
502
									<?php
503
											/* can only delete user priv indexes */
504
											if (!$group)
505
												$i++;
506
											endforeach;
507
										endif;
508
									?>
509
									<tr>
510
										<td class="list" colspan="3"></td>
511
										<td class="list">
512
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
513
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
514
											</a>
515
										</td>
516
									</tr>
517
								</table>
518
							</td>
519
						</tr>
520
						<tr>
521
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
522
							<td width="78%" class="vtable">
523
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
524
									<tr>
525
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
526
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
527
										<td class="list"></td>
528
									</tr>
529
									<?php
530
										
531
										$a_cert = $a_user[$id]['cert'];
532
										if(is_array($a_cert)):
533
											$i = 0;
534
											foreach ($a_cert as $cert):
535
						                        $ca = lookup_ca($cert['caref']);
536
									?>
537
									<tr>
538
										<td class="listlr">
539
											<?=htmlspecialchars($cert['name']);?>
540
										</td>
541
										<td class="listr">
542
											<?=htmlspecialchars($ca['name']);?>
543
										</td>
544
										<td valign="middle" nowrap class="list">
545
											<a href="system_usermanager.php?act=expckey&id=<?=$id;?>&certid=<?=$i;?>">
546
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export private key" alt="export private key" width="17" height="17" border="0" />
547
											</a>
548
											<a href="system_usermanager.php?act=expcert&id=<?=$id;?>&certid=<?=$i;?>">
549
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export cert" alt="export cert" width="17" height="17" border="0" />
550
											</a>
551
											<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this certificate?");?>')">
552
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete cert" />
553
											</a>
554
										</td>
555
									</tr>
556
									<?php
557
												$i++;
558
											endforeach;
559
										endif;
560
									?>
561
									<tr>
562
										<td class="list" colspan="2"></td>
563
										<td class="list">
564
											<a href="system_usermanager_addcert.php?userid=<?=$id?>">
565
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
566
											</a>
567
										</td>
568
									</tr>
569
								</table>
570
							</td>
571
						</tr>
572

    
573
						<?php endif; ?>
574

    
575
						<tr>
576
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
577
							<td width="78%" class="vtable">
578
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
579
								<br/>
580
								<?=gettext("Paste an authorized keys file here.");?>
581
							</td>
582
						</tr>
583
						<tr>
584
							<td width="22%" valign="top">&nbsp;</td>
585
							<td width="78%">
586
								<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
587
								<?php if (isset($id) && $a_user[$id]): ?>
588
								<input name="id" type="hidden" value="<?=$id;?>" />
589
								<?php endif;?>
590
							</td>
591
						</tr>
592
					</table>
593
				</form>
594

    
595
				<?php else: ?>
596

    
597
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
598
					<tr>
599
						<td width="25%" class="listhdrr">Username</td>
600
						<td width="25%" class="listhdrr">Full name</td>
601
						<td width="30%" class="listhdrr">Groups</td>
602
						<td width="10%" class="list"></td>
603
					</tr>
604
					<?php
605
						$i = 0;
606
						foreach($a_user as $userent):
607
					?>
608
					<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
609
						<td class="listlr">
610
							<table border="0" cellpadding="0" cellspacing="0">
611
								<tr>
612
									<td align="left" valign="center">
613
										<?php
614
											if($userent['scope'] != "user")
615
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
616
											else
617
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
618
										?>
619
										<img src="<?=$usrimg;?>" alt="User" title="User" border="0" height="16" width="16" />
620
									</td>
621
									<td align="left" valign="middle">
622
										<?=htmlspecialchars($userent['name']);?>
623
									</td>
624
								</tr>
625
							</table>
626
						</td>
627
						<td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
628
						<td class="listbg">
629
								<?=implode(",",local_user_get_groups($userent));?>
630
							&nbsp;
631
						</td>
632
						<td valign="middle" nowrap class="list">
633
							<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
634
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="edit user" alt="edit user" width="17" height="17" border="0" />
635
							</a>
636
							<?php if($userent['scope'] != "system"): ?>
637
							&nbsp;
638
							<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
639
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete user" alt="delete user" width="17" height="17" border="0" />
640
							</a>
641
							<?php endif; ?>
642
						</td>
643
					</tr>
644
					<?php
645
							$i++;
646
						endforeach;
647
					?>
648
					<tr>
649
						<td class="list" colspan="3"></td>
650
						<td class="list">
651
							<a href="system_usermanager.php?act=new">
652
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add user" alt="add user" width="17" height="17" border="0" />
653
							</a>
654
						</td>
655
					</tr>
656
					<tr>
657
						<td colspan="3">
658
							<p>
659
								<?=gettext("Additional webConfigurator users can be added here.");?>
660
								<?=gettext("User permissions can be assinged diretly or inherited from group memberships.");?>
661
								<?=gettext("An icon that appears grey indicates that it is a system defined object.");?>
662
								<?=gettext("Some system object properties can be modified but they cannot be deleted.");?>
663
							</p>
664
						</td>
665
					</tr>
666
				</table>
667

    
668
				<?php endif; ?>
669

    
670
			</div>
671
		</td>
672
	</tr>
673
</table>
674
<?php include("fend.inc");?>
675
</body>
676

    
677
<?php
678

    
679
	// end admin user code
680

    
681
} else {
682

    
683
	// start normal user code
684

    
685
	$pgtitle = array("System","User Password");
686

    
687
	if (isset($_POST['save'])) {
688
		unset($input_errors);
689

    
690
		/* input validation */
691
		$reqdfields = explode(" ", "passwordfld1");
692
		$reqdfieldsn = explode(",", "Password");
693

    
694
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
695

    
696
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
697
			$input_errors[] = "The passwords do not match.";
698

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

    
703
			write_config();
704
			$savemsg = "Password successfully changed<br />";
705
		}
706
	}
707

    
708
	/* deterimine if user is not local to system */
709
	$islocal = false;
710
	foreach($config['system']['user'] as $user) 
711
		if($user['name'] == $_SESSION['Username'])
712
			$islocal = true;
713
?>
714

    
715
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
716
<?php
717
    include("head.inc");
718
	include("fbegin.inc");
719
	if ($input_errors)
720
		print_input_errors($input_errors);
721
	if ($savemsg)
722
		print_info_box($savemsg);
723

    
724
	if($islocal == false) {
725
		echo "Sorry, you cannot change the password for a LDAP user.";
726
		include("fend.inc");
727
		exit;
728
	}
729
?>
730
<div id="mainarea">
731
	<div class="tabcont">
732
		<form action="system_usermanager.php" method="post" name="iform" id="iform">
733
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
734
				<tr>
735
					<td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s Password</td>
736
				</tr>
737
				<tr>
738
					<td width="22%" valign="top" class="vncell" rowspan="2">Password</td>
739
					<td width="78%" class="vtable">
740
						<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
741
					</td>
742
				</tr>
743
				<tr>
744
					<td width="78%" class="vtable">
745
						<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
746
						&nbsp;<?=gettext("(confirmation)");?>
747
						<br/>
748
						<span class="vexpl">
749
							<?=gettext("Select a new password");?>
750
						</span>
751
					</td>
752
				</tr>
753
				<tr>
754
					<td width="22%" valign="top">&nbsp;</td>
755
					<td width="78%">
756
						<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
757
					</td>
758
				</tr>
759
			</table>
760
		</form>
761
	</div>
762
</div>
763
<?php include("fend.inc");?>
764
</body>
765

    
766
<?php
767

    
768
} // end of normal user code
769

    
770
?>
(180-180/206)