View file public_html/ads/jsads.php

File size: 3.46Kb
<?php

include '../db.php';
include '../functions.php';
include '../wap/country.php';
include '../show/md.php'; 

$user_agent=$_SERVER["HTTP_USER_AGENT"];
$detect = new Mobile_Detect($user_agent);

$sid=formget("sid");

if ($detect->isIphone()) {
$device=='IPHONE';
}
	
else if ($detect->isIpad()) {
$device='IPAD';
}

else if ($detect->isIpod()) {
$device='IPOD';
}

else if($detect->isAndroidOS()){ 
$device='ANDROID';
}

else if($detect->ismobile()){
$device='OTHER';
}

else {
$device='web';
}


$errors=array();

$chSite=mysql_query("SELECT status FROM cpmsites WHERE id='$sid'");
$chSblock=mysql_fetch_array(mysql_query("SELECT status,adult,url FROM cpmsites WHERE id='$sid'"));

$fetchurl=mysql_fetch_array(mysql_query("SELECT url FROM cpmsites WHERE id='$sid'"));
$url=$fetchurl[0];
$getbysiteurl=$url;
$getjsurl=$_SERVER["HTTP_HOST"];
$getbytempsiteurl=str_replace('http://','',$getbysiteurl);

if(empty($sid)){
 $errors[]='<font color="red"><b>Site Not Exists</b></font>';
}
if(mysql_num_rows($chSite)<1){
 $errors[]='<font color="red"><b>Site Not Exists</b></font>';
}
if($chSblock["status"]=="Pending"){
 $errors[]='<font color="red"><b>Your Site Is Pending at EarnBuzz.In</b></font>';
}
if($chSblock["status"]=="Rejected"){
 $errors[]='<font color="red"><b>Your Site Has Rejected at EarnBuzz.In</b></font>';
}

if(stripos($getjsurl,$getbytempsiteurl) == false)  {
$errors[]=$getbysiteurl;
}
if(empty($errors)){
$userid=mysql_fetch_array(mysql_query("SELECT userid FROM cpmsites WHERE id='$sid'"));
$uid=$userid[0];

  $getAds=mysql_query("SELECT id,height,width,url,network,status FROM cpmads WHERE status='Running' AND (country LIKE '$country_name' OR country='ALL') AND (device LIKE '$device' OR device='ALL') ORDER BY rand() LIMIT 0,1");

  $ip=$_SERVER["REMOTE_ADDR"];
  $ua=$_SERVER["HTTP_USER_AGENT"];
  $ref=$_SERVER["HTTP_REFERER"];

  while($Ads=mysql_fetch_array($getAds)){
   $AdsId=$Ads["id"];
   $network=$Ads["network"];

      $_SESSION["cpmsid"]=$sid;
      $_SESSION["cpmuid"]=$uid;
      $_SESSION["cpmip"]=$ip;
      $_SESSION["cpmua"]=$ua;
      $_SESSION["cpmref"]=$ref;
      $_SESSION["cpmaid"]=$AdsId;
      $_SESSION["cpmadurl"]=$adurl;
      
      $rand=md5(microtime()*5);
      $_SESSION["hash"]=$rand;

include 'modules/'.$network.'/request.php';
      $pr='<a href="http://ads.earnbuzz.in/click.php?ses?'.$rand.'"><img src="'.$adimage.'" height="'.$Ads["height"].'" width="'.$Ads["width"].'" alt="Click Here.."/></br>Click Here.!</a><br/>';
   }
   echo 'document.write(\''.$pr.'\');';
$date=date("Y-m-d");
$month=date("m-d");
$chkimps=mysql_query("SELECT id FROM cpmimps WHERE date='$date' AND ip='$ip'");
if(mysql_num_rows($chkimps) > 0) {

}
else
{

mysql_query("INSERT INTO cpmimps(userid,adid,ua,ip,os,date,month,country,earned) VALUES('$uid','$AdsId','$ua','$ip','$device','$date','$month','$country_name','$ecpm')");
$chkimpsupdate=mysql_query("SELECT id,earned,clicks,imp FROM cpmstats WHERE date='$date' AND userid='$uid'");

if(mysql_num_rows($chkimpsupdate) > 0) {
$fetchzz=mysql_fetch_array($chkimpsupdate);
$earned=$fetchzz[1];
$earned=$earned+$ecpm;
$imps=$fetchzz[3];
$imps=($imps+1);

mysql_query("UPDATE cpmstats SET imp='$imps',earned='$earned' WHERE date='$date' AND userid='$uid'");
}
else
{
mysql_query("INSERT INTO cpmstats(date,month,userid,clicks,imp,earned,updated) VALUES('$date','$month','$uid','0','1','','No')");
}

}
}
else {

foreach($errors as $error){
echo 'document.write(\''.$error.'\');';
}
}

mysql_close($dbcon);
header('Content-type: application/js');

?>