Project

General

Profile

Download (5.24 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / system_usermanager_passwordmg.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
    Copyright (C) 2011 Ermal Luçi
5
    system_usermanager.php
6

    
7
    Redistribution and use in source and binary forms, with or without
8
    modification, are permitted provided that the following conditions are met:
9

    
10
    1. Redistributions of source code must retain the above copyright notice,
11
       this list of conditions and the following disclaimer.
12

    
13
    2. Redistributions in binary form must reproduce the above copyright
14
       notice, this list of conditions and the following disclaimer in the
15
       documentation and/or other materials provided with the distribution.
16

    
17
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
    POSSIBILITY OF SUCH DAMAGE.
27
*/
28
/*
29
        pfSense_BUILDER_BINARIES:
30
        pfSense_MODULE: auth
31
*/
32

    
33
##|+PRIV
34
##|*IDENT=page-system-usermanager-passwordmg
35
##|*NAME=System: User Password Manager page
36
##|*DESCR=Allow access to the 'System: User Password Manager' page.
37
##|*MATCH=system_usermanager_passwordmg.php*
38
##|-PRIV
39

    
40
require_once("certs.inc");
41
require_once("guiconfig.inc");
42

    
43
$pgtitle = array(gettext("System"),gettext("User Password"));
44

    
45
if (isset($_POST['save'])) {
46
	unset($input_errors);
47
	/* input validation */
48

    
49
	$reqdfields = explode(" ", "passwordfld1");
50
	$reqdfieldsn = array(gettext("Password"));
51
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
52

    
53
	if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
54
		$input_errors[] = gettext("The passwords do not match.");
55

    
56
	if (!$input_errors) {
57
		if (!session_id())
58
			session_start();
59
		// all values are okay --> saving changes
60
		$config['system']['user'][$userindex[$_SESSION['Username']]]['password'] = crypt(trim($_POST['passwordfld1']));
61
		local_user_set($config['system']['user'][$userindex[$_SESSION['Username']]]);
62
		session_commit();
63

    
64
		write_config();
65

    
66
		$savemsg = gettext("Password successfully changed") . "<br />";
67
	}
68
}
69

    
70
if (!session_id())
71
	session_start();
72

    
73
/* determine if user is not local to system */
74
$islocal = false;
75
foreach($config['system']['user'] as $user)
76
	if($user['name'] == $_SESSION['Username'])
77
		$islocal = true;
78

    
79
session_commit();
80

    
81
include("head.inc");
82

    
83
?>
84

    
85
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
86
<?php
87
include("fbegin.inc");
88

    
89
if ($input_errors)
90
	print_input_errors($input_errors);
91
if ($savemsg)
92
	print_info_box($savemsg);
93

    
94
if ($islocal == false) {
95
	echo gettext("Sorry, you cannot change the password for a non-local user.");
96
	include("fend.inc");
97
	exit;
98
}
99

    
100
?>
101

    
102
<div id="mainarea">
103
        <div class="tabcont">
104
                <form action="system_usermanager_passwordmg.php" method="post" name="iform" id="iform">
105
                        <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
106
                                <tr>
107
<?php if (!session_id())
108
		session_start();
109
?>
110
                                        <td colspan="2" valign="top" class="listtopic"><?=$_SESSION['Username']?>'s <?=gettext("Password"); ?></td>
111
<?php session_commit(); ?>
112
                                </tr>
113
                                <tr>
114
                                        <td width="22%" valign="top" class="vncell" rowspan="2"><?=gettext("Password"); ?></td>
115
                                        <td width="78%" class="vtable">
116
                                                <input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
117
                                        </td>
118
                                </tr>
119
                                <tr>
120
                                        <td width="78%" class="vtable">
121
                                                <input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
122
                                                &nbsp;<?=gettext("(confirmation)");?>
123
                                                <br />
124
                                                <span class="vexpl">
125
                                                        <?=gettext("Select a new password");?>
126
                                                </span>
127
                                        </td>
128
                                </tr>
129
                                <tr>
130
                                        <td width="22%" valign="top">&nbsp;</td>
131
                                        <td width="78%">
132
                                                <input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
133
                                        </td>
134
                                </tr>
135
                        </table>
136
                </form>
137
        </div>
138
</div>
139
<?php include("fend.inc");?>
140
</body>
141
</html>
(231-231/256)