0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
affiliates
/
[
Home
]
File: jrox.php
<?php ##################################################################################### ## JROX.COM Affiliate Manager - jrox.php file ## Version 1.6.2 ## ## Author: Ryan Roxas(ryan@jrox.com) ## Homepage: http://jam.jrox.com ## Bug Reports: http://jam.jrox.com/bugzilla/ ## Release Notes: docs/READ_ME.txt ####################################################################################### ####################################################################################### ## COPYRIGHT NOTICE ## Copyright 2007 JROX Technologies, Inc. All Rights Reserved. ## ## This script may be only used and modified in accordance to the license ## agreement attached (license.txt) except where expressly noted within ## commented areas of the code body. This copyright notice and the ## comments above and below must remain intact at all times. By using this ## code you agree to indemnify JROX Technologies, Inc, its corporate agents ## and affiliates from any liability that might arise from its use. ## ## Selling the code for this program without prior written consent is ## expressly forbidden and in violation of Domestic and International ## copyright laws. ####################################################################################### ####################################################################################### ## This file is the main affiliate link file for setting the affiliate cookie and ## redirecting the visitor to the appropriate web site ####################################################################################### $jam_ext_sessions = 1; require_once "includes/common.php"; require_once 'includes/sessions.php'; require_once 'includes/setlang.php'; if (DEBUG_ADVANCED_ERROR == true) { error_reporting(E_ALL); } else { error_reporting(0); } //SET THE DEFAULT REDIRECT URL $product_url = $default_redirect_url; //CHECK TO SEE IF THERE IS AN ID VARIABLE FIRST if (!empty($_GET['id'])) { $id = Clean_Data($_GET['id']); $id_type = 'id'; $id_table = 'mid'; } elseif (!empty($_GET['uid'])) { $id = Clean_Data($_GET['uid']); $id_type = 'uid'; $id_table = 'username'; } else { header("Location:$product_url"); exit(); } if (Check_Affiliate_Encode() == true) { $id = Decrypt_Text($id); } $id_array = explode('_', $id); $affid = $id_array[0]; if (count($id_array) >= 2) { $prod_id = $id_array[1]; } if (count($id_array) >= 4) { $tool_type = $id_array[2]; $tool_id = $id_array[3]; } else { $tool_type = ''; $tool_id = 0; } if (count($id_array) == 5) { $tracker = substr($id_array[4], 0, 25); $tracker = preg_replace("/([^0-9A-Za-z]+)/", "", $tracker); } else { $tracker = ''; } //CHECK TO SEE IF USERNAME IN ID VARIABLE IS VALID $affid = mysql_real_escape_string($affid); $partner_check = mysql_query("SELECT mid, username, enable_custom_url, custom_affiliate_url FROM jx_members WHERE $id_table = '$affid' AND status = 'active'") or die(cmysql_error(__LINE__, __FILE__)); if (mysql_num_rows($partner_check) != 1) { //FOR DEVELOPMENT //echo "no user found"; header("Location:$product_url"); } else { $username_row = mysql_fetch_row($partner_check); $mid = $username_row[0]; $username = $username_row[1]; $enable_custom_url = $username_row[2]; $custom_affiliate_url = $username_row[3]; //CHECK FOR MARKETING TOOLS DATA switch ($tool_type) { case "bid": $tool = 1; $table = "jx_banners"; $index_id = "bid"; break; case "tlid": $tool = 2; $table = "jx_text_links"; $index_id = "tlid"; break; case "taid": $tool = 3; $table = "jx_text_ads"; $index_id = "taid"; break; case "haid": $tool = 4; $table = "jx_hover_ads"; $index_id = "haid"; break; case "eaid": $tool = 5; $table = "jx_email_ads"; $index_id = "eaid"; break; case "aaid": $tool = 6; $table = "jx_article_ads"; $index_id = "aaid"; break; default: $tool = 0; $tool_id = 0; break; } if ($tool == 1 || $tool == 2 || $tool == 3 || $tool == 4 || $tool == 5 || $tool == 6) { //CHECK FOR CORRECT BANNER ID and CUSTOM REDIRECT URL $tool_id = mysql_real_escape_string($tool_id); $tool_check = mysql_query("SELECT pid, enable_redirect, redirect_custom_url FROM $table WHERE $index_id = '$tool_id'") or die(cmysql_error(__LINE__, __FILE__)); if ($tool_check) { if (mysql_num_rows($tool_check) == 1) { $tool_row = mysql_fetch_row($tool_check); if ($tool_row[1] == 1) { $product_url = $tool_row[2]; $custom_redirect = 2323; } $tool_pid = $tool_row[0]; } else { $tool = 0; $tool_id = 0; } } } //GET PRODUCT INFORMATION FROM DATABASE if (!empty($tool_pid)) { $pid = $tool_pid; } elseif (!empty($prod_id) AND $prod_id != '') { $pid = $prod_id; } else { $pid =1; } $pid = mysql_real_escape_string($pid); $product_check = mysql_query("SELECT * FROM jx_products WHERE pid = '$pid'") or die(cmysql_error(__LINE__, __FILE__)); if (mysql_num_rows($product_check) == 1) { $product_row = mysql_fetch_assoc($product_check); $product_type = $product_row['product_type']; $ppc_interval_value = $product_row['ppc_interval_value']; $ppc_interval_type = $product_row['ppc_interval_type']; $commission_levels = $product_row['commission_levels']; } else { //FOR DEVELOPMENT //echo "No product settings"; header("Location:$product_url"); exit(); } if ($enable_custom_url == 1) //CHECK TO SEE IF CUSTOM AFFILIATE URL IS ENABLED AND SET REDIRECT { $product_url = $custom_affiliate_url; } elseif (!empty($custom_redirect) AND $custom_redirect == 2323) { //okay } else { $product_url = $product_row['product_url']; } //SET AFFILIATE COOKIE /* $timer_check = mysql_query("SELECT enable_ip_tracking, enable_session_tracking, cookie_date_value, cookie_date_type, overwrite_cookie, append_cookie_url, enable_affiliate_custom_url FROM jx_settings") or die(cmysql_error(__LINE__, __FILE__)); $timer_row = mysql_fetch_assoc($timer_check); extract($timer_row); */ //GET REFERER INFORMATION if(empty($_SERVER['HTTP_REFERER'])) { $ref_site = ROW_UNKNOWN; } else { $ref_site = addslashes(substr($_SERVER['HTTP_REFERER'],0,100)); } //CALCULATE COOKIE TIMER switch ($JAMSettings['cookie_date_type']) { case "day": $cookie_expires = $JAMSettings['cookie_date_value'] * 60 * 60 * 24; break; case "week": $cookie_expires = $JAMSettings['cookie_date_value'] * 60 * 60 * 24 * 7; break; case "month": $cookie_expires = $JAMSettings['cookie_date_value'] * 60 * 60 * 24 * 30; break; case "year": $cookie_expires = $JAMSettings['cookie_date_value'] * 60 * 60 * 24 * 365; break; } //CHECK IF TRACKER IS PRESENT AND ADD if (!empty($tracker)) { $cookie_id = $mid."###".$pid."###".$tool."###".$tool_id."###".$tracker."###".$ref_site; } else { $cookie_id = $mid."###".$pid."###".$tool."###".$tool_id."###".$ref_site; } //CHECK TO SEE IF COOKIE HAS ALREADY BEEN SET if ($JAMSettings['overwrite_cookie'] == 0) { if (!empty($_COOKIE['jrox'])) { //CHECK IF COOKIE IS LEGITIMATE $cookie_check1 = urldecode($_COOKIE['jrox']); if (strstr($cookie_check1, "###") == true) { $cookie_check2 = explode("-", $cookie_check1); if (is_numeric($cookie_check2[0])) { //CHECK FOR LEGITIMATE USER $cookie_check3 = mysql_query("SELECT mid FROM jx_members WHERE mid = '$cookie_check2[0]'") or die(cmysql_error(__LINE__, __FILE__)); if ($cookie_check3) { if (mysql_num_rows($cookie_check3) == 1) { $mid = $cookie_check3[0]; header("Location:$product_url"); exit(); } } } } } } //SET THE COOKIE INFORMATION $cookie_domain = ".".COOKIE_DOMAIN; if (setcookie("jrox", $cookie_id, time()+$cookie_expires,"/", $cookie_domain)) { $go_referer = 'YES'; } else { if ($enable_ip_tracking == '1' || $enable_session_tracking == '1') { $go_referer = 'YES'; } else { header("Location:$product_url"); } } if (!empty($go_referer) AND $go_referer == 'YES') { if ($JAMSettings['enable_session_tracking'] == 1) { if (!empty($tracker)) { $_SESSION['jrox_jam'] = urlencode($mid."###".$pid."###".$tool."###".$tool_id."###".$tracker."###".$ref_site); } else { $_SESSION['jrox_jam'] = urlencode($mid."###".$pid."###".$tool."###".$tool_id."###".$ref_site); } } //GET THE IP ADDRESS AND BROWSER INFORMATION $ip = $_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_USER_AGENT'])) { $user_agent = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']); //FIND OUT WHAT BROWSER THEY ARE USING $browser_type = browser_detection('browser'); if ($browser_type == "ie") { $browser = "Internet Explorer"; } elseif ($browser_type == "moz") { $browser = "Netscape/Firefox"; } elseif ($browser_type == "op") { $browser = "Opera"; } else { $browser = "Unknown"; } if ($browser == "Internet Explorer" || $browser == "Netscape/Firefox" || $browser == "Opera") { $browser_version = browser_detection('number'); $browser = $browser." ".$browser_version; } //GET OPERATING SYSTEM $os_type = browser_detection('os'); if ($os_type == "win" || $os_type == "nt") { $os = "Windows"; } elseif ($os_type == "mac") { $os = "Macintosh"; } elseif ($os_type == "lin") { $os = "Linux"; } else { $os = "Unknown"; } if ($os == "Windows" || $os == "Macintosh" || $os == "Linux") { $os_version = browser_detection('os_number'); if ($os == "Windows" AND $os_version == "5.0") { $os_version = "2000"; } elseif ($os == "Windows" AND $os_version == "5.1") { $os_version = "XP"; } elseif ($os == "Windows" AND $os_version == "5.2") { $os_version = "2003"; } $os = $os." ".$os_version; } } else { $user_agent = "Unknown"; $os = "Unknown"; $browser = "Unknown"; } //GET ISP INFORMATION if (!empty($_SERVER['REMOTE_ADDR'])) { $isp = gethostbyaddr($_SERVER['REMOTE_ADDR']); } else { $isp = "Unknown"; } $expires = 0; if ($ppc_interval_type != 'unique') { if (empty($ppc_interval_value)) { $ppc_interval_value = 0; } switch ($ppc_interval_type) { case "minute": $expires = time() + (60 * $ppc_interval_value); break; case "day": $expires = time() + (60 * 24 * $ppc_interval_value); break; case "week": $expires = time() + (60 * 24 * 7 * $ppc_interval_value); break; case "month": $expires = time() + (60 * 24 * 30 * $ppc_interval_value); break; } } //CHECK IF IT IS PAY-PER-CLICK if ($product_type == 'click') { //CHECK IF CLICK IS IN DATABASE if (Check_PPC($ppc_interval_value, $ppc_interval_type, $pid, $_SERVER['REMOTE_ADDR'], $expires) == true) { //SET REFERRER INFORMATION $referer_insert = mysql_query("INSERT INTO jx_traffic (date, mid, pid, tool, tool_id, referrer, ip_address, user_agent, os, browser, isp, tracker, expires) VALUES ( NOW(), '$mid', '$pid', '$tool', '$tool_id', '$ref_site', '$ip', '$user_agent', '$os', '$browser', '$isp', '$tracker', '$expires')") or die(cmysql_error(__LINE__, __FILE__)); //CALL SALE.PHP $custom_mid = $cookie_id; if (!empty($_REQUEST['amount']) AND is_numeric($_REQUEST['amount'])) { $amount = $_REQUEST['amount']; } else { $amount = '1.00'; } $url = HOME_BASE_URL . HOME_BASE_AFFILIATE_DIRECTORY . "/sale.php?amount=".$amount."&trans_id=PPC-".JAM_PPC_TRANS_ID."&custom_mid=".$custom_mid; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $resp = curl_exec($ch); curl_close ($ch); } } else { //SET REFERRER INFORMATION $referer_insert = mysql_query("INSERT INTO jx_traffic (date, mid, pid, tool, tool_id, referrer, ip_address, user_agent, os, browser, isp, tracker, expires) VALUES ( NOW(), '$mid', '$pid', '$tool', '$tool_id', '$ref_site', '$ip', '$user_agent', '$os', '$browser', '$isp', '$tracker', '$expires')") or die(cmysql_error(__LINE__, __FILE__)); } if ($JAMSettings['enable_affiliate_custom_url'] == 1) { if (!empty($_GET['jxURL'])) { $product_url = $_GET['jxURL']; } } if (!empty($_GET['signup']) AND is_numeric($_GET['signup'])) { header("Location:".MEMBERS_HOME_BASE_URL.HOME_BASE_AFFILIATE_DIRECTORY."/index.php?req=newaccount&pid=".$_GET['signup']); } elseif (!empty($_GET['desc']) AND is_numeric($_GET['desc'])) { header("Location:".MEMBERS_HOME_BASE_URL.HOME_BASE_AFFILIATE_DIRECTORY."/index.php?req=desc&pid=".$_GET['desc']); } elseif ($JAMSettings['append_cookie_url'] == 1) { $cookie_id = urlencode($cookie_id); header("HTTP/1.1 301 Moved Permanently"); header("Location:$product_url?jrox=$cookie_id"); exit(); } else { $product_url = Replace_Strings($product_url, $mid); $product_url = str_replace("%%%COOKIE_ID%%%", urlencode($cookie_id), $product_url); header("HTTP/1.1 301 Moved Permanently"); header("Location:$product_url"); exit(); } } } ?>