/** * RedirTrack -- Simple PHP script for redirecting visitors to affiliate * sites while tracking important things the visits. * * Version: 0.9 * Date: April 13, 2007 * * Copyright 2007 by Eric Giguere. */ require 'convert.php'; require 'settings.php'; // Override the defaults using query parameters, if allowed if( $allowoverrides ){ if( isset( $_GET['clickbankid'] ) ){ $clickbankid = $_GET['clickbankid']; } if( isset( $_GET['amazonid'] ) ){ $amazonid = $_GET['amazonid']; } } // Figure out which affiliate program we're using $redirtype = 0; $err = ''; $explain = ''; $url = ''; if( isset( $_GET[ 'cbvendorid' ] ) ){ // ClickBank $redirtype = 1; $cbvendorid = $_GET[ 'cbvendorid' ]; if( empty( $cbvendorid ) ){ $err = "The ClickBank product information (vendor ID) is missing."; } else { $url = "http://$clickbankid.$cbvendorid.hop.clickbank.net"; } } else if( isset( $_GET[ 'asin' ] ) ){ // Amazon $redirtype = 2; $asin = $_GET[ 'asin' ]; if( empty( $asin ) ){ $err = "The Amazon product information (ASIN) is missing."; } else { $url = "http://www.amazon.com/gp/product/$asin/?tag=$amazonid"; } } else { $err = "There is no product information for any supported affiliate program."; $explain = "To specify a ClickBank product, add 'cbvendorid=uavol1' to the URL. " . "To specify an Amazon product, add 'asin=0321321146' to the URL."; } // Grab all the tracking data first. We want to minimize the time we keep // the database open. $v_ip = $_SERVER['REMOTE_ADDR']; $v_referrer = $_SERVER['HTTP_REFERER']; $v_browser = $_SERVER['HTTP_USER_AGENT']; $v_request = $_SERVER['REQUEST_URI']; // Get our 'unique' tracking ID. $tid = redirtrack_getfaketid(); $tid = redirtrack_cleantid( $tid, $tidprefix ); if( $redirtype == 1 ){ $url .= "/?tid=$tid"; } // Log info as required if( $debug || $err ){ $fp = fopen( $debugfname, 'a' ); if( $fp ){ fputs( $fp, redirtrack_debugmsg() ); fclose( $fp ); } } if( !$err && $url ){ header( "Location: $url" ); exit; } // Returns a fake TID based on the uniqid() method. There's no // guarantee it will be unique, but there's a good chance it will be. function redirtrack_getfaketid(){ return dec2string( string2dec( strtoupper( uniqid( '' ) ), 16 ), 36 ); } // Cleans the TID by forcing it to be 8 characters long. function redirtrack_cleantid( $id, $prefix='' ){ $idlen = strlen( $id ); $plen = strlen( $prefix ); if( $idlen > ( 8 - $plen ) ){ $id = substr( $id, $idlen - ( 8 - $plen ) ); } $id = $prefix . str_pad( $id, 8 - $plen, '0', STR_PAD_LEFT ); return $id; } function redirtrack_debugmsg(){ global $v_request; global $v_ip; global $v_referrer; global $v_browser; global $err; global $url; global $tid; $msg = "[$tid] Request $v_request\n" . " IP: $v_ip\n" . " Referrer: $v_referrer\n" . " Browser: $v_browser\n" . " Parameters:\n"; foreach( $_GET as $key => $value ){ $msg .= " $key=$value\n"; } if( $err ){ $msg .= " Error message: $err\n"; } if( $url ){ $msg .= " Redirecting to $url\n"; } return $msg; } // TODO: Database support //$connection = mysql_connect($dbserver,$dbuserid,$dbpassword) or die( mysql_error() ); //$database = mysql_select_db( $dbname ) or die( mysql_error() ); ?> RedirTrack Error

RedirTrack Error

The redirection request could not be completed due to the following error:

Here is a dump of the full request:


Fatal error: Call to undefined function redirtrack_debugmsg() in /home/synclast/public_html/dogtraining/redirtrack.php on line 172