Location: PHPKode > scripts > SelectaPix Image Gallery > admin/change_passwd.php
<?php
/* +----------------------------------------------------------------------+
   |SelectaPix Open Source Gallery	                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 2004 OutOfTheTrees			                          |
   |                                                                      |
   | http://www.outofthetrees.co.uk/index.php                             |
   | 												                      |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.0 of the GPL license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.outofthetrees.co.uk/license/2_0.txt.                      |
   | If you did not receive a copy of the SelectaPix license and are 	  |
   | unable to obtain it through the world-wide-web, please send a note   |
   | to hide@address.com so we can mail you a copy immediately.|
   +----------------------------------------------------------------------+ */
require_once("includes/inc_global_fns.php");
session_start();
do_html_header("Changing password");
$user->check_valid_user(1);
do_html_heading("<span>".SITE_NAME."</span> Change Password");
echo "<div id=\"breadcrumbtrail\"><a href=\"member.php\">Main Admin Area</a> &gt;&gt; Change Password</div>";
if ($_POST) {
	$username = $_SESSION['valid_user'];
	$old_passwd = $_POST['old_passwd'];
	$new_passwd = $_POST['new_passwd'];
	$new_passwd2 = $_POST['new_passwd2'];
	if (!$user->filled_out($_POST)) {
		echo '<p class="badnews">You have not filled out the form completely.
	         	Please try again.</p>';
	   	display_password_form();
	   	do_html_footer(nokwikenav);
	   	exit;
	}
	else {
		if($_SESSION['RoleLevel'] <= 2) {
	        echo '<p class="badnews">You do not have sufficient administrative rights to perform this action<br />';
	        echo 'Please click <a href="member.php">here</a> and try another link.<br />';
		    echo 'If you believe that you should have access please contact the site administrator.</p>';
	    }
		elseif ($new_passwd != $new_passwd2) {
	    	echo '<p class="badnews">Passwords entered were not the same. Password not changed. Please try again.</p>';
	       	display_password_form();
	    }
	    elseif (strlen($new_passwd)>16 || strlen($new_passwd)<6) {
	    	echo '<p class="badnews">New password must be between 6 and 16 characters. Please try again.</p>';
	       	display_password_form();
	    }
	    elseif ($new_passwd == $old_passwd) {
	    	echo '<p class="badnews">The new password you entered is the same as the old one. Please try again.</p>';
	       	display_password_form();
	    }
	    else {
	        // attempt update
		    if ($user->change_password($username, $old_passwd, $new_passwd)) {
		      	echo '<p class="goodnews">Password changed.</p>';
				display_user_menu();
		    }
		    else {
		       	echo '<p class="badnews">Unknown Error&#8212;password could not be changed.</p>';
		       	display_password_form();
		    }
	 	}
	}
}
else {
	display_password_form();
}
do_html_footer('5', 'nokwikenav');
?>
Return current item: SelectaPix Image Gallery