<?php
ob_start("ob_gzhandler");
error_reporting(0);
//error_reporting(E_ALL  & ~E_DEPRECATED);
//ini_set('display_errors', -1);
include_once 'includes/db.php';
include_once 'includes/User.php';
include_once 'includes/sendMail.php';
include_once 'includes/Mat_Updates.php';
session_start();
$session_uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : NULL; 
if(!empty($session_uid))
{
header("location:index.php");
}

$User = new User();

$Get_Configurations=$User->Get_Configurations();
$forgot=$Get_Configurations['forgot'];
//Login
$login_error='';

if($_SERVER["REQUEST_METHOD"] == "POST")
{
$recaptcha=$_POST['g-recaptcha-response'];
if(!empty($recaptcha))
{
include("getCurlData.php");
$google_url="https://www.google.com/recaptcha/api/siteverify";
$secret='  YOUR SECRET KEY ';
$ip=$_SERVER['REMOTE_ADDR'];
$url=$google_url."?secret=".$secret."&response=".$recaptcha."&remoteip=".$ip;
$res=getCurlData($url);
$res= json_decode($res, true);

if($_POST['user'] )
{
$username=$_POST['user'];

if (strlen($username)>0)
{


$forgot=$User->Forgot($username,$forgot);


if($forgot)
{
$Mat = new Mat_Updates();
$fuid=$Mat->User_ID($username);
$data=$Mat->User_Details($fuid);
$newpassword_url=$base_url.'newpassword.php?id='.$forgot;

include 'configurations.php';


$to=$data['email'];
$uname=$data['username'];

$emailName=$Mat->UserFullName($uname);


$subject ='Somebody request a new password for your '.$applicationName.' account';
$body="Hi ".$emailName.",<br/> <br/>Somebody recenlty asked to reset your ".$applicationName." password. <br/><br/><a href='".$newpassword_url."'>Click here to change your password.</a><br/><br/>Support<br/>".$base_url;

sendMail($to,$subject,$body,$smtpHost,$smtpPort,$smtpUsername,$smtpPassword,$smtpFrom,$applicationName);
$login_error="<span class='msg'>Please check your email for new password.</span>";


}
else
{
$login_error="<span class='error'>Wrong Username </span>";
}


}
}
else
{
$login_error="<span class='error'>Please prove you're not a robot</span>";
}

}
else
{
$login_error="<span class='error'>Please prove you're not a robot</span>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>SocialMat  || Login and Register Page</title>
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/animate.min.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script src="js/login.js" type="text/javascript"></script>  
<script src="js/loginsignup.js" type="text/javascript"></script> 
<script src="js/md.js"></script>
<script type="text/javascript">
$(window).load(function() {
 $('.preloader').addClass('animated fadeOut').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
 $('.preloader').hide();
});
$(".typed").typewriter({
   speed: 60
});	
});
</script>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>

<body>
<div class="preloader"><img src="css/icons/loader.gif" alt="Preloader image"></div>			
<div id="large-header" class="large-header">
<canvas id="demo-canvas"></canvas>
</div>
		
<div class="global-main-container">
<div class="site_logo"><span class="helper"></span><img src="css/icons/mainLogo.png" /></div>
<div class="tyy">
<div id="loginbox" >
<div class="box" style="min-height:50px">
<form method="post" action="" name="login">
<div class="input-global">
<input type="text" name="user" class="input-style back-newpass" placeholder="Username" AUTOCOMPLETE='OFF'/>
</div>
<div class="input-global">
<div class="g-recaptcha" data-sitekey=" YOUR DATA SITE KEY "></div>
</div>
<div ><?php echo $login_error; ?></div>
<div>
</div>
<div id="button">
<input type="submit" class="newpass_btn background-newpass" value="SUBMIT">
</div>
</div>
</form>

</div>
    </div>
</div>
<div class="footer"><div class="footer_in"><!--About Area--></div></div>
<script src="js/typewriter.js"></script>
<script src="js/bubble.js" type="text/javascript"></script>  
<script src="js/rAF.js" type="text/javascript"></script>  
</body>
</html>