Location: PHPKode > projects > PHP Enter > www/recovery.php
<?php  session_start();
if(@$_SESSION['INC_USER_ID'] == true){ echo"Error. Signin User";die();}
include('settings.php');
require_once('./languages/lang_'.$config['lang'].'.php');
$tmp = mysql_query("SELECT * FROM categori ORDER BY name ASC") 
or die("A MySQL error has occurred.<br />Your Query: " . $tmp . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());
while ($aclrow = mysql_fetch_assoc($tmp))
{
$ccval[] = $aclrow;
}
$smarty->assign('path',$path);
$smarty->assign('title',$title);
$smarty->assign('temp',$temp);
$smarty->assign('categori', $ccval);
$smarty->display('blank.php');
?>
<script language="JavaScript">
function validationEmail(maForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(maForm.email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}
</script>
<?php
if(isset($_POST['Submit']))
{
require_once('recaptchalib.php');
$privatekey = $config['keycaptcha'];
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) { 
die ($lang['RECAPTCHA']);
 }
if (!isset($_SESSION["jumps"]))
$_SESSION["jumps"] = 0;
$_SESSION["jumps"] = $_SESSION["jumps"] + 1;
if ($_SESSION["jumps"] > 3)
{
echo"404 Page";
die;
}
$ccemail = $_POST['email'];
$ccemail = addslashes($ccemail);
if (ereg("^\.",$ccemail)) {
echo "<center>Invalid Characters:</center>";  
Die();
}
if (ereg("\<", $ccemail)) {
echo "<center><span style=\"background:#FFF1A8\">Invalid Characters: <font color = \"black\"><strong><</strong></font> </center>";  
 Die();
}
if (ereg("\[", $ccemail)) {
echo "<center><span style=\"background:#FFF1A8\">Invalid Characters: <font color = \"black\"><strong>[</strong></font> </center>";  
 Die();
}
if (strlen($ccemail) < 2) {
echo "<center><span style=\"background:#FFF1A8\">Field must be at least 2 characters long
</center>";  
Die();
}
if (strlen($ccemail) > 40) {
echo "<center><span style=\"background:#FFF1A8\">Max Characters Field: 40
</center>";  
Die();
}
$query = "SELECT * FROM users where `email`  = '" . mysql_real_escape_string($ccemail) . "'";
$results = mysql_query($query);
$numResults = mysql_num_rows($results);
if ($numResults > 0) {
while ($ccrow = mysql_fetch_assoc($results))
{
$usid = $ccrow['usid'];
$username = $ccrow['username'];
$password = $ccrow['password'];
$email = $ccrow['email'];
}
} else {
echo"<div style=\"padding:5px;color:#555\" id=\"ercont\"><center>You have not entered an email address that we recognize. 
Please <a href=\"javascript:history.go(-1)\">try again</a> or contact the 
<a href=\"mailto:$ccmail?subject=$title\">administrator</a>.</center></div>";
die;
}
$tips = 'YjuPKnBfghfEeNqAuL';
$cchash = sha1(uniqid($tips . mt_rand(), true));
$result = mysql_query("UPDATE users SET tempass='$cchash' 
WHERE usid = '" . mysql_real_escape_string($usid) . "' ") 
or die(mysql_error());
$urlh = getenv('HTTP_HOST');
$urls = dirname($_SERVER['PHP_SELF']);
$myurl = "http://$urlh$urls" . "reset.php?id=" . $cchash;
$body ='
<html>
<head>
<style>
<!--
body, P.msoNormal, LI.msoNormal
{
background-position: top;
background-color: #ffffff;
margin-left:  2em;
margin-top: 1em;
font-family: verdana;
font-size:   10pt;
font-weight:normal;
color:   #555555;
lettet-spacing:1px;
}
h4{
font-weight:normal;
border-bottom:1px solid #A2BBCC;
}
</style>
</head>
<body> 
';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From: $ccmail" . "\r\n";
$bodys = "
<head>
<style>
#content{
align:center;
padding:5px;
margin:0px auto;
background:#fff;
border-top:2px solid #FF8300;
width:100%;
font-family;tahoma;
color:#222;
}
</style>
</head>
<div id = 'content'>
<h4>$title</h4>$lang[RETHEADE] \"$username\",<br />$lang[RETMESSG]<br /><br /><a href=\"$myurl\">$myurl</a><br /><br />
$lang[RETREGAR], $title $lang[RETTEAM]";
$subject = "$title";
mail($email, $subject, $bodys, $headers);
echo"<div style=\"padding:5px;color:#555\" id=\"ercont\"><center>$lang[PASTHE]</center></div></div>";
}else{
?>
<body>
<script type="text/javascript">
 var RecaptchaOptions = {
    theme : 'white'
 };
 </script>
<body style="text-align: center">
<div id="center">
<table width="100%" style="font-size:13px;"><tr><td>
<?php echo $lang['RETRIVED'] ?>
</td></tr></table>
<form name="maForm" action="recovery.php" method="post" onSubmit="return validationEmail(this)">
<table width="100%" style="font-size:13px;"><tr>
<td valign="top" width="195px"><?php echo $lang['EMAIL'] ?>:</td>
<td><input style="width:318px;" name="email" type="text">
</td></tr></table>
<table width="100%" style="font-size:13px;"><tr>
<td valign="top" width="195px">
<?php echo $lang['CODE'] ?>:</td>
<td>
<?php
require_once('recaptchalib.php');
$publickey = $config['keypublic'];
echo recaptcha_get_html($publickey);
?>
</td></tr></table>
<table width="100%" style="font-size:13px;"><tr>
<td valign="top" width="195px"></td>
<td><input class="incc" type="submit" style="color:#ffffff;border:1px solid #ffffff;background:#A5C6EC" value="<?php echo $lang['RECOVERY'] ?>" name="Submit" type="button">
</td></tr></table></form>
 </div>
  </td>
 </tr>
</table>
<?php } ?>
</div>
<?php $smarty->display('footer.php'); ?>
Return current item: PHP Enter