<?php 

$qryApi = mysqli_query($conn,"SELECT * FROM api_setting");
$apidata = mysqli_fetch_array($qryApi);

$apikey = $apidata['APIkey']; 
$url = $apidata['baseurl'];
$accesscode = $apidata['accesscode'];
$web = $_SERVER['SERVER_NAME'];

$host = "https://$url/api/access/?apikey=$apikey";



//Initialize cURL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$vdata = curl_exec($ch);
$result = json_decode($vdata,true);

//Close the cURL handle.
curl_close($ch);



//GOTV
		
$smallieA = $result['gotv_smallie'];
$smallieB = $result['gotv_smallie_3months'];
$smallieC = $result['gotv_smallie_1year'];
$jinja = $result['gotv_jinja'];
$jolli = $result['gotv_jolli'];
$max = $result['gotv_max'];



//DSTV			
		
$padi = $result['dstv_padi'];
$yanga = $result['dstv_yanga'];
$confam = $result['dstv_confam'];
$compact = $result['dstv_compact'];
$compactplus = $result['dstv_compact_plus'];
$premium = $result['dstv_premium'];
$asia = $result['dstv_asia'];
$premiumfrench = $result['dstv_premium_french'];



//startimes	
					
$novaA = $result['startimes_nova_daily'];
$novaB = $result['startimes_nova_weekly'];
$nova = $result['startimes_nova'];
$basicA = $result['startimes_basic_daily'];
$basicB = $result['startimes_basic_weekly'];
$basic = $result['startimes_basic'];
$smartA = $result['startimes_smart_daily'];
$smartB = $result['startimes_smart_weekly'];
$smart = $result['startimes_smart'];
$classicA = $result['startimes_classic_daily'];
$classicB = $result['startimes_classic_weekly'];
$classic = $result['startimes_classic'];
$superA = $result['startimes_super_daily'];
$superB = $result['startimes_super_weekly'];
$super = $result['startimes_super'];
$uniqueA = $result['startimes_unique_daily'];
$uniqueB = $result['startimes_unique_weekly'];
$unique = $result['startimes_unique'];


$sql_store = mysqli_query($conn,
	
	"UPDATE dstv SET
	padi='$padi',
	yanga='$yanga',
	confam='$confam',
        compact='$compact',
	compact_plus='$compactplus',
	premium='$premium',
        asia='$asia',
	premium_french='$premiumfrench'
");



$sql_store = mysqli_query($conn,
	
	"UPDATE gotv SET
	smallieA='$smallieA',
	smallieB='$smallieB',
	smallieC='$smallieC',
	jinja='$jinja',
	jolli='$jolli',
	max='$max' 
");



$sql_store = mysqli_query($conn,
	
	"UPDATE startimes SET
	novaA='$novaA',
	novaB='$novaB',
	nova='$nova',
    basicA='$basicA',
	basicB='$basicB',
	basic='$basic',
    smartA='$smartA',
	smartB='$smartB',
	smart='$smart',
    classicA='$classicA',
	classicB='$classicB',
	classic='$classic',
    uniqueA='$uniqueA',
	uniqueB='$uniqueB',
	uniqueC='$unique',
    superA='$superA',
	superB='$superB',
	super='$super'
");


$ins = mysqli_query($conn,"SELECT * FROM users WHERE email='$user' ");
$data = mysqli_fetch_array($ins);

$level = $data['level'];

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


$query_rec1 = mysqli_query($conn,"SELECT * FROM dstv");
			
			$smeA2 = mysqli_fetch_array($query_rec1);


$query_rec2 = mysqli_query($conn,"SELECT * FROM startimes");
			
			$smeR = mysqli_fetch_array($query_rec2);








		
//GOTV
		
$smallieA = $sme['smallieA'];
$smallieB = $sme['smallieB'];
$smallieC = $sme['smallieC'];
$jinja = $sme['jinja'];
$jolli = $sme['jolli'];
$max = $sme['max'];



//DSTV			
		
$padi = $smeA2['padi'];
$yanga = $smeA2['yanga'];
$confam = $smeA2['confam'];
$compact = $smeA2['compact'];
$compactplus = $smeA2['compact_plus'];
$premium = $smeA2['premium'];
$asia = $smeA2['asia'];
$premiumfrench = $smeA2['premium_french'];



//startimes	
					
$novaA = $smeR['novaA'];
$novaB = $smeR['novaB'];
$nova = $smeR['nova'];
$basicA = $smeR['basicA'];
$basicB = $smeR['basicB'];
$basic = $smeR['basic'];
$smartA = $smeR['smartA'];
$smartB = $smeR['smartB'];
$smart = $smeR['smart'];
$classicA = $smeR['classicA'];
$classicB = $smeR['classicB'];
$classic = $smeR['classic'];
$uniqueA = $smeR['uniqueA'];
$uniqueB = $smeR['uniqueB'];
$unique = $smeR['uniqueC'];
$superA = $smeR['superA'];
$superB = $smeR['superB'];
$super = $smeR['super'];
 

		
	
?>