Here is the go.php script:
<?php
// ListMailPro Link Tracking Script -- without user tracking
// This entire script is based upon whether the $urlid parameter is set
// "urlid" is used to make the links look less like redirections.
// This file should be placed in a generic directory, like "Links".
// In Html, Forums, E-Books, etc. use: http://yourdomain.com/Links/go.php?urlid=therefcode
/* ====== STUFF TO EDIT MANUALLY ============= */
$configfile = "../ListMail/config.php";
$adminfile = "../ListMail/admin.php";
/* ============== THE MEAT =============== */
if ( isset($urlid) ) {
// continue
} else {
echo "<html><head></head><body>No link was specified.</body></html>";
exit;
}
include($configfile); // grabs info to connect to database
include($adminfile); // grabs info to connect to database
$link = mysql_connect($sqlhost,$sqluser,$sqlpass);
mysql_selectdb($sqldb);
$rcode = $urlid;
// get link data from MySQL table
$krow = mysql_query("select id as kid,refcode,title,http,hits from $ktable where refcode = '$rcode' limit 0,1");
if(mysql_num_rows($krow)==0){ $krow = mysql_query("select id as kid,refcode,title,http,hits from $ktable where refcode = '$urlid' limit 0,1"); }
if(mysql_num_rows($krow)==0) echo "Link not found.";
while(list($kid,$refcode,$title,$http,$hits) = @mysql_fetch_row($krow)) {
$newhit = $hits + 1;
$cmd = "update $ktable set hits = '$newhit' where id = '$kid'";
mysql_query($cmd);
// insert id,uid,linkid
if (!strstr($http, "://")) { $http = "http://" . $http; }
// process msg code in link
$http = urlencode(processmsg('',$uid,$http,'0'));
// fix ://
$http = str_replace('%3A',':',$http);
$http = str_replace('%2F','/',$http);
$http = str_replace('%3F','?',$http);
$http = str_replace('%3D','=',$http);
$http = str_replace('%26','&',$http);
// show the redirect page
echo "<html>
<head>
<title>Linking to $title... Please stand by...</title>
<noscript>
<meta http-equiv=\"refresh\" content=\"3; URL=$http\">
</noscript>
<script language=\"JavaScript\">
<!--
var sTargetURL = \"$http\";
function doRedirect()
{
setTimeout( \"window.location.href = sTargetURL\", 2*1000 );
}
//-->
</script>
<script language=\"JavaScript1.1\">
<!--
function doRedirect()
{
window.location.replace( sTargetURL );
}
doRedirect();
//-->
</script>
</head>
<body onload=\"doRedirect()\">
If you are seeing this, either the link does not exist, or you need to <a href=\"$http\">click here</a>.
<script>window.status='$logtxt';</script>
</body>
</html>";
} // End of While Statement
?>
Dean actually wrote most of this script. I just made some minor adjustments. I hope this helps out.
- Jon