<?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.           #
// // ###############################################################################
?>
<!-- BEGIN PAGE HEADER-->
			<h3 class="page-title">
			Activate PIN <small>activate PIN</small>
			</h3>
			<div class="page-bar">
				<ul class="page-breadcrumb">
					<li>
						<i class="fa fa-home"></i>
						<a href="index.php">Home</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#">Profile</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#">Activate PIN</a>
					</li>
				</ul>
				<div class="page-toolbar">
					
				</div>
			</div>
			<!-- END PAGE HEADER-->

<?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{
?>

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

$pinbaru = $_POST['pinbaru'];
$lock = $_POST['lock'];
$username = $_POST['username'];
$status = $_POST['status'];
$tgl = $_POST['tgl'];

$pinbarune = md5($pinbaru);	
if($lock == 1) {
header("location: ?go=activatepin&result=blocked");
	exit;
} else {

$sqls = mysql_query("SELECT * FROM pincode WHERE username='$username'");
$nums = mysql_num_rows($sqls);
while($rows = mysql_fetch_array($sqls)){
  $tgle = formatgl($rows['tgl']);
  $st = $rows['status'];
  }
if($st == 1) {
header("location: ?go=activatepin&result=still_active");
	exit;

} else {
$db->update("pincode", "pin='$pinbarune', status=1", "username='$username'");

$nama = $db->dataku("nama", $username);
		$email = $db->dataku("email", $username);
$tgl = formatgl($clientdate);
$waktu = date("H:i:s");

$mail = new PHPMailer(); // defaults to using php "mail()"
$data = $mail_ubah_pin_isi;
	$data = preg_replace("/{nama}/", $nama, $data);			
    $data = preg_replace("/{pinbaru}/", $pinbaru, $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=activatepin&result=activated");
	exit;
} 
}
?>
<?php
} else if (isset($_GET['page']) && $_GET['page'] == "update2") {
	

$ipne = $_SERVER['REMOTE_ADDR'];

$pinku = $_POST['pinku'];
$username = $_POST['username'];
$tgl = $_POST['tgl'];
$pine = md5($pinku);
$tanggal=date("Y-m-d H:i:s");

$sqlw = mysql_query("SELECT * FROM pincode WHERE username='$username'");
$numw = mysql_num_rows($sqlw);
if(!empty($numw)) {
header("location: ?go=activatepin&result=wrong_pin");
	exit;
} else {
$db->insert("pincode", "", "'', '$username', '$pine', '1', '$tanggal', '0', ''");
header("location: ?go=activatepin&result=activated");
	exit;
} 
?>
<?php
} else {
?>
<?php
$results = $_GET['result'];
if($results == "activated") { 
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["actvpin"]."</div>";
} else if($results == "still_active") { 
echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["stillactvpin"]."</div>";
} else if($results == "blocked") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["pinblock"]."</div>";
} else if($results == "wrong_pin") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["haveactvpin"]."</div>";
} else if($results == "wrong_captcha") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["wrongcaptcha"]."</div>";
} 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);
$pin = $data['pin'];
$status = $data['status'];
$lock = $data['locks'];
if (!empty($jumlah)){
if($status > 0 && $lock == 0){
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["actvpin"]."</div>";
}else if($status > 0 && $lock == 1 ) {
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["pinblock"]."</div>";
} else {
?>









<div class="portlet box blue-hoki">
									<div class="portlet-title">
										<div class="caption">
											<i class="fa fa-lock"></i>&nbsp;PIN Activation
										</div>
										
									</div>
									<div class="portlet-body form">
										<!-- BEGIN FORM-->
										<form action="?go=activatepin&page=update" class="form-horizontal" method="post">
                                         <input name="username" type="hidden" id="username" value="<?php echo $user_session; ?>">
                                         <?php
							 $acake = substr(str_shuffle(str_repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz", 6)), 0, 7);
							
  ?>
			  <input name="status" type="hidden" id="status" value="<?php echo $status; ?>">
			  <input name="lock" type="hidden" id="lock" value="<?php echo $lock; ?>">
                    <input name="tgl" type="hidden" id="tgl" value="<?php $tanggal=date("Y-m-d H:i:s"); echo "$tanggal"; ?>"> 
											<div class="form-body">
												
                                                
                                                <div class="form-group">
													<label class="col-md-3 control-label">New PIN</label>
													<div class="col-md-4">
														<div class="input-group">
															<span class="input-group-addon">
															<i class="fa fa-lock"></i>
															</span>
															<input type="password" class="form-control" name="pinbaru" required='required' placeholder="Enter New PIN here">
														</div>
													</div>
												</div>
                                              <div class="form-actions">
												<div class="row">
													<div class="col-md-offset-3 col-md-9">
														<button type="submit" class="btn blue-hoki" ><i class="fa fa-check"></i>&nbsp;Activation</button>
													</div>
												</div>
											</div>
												
											</div>
                     
										</form>
										<!-- END FORM-->
									</div>
								</div>
 <?php } 
		}
		else { ?>

<div class="portlet box blue-hoki">
									<div class="portlet-title">
										<div class="caption">
											<i class="fa fa-gift"></i>PIN Activation
										</div>
										
									</div>
									<div class="portlet-body form">
										<!-- BEGIN FORM-->
										<form action="?go=activatepin&page=update2" class="form-horizontal" method="post">
                                         <input name="username" type="hidden" id="username" value="<?php echo $user_session; ?>">
                                         <?php
							 $acake = substr(str_shuffle(str_repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz", 6)), 0, 7);
							
  ?>
			
                    <input name="tgl" type="hidden" id="tgl" value="<?php $tanggal=date("Y-m-d H:i:s"); echo "$tanggal"; ?>"> 
											<div class="form-body">
												
                                                
                                                <div class="form-group">
													<label class="col-md-3 control-label">New PIN</label>
													<div class="col-md-4">
														<div class="input-group">
															<span class="input-group-addon">
															<i class="fa fa-lock"></i>
															</span>
															<input type="password" class="form-control" name="pinku" required='required'>
														</div>
													</div>
												</div>
                                              <div class="form-actions">
												<div class="row">
													<div class="col-md-offset-3 col-md-9">
														<button type="submit" class="btn blue-hoki" >Activation</button>
													</div>
												</div>
											</div>
												
											</div>
                     
										</form>
										<!-- END FORM-->
									</div>
								</div>





<?php 
} 
}
}
}
?>

<?php ob_flush(); ?>