error_reporting(0);
if ($_REQUEST['id']) { $id = $_REQUEST['id']; } else { $id = $id; }
include("config/config.php");
if (!$tlinks) {
$checkref=mysql_query("select ta, ti from idevaff_tlog where ta = '$id' and ti = '$ip_addr'");
if (!mysql_num_rows($checkref)) {
mysql_query ("insert into idevaff_tlog (ta, ti) values ('$id', '$ip_addr')"); } }
$incoming_data = explode("_", $id);
$id = $incoming_data[0];
$page = $incoming_data[1];
$set = $incoming_data[2];
$link = $incoming_data[3];
$split = $incoming_data[4];
$split_redirect = $incoming_data[5];
$idchk = mysql_query("select id from idevaff_affiliates where id = $id");
if (mysql_num_rows($idchk)) {
if ($id != 0) {
if ($_REQUEST['page']) { $page = $_REQUEST['page']; }
if ($_REQUEST['set']) { $set = $_REQUEST['set']; }
if ($_REQUEST['link']) { $link = $_REQUEST['link']; }
if ($set == 1) { $table = "banners"; $col = "number"; }
if ($set == 2) { $table = "ads"; $col = "id"; }
if ($set == 3) { $table = "links"; $col = "id"; }
$itime = date("g:ia"); $idate = date("m-d-y"); $time_now = time();
if ($_GET['clickref']) { $curl = $_GET['clickref']; }
$checkip=mysql_query("select * from idevaff_iptracking where acct_id = '$id' and ip = '$ip_addr' order by id DESC");
$checkip=mysql_fetch_array($checkip);
$rowid=$checkip[id];
$stamp=$checkip[stamp];
if ($rowid) {
$diff = $time_now - $stamp;
if ($diff >= $ex3) {
if ($_GET['curlad']) { $curl = $_GET['curlad']; }
setcookie ("idev", "", time()-$ex3, "/", "$cookie_url", 0);
setcookie ("idev", "$id", time()+$ex3, "/", "$cookie_url", 0);
mysql_query("insert into idevaff_iptracking (acct_id, ip, refer, stamp, hit_time, hit_date, src1, src2, split) values ('$id', '$ip_addr', '$curl', '$time_now', '$itime', '$idate', '$set', '$link', '$split')");
mysql_query("update idevaff_$table set hits = hits+1 where $col = $link"); }
} else {
$idev_credit = 1;
if ($_GET['curlad']) { $curl = $_GET['curlad']; }
setcookie ("idev", "$id", time()+$ex3, "/", "$cookie_url", 0);
mysql_query("insert into idevaff_iptracking (acct_id, ip, refer, stamp, hit_time, hit_date, src1, src2, split) values ('$id', '$ip_addr', '$curl', '$time_now', '$itime', '$idate', '$set', '$link', '$split')");
mysql_query("update idevaff_$table set hits = hits+1 where $col = $link"); }
session_start();
$_SESSION['idev'] = $id;
mysql_query("update idevaff_affiliates set hits_in = hits_in+1 where id = '$id'");
$getpaylevel=mysql_query("select type, level from idevaff_affiliates where id = '$id'");
$paylevel=mysql_fetch_array($getpaylevel);
$type=$paylevel[type];
$level=$paylevel[level];
$getpayamount=mysql_query("select amt from idevaff_paylevels where type = '$type' and level = '$level'");
$payamount=mysql_fetch_array($getpayamount);
$payout=$payamount[amt];
$app_check = "sale_approval_$type";
if (($type == 3) && ($idev_credit == 1)) {
if ($sale_notify_ppc == 1) { $idev = $id; include ("$path/admin/includes/email_templates/admin_new_sale.php"); }
if ($$app_check == 1) { $setme = "0"; } else { $setme = "1"; }
$checktier=mysql_query("select tier from idevaff_affiliates where id = '$id'");
$texist=mysql_fetch_array($checktier);
$texist=$texist[tier];
if ($texist > 0) { $tiernumber = $texist; } else { $tiernumber = 0; }
mysql_query("insert into idevaff_sales (id, date, time, payment, tier, approved, ip, code, type) values ('$id', '$cdate', '$ctime', '$payout', '$tiernumber', '$setme', '$ip_addr', $sale_time, $type)");
if ($$app_check == 0) {
if ($rewards == 1) {
if (($rew_app == 2) || ($rew_app == 3)) { $who = $id; include("$path/admin/includes/process_rewards.php"); } }
if ($sale_notify_affiliate_ppc == 1) { $id = $id; $email = 'top';
include("$path/admin/includes/email_templates/new_sale.php"); } }
if ($$app_check == 0) {
mysql_query("update idevaff_affiliates set tagged = '1', sales = sales+1 where id = '$id'");
if ($texist > 0) {
$lastrec=mysql_query("select max(record) as latest from idevaff_sales");
$lastres=mysql_fetch_array($lastrec);
$lastres=$lastres[latest];
$tpay = $payout * $tier_payout;
$tpay = (number_format($tpay,2));
if ($tpay >= .01) {
mysql_query("insert into idevaff_sales (id, date, time, payment, top_tier_tag, approved, tier_id, rec_id, type) values ('$tiernumber', '$cdate', '$ctime', '$tpay', '1', '1', '$id', '$lastres', $type)");
mysql_query("update idevaff_affiliates set tagged = '1', tier_sales = tier_sales+1 where id = '$tiernumber'");
if ($sale_notify_affiliate_ppc == 1) { $id = $tiernumber; $email = 'tier'; $payout = $tpay;
include("$path/admin/includes/email_templates/new_sale.php"); } } } } } } }
if ($id == 0) { include("config/config.php"); }
include("update.php");
if ($_REQUEST['offline_delivery'] == 1) {
header("Location: $offline_send");
} elseif ($split) {
$getpage=mysql_query("select link from idevaff_custom where id = '$split_redirect'");
$getpage=mysql_fetch_array($getpage);
$sendvisitor=$getpage[link];
if (!$sendvisitor) { $sendvisitor = $full_path; }
header("Location: $sendvisitor");
} elseif ($page) {
$getpage=mysql_query("select location from idevaff_groups where id = '$page'");
$getpage=mysql_fetch_array($getpage);
$sendvisitor=$getpage[location];
header("Location: $sendvisitor");
} else {
header("Location: $full_path"); }