Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/members/saaceadmin/
Upload File :
Current File : /var/www/cesa.co.za/members/saaceadmin/resetpw.phtml

<html>
<head>
<title>CESA Site Admin</title>
</head>
<body>
<h3>CESA site Administration</h3>
<?php
if ($id) {
	include('../inc/conf.inc');
	include('../inc/db.inc');
	
	$sql = "SELECT id FROM user_login WHERE contact_id = $id";
	//echo $sql;
	$result=mysql_query($sql);
	$result_rows=mysql_num_rows($result);
	if ($result_rows == 1) {	
	$sql = "SELECT PreferredEmail, ContactSurname, ContactInitials, ContactFirstName, ContactDesignation FROM Contacts WHERE ContactsID= $id";
	//echo $sql;
	$result = mysql_query($sql);
	$row=mysql_fetch_array($result);
	$email=$row["PreferredEmail"];
	$sn=$row["ContactSurname"];
	$ini=$row["ContactInitials"];
	$fn=$row["ContactFirstName"];
	$dg=$row["ContactDesignation"];
	$str = md5($email + time());
	$pass = substr($str,0,7);
	$lastlogin=gmdate("Y-m-d H:i:s",time()+7200);
	$lastupdate=gmdate("Y-m-d H:i:s",time()+7200);
	$logincount=0;
	
	$str = substr(md5($email + time()),0,8);
		
	$salt = substr(ereg_replace("[^A-Za-z0-9]", "", crypt(time()+2700)) .
         	ereg_replace("[^A-Za-z0-9]", "", crypt(time())) .
         	ereg_replace("[^A-Za-z0-9]", "", crypt(time())),
     		0, 20);
     	
     	$pass = crypt($str, $salt);
     	//echo $str." ".$pass." ".$salt;
     	$sql="UPDATE user_login SET password='$pass', salt='$salt' WHERE contact_id=$id";
     	//echo $sql;
     	$result = mysql_query($sql);
     	$subject="New Password for $dg $fn $ini $sn (cesa.co.za)";
	$msg="The password for $dg $fn $ini $sn has been changed by CESA.\nIf you have any questions, please contact CESA at +27 (011) 463 2022.\n\nYour username stays as it was.\n
	Your password: ".$str."\n\nTo visit the site, please go to http://www.cesa.co.za/members in your browser and login using the your username and the password from this email\n\nThank you\n\nMembership Services\nCESA";
	mail($email,$subject,$msg,"From: \"CESA Member Services\" <members@cesa.co.za>\nReply-to: members@cesa.co.za\n");
	echo "The member's password has been changed and mailed to them.<br>email address: <b>$email</b> <br> password: <b>$str</b> <br>";
	echo "Go back to <a href=\"/saaceadmin/\">saaceadmin</a>";
	
	} elseif ($result_rows > 1) {
		echo "More than one row returned";	
	} else {
		echo "This user is not currently registered";
	}
} else {
	echo "<b>Error</b>: No record specified. Please gpo back and choose a record.";
}
?>
</body>
</html>