<?php 
	/*
	Hezecom Email Solution
	Author: Hezecom Technologies (http://hezecom.com) info@hezecom.net
	COPYRIGHT 2014 ALL RIGHTS RESERVED
	
	You must have purchased a valid license from CodeCanyon.com in order to have 
	access this file.

	You may only use this file according to the respective licensing terms 
	you agreed to when purchasing this item.
	*/	

	session_start();	
	include('../config/config.php');
	include('../language/eng.php');
	include('../libraries/functions.php');
	include_once('../libraries/class_dbcon.php');
	$db=DB::getInstance();
	//Find Password
	if($_POST)
	{
	$email = post('email');
	
	if ($email=='') { echo '<div class="alert alert-danger">'.LANG_ENTER_EMAIL_ADDRESS.'</div>';}
	if ($email!= ""){
	$sql = "SELECT COUNT(cemail) AS email from mailusers WHERE cemail =:cemail LIMIT 1";
	$stmt=$db->prepare($sql);
	$stmt->bindParam(':cemail',$email);
	$stmt->execute();
	$row=$stmt->fetch(PDO::FETCH_OBJ);
	//$stmt->fetchColumn()
	if($row->email>0){
	$sql = "SELECT  * FROM  mailusers WHERE cemail = :cemail LIMIT 1";
	$stmt=$db->prepare($sql);
	$stmt->bindParam(':cemail',$email);
	$stmt->execute();
	$row=$stmt->fetch(PDO::FETCH_OBJ);
	//the message
	$subject = LANG_PASSWORD_RECOVERY_SUBJECT; 
	$notes =LANG_PASSWORD_RECOVERY_MESSAGE1.$row->cusername.LANG_PASSWORD_RECOVERY_MESSAGE2.base64_decode($row->cpassword). 
	LANG_PASSWORD_RECOVERY_MESSAGE3; 
	$message = "
	$notes \n 
	";
	$from =LANG_FROM;
	mail($email, $subject, $message, $from);
	echo '<div class="alert alert-success">'.LANG_PASSWORD_SENT_SUCCESS.' '.$email.'</div>';
	}
	else{
	echo  '<div class="alert alert-danger">'.LANG_PASSWORD_NOT_SENT.' 
	<br> <a href = "../index.php" class="btn btn-info btn-sm">'.LANG_CLICK_TO_REGISTER.'</a></div>'; 
	}
	}}
	
	?>