Sorry for the long waiting, but here's the official answer to the related problem.
Many of you guys might think we are doing some kind of shaving because we are using javascript code in our fhg galleries.
We have changed to javascript over PHP, because apache with php is not the fastest solution on the market for this kind of functionality, therefore we thought improving the server performance would be good for all of us. Why? PHP was only used to append the NATS code to the tracking urls in the galleries and we were able to port this functionality over to javascript.
So let?s see, how does it work. If you look at the source code of the galleries, you can see this.
<script language="javascript" src="/include.js"></script>
</head>
<script language="JavaScript">
<!--
var gsDefaultNATS = "MDowOjQ";
var gsTrackingURL = "http://signup.assholefever.com/track/";
//-->
</script>
This line loads up the include.js file for the free hosted gallery
<script language="javascript" src="/include.js"></script>
</head>
The include.js file hold gallery independent javascript code.
Below that, you can see the following lines.
<script language="JavaScript">
<!--
var gsDefaultNATS = "MDowOjQ";
var gsTrackingURL = "http://signup.assholefever.com/track/";
//-->
</script>
These are gallery specific javascript codes.
gsDefaultNATS is the DEFAULT nats code, if THERE IS NO reseller specific one.
gsTrackingURL is the site tracking url, where visitors should go to if they click on the links.
To see, what kind of code is in the include.js file, simply enter this url in your browser:
http://fhg.assholefever.com/include.js
Of course you can replace the assholefever.com domain to any other domain of ours, if you would like to check on them as well.
For example:
http://fhg.dpfanatics.com/include.js
Now let?s see what is in the javascript file.
----- CONTENT OF JAVASCRIPT FILE ? START -----
function getGETParameter(psParameterName)
{
var lsReturn = "";
var lsURL = document.URL;
if (lsURL.indexOf("?") > -1 )
{
var lsParameterString = lsURL.substr(lsURL.indexOf("?"));
var laParameter = lsParameterString.split("&");
for ( var liParameterCounter = 0; liParameterCounter < laParameter.length; liParameterCounter++ )
{
if (laParameter[liParameterCounter].toLowerCase().indexOf(psParameterName.toLowerCase () + "=") > -1 )
{
var lsParameter = laParameter[liParameterCounter].split("=");
lsReturn = lsParameter[1];
break;
}
}
}
return lsReturn;
}
function gotoTrackingURL()
{
if(gsNATS.length > 0)
document.location.href = gsTrackingURL + gsNATS;
else
document.location.href = gsTrackingURL + gsDefaultNATS;
}
var gsNATS = getGETParameter("nats");
----- CONTENT OF JAVASCRIPT FILE ? END -----
Let?s see what is what in the javascript file.
function getGETParameter(psParameterName) is a function that is looking for a specific GET parameter in the requested FHG URL using the value of psParameterName variable.
For example:
This is the request URL:
http://fhg.assholefever.com/8142/ind...er,0,0,0,41020
Everything behind the ? sign is what we call GET parameters, if there are more than one parameter, they are separated by the & sign. In the example url there is one GET parameter, this is the LINKING CODE: nats=darksider:partner:assholefever,0,0,0,41020
So the output of the getGETParameter(?nats?) will be darksider:partner:assholefever,0,0,0,41020.
function gotoTrackingURL() is a function that puts together the full target URL, where visitors should go when they click on a link. This url contains the tracking url and the NATS CODE, if there is no reseller specific nats code in gsNATS variable, then we are using gsDefaultNATS variable site specific NATS code.
How do we decide if there is no reseller code, in this line:
if(gsNATS.length > 0)
if gsNATS variable has more than 0 characters, THERE IS RESELLER SPECIFIC NATS code and WE USE THAT.
We have arrived to the last lime
var gsNATS = getGETParameter("nats");
this is where we set up RESELLER SPECIFIC NATS CODE for the whole gallery, so looking at the above example, if the requested FHG url is
http://fhg.assholefever.com/8142/ind...er,0,0,0,41020
then gsNATS will be ?darksider:partner:assholefever,0,0,0,41020?.
Let?s see the runtime flow.
Visitor loads up the
http://fhg.assholefever.com/8142/ind...er,0,0,0,41020 into the browser.
Before the browser shows the HTML page, include.js loads up and gsNATS, gsDefaultNATS, gsTrackingURL gets initialized.
So when the page get shows up in the browser
gsNATS will has the value ?darksider:partner:assholefever,0,0,0,41020?
gsDefaultNATS will has the value "MDowOjQ"
gsTrackingURL will has the value "http://signup.assholefever.com/track/"
if you check into the HTML source you can see lines like this onClick="gotoTrackingURL()".
This is responsible for sending the visitors to the tracking URL when they are clicking on a the link.
So, this is how galleries are working, sorry if it has become a bit too technical!