<?php ob_start(); 
error_reporting(0);
(@include ('./dt_page/common.php')) or die("<p style='font-family:Arial, Helvetica, sans-serif; margin-top:80px; font-size:16px; line-height:180%; letter-spacing:2px;' align='center'><img src='https://primadesain.com/images/block.png' width='90' height='90' /></br></br>Database failed, you can not access this script.<br>Please contact us to fix this error.<br><strong><a href='http://www.primadesain.com'>www.primadesain.com</a></strong></p><br><p style='font-family:Arial, Helvetica, sans-serif; margin-top:30px; font-size:12px; line-height:180%; letter-spacing:2px;' align='center'>&copy; 2009 - ".date("Y")." www.primadesain.com</p>");
(@include ('./dt_page/classMySQL.php')) or die("<p style='font-family:Arial, Helvetica, sans-serif; margin-top:80px; font-size:16px; line-height:180%; letter-spacing:2px;' align='center'><img src='https://primadesain.com/images/block.png' width='90' height='90' /></br></br>System failed, you can not access this script.<br>Please contact us to fix this error.<br><strong><a href='http://www.primadesain.com'>www.primadesain.com</a></strong></p><br><p style='font-family:Arial, Helvetica, sans-serif; margin-top:30px; font-size:12px; line-height:180%; letter-spacing:2px;' align='center'>&copy; 2009 - ".date("Y")." www.primadesain.com</p>");
$db = new db_mysql($server_name, $userdb, $passdb, $databasename,"");
(@include ('./dt_page/function.php')) or die("<p style='font-family:Arial, Helvetica, sans-serif; margin-top:80px; font-size:16px; line-height:180%; letter-spacing:2px;' align='center'><img src='https://primadesain.com/images/block.png' width='90' height='90' /></br></br>Function failed, you can not access this script.<br>Please contact us to fix this error.<br><strong><a href='http://www.primadesain.com'>www.primadesain.com</a></strong></p><br><p style='font-family:Arial, Helvetica, sans-serif; margin-top:30px; font-size:12px; line-height:180%; letter-spacing:2px;' align='center'>&copy; 2009 - ".date("Y")." www.primadesain.com</p>");
(@include ('./dt_page/affiliate.php')) or die("<p style='font-family:Arial, Helvetica, sans-serif; margin-top:80px; font-size:16px; line-height:180%; letter-spacing:2px;' align='center'><img src='https://primadesain.com/images/block.png' width='90' height='90' /></br></br>Refferal system failed, you can not access this script.<br>Please contact us to fix this error.<br><strong><a href='http://www.primadesain.com'>www.primadesain.com</a></strong></p><br><p style='font-family:Arial, Helvetica, sans-serif; margin-top:30px; font-size:12px; line-height:180%; letter-spacing:2px;' align='center'>&copy; 2009 - ".date("Y")." www.primadesain.com</p>");
if($db->config("maintenance") == 1){ ?>
<!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>
<!--
	/* 
	#######################
	http://primadesain.com
	primapc57@gmail.com
    +62 8122222044
	#######################
	*/
-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $db->config("title"); ?></title>
<link href="images/banner/<?php echo $db->config("fcon"); ?>" rel="SHORTCUT ICON" />
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<style>
 html, body {
                background-color: #fff;
                color: #636b6f;
                font-family: 'Raleway', sans-serif;
                font-weight: 100;
                margin: 0;
            }

            .flex-center {
                align-items: center;
                display: flex;
                justify-content: center;
            }
            .content {
                text-align: center;
				margin-top:50px;
            }

			.linetext {
                font-size: 20px;
                padding: 20px;
				max-width:600px;
				font-weight:bold;
				line-height:160%;
            }
			</style>
</head>
<body>
<div class="flex-center">
<div class="content">
<img src="images/maintenance.png" style="max-width:600px; width:100%;">
<div class="linetext"><?php echo $db->config("maintenance_info"); ?></div>
</div>
</div>
</body>
</html>
<?php } else { 
if($lang == 1){
include("./dt_page/langid.php");
}else{
include("./dt_page/langen.php");
}
require_once('./dt_page/class.phpmailer.php');
include("./dt_page/class.smtp.php");

if ($blockie == 1 && preg_match("/MSIE/",getenv("HTTP_USER_AGENT")) ||
preg_match("/Internet Explorer/",getenv("HTTP_USER_AGENT"))) {
include ('./block_ie.php');
exit;
}   
?>
<!doctype html>
<html class="no-js" lang="">

<head>
<!--
	/* 
	#######################
	http://primadesain.com
	primapc57@gmail.com
    +62 8122222044
	#######################
	*/
-->
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
      <meta name="author" content="<?php echo WEB_DOMAIN; ?>"/>
    <meta name="description" content="<?php echo WEB_DESC; ?>" />
    <meta name="keywords" content="<?php echo WEB_KEYWORDS; ?>" />
	<title>Forgot Password - <?php echo WEB_TITLE; ?></title>
    <link href="images/banner/<?php echo WEB_FAVCONS; ?>" rel="SHORTCUT ICON" /><!--favicon-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Favicon -->
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="logintheme/css/bootstrap.min.css">
    <!-- Fontawesome CSS -->
    <link rel="stylesheet" href="logintheme/css/fontawesome-all.min.css">
    <!-- Flaticon CSS -->
    <link rel="stylesheet" href="logintheme/font/flaticon.css">
    <!-- Google Web Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="logintheme/style.css">
	<script src='https://www.google.com/recaptcha/api.js'></script>
  <script src="js/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="css/sweetalert.css">  
</head>

<body>
    <!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->     
    <section class="fxt-template-animation fxt-template-layout28" data-bg-image="logintheme/img/figure/bg28-l.jpg">  
        <!-- Animation Start Here -->
        <div id="particles-js"></div>
        <!-- Animation End Here -->     
        <div class="fxt-content">
            <div class="fxt-header" style="margin-top:-30px;">
                <a href="index.php" class="fxt-logo" style="margin-bottom:25px;"><img src="logintheme/img/logo-28.png" alt="Logo" style="width:<?php echo $withlogone; ?>px;"></a> 
                <ul class="fxt-switcher-wrap">
                    <li><a href="login.php" class="switcher-text">Login</a></li>
                    <?php if($regpublic == 1){ ?><li><a href="signup.php" class="switcher-text">Register</a></li><?php } ?>
                    <li><a href="forgotpass.php" class="switcher-text active">Forgot Password</a></li>
                </ul>
            </div>                            
            <div class="fxt-form"> 
                <div class="fxt-transformY-50 fxt-transition-delay-1">
                    <p>Reset Your Password</p>
                    
                    
                    

                    
                    
     <?php
if(isset($_GET['result'])&&$_GET['result']=="no_session"){
echo '<script type=text/javascript>
              swal({
  title: "Error Session!",
  text: "Session Not Found!<br>Please update passwords through a link that we sent to your email.",
  type: "error",
  showCancelButton: false,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "OK",
  cancelButtonText: "No, cancel plx!",
  closeOnConfirm: true,
  closeOnCancel: false
});
              </script>';	
}
?>
		<?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo '<script type=text/javascript>
              swal({
  title: "Wrong Captcha!",
  type: "error",
  showCancelButton: false,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "OK",
  cancelButtonText: "No, cancel plx!",
  closeOnConfirm: true,
  closeOnCancel: false
});
              </script>';	
}
?>	  
	<?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_user"){
echo '<script type=text/javascript>
              swal({
  title: "User Not Found",
  type: "error",
  showCancelButton: false,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "OK",
  cancelButtonText: "No, cancel plx!",
  closeOnConfirm: true,
  closeOnCancel: false
});
              </script>';	
}
?>	  
  
	<?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_mail"){
echo '<script type=text/javascript>
              swal({
  title: "Wrong Email",
  type: "error",
  showCancelButton: false,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "OK",
  cancelButtonText: "No, cancel plx!",
  closeOnConfirm: true,
  closeOnCancel: false
});
              </script>';	
}
?>	

<?php
if(isset($_GET['result'])&&$_GET['result']=="already_sent"){
$m = $_GET['m'];
echo '<script type=text/javascript>
              swal({
  title: "Error",
  text: "You have sent a password reset as '.$m.' times, please proccess your reset password first before being able to send a password reset back.",
  type: "error",
  showCancelButton: false,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "OK",
  cancelButtonText: "No, cancel plx!",
  closeOnConfirm: true,
  closeOnCancel: false
});
              </script>';	
}
?>

<?php
if(isset($_GET['result'])&&$_GET['result']=="success"){
$m = $_GET['m'];
$m2=base64_decode($m);
echo '<script type=text/javascript>
              swal({
  title: "Success",
  text: "Reset password has been sent to '.$m2.', please check your mailbox.",
  type: "success",
  showCancelButton: false,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "OK",
  cancelButtonText: "No, cancel plx!",
  closeOnConfirm: true,
  closeOnCancel: false
});
              </script>';	
}
?>	
<?php
if(isset($_GET['result'])&&$_GET['result']=="refresh"){
$m = $_GET['m'];
$m2=base64_decode($m);
echo '<script type=text/javascript>
              swal({
  title: "Success",
  text: "reset password has been sent previously, please check your mailbox '.$m2.'.",
  type: "info",
  showCancelButton: false,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "OK",
  cancelButtonText: "No, cancel plx!",
  closeOnConfirm: true,
  closeOnCancel: false
});
              </script>';	
}
?>	               
                    
                    
           
                    
                    
                    
                    
                </div>
                
                
                                <?php
if (isset($_GET['do']) && $_GET['do'] == "send") {
	
if(isset($_GET["sess"])){ $sess = anti_injection($_GET["sess"]); }
if(isset($_GET["token"])){ $token = anti_injection($_GET["token"]); }


$cek=md5(md5(date('\i\t \i\s \t\h\e jS \d\a\y g a')).md5($sess));
if(!$sess || !$token || $token<>$cek){
header("location: ./forgotpass.php?result=no_session");
exit;

}else{
	
$captcha = isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response']:'';
$secret_key = $secret_key_google; //masukkan secret key-nya berdasarkan secret key masig-masing saat create api key nya
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secret_key) . '&response=' . $captcha;   
   $recaptcha = file_get_contents($url);
   $recaptcha = json_decode($recaptcha, true);
   if ($usecaptcha==1 && !$recaptcha['success']) { 
         header("location: forgotpass.php?result=wrong_captcha");
      } else {

		
		  
  $userid = anti_injection($_POST['username']);
	  
	  $db->select("username", "member", "username='".mysql_real_escape_string($userid)."'");
   
   
    if($db->num_rows() == 0){ 
		
      header("location:./forgotpass.php?result=wrong_user");
       // exit(); 
    } else {
    // Everything looks ok, generate password, update it and send it!
	$username = $db->result(0, "username");
	$nama = $db->dataku("nama",$username);
	$hp = $db->dataku("hp",$username);
	
 $email = anti_injection($_POST['email']);
		 
		 
$sqlc = mysql_query("SELECT * FROM member WHERE username='$userid' and email='$email'");
$numc = mysql_num_rows($sqlc);
if(!$numc) {
	header("location: ./forgotpass.php?result=wrong_mail");
	exit;
} else {

	
    //$sql = "UPDATE member SET pass='$db_password' WHERE username='$username'";
	//myquery($sql);
	$admin_email = $db->config("email");
	$clientdate    = (date ("Y-m-d H:i:s"));
	$tgl = formatgl($clientdate);
	$waktu = date("H:i:s");
	$time=time();
	$sess = substr(str_shuffle(str_repeat("ABCDEFGH45678IJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmno8367450162pqrstuvwxyz", 64)), 0, 64);
	$token = md5(md5($clientdate));
	$links = $changepass."?sess=".$sess."&token=".$token;
	
	$sql = mysql_query("SELECT * FROM changepass WHERE username='".mysql_real_escape_string($username)."'");
$num = mysql_num_rows($sql);
$rw=mysql_fetch_array($sql);
$batas = $rw['batas'];
if($batas == 3) {

header("location: ./forgotpass.php?result=already_sent&m=3");
	exit;


?>
<?php
}else{
if($num!= "") {
		$db->update("changepass", "date='$time', sess='$sess', token='$token', batas = batas + 1", "username='".mysql_real_escape_string($username)."'");	
		
	
	

$mail = new PHPMailer(); // defaults to using php "mail()"
$data = $mail_konfirmasi_reset_password_isi;
	$data = preg_replace("/{links}/", $links, $data);			
    $data = preg_replace("/{username}/", $username, $data);
    $data = preg_replace("/{tgl}/", $tgl, $data);
    $data = preg_replace("/{waktu}/", $waktu, $data);	
    $data = preg_replace("/{ipne}/", $ipne, $data);	
    $data = preg_replace("/{nama}/", $nama, $data);
	$data = preg_replace("/{hpadmin}/", $hpadmin, $data);			
    $data = preg_replace("/{alamatadmin}/", $alamatadmin, $data);
    $data = preg_replace("/{contactpage}/", $contactpage, $data);
    $data = preg_replace("/{login}/", $login, $data);
    $data = preg_replace("/{bisnisname}/", $bisnisname, $data);
    $data = preg_replace("/{logomail}/", $logomail, $data);
    $data = preg_replace("/{logourl}/", $logourl, $data);
    $data = preg_replace("/{emailadmin}/", $emailadmin, $data);
	$body = $data;
	
	$datax = $mail_konfirmasi_reset_password_subject;
	$datax = preg_replace("/{nama}/", $nama, $datax);	
	$subject_konfirmasi_reset_password = $datax;

//$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = $smtphost; // SMTP server
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = $smtphost; // sets the SMTP server
$mail->Port       = $smtport;                    // set the SMTP port for the GMAIL server
$mail->Username   = $smtpuser; // SMTP account username
$mail->Password   = $smtpass;        // SMTP account password

$mail->SetFrom(''.$emailadmin.'', ''.$bisnisname.'');
	$address = $email;
	$mail->AddAddress($address, "".$nama."");
	$mail->IsHTML(true);      
	$mail->Subject    = "".$subject_konfirmasi_reset_password."";
	$mail->AltBody    = "Pesan HTML, Untuk melihat pesan, silakan menggunakan peninjau HTML email yang kompatibel!"; // Alt Body
	$mail->MsgHTML($body);

$mail->Send();
if($hp){
$isipesan = "Hello ".$nama.", to reset your password, please use this link ".$links."";
sendwa($hp, $isipesan, $apikeywoowa);	
}

$ussx=base64_encode($email); 
header("location: ./forgotpass.php?result=refresh&m=$ussx");
	exit;

?>
<?php	

 
    }else{
	$db->insert("changepass", "", "'', '".mysql_real_escape_string($username)."', '$sess', '$time', '', '$token', '0'");
	
	$clientdate    = (date ("Y-m-d H:i:s"));
	$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");
		
$mail = new PHPMailer(); // defaults to using php "mail()"
$data = $mail_konfirmasi_reset_password_isi;
	$data = preg_replace("/{links}/", $links, $data);			
    $data = preg_replace("/{username}/", $username, $data);
    $data = preg_replace("/{tgl}/", $tgl, $data);
    $data = preg_replace("/{waktu}/", $waktu, $data);	
    $data = preg_replace("/{ipne}/", $ipne, $data);	
    $data = preg_replace("/{nama}/", $nama, $data);
	$data = preg_replace("/{hpadmin}/", $hpadmin, $data);			
    $data = preg_replace("/{alamatadmin}/", $alamatadmin, $data);
    $data = preg_replace("/{contactpage}/", $contactpage, $data);
    $data = preg_replace("/{login}/", $login, $data);
    $data = preg_replace("/{bisnisname}/", $bisnisname, $data);
    $data = preg_replace("/{logomail}/", $logomail, $data);
    $data = preg_replace("/{logourl}/", $logourl, $data);
    $data = preg_replace("/{emailadmin}/", $emailadmin, $data);
	$body = $data;
	
	$datax = $mail_konfirmasi_reset_password_subject;
	$datax = preg_replace("/{nama}/", $nama, $datax);	
	$subject_konfirmasi_reset_password = $datax;

if($mailset == 1){	
//$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = $smtphost; // SMTP server
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = $smtphost; // sets the SMTP server
$mail->Port       = $smtport;                    // set the SMTP port for the GMAIL server
$mail->Username   = $smtpuser; // SMTP account username
$mail->Password   = $smtpass;        // SMTP account password
}
$mail->SetFrom(''.$emailadmin.'', ''.$bisnisname.'');
	$address = $email;
	$mail->AddAddress($address, "".$nama."");
	$mail->IsHTML(true);      
	$mail->Subject    = "".$subject_konfirmasi_reset_password."";
	$mail->AltBody    = "Pesan HTML, Untuk melihat pesan, silakan menggunakan peninjau HTML email yang kompatibel!"; // Alt Body
	$mail->MsgHTML($body);

$mail->Send();
if($hp){
$isipesan = "Hello ".$nama.", to reset your password, please use this link ".$links."";
sendwa($hp, $isipesan, $apikeywoowa);	
}

$ussx=base64_encode($email); 
header("location: ./forgotpass.php?result=success&m=$ussx");
	exit;
	
}
}
}
}
}
}
}else{
?>
   <?php
$sess = substr(str_shuffle(str_repeat("ABCaqDEFG345678HIJKLMNOPQ345678RSTUVWXYZ0123456789abcdefghijklmnop32q34STUVW5678rstuvwxyz", 96)), 0, 96);
$token = md5(md5(date('\i\t \i\s \t\h\e jS \d\a\y g a')).md5($sess));
?>        
                
                <form action="forgotpass.php?do=send&sess=<?php echo $sess;?>&token=<?php echo $token;?>" method="POST">
                
                    <div class="form-group"> 
                        <div class="fxt-transformY-50 fxt-transition-delay-2">   
                    <input class="form-control" placeholder="Username" required name="username" type="text">                  
                        </div>
                    </div>
                    <div class="form-group">  
                        <div class="fxt-transformY-50 fxt-transition-delay-3">   
                    <input class="form-control" placeholder="Email Address" required name="email" type="email" value="">      
                        </div>
                    </div>
                    
                <?php if($usecaptcha==1){ ?>
                    <div class="form-group">  
                        <div class="fxt-transformY-50 fxt-transition-delay-3">    
						<div class="g-recaptcha" data-sitekey="<?php echo $site_key_google; ?>"></div>
                        </div>
                    </div>
                <?php } ?>
                    
                    
                    <div class="form-group">
                        <div class="fxt-transformY-50 fxt-transition-delay-4">
                            <div class="fxt-checkbox-area">
                            
                            
                            
                              <div id="showme" style="display:none;"><a href="forgotpass.php"><button type="button" class="fxt-btn-fill">Reload</button></a></div>
  <div id="loadingGif" style="display:none">
                                <img src="images/ld.gif" style="width:100px;"></div>
                                <button type="submit" class="fxt-btn-fill" name="submit" id="Login" onclick="showDiv()">Reset Password</button>
                                
                                
                            </div>
                            </div>
                        </div>
                    </div>
                </form>    
                
                
             <script type='text/javascript'>
   function showDiv() {
  document.getElementById('Login').style.display = "none";
  document.getElementById('loadingGif').style.display = "block";
  setTimeout(function() {
    document.getElementById('loadingGif').style.display = "none";
    document.getElementById('showme').style.display = "block";
  },2000);
   
}
</script>          
                
                <?php } ?>            
            </div> 
           
          
        </div>
    </section>    
    <!-- jquery-->
    <script src="logintheme/js/jquery-3.5.0.min.js"></script>
    <!-- Popper js -->
    <script src="logintheme/js/popper.min.js"></script>
    <!-- Bootstrap js -->
    <script src="logintheme/js/bootstrap.min.js"></script>
    <!-- Imagesloaded js -->
    <script src="logintheme/js/imagesloaded.pkgd.min.js"></script>
    <!-- Particles js -->
    <script src="logintheme/js/particles.js"></script>
    <script src="logintheme/js/particles-1.js"></script>
    <!-- Validator js -->
    <script src="logintheme/js/validator.min.js"></script>
    <!-- Custom Js -->
    <script src="logintheme/js/main.js"></script>


<script>
var width = $('.g-recaptcha').parent().width();
if (width < 302) {
	var scale = width / 302;
	$('.g-recaptcha').css('transform', 'scale(' + scale + ')');
	$('.g-recaptcha').css('-webkit-transform', 'scale(' + scale + ')');
	$('.g-recaptcha').css('transform-origin', '0 0');
	$('.g-recaptcha').css('-webkit-transform-origin', '0 0');
}
</script><?php if($stchat == 1) { include("tawkto.php"); 
} else if($stchat == 2) { include("whatshelp.php"); 
} else if($stchat == 3) { include("whatshelptawk.php"); 
} ?> 
</body>
</html>
<?php } ?>