0) { // skip any view saving // disable this update? $res = mysql_db_query($GLOBALS['DataBase']," UPDATE clickdb SET count=count+1 WHERE bid='$pid' AND ip='$rawip' AND hid='$hid' "); // print "double!"; } else { // have fun here :) $res = mysql_db_query($GLOBALS['DataBase']," REPLACE INTO clickdb (bid,ip,hid,ref,ct,dt,count,dns) VALUES ('$pid','$rawip','$hid','$refer', '$country',NOW(),'1','$dns') "); // get host price from offer (for one click - it will be the same for all hosts) $res = mysql_db_query($GLOBALS['DataBase'],"SELECT hprice FROM offers WHERE pid = '$pid' AND status='active'"); if (!(list($hprice)=mysql_fetch_array($res))) promo_banner(); // all ok - update offers $res = mysql_db_query($GLOBALS['DataBase'],"UPDATE offers SET tc=tc+1,mc=mc+1,dayc=dayc+1,monthspent=monthspent+price WHERE pid='$pid'"); // update banner $res = mysql_db_query($GLOBALS['DataBase'],"UPDATE banners SET tc=tc+1,mc=mc+1,dayc=dayc+1 WHERE pid='$pid' AND bid='$bid'"); // try to update host stats in applydb - it has to exist!!! $res = mysql_db_query($GLOBALS['DataBase'],"UPDATE applydb SET tc=tc+1,mc=mc+1,dayc=dayc+1,monthrevenue=monthrevenue+price WHERE hid='$hid' AND pid='$pid'"); // update refdb for referrals if (!empty($refhost)) { $res = mysql_db_query($GLOBALS['DataBase'],"UPDATE refdb SET amount=amount+'$hprice' WHERE refer='$refhost' AND referred='$h'"); }; }; // if unique setcookie("PRAD${n}${bid}${pid}",'no',$Cdata,$Cpath); $url=parse_macro($url); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 header("Location: $url"); exit(); }; // CPC end }; // if !empty(program) CPC/CPM programs ended // CPL/CPS offers: we get pid & bid for URL $res = mysql_db_query($GLOBALS['DataBase']," SELECT bid,advid,pid,url,image,ptype FROM banners WHERE status='active' AND bid='$bid' AND pid='$pid' "); if (!(list($bid,$advid,$pid,$url,$image,$ptype1)=mysql_fetch_array($res))) promo_banner(); // fix active offer status $res = mysql_db_query($GLOBALS['DataBase']," SELECT pid FROM offers WHERE pid='$pid' AND status='active' "); if(mysql_num_rows($res) <= 0) { promo_banner(); }; // get host details for selected offer $res = mysql_db_query($GLOBALS['DataBase']," SELECT price,ptype FROM applydb WHERE hid='$hid' AND pid='$pid' AND status='active' "); if(mysql_num_rows($res) > 0) { list($price,$ptype) = mysql_fetch_array($res); } else { promo_banner(); }; // check for unique click in database ( 1 unique IP for offer ) if ($ptype=='lead' || $ptype=='res1') { $res = mysql_db_query($GLOBALS['DataBase']," SELECT bid,ip,hid FROM leaddb WHERE bid = '$pid' AND ip = '$rawip' AND hid='$hid' "); } else if ($ptype=='sale') { $res = mysql_db_query($GLOBALS['DataBase']," SELECT bid,ip,hid FROM salesdb WHERE bid = '$pid' AND ip = '$rawip' AND hid='$hid' "); }; if(mysql_num_rows($res) > 0) { if ($ptype=='lead' || $ptype=='res1') { $res = mysql_db_query($GLOBALS['DataBase']," UPDATE leaddb SET count=count+1 WHERE bid='$pid' AND ip='$rawip' AND hid='$hid' "); } else if ($ptype=='sale') { $res = mysql_db_query($GLOBALS['DataBase']," UPDATE salesdb SET count=count+1 WHERE bid='$pid' AND ip='$rawip' AND hid='$hid' "); }; } else { // have fun here :) if ($ptype=='lead' || $ptype=='res1') { $res = mysql_db_query($GLOBALS['DataBase']," REPLACE INTO leaddb (bid,advid,hid,ip,status,ctime,ltime,ref,ct,count,dns,ldata) VALUES ('$pid','$advid','$hid','$rawip','click',NOW(),NULL,'$refer','$country','1','$dns',' ') "); } else if ($ptype=='sale') { $res = mysql_db_query($GLOBALS['DataBase']," REPLACE INTO salesdb (bid,advid,hid,ip,status,ctime,ltime,ref,ct,count,dns,ldata,amount) VALUES ('$pid','$advid','$hid','$rawip','click',NOW(),NULL,'$refer','$country','1','$dns',' ',0) "); } else { echo "Unknown offer type!"; exit(); }; // update offer $res = mysql_db_query($GLOBALS['DataBase'],"UPDATE offers SET tc=tc+1,mc=mc+1,dayc=dayc+1 WHERE pid='$pid'"); // update banner $res = mysql_db_query($GLOBALS['DataBase'],"UPDATE banners SET tc=tc+1,mc=mc+1,dayc=dayc+1 WHERE pid='$pid' AND bid='$bid'"); // update host stats in applydb $res = mysql_db_query($GLOBALS['DataBase'],"UPDATE applydb SET tc=tc+1,mc=mc+1,dayc=dayc+1 WHERE hid='$hid' AND pid='$pid'"); }; // if unique entry setcookie("rIP$n",$HTTP_X_FORWARDED_FOR,$Cdata,$Cpath); setcookie("CGoP${pid}H",$h,$Cdata,$Cpath); setcookie("CGoP${pid}Ban",$bid,$Cdata,$Cpath); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 $url=parse_macro($url); header("Location: $url"); exit(); ?>