<?php
/************************************
Script : Adnetwork
Website : http://facebook.com/mohd.arshadsaifi79
Script is created and provided by Arshad (http://facebook.com/mohd.arshadsaifi79)
**************************************/
include '../db.php';
include '../functions.php';
headtag("$SiteName - UCWEB Monthly Installation Report");
if($adminlog==1){
$user=formget("user");
$getu = mysql_query("SELECT * FROM userdata WHERE username='$user'");
$getu1 = mysql_fetch_array($getu);
$ucbalance = $getu1['ucbalance'];
$d=date("d");
$mn=date("F,Y");
$monthly=date("F");
$yesterday=date("d-m-Y", time()-86400);
$lastpay=dump_udata("lastucpay");
$lastbal=dump_udata("uclast");
echo '<div class="title">UCWEB Installation Report</div>';
error_reporting(E_ERROR | E_PARSE);
$url="http://data.union.ucweb.com/ExStatIntService?acc=arshadwap&key=142370960584148b8bcc16c12b0b7c5c&sdate=2015-11-01&edate=2015-11-30&metrics=bimei&dimensions=date,pub,pid,country&platform=android";
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
// Will dump a beauty json :3
$array=json_decode($result,true);
$url1="http://data.union.ucweb.com/ExStatIntService?acc=arshadwap&key=bfc34f76025c58d140ce9bf7cf492ab7&sdate=2015-11-01&edate=2015-11-30&metrics=bimei&dimensions=date,pub&platform=others";
// Initiate curl
$ch1 = curl_init();
// Disable SSL verification
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch1, CURLOPT_URL,$url1);
// Execute
$result1=curl_exec($ch1);
// Closing
curl_close($ch1);
// Will dump a beauty json :3
$array1=json_decode($result1,true);
$url2="http://data.union.ucweb.com/ExStatIntService?acc=arshadwap&key=9898824f9bc5b4bcb1ac8dd5cedf3c70&sdate=2015-11-01&edate=2015-11-30&metrics=bimei&dimensions=date,pub,pid&platform=android";
// Initiate curl
$ch2 = curl_init();
// Disable SSL verification
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch2, CURLOPT_URL,$url2);
// Execute
$result2=curl_exec($ch2);
// Closing
curl_close($ch2);
// Will dump a beauty json :3
$array2=json_decode($result2,true);
try
{
$pub = $getu1['pub'];
$y ='2015';
$m ='11';
$yesterdaya=date("Y-m-d", time()-86400);
$pu='moh@EarnBuzz11';
$chck=$array["data"][$yesterdaya][$pu][4][IN][0]["bimei"];
if(empty($chck))
{
$mrarshad=2;
}
else
{
$mrarshad=1;
}
$d =date("d")-$mrarshad;
if($d <=0)
{
$d=31;
$m--;
if($m <10)
{
$m="0".$m;
}
}
$aapps=0;
$ucbal=0;
for($i=1;$i<=$d;$i++)
{
if($i<10)
{
$i="0".$i;
}
$date= $y."-".$m."-".$i;
$apps=$array["data"][$date][$pub][4][IN][0]["bimei"];
$java=$array1["data"][$date][$pub][0]["bimei"];
$apus=$array2["data"][$date][$pub][2019031][0]["bimei"];
$hotvideo=$array2["data"][$date][$pub][2013016][0]["bimei"];
$in=$array["data"][$date][$pub][2000022][IN][0]["bimei"];
$id=$array["data"][$date][$pub][2000022][ID][0]["bimei"];
$bd=$array["data"][$date][$pub][2000022][BD][0]["bimei"];
$my=$array["data"][$date][$pub][2000022][MY][0]["bimei"];
$vn=$array["data"][$date][$pub][2000022][VN][0]["bimei"];
$br=$array["data"][$date][$pub][2000022][BR][0]["bimei"];
$ru=$array["data"][$date][$pub][2000022][RU][0]["bimei"];
$pk=$array["data"][$date][$pub][2000022][PK][0]["bimei"];
$ph=$array["data"][$date][$pub][2000022][PH][0]["bimei"];
$za=$array["data"][$date][$pub][2000022][ZA][0]["bimei"];
$np=$array["data"][$date][$pub][2000022][NP][0]["bimei"];
$sa=$array["data"][$date][$pub][2000022][SA][0]["bimei"];
$qa=$array["data"][$date][$pub][2000022][QA][0]["bimei"];
$sg=$array["data"][$date][$pub][2000022][SG][0]["bimei"];
$uz=$array["data"][$date][$pub][2000022][UZ][0]["bimei"];
$ng=$array["data"][$date][$pub][2000022][NG][0]["bimei"];
$ne=$array["data"][$date][$pub][2000022][NE][0]["bimei"];
$ye=$array["data"][$date][$pub][2000022][YE][0]["bimei"];
$other=$pk+$ph+$za+$np+$sa+$qa+$sg+$uz+$ng+$ne+$ye;
if(strlen($apps) == 0)
{
$apps="0";
}
if(strlen($java) == 0)
{
$java="0";
}
if(strlen($in) == 0)
{
$in="0";
}
if(strlen($id) == 0)
{
$id="0";
}
if(strlen($bd) == 0)
{
$bd="0";
}
if(strlen($my) == 0)
{
$my="0";
}
if(strlen($vn) == 0)
{
$vn="0";
}
if(strlen($br) == 0)
{
$br="0";
}
if(strlen($ru) == 0)
{
$ru="0";
}
if(strlen($other) == 0)
{
$other="0";
}
if(strlen($apus) == 0)
{
$apus="0";
}
if(strlen($hotvideo) == 0)
{
$hotvideo="0";
}
$aapps=$apps*$appsprice;
$ajava=$java*$javaprice;
$ain=$in*$indiaprice;
$aid=$id*$indoprice;
$abd=$bd*$bdprice;
$amy=$my*$myprice;
$avn=$vn*$vnprice;
$abr=$br*$brprice;
$aru=$ru*$ruprice;
$aother=$other*$otherprice;;
$aapus=$apus*$apusprice;
$ahotvideo=$hotvideo*$hotvideoprice;;
$money=$aapps+$ajava+$ain+$aid+$abd+$amy+$avn+$abr+$aru+$aother+$aapus+$ahotvideo;
$sumapps+=$apps;
$sumjava+=$java;
$sumin+=$in;
$sumid+=$id;
$sumbd+=$bd;
$summy+=$my;
$sumvn+=$vn;
$sumbr+=$br;
$sumru+=$ru;
$sumother+=$other;
$sumapus+=$apus;
$sumhotvideo+=$hotvideo;
$tapps=$sumapps*$appsprice;
$tjava=$sumjava*$javaprice;
$tin=$sumin*$indiaprice;
$tid=$sumid*$indoprice;
$tbd=$sumbd*$bdprice;
$tmy=$summy*$myprice;
$tvn=$sumvn*$vnprice;
$tbr=$sumbr*$brprice;
$tru=$sumru*$ruprice;
$tother=$sumother*$otherprice;
$tapus=$sumapus*$apusprice;
$thotvideo=$sumhotvideo*$hotvideoprice;
$totalmoney=$tapps+$tjava+$tin+$tid+$tbd+$tmy+$tvn+$tbr+$tru+$tother+$tapus+$thotvideo;
$querydata=mysql_query("select * from ucreport where date='$date' AND user='$user'");
if(mysql_num_rows($querydata)==0)
{
$year='2015';
if($apps==0)
{
$appst=0;
}
else if($apps > 0 && $apps <=10)
{
$appst=($apps-0);
}
else if($apps > 10 && $apps <= 30)
{
$appst=($apps-3);
}
else if($apps>30 && $apps <= 50)
{
$appst=($apps-8);
}
else if($apps>50 && $apps <= 70)
{
$appst=($apps-14);
}
else if($apps>70 && $apps <=100)
{
$appst=($apps-18);
}
else if($apps>100 && $apps <= 200)
{
$appst=($apps-30);
}
else if($apps>200 && $apps <= 300)
{
$appst=($apps-60);
}
else if($apps>300 && $apps <= 400)
{
$appst=($apps-90);
}
else if($apps>400 && $apps <= 500)
{
$appst=($apps-120);
}
else if($apps>500)
{
$appst=($apps-150);
}
if($in==0)
{
$int=0;
}
else if($in > 0 && $in <=10)
{
$int=($in-0);
}
else if($in>10 && $in <= 30)
{
$int=($in-3);
}
else if($in>30 && $in <= 50)
{
$int=($in-8);
}
else if($in>50 && $in <= 70)
{
$int=($in-14);
}
else if($in>70 && $in <=100)
{
$int=($in-18);
}
else if($in>100 && $in <= 200)
{
$int=($in-30);
}
else if($in>200 && $in <= 300)
{
$int=($in-60);
}
else if($in>300 && $in <= 400)
{
$int=($in-90);
}
else if($in>400 && $in <= 500)
{
$int=($in-120);
}
else if($in>500)
{
$int=($in-150);
}
if($id==0)
{
$idt=0;
}
else if($id > 0 && $id <=10)
{
$idt=($id-0);
}
else if($id>10 && $id <= 30)
{
$idt=($id-3);
}
else if($id>30 && $id <= 50)
{
$idt=($id-8);
}
else if($id>50 && $id <= 70)
{
$idt=($id-14);
}
else if($id>70 && $id <=100)
{
$idt=($id-18);
}
else if($id>100 && $id <= 200)
{
$idt=($id-30);
}
else if($id>200 && $id <= 300)
{
$idt=($id-60);
}
else if($id>300 && $id <= 400)
{
$idt=($id-90);
}
else if($id>400 && $id <= 500)
{
$idt=($id-120);
}
else if($id>500)
{
$idt=($id-150);
}
if($bd==0)
{
$bdt=0;
}
else if($bd > 0 && $bd <=10)
{
$bdt=($bd-0);
}
else if($bd>10 && $bd <= 30)
{
$bdt=($bd-3);
}
else if($bd>30 && $bd <= 50)
{
$bdt=($bd-8);
}
else if($bd>50 && $bd <= 70)
{
$bdt=($bd-14);
}
else if($bd>70 && $bd <=100)
{
$bdt=($bd-18);
}
else if($bd>100 && $bd <= 200)
{
$bdt=($bd-30);
}
else if($bd>200 && $bd <= 300)
{
$bdt=($bd-60);
}
else if($bd>300 && $bd <= 400)
{
$bdt=($bd-90);
}
else if($bd>400 && $bd <= 500)
{
$bdt=($bd-120);
}
else if($bd>500)
{
$bdt=($bd-150);
}
if($apus==0)
{
$apust=0;
}
else if($apus > 0 && $apus <=10)
{
$apust=($apus-0);
}
else if($apus>10 && $apus <= 30)
{
$apust=($apus-3);
}
else if($apus>30 && $apus <= 50)
{
$apust=($apus-8);
}
else if($apus>50 && $apus <= 70)
{
$apust=($apus-14);
}
else if($apus>70 && $apus <=100)
{
$apust=($apus-18);
}
else if($apus>100 && $apus <= 200)
{
$apust=($apus-30);
}
else if($apus>200 && $apus <= 300)
{
$apust=($apus-60);
}
else if($apus>300 && $apus <= 400)
{
$apust=($apus-90);
}
else if($apus>400 && $apus <= 500)
{
$apust=($apus-120);
}
else if($apus>500)
{
$apust=($apus-150);
}
if($hotvideo==0)
{
$hotvideot=0;
}
else if($hotvideo > 0 && $hotvideo <=10)
{
$hotvideot=($hotvideo-0);
}
else if($hotvideo>10 && $hotvideo <= 30)
{
$hotvideot=($hotvideo-3);
}
else if($hotvideo>30 && $hotvideo <= 50)
{
$hotvideot=($hotvideo-8);
}
else if($hotvideo>50 && $hotvideo <= 70)
{
$hotvideot=($hotvideo-14);
}
else if($hotvideo>70 && $hotvideo <=100)
{
$hotvideot=($hotvideo-18);
}
else if($hotvideo>100 && $hotvideo <= 200)
{
$hotvideot=($hotvideo-30);
}
else if($hotvideo>200 && $hotvideo <= 300)
{
$hotvideot=($hotvideo-60);
}
else if($hotvideo>300 && $hotvideo <= 400)
{
$hotvideot=($hotvideo-90);
}
else if($hotvideo>400 && $hotvideo <= 500)
{
$hotvideot=($hotvideo-120);
}
else if($hotvideo>500)
{
$hotvideot=($hotvideo-150);
}
$doit=mysql_query("INSERT INTO ucreport (user, month, date, apps, java, india, indo, bd, my, vn, br, ru, other, apus, hotvideo)
VALUES ('$user', 'November,2015', '$date', '$appst', '$java', '$int', '$idt', '$bdt', '$my', '$vn', '$br', '$ru', '$other', '$apust', '$hotvideot')");
$tappsbal=$appst*$appsprice;
$tjavabal=$java*$javaprice;
$tinbal=$int*$indiaprice;
$tidbal=$idt*$indoprice;
$tbdbal=$bdt*$bdprice;
$tmybal=$my*$myprice;
$tvnbal=$vn*$vnprice;
$tbrbal=$br*$brprice;
$trubal=$ru*$ruprice;
$totherbal=$other*$otherprice;
$tapusbal=$apust*$apusprice;
$thotvideobal=$hotvideot*$hotvideoprice;
$money1=$tappsbal+$tjavabal+$tinbal+$tidbal+$tbdbal+$tmybal+$tvnbal+$tbrbal+$trubal+$totherbal+$tapusbal+$thotvideobal;
$ucbal+=$money1;
}
}
$ucbal+=$ucbalance;
$doit1=mysql_query("UPDATE userdata SET ucbalance='$ucbal' WHERE username='$user'");
header('Location:appreport.php?user='.$user.'');
echo '<div class="page"><a href="index.php">Home</a></div>';
include '../foot.php';
}
catch(Exception $e)
{
echo $e->getMessage();
}
}
else {
header('Location:/login.php');
}
?>