<?php ob_start(); ?>
<?php
if (basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)){
echo "<p align=center><br><br><br><br><br><br><font size=\"6\" color=\"#FF0000\">ILLEGAL ACCESS !!";
echo "<meta http-equiv=\"refresh\" content=\"2; url=../index.php\">";
exit();} 
// // #-----------------------------------------------------------------------------#
// // #-------------------------------.*PRIMADESAIN*.-------------------------------#
// // #-------------------------------: Script MMM3 :-------------------------------#
// // #------------------- Copyright 2009-2015 Primadesain.com ---------------------#
// // #----------- Email: primapc57@gmail.com Phone: +62 852 2865 7360 -------------#
// // #--------- http://www.primadesain.com - http://www.primadesain.net -----------#
// // #-----------------------------------------------------------------------------#
// // #------------- Primadesain.Com | Jasa Webdesain Bisnis Online ----------------#
// // #--- Website Bisnis MLM, Bisnis Investasi, Forex, Hyip, Binary, Trinary, -----#
// // #------- Matrix 4 -- 10, Toko Online, Iklan Baris, Profil, Reseller. ---------#
// // #-----------------------------------------------------------------------------#
// // # This software is  furnished  under a  license and may  be used and   copied #
// // # only  in accordance with the terms of such  license and with  the inclusion #
// // # of  the above copyright notice.  This software or any other  copies thereof #
// // # may not be  provided or otherwise made available  to any other person.   No #
// // # title to and  ownership of the software is hereby transferred.              #
// // #                                                                             #
// // # You  may  not  reverse   engineer,  decompile,  defeat  license  encryption #
// // # mechanisms, or  disassemble  this  software  product  or software   product #
// // # license. We  may terminate  this license if you  don't comply  with any  of #
// // # the terms and   conditions set forth   in our  End  User  License Agreement #
// // # (EULA). In  such event, licensee  agrees to return licensor or  destroy all #
// // # copies of software upon termination  of the license.                        #
// // # Please see the EULA file for the full End User License Agreement.           #
// // ###############################################################################
?>

<?php
if($db->dataku("status", $user_session) == 0 || $db->dataku("blokir", $user_session) == 1) {
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["status0"]."</div>";
}else{
?>
<div class="col-md-9">
<?php
 if(isset($_GET['result'])&&$_GET['result']=="success"){
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["sschgepin"]."</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="blocked"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["pinblock"]."</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_oldpin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["oldpinwr"]."</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_newpin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["newpinwr"]."</div>";
}
?>

<?php
 if(isset($_GET['result'])&&$_GET['result']=="restrict"){
if(isset($_GET['rem'])) { $rem = base64_decode($_GET['rem']); } 
echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Please wait ".$rem." to change PIN again.</div>";
}
?> 
<?php
if (isset($_GET['page']) && $_GET['page'] == "update") {



$sql232    = "SELECT * FROM pincode WHERE username='$user_session'";
$hasil232  = mysql_query($sql232);
$jumlah232 = mysql_num_rows($hasil232);
// Apabila kode verifikasi ditemukan
$data232=mysql_fetch_array($hasil232);
$batas = $data232['batas'];

if($batas > $clientdate){

$to_time = strtotime($batas);
$from_time = strtotime($clientdate);
$remain = base64_encode(round(abs($to_time - $from_time) / 60). " minute");

header("location: ?go=requestpin&result=restrict&rem=$remain");
exit;
} else {


$username = $_POST['username'];		
$status = $_POST['status'];		
$pincods = md5($_POST['pincode']);
$pincodsx = $_POST['pincodex'];	


	if($pincods <> $pincodsx) {
	$expired = date('Y-m-d H:i:s', strtotime("+ 5 minutes"));
	$db->update("pincode", "batas='$expired'", "username='$user_session'");
	
 header("location: ?go=requestpin&result=wrong_oldpin");
	exit;

 } else {


$pin = $_POST['pin'];
$username = $_POST['username'];

$pine = md5($pin);

$db->update("pincode", "pin = '$pine', tgl = '$clientdate'", "username='$username'");
			$db->update("acc", "pin='$pin'", "username='$user_session'");
	
	$nama = $db->dataku("nama", $username);
		$email = $db->dataku("email", $username);
		$emailadmin = $db->config("email");
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");
if($mail_ubah_pin_status == 1){		
$mail = new PHPMailer(); // defaults to using php "mail()"
$data = $mail_ubah_pin_isi;
	$data = preg_replace("/{nama}/", $nama, $data);			
    $data = preg_replace("/{pinbaru}/", $pin, $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("/{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_ubah_pin_subject;
	$datax = preg_replace("/{nama}/", $nama, $datax);	
	$subject_ubah_pin = $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_ubah_pin."";
	$mail->AltBody    = "Pesan HTML, Untuk melihat pesan, silakan menggunakan peninjau HTML email yang kompatibel!"; // Alt Body
	$mail->MsgHTML($body);

$mail->Send();
}
header("location: ?go=requestpin&result=success");
	exit;

}
}
?>

<?php
}else if (isset($_GET['page']) && $_GET['page'] == "check") {

require('../dt_page/php-captcha.inc.php');
	
	session_start();	
$captcha = $_POST['php_captcha']; // the user's entry for the captcha code

      require_once('../securimage/securimage.php');
      $securimage = new Securimage();

      if ($securimage->check($captcha) == false) {
        header("location: ?go=requestpin&result=wrong_captcha");
	exit;

      } else {
	  

$username = $_POST['username'];		
$status = $_POST['status'];		
$pincods = md5($_POST['pincode']);
$pincodsx = $_POST['pincodex'];	


	if($pincods <> $pincodsx) {
	
	 mysql_query("UPDATE pincode SET batas = batas + 1 where username='$username'");
	$sqlg="SELECT batas, username FROM pincode WHERE username='$username'"; 
    $dtg=mysql_query($sqlg);
    $a=mysql_fetch_array($dtg);
    $b=$a['batas'];	
	$c=$a['username'];	
		
		$bataslog = 3;
        if($b >= $bataslog){
	mysql_query("UPDATE pincode SET locks = '1' where username='$username'");
	
	$email = $db->dataku("email", $username);
	$nama = $db->dataku("nama", $username);
	$reason = "3 times wrong entered PIN";
	 $tgl = formatgl($clientdate);
	$waktu = date("H:i:s");
	if($mail_blokirpin_member_status == 1){
	$mail = new PHPMailer(); // defaults to using php "mail()"
$data = $mail_blokirpin_member_isi;
	$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("/{reason}/", $reason, $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_blokirpin_member_subject;
	$datax = preg_replace("/{nama}/", $nama, $datax);	
	$subject_blokirpin_member = $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_blokirpin_member."";
	$mail->AltBody    = "Pesan HTML, Untuk melihat pesan, silakan menggunakan peninjau HTML email yang kompatibel!"; // Alt Body
	$mail->MsgHTML($body);

$mail->Send();
}
header("location: ?go=requestpin&result=blocked");
	exit;

} else {
	
	header("location: ?go=requestpin&result=wrong_oldpin");
	exit;
}
} else {

	 
	

}	 
?>


<?php

	}
?>

<?php
} else {
?>
<?php
$sql    = "SELECT * FROM pincode WHERE username='$user_session'";
$hasil  = mysql_query($sql);
$jumlah = mysql_num_rows($hasil);
// Apabila kode verifikasi ditemukan
$data=mysql_fetch_array($hasil);
$pincod = $data['pin'];
$status = $data['status'];
$lock = $data['locks'];

if($lock == 1 ){

echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your PIN is blocked! Contact your administrator!</div>";
}else if($status == 0) {
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your PIN is inactive! Activate your PIN before change your PIN</div>";
} else {
?>
</div>
<?php
$codesms = substr(str_shuffle(str_repeat("121234567890123434567890567890011223344556677889900558877443365982541", 64)), 0, 7);
?>




<div class="row">
                        
                        	<div class="col-md-9">
                            	<div class="content-box">
                                    <h3 class="content-box-header bg-primary">
                                        <i class="glyph-icon icon-file-zip-o"></i>
                                       Change PIN
                                    </h3>
                                        <div class="content-box-wrapper">
                                        
                                     <form id="tab" action="?go=requestpin&page=update" method="post">
                                       <input name="tujuan" type="hidden" id="tujuan" value="<?php echo $user_session; ?>" size="15" />
			  <input name="username" type="hidden" id="username" value="<?php echo $user_session; ?>">
			  <input name="status" type="hidden" id="status" value="<?php echo $status; ?>">
			  <input type="hidden" id="kodex" name="kodex" value="<?php echo $codesms; ?>"/>
                     <input name="hp" id="hp" type="hidden" value="<?php echo $db->dataku("hp", $user_session); ?>" size="40"/>
					 <input type="hidden" id="kodex" name="kodex" value="<?php echo $codesms; ?>"/>
                     <input name="tgl" type="hidden" id="tgl" value="<?php $tanggal=date("Y-m-d H:i:s"); echo "$tanggal"; ?>"> 
                     <input type="hidden" name="pincodex" id="pincodex" value="<?php echo $pincod; ?>"/>   
                                        
                                        
      
      <div class="controls-row">

            <div class="col-md-12"> <label>New PIN</label></div>

       		

         </div>

         

         <div class="controls-row">

            <div class="col-md-12"> <input type="password" class="form-control" name="pin" required='required' placeholder="Enter New PIN here"></div>

       		

         </div>
         
         
         

         
      

      <div class="controls-row">

            <div class="col-md-6"> <label>Old PIN</label></div>

       		<div class="col-md-6"><label>&nbsp;</label></div>

      </div>

      

      <div class="controls-row">

            <div class="col-md-6"> <input type="password" class="form-control" name="pincode" placeholder="Enter Old PIN here" required='required'></div>

       	
      </div>

       

        <div style="margin:10px;">

              <input type="submit" value="Update"class="btn btn-primary">

          </div>

        </form>
                                        </div>
                                	</div>
                            </div>
                            <div class="col-md-3">
                                
                                    
                            
                               
                                   
                                	</div>
                        		
                            
                            </div>
                            
                            </div>
                        
                        
                        </div>


















<?php
} 
}
}
?>
 
<?php ob_flush(); ?>