Linkcode Decoding

From TMMwiki
Jump to: navigation, search
NATS 3
Sites Admin
Sites
Site Setup
Configure Redirects
ID Numbers
Automail
Site User Management
Username Checking
Join Form Errors
Free Pre-Initial Checkbox
Payouts Based on Program and Join Options
Payouts Based on Join Option and Per Option
Adding Extra Site Tours
Site Partner
Join Options
Multisite Access
Removing Join Options
Tour Setup
Site Undelete
Join Option Box vs Button
Redirecting Traffic to a Sponsor
Qualified Join Page Hits
Type-In Traffic
Allowed languages
Linkcode Decoding

If you want to manually encode or decode a NATS3 link code, you should use a custom PHP script in order to do this, as including NATS functions for encoding or decoding a link code will create unnecessary overhead. You would also only be able to run the NATS functions on the NATS server. Instead of using a NATS function here, we recommend that you use a custom script, such as the ones in the following examples.

Decoding a Link

You can use this example PHP script to decode NATS link codes.

<?
$data = "MjE3OjY6MTE";

if($argv[1]) $data = $argv[1];
$chars = strlen($data);
$add = 4 - ($chars % 4);
if ($add < 4) while($add--) $data .= '=';


list($campaign, $program, $site) = explode(':', base64_decode($data));
echo "Campaign: $campaign \nProgram: $program \nSite: $site \n\n";
?>

Encoding a Link

You can use this example PHP script to encode NATS link codes.

<?
$campaignid = '38';
$programid = '21';
$siteid = '13';

$data = str_replace('=', '', base64_encode($campaignid.':'.$programid.':'.$siteid));
echo $data."\n";
?>