<?
//***************************************************
// http://www.niadesain.com
// Solusi Hemat Script Bisnis Online Anda
// Menerima Jasa Pembuatan Website & Template Website
//***************************************************
?>
<?
session_start();
include "config/koneksi.php";

function anti_injection($data){
  $filter = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES))));
  return $filter;
}

  $email      = anti_injection($_POST['email']);

  $login = mysql_query("SELECT email, username, pass, nama, status, blokir, counter from banner_kanan WHERE email='$email' limit 1");
  $ketemu = mysql_num_rows($login);
  $r = mysql_fetch_array($login);

// Apabila username dan password ditemukan
if ($ketemu > 0){
  session_start();

  $_SESSION[user_email]     = $r[email];
  $_SESSION[user_id]        = $r[username];
  $_SESSION[user_password]  = base64_decode($r[pass]);
  $_SESSION[user_nama]      = $r[nama];
  $_SESSION[user_status]    = $r[status];
  $_SESSION[user_blokir]    = $r[blokir];
  $_SESSION[user_counter]   = $r[counter];
  $_SESSION[admin_csemail]  = $cs_email;
  $_SESSION[admin_domain]   = $cs_domain;
  $_SESSION[admin_bisnis]   = $set_bisnis;
  $_SESSION[admin_caption]  = $set_caption;


        //echo "ok";
        //email lupa password ke member ---------------------------------------------------------
        //---------------------------------------------------------------------------------------
        $to       = htmlentities($cs_email);
	$to2      = htmlentities($email);
 	$subject2 = "Lupa password di $cs_domain";

        $from     =  $db->config("email_noreply"); //buat email account di cpanel dulu ya (peraturan baru)
        $headers2 = "From: $cs_domain <".$from.">\nX-Sender: ".$from."\n";

 	if($off == 1) {
		$filename = "../lupapassword.txt";
	} else {
		$filename = "lupapassword.txt";
	}
	$fp = fopen($filename, "r");
	$data = fread($fp, filesize($filename));
	fclose($fp);

	$data = preg_replace("/{NAMA}/", $_SESSION[user_nama], $data);
	$data = preg_replace("/{EMAIL}/", $email, $data);
	$data = preg_replace("/{USERID}/", $_SESSION[user_id], $data);
	$data = preg_replace("/{PASSWORD}/", $_SESSION[user_password], $data);
	$data = preg_replace("/{CS_EMAIL}/", $_SESSION[admin_csemail], $data);
	$data = preg_replace("/{CS_DOMAIN}/", $_SESSION[admin_domain], $data);
        $data = preg_replace("/{CS_BISNIS}/", $_SESSION[admin_bisnis], $data);
        $data = preg_replace("/{CS_CAPTION}/", $_SESSION[admin_caption], $data);
	$aemailbody = $data;
        @mail($to2, $subject2, $aemailbody, $headers2);
        include "kirimpasswordberhasil.php";


  } else {
        //echo "salah";
        include "kirimpasswordgagal.php";
}
?>