<?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/btcpin.png" alt="Deposit" class="header-icon" width="30">
                    BTC PIN
                </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); 

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

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

?>






 <div class="row">
                <div class="col-md-4">
                
                
				 <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Transfer BTC PIN</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($transfercoin == 0){ 
				 echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Transfer BTC PIN balance is temporary disabled 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 dataewalet2cx where username='".$user_session."' and status='0'");
                        $ada_sp3 = mysql_num_rows($sql_sp3);
                        if($ada_sp3){	
		echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have a pending transaction. Wait until the transaction is processed in order to be able to add BTC PIN balance again.</div>";
$diss4=" disabled='disabled'";
		
} else {
				
$diss4="";
}
						
?>	 




  <?php
 if(isset($_GET['result'])&&$_GET['result']=="success_add"){
if(isset($_GET["co"])){ $co = anti_injection(base64_decode($_GET["co"])); }
if(isset($_GET["ca"])){ $ca = anti_injection(base64_decode($_GET["ca"])); }
if(isset($_GET["cd"])){ $cd = anti_injection(base64_decode($_GET["cd"])); }
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Transfer BTC PIN balance no ".$co." to user ".$cd." has been sent.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="nocrossline"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You can only transfer BTC PIN balance to upline or downline, not to crossline.</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>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="min_trans"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Min transfer BTC PIN balance is ".rupiah($minimaltransfercoin).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_trans"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max transfer BTC PIN balance is ".rupiah($maksimaltransfercoin).".</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 a BTC PIN balance transfer transaction previously pending status. Wait until the transaction is processed in order to be able to transfer BTC PIN balances back.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="nouser"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>transfer recipient can not be empty.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="usernotfound"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>transfer recipient is not found.</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="errors"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You can not transfer BTC PIN balance to your self.</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 BTC PIN balance is insufficient, max transfer is ".rupiah($mx).".</div>";
}
?>


 		<?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo "<div class='alert alert-danger'>Wrong Captcha!</div>";
}
?>	          
<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>       
 <script>
		function confirmtransfer(){
      var session_value=document.getElementById('tujuan').value;
      var session_valuex=document.getElementById('amount').value;
      var confirmed = confirm("Are you sure you want to transfer coin balance:" + "\n" + "Amount: £"+session_valuex+"\n" + "Transfer To: "+session_value);
      return confirmed;
}
</script>              

<form method="post" id="tab2" name="transfer" action="?go=btcpin&page=trans_balance_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 $feetransfercoin; ?>"/>
<input type="hidden" id="accid" name="accid" value="<?php echo $db->dataku("accid", $user_session); ?>"/>


          <div class="controls-row">

            <label>BTC PIN Balance</label>

            <select name="jenis" id="jenis" required='required' class="form-control">
             
                <?php 
			 
			 $saldobwallete = $db->mycwalet($user_session);
			 $pendingbwallete = $db->mycwaletpending($user_session);
			 $totalbwalete = $saldobwallete-$pendingbwallete;
			
		
			 ?>
             <?php 
			
			if($totalbwalete > 0){
				echo "<option value='1'>BTC PIN [Balance ".rupiah($totalbwalete)."]</option>";
			}else{
				echo "<option value='1' disabled='disabled'>BTC PIN [No Balance]</option>";
		}
			// if($totalcwalete > 0){
			//	echo "<option value='2'>R-POINT [Balance ".rupiah($totalcwalete)."]</option>";
			//}else{
			//	echo "<option value='2' disabled='disabled'>R-POINT [No Balance]</option>";
			//}
			
			//if($totalawalete > 0){
			//	echo "<option value='3'>Z-POINT [Balance ".rupiah($totalawalete)."]</option>";
			//}else{
			//	echo "<option value='3' disabled='disabled'>Z-POINT [No Balance]</option>";
			//}
			?>
             
		       </select>  

          </div>
<div class="controls-row">

            <label>Recipient</label>

           <input name="tujuan" class="form-control" id="tujuan"  placeholder="Wallet ID Recipient" required='required' <?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

          </div>
         

          <div class="controls-row">

            <label>Amount BTC PIN</label>

           <input name="jumlah" class="form-control" id="jumlah" onkeypress="return isNumberKey(event,this)" placeholder="Amount" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

          </div>

          <div class="controls-row">

            <label>Fee Transfer</label>
<input type="text" class="form-control" readonly="readonly" style='color:#333;' value="<?php echo $feetransfercoin;?>%">

          </div>
           <div class="controls-row">

            <label>PIN</label>

           <input name="pincode" class="form-control" id="pincode" type="password" placeholder="PIN" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>

          </div>

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

            <label></label>

           <?php
      // show captcha HTML using Securimage::getCaptchaHtml()
      require_once 'securimage/securimage.php';
      $options = array();
      $options['input_name'] = 'php_captcha'; // change name of input element for form post
      //$options['audio_button_bgcol'] = '#E0E0E0'; // change name of input element for form post
      echo Securimage::getCaptchaHtml($options);
    ?>
    <input class="form-control" placeholder="Enter Captcha" required name="php_captcha" type="text" value="" style=" margin-top:10px;"<?php echo $diss3; ?><?php echo $diss4; ?><?php echo $diss3b; ?>>
                                               

          </div>
 <div>

           &nbsp;

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

          </div>

        </form>
        
        
        
                </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">Transfer BTC PIN 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="15%">To</th>
							<th width="20%"><?php echo $LANG["amount"]?></th>
							<th width="25%"><?php echo $LANG["news"]?></th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
<?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, jenis, fee, jumlahnet, accid2", "dataewalet2cx", "username='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[4] == $user_session) {
				$ket = "$row[1]";
			} else {
				$ket = 	"$row[1]";
			}
			if($row[2] == $user_session) {
				$type = "Debet";
			} else {
				$type = "Credit";
			}		
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='label label-success'>Done</span>";
				$style = "<font>";
			} else {
				$st = "<span class='label label-danger'>Pending</span>";
			
	   $style = "<font color='#F00000'>";
			}	
				$tt = formatgl($row[5]);
				
			$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[10]; ?></font></td>
							<td align="center"><?php echo $style; ?><?= rupiah($row[3]); ?></font></td>
							<td align="center"><?php echo $style; ?><?= $ket; ?></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
 } else if (isset($_GET['page']) && $_GET['page'] == "trans_balance_go") {



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



$username = anti_injection($_POST['user']);	
$kode = anti_injection($_POST['kode']);	
$amount = anti_injection($_POST['jumlah']);	
$uraiannya = anti_injection($_POST['uraian']);	
$jenis = anti_injection($_POST['jenis']);
$accid = anti_injection($_POST['accid']);
$accid2 = anti_injection($_POST['tujuan']);

$tujuan=$db->dataku("username", $accid2);


$queryupline = "SELECT username FROM upline WHERE 
username='$username' and upline0='$tujuan' or 
username='$username' and upline1='$tujuan' or username='$username' and upline2='$tujuan' or 
username='$username' and upline3='$tujuan' or username='$username' and upline4='$tujuan' or 
username='$username' and upline5='$tujuan' or username='$username' and upline6='$tujuan' or 
username='$username' and upline7='$tujuan' or username='$username' and upline8='$tujuan' or 
username='$username' and upline9='$tujuan' or username='$username' and upline10='$tujuan' or 
username='$username' and upline11='$tujuan' or username='$username' and upline12='$tujuan' or 
username='$username' and upline13='$tujuan' or username='$username' and upline14='$tujuan' or 
username='$username' and upline15='$tujuan' or username='$username' and upline16='$tujuan' or 
username='$username' and upline17='$tujuan' or username='$username' and upline18='$tujuan' or 
username='$username' and upline19='$tujuan' or username='$username' and upline20='$tujuan' or 
username='$username' and upline21='$tujuan' or username='$username' and upline22='$tujuan' or 
username='$username' and upline23='$tujuan' or username='$username' and upline24='$tujuan' or 
username='$username' and upline25='$tujuan' or username='$username' and upline26='$tujuan' or 
username='$username' and upline27='$tujuan' or username='$username' and upline28='$tujuan' or 
username='$username' and upline29='$tujuan' or username='$username' and upline30='$tujuan' or 
username='$username' and upline31='$tujuan' or username='$username' and upline32='$tujuan' or 
username='$username' and upline33='$tujuan' or username='$username' and upline34='$tujuan' or 
username='$username' and upline35='$tujuan' or username='$username' and upline36='$tujuan' or 
username='$username' and upline37='$tujuan' or username='$username' and upline38='$tujuan' or 
username='$username' and upline39='$tujuan' or username='$username' and upline40='$tujuan' or 
username='$username' and upline41='$tujuan' or username='$username' and upline42='$tujuan' or 
username='$username' and upline43='$tujuan' or username='$username' and upline44='$tujuan' or 
username='$username' and upline45='$tujuan' or username='$username' and upline46='$tujuan' or 
username='$username' and upline47='$tujuan' or username='$username' and upline48='$tujuan' or 
username='$username' and upline49='$tujuan' or username='$username' and upline50='$tujuan' or 
username='$username' and upline51='$tujuan' or username='$username' and upline52='$tujuan' or 
username='$username' and upline53='$tujuan' or username='$username' and upline54='$tujuan' or 
username='$username' and upline55='$tujuan' or username='$username' and upline56='$tujuan' or 
username='$username' and upline57='$tujuan' or username='$username' and upline58='$tujuan' or 
username='$username' and upline59='$tujuan' or username='$username' and upline60='$tujuan' or 
username='$username' and upline61='$tujuan' or username='$username' and upline62='$tujuan' or 
username='$username' and upline63='$tujuan' or username='$username' and upline64='$tujuan' or 
username='$username' and upline65='$tujuan' or username='$username' and upline66='$tujuan' or 
username='$username' and upline67='$tujuan' or username='$username' and upline68='$tujuan' or 
username='$username' and upline69='$tujuan' or username='$username' and upline70='$tujuan' or 
username='$username' and upline71='$tujuan' or username='$username' and upline72='$tujuan' or 
username='$username' and upline73='$tujuan' or username='$username' and upline74='$tujuan' or 
username='$username' and upline75='$tujuan' or username='$username' and upline76='$tujuan' or 
username='$username' and upline77='$tujuan' or username='$username' and upline78='$tujuan' or 
username='$username' and upline79='$tujuan' or username='$username' and upline80='$tujuan' or 
username='$username' and upline81='$tujuan' or username='$username' and upline82='$tujuan' or 
username='$username' and upline83='$tujuan' or username='$username' and upline84='$tujuan' or 
username='$username' and upline85='$tujuan' or username='$username' and upline86='$tujuan' or 
username='$username' and upline87='$tujuan' or username='$username' and upline88='$tujuan' or 
username='$username' and upline89='$tujuan' or username='$username' and upline90='$tujuan' or 
username='$username' and upline91='$tujuan' or username='$username' and upline92='$tujuan' or 
username='$username' and upline93='$tujuan' or username='$username' and upline94='$tujuan' or 
username='$username' and upline95='$tujuan' or username='$username' and upline96='$tujuan' or 
username='$username' and upline97='$tujuan' or username='$username' and upline98='$tujuan' or 
username='$username' and upline99='$tujuan' or username='$username' and upline100='$tujuan'"; 
$resultupline = mysql_query($queryupline);
$ada_upline = mysql_num_rows($resultupline); 


$querydownline = "SELECT username FROM upline WHERE 
username='$tujuan' and upline0='$username' or 
username='$tujuan' and upline1='$username' or username='$tujuan' and upline2='$username' or 
username='$tujuan' and upline3='$username' or username='$tujuan' and upline4='$username' or 
username='$tujuan' and upline5='$username' or username='$tujuan' and upline6='$username' or 
username='$tujuan' and upline7='$username' or username='$tujuan' and upline8='$username' or 
username='$tujuan' and upline9='$username' or username='$tujuan' and upline10='$username' or 
username='$tujuan' and upline11='$username' or username='$tujuan' and upline12='$username' or 
username='$tujuan' and upline13='$username' or username='$tujuan' and upline14='$username' or 
username='$tujuan' and upline15='$username' or username='$tujuan' and upline16='$username' or 
username='$tujuan' and upline17='$username' or username='$tujuan' and upline18='$username' or 
username='$tujuan' and upline19='$username' or username='$tujuan' and upline20='$username' or 
username='$tujuan' and upline21='$username' or username='$tujuan' and upline22='$username' or 
username='$tujuan' and upline23='$username' or username='$tujuan' and upline24='$username' or 
username='$tujuan' and upline25='$username' or username='$tujuan' and upline26='$username' or 
username='$tujuan' and upline27='$username' or username='$tujuan' and upline28='$username' or 
username='$tujuan' and upline29='$username' or username='$tujuan' and upline30='$username' or 
username='$tujuan' and upline31='$username' or username='$tujuan' and upline32='$username' or 
username='$tujuan' and upline33='$username' or username='$tujuan' and upline34='$username' or 
username='$tujuan' and upline35='$username' or username='$tujuan' and upline36='$username' or 
username='$tujuan' and upline37='$username' or username='$tujuan' and upline38='$username' or 
username='$tujuan' and upline39='$username' or username='$tujuan' and upline40='$username' or 
username='$tujuan' and upline41='$username' or username='$tujuan' and upline42='$username' or 
username='$tujuan' and upline43='$username' or username='$tujuan' and upline44='$username' or 
username='$tujuan' and upline45='$username' or username='$tujuan' and upline46='$username' or 
username='$tujuan' and upline47='$username' or username='$tujuan' and upline48='$username' or 
username='$tujuan' and upline49='$username' or username='$tujuan' and upline50='$username' or 
username='$tujuan' and upline51='$username' or username='$tujuan' and upline52='$username' or 
username='$tujuan' and upline53='$username' or username='$tujuan' and upline54='$username' or 
username='$tujuan' and upline55='$username' or username='$tujuan' and upline56='$username' or 
username='$tujuan' and upline57='$username' or username='$tujuan' and upline58='$username' or 
username='$tujuan' and upline59='$username' or username='$tujuan' and upline60='$username' or 
username='$tujuan' and upline61='$username' or username='$tujuan' and upline62='$username' or 
username='$tujuan' and upline63='$username' or username='$tujuan' and upline64='$username' or 
username='$tujuan' and upline65='$username' or username='$tujuan' and upline66='$username' or 
username='$tujuan' and upline67='$username' or username='$tujuan' and upline68='$username' or 
username='$tujuan' and upline69='$username' or username='$tujuan' and upline70='$username' or 
username='$tujuan' and upline71='$username' or username='$tujuan' and upline72='$username' or 
username='$tujuan' and upline73='$username' or username='$tujuan' and upline74='$username' or 
username='$tujuan' and upline75='$username' or username='$tujuan' and upline76='$username' or 
username='$tujuan' and upline77='$username' or username='$tujuan' and upline78='$username' or 
username='$tujuan' and upline79='$username' or username='$tujuan' and upline80='$username' or 
username='$tujuan' and upline81='$username' or username='$tujuan' and upline82='$username' or 
username='$tujuan' and upline83='$username' or username='$tujuan' and upline84='$username' or 
username='$tujuan' and upline85='$username' or username='$tujuan' and upline86='$username' or 
username='$tujuan' and upline87='$username' or username='$tujuan' and upline88='$username' or 
username='$tujuan' and upline89='$username' or username='$tujuan' and upline90='$username' or 
username='$tujuan' and upline91='$username' or username='$tujuan' and upline92='$username' or 
username='$tujuan' and upline93='$username' or username='$tujuan' and upline94='$username' or 
username='$tujuan' and upline95='$username' or username='$tujuan' and upline96='$username' or 
username='$tujuan' and upline97='$username' or username='$tujuan' and upline98='$username' or 
username='$tujuan' and upline99='$username' or username='$tujuan' and upline100='$username'"; 
$resultdownline = mysql_query($querydownline);
$ada_downline = mysql_num_rows($resultdownline); 
	
	
if(!$ada_upline && !$ada_downline){	
	    header("location: index.php?go=btcpin&page=transfer&result=nocrossline");
	exit;
	
      } else {		
	


$saldocwallete = $db->mycwalet($user_session);
$pendingcwallete = $db->mycwaletpending($user_session);
$jmlsaldone_c = $saldocwallete-$pendingcwallete;



if($jenis == 1){
$uraian = "BTC PIN Balance -".$uraiannya;
$dbusernya = "datacwalet";
$dbtujuannya = "datacwalet";
$jmlsaldone = $jmlsaldone_c;
}else{ }
	

$fee = $_POST['fee'];
$jumlah=$amount;	

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

$jml_byr=$amount-$jml_fee;
$jmlfeex = rupiah($jml_fee);
$jmlrecx = rupiah($jml_byr);


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




$db->select("status", "dataewalet2cx", "status='0' and username='$username'");

				$ada = $db->num_rows();

if ($ada >0) {
  header("location: index.php?go=btcpin&page=transfer&result=pending");
	exit;
	
} else {


if (!$accid2) {
        header("location: index.php?go=btcpin&page=transfer&result=nouser");
	exit;
	
      } else {
		  
if ($accid2 == $accid) {
        header("location: index.php?go=btcpin&page=transfer&result=nosame");
	exit;
	
      } else {		  
		  
$cektujuan = mysql_query("select * from member where accid='$accid2'");
$ada_tujuan = mysql_num_rows($cektujuan); //---flush out hari ini
if (!$ada_tujuan) {
header("location: index.php?go=btcpin&page=transfer&result=usernotfound");
	exit;
}else{	
		  



if (!$amount || $amount < $minimaltransfercoin) {
        header("location: index.php?go=btcpin&page=transfer&result=min_trans");
	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(jumlah) from dataewalet2c where username='$username' and (tgl between '$dtfromnya' and '$dttonya')");
	
	                 while($rowcekjumlah=mysql_fetch_row($cekjmlah)) {
		             $tothariini = $rowcekjumlah[0]+$amount;
		             }
if ($tothariini > $maksimaltransfercoin) {
        header("location: index.php?go=btcpin&page=transfer&result=max_trans");
	exit;
      } else {	  


 
	
	
	
$db->insert("dataewalet2cx", "", "'', '$kode', '$username', '$jumlah', '$uraian', '$tujuan', '$clientdate', '1', '$jenis', '$jml_fee', '$jml_byr', '$accid', '$accid2'");	
	
$uraian1 = "Transfer ".$uraian." To ".$accid2."";
$uraian2 = "Transfer ".$uraian." from ".$accid."";
$uraian1x = "Fee ".$fee."% (".rupiah($jml_fee).")";
$uraian1c = "Fee transfer ".$fee."% to ".$accid2."";


$cekadane = mysql_query("select kode from $dbusernya where kode='$kode'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {

$db->insert("".$dbusernya."", "", "'', '$kode', '$username', '$jml_byr', '".mysql_real_escape_string($uraian1)."', '$tujuan', '$clientdate', 1, '$clientdate', '$accid', '$accid2'");	



if($jml_fee > 0){
$db->insert("".$dbusernya."", "", "'', '$kode', '$username', '$jml_fee', '".mysql_real_escape_string($uraian1c)."', 'administrator', '$clientdate', 1, '$clientdate', '$accid', 'administrator'"); 
}	
}	
	
	
	$spon_nama = $db->dataku("nama", $user_session);

		$spon_mail = $db->dataku("email", $user_session);
		$nama = $db->dataku("nama", $user_session);
		$jumlahdepone = rupiah($amount);
		$namadmin = $db->config("name");
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");


$sess = substr(str_shuffle(str_repeat("4453141119066764203711128717497783625536342396411241472162223777", 64)), 0, 22);
			$invc="TRANSFER".$user_session."_".$sess."_".$kode;
			$inv="http://".$domain."/invoice/".$invc.".pdf";
			$db->insert("invoice","","'', '$user_session', '$kode', '$invc', '$clientdate'");
			$nama_ku = $db->dataku("nama",$user_session);
			$email_ku = $db->dataku("email",$user_session);
			$hp_ku = $db->dataku("hp",$user_session);
			$nama_nya = $db->dataku("nama",$tujuan);
			$hptujuan = $db->dataku("hp",$tujuan);
			$emailtujuan = $db->dataku("email",$tujuan);
	


//$isipesan = "".$nama_ku.", pembelian balance ".$jenis." sebesar ".$jumlahdepone." telah berhasil, selanjutnya silahkan lakukan pembayaran.";
//mysql_query("insert into outbox values('', '$kode', '".$user_session."', '$hp_ku', '$isipesan', '$clientdate', '1')") or die(mysql_error());
//sendsms($hp_ku, $isipesan) ;
	
//$isipesan2 = "Ada member beli balance ".$jenis." sebesar ".$jumlahdepone.", Kode: ".$kode.", User: ".$user_session.", Nama: ".$nama_ku."";
//sendsms($hpadmin, $isipesan2) ;
	
$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Hello ".$nama_ku." (".$user_session."),</p>
<p>You have to transfer BTC PIN balance,</p>
<p>No: ".$kode."<br>
Type: ".$uraian."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Transfer: ".$jmlrecx."<br>
Recipient: ".$nama_nya." (Wallet ID: ".$accid2.")<br>
Date: ".$tgl."<br>
Status: success<br>
<p>
Notes: ".$uraian."
</p>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email_ku, $nama_ku);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama_ku.', your transfer BTC PIN balance';
        $mail3->msgHTML($isimail);
	   // $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
     //   $mail3->send();		
	
	

$isimail2="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Hello ".$nama_nya." (".$tujuan."),</p>
<p>You have to get BTC PIN balance,</p>
<p>No: ".$kode."<br>
Type: ".$uraian."<br>
Amount: ".$jumlahdepone."<br>
Fee ".$fee."%: ".rupiah($jml_fee)."<br>
Transfer: ".$jmlrecx."<br>
From: ".$nama_ku." (Wallet ID: ".$accid.")<br>
Date: ".$tgl."<br>
Status: success<br>
<p>
Notes: ".$uraian."
</p>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";


 $mail3b = new PHPMailer;
        $mail3b->setFrom($emailadmin, $bisnisname);
        $mail3b->addAddress($emailtujuan, $nama_nya);
	    $mail3b->IsHTML(true);       
        $mail3b->Subject = ''.$nama_nya.', you get BTC PIN balance';
        $mail3b->msgHTML($isimail2);
      //  $mail3b->send();		

$db->insert("notifikasi", "", "'', '$username', 'Transfer BTC PIN balance', '', '', 'Transfer ".$uraian." ".$kode." has been processed.', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");

$db->insert("notifikasi", "", "'', '$tujuan', 'Transfer BTC PIN balance', '', '', 'You get a ".$uraian." ".$kode." from ".$accid." (".$nama_ku.").', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");

  header("location: index.php?go=btcpin&page=transfer&result=success_add&co=".base64_encode($kode)."&ca=".base64_encode($jumlahdepone)."&cd=".base64_encode($accid2)."");
	exit;
}
}
}
}
}
}
}
}
}
}
}
	  }
	  }
?>

 
 
 
 
 

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

?>



   
   
   <div class="row">
                <div class="col-md-4">
                
                 <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Add BTC PIN Balance</h4>
                        </div>
                        <div class="panel-body">
               
               
               
                 <?php  if($convertcoin == 0){ 
				 echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Add balance is curently 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 dataewalet22 where username='".$user_session."' and status='0'");
                        $ada_sp3 = mysql_num_rows($sql_sp3);
                        if($ada_sp3){	
		echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>You still have a pending transaction. Wait until the transaction is processed in order to be able to add balance again.</div>";
$diss4=" disabled='disabled'";
		
} else {
				
$diss4="";
}
						
?>	   


<?php
 if(isset($_GET['result'])&&$_GET['result']=="success_add"){
if(isset($_GET["co"])){ $co = anti_injection(base64_decode($_GET["co"])); }
if(isset($_GET["ca"])){ $ca = anti_injection(base64_decode($_GET["ca"])); }
echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Add coin balance ".$co." has been successfully, please make payment according to the value balance of your order".$ca.".</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>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="min_buy"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Minimum add BTC PIN balance is ".rupiah($minimalconvertcoin).".</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="max_buy"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max add BTC PIN balance is ".rupiah($maksimalconvertcoin).".</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 a transaction pending status. Wait until the transaction is processed in order to be able to add add BTC PIN again.</div>";
}
?>
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="type"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Select type balance.</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>Add BTC PIN balance Has been successfully submitted.</div>";
}
?>
<?php
if(isset($_GET['result'])&&$_GET['result']=="wrong_captcha"){
echo "<div class='alert alert-danger'>Wrong Captcha!</div>";
}
?>	
         
<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> 
    <?php 
			 
			 $saldobwallete = $db->myewalet($user_session);
			 $pendingbwallete = $db->myewaletpending($user_session);
			 $totalbwalete = $saldobwallete-$pendingbwallete;
			
			 $jmlcoinex=$totalbwalete;
			
			
			 ?>  
               
                <form id="tab2" name="wallet_depo" method="post" action="?go=btcpin&page=buy_balance_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 $feeconvertcoin; ?>"/>   
<input type="hidden" id="accid" name="accid" value="<?php echo $db->dataku("accid", $user_session); ?>"/>  
<input type="hidden" id="jenis" name="jenis" value="datacwalet"/>    

          <div class="controls-row">

            <label>Wallet Balance</label>
           <select name="" id="" required='required' class="form-control">
             
                
             <?php 
			
			if($totalbwalete > 0){
				echo "<option value='1'>WALLET BALANCE [Balance ".rupiah($totalbwalete)."]</option>";
			}else{
				echo "<option value='1' disabled='disabled'>WALLET BALANCE [No Balance]</option>";
		}
			// if($totalcwalete > 0){
			//	echo "<option value='2'>R-POINT [Balance ".rupiah($totalcwalete)."]</option>";
			//}else{
			//	echo "<option value='2' disabled='disabled'>R-POINT [No Balance]</option>";
			//}
			
			//if($totalawalete > 0){
			//	echo "<option value='3'>Z-POINT [Balance ".rupiah($totalawalete)."]</option>";
			//}else{
			//	echo "<option value='3' disabled='disabled'>Z-POINT [No Balance]</option>";
			//}
			?>
             
		       </select>  

          </div>

          

          <div class="controls-row">

            <label>Amount BTC PIN</label>
            <?php if($jmlcoinex > 0){ ?>

           <input name="jumlah" class="form-control" id="jumlah" value="<?php echo $jmlcoinex; ?>" onkeypress="return isNumberKey(event,this)" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?>>
           
           <?php } else { ?>
           <input name="jumlah" class="form-control" id="jumlah" disabled="disabled" value="0" onkeypress="return isNumberKey(event,this)" required='required' autocomplete="off"<?php echo $diss3; ?><?php echo $diss4; ?>> 
           
           <?php } ?>

          </div>
          
          
          <div class="controls-row">

            <label>Fee Conversion</label>
<input type="text" class="form-control" readonly="readonly" style='color:#333;' value="<?php echo $feeconvertcoin;?>%">

          </div>
          
 <div class="controls-row">

            <label>PIN</label>

           <input type="password" class="form-control" placeholder="Enter Your PIN" name="pincode" required='required'>
                                                          

          </div>

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

            <label></label>

           <?php
      // show captcha HTML using Securimage::getCaptchaHtml()
      require_once 'securimage/securimage.php';
      $options = array();
      $options['input_name'] = 'php_captcha'; // change name of input element for form post
      //$options['audio_button_bgcol'] = '#E0E0E0'; // change name of input element for form post
      echo Securimage::getCaptchaHtml($options);
    ?>
    <input class="form-control" placeholder="Enter Captcha" required name="php_captcha" type="text" value="" style=" margin-top:10px;">
                                               

          </div>
          

         
 <div>

           &nbsp;

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

          </div>

        </form>
        
        
        
                </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">Add BTC PIN Balance 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="15%"><?php echo $LANG["amount"]?></th>
							<th width="15%">Fee</th>
							<th width="15%">Add</th>
							<th width="7%">Status</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>
                                           
                                               
                                            <?

	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, tglproses, jenis, fee, bayar", "dataewalet22", "username='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[8] == "ewalet") {
				$jenise = "Balance";
			} else if($row[8] == "bwalet") {
				$jenise = "B-Walet";
			} else {
				$jenise = "R-Walet";
			}		
			
			
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[6] > 0) {
				$st = "<span class='label label-success tooltips' data-original-title='Lunas tanggal ".formatgl($row[7])."'>Done</span>";
				$sxt = "---";
				$style = "<font>";
			} else {
				$st = "<span class='label label-danger'>Pending</span>";
				$sxt = '<a href="#null" onClick="newWindow(\'page.php?go=payment_walet&sc='.$row[0].'\',\'\',\'800\',\'800\',\'resizable,scrollbars,status\')">
	   <button class="btn btn-xs green  tooltips" type="button" data-original-title="Pembayaran">Detail Pembayaran</button></a>';
				$style = "<font color='#F00000'>";
			}	
			
			
				$tt = formatgl($row[5]);
				
			$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"><?= $style; ?><?= $tt; ?></font></td>
							<td align="center"><?= $style; ?><?= rupiah($row[3]); ?></font></td>
							<td align="center"><?= $style; ?><?= rupiah($row[9]); ?></font></td>
							<td align="center"><?= $style; ?><?= rupiah($row[10]); ?></font></td>
                          
							
							<td align="center"><?= $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
 } else if (isset($_GET['page']) && $_GET['page'] == "buy_balance_go") {

?>
<?

$captcha = anti_injection($_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: index.php?go=btcpin&page=buybalance&result=wrong_captcha");
		 exit;
      } else {	


 $saldobwallete = $db->myewalet($user_session);
			 $pendingbwallete = $db->myewaletpending($user_session);
			 $totalbwalete = $saldobwallete-$pendingbwallete;
			 $jmlcoinex=$totalbwalete;
			 
	if (!$totalbwalete) {
        header("location: index.php?go=btcpin&page=buybalance&result=nobalance");
	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=btcpin&page=buybalance&result=no_pin");
	exit;
} else {
if(!$pincods || $pincods <> $pin) {
	header("location: index.php?go=btcpin&page=buybalance&result=wrong_pin");
	exit;
} else {
if($lock == 1) {
	header("location: index.php?go=btcpin&page=buybalance&result=pin_lock");
exit;
	} else {
if($sts == 0) {
	header("location: index.php?go=btcpin&page=buybalance&result=pin_off");
	exit;
} else {	



$jumlah = anti_injection($_POST['jumlah']);
$jenis = $_POST['jenis'];
$kode = $_POST['kode'];
$username = anti_injection($_POST['user']);	
$accid = anti_injection($_POST['accid']);	
$amount = anti_injection($_POST['jumlah']);

$fee = $_POST['fee'];
$jumlah=$amount;	

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

$jml_byr=$amount-$jml_fee;
$jmlfeex = rupiah($jml_fee);
$jmlrecx = rupiah($jml_byr);

$jml_dtwce=$amount;


if ($amount > $jmlcoinex) {
        header("location: index.php?go=btcpin&page=buybalance&result=error");
	exit;
      } else {	

if (!$jenis) {
        header("location: index.php?go=btcpin&page=buybalance&result=type");
	exit;
      } else {

$db->select("status", "dataewalet22", "status='0' and tujuan='$username'");
				$ada = $db->num_rows();
if ($ada >0) {
  header("location: index.php?go=btcpin&page=buybalance&result=pending");
	exit;
} else {

		

if (!$amount || $amount < $minimalconvertcoin) {
        header("location: index.php?go=btcpin&page=buybalance&result=min_buy");
	exit;
      } else {

if ($amount > $maksimalconvertcoin) {
        header("location: index.php?go=btcpin&page=buybalance&result=max_buy");
	exit;
      } else {


$db->insert("dataewalet22", "", "'', '$kode', '$username', '$amount', '', '$username', '$clientdate', '1', '$jenis', '', '$accid', '', '$jml_fee', '$jml_byr'"); 		
			
if($jenis == "datacwalet"){
	$jenise="BTC PIN Balance";
}else{
	$jenise="";
}

$uraian1 = "Add BTC PIN Balance";
$uraian1x = "Fee ".$fee."% (".rupiah($jml_fee).")";

$cekadanes = mysql_query("select kode from dataewalet where kode='$kode'");
$ada_adanes = mysql_num_rows($cekadanes); 
if(!$ada_adanes) {
$db->insert("dataewalet", "", "'', '$kode', '$username', '$jml_dtwce', '".mysql_real_escape_string($uraian1)."', 'administrator', '$clientdate', 1, '$clientdate', '$accid', 'administrator'");		
}

$cekadane = mysql_query("select kode from datacwalet where kode='$kode'");
$ada_adane = mysql_num_rows($cekadane); 
if(!$ada_adane) {
$db->insert("datacwalet", "", "'', '$kode', 'administrator', '$jml_byr', '".mysql_real_escape_string($uraian1)."', '$username', '$clientdate', 1, '$clientdate', 'administrator', '$accid'");	
if($jml_fee > 0){
$db->insert("datacwalet", "", "'', '$kode', '$username', '$jml_fee', '".mysql_real_escape_string($uraian1x)."', 'administrator', '$clientdate', 1, '$clientdate', '$accid', 'administrator'"); 
}	
}	




$spon_nama = $db->dataku("nama", $username);

		$spon_mail = $db->dataku("email", $username);
		$nama = $db->dataku("nama", $username);
		$jumlahdepone = rupiah($amount);
		$namadmin = $db->config("name");
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");



$sess = substr(str_shuffle(str_repeat("4453141119066764203711128717497783625536342396411241472162223777", 64)), 0, 22);
			$invc="ADDBALANCE_".$user_session."_".$sess."_".$kode;
			$inv="http://".$domain."/invoice/".$invc.".pdf";
			$db->insert("invoice","","'', '$user_session', '$kode', '$invc', '$clientdate'");
			$nama_ku = $db->dataku("nama",$user_session);
			$email_ku = $db->dataku("email",$user_session);
			$hp_ku = $db->dataku("hp",$user_session);
			$nama_nya = $db->dataku("nama",$tujuan);
			


$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$nama_ku." (".$user_session."),</p>
<p>Your add balance</p>
<p><strong>No: ".$kode."<br>
Type: ".$jenise."<br>
Amount: ".$jumlahdepone."<br>
Fee: ".$jmlfeex."<br>
Add: ".$jmlrecx."<br>
Date: ".$tgl."<br>
</p>

<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email_ku, $nama_ku);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama_ku.', Your add balance';
        $mail3->msgHTML($isimail);
	  //$mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	


$db->insert("notifikasi", "", "'', '$username', 'Add BTC PIN Balance', '', '', 'Add BTC PIN Balance No Transaction ".$kode."', '$clientdate', 'label label-sm label-icon label-info', 'fa fa-info', '0', '$kode'");



 header("location: index.php?go=btcpin&page=buybalance&result=success");
	exit;


	  }
}
}
}
}
	}
}
}
}
}
	  }
?>	
    
    
    
    
    
    
    
    <?
	
	
} else {
?>

   
   
   
         <div class="row">
            	<div class="col-md-12">
                	
                    
                    <div class="panel panel-inverse">
                        <!-- Start .panel -->
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white"> BTC PIN Balance [<?  $saldoawalete = $db->mycwalet($user_session);
			 $pendingawalete = $db->mycwaletpending($user_session);
			 $totalawalete = $saldoawalete-$pendingawalete; 
			 if($totalawalete > 0){ echo rupiah($totalawalete); }else{ echo rupiah(0);} ?>]</h4>
                           
                        </div>
                        
                        <div class="panel-body">
                        
                        
                        
                        
                        
                                    <table id="data-table" class="table table-bordered" cellspacing="0" width="100%">          
                
             
              <thead>
                <tr>
                	<th width="10%">NO</th>
							<th width="20%">DATE</th>
							<th width="10%">TYPE</th>
							<th width="20%">AMOUNT</th>
							<th width="30%">NOTE</th>
							<th width="6%">STATUS</th>
                </tr>
              </thead>
              <tbody>          
                
	<?


	$db->select("kode, uraian, username, jumlah, tujuan, tgl, status, tglproses, accid, accid2", "datacwalet", "username='$user_session' or tujuan='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[4] == $user_session) {
				$ket = "$row[1]";
			} else {
				$ket = 	"$row[1]";
			}
			if($row[2] == $user_session) {
				$type = "Debet";
			} else {
				$type = "Credit";
			}	
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[7] == "0000-00-00 00:00:00"){
		$dtpros = "<span class='label label-success' onMouseover=\"ddrivetip('Date process not found')\" onMouseout='hideddrivetip()' >Done</span>";
	}else{
		$dtpros = "<span class='label label-success' onMouseover=\"ddrivetip('Process : ".formatgl($row[7])."')\" onMouseout='hideddrivetip()'>Done</span>";
	}
			if($row[6] > 0) {
				$st = $dtpros;
			} else {
				$st = "<span class='label label-danger'>Pending</span>";
			}	
			
			if($row[2] == $user_session) {
				$style = "<font color='#FF6600'>";
			} else {
				$style = "<font>";
			}		
			
		
	$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; ?><?= $row[0]; ?></font></td>
            <td align="center"><?php echo $style; ?><?= date("d-m-Y", strtotime($row[5])); ?></font></td>
            <td align="center"><?php echo $style; ?><?= $type; ?></font></td>
            
            <td align="center"><?php echo $style; ?><?= rupiah($row[3]); ?></font></td>
            <td align="center"><?php echo $style; ?><?= $ket; ?></font></td>
           
            <td align="center"><?php echo $style; ?><?= $st; ?></font></td>
    </tr>
	<?
		}
	?>
              </tbody>
            </table>
                  </div>
                    </div>
                </div>
			</div>
			<!-- END PAGE CONTENT -->       
   
   
 
 
 
 
 
 
 
 
 
 


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