Special Ops 2.50
[specialops2.git] / passwd.php
blobb084f1d3b49296eded387e7115a81a30f7ba7491
1 <?php
2 /**
3 * User Password Editor
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://COPYING
7 * @version 2.15
8 */
10 require 'con.php';
11 SO2::$Page->title = 'Change Password';
13 if ( ! (SO2::$User instanceof User_Authenticated) ) {
14 SO2::$Page->message(Page::ERR_LOGIN);
17 if ( isset($_POST['submit']) ) {
18 try {
19 if ( ! SO2::$User->check_nullpass()
20 && strval(SO2::$User->password) != $_POST['old'] ) {
21 throw new InvalidInputException('Old password does not match.');
23 if ( $_POST['new'] != $_POST['n2'] ) {
24 throw new InvalidInputException('New password not confirmed correctly.');
26 if ( ! strlen(trim($_POST['new'])) ) {
27 throw new InvalidInputException('New password must not be blank.');
30 SO2::$User->password = $_POST['new'];
31 setcookie('p', $_POST['new'], T_NOW+172800);
33 SO2::$Page->message('Password changed.', E_USER_NOTICE);
34 } catch ( InvalidInputException $e ) {
35 SO2::$Page->message($e->getMessage(), E_USER_WARNING);
37 } else {
38 SO2::$Page->pageheader();
42 <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
43 <table>
44 <tbody>
45 <tr>
46 <th scope="row"><label for="old">Old password</label></th>
47 <td><input type="password" name="old" id="old"<?php echo SO2::$User->check_nullpass() ? ' disabled="disabled"' : '' ?>/></td>
48 </tr>
49 <tr>
50 <th scope="row"><label for="new">New password</label></th>
51 <td><input type="password" name="new" id="new"/></td>
52 </tr>
53 <tr>
54 <th scope="row"><label for="n2">Retype password</label></th>
55 <td><input type="password" name="n2" id="n2"/></td>
56 </tr>
57 </tbody>
58 </table>
59 <p><button type="submit" name="submit">Confirm</button></p>
60 </form>