Jump to content

Affiliate System Customization


rmatakajr

Recommended Posts

If your like me, you want the affiliate program to do more then it

already does... so i hacked it and here is a solution to give your

customer specific affiliate links for promos you run through WHMCS

affiliate system, plus i made the links search engine friendly

 

APACHE MUST HAVE AcceptPathInfo = on

 

 

STEP 1

 

Edit The affiliates.tpl

 

Change


<input type="text" size="80" value="{$referrallink}">

to

<input type="text" size="80" readonly="readonly" value="http://www.yourdomain.com/whmcs/*/aff/{$affiliateid}/NAME-OF-PROGRAM">

 

Where

 

NAME-OF-PROGRAM == to unique program, like mypackage

 

so it would look like

 


<input type="text" size="80" readonly="readonly" value="http://www.yourdomain.com/whmcs/*/aff/{$affiliateid}/mypackage">

 

 

Step 2

 

Now Replace the Code in *

with this code

 

 



<?php
define("CLIENTAREA",true);

include("dbconnect.php");
include("includes/functions.php");


$pathArray=array();
$strip_array=array();
$pathArray=processURI();
//print_r($pathArray); exit();


// ORG WHMCS CODE

// if (isset($aff)) {
//	update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));
//	setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60);
// }

// NEW CODE

if (($pathArray['arg1']=='aff') && (is_numeric($pathArray['arg2'])) ) {
update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$pathArray['arg2']));
setcookie("WHMCSAffiliateID", $pathArray['arg2'], time()+90*24*60*60);
}



header("HTTP/1.1 301 Moved Permanently"); 
if ( (isset($pathArray['arg3'])) && ($pathArray['arg3']=='mypackage') )    {

header("Location: http://www.mydomain.com/mypackage.php");

}else{

// Send To Home Page
header("Location: ".$CONFIG["Domain"]);

}


// Lets Setup Search Engine Friendly URIS
// http://localhost/listing/index.php/1093114973.html
// this phrases the /var/1/2/

function processURI() {
global $PATH_INFO;   // Define our global variables
$array = explode("/",$PATH_INFO);	// Explode the URI using '/'.
$num = count($array);	// How many items in the array?
$url_array = array();	// Init our new array	

for ($i = 1 ; $i < $num ; $i++) {	         
$url_array["arg".$i] = $array[$i];  
}

return $url_array;  // return our new shiny array
}

 

NOW YOUR LINKS SHOULD LOOK LIKE THIS in the Client Area

for the affiliate program

 

http://www.yourdomain.com/whmcs/*/aff/004/mypackage'>http://www.yourdomain.com/whmcs/*/aff/004/mypackage

 

 

When you go to this link, it will track the aff=004 and

send them off to your mypackage page

 

 

If you leave off /mypackage

 

Then it will send off to your home page

 

 

I have 2 links in my affiliate area like look like this

 

Special Offer Page Affiliate Link

http://www.yourdomain.com/whmcs/*/aff/004/mypackage'>http://www.yourdomain.com/whmcs/*/aff/004/mypackage

 

Home page affiliate link

http://www.yourdomain.com/whmcs/*/aff/004

 

 

Enjoy!

Rick Jr :-P

http://www.mataka.com

Link to comment
Share on other sites

  • 5 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated