<?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/transaction.png" alt="Withdrawal Profit" class="header-icon" width="30">
                    Withdrawal Profit
                </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
 
	 $minwdne=$minwdro;
	 $maxwdne=$maxwdro;
?>

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



if($wdcash == 0){
        header("location: index.php?go=withdrawalpro&result=disable");
	exit;
      } else {




	  $authgoogles=$db->dataku("authgoogle", $user_session);
$code    = anti_injection($_POST['one_time_password']);	  
$result  = $authenticator->verifyCode($secret,$code,$tolerance);
if($googleauntentic == 1 && $authgoogles == 1 && !$result){
header("location: index.php?go=withdrawalpro&result=wrong_auth");
exit;
} else {	



$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=withdrawalpro&result=no_pin");
	exit;
} else {
if(!$pincods || $pincods <> $pin) {
	header("location: index.php?go=withdrawalpro&result=wrong_pin");
	exit;
} else {
if($lock == 1) {
	header("location: index.php?go=withdrawalpro&result=pin_lock");
exit;
	} else {
if($sts == 0) {
	header("location: index.php?go=withdrawalpro&result=pin_off");
	exit;
} else {	


		
$username = anti_injection($_POST['user']);	
$kode = anti_injection($_POST['kode']);	
$amount = anti_injection($_POST['amount']);	
$fee = anti_injection($_POST['fee']);
$tujuan = anti_injection($_POST['tujuan']);
$accid = anti_injection($_POST['accid']);	
if($tujuan == 1){
	$tujuane=$db->dataku("bank", $user_session);
}else{
	$tujuane="Wallet ID ".$user_session;
}
	
$jumlah=$amount;


$jml_fee=($fee/100)*$amount;


$minsellbalancex = $minwdne;
$maxsellbalancex = $maxwdne;


$ttlbonusee = total_profit_member($username);
$ttlwdbonusee = total_wdprofit_member($username);
$jmlsaldone = $ttlbonusee-$ttlwdbonusee;


if ($jumlah > $jmlsaldone) {
        header("location: index.php?go=withdrawalpro&result=insufficient&mx=$jmlsaldone");
	exit;
      } else {

$jml_byr=$amount-$jml_fee;

if ($jumlah > $maxsellbalancex) {
        header("location: index.php?go=withdrawalpro&result=max_sell&mx=$maxsellbalancex");
	exit;
	
      } else {


$db->select("status", "wd", "status='0' and userid='$username' and jenis='2'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=withdrawalpro&result=pending");
	exit;
	
} else {


if ($amount < $minsellbalancex) {
        header("location: index.php?go=withdrawalpro&result=min_sell&mx=$minsellbalancex");
	exit;
      } else {



            $tgl_skr = (date("Y-m-d"));
			$dtfromnya = "$tgl_skr 00:00:00";
			$dttonya = "$tgl_skr 23:59:59";

  $cekjmlah=mysql_query("select SUM(total) from wd where userid='$username' and jenis='2' and (tglminta between '$dtfromnya' and '$dttonya')");
	
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0];
		             }

$btsharinie=$maxsellbalancex-$tothariini;

if ($amount > $btsharinie) {
        header("location: index.php?go=withdrawalpro&result=max_sellb&d=$btsharinie");
	exit;
	
      } else {


$uraian1 = "Fee ".rupiah($jml_fee)."";
//$pym = $db->dataku("py", $user_session);
$cekadane = mysql_query("select kode from wd where kode='$kode' and userid='$username'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {
$db->insert("wd", "", "'', '$username', '$clientdate', '', '$amount', '$jml_fee', '$jml_byr', '0', '$tujuane', '$kode', '2', '".$_SERVER['REMOTE_ADDR']."', '$tujuan'"); 		
}
	
if($tujuan == 2){	
$cekadane2 = mysql_query("select kode from dataewalet where kode='$kode' and tujuan='$username'");
$ada_adane2 = mysql_num_rows($cekadane2); 
if(!$ada_adane2) {
$db->insert("dataewalet", "", "'', '$kode', 'administrator', '$jml_byr', 'Withdrawal Bonus', '$username', '$clientdate', '1', '$clientdate', 'administrator', '".$db->dataku("accid", $username)."'"); 
$db->update("wd", "status='1', tglbayar='$clientdate'", "kode='$kode'");		
}		
}
		
		
		$namaku = $db->dataku("nama", $username);
		$emailku = $db->dataku("email", $username);
		$jumlahdepone = rupiah($amount);
		$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>Hello ".$namaku." (".$username."),</p>
<p>Withdrawal Profit.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee Admin: ".rupiah($jml_fee)."<br>
Transfered: ".rupiah($jml_byr)."<br>
Destination: ".$tujuane."<br>
Date: ".$tgl."<br>
</p>
<p>To withdrawal to your account, please wait we will process soon.</p>

<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
		if($smaile == 1){	
//$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($emailku, $namaku);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$namaku.', Withdrawal Profit';
        $mail3->msgHTML($isimail);
	  //  $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	

        header("location: index.php?go=withdrawalpro&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 Profit</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
 if(isset($_GET['result'])&&$_GET['result']=="max_sell"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max withdrawal Profit ".rupiah($_GET["mx"])." per days.</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_sellb"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max withdrawal Profit today ".rupiah($_GET["d"]).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_sell2"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max withdrawal Profit is ".rupiah($maxsellbalance).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="min_sell"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Min withdrawal Profit ".rupiah($_GET["mx"]).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pending"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have pending withdrawals, to be able to withdrawal again, please wait for the withdrawal done in the process.</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="insufficient"){
$mx = $_GET['mx'];
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your Profit Balance is not enough, max withdraw ".rupiah($mx).".</div>";
}
?>

<?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>Withdrawal profit has been successfully submitted, (Kode ".$_GET['co'].").</div>";
}
?>

<?php
 if(isset($_GET['result'])&&$_GET['result']=="no_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_NO_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_WRONG_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_lock"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_BLOCK_PIN."</div>";
}
?>  

 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_off"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_OFF_PIN."</div>";
}

if(isset($_GET['result'])&&$_GET['result']=="disable"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Withdrawal Profit is curently disable by administrator.</div>";
}
?>
   <?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo "<div class='alert alert-danger'>Wrong Captcha!</div>";
}
?>	           
   <?php
$results = $_GET['result'];
if($results == "wrong_auth") { 
echo "<div class='alert alert-danger'>You're enable two factor authentication at your account, Please enter your google authenticator six-digit code!</div>";
}
?>    
 <?php
$results = $_GET['result'];
if($results == "wrong_authx") { 
echo "<div class='alert alert-danger'>Wrong google authenticator six-digit code!</div>";
}
?>                   
              
              
               <?php if($wdro == 0){ 
				  echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>withdrawal Profit disable by administrator.</div>"; 
				  $diss3=" disabled='disabled'";
				  }else{
				  $diss3="";
				  ?>
               
               
                
                  
                  
                                	
      <?php    
$initialex = substr(str_shuffle(str_repeat("ABEF123456789GHIJKLMNPR123456789KLEFGHILMNP123456789RRSTUVWXYZ", 46)), 22, 12);
?>           

   <?php
$sql_sp3 = mysql_query("select * from wd where userid='".$user_session."' and status='0' and jenis='2'");
                        $ada_sp3 = mysql_num_rows($sql_sp3);
                        if($ada_sp3){	
		
		echo "<div class='alert alert-danger'>You still have pending withdrawals, to be able to withdrawal again, please wait for the withdrawal done in the process.</div>";
$diss4=" disabled='disabled'";
		
} else {
				
$diss4="";
}
	
$ttlbonusee = total_profit_member($user_session);
$ttlwdbonusee = total_wdprofit_member($user_session);
$saldobonusee = $ttlbonusee-$ttlwdbonusee;
 if($saldobonusee > 0){		
 	
$diss4b="";	
 }else{
	
$diss4b=" disabled='disabled'";
}
?>








<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=withdrawalpro&page=wdro_go">
<input type="hidden" id="kode" name="kode" value="<?php echo $initialex; ?>"/>
<input type="hidden" id="user" name="user" value="<?php echo $user_session; ?>"/>
<input type="hidden" id="fee" name="fee" value="<?php echo $feewdro; ?>"/>
                 

 

          <div class="controls-row">

            <label>Profits Balance</label>

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

          </div>

          

          <div class="controls-row" style="margin-top:10px;">

            <label>Amount Withdrawal</label>
            
          
          <input name="amount" type="number" class="form-control" id="amount" onkeypress="return isNumberKey(event,this)" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss4b; ?> min="<?php echo $minwdne; ?>" max="<?php echo $maxwdne; ?>">

          </div>

          <div class="controls-row" style="margin-top:10px;">

            <label>Fee Admin</label>
            
          
           <input name="" class="form-control" value="<?php echo $feewdro;?>%" disabled="disabled">

          </div>  

         
         <div class="controls-row" style="margin-top:10px;">



            <label>Withdrawal To</label>
            
            
              <select name="tujuan" id="tujuan" class="form-control"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss4b; ?> required='required'>
   <?php if($db->dataku("bank", $user_session)) { ?>
   
   <?php } else{ ?>
   <option value='0' style="background-color:#009F50; color:#FFF;" disabled="disabled">Update payment gateway in your profile!</option>
   <?php } ?>
   <option value='2'>Wallet</option>
		  </select> 
            
            
          </div>  
          
          
          
          <div class="controls-row" style="margin-top:10px;">

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

         <?php if($db->dataku("authgoogle", $user_session) == 1){ ?>
            <div class="controls-row" style="margin-top:10px;">

            <label>2FA Code</label>

           <input type="text" class="form-control" placeholder="Enter Google 2FA Code" name="one_time_password">
                                                          

          </div>
<?php } ?>
          
          
          
 <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 width="15%"><?php echo $LANG["date"]?></th>
                            <th width="10%">No Trx</th>
							<th width="15%"><?php echo $LANG["amount"]?></th>
							<th width="15%">Fee</th>
							<th width="15%">Received</th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
                                               
                                        <?

	$db->select("kode, userid, tglminta, tglbayar, total, charge, rp, status, tujuan, kode, jenis, ip", "wd", "userid='$user_session' and jenis='2'", "tglminta desc");
	
		while($row=$db->fetch_row()) {
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[7] > 0) {
				$st = "<button class='btn btn-success btn-xs' type='button' onMouseover='ddrivetip(\"Done tanggal ".formatgl($row[3])."\")'; onMouseout='hideddrivetip()'>Done</button>";	
				$style = "<font>";
			} else {
				$st = "<button class='btn btn-success btn-xs' type='button' onMouseover='ddrivetip(\"Menunggu Proses\")'; onMouseout='hideddrivetip()'>Pending</button>";
	   $style = "<font color='#F00000'>";
			}	
				$tt = formatgl($row[2]);
				
			$cdo = $row[0];		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$cdo'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$invc = $rowc['file'];				
				
?>
     	<tr>
							<td align="center"><?php echo $style; ?><?= $tt; ?></font></td>
							<td align="center"><?php echo $style; ?><?= $row[9]; ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[4]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[5]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[6]); ?></font></td>
                            
            
							<td align="center"><?php echo $style; ?><?= $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(); ?>