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


    
$q_d = "select x from alogin where id = '1'";
$d_r = mysqli_query($con,$q_d);
$db_x = mysqli_R($d_r,0);

$q_d = "select y from alogin where id = '1'";
$d_r = mysqli_query($con,$q_d);
$db_y = mysqli_R($d_r,0);

$q_d = "select z from alogin where id = '1'";
$d_r = mysqli_query($con,$q_d);
$db_z = mysqli_R($d_r,0);

if($db_x <= 0){
    header('location:/cadminc/indexs.php');
    die();
}




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'];

				$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'];

				$tr = '  <option value="'.$email.'"  >'.$fname.' '.$lname.' </option>';   
									  echo $tr;
				
			}
	
}




if(isset($_POST['lck'])){
	$id = $_POST['lck'];
	    $q = "select lock_account from info where id='$id'";
	    $r = mysqli_query($con,$q);
	    $locked = mysqli_R($r,0);
	    
	
		if(!empty($id)){
		    if($locked == 1){    
			$query = "update  info  set lock_account = '0' where id = '$id' ";
				$lck_msg = 'Account Unlocked';
		    }else{
		  	$query = "update  info  set lock_account = '1' where id = '$id' ";
		  	$lck_msg = 'Account Locked';

		    }
				if(mysqli_query($con,$query)){
						echo  "<script>alert('action Successful.') </script>";
						// 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "$lck_msg";
					header('location:./');
					die();
				}
		}
}



if(isset($_POST['stat'])){
	$id = $_POST['stat'];
	    $q = "select stat from info where id='$id'";
	    $r = mysqli_query($con,$q);
	    $stat = mysqli_R($r,0);
	    
	
		if(!empty($id)){
		    if($stat == 'online'){    
			$query = "update  info  set stat = 'inactive' where id = '$id' ";
				$stat_msg = 'Status updated to Inactive';
		    }else{
		  	$query = "update  info  set stat = 'online' where id = '$id' ";
		  	$stat_msg = 'Status Updated to Online';

		    }
				if(mysqli_query($con,$query)){
						echo  "<script>alert('action Successful.') </script>";
						// 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "$stat_msg";
					header('location:./');
					die();
				}
		}
}



if(isset($_POST['KYC'])){
	$id = $_POST['KYC'];
	    $q = "select kyc from info where id='$id'";
	    $r = mysqli_query($con,$q);
	    $stat = mysqli_R($r,0);
	    
	
		if(!empty($id)){
		    if($stat == '0'){    
			$query = "update  info  set kyc = '1' where id = '$id' ";
				$stat_msg = 'Kyc is set to pending';
		    }elseif($stat == '1'){
		  	$query = "update  info  set kyc = '2' where id = '$id' ";
		  	$stat_msg = 'Kyc is set to verified';

		    }else{
		        	$query = "update  info  set kyc = '0' where id = '$id' ";
		  	$stat_msg = 'Kyc is set to unverified';
		    }
				if(mysqli_query($con,$query)){
						echo  "<script>alert('action Successful.') </script>";
						// 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "$stat_msg";
					header('location:./');
					die();
				}
		}
}




if(isset($_POST['mng'])){
	$id = $_POST['mng'];
	    $q = "select mining from info where id='$id'";
	    $r = mysqli_query($con,$q);
	    $locked = mysqli_R($r,0);
	    
	
		if(!empty($id)){
		    if($locked == 1){    
			$query = "update  info  set mining = '0' where id = '$id' ";
		    }else{
		  	$query = "update  info  set mining = '1' where id = '$id' ";

		    }
				if(mysqli_query($con,$query)){
						echo  "<script>alert('action Successful.') </script>";
				}
		}
}



if(isset($_POST['veri'])){
	$id = $_POST['veri'];
	    $q = "select ver from info where id='$id'";
	    $r = mysqli_query($con,$q);
	    $ver = mysqli_R($r,0);
	    
	
		if(!empty($id)){
		    if($ver == 1){    
			$query = "update  info  set ver = '2' where id = '$id' ";
		    }elseif($ver == 2){
		  	$query = "update  info  set ver = '0' where id = '$id' ";
		    }else{
		   	$query = "update  info  set ver = '1' where id = '$id' ";
 
		    }
				if(mysqli_query($con,$query)){
						echo  "<script>alert('action Successful.') </script>";
						// 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "Account  Verified";
					header('location:./');
					die();
				}
		}
}
// ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); 

if(isset($_POST['dele'])){
	$id = $_POST['dele'];
	   // $q = "select ver from info where id='$id'";
	   // $r = mysqli_query($con,$q);
	   // $ver = mysqli_R($r,0);
	    $ver =1;
	    
	    $q="select fname from info where id='$id'";
        $r = mysqli_query($con,$q);
        $fname = mysqli_R($r,0);
        
        
	    $q="select lname from info where id='$id'";
        $r = mysqli_query($con,$q);
        $lname = mysqli_R($r,0);
		
		if(!empty($id)){
		    if($ver == 1){    
			$query = "Delete from info where id = '$id' ";
		    }
				if(mysqli_query($con,$query)){
						echo  "<script>alert('Account deleted.') </script>";
						// 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "$fname $lname Account Deleted";
					header('location:./');
					die();
				}
		}
}


if(isset($_POST['lwith'])){
    $id = $_POST['lwith'];
    if(!empty($id)){
        $q = "select lwith from info where id = '$id'";
        $r = mysqli_query($con,$q);
        $oldlwith  = mysqli_R($r,0);
            if($oldlwith == 0){
                $newlwith = 1;
                $msg = "Withdrawal Allowed";
            }else{
                 $newlwith = 0;
                $msg = "Withdrawal Dissallowed (Linking required)"; 
            }
            
            $q = "update info set lwith = '$newlwith' where id = '$id'";
            if(mysqli_query($con,$q)){
                // echo "<script> alert('$msg'); </script>";
                // 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "$msg";
					header('location:./');
					die();
            }
    }
}



if(isset($_POST['gencode'])){
    $id = $_POST['gencode'];
    
    if(!empty($id)){
$cot = rand(10000,999999);$vat = rand(10000,999999);$imf = rand(10000,999999);


$qrr="select fname from info where  id = '$id'";
$rr = mysqli_query($con,$qrr);
$fname = mysqli_R($rr,0);


$qrr="select lname from info where  id = '$id'";
$rr = mysqli_query($con,$qrr);
$lname = mysqli_R($rr,0);


            $q = "update info set cot = '$cot', vat='$vat', imf='$imf' where id = '$id'";
            if(mysqli_query($con,$q)){
                // echo "<script> alert('$msg'); </script>";
                // 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "New Codes Generated for $fname $lname";
					header('location:./');
					die();
            }else{
               	// $_SESSION['success'] = "New Codes Generatedz";
            }
    }
}




///dddd
function codes4(){
	
	

	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'];
					// $pack = $query_row['pack'];
					$ee = $query_row['ver'];
					$phone = $query_row['phone'];
					// $regcode = $query_row['regcode'];
					// $eth = $query_row['eth'];
					// $btc = $query_row['wallet'];
					$plan = $query_row['plan'];
					$locked = $query_row['locked'];
					$mine = $query_row['mining'];
					$type = $query_row['type'];
					$u = $query_row['u'];
					$u2 = $query_row['u2'];
					$lwith = $query_row['lwith'];

					$vat = $query_row['vat'];
					$cot = $query_row['cot'];
					$imf = $query_row['imf'];


					
					if($locked == '1'){
					   		$lbtn  ='<form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="lck"> <button type="submit" class="btn btn-primary"><i class="fa fa-lock"></i> suspend</button> </form>';
                                $lcked ="<span style='color:green'>Unsuspend</style> ";
					}else{
					   		$lbtn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="lck"> <button type="submit" class="btn btn-success"><i class="fa fa-open"></i>  UnSuspened </button>  </form>';
					        $lcked ="<span style='color:red'>suspend</style> ";

					}
					
					
					if($mine == '1' && $type == 'mining'){
					   		$mbtn  ='<form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="mng"> <button type="submit" class="btn btn-danger"><i class="fa fa-power-off"></i> OFF</button> </form>';
                            $mn ="<span style='color:green'>ON</style> ";
					}elseif($mine == '0' && $type == 'mining'){
					    
					   		$mbtn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="mng"> <button type="submit" class="btn btn-success"><i class="fa fa-power-off"></i>  ON </button>  </form>';
					        $mn ="<span style='color:red'>OFF</style> ";

					}else{
					    $mbtn = "----";
					    $mn = "----";
					    
					}
					  
			$dmbtn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="dele"> <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i>  Delete </button>  </form>';
			$dvbtn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="veri"> <button type="submit" class="btn btn-primary"><i class="fa fa-check"></i>  verify </button>  </form>';
					
					
				if($ee == 0){
					$verif = "<span style='color:red'>Unverified</style> ";
				}elseif($ee == 1){
					$verif = "<a target='_blank' href='https://cryptonaryfinancing.com/dashboard/verify-account/upload/$u2' ><span style='color:blue'>Awaiting verifiaction</span></a> ";
				}else{
				  	$verif = "<span style='color:green'>Verified</style> ";
  
				}
				
		if($lwith == 1){
$lwithbtn = "<form action='' method='POST'><input type='hidden' name='lwith' value='$id'> <button class='btn btn-warning'> <i class='fa fa-banned'></i> Disallow Withdrawal </button>  </form> ";
		}else{
$lwithbtn = "<form action='' method='POST'><input type='hidden' name='lwith' value='$id'> <button class='btn btn-info'> <i class='fa fa-cash'></i> Allow Withdrawal </button>  </form> ";		    
		}		

$lwithbtn = "<form action='' method='POST'><input type='hidden' name='gencode' value='$id'> <button class='btn btn-info' type='submit'> <i class='fa fa-keypad'></i> Generate code </button>  </form> ";		    
				
				
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.$fname.'
                                        </td>
                                        <td >
                                          '.$lname.'
                                        </td>
                                        <td>
                                          <span class="c-primary"><b>'.$email.'</b></span>
                                        </td>
                                      
										<td >
                                          '.$vat.'
                                        </td>
                                        
                                        <td >
                                          '.$cot.'
                                        </td>
                                        
                                        
                                        <td >
                                          '.$imf.'
                                        </td>
                                        
                                        
								
			                        <td>'.$lwithbtn.'</td> 
                                      </tr>';
									  echo $tr;
				
			}
	
}


///sss

// function change_plan_detail($column,$value,$id){
//     $q= "update plan set $column ='$value' where id ='$id'";
//     if(mysqli_query($con,$q)){
//         return 'success';
//     }
// }

//     ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

if(isset($_POST['plan_min']) && isset($_POST['plan_rate']) && isset($_POST['plan_period']) && isset($_POST['plan_name'])){
    $plan_min = mysqli_real_escape_string($con,trim($_POST['plan_min']));
    $plan_rate = mysqli_real_escape_string($con,trim($_POST['plan_rate']));
    $plan_period = mysqli_real_escape_string($con,trim($_POST['plan_period']));
    $plan_name = mysqli_real_escape_string($con,trim($_POST['plan_name']));
    
    $plan_id = mysqli_real_escape_string($con,trim($_POST['plan_id']));
    
    if(!empty($plan_min) && !empty($plan_rate) && !empty($plan_period) && !empty($plan_name) &&  !empty($plan_name)){
    
    
     $q= "update plans set name ='$plan_name', period= '$plan_period', min = '$plan_min', rate = '$plan_rate'  where id ='$plan_id'";

        if(mysqli_query($con,$q)){
            
            	$_SESSION['success'] = "Plan details updated ";
					header('location:./');
					die();
        }else{
            	$_SESSION['error'] = "Plan details could not be updated try again";
					header('location:./');
					die();
        }    
    
    
    
}else{
    	$_SESSION['error'] = "Plan details could not be updated try again";
					header('location:../');
					die();
}


}

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'];
					// $pack = $query_row['pack'];
					$ee = $query_row['stat'];
					$kyc = $query_row['kyc'];
					$front = $query_row['id_front_name'];
					$back = $query_row['id_back_name'];
					$phone = $query_row['phone'];
					// $regcode = $query_row['regcode'];
					// $eth = $query_row['eth'];
					// $btc = $query_row['wallet'];
				// 	$plan = $query_row['plan'];
					$locked = $query_row['lock_account'];
				// 	$mine = $query_row['mining'];
				// 	$type = $query_row['type'];
				// 	$u = $query_row['u'];
				// 	$u2 = $query_row['u2'];
				// 	$lwith = $query_row['lwith'];
					
					if($locked == '0'){
					   		$lbtn  ='<form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="lck"> <button type="submit" class="btn btn-primary"><i class="fa fa-lock"></i> Lock</button> </form>';
                                $lcked ="<span style='color:green'>Unlocked</style> ";
					}else{
					   		$lbtn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="lck"> <button type="submit" class="btn btn-success"><i class="fa fa-unlock"></i>  Unlock </button>  </form>';
					        $lcked ="<span style='color:red'>Locked</style> ";

					}
					
					
										
					if($kyc == '0'){
					   		$kyc_btn  ='<form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="KYC"> <button type="submit" class="btn btn-warning"><i class="fa fa-check"></i> Set to Pending</button> </form>';
                                $kyc_text ="<span style='color:red'>Unverified</style> ";
					}elseif($kyc == '1'){
					   		$kyc_btn  ='<form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="KYC"> <button type="submit" class="btn btn-success"><i class="fa fa-caution"></i> Verify</button> </form>';
                                $kyc_text ="<span style='color:yellow'>Verification pending (<a href='/user/php/upload/$front' target='_blank'>Front</a> <a href='/user/php/upload/$back' target='_blank'>Back</a> ) </style> ";
					}else{
					   		$kyc_btn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="KYC"> <button type="submit" class="btn btn-danger"><i class="fa fa-unlock"></i>  Unverify  </button>  </form>';
					        $kyc_text ="<span style='color:green'>Verified (<a href='/user/php/upload/$front' target='_blank'>Front</a> <a href='/user/php/upload/$back' target='_blank'>Back</a> )</style> ";

					}
					
					
					
					
					
					if($mine == '1' && $type == 'mining'){
					   		$mbtn  ='<form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="mng"> <button type="submit" class="btn btn-danger"><i class="fa fa-power-off"></i> OFF</button> </form>';
                            $mn ="<span style='color:green'>ON</style> ";
					}elseif($mine == '0' && $type == 'mining'){
					    
					   		$mbtn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="mng"> <button type="submit" class="btn btn-success"><i class="fa fa-power-off"></i>  ON </button>  </form>';
					        $mn ="<span style='color:red'>OFF</style> ";

					}else{
					    $mbtn = "----";
					    $mn = "----";
					    
					}
					  
		if(!($ee == 'inactive')){
					$verif2 = "INACTIVE ";
				}else{
				  	$verif2 = "ONLINE ";
				}
	
			$dmbtn  =' <form action ="" method="POST"> <input type="hidden" value="'.$id.'" name="dele"> <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i>  Delete </button>  </form>';
			$dvbtn  =' <form action ="" method="POST">   <input type="hidden" value="'.$id.'" name="stat"> <input type="hidden" value="'.$verif2.'" name="stat2">  <button type="submit" class="btn btn-primary"><i class="fa fa-check"></i>  '.$verif2.' </button>  </form>';
					
					
				if($ee == 'inactive'){
					$verif = "<span style='color:red'>INACTIVE</style> ";
				}else{
				  	$verif = "<span style='color:green'>ONLINE</style> ";
				}
$lwith=1;				
		if($lwith == 1){
$lwithbtn = "<form action='' method='POST'><input type='hidden' name='lwith' value='$id'> <button class='btn btn-warning'> <i class='fa fa-banned'></i> Disallow Withdrawal </button>  </form> ";
		}else{
$lwithbtn = "<form action='' method='POST'><input type='hidden' name='lwith' value='$id'> <button class='btn btn-info'> <i class='fa fa-cash'></i> Allow Withdrawal </button>  </form> ";		    
		}		
				
				
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.$fname.'
                                        </td>
                                        <td >
                                          '.$lname.'
                                        </td>
                                        <td>
                                          <span class="c-primary"><b>'.$email.'</b></span>
                                        </td>
                                      
										<td >
                                          '.$password.'
                                        </td>
										<td >
                                          '.$country.'
                                        </td>
										<td >
                                          '.$phone.'
                                        </td>
										
										<td >
                                          '.$bal.'
                                        </td>	
											
									<!--	<td >
                                          '.$plan.'
                                        </td>  -->											
										<td >
                                          '.$lcked.'
                                        </td>
										<td >
                                          '.$verif.'
                                        </td>										
                                        <td >
                                          '.$kyc_text.'
                                        </td>
                                        
                                   <!--     <td>
                                        <div class="dropdown">
  <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Action
  <span class="caret"></span></button>
  <ul class="dropdown-menu">
    <li>'.$lbtn.'</li>
    <li>'.$dmbtn.'</li>
    <li>'.$dvbtn.'</li>
    <li>'.$lwithbtn.'</li>
  </ul>
</div>
                                        </td> -->
										
			                       <td>'.$lbtn.'</td>
			                        <td>'.$dmbtn.'</td>
			                        <td>'.$dvbtn.'</td>
			                        <td>'.$kyc_btn.'</td>
			                        <!--<td>'.$lwithbtn.'</td>  -->
                                      </tr>';
									  echo $tr;
				
			}
	
}

 //   $service_url = 'http://worldtimeapi.org/api/timezone/africa/lagos';
       $service_url = 'http://worldtimeapi.org/api/ip';
       $service_url = 'https://worldtimeapi.org/api/timezone/America/New_York';
       $curl = curl_init($service_url);
       curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
       curl_setopt($curl, CURLOPT_POST, false);
       curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
       $curl_response = curl_exec($curl);
       curl_close($curl);
       $json_objekat=json_decode($curl_response);
  
   $nowtime = $json_objekat->unixtime;




//clear bal and profit


if(isset($_POST['bal3'])){

	$id = $_POST['bal3'];
// 	$days = $_POST['days'];
$days = 1;
		if(!empty($id)){
		    
		    $qq= "select fname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $fname = mysqli_R($r,0);
		    
		    		    
		    $qq= "select lname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $lname = mysqli_R($r,0);
		    $bal=0;
		  //  $ddate = date('Y-m-d h:i:s',$nowtime);
			$query = "update   info  set bal = '$bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
								$_SESSION['success'] = "$fname $lname Balance Emptied to $bal";
						header('location:./');
						die();
				}
		}
}



if(isset($_POST['profit3'])){

	$id = $_POST['profit3'];
// 	$days = $_POST['days'];
$days = 1;
		if(!empty($id)){
		    
		    $qq= "select fname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $fname = mysqli_R($r,0);
		    
		    		    
		    $qq= "select lname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $lname = mysqli_R($r,0);
		    $bal=0;
		  //  $ddate = date('Y-m-d h:i:s',$nowtime);
			$query = "update   info  set profit = '$bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
								$_SESSION['success'] = "$fname $lname Profit Emptied to $bal";
						header('location:./');
						die();
				}
		}
}


//set bal profit and bonus

if(isset($_POST['act']) && isset($_POST['bal2'])){
	$id = $_POST['act'];
	$bal = $_POST['bal2'];
// 	$days = $_POST['days'];
$days = 1;
		if(!empty($id)){
		    
		    $qq= "select fname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $fname = mysqli_R($r,0);
		    
		    		    
		    $qq= "select lname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $lname = mysqli_R($r,0);
		    
		  //  $ddate = date('Y-m-d h:i:s',$nowtime);
			$query = "update   info  set bal = '$bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
								$_SESSION['success'] = "$fname $lname Balance Updated to $bal";
						header('location:./');
						die();
				}
		}
}


if(isset($_POST['act']) && isset($_POST['bal'])){
	$id = $_POST['act'];
	$bal = $_POST['bal'];
// 	$days = $_POST['days'];
$days = 1;
		if(!empty($id)){
		    
		    $qq= "select fname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $fname = mysqli_R($r,0);
		    
		    		    
		    $qq= "select lname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $lname = mysqli_R($r,0);
		    
		    
		    
		     $qq= "select bal from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $old_bal = mysqli_R($r,0);
		    $new_bal = $old_bal + $bal;
		    
		  //  $ddate = date('Y-m-d h:i:s',$nowtime);
			$query = "update   info  set bal = '$new_bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
								$_SESSION['success'] = "$fname $lname Balance Updated to $new_bal";
						header('location:./');
						die();
				}
		}
}



if(isset($_POST['act']) && isset($_POST['profit2'])){
	$id = $_POST['act'];
	$bal = $_POST['profit2'];
		if(!empty($id)){
		    		    
		    $qq= "select fname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $fname = mysqli_R($r,0);
		    
		    		    
		    $qq= "select lname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $lname = mysqli_R($r,0);
		    
			$query = "update   info  set profit = '$bal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
							$_SESSION['success'] = "$fname $lname Profit Updated to $bal";
						header('location:./');
						die();
				}
		}
}




if(isset($_POST['act']) && isset($_POST['profit'])){
	$id = $_POST['act'];
	$bal = $_POST['profit'];
		if(!empty($id)){
		    		    
		    $qq= "select fname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $fname = mysqli_R($r,0);
		    
		    		    
		    $qq= "select lname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $lname = mysqli_R($r,0);
		    
		    		    		    
		    $qq= "select profit from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $old_profit = mysqli_R($r,0);
		    $new_profit = $old_profit + $bal;
		    
			$query = "update   info  set profit = '$new_profit' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
							$_SESSION['success'] = "$fname $lname Profit Updated to $new_profit";
						header('location:./');
						die();
				}
		}
}



if(isset($_POST['act']) && isset($_POST['bonbal'])){
	$id = $_POST['act'];
	$bonbal = $_POST['bonbal'];
		if(!empty($id)){
		    		    
		    $qq= "select fname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $fname = mysqli_R($r,0);
		    
		    		    
		    $qq= "select lname from info where id='$id'";
		    $r = mysqli_query($con,$qq);
		    $lname = mysqli_R($r,0);
		    
			$query = "update   info  set bal2 = '$bonbal' where id = '$id' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.')";
						$_SESSION['success'] = "Bonus Updated";
						header('location:./');
						die();
				}
		}
}

if(isset($_POST['act']) && isset($_POST['plan'])){
	$id = $_POST['act'];
	$plan = $_POST['plan'];
		if(!empty($id)){
			$query = "update   info  set plan = '$plan' where id = '$id' ";
				if(mysqli_query($con,$query)){
					// 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "Plan changed ";
					header('location:./');
					die();
				}
		}
}




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'];
					// $password = $query_row['pass'];
					$bal = $query_row['bal'];
					$profit = $query_row['profit'];
					// $pack = $query_row['pack'];
					$ee = $query_row['ver'];
					// $regcode = $query_row['regcode'];
					// $eth = $query_row['eth'];
					// $btc = $query_row['btc'];
				if($ee == 0){
					$verif = "<span style='color:red'>Unverified</style> ";
				}else{
					$verif = "<span style='color:green'>Verified</style> ";
				}
				
				$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>'.$profit.'</b></span>
                                        </td>
                                      
										
										
										
										
										<td >
                                          '.$email.'
                                        </td>	
										
	<td><form method="POST"><input name="profit3" value="'.$id.'" type="hidden"><button class="btn btn-primary" type="submit">Clear Profit</button></form></td>									
	<td><form method="POST"><input name="bal3" value="'.$id.'"  type="hidden"><button class="btn btn-primary" type="submit">Clear Balance</button></form></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'];
					// $password = $query_row['pass'];
					$bon = $query_row['bonus'];
					// $pack = $query_row['pack'];
					$ee = $query_row['ver'];
					// $regcode = $query_row['regcode'];
					// $eth = $query_row['eth'];
					// $btc = $query_row['btc'];
				if($ee == 0){
					$verif = "<span style='color:red'>Unverified</style> ";
				}else{
					$verif = "<span style='color:green'>Verified</style> ";
				}
				
				$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 PLAN(){
	
	

	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'];
					$plan = $query_row['plan'];
					$bon = $query_row['bonus'];
					$bal = $query_row['bonus'];
					// $pack = $query_row['pack'];
					$ee = $query_row['ver'];
					// $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>'.$plan.'</b></span>
                                        </td>
                                      
										
										
										
										
										<td >
                                          '.$email.'
                                        </td>	
										
										
                                      </tr>';
									  echo $tr;
				
			}
	
}



    // include_once '../php/conn.php';
//     ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

  
function PLANS(){

	$i=0;
	
	global $con;
		$query = "select * from   plans  where 1 ORDER BY id ASC ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$name = $query_row['name'];
					$period = $query_row['period'];
					$rate = $query_row['rate'];
					$min = $query_row['min'];


			
				
				$tr = '     <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                     <td style="white-space:nowrap;" colspan="5">    <form method="post" class="d-flex"> 
                                          <input class="form-control" value="'.$id.'" type="hidden" name="plan_id" >
                                          
                                          <input class="form-control" value="'.$name.'" name="plan_name" >
                                      
                                         <input class="form-control" value="'.$period.'" name="plan_period" >
                                    
                                          <input class="form-control" value="'.$rate.'" name="plan_rate" >
                                       
                                         <input class="form-control" value="'.$min.'" name="plan_min" >
                                         
                                        <button class="btn btn-primary" TYPE="submit"> <i class="fa fa-save"></i> Save Changes </button>   </form> </td>

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








if(isset($_POST['v'])){
	$v = $_POST['v'];
		if(!empty($v)){
		   
		    	$qz="select status from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$status = mysqli_R($r,0);
		    
			$query = "update trans set status = 'success' where id = '$v' ";
			
				if(mysqli_query($con,$query)){
				// 		$maro = "alert('action Successful.')";
					// 	$maro = "alert('action Successful.')";
			$qz="select email from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$email = mysqli_R($r,0);
			
			$qz="select amount from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
		$amount = $amt = mysqli_R($r,0);	
			
		
			
			$qz="select bal from info where email = '$email' ";		
			$r = mysqli_query($con,$qz);
			$bal  = mysqli_R($r,0);
			
			
						
			$qz="select profit from info where email = '$email' ";		
			$r = mysqli_query($con,$qz);
			$profit  = mysqli_R($r,0);
			
			
			 if( $amount > $profit){
								        $new_profit = 0;
								        $current_bal  = $bal+$profit;
								        $newbal = $current_bal - $amount;
								        $newbal  = abs($newbal);
								        
								    }else{
								        $new_profit = abs($profit - $amount);
								        $newbal = $bal;
								        
								    }
				
				// $newbal = $bal - $amt;	
				
				
				
			if($status != 'success' && $status != 'pending'  ){	
				
				
$q="update info set bal = '$newbal' where email = '$email' ";
$r = mysqli_query($con,$q);
				
$q="update info set profit = '$new_profit' where email = '$email' ";
$r = mysqli_query($con,$q);

// $email = mysqli_R($r,0);

$tbal = $bal +$profit;
$tbal2 = $amt +$bal;
					$_SESSION['success'] = "Transaction Successful - Amount of $amt  has been removed from balance($tbal) of $email new balance is $newbal ";
					header('location:./');
					die();
			
			}elseif($status == 'pending' ){
		$tbal = $bal +$profit;
$tbal2 = $amt +$tbal;	    
			    $_SESSION['success'] = "Transaction Successful - Amount of $amt  has been removed from balance($tbal2) of $email new balance is $tbal ";
					header('location:./');
					die();
			}else{
				    	$_SESSION['error'] = " Transaction already confirmed";
					header('location:./');
					die();
				    
				}
			
			
				}
				
			
		}
}


if(isset($_POST['u'])){
	$v = $_POST['u'];
		if(!empty($v)){
		    
		    $qz="select status from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$status = mysqli_R($r,0);
		    
			$query = "update trans set status = 'canceled' where id = '$v' ";
				if(mysqli_query($con,$query)){
				// 	// 	$maro = "alert('action Successful.')";
				
			
			
			$qz="select email from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$email = mysqli_R($r,0);
			
			$qz="select amount from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$amt = mysqli_R($r,0);
			
			$qz="select bal from info where email = '$email' ";		
			$r = mysqli_query($con,$qz);
			$bal  = mysqli_R($r,0);
				
				$newbal = $bal + $amt;	;
				
		if($status == 'success'){	
				
$q="update info set bal = '$newbal' where email = '$email' ";
$r = mysqli_query($con,$q);
// $email = mysqli_R($r,0);

				
					$_SESSION['success'] = "Transaction Successful - Amount of $amt  has been added from balance($bal) of $email new balance is $newbal ";
					header('location:./');
					die();
					
				}else{
				    	$_SESSION['error'] = " Transaction already confirmed";
					header('location:./');
					die();
				    
				}
	
				
				
					$_SESSION['success'] = "Transaction Canceled";
					header('location:./');
					die();
				}
		}
}




if(isset($_POST['v22'])){
	$v = $_POST['v22'];
		if(!empty($v)){
		   
		    	$qz="select status from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$status = mysqli_R($r,0);
		    
			$query = "update trans set status = 'success' where id = '$v' ";
			
				if(mysqli_query($con,$query)){
				// 		$maro = "alert('action Successful.')";
					// 	$maro = "alert('action Successful.')";
			$qz="select email from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$email = mysqli_R($r,0);
			
			$qz="select amount from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$amt = mysqli_R($r,0);	
			
		
			
			$qz="select bal from info where email = '$email' ";		
			$r = mysqli_query($con,$qz);
			$bal  = mysqli_R($r,0);
			
			
				
				$newbal = $bal + $amt;	
				
			if($status != 'success'){	
				
$q="update info set bal = '$newbal' where email = '$email' ";
$r = mysqli_query($con,$q);
// $email = mysqli_R($r,0);

				
					$_SESSION['success'] = "Transaction Successful - Amount of $amt  has been added to balance($bal) of $email new balance is $newbal ";
					header('location:./');
					die();
					
				}else{
				    	$_SESSION['error'] = " Transaction already confirmed";
					header('location:./');
					die();
				    
				}
			
			
				}
				
			
		}
}


if(isset($_POST['u22'])){
	$v = $_POST['u22'];
		if(!empty($v)){
		    
		    $qz="select status from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$status = mysqli_R($r,0);
		    
			$query = "update trans set status = 'canceled' where id = '$v' ";
				if(mysqli_query($con,$query)){
				// 	// 	$maro = "alert('action Successful.')";
				
			
			
			$qz="select email from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$email = mysqli_R($r,0);
			
			$qz="select amount from trans where id = '$v' ";		
			$r = mysqli_query($con,$qz);
			$amt = mysqli_R($r,0);
			
			$qz="select bal from info where email = '$email' ";		
			$r = mysqli_query($con,$qz);
			$bal  = mysqli_R($r,0);
				
				$newbal = $bal - $amt;	;
				
		if($status == 'success'){	
				
$q="update info set bal = '$newbal' where email = '$email' ";
$r = mysqli_query($con,$q);
// $email = mysqli_R($r,0);

				
					$_SESSION['success'] = "Transaction Successful - Amount of $amt  has been removed from balance($bal) of $email new balance is $newbal ";
					header('location:./');
					die();
					
				}else{
				    	$_SESSION['error'] = " Transaction already confirmed";
					header('location:./');
					die();
				    
				}
	
				
				
					$_SESSION['success'] = "Transaction Canceled";
					header('location:./');
					die();
				}
		}
}



if(isset($_POST['trans_del'])){
	$id = $_POST['trans_del'];
		if(!empty($id)){
			$query = "Delete from trans where id='$id' ";
				if(mysqli_query($con,$query)){
				    // 	$maro = "alert('action Successful.')";
					$_SESSION['success'] = "Transaction Deleted";
					header('location:./');
					die();
				}
		}
}



















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'];
					$details = $query_row['details'];
					$method = $query_row['method'];
					$date = $query_row['created_at'];
	
	$qas = "select count(*) from info where email='$email' order by id";
	$rsa = mysqli_query($con,$qas);
	$press =  mysqli_R($rsa,0);
	if(!($press >= 1)){
	    continue;
	}					
			
	
			$qq = "select fname from info where email = '$email' ";
		$rr = mysqli_query($con,$qq);
		$fname = mysqli_R($rr,0);
	
							
		$qq = "select lname from info where email = '$email'";
		$rr = mysqli_query($con,$qq);
		$lname = mysqli_R($rr,0);
					
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                         <td >
                                          '.ucwords("$fname $lname").'
                                        </td>
                                        <td >
                                          '.$email.'
                                        </td>
										 <td>
                                          <span class="c-primary"><b>'.$amt.'</b></span>
                                        </td>		
                                        <td>
                                          <span class="c-primary"><b>('.$method. ' - '.$details.')</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>	
										
                                    
                                    	<td >
                                         <form method="post" action="#"> <input hidden name="trans_del" value='.$id.'> <button class="btn btn-danger" value="Decline" type="submit"><i class="fa fa-trash"></i></button> </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'];
					$proof = $query_row['proof'];
					$date = $query_row['created_at'];
	
	$qas = "select count(*) from info where email='$email' order by id";
	$rsa = mysqli_query($con,$qas);
	$press =  mysqli_R($rsa,0);
	if(!($press >= 1)){
	    continue;
	}
					
		$qq = "select fname from info where email = '$email' ";
		$rr = mysqli_query($con,$qq);
		$fname = mysqli_R($rr,0);
	
							
		$qq = "select lname from info where email = '$email'";
		$rr = mysqli_query($con,$qq);
		$lname = mysqli_R($rr,0);
		
		$proof = "<a target='_blank' href='/authorize/user/proof/$proof'>Deposit Proof</a>";
		
				$tr = '       <tr >
                                        <td>
                                         '.$i.'
                                        </td>
                                        <td >
                                          '.ucwords("$fname $lname").'
                                        </td>
                                        <td >
                                          '.$email.'
                                        </td>
                                        <td >
                                          '.$status.'
                                        </td>
                                        <td>
                                          <span class="c-primary"><b>'.$amt.'</b></span>
                                        </td>
                                      
									<!--	<td >
                                          '.$proof.'
                                        </td> -->
										                               
										<td >
                                          '.$date.'
                                        </td>
										
										<td >
                                        <form method="post" action="#"> <input hidden name="v22" value='.$id.'> <input class="btn btn-success" value="Confirm" type="submit"> </form>
                                        </td>
										
										<td >
                                         <form method="post" action="#"> <input hidden name="u22" value='.$id.'> <input class="btn btn-danger" value="Decline" type="submit"> </form>
                                        </td>	
                                    
                                    	<td >
                                         <form method="post" action="#"> <input hidden name="trans_del" value='.$id.'> <button class="btn btn-danger" value="Decline" type="submit"><i class="fa fa-trash"></i></button> </form>
                                        </td>										

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

















// settings



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



if(isset($_POST['ltc'])){
	$v = $_POST['ltc'];
		if(!empty($v)){
			$query = "update settings set ltc = '$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['doge'])){
	$v = $_POST['doge'];
		if(!empty($v)){
			$query = "update settings set doge = '$v' where id = '1' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful. ".$v."')";
				}
		}
}


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['wphone'])){
	$v = $_POST['wphone'];
		if(!empty($v)){
			$query = "update settings set blank = '$v' where id = '1' ";
				if(mysqli_query($con,$query)){
						$maro = "alert('action Successful.".$v."')";
				}
		}
}

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



if(isset($_POST['address'])){
	$v = $_POST['address'];
		if(!empty($v)){
			$query = "update settings set address = '$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 1 ";
		$result  = mysqli_query($con,$query);
			while($query_row = mysqli_fetch_assoc($result)){
				$i++;
					$id = $query_row['id'];
					$btc = $query_row['btc'];
					$wphone = $query_row['blank'];
					$phone = $query_row['phone'];
					$address = $query_row['address'];
					$eth = $query_row['eth'];
					$ltc = $query_row['ltc'];
					$bch = $query_row['bch'];
					$doge = $query_row['doge'];
												  
			}
			
			if($i != 0){
			if($q == 1){
				echo $btc;
			}
			if($q == 2){
				echo $wphone;
			}
			if($q == 3){
				echo $phone;
			}
			if($q == 4){
				echo $address;
			}
			if($q == 'doge'){
				echo $doge;
			}
			if($q == 'eth'){
				echo $eth;
			}
			if($q == 'ltc'){
				echo $ltc;
			}
			if($q == 'bch'){
				echo $bch;
			}
			
			
		}
}




if(isset($_POST['acct']) && isset($_POST['amount']) && isset($_POST['dateer']) && isset($_POST['status'])){
	$act = $_POST['acct'];
	$amt = $_POST['amount'];
	$dateer = $_POST['dateer'];
	$status = $_POST['status'];
	$meth = $_POST['methodd'];
		if(!empty($act) && !empty($amt) && !empty($dateer) && !empty($status) && !empty($meth)){
		  
		  $trans_id = 'TRX'.rand(100000,999999);
		  $description = "Deposit of $amt";
		  $mail = $act;
		  $amount = $amt;
		  $fee =0;
		  $method = $meth;
		  $type ='deposit';
		  $proof = 'admin.png';
		  //  $q = "insert into trans VALUES(NULL,'$dateer','$amt','deposit','$meth','$status','$act')";
		  if($status == 'successful'){
		      $status = 'success';
		  }
		  

		      $q1 ="select fname from info where email= '$mail'";
		      $r2 =  mysqli_query($con,$q1);
		      $fname = mysqli_R($r2,0);
		      $q1 ="select lname from info where email= '$mail'";
		      $r2 =  mysqli_query($con,$q1);
		      $lname = mysqli_R($r2,0);
		      
		    
        $q  = "insert into trans values(NULL,'$trans_id','$description','$mail','$amount','$fee','$status','$method','$type',NULL,NULL);";
  
		    
				if(mysqli_query($con,$q)){
				     if(strtolower($status) == 'success' || strtolower($status) == 'successful' ){
		      $q1 ="select bal from info where email= '$mail'";
		      $r2 =  mysqli_query($con,$q1);
		      $old_bal = mysqli_R($r2,0);
		      
		      $new_bal = $old_bal + $amt; 
		      $qz = "update info set bal = '$new_bal' where email = '$mail' ";
		      mysqli_query($con,$qz);
		      	$_SESSION['success'] =  "Deposit Created for $fname $lname with status $status and  balacne update from $old_bal to $new_bal";
		  }else{
		      	$_SESSION['success'] =  "Deposit Created for $fname $lname with status $status";
		  }
						
				}
		}
}


?>