Location: PHPKode > projects > Peardrop CMS > peardrop/password_reset.php
<!DOCTYPE html>
<html>
   <head>
	<?php 
	error_reporting(-1);
	$header = file_get_contents("inc/header");
	$meta = file_get_contents("inc/meta");
	$footer = file_get_contents("inc/footer");
	//Working Directories
	$dir = "content";
	include('./inc/folders.inc.php'); 
	?>
	<link href="./css/admin_style.css" type="text/css" rel="stylesheet">
	<title>Peardrop Admin Panel</title>
	<meta name="author" content="Ron Laws">
	<meta charset="utf-8">
	<script type="text/javascript" src="./ckeditor/ckeditor.js"></script>
  	<link rel="Stylesheet" href="spgm/flavors/default/spgm_style.css" />
  	<script src="spgm/spgm.js" type="text/javascript"></script>
 	 <script src="spgm/contrib/overlib410/overlib.js" type="text/javascript"></script>
	<SCRIPT LANGUAGE="JavaScript">
		<!-- Original:  Wayne Nolting (hide@address.com) -->

		<!-- This script and many more are available free online at -->
		<!-- The JavaScript Source!! http://javascript.internet.com -->

		<!-- Begin
		function verify() {
		var themessage = "You are required to complete the following fields: ";
		if (document.form.password.value=="") {
		themessage = themessage + " - Password";
		}
		if (document.form.email.value=="") {
		themessage = themessage + " -  E-mail";
		}
		//alert if fields are empty and cancel form submit
		if (themessage == "You are required to complete the following fields: ") {
		document.form.submit();
		}
		else {
		alert(themessage);
		return false;
		   }
		}
		//  End -->
	</script>
	<script type="text/javascript" src="./ckeditor/ckeditor.js"></script>
	    <link rel="stylesheet" href="./CodeMirror/lib/codemirror.css">
	    <script src="./CodeMirror/lib/codemirror.js"></script>
	    <script src="./CodeMirror/lib/util/overlay.js"></script>
	    <script src="./CodeMirror/mode/xml/xml.js"></script>
	    <script src="./CodeMirror/mode/css/css.js"></script>
	<link rel="stylesheet" type="text/css" href="./css/pro_dropdown_3.css" />
	<script src="./js/stuHover.js" type="text/javascript"></script>
	  <script src="./js/jquery-latest.js"></script>
	  <script>
	  $(document).ready(function(){
	   setTimeout(function(){
	  $("div.msgbox").fadeOut("slow", function () {
	  $("div.msgbox").remove();
	      });
	    
	}, 6000);
	 });
	  </script>
  
<body>
<div id="container">
   <div id="navigation">
	<ul>
	</ul>
   </div>
   <div id="content">
<?php
include('./config/passwd.inc.php');
function printForm()
{
print <<<ENDHTM
<br><br><br><br><br>
<div id="auth-box">
<form name="form" action="password_reset.php?reset=1" method="post">
		<p>
			Enter your Email Address:<br>
			
			<input type="text" name="email" value=""> <br>
		</p>
		<p>
			<input type="submit" value="Save" onclick="verify();">
		</p>
		</form>
		<a href="admin.php" alt="Back to admin">Back to login</a>
</div>
<br><br><br><br><br>
ENDHTM;
}
$reset = $_REQUEST['reset'];
if ($reset == 1){ 
$eml = $_POST['email'];
	if ($eml == $email){
		//make new password
		$temppass = md5(time());
		$string = '<?php 
		$username = "'.$username.'";
		$password = "'. md5($temppass). '";
		$email = "'.$email. '";
		?>';
		$fp = fopen("passwd.inc.php", "w");

		fwrite($fp, $string);
		fclose($fp);
		copy ("passwd.inc.php", "config/passwd.inc.php") or die ("Could not move file, check file permissions of $dir");
		unlink ("passwd.inc.php");
		chmod("config/passwd.inc.php", 0644);
		//email that to the administrator	
		mail($email, 'Password Reset', "As requested, a new password has been made for you, please log in using $temppass as your login password and then change it through the administration panel.");
			print ('
			<br><br><br><br><br>
			<div id="auth-box">
			<p>Your password has been reset, please check your email for instructions.</p>
			<a href="admin.php" alt="Back to admin">Back to login</a>
			</div>
			<br><br><br><br><br>
			');
	}else{
		echo("<div class=\"msgbox\"><p><img class=\"align-left\" src=\"./img/alert.png\" alt=\"info\">Wrong Email!</p></div>");
		printForm();
	}

}else{
	echo ("Password Reset Form:");
	echo("<div class=\"msgbox\"><p><img class=\"align-left\" src=\"./img/info.png\" alt=\"info\">Enter the admin email address</p></div>");
	printForm();
}

?>
   </div>
</body>
</html>
Return current item: Peardrop CMS