<?php 

								
$user = $_SESSION['user'];
$refverified = $_SESSION["log"];
								
$ins = mysqli_query($conn,"SELECT * FROM users WHERE email='$user' ");
$data = mysqli_fetch_array($ins);
$fname = $data['firstname'];
$lname = $data['lastname'];								
$email = $data['email'];
$rowpas = $data['pass'];
$level = $data['level'];
$bal = $data['bal'];
$refbal = $data['refwallet'];
$refwallet = $data['refwallet'];
$rebid = $data['refbyid'];
$rebyid = $data['refbyid'];
$refid = $data['refid'];
$emailverify = $data['emailverify'];
$status = $data['status'];
$blockstat = $data['blockstat'];
$accno = $data['accno'];
$refcode = $data['refverified'];
$website = $data['website'];
$customer = "$fname $lname";
$commi = 2;

 



$currency = "₦";
$cur = "₦";

$uri = $_SERVER['REQUEST_URI'];
$hosturl = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
$request_dir = $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
$reflink = "https://$hosturl/register.php?refid=$refid";


if($refcode !== $refverified){
$_SESSION["loggedin"] = false;
//header("location: index.php");
//exit;
}



$query_rec = mysqli_query($conn,"SELECT * FROM settings");
$settings = mysqli_fetch_array($query_rec);


 $sitname = $settings['sitename'];
  $sitename = $settings['sitename'];
 $siturl = $_SERVER['SERVER_NAME'];
 $adminTel = $settings['mobile'];
 $sitlogo = $settings['sitelogo'];
$sender = $sitname;	


$cal = mysqli_query($conn,"SELECT * FROM earnings WHERE email='$user' LIMIT 3 ");
$clog = mysqli_fetch_array($cal);
					
$qrypat = "SELECT * FROM payalert WHERE email='$user' LIMIT 5 ";
$paynoti = $conn->query($qrypat);		
			

$fcal = "SELECT * FROM earnlog WHERE refby='$user' ORDER BY `date` DESC LIMIT 5  ";
$enlog = $conn->query($fcal);					
					
	
							
$bnk = mysqli_query($conn,"SELECT * FROM bankinfo");
$payinfo = mysqli_fetch_array($bnk);


											

$sql = "SELECT * FROM deposit WHERE email='$user' ORDER BY `serial` DESC LIMIT 3";									
$resu = $conn->query($sql);


$service = "SELECT * FROM services WHERE status='Active' ORDER BY RAND() ";
$getfil = $conn->query($service);
	
$apikey = substr(str_shuffle("0123456789ABCDEFGHIJklmnopqrstvwxyzAbAcAdAeAfAgAhBaBbBcBdC1C23C3C4C5C6C7C8C9xix2x3"), 0, 30);



$qryApi = mysqli_query($conn,"SELECT * FROM payment");
$apidata = mysqli_fetch_array($qryApi);
$feebearer = $apidata['feeBearer'];
			
$query_bank = mysqli_query($conn,"SELECT * FROM add_bank");			
$bank = mysqli_fetch_array($query_bank);

$query_rec = mysqli_query($conn,"SELECT * FROM billing");
$bill = mysqli_fetch_array($query_rec);

$query_regular = mysqli_query($conn,"SELECT * FROM regular_billing");
$regbil = mysqli_fetch_array($query_regular);
$Regubil = mysqli_fetch_array($query_regular);

$query_com = mysqli_query($conn,"SELECT * FROM commission");
$afi = mysqli_fetch_array($query_com);

$Rco = ($bill['affiliate']/100)*$bill['reseller'];
//$Aco = ($bill['affiliate']/100)*$bil['agent']; //($agentbil['affiliate']/100)*$agentbil['agent'];

$qrefer = mysqli_query($conn,"SELECT * FROM users WHERE refid='$rebyid' ");
$datref = mysqli_fetch_array($qrefer);
$affto = $datref['email'];
$refbyF = $datref['firstname'];
$refbyL = $datref['lastname'];
$refby = "$refbyF $refbyL";


if($data['level'] === 'paid'){
$accType = 'Reseller'; 
}else{
$accType = 'Normal';
}


if($data['acctype'] === 'API'){
$apiType = 'API User';
}else{
$apiType = 'Normal User'; 
}

$noo=3;	
$nooo=0; 
?>