Reduced the gfh2 background image contrast a bit since it was hard to read text with it.
[specialops2.git] / passwd.php
blob2a1355ce67a34c1d49930d6aa150934bd23498f5
1 <?php
2 // $Id$
4 require 'con.php';
5 $page->title = 'Change Password';
7 if ( ! ($user instanceof authuser) )
8 $page->errorfooter('login');
10 if ( isset($_POST['submit']) ) {
11 try {
12 if ( !$user->check_nullpass() && $user->password != $_POST['old'] )
13 throw new InvalidInputException('Old password does not match.');
14 if ( $_POST['new'] != $_POST['n2'] )
15 throw new InvalidInputException('New password not confirmed correctly.');
16 if ( !strlen(trim($_POST['new'])) )
17 throw new InvalidInputException('New password must not be blank.');
19 $user->password = $_POST['new'];
20 setcookie('p', $_POST['new'], time()+86400, '/');
22 $user->userheader();
23 echo '<p class="notice">Password changed.</p>';
24 } catch ( InvalidInputException $e ) {
25 $user->userheader();
26 echo '<p class="error">',$e->getMessage(),'</p>';
28 } else
29 $user->userheader();
32 <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
33 <table>
34 <tbody>
35 <tr><th scope="row"><label for="old">Old password</label></th>
36 <td><input type="password" name="old" id="old"<?php
37 echo $user->check_nullpass() ? ' disabled="disabled"' : '' ?>/></td></tr>
38 <tr><th scope="row"><label for="new">New password</label></th>
39 <td><input type="password" name="new" id="new"/></td></tr>
40 <tr><th scope="row"><label for="n2">Retype password</label></th>
41 <td><input type="password" name="n2" id="n2"/></td></tr>
42 </tbody>
43 </table>
45 <p><button type="submit" name="submit" value="confirm" accesskey="c">Confirm (C)</button></p>
46 </form>
48 <?php
49 $page->pagefooter();