Project

General

Profile

Download (23.8 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['groups'] = local_user_get_groups($a_user[$id]);
153
			$pconfig['utype'] = $a_user[$id]['scope'];
154
			$pconfig['uid'] = $a_user[$id]['uid'];
155
			$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
156
			$pconfig['priv'] = $a_user[$id]['priv'];
157
		}
158
	}
159

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

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

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

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

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

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

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

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

    
204
		/* if this is an AJAX caller then handle via JSON */
205
		if (isAjax() && is_array($input_errors)) {
206
			input_errors2Ajax($input_errors);
207
			exit;
208
		}
209

    
210
		if (!$input_errors) {
211
			$userent = array();
212
			if (isset($id) && $a_user[$id])
213
				$userent = $a_user[$id];
214

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

    
217
			/* the user name was modified */
218
			if ($_POST['usernamefld'] <> $_POST['oldusername'])
219
				$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
220

    
221
			/* the user password was mofified */
222
			if ($_POST['passwordfld1'])
223
				local_user_set_password($userent, $_POST['passwordfld1']);
224

    
225
			$userent['name'] = $_POST['usernamefld'];
226
			$userent['fullname'] = $_POST['fullname'];
227
			$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
228

    
229
			if (isset($id) && $a_user[$id])
230
				$a_user[$id] = $userent;
231
			else {
232
				$userent['uid'] = $config['system']['nextuid']++;
233
				$a_user[] = $userent;
234
			}
235

    
236
			local_user_set($userent);
237
			local_user_set_groups($userent,$_POST['groups']);
238
			write_config();
239

    
240
			conf_mount_ro();
241
			
242
			pfSenseHeader("system_usermanager.php");
243
		}
244
	}
245

    
246
	include("head.inc");
247
?>
248

    
249
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
250
<?php include("fbegin.inc"); ?>
251
<script language="JavaScript">
252
<!--
253

    
254
function setall_selected(id) {
255
	selbox = document.getElementById(id);
256
	count = selbox.options.length;
257
	for (index = 0; index<count; index++)
258
		selbox.options[index].selected = true;
259
}
260

    
261
function clear_selected(id) {
262
	selbox = document.getElementById(id);
263
	count = selbox.options.length;
264
	for (index = 0; index<count; index++)
265
		selbox.options[index].selected = false;
266
}
267

    
268
function remove_selected(id) {
269
	selbox = document.getElementById(id);
270
	index = selbox.options.length - 1;
271
	for (; index >= 0; index--)
272
		if (selbox.options[index].selected)
273
			selbox.remove(index);
274
}
275

    
276
function copy_selected(srcid, dstid) {
277
	src_selbox = document.getElementById(srcid);
278
	dst_selbox = document.getElementById(dstid);
279
	count = src_selbox.options.length;
280
	for (index = 0; index < count; index++) {
281
		if (src_selbox.options[index].selected) {
282
			option = document.createElement('option');
283
			option.text = src_selbox.options[index].text;
284
			option.value = src_selbox.options[index].value;
285
			dst_selbox.add(option, null);
286
		}
287
	}
288
}
289

    
290
function move_selected(srcid, dstid) {
291
	copy_selected(srcid, dstid);
292
	remove_selected(srcid);
293
}
294

    
295
function presubmit() {
296
	clear_selected('notgroups');
297
	setall_selected('groups');
298
}
299

    
300
//-->
301
</script>
302
<?php
303
	if ($input_errors)
304
		print_input_errors($input_errors);
305
	if ($savemsg)
306
		print_info_box($savemsg);
307
?>
308
<table width="100%" border="0" cellpadding="0" cellspacing="0">
309
	<tr>
310
		<td>
311
		<?php
312
			$tab_array = array();
313
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
314
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
315
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
316
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
317
			display_top_tabs($tab_array);
318
		?>
319
		</td>
320
	</tr>
321
	<tr>
322
		<td id="mainarea">
323
			<div class="tabcont">
324

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

    
327
				<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
328
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
329
						<?php
330
							$ro = "";
331
							if ($pconfig['utype'] == "system")
332
								$ro = "readonly = \"readonly\"";
333
						?>
334
	                    <tr>
335
	                        <td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
336
	                        <td width="78%" class="vtable">
337
	                            <strong><?=strtoupper($pconfig['utype']);?></strong>
338
								<input name="utype" type="hidden" value="<?=$pconfig['utype']?>"/>
339
	                        </td>
340
	                    </tr>
341
						<tr>
342
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
343
							<td width="78%" class="vtable">
344
								<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
345
								<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
346
							</td>
347
						</tr>
348
						<tr>
349
							<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
350
							<td width="78%" class="vtable">
351
								<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
352
							</td>
353
						</tr>
354
						<tr>
355
							<td width="78%" class="vtable">
356
								<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
357
							</td>
358
						</tr>
359
						<tr>
360
							<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
361
							<td width="78%" class="vtable">
362
								<input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<?=htmlspecialchars($pconfig['fullname']);?>" <?=$ro;?>/>
363
								<br/>
364
								<?=gettext("User's full name, for your own information only");?>
365
							</td>
366
						</tr>
367
						<tr>
368
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
369
							<td width="78%" class="vtable" align="center">
370
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
371
									<tr>
372
										<td align="center" width="50%">
373
											<strong>Not Member Of</strong><br/>
374
											<br/>
375
											<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onChange="clear_selected('groups')" multiple>
376
												<?php
377
													foreach ($config['system']['group'] as $group):
378
														if ($group['gid'] == 1998) /* all users group */
379
															continue;
380
														if (in_array($group['name'],$pconfig['groups']))
381
															continue;
382
												?>
383
												<option value="<?=$group['name'];?>" <?=$selected;?>>
384
													<?=htmlspecialchars($group['name']);?>
385
												</option>
386
												<?php endforeach; ?>
387
											</select>
388
											<br/>
389
										</td>
390
										<td>
391
											<br/>
392
											<a href="javascript:move_selected('notgroups','groups')">
393
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="Add Groups" alt="Add Groups" width="17" height="17" border="0" />
394
											</a>
395
											<br/><br/>
396
											<a href="javascript:move_selected('groups','notgroups')">
397
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="Remove Groups" alt="Remove Groups" width="17" height="17" border="0" />
398
											</a>
399
										</td>
400
										<td align="center" width="50%">
401
											<strong>Member Of</strong><br/>
402
											<br/>
403
											<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onChange="clear_selected('nogroups')" multiple>
404
												<?php
405
													foreach ($config['system']['group'] as $group):
406
														if ($group['gid'] == 1998) /* all users group */
407
															continue;
408
														if (!in_array($group['name'],$pconfig['groups']))
409
															continue;
410
												?>
411
												<option value="<?=$group['name'];?>">
412
													<?=htmlspecialchars($group['name']);?>
413
												</option>
414
												<?php endforeach; ?>
415
											</select>
416
											<br/>
417
										</td>
418
									</tr>
419
								</table>
420
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
421
							</td>
422
						</tr>
423

    
424
						<?php if ($pconfig['uid']): ?>
425

    
426
						<tr>
427
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
428
							<td width="78%" class="vtable">
429
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
430
									<tr>
431
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
432
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
433
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
434
										<td class="list"></td>
435
									</tr>
436
									<?php
437
											
438
										$privdesc = get_user_privdesc($a_user[$id]);
439
										if(is_array($privdesc)):
440
											$i = 0;
441
											foreach ($privdesc as $priv):
442
											$group = false;
443
											if ($priv['group'])
444
												$group = $priv['group'];
445
									?>
446
									<tr>
447
										<td class="listlr"><?=$group;?></td>
448
										<td class="listr">
449
											<?=htmlspecialchars($priv['name']);?>
450
										</td>
451
										<td class="listbg">
452
												<?=htmlspecialchars($priv['descr']);?>
453
										</td>
454
										<td valign="middle" nowrap class="list">
455
											<?php if (!$group): ?>
456
											<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
457
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
458
											</a>
459
											<?php endif; ?>
460
										</td>
461
									</tr>
462
									<?php
463
											/* can only delete user priv indexes */
464
											if (!$group)
465
												$i++;
466
											endforeach;
467
										endif;
468
									?>
469
									<tr>
470
										<td class="list" colspan="3"></td>
471
										<td class="list">
472
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
473
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
474
											</a>
475
										</td>
476
									</tr>
477
								</table>
478
							</td>
479
						</tr>
480
						<tr>
481
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
482
							<td width="78%" class="vtable">
483
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
484
									<tr>
485
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
486
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
487
										<td class="list"></td>
488
									</tr>
489
									<?php
490
										
491
										$a_cert = $a_user[$id]['cert'];
492
										if(is_array($a_cert)):
493
											$i = 0;
494
											foreach ($a_cert as $cert):
495
						                        $ca = lookup_ca($cert['caref']);
496
									?>
497
									<tr>
498
										<td class="listlr">
499
											<?=htmlspecialchars($cert['name']);?>
500
										</td>
501
										<td class="listr">
502
											<?=htmlspecialchars($ca['name']);?>
503
										</td>
504
										<td valign="middle" nowrap class="list">
505
											<a href="system_usermanager.php?act=expckey&id=<?=$id;?>&certid=<?=$i;?>">
506
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export private key" alt="export private key" width="17" height="17" border="0" />
507
											</a>
508
											<a href="system_usermanager.php?act=expcert&id=<?=$id;?>&certid=<?=$i;?>">
509
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export cert" alt="export cert" width="17" height="17" border="0" />
510
											</a>
511
											<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this certificate?");?>')">
512
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete cert" />
513
											</a>
514
										</td>
515
									</tr>
516
									<?php
517
												$i++;
518
											endforeach;
519
										endif;
520
									?>
521
									<tr>
522
										<td class="list" colspan="2"></td>
523
										<td class="list">
524
											<a href="system_usermanager_addcert.php?userid=<?=$id?>">
525
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
526
											</a>
527
										</td>
528
									</tr>
529
								</table>
530
							</td>
531
						</tr>
532

    
533
						<?php endif; ?>
534

    
535
						<tr>
536
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
537
							<td width="78%" class="vtable">
538
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
539
								<br/>
540
								<?=gettext("Paste an authorized keys file here.");?>
541
							</td>
542
						</tr>
543
						<tr>
544
							<td width="22%" valign="top">&nbsp;</td>
545
							<td width="78%">
546
								<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
547
								<?php if (isset($id) && $a_user[$id]): ?>
548
								<input name="id" type="hidden" value="<?=$id;?>" />
549
								<?php endif;?>
550
							</td>
551
						</tr>
552
					</table>
553
				</form>
554

    
555
				<?php else: ?>
556

    
557
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
558
					<tr>
559
						<td width="25%" class="listhdrr">Username</td>
560
						<td width="25%" class="listhdrr">Full name</td>
561
						<td width="30%" class="listhdrr">Groups</td>
562
						<td width="10%" class="list"></td>
563
					</tr>
564
					<?php
565
						$i = 0;
566
						foreach($a_user as $userent):
567
					?>
568
					<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
569
						<td class="listlr">
570
							<table border="0" cellpadding="0" cellspacing="0">
571
								<tr>
572
									<td align="left" valign="center">
573
										<?php
574
											if($userent['scope'] != "user")
575
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
576
											else
577
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
578
										?>
579
										<img src="<?=$usrimg;?>" alt="User" title="User" border="0" height="16" width="16" />
580
									</td>
581
									<td align="left" valign="middle">
582
										<?=htmlspecialchars($userent['name']);?>
583
									</td>
584
								</tr>
585
							</table>
586
						</td>
587
						<td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
588
						<td class="listbg">
589
								<?=implode(",",local_user_get_groups($userent));?>
590
							&nbsp;
591
						</td>
592
						<td valign="middle" nowrap class="list">
593
							<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
594
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="edit user" alt="edit user" width="17" height="17" border="0" />
595
							</a>
596
							<?php if($userent['scope'] != "system"): ?>
597
							&nbsp;
598
							<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
599
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete user" alt="delete user" width="17" height="17" border="0" />
600
							</a>
601
							<?php endif; ?>
602
						</td>
603
					</tr>
604
					<?php
605
							$i++;
606
						endforeach;
607
					?>
608
					<tr>
609
						<td class="list" colspan="3"></td>
610
						<td class="list">
611
							<a href="system_usermanager.php?act=new">
612
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add user" alt="add user" width="17" height="17" border="0" />
613
							</a>
614
						</td>
615
					</tr>
616
					<tr>
617
						<td colspan="3">
618
							<p>
619
								<?=gettext("Additional webConfigurator users can be added here.");?>
620
								<?=gettext("User permissions can be assinged diretly or inherited from group memberships.");?>
621
								<?=gettext("An icon that appears grey indicates that it is a system defined object.");?>
622
								<?=gettext("Some system object properties can be modified but they cannot be deleted.");?>
623
							</p>
624
						</td>
625
					</tr>
626
				</table>
627

    
628
				<?php endif; ?>
629

    
630
			</div>
631
		</td>
632
	</tr>
633
</table>
634
<?php include("fend.inc");?>
635
</body>
636

    
637
<?php
638

    
639
	// end admin user code
640

    
641
} else {
642

    
643
	// start normal user code
644

    
645
	$pgtitle = array("System","User Password");
646

    
647
	if (isset($_POST['save'])) {
648
		unset($input_errors);
649

    
650
		/* input validation */
651
		$reqdfields = explode(" ", "passwordfld1");
652
		$reqdfieldsn = explode(",", "Password");
653

    
654
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
655

    
656
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
657
			$input_errors[] = "The passwords do not match.";
658

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

    
663
			write_config();
664
			$savemsg = "Password successfully changed<br />";
665
		}
666
	}
667

    
668
	/* deterimine if user is not local to system */
669
	$islocal = false;
670
	foreach($config['system']['user'] as $user) 
671
		if($user['name'] == $_SESSION['Username'])
672
			$islocal = true;
673
?>
674

    
675
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
676
<?php
677
    include("head.inc");
678
	include("fbegin.inc");
679
	if ($input_errors)
680
		print_input_errors($input_errors);
681
	if ($savemsg)
682
		print_info_box($savemsg);
683

    
684
	if($islocal == false) {
685
		echo "Sorry, you cannot change the password for a LDAP user.";
686
		include("fend.inc");
687
		exit;
688
	}
689
?>
690
<div id="mainarea">
691
	<div class="tabcont">
692
		<form action="system_usermanager.php" method="post" name="iform" id="iform">
693
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
694
				<tr>
695
					<td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s Password</td>
696
				</tr>
697
				<tr>
698
					<td width="22%" valign="top" class="vncell" rowspan="2">Password</td>
699
					<td width="78%" class="vtable">
700
						<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
701
					</td>
702
				</tr>
703
				<tr>
704
					<td width="78%" class="vtable">
705
						<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
706
						&nbsp;<?=gettext("(confirmation)");?>
707
						<br/>
708
						<span class="vexpl">
709
							<?=gettext("Select a new password");?>
710
						</span>
711
					</td>
712
				</tr>
713
				<tr>
714
					<td width="22%" valign="top">&nbsp;</td>
715
					<td width="78%">
716
						<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
717
					</td>
718
				</tr>
719
			</table>
720
		</form>
721
	</div>
722
</div>
723
<?php include("fend.inc");?>
724
</body>
725

    
726
<?php
727

    
728
} // end of normal user code
729

    
730
?>
(189-189/216)