ClickBank custom redirect module

<?php

// This is the default page to redirect to
$go = "http://www.yourmainpage.com/";

// Set your redirect pages here
// Please ensure there is a comma at the end of every keyword line except the last one
$redirects = array (
    "keyword1" => "http://www.yourmainpage.com/subpage/",
    "keyword2" => "http://www.google.com/"
);

// Do you want the hop ID to appear in the destination URL?
// This is very useful for Google Analytics 
$verboseUrl = true;

// How many months to store the affiliate cookie
$cookieMonths = 12; 

/************************************************
 *                                              *
 * END OF CONFIGURATION SECTION - GO NO FURTHER *
 *                                              *
 ************************************************/


// Get the affiliate hop ID if there is one
$hop = "";
if($_GET['hop']) {
	$hop = preg_replace("/\W/", "", $_GET['hop']); // Sanitize hop data, only alphanumeric characters
	$cookieExpires = 60 * 60 * 24 * 30 * $cookieMonths + time();
	setcookie('cbAffiliate', $hop, $cookieExpires);
}

// Check for a redirect
$rd = $_GET["rd"];
if (array_key_exists($rd, $redirects)) {
    $go = $redirects[$rd];
}

// Add hop link if we've got one (for Google Analytics)
if(strlen($hop) && $verboseUrl) {
	$go = $go . "?hop=" . $hop;
}

// Send the traffic
header("Location:$go");
exit;
?>