0) { $ad_id = getAdID($ad_dir, $db); if($ad_id==0) { header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); echo ' 404 - Page Not Found. Sorry, this page was not found. In a few seconds, you will be redirected to the Home page.
Please visit our home page.
'; exit; } $select = "select ad_vehicle_name, track_url , sales_choice, user_id from aa_ads where status = 1 and ad_id = '$ad_id'"; $result = mysql_query($select, $db); if (mysql_num_rows($result)) { $row = mysql_fetch_object($result); $AD_VEHICLE_NAME = $row->ad_vehicle_name; $TARGET_URL = $row->track_url; $sales_choice = $row->sales_choice; $user_id = $row->user_id; if ($sales_choice == 1)//Cookie Tracked Sales { $COOKIE_DURATION = mktime(0,0,1, date("m"), date("d"), date("Y")+1); // COOKIES Life is 1 Year //Array cannot be written in COOKIES //Prev Idea Flopped //Trying to Write STRING ONLY with PIPE (|) separator $ads=$HTTP_COOKIE_VARS["ads"]; if ($ads) // If cookie found with ads data { $ads .="|$ad_id"; } else { $ads ="0|$ad_id"; } setcookie("ads", $ads, $COOKIE_DURATION, "/", "", 0); } //Record Hits $IP = $_SERVER["REMOTE_ADDR"]; $REFERER = $_SERVER["HTTP_REFERER"]; $REFERER = addslashes(substr($REFERER, 0, 250)); $insert = "insert into aa_hits (ad_id, user_id, hit_date, hit_ip, referer) values ('$ad_id', '$user_id', now(), '$IP', '$REFERER')"; $result = mysql_query($insert, $db); //Update total hits $update = "update aa_ads set total_hits = total_hits + 1 where ad_id = '$ad_id'"; $result = mysql_query($update, $db); } else { header("Location: $DEFAULT_EXIT_URL"); flush(); exit; } mysql_close(); header( "Location: $TARGET_URL"); exit; } else { header("Location: $DEFAULT_EXIT_URL"); flush(); exit; } function getAdID($ad_dir, $db) { $ad_dir = mysql_real_escape_string($ad_dir, $db); $select = "select ad_id from aa_ads where status = 1 and ad_dir = '$ad_dir'"; $result = mysql_query($select, $db); if (mysql_num_rows($result)) { $row=mysql_fetch_object($result); if($row->ad_id > 0) { return $row->ad_id; } else { return 0; } } else { return 0; } } function GetAppVar($VAR) { GLOBAL $db, $THIS_SITE_ID; $query = "select value from comm_systemdata where var ='$VAR'"; $result=mysql_query($query,$db); if($row=mysql_fetch_object($result)) { return $row->value; } else { return 0; } } //*******************************************************************************/ ?>