Project

General

Profile

Download (22.5 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'] == "delcert") {
94

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

    
100
		$certdeleted = $a_user[$id]['cert'][$_GET['certid']]['name'];
101
		unset($a_user[$id]['cert'][$_GET['certid']]);
102
		write_config();
103
		$_GET['act'] = "edit";
104
		$savemsg = gettext("Certificate")." {$certdeleted} ".
105
					gettext("successfully deleted")."<br/>";
106
	}
107

    
108
	if ($_GET['act'] == "edit") {
109
		if (isset($id) && $a_user[$id]) {
110
			$pconfig['usernamefld'] = $a_user[$id]['name'];
111
			$pconfig['fullname'] = $a_user[$id]['fullname'];
112
			$pconfig['groups'] = local_user_get_groups($a_user[$id]);
113
			$pconfig['utype'] = $a_user[$id]['scope'];
114
			$pconfig['uid'] = $a_user[$id]['uid'];
115
			$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
116
			$pconfig['priv'] = $a_user[$id]['priv'];
117
		}
118
	}
119

    
120
	if ($_GET['act'] == "new") {
121
		/*
122
		 * set this value cause the text field is read only
123
		 * and the user should not be able to mess with this
124
		 * setting.
125
		 */
126
		$pconfig['utype'] = "user";
127
	}
128

    
129
	if ($_POST) {
130
		unset($input_errors);
131
		$pconfig = $_POST;
132

    
133
		/* input validation */
134
		if (isset($id) && ($a_user[$id])) {
135
			$reqdfields = explode(" ", "usernamefld");
136
			$reqdfieldsn = explode(",", "Username");
137
		} else {
138
			$reqdfields = explode(" ", "usernamefld passwordfld1");
139
			$reqdfieldsn = explode(",", "Username,Password");
140
		}
141

    
142
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
143

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

    
147
		if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
148
			$input_errors[] = gettext("The passwords do not match.");
149

    
150
		/* make sure this user name is unique */
151
		if (!$input_errors && !(isset($id) && $a_user[$id])) {
152
			foreach ($a_user as $userent) {
153
				if ($userent['name'] == $_POST['usernamefld']) {
154
					$input_errors[] = gettext("Another entry with the same username already exists.");
155
					break;
156
				}
157
			}
158
		}
159

    
160
		if(is_array($_POST['groups']))
161
			foreach($_POST['groups'] as $groupname)
162
				if ($pconfig['utype'] <> "system" && !isset($groupindex[$groupname]))
163
					$input_errors[] = gettext("group {$groupname} does not exist, please define the group before assigning users.");
164

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

    
168
		/* if this is an AJAX caller then handle via JSON */
169
		if (isAjax() && is_array($input_errors)) {
170
			input_errors2Ajax($input_errors);
171
			exit;
172
		}
173

    
174
		if (!$input_errors) {
175
			$userent = array();
176
			if (isset($id) && $a_user[$id])
177
				$userent = $a_user[$id];
178

    
179
			/* the user name was modified */
180
			if ($_POST['usernamefld'] <> $_POST['oldusername'])
181
				$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
182

    
183
			/* the user password was mofified */
184
			if ($_POST['passwordfld1'])
185
				local_user_set_password($userent, $_POST['passwordfld1']);
186

    
187
			$userent['name'] = $_POST['usernamefld'];
188
			$userent['fullname'] = $_POST['fullname'];
189

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

    
192
			if(isset($config['system']['ssh']['sshdkeyonly']))
193
				$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
194

    
195
			if (isset($id) && $a_user[$id])
196
				$a_user[$id] = $userent;
197
			else {
198
				$userent['uid'] = $config['system']['nextuid']++;
199
				$a_user[] = $userent;
200
			}
201

    
202
			local_user_set($userent);
203
			local_user_set_groups($userent,$_POST['groups']);
204
			write_config();
205

    
206
			pfSenseHeader("system_usermanager.php");
207
		}
208
	}
209

    
210
	include("head.inc");
211
?>
212

    
213
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
214
<?php include("fbegin.inc"); ?>
215
<script language="JavaScript">
216
<!--
217

    
218
function setall_selected(id) {
219
	selbox = document.getElementById(id);
220
	count = selbox.options.length;
221
	for (index = 0; index<count; index++)
222
		selbox.options[index].selected = true;
223
}
224

    
225
function clear_selected(id) {
226
	selbox = document.getElementById(id);
227
	count = selbox.options.length;
228
	for (index = 0; index<count; index++)
229
		selbox.options[index].selected = false;
230
}
231

    
232
function remove_selected(id) {
233
	selbox = document.getElementById(id);
234
	index = selbox.options.length - 1;
235
	for (; index >= 0; index--)
236
		if (selbox.options[index].selected)
237
			selbox.remove(index);
238
}
239

    
240
function copy_selected(srcid, dstid) {
241
	src_selbox = document.getElementById(srcid);
242
	dst_selbox = document.getElementById(dstid);
243
	count = src_selbox.options.length;
244
	for (index = 0; index < count; index++) {
245
		if (src_selbox.options[index].selected) {
246
			option = document.createElement('option');
247
			option.text = src_selbox.options[index].text;
248
			option.value = src_selbox.options[index].value;
249
			dst_selbox.add(option, null);
250
		}
251
	}
252
}
253

    
254
function move_selected(srcid, dstid) {
255
	copy_selected(srcid, dstid);
256
	remove_selected(srcid);
257
}
258

    
259
function presubmit() {
260
	clear_selected('notgroups');
261
	setall_selected('groups');
262
}
263

    
264
//-->
265
</script>
266
<?php
267
	if ($input_errors)
268
		print_input_errors($input_errors);
269
	if ($savemsg)
270
		print_info_box($savemsg);
271
?>
272
<table width="100%" border="0" cellpadding="0" cellspacing="0">
273
	<tr>
274
		<td class="tabnavtbl">
275
		<?php
276
			$tab_array = array();
277
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
278
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
279
			$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
280
			$tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php");
281
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
282
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
283
			display_top_tabs($tab_array);
284
		?>
285
		</td>
286
	</tr>
287
	<tr>
288
		<td class="tabcont">
289

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

    
292
			<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
293
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
294
					<?php
295
						$ro = "";
296
						if ($pconfig['utype'] == "system")
297
							$ro = "readonly = \"readonly\"";
298
					?>
299
                    <tr>
300
                        <td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
301
                        <td width="78%" class="vtable">
302
                            <strong><?=strtoupper($pconfig['utype']);?></strong>
303
							<input name="utype" type="hidden" value="<?=$pconfig['utype']?>"/>
304
                        </td>
305
                    </tr>
306
					<tr>
307
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
308
						<td width="78%" class="vtable">
309
							<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
310
							<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
311
						</td>
312
					</tr>
313
					<tr>
314
						<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
315
						<td width="78%" class="vtable">
316
							<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
317
						</td>
318
					</tr>
319
					<tr>
320
						<td width="78%" class="vtable">
321
							<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
322
						</td>
323
					</tr>
324
					<tr>
325
						<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
326
						<td width="78%" class="vtable">
327
							<input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<?=htmlspecialchars($pconfig['fullname']);?>" <?=$ro;?>/>
328
							<br/>
329
							<?=gettext("User's full name, for your own information only");?>
330
						</td>
331
					</tr>
332

    
333
					<?php if (isset($config['system']['ssh']['sshdkeyonly'])): ?>
334

    
335
					<tr>
336
						<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
337
						<td width="78%" class="vtable">
338
							<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
339
							<br/>
340
							<?=gettext("Paste an authorized keys file here.");?>
341
						</td>
342
					</tr>
343

    
344
					<?php endif; ?>
345

    
346
					<tr>
347
						<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
348
						<td width="78%" class="vtable" align="center">
349
							<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
350
								<tr>
351
									<td align="center" width="50%">
352
										<strong>Not Member Of</strong><br/>
353
										<br/>
354
										<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onChange="clear_selected('groups')" multiple>
355
											<?php
356
												foreach ($config['system']['group'] as $group):
357
													if ($group['gid'] == 1998) /* all users group */
358
														continue;
359
													if (in_array($group['name'],$pconfig['groups']))
360
														continue;
361
											?>
362
											<option value="<?=$group['name'];?>" <?=$selected;?>>
363
												<?=htmlspecialchars($group['name']);?>
364
											</option>
365
											<?php endforeach; ?>
366
										</select>
367
										<br/>
368
									</td>
369
									<td>
370
										<br/>
371
										<a href="javascript:move_selected('notgroups','groups')">
372
											<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="Add Groups" alt="Add Groups" width="17" height="17" border="0" />
373
										</a>
374
										<br/><br/>
375
										<a href="javascript:move_selected('groups','notgroups')">
376
											<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="Remove Groups" alt="Remove Groups" width="17" height="17" border="0" />
377
										</a>
378
									</td>
379
									<td align="center" width="50%">
380
										<strong>Member Of</strong><br/>
381
										<br/>
382
										<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onChange="clear_selected('nogroups')" multiple>
383
											<?php
384
												foreach ($config['system']['group'] as $group):
385
													if ($group['gid'] == 1998) /* all users group */
386
														continue;
387
													if (!in_array($group['name'],$pconfig['groups']))
388
														continue;
389
											?>
390
											<option value="<?=$group['name'];?>">
391
												<?=htmlspecialchars($group['name']);?>
392
											</option>
393
											<?php endforeach; ?>
394
										</select>
395
										<br/>
396
									</td>
397
								</tr>
398
							</table>
399
							<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
400
						</td>
401
					</tr>
402

    
403
					<?php if ($pconfig['uid']): ?>
404

    
405
					<tr>
406
						<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
407
						<td width="78%" class="vtable">
408
							<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
409
								<tr>
410
									<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
411
									<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
412
									<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
413
									<td class="list"></td>
414
								</tr>
415
								<?php
416
										
417
									$privdesc = get_user_privdesc($a_user[$id]);
418
									if(is_array($privdesc)):
419
										$i = 0;
420
										foreach ($privdesc as $priv):
421
										$group = false;
422
										if ($priv['group'])
423
											$group = $priv['group'];
424
								?>
425
								<tr>
426
									<td class="listlr"><?=$group;?></td>
427
									<td class="listr">
428
										<?=htmlspecialchars($priv['name']);?>
429
									</td>
430
									<td class="listbg">
431
										<font color="#FFFFFF">
432
											<?=htmlspecialchars($priv['descr']);?>
433
										</font>
434
									</td>
435
									<td valign="middle" nowrap class="list">
436
										<?php if (!$group): ?>
437
										<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
438
											<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
439
										</a>
440
										<?php endif; ?>
441
									</td>
442
								</tr>
443
								<?php
444
										/* can only delete user priv indexes */
445
										if (!$group)
446
											$i++;
447
										endforeach;
448
									endif;
449
								?>
450
								<tr>
451
									<td class="list" colspan="3"></td>
452
									<td class="list">
453
										<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
454
											<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
455
										</a>
456
									</td>
457
								</tr>
458
							</table>
459
						</td>
460
					</tr>
461

    
462
					<?php endif; ?>
463

    
464
					<tr>
465
						<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
466
						<td width="78%" class="vtable">
467
							<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
468
								<tr>
469
									<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
470
									<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
471
									<td class="list"></td>
472
								</tr>
473
								<?php
474
										
475
									$a_cert = $a_user[$id]['cert'];
476
									if(is_array($a_cert)):
477
										$i = 0;
478
										foreach ($a_cert as $cert):
479
					                        $ca = lookup_ca($cert['caref']);
480
								?>
481
								<tr>
482
									<td class="listlr">
483
										<?=htmlspecialchars($cert['name']);?>
484
									</td>
485
									<td class="listr">
486
										<?=htmlspecialchars($ca['name']);?>
487
									</td>
488
									<td valign="middle" nowrap class="list">
489
										<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this certificate?");?>')">
490
											<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
491
										</a>
492
									</td>
493
								</tr>
494
								<?php
495
											$i++;
496
										endforeach;
497
									endif;
498
								?>
499
								<tr>
500
									<td class="list" colspan="2"></td>
501
									<td class="list">
502
										<a href="system_usermanager_addcert.php?userid=<?=$id?>">
503
											<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
504
										</a>
505
									</td>
506
								</tr>
507
							</table>
508
						</td>
509
					</tr>
510
					<tr>
511
						<td width="22%" valign="top">&nbsp;</td>
512
						<td width="78%">
513
							<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
514
							<?php if (isset($id) && $a_user[$id]): ?>
515
							<input name="id" type="hidden" value="<?=$id;?>" />
516
							<?php endif;?>
517
						</td>
518
					</tr>
519
				</table>
520
			</form>
521

    
522
			<?php else: ?>
523
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
524
				<tr>
525
					<td width="25%" class="listhdrr">Username</td>
526
					<td width="25%" class="listhdrr">Full name</td>
527
					<td width="30%" class="listhdrr">Groups</td>
528
					<td width="10%" class="list"></td>
529
				</tr>
530
				<?php
531
					$i = 0;
532
					foreach($a_user as $userent):
533
				?>
534
				<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
535
					<td class="listlr">
536
						<table border="0" cellpadding="0" cellspacing="0">
537
							<tr>
538
								<td align="left" valign="center">
539
									<?php
540
										if($userent['scope'] != "user")
541
											$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
542
										else
543
											$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
544
									?>
545
									<img src="<?=$usrimg;?>" alt="User" title="User" border="0" height="16" width="16" />
546
								</td>
547
								<td align="left" valign="middle">
548
									<?=htmlspecialchars($userent['name']);?>
549
								</td>
550
							</tr>
551
						</table>
552
					</td>
553
					<td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
554
					<td class="listbg">
555
						<font color="white">
556
							<?=implode(",",local_user_get_groups($userent));?>
557
						</font>
558
						&nbsp;
559
					</td>
560
					<td valign="middle" nowrap class="list">
561
						<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
562
							<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="edit user" alt="edit user" width="17" height="17" border="0" />
563
						</a>
564
						<?php if($userent['scope'] != "system"): ?>
565
						&nbsp;
566
						<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
567
							<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete user" alt="delete user" width="17" height="17" border="0" />
568
						</a>
569
						<?php endif; ?>
570
					</td>
571
				</tr>
572
				<?php
573
						$i++;
574
					endforeach;
575
				?>
576
				<tr>
577
					<td class="list" colspan="3"></td>
578
					<td class="list">
579
						<a href="system_usermanager.php?act=new">
580
							<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add user" alt="add user" width="17" height="17" border="0" />
581
						</a>
582
					</td>
583
				</tr>
584
				<tr>
585
					<td colspan="3">
586
						<p>
587
							<?=gettext("Additional webConfigurator users can be added here.");?>
588
							<?=gettext("User permissions can be assinged diretly or inherited from group memberships.");?>
589
							<?=gettext("An icon that appears grey indicates that it is a system defined object.");?>
590
							<?=gettext("Some system object properties can be modified but they cannot be deleted.");?>
591
						</p>
592
					</td>
593
				</tr>
594
			</table>
595

    
596
			<?php endif; ?>
597

    
598
		</td>
599
	</tr>
600
</table>
601
<?php include("fend.inc");?>
602
</body>
603

    
604
<?php
605

    
606
	// end admin user code
607

    
608
} else {
609

    
610
	// start normal user code
611

    
612
	$pgtitle = array("System","User Password");
613

    
614
	if (isset($_POST['save'])) {
615
		unset($input_errors);
616

    
617
		/* input validation */
618
		$reqdfields = explode(" ", "passwordfld1");
619
		$reqdfieldsn = explode(",", "Password");
620

    
621
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
622

    
623
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
624
			$input_errors[] = "The passwords do not match.";
625

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

    
630
			write_config();
631
			$savemsg = "Password successfully changed<br />";
632
		}
633
	}
634

    
635
	/* deterimine if user is not local to system */
636
	$islocal = false;
637
	foreach($config['system']['user'] as $user) 
638
		if($user['name'] == $_SESSION['Username'])
639
			$islocal = true;
640
?>
641

    
642
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
643
<?php
644
    include("head.inc");
645
	include("fbegin.inc");
646
	if ($input_errors)
647
		print_input_errors($input_errors);
648
	if ($savemsg)
649
		print_info_box($savemsg);
650

    
651
	if($islocal == false) {
652
		echo "Sorry, you cannot change the password for a LDAP user.";
653
		include("fend.inc");
654
		exit;
655
	}
656
?>
657
<form action="system_usermanager.php" method="post" name="iform" id="iform">
658
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
659
		<tr>
660
			<td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s Password</td>
661
		</tr>
662
		<tr>
663
			<td width="22%" valign="top" class="vncell" rowspan="2">Password</td>
664
			<td width="78%" class="vtable">
665
				<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
666
			</td>
667
		</tr>
668
		<tr>
669
			<td width="78%" class="vtable">
670
				<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
671
				&nbsp;<?=gettext("(confirmation)");?>
672
				<br/>
673
				<span class="vexpl">
674
					<?=gettext("Select a new password");?>
675
				</span>
676
			</td>
677
		</tr>
678
		<tr>
679
			<td width="22%" valign="top">&nbsp;</td>
680
			<td width="78%">
681
				<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
682
			</td>
683
		</tr>
684
	</table>
685
</form>
686
<?php include("fend.inc");?>
687
</body>
688

    
689
<?php
690

    
691
} // end of normal user code
692

    
693
?>
(179-179/215)