Added Tell-A-Friend v2.2 -> Added version list. -> Added ability to only allow purchasing customers to be affiliates. -> Added giveaway product functionality. -> Added affiliate emailing. -> Added a few bug fixes. v2.3 -> Added code for parsing PHP in templates. -> Updated code that decides who gets OTO sale. -> Major Security update tracks purchases by IP and only allows Completed payments to be redirected to the download page. -> Added ability to only allow OTO customers to get commissions on the OTO. -> Added ability to disable download emails from automatically being sent. -> Added support for all PayPal currencies. -> BUG FIX: Corrected 48 hour extension of download link to add 48 hours to THIS moment. -> Added script configure util (config.php) v2.4 -> BUG FIX: When OTO commission is set to zero, affiliate always gets the commission. -> BUG FIX: Affiliate cookie now cleared if only customers are allowed to be affiliates. -> BUG FIX: Removed case-sensitive referrer domain comparison for TAF. -> IPN script now prevents people from paying less than stated price for products. -> IPN script now prevents people from purchasing using different emails from the same domains. -> Added admin section for viewing fraudulent transactions. -> Added version number to ipn.php, config.php and settings.php -> Added back-end search features for sales records. -> Added download security. v2.5 -> BUG FIX: Sometimes you could still purchase through your own link even if you weren't a customer and $sys_purchasers_only was true. -> BUG FIX: If customer clicked OTO purchase link but did not purchase, their download link would be to the OTO. -> BUG FIX: config.php file wasn't writing out the currency value to settings.php -> BUG FIX: to prevent warning messages, a blank ipn.txt file is created automatically if it doesn't exist. -> SECURITY: to prevent directory listing of templates folder (should someone discover its name), an index.html file is created there automatically. -> Removed need for cookies throughout purchase/download process to prevent expired download issues. v2.6 -> Added ability to alternate commissions on primary product as well. -> Added version info and item/oto commission info on "Please Wait" order screen. -> SECURITY: Added additional security for admin back-end to prevent cookie spoofing. -> BUG FIX: Added folder location into cookie path for multiple products running on the same domain. */ $sys_version = 2.6; include("settings.php"); function searchKeywords($url){ $parts = parse_url($url); $host = str_replace("www.", "", $parts["host"]); $keywords = ""; parse_str($parts["query"], $vars); if(strpos(" $host", "google")){ $keywords = urldecode($vars["q"]); } elseif(strpos(" $host", "yahoo")){ $keywords = urldecode($vars["p"]); } elseif(strpos(" $host", "live")){ $keywords = urldecode($vars["q"]); } elseif($vars["keywords"]){ $keywords = urldecode($vars["keywords"]); } elseif($vars["query"]){ $keywords = urldecode($vars["query"]); } else{ $keywords = urldecode($vars["q"]); } return $keywords; } function evalPHP($template){ # Make all settings.php variables accessible to template PHP code. global $sys_admin_username, $sys_admin_password, $sys_domain, $sys_support_address, $sys_script_folder, $sys_template_folder, $sys_default_email, $sys_item_name, $sys_item_number, $sys_item_cost, $sys_oto, $sys_oto_name, $sys_oto_number, $sys_oto_cost, $sys_oto_percent, $sys_item_cancel_url, $sys_expire_hours, $sys_blocked, $sys_secure_dl, $sys_tell_subject, $sys_tell_body, $sys_purchasers_only, $sys_purchasers_override, $sys_giveaway_product, $sys_oto_purchasers_only, $sys_oto_purchasers_override; # Eval all php code in a template and plug result into output. $output = ""; $last = 0; $i = strpos($template, "", $i); $phpcode = trim(str_replace(array(""), "", substr($template, $i, $i2 - $i))); $val = eval($phpcode); $output .= $val; $last = $i2 + 3; $i = strpos($template, "", $i); $phpcode = trim(str_replace(array("=", "?>"), "", substr($output, $i, $i2 - $i))); $val = eval("return $phpcode;"); $output2 .= $val; $last = $i2 + 3; $i = strpos($output, "=", $i2); } $output2 .= substr($output, $last, strlen($output) - $last); return $output2; } function showTemplate($filename){ include($filename); return; $output = ""; $fh = @fopen($filename, "r"); while($s = fgets($fh)){ $output .= $s; } @fclose($fh); echo evalPHP($output); } function getIPSalesRecord($oto = false){ global $sys_template_folder, $sys_oto_number; $ip = $_SERVER["REMOTE_ADDR"]; $sales = @file($sys_template_folder . "ipn.txt"); $output = ""; foreach($sales as $sale){ $sale = explode("|", str_replace(array("\r", "\n"), "", $sale)); if($sale[14]==$ip){ $valid = true; if($oto && $sale[2]!=$sys_oto_number){ $output = ""; $valid = false; } if($valid){ # Make sure sale is within valid timeframe. if(time()<$sale[9]){ $output = $sale; break; } else{ # Download has expired. $output = ""; } } } } return $output; } function getOTOSalesRecord($affemail){ global $sys_template_folder, $sys_oto_number; $sales = @file($sys_template_folder . "ipn.txt"); $output = ""; foreach($sales as $sale){ $sale = explode("|", str_replace(array("\r", "\n"), "", $sale)); if($sale[4]==$affemail){ $valid = true; if($sale[2]!=$sys_oto_number){ $output = ""; $valid = false; } if($valid){ $output = $sale; break; } } } return $output; } function sys_download_url($oto){ $md5 = uniqid(""); return "index.php?action=dlid&oto=$oto&pid=$md5"; } function getPaymentEmail($itemnumber, $percent){ global $sys_template_folder, $sys_default_email; # Use sales data to figure out who should get next OTO sale. $sales = @file($sys_template_folder . "ipn.txt"); $afftotal = 0; $affsales = 0; foreach($sales as $sale){ $sale = explode("|", $sale); if($sale[2] == $itemnumber && strtolower($sale[13]) == strtolower(urldecode($_COOKIE["aff"]))){ # Sale referred by affiliate. $afftotal++; if(strtolower($sale[3]) == strtolower(urldecode($_COOKIE["aff"]))){ # Affiliate got the sale. $affsales++; } } } if($afftotal > 0){ $affper = ($affsales / $afftotal)*100; } else{ $affper = 0; } if($percent > 0 && $affper<=$percent){ # Give OTO to affiliate. $email = urldecode($_COOKIE["aff"]); } else{ # Give OTO to vendor. $email = $sys_default_email; } return $email; } $action = $_REQUEST["action"]; # Set privacy policy for IE6/WinXP users. # If you don't do this, a lot of IE browsers wont accept the cookie. header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); if(!file_exists($sys_template_folder . "ipn.txt")){ # IPN file doesn't exist. Create a blank one. $fh = fopen($sys_template_folder . "ipn.txt", "w+"); fwrite($fh, ""); fclose($fh); } if(!file_exists($sys_template_folder . "index.html")){ # index.html file doesn't exist in templates folder. Create a blank one. $fh = fopen($sys_template_folder . "index.html", "w+"); fwrite($fh, ""); fclose($fh); } if(substr($action, 0, 5)=="admin" && $action != "admin" && $action != "adminlogin" && !$_COOKIE["admin"]){ # Not logged in. Redirect to login. header("Location: $_SERVER[PHP_SELF]?action=admin"); exit; } # Redirectin case PayPal goofs and fails to do so. if(!isset($_COOKIE["giveaway"]) && !isset($_GET["fdl"]) && ($action == "squeeze"| $action == "downloadoto") && !isset($_GET["e"])){ # Check for customer IP address in IPN file. if($action=="downloadoto"){ $oto = true; } else{ $oto = false; } $sale = getIPSalesRecord($oto); if(is_array($sale)){ # Purchase record found. if($action=="downloadoto"){ $url = "index.php?action=download&id=$sale[0]&fdl=1"; } elseif($action=="squeeze"|$action=="download"){ $url = "index.php?action=squeeze&id=$sale[0]&fdl=1"; } else{ # Not sure what's up. Send to sales letter. $url = "index.php"; } # Send to appropriate page. header("Location: $url"); } elseif($_GET["tries"]<11){ # Give one minute for PayPal to post IPN record before giving up and showing an error. if(!isset($_GET["tries"])){ $tries = 1; } else{ $tries = $_GET["tries"] + 1; } $seconds = 60 - ($tries * 5); echo "
|
|
|
|
| |
|
[affiliate = $affemail] |
You will no longer receive email from $sys_item_name.
"; exit; } } # ============================================================================= # ALL OTHER PURCHASE-REQUIRED ACTIONS # ============================================================================= else{ # All other actions require a purchase (unless it was a giveaway). # First verify that person actually purchased. if($action=="downloadoto"){ $sale = getIPSalesRecord(true); } else{ if($sys_giveaway_product && isset($_COOKIE["giveaway"])){ $sale = array(); } else{ $sale = getIPSalesRecord(false); } } if(is_array($sale)){ if($action=="oto"){ # Show oto page. $filename = $sys_template_folder . "oto.html"; } elseif($action=="squeeze"){ # Show name squeeze page. $filename = $sys_template_folder . "squeeze.html"; } elseif($action=="download"){ if($sys_oto && !isset($_GET["dl"])){ # Show OTO page. $filename = $sys_template_folder . "oto.html"; } else{ # Show download page. $filename = $sys_template_folder . "download.html"; } } elseif($action=="downloadoto"){ # Show OTO download page. $filename = $sys_template_folder . "downloadoto.html"; } else{ # Invalid action. Show expired page. $filename = $sys_template_folder . "downloadexpired.html"; } } else{ # User not found in sales records. Show expired page. $filename = $sys_template_folder . "downloadexpired.html"; } } # ============================================================================= # ADMIN BACK-END FUNCTIONS # ============================================================================= if($action=="admin"){ # Get username/password for admin area. echo " "; exit; } elseif($action=="adminlogin"){ # Verify admin username/password. if($_POST["username"] == $sys_admin_username && $_POST["password"] == $sys_admin_password){ # Valid. Cookie and redirect. $uniq = uniqid(""); setcookie("admin", true); setcookie("uniq", $uniq); $fh = fopen($sys_template_folder . "uniq.txt", "w+"); fwrite($fh, $uniq); fclose($fh); header("Location: $_SERVER[PHP_SELF]?action=adminmenu"); exit; } else{ echo "Invalid username or password."; exit; } } if($_COOKIE["admin"]){ $uniq = file_get_contents($sys_template_folder . "uniq.txt"); if($_COOKIE["uniq"] != $uniq){ # Somebody's trying to hack. setcookie("admin", "", time() - 3600); header("Location: $_SERVER[PHP_SELF]?action=admin"); exit; } $adminheader = "
$7 Secrets Scripts v$sys_version
"; $adminfooter = "