<?php
require_once 'connect.inc.php'; require_once '../php/c.php';

if(function_exists('alert')){
    
}else{
    function alert($x){
        echo "<script> alert('$x'); </script>";
    }
}



function user1(){
	
	

	if(isset($_COOKIE['nm'])){
	
	$var = $_COOKIE['nm'];
	
}else{
	
}
	$i=0;
	
	global $con;
		$query = "select * from info where 1 ORDER BY id DESC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$fname = $query_row['fname'];
					$lname = $query_row['lname'];
					$email = $query_row['email'];
					$country = $query_row['country'];
					$password = $query_row['password'];
					$bal = $query_row['balance'];
					// $pack = $query_row['pack'];
					$ee = $query_row['verify'];
					$gender = $query_row['gender'];
					// $eth = $query_row['eth'];
					$btc = $query_row['account'];
				if($ee == 0){
					$verif = "<span style='color:red'>Unverified</style> ";
				}else{
					$verif = "<span style='color:green'>Verified</style> ";
				}
				
				$tr = '  <option value="'.$id.'"  >'.$fname.' '.$lname.' </option>';   
									  echo $tr;
				
			}
	
}




function user11(){
	
	

	if(isset($_COOKIE['nm'])){
	
	$var = $_COOKIE['nm'];
	
}else{
	
}
	$i=0;
	
	global $con;
		$query = "select * from info where 1 ORDER BY id DESC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$fname = $query_row['fname'];
					$lname = $query_row['lname'];
					$email = $query_row['email'];
					$country = $query_row['country'];
					$password = $query_row['password'];
					$bal = $query_row['balance'];
					// $pack = $query_row['pack'];
					$ee = $query_row['verify'];
					$gender = $query_row['gender'];
					// $eth = $query_row['eth'];
					$btc = $query_row['account'];
				if($ee == 0){
					$verif = "<span style='color:red'>Unverified</style> ";
				}else{
					$verif = "<span style='color:green'>Verified</style> ";
				}
				
				$tr = '  <option value="'.$email.'"  >'.$fname.' '.$lname.' </option>';   
									  echo $tr;
				
			}
	
}



if($_POST['verify_user']){
    $id = $_POST['verify_user'];
    if(!empty($id)){
        $q = "update info set kyc = '2' where id ='$id' ";
        if(mysqli_query($con,$q)){
            alert('User Verified');
        }
    }
}
if($_POST['unverify_user']){
    $id = $_POST['unverify_user'];
    if(!empty($id)){
        $q = "update info set kyc = '0' where id ='$id' ";
        if(mysqli_query($con,$q)){
            alert('User Verified');
        }
    }
}



if($_POST['delete_user']){
    $id = $_POST['delete_user'];
    if(!empty($id)){
        $q = "DELETE FROM info where id ='$id' ";
        if(mysqli_query($con,$q)){
            alert('User Deleted');
        }
    }
}




if($_POST['block_user']){
    $id = $_POST['block_user'];
    if(!empty($id)){
        $q = "UPDATE info SET lock_account = '1' WHERE id ='$id' ";
        if(mysqli_query($con,$q)){
            alert('User Blocked');
        }
    }
}


if($_POST['unblock_user']){
    $id = $_POST['unblock_user'];
    if(!empty($id)){
        $q = "UPDATE info SET lock_account = '0' WHERE id ='$id' ";
        if(mysqli_query($con,$q)){
            alert('User Blocked');
        }
    }
}

if($_POST['edit_user']){
    $id = $_POST['edit_user'];
    if(!empty($id)){
        header("location:../edit/?id=".md5($id));
    }
}









function user(){
	
	

	if(isset($_COOKIE['nm'])){
	
	$var = $_COOKIE['nm'];
	
}else{
	
}
	$i=0;
	
	global $con;
		$query = "select * from info where 1 ORDER BY id DESC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$fname = $query_row['fname'];
					$lname = $query_row['lname'];
					$email = $query_row['email'];
					$country = $query_row['country'];
					$password = $query_row['pass'];
					$bal = $query_row['bal'];
					$phone = $query_row['phone'];
					// $pack = $query_row['package'];
					$ee = $query_row['kyc'];

					// $bonus = $query_row['bonus'];
					// $btc = $query_row['account'];
				if($ee == 0){
					$verif = "<span style='color:red'>Unverified</style> ";
				}elseif($ee==1){
					$verif = "<span style='color:#ff9900'>Pending kyc</style> ";

				    }else{
					$verif = "<span style='color:green'>Verified</style> ";
				}
				
	$ver_btn = "<form method='POST'> <input type='hidden' value='$id' name='verify_user'> <button type='submit' class='btn btn-success'> <i class='fa fa-check'></i> Verify User</button> </form>";	
					
	$unver_btn = "<form method='POST'> <input type='hidden' value='$id' name='unverify_user'> <button type='submit' class='btn btn-danger'> <i class='fa fa-check'></i>Unverify User</button> </form>";	
	
	$del_btn = "<form method='POST'> <input type='hidden' value='$id' name='delete_user'> <button type='submit' class='btn btn-danger'> <i class='fa fa-trash'></i> Delete User</button> </form>";	
	
    $block_btn = "<form method='POST' > <input type='hidden' value='$id' name='block_user'> <button type='submit' class='btn btn-danger'> <i class='fa fa-lock'></i> Bock User</button> </form>";
    
    $unblock_btn = "<form method='POST' > <input type='hidden' value='$id' name='unblock_user'> <button type='submit' class='btn btn-primary'> <i class='fa fa-unlock'></i> Unblock User</button> </form>";
	
	    
    $edit_btn = "<form  method='POST' > <input type='hidden' value='$id' name='edit_user'> <button type='submit' class='btn btn-primary'> <i class='fa fa-edit'></i> Edit User</button> </form>";
    	
	    
    $edit_btn = "<form method='POST'> <input type='hidden' value='$id' name='edit_user'> <button type='submit' class='btn btn-primary'> <i class='fa fa-edit'></i> Edit User</button> </form>";
		
	
$view_front_id  = (!empty($query_row['id_front_name'])) ?  "<a href='https://financetradeexpert.com/user/php/upload/".$query_row['id_front_name']."'> <span> View Front ID </span> </a>" : "<span> No ID </span>";
$view_back_id  = (!empty($query_row['id_back_name'])) ?  "<a href='https://financetradeexpert.com/user/php/upload/".$query_row['id_back_name']."'> <span> View Back ID </span> </a>" : "<span> No ID </span>";
$dt = (($query_row['last_login']));
$dt =  (!empty($dt)) ? strtotime($dt) : time();
$last_login =  date('d M Y',$dt);
$blocked_btn = (($query_row['lock_account'] == 1)) ? $unblock_btn : $block_btn;

$v_btn =  (($query_row['kyc'] == 0) || ($query_row['kyc'] == 1)) ? $ver_btn : $unver_btn;
		
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.$fname.'
                                        </td>
                                        <td >
                                          '.$lname.'
                                        </td>
                                        <td>
                                          <span class="c-primary"><b>'.$email.'</b></span>
                                        </td>
                                        <td>
                                          <span class="c-primary"><b>'.$phone.'</b></span>
                                        </td>
                                      
										<td >
                                          '.$password.'
                                        </td>
										
										<td >
                                          '.$country.'
                                        </td>
										
										<td >
                                          '.$bal.'
                                        </td>
                                        
                                		<td style="white-space:nowrap;" >
                                          '.$last_login.'
                                        </td>
										
										<td >
                                          '.$verif.'
                                        </td>
                                        
                                        										
										<td >
                                          '.$view_front_id.'
                                        </td>
                                        
                                                                                										
										<td >
                                          '.$view_back_id.'
                                        </td>
                                        										
										<td >
                                          '.$v_btn.'
                                        </td>
                                        
                                                                                										
										<td >
                                          '.$edit_btn.'
                                        </td>
                                        
                                                                                										
										<td >
                                          '.$blocked_btn.'
                                        </td>
                                                
                                                                                                                        										
										<td >
                                          '.$del_btn.'
                                        </td>
                                        
                                      </tr>';
									  echo $tr;
				
			}
	
}







function BAL(){
	
	

	if(isset($_COOKIE['nm'])){
	
	$var = $_COOKIE['nm'];
	
}else{
	
}
	$i=0;
	
	global $con;
		$query = "select * from info where 1 ORDER BY id DESC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$fname = $query_row['fname'];
					$lname = $query_row['lname'];
					$email = $query_row['email'];
					$country = $query_row['country'];
					$bal = $query_row['bal'];
					$bal2 = $query_row['bal2'];
					// $regcode = $query_row['regcode'];
					// $eth = $query_row['eth'];
					// $btc = $query_row['btc'];

				
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.$fname.' '.$lname.'
                                        </td>
                                       
                                        <td>
                                          <span class="c-primary"><b>'.$bal.'</b></span>
                                        </td>                
				                       <td>
										<span class="c-primary"><b>'.$bal2.'</b></span>
									  </td>
                                      
										
										
										
										
										<td >
                                          '.$email.'
                                        </td>	
										
										
                                      </tr>';
									  echo $tr;
				
			}
	
}













function BON(){
	
	

	if(isset($_COOKIE['nm'])){
	
	$var = $_COOKIE['nm'];
	
}else{
	
}
	$i=0;
	
	global $con;
		$query = "select * from info where 1 ORDER BY id DESC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$fname = $query_row['fname'];
					$lname = $query_row['lname'];
					$email = $query_row['email'];
					$country = $query_row['country'];
					$bon = $query_row['profit'];
					// $regcode = $query_row['regcode'];
					// $eth = $query_row['eth'];
					// $btc = $query_row['btc'];

				
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.$fname.' '.$lname.'
                                        </td>
                                       
                                        <td>
                                          <span class="c-primary"><b>'.$bon.'</b></span>
                                        </td>
                                      
										
										
										
										
										<td >
                                          '.$email.'
                                        </td>	
										
										
                                      </tr>';
									  echo $tr;
				
			}
	
}























function drw(){
	
	$i=0;
	
	global $con;
		$query = "select * from trans where  type='withdraw' order BY id DESC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$email = $query_row['email'];
					$amt = $query_row['amount'];
					$status = $query_row['status'];
					$dt = strtotime($query_row['created_at']);
					$date = date('d M Y h:i',$dt);;
					
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.$email.'
                                        </td>
                                      
                                        <td>
                                          <span class="c-primary"><b>'.$amt.'</b></span>
                                        </td>
                                      
										<td >
                                          '.$date.'
                                        </td>
										<td >
										'.$status.'
									  </td>
										<td >
                                        <form method="post" action="#"> <input hidden name="v" value='.$id.'> <input class="btn btn-success" value="Confirm" type="submit"> </form>
                                        </td>
										
										<td >
                                         <form method="post" action="#"> <input hidden name="u" value='.$id.'> <input class="btn btn-danger" value="Decline" type="submit"> </form>
                                        </td>	
										

                                      </tr>';
									  echo $tr;
			}
	
}






function depa(){
	
	$i=0;
	
	global $con;
		$query = "select * from trans where type='deposit' ORDER BY id DESC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$email = $query_row['email'];
					$amt = $query_row['amount'];
					$status = $query_row['status'];
					$dt = strtotime($query_row['created_at']);
					$date = date('d M Y h:i',$dt);

				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.$email.'
                                        </td>
                                        <td >
                                          '.$status.'
                                        </td>
                                        <td>
                                          <span class="c-primary"><b>'.$amt.'</b></span>
                                        </td>
                                      
										<td >
                                          '.$date.'
                                        </td>
										
										<td >
                                        <form method="post" action="#"> <input hidden name="v2" value='.$id.'> <input class="btn btn-success" value="Confirm" type="submit"> </form>
                                        </td>
										
										<td >
                                         <form method="post" action="#"> <input hidden name="u2" value='.$id.'> <input class="btn btn-danger" value="Decline" type="submit"> </form>
                                        </td>	
										

                                      </tr>';
									  echo $tr;
			}
	
}













if(isset($_POST['v2'])){
	$v = $_POST['v2'];
		if(!empty($v)){
			$query = "update trans set status = 'success' where id = '$v' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
				}
		}
}


if(isset($_POST['v'])){
	$v = $_POST['v'];
		if(!empty($v)){
			$query = "update transs set status = 'success' where id = '$v' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
				}
		}
}


if(isset($_POST['u2'])){
	$v = $_POST['u2'];
		if(!empty($v)){
			$query = "update trans set status = 'cancelled' where id = '$v' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
				}
		}
}



if(isset($_POST['u'])){
	$v = $_POST['u'];
		if(!empty($v)){
			$query = "update trans set status = 'cancelled' where id = '$v' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
				}
		}
}



if(isset($_POST['act']) && isset($_POST['bal'])){
	$id = $_POST['act'];
	$bal = $_POST['bal'];
		if(!empty($id)){
			$query = "update info set bal = '$bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
				}
		}
}




if(isset($_POST['act']) && isset($_POST['bal2'])){
	$id = $_POST['act'];
	$bal = $_POST['bal2'];
		if(!empty($id)){
			$query = "update info set bal2 = '$bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
				}
		}
}



if(isset($_POST['act']) && isset($_POST['aid']) ){
	$v2 = $_POST['aid'];
	$v = $_POST['act'];
		if(!empty($v2)){
		    if(trim($v2) == "YESS" ){
			$query = "update info set cvc = '1' where id = '$v' ";
				if(mysqli_query($con,$query)){
				// 		$maro = "alert('action Successful.')";
				}
		    }
		}
}



if(isset($_POST['acct']) && isset($_POST['aid']) ){
	$v2 = $_POST['aid'];
	$v = $_POST['acct'];
		if(!empty($v2)){
		    if(trim($v2) == "YESS" ){
			$query = "update info set cvc = '1' where email = '$v' ";
				if(mysqli_query($con,$query)){
				// 		$maro = "alert('action Successful.')";
				}
		    }
		}
}





if(isset($_POST['act']) && isset($_POST['bon'])){
	$id = $_POST['act'];
	$bal = $_POST['bon'];
		if(!empty($id)){
			$query = "update info set bonus = '$bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
				}
		}
}





// settings



if(isset($_POST['btc'])){
	$v = $_POST['btc'];
		if(!empty($v)){
			$query = "update settings set btc = '$v' where id = '1' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful. ".$v."')";
				}
		}
}


if(isset($_POST['eth'])){
	$v = $_POST['eth'];
		if(!empty($v)){
			$query = "update settings set eth = '$v' where id = '1' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.".$v."')";
				}
		}
}



if(isset($_POST['usdt_trc20'])){
	$v = $_POST['usdt_trc20'];
		if(!empty($v)){
			$query = "update settings set usdt_trc20 = '$v' where id = '1' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.".$v."')";
				}
		}
}


if(isset($_POST['usdt_erc20'])){
	$v = $_POST['usdt_erc20'];
		if(!empty($v)){
			$query = "update settings set usdt_erc20 = '$v' where id = '1' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.".$v."')";
				}
		}
}


if(isset($_POST['usdt_bep2'])){
	$v = $_POST['usdt_bep2'];
		if(!empty($v)){
			$query = "update settings set usdt_bep2 = '$v' where id = '1' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.".$v."')";
				}
		}
}

// if(isset($_POST['reg'])){
	// $v = $_POST['reg'];
		// if(!empty($v)){
			// $query = "update settings set reg = '$v' where id = '1' ";
				// if(mysqli_query($con,$query)){
						// $maro = "alert('action Successful.".$v."')";
				// }
		// }
// }

function set($q){
	
	
	$i=0;
	
	global $con;
		$query = "select * from settings where  id =1 ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$btc = $query_row['btc'];
					$eth = $query_row['eth'];
					$usdt_trc20 = $query_row['usdt_trc20'];
					$usdt_erc20 = $query_row['usdt_erc20'];
					$usdt_bep2 = $query_row['usdt_bep2'];
					
					
			
									  
			}
			if($q == 'btc'){
				echo $btc;
			}
			if($q == 'eth'){
				echo $eth;
			}			if($q == 'usdt_trc20'){
				echo $usdt_trc20;
			}			if($q == 'usdt_erc20'){
				echo $usdt_erc20;
			}			if($q == 'usdt_bep2'){
				echo $usdt_bep2;
			}
			if($q == 3){
				echo $regi;
			}
	
}

if(isset($_POST['acct']) && isset($_POST['amount']) && isset($_POST['date']) && isset($_POST['status'])){
    $acct = mysqli_real_escape_string($con,trim($_POST['acct']));
    $amount = mysqli_real_escape_string($con,trim($_POST['amount']));
    $date = mysqli_real_escape_string($con,trim($_POST['date']));
    $status = mysqli_real_escape_string($con,trim($_POST['status']));
    $tid = rand(100,999).rand(100,999).rand(100,999);
    if(!empty($acct) && !empty($amount) && !empty($date) && !empty($status)){
        
        $q= "insert  into deposit VALUES(NULL,'$tid','$amount','$acct','$date','$status','bitcoin')";
       if(mysqli_query($con,$q)){
          echo '<script> alert("Deposit added"); </script>';  
        }
    }else{
                //  echo '<script> alert("empty added '.$amount.'"); </script>';  

    }
    
}


?>