Page is a not externally linkable
rainborick - 5:28 pm on Dec 28, 2012 (gmt 0)
A JavaScript file that large is just going to be a continuous source of problems. First of all, it's going to be terrible for your site's performance, and a horrible bandwidth hog - especially if it's used on many pages on your site. It would be much better to use a database to hold the URLs and use a PHP script to fetch the desired URL and redirect the user to it.
At least half of the job is already done for you by the forum software's database. Just add a separate table in the forum database to hold the 'trafficlinks'. You can use PHP to generate the JavaScript required to determine the number of forum URLs available for 'contentlinks' and 'trafficlinks'. Then it's just a matter of changing the window.open() calls in getRandomLink() to point to the PHP redirection script I mentioned above.
If this is beyond your experience at the moment, in the meantime you should be able to significantly reduce the size of your JavaScript file by removing the repetitious instances of 'http://forums.example.org/showthread.php?f=154&t=' in the contentlinks[] array, and just have it filled with the thread ID numbers. Then just use something like:
if (whichSet==0) { window.open('http://forums.example.org/showthread.php?f=154&t='+ contentlinks[GetRandom(0,contentlinks.length-1)]) }
else if (whichSet==1) { window.open(trafficlinks[GetRandom(0,trafficlinks.length-1)]) }
}