<?php
ob_start();
(@include ('../dt_page/lic.php')) or die("<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>");
//$lic=$license;if(!$lic){echo "<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>";}$svr=$_SERVER['SERVER_NAME'];$c=curl_init();curl_setopt($c,CURLOPT_URL,"http://www.primadesain.com/verifylicenses.php");curl_setopt($c,CURLOPT_TIMEOUT,30);curl_setopt($c,CURLOPT_POST,1);curl_setopt($c,CURLOPT_RETURNTRANSFER,1);$postfields='svr='.$svr.'&lic='.$lic;curl_setopt($c,CURLOPT_POSTFIELDS,$postfields);$result=curl_exec($c);if($result=="fail"){echo "<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>";die();}
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();} 
?>
 <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">
                    <img src="../themes/img/bonus.png" alt="Withdrawal Reward" class="header-icon" width="30">
                    Withdrawal Reward
                </h1>
            </div>
        </div>
<?php // Your license key 
$server = $_SERVER['SERVER_NAME'];

/*$c = curl_init(); 
// Set the full url path to point to your verifyLicense.php on your server 
curl_setopt($c, CURLOPT_URL, "http://www.primadesain.com/verifydomains.php"); 
curl_setopt($c, CURLOPT_TIMEOUT, 30); 
curl_setopt($c, CURLOPT_POST, 1); 
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 

$postfields = 'svr='.$server; 
curl_setopt($c, CURLOPT_POSTFIELDS, $postfields); 
$result = curl_exec($c); */

$result = 'valid';
if ($result=="fail") { 
echo "<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>You not have a license to use this script on this domain,<br>Please contact us to purchase a license.<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>";
die(); }
?>

<?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'] == "wdrw_go") {







$pincods = md5($_POST['pincode']);	
$sqlc = mysql_query("SELECT * FROM pincode WHERE username='$user_session'");
$numc = mysql_num_rows($sqlc);
while($rowc = mysql_fetch_array($sqlc)){
$tgl = formatgl($rowc['tgl']);
$pin = $rowc['pin'];
$sts = $rowc['status'];
$lock = $rowc['locks'];
	}
	if(!$numc) {
	header("location: index.php?go=withdrawalrw&result=no_pin");
	exit;
} else {
if(!$pincods || $pincods <> $pin) {
	header("location: index.php?go=withdrawalrw&result=wrong_pin");
	exit;
} else {
if($lock == 1) {
	header("location: index.php?go=withdrawalrw&result=pin_lock");
exit;
	} else {
if($sts == 0) {
	header("location: index.php?go=withdrawalrw&result=pin_off");
	exit;
} else {	





$reward = anti_injection($_POST['reward']);
$kodeproses = anti_injection($_POST['kodeproses']);


$rwww="SELECT peringkat2 FROM configuration"; 
$dtrwww=mysql_query($rwww);
$configrwww=mysql_fetch_array($dtrwww);
$batasrwd = explode("|", $configrwww['peringkat2']);
$rankrwd = explode("|", $configrwww['peringkat2']);
$rewardrwd = explode("|", $configrwww['peringkat2']);

$batasrwx1 = $batasrwd[0]; 
$batasrwx2 = $batasrwd[4]; 
$batasrwx3 = $batasrwd[8]; 
$batasrwx4 = $batasrwd[12]; 
$batasrwx5 = $batasrwd[16];
$batasrwx6 = $batasrwd[20];

$rankrwx1 = $rankrwd[1]; 
$rankrwx2 = $rankrwd[5]; 
$rankrwx3 = $rankrwd[9]; 
$rankrwx4 = $rankrwd[13]; 
$rankrwx5 = $rankrwd[17]; 
$rankrwx6 = $rankrwd[21]; 

$rewardx1 = $rewardrwd[2]; 
$rewardx2 = $rewardrwd[6]; 
$rewardx3 = $rewardrwd[10]; 
$rewardx4 = $rewardrwd[14]; 
$rewardx5 = $rewardrwd[18]; 
$rewardx6 = $rewardrwd[22]; 

if($reward == 1){
$rewardnyax = $rewardx1;
$pointnyax = $batasrwx1;
$jenisnyax = $rankrwx1;
}else if($reward == 2){
$rewardnyax = $rewardx2;
$pointnyax = $batasrwx2;
$jenisnyax = $rankrwx2;
}else if($reward == 3){
$rewardnyax = $rewardx3;
$pointnyax = $batasrwx3;
$jenisnyax = $rankrwx3;
}else if($reward == 4){
$rewardnyax = $rewardx4;
$pointnyax = $batasrwx4;
$jenisnyax = $rankrwx4;
}else if($reward == 5){
$rewardnyax = $rewardx5;
$pointnyax = $batasrwx5;
$jenisnyax = $rankrwx5;
}else if($reward == 6){
$rewardnyax = $rewardx6;
$pointnyax = $batasrwx6;
$jenisnyax = $rankrwx6;
}else if($reward == 7){
$rewardnyax = $rewardx7;
$pointnyax = $batasrwx7;
$jenisnyax = $rankrwx7;
}else{
$rewardnyax = "";
$pointnyax = "";
$jenisnyax = "";
}


if (!$reward){ 
header("location: index.php?go=withdrawalrw&result=noreward");
	exit;

}else{
 
   
$rewarde = $rewardnyax;
$point = $pointnyax;
$jenis = $jenisnyax;
$jenisrw = $reward;
$kodeproses = $kodeproses;                       


$smc = mysql_query("SELECT * FROM wd_reward WHERE kode='".mysql_real_escape_string($kodeproses)."'");
$cekode = mysql_num_rows($smc);
if($cekode > 0) {
header("location: index.php?go=withdrawalrw&result=already_process");
	exit;

}else{


$db->insert("wd_reward", "", "'', '$kodeproses', '$user_session', '$jenisrw', '$point', '$rewarde', '0', '$clientdate', '', '$info', '$jenis'"); 



$nama = $db->dataku("nama", $user_session);	
$alamat = $db->dataku("alamat", $user_session);	
$hp = $db->dataku("hp", $user_session);	
$email = $db->dataku("email", $user_session);	
$to = "To: ".$nama.", ".$alamat.", HP: ".$hp.", Email: ".$email.".";	
	
$tgl = formatgl($clientdate);

	
$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Halo ".$namaku." (".$username."),</p>
<p>Withdrawal Your Reward.</p>
<p><strong>No: ".$kodeproses."<br>
Reward: ".$rewarde."<br>
Receiver: ".$to."<br>
Date: ".$tgl."<br>
</p>
<p>Please wait your withdrawal will be processed immediately.</p>

<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
	//	$mail3->IsSMTP(); // telling the class to use SMTP
        $mail3->Host       = $smtphost; // SMTP server
        $mail3->SMTPAuth   = true;                  // enable SMTP authentication
        $mail3->Host       = $smtphost; // sets the SMTP server
        $mail3->Port       = $smtport;                    // set the SMTP port for the GMAIL server
        $mail3->Username   = $smtpuser; // SMTP account username
        $mail3->Password   = $smtpass;        // SMTP account password
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email, $nama);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama.', Withdrawal Reward';
        $mail3->msgHTML($isimail);
	  //  $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	

        header("location: index.php?go=withdrawalrw&result=success&co=".$kode."");
	exit;
}
}
}
	}
}
}
	


 }else{
?>




 <div class="row">
                <div class="col-md-4">
                
                
				 <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Withdrawal</h4>
                        </div>
                        <div class="panel-body">
              
          <?php  if($db->dataku("act", $user_session) == 0){ 
				 echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>to be able to use this facility you must have a deposit first.</div>";
				 $diss3b=" disabled='disabled'";
}else{
	$diss3b="";
}
				 
				  ?>    
              
              
               <?php
$results = $_GET['result'];
if($results == "already_process") { 
echo "<div style='margin-left:12px'><div class='errorx' style='width:390px;'><strong>This transaction already in process!</strong></div></div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "err") { 
echo "<div style='margin-left:12px'><div class='errorx' style='width:390px;'>Minimum request assistance is after running 12 days contribute complete..</div></div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "insufficient") { 
echo "<div class='alert-box errors'><span>Your balance is insufficient or any request request still pending!</span></div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "wrong_captcha") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Captcha salah!</div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "already_process") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Withdrawal reward ini sudah di kirim sebelumnya!</div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "noreward") { 
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You don't have a reward yet!</div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "wrong_pin_none") { 
echo "<div class='alert alert-danger'><span>".$LANG["pinnone"]."</span></div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "wrong_pin_lock") { 
echo "<div class='alert alert-danger'><span>".$LANG["pinblock"]."</span></div>";
}
?>
<?php
$results = $_GET['result'];
if($results == "wrong_pin_invalid") {
echo "<div class='alert alert-danger'><span>".$LANG["pinnonactive"]."</span></div>"; 
}
?>
<?php
$results = $_GET['result'];
if($results == "wrong_pin") { 
echo "<div class='alert alert-danger'><span>".$LANG["pinwrong"]."</span></div>";
}
?>
<?php      
$initiale = substr(str_shuffle(str_repeat("ABCEFGHIJKLMNPRSTUVWXYZ", 36)), 6, 2);
$stkode = strtotime(date("Y-m-d H:i:s"));
$kodecontribute = $initiale."".$stkode;
?>
<?php
$rwww="SELECT peringkat2 FROM configuration"; 
$dtrwww=mysql_query($rwww);
$configrwww=mysql_fetch_array($dtrwww);
$batasrwd = explode("|", $configrwww['peringkat2']);
$rankrwd = explode("|", $configrwww['peringkat2']);
$rewardrwd = explode("|", $configrwww['peringkat2']);

$batasrwx1 = $batasrwd[0]; 
$batasrwx2 = $batasrwd[4]; 
$batasrwx3 = $batasrwd[8]; 
$batasrwx4 = $batasrwd[12]; 
$batasrwx5 = $batasrwd[16];
$batasrwx6 = $batasrwd[20];

$rankrwx1 = $rankrwd[1]; 
$rankrwx2 = $rankrwd[5]; 
$rankrwx3 = $rankrwd[9]; 
$rankrwx4 = $rankrwd[13]; 
$rankrwx5 = $rankrwd[17]; 
$rankrwx6 = $rankrwd[21]; 

$rewardx1 = $rewardrwd[2]; 
$rewardx2 = $rewardrwd[6]; 
$rewardx3 = $rewardrwd[10]; 
$rewardx4 = $rewardrwd[14]; 
$rewardx5 = $rewardrwd[18]; 
$rewardx6 = $rewardrwd[22]; 


$sql_rwd1 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='1'");
$rowcrwd1 = mysql_fetch_array($sql_rwd1);
if($rowcrwd1[0] > 0){
$point1 = $rowcrwd1[0];
$status1="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point1 = "";
$status1="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd2 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='2'");
$rowcrwd2 = mysql_fetch_array($sql_rwd2);
if($rowcrwd2[0] > 0){
$point2 = $rowcrwd2[0];
$status2="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point2 = "";
$status2="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd3 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='3'");
$rowcrwd3 = mysql_fetch_array($sql_rwd3);
if($rowcrwd3[0] > 0){
$point3 = $rowcrwd3[0];
$status3="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point3 = "";
$status3="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd4 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='4'");
$rowcrwd4 = mysql_fetch_array($sql_rwd4);
if($rowcrwd4[0] > 0){
$point4 = $rowcrwd4[0];
$status4="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point4 = "";
$status4="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd5 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='5'");
$rowcrwd5 = mysql_fetch_array($sql_rwd5);
if($rowcrwd5[0] > 0){
$point5 = $rowcrwd5[0];
$status5="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point5 = "";
$status5="<img src='../images/publish_x.png' width='16' height='16' />";
}
$sql_rwd6 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='6'");
$rowcrwd6 = mysql_fetch_array($sql_rwd6);
if($rowcrwd6[0] > 0){
$point6 = $rowcrwd6[0];
$status6="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point6 = "";
$status6="<img src='../images/publish_x.png' width='16' height='16' />";
}
$sql_rwd7 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='7'");
$rowcrwd7 = mysql_fetch_array($sql_rwd7);
if($rowcrwd7[0] > 0){
$point7 = $rowcrwd7[0];
$status7="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point7 = "";
$status7="<img src='../images/publish_x.png' width='16' height='16' />";
}

$pointnya = $point1+$point2+$point3+$point4+$point5+$point6+$point7;

$memberix = omsetkiri($user_session);
$membernanx = omsetkanan($user_session);
$memberi = ($memberix - $pointnya);
$membernan = ($membernanx - $pointnya);



	
	if($memberi >= $batasrwx1 && $membernan >= $batasrwx1){
		$rewarde1 = $rewardx1; }
	if($memberi >= $batasrwx2 && $membernan >= $batasrwx2){
		$rewarde2 = $rewardx2; }
	if($memberi >= $batasrwx3 && $membernan >= $batasrwx3){
		$rewarde3 = $rewardx3; }
	if($memberi >= $batasrwx4 && $membernan >= $batasrwx4){
		$rewarde4 = $rewardx4; }
	if($memberi >= $batasrwx5 && $membernan >= $batasrwx5){
		$rewarde5 = $rewardx5; }
	if($memberi >= $batasrwx6 && $membernan >= $batasrwx6){
		$rewarde6 = $rewardx6; }
	if($memberi >= $batasrwx7 && $membernan >= $batasrwx7){
		$rewarde7 = $rewardx7; }
	
			
?>
<script type="text/javascript">
 
        function isNumberKey(evt, obj) {
 
            var charCode = (evt.which) ? evt.which : event.keyCode
            var value = obj.value;
            var dotcontains = value.indexOf(".") != -1;
            if (dotcontains)
                if (charCode == 46) return false;
            if (charCode == 46) return true;
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }
 

 
    </script>         
                <form id="tab2" name="wallet_depo" method="post" action="?go=withdrawalrw&page=wdrw_go">
															<input name="kodeproses" type="hidden" id="kodeproses" value="<?php echo $kodecontribute; ?>">
                 

  <div class="controls-row">

            <label>Achievement</label>

           
			<input type="text" disabled="disabled" class="form-control" style="background-color:#009F50; color:#FFF;" value="<?php if($memberi>0) { echo "Left ".rupiah($memberi);}else{ echo "Left 0"; }?> | <?php if($membernan>0) { echo "Right ".rupiah($membernan);}else{ echo "Right 0"; }?>" />
           

          </div>

          <div class="controls-row">

            <label>Reward</label>

          <select name="reward" id="reward"  class="form-control" required='required'>
       <option value='' selected="selected">[ Select Reward ]</option>
    <?php if($rewarde1){  ?> <option value='1'><?php echo $rankrwx1; ?> - <?php echo $rewarde1; ?></option><?php } ?>
    <?php if($rewarde2){  ?> <option value='2'><?php echo $rankrwx2; ?> - <?php echo $rewarde2; ?></option><?php } ?>
    <?php if($rewarde3){  ?> <option value='3'><?php echo $rankrwx3; ?> - <?php echo $rewarde3; ?></option><?php } ?>
    <?php if($rewarde4){  ?> <option value='4'><?php echo $rankrwx4; ?> - <?php echo $rewarde4; ?></option><?php } ?>
    <?php if($rewarde5){  ?> <option value='5'><?php echo $rankrwx5; ?> - <?php echo $rewarde5; ?></option><?php } ?>
    <?php if($rewarde6){  ?> <option value='6'><?php echo $rankrwx6; ?> - <?php echo $rewarde6; ?></option><?php } ?>
    <?php if($rewarde7){  ?> <option value='7'><?php echo $rankrwx7; ?> - <?php echo $rewarde7; ?></option><?php } ?>
		  </select> 

          </div>

          
          <div class="controls-row">

            <label>PIN</label>

           <input type="password" class="form-control" placeholder="Enter Your PIN" name="pincode" required='required'<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss4b; ?>>
                                                          

          </div>

            
          
          
          
 <div>

           &nbsp;

          </div>
          <div>
        
            <input type="submit" value="Submit"class="btn btn-primary" name="addbalance" <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss4b; ?>>

          </div>

        </form>
        
        
        
                   <?php } ?>
                </div></div>
                
                   <div class="row">
                   
                   	
                   </div>
                   
                </div><!--end .col-->
                
                <div class="col-md-8">
                    <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Withdrawal History</h4>
                        </div>
                        <div class="panel-body">
                                                          
                                    <table id="data-table" class="table table-bordered" cellspacing="0" width="100%">
                                        <thead>
                                            <tr>
                           
                            <th>Date</th>
                                    <th>Point</th>
                                    <th>Reward</th>
                                    <th>Process Date</th>
                                    <th>#</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
                                       <?
	$db->select("id, kode, username, pointreward, reward, jenisrw, tgl, tglproses, status, ket", "wd_reward", "username='$user_session'", "tgl asc");
	
		while($row=$db->fetch_row()) {
			
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[8] > 0) {
				$st = "<button class='btn btn-success btn-xs' type='button' >Done</button>";
			} else {
				$st = "<button class='btn btn-danger btn-xs' type='button' >Pending</button>";
			}	
			
			if(!$row[7] || $row[7] == "0000-00-00 00:00:00"){	
		$tglpross="--";
			}else{
		$tglpross=formatgl($row[7]);
			}
$poinyax=$row[3]/$kurspoin;
?>			             
                     <tr> 
                            <td><?php echo $style; ?><?php echo formatgl($row[6]); ?></font></td>
                            <td><?php echo $style; ?><?php echo $poinyax; ?> Poin (<?php echo rupiah($row[3]); ?>)</font></td>
                            <td><?php echo $style; ?><?php echo $row[4]; ?></font></td>
                            <td><?php echo $style; ?><?php echo $tglpross; ?></font></td>
                            <td><?php echo $style; ?><?php echo $st; ?></font></td>
                        </tr>
                                                                    
        
	<?
		}
	?>

                                                                                </tbody>
                                    </table>
                                    </div>
                                </div>
<input type=hidden id='clr' value='yellow'>
                            <div class="clearfix"></div>
                        </div>
                    </div><!-- End .panel -->                       
             








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