![]() |
How to swap out sponsor links the easy way! [SCRIPT]
We've all experienced the pain of having to swap out large numbers of sponsor links when a sponsor goes bust, closes a site, changes their linking codes etc. Normally this requires either painfully going through page by page and swapping out the links by hand, or using error prone methods like site wide Dreamweaver search and replace, or using utilities like sed for the unix geeks. Here's an easy way to dynamically update all your sponsor links using simple text files and php - no mysql required.
Step 1 Make a plain, tab-delimited text file with all your sponsor info. Put one paysite per line, in the format: campaign|paysite name|paysite domain|url You can have comment lines beginning with a hash (#) Here's an example: Code:
# My paysites For example, my hosting account is laid out like: /users/seanp/domains/domain1.com /users/seanp/domains/domain2.com /users/seanp/domains/domain3.com I could potentially upload my links.txt to: /users/seanp/domains/domain1.com/links.txt or /users/seanp/domains/links.txt Your choice of a name for the campaign should be easy to remember and based on the paysite name. Using this system, you can easily swap out both the console and nonconsole versions of a link code (eg. consoles for hubs, no consoles for free sites) - just label your campaigns in an intuitive way. Step 2 Upload this script in the root directory of every domain that you want to use this link inserting script. You have to edit the value of $sponsors_file to be the absolute path to your links.txt file on your server. Edit the three $default_ variables to point to a hub or something like that; these are used if there is no data found for a given paysite - you want to point your links to a hub at least rather than just having a broken link. Code:
Step 3 Now you are ready to start using dynamic sponsor urls in your pages! In any page you want to use your dynamic urls, insert this line above your opening tag: Code:
For example, if you have a domain laid out like this: Code:
http://www.yourdomain.com/links.txt Code:
Code:
paysite_url($campaign) paysite_name($campaign) paysite_domain($campaign) You would insert these into the page like this: Code:
Code:
eg. in your links.txt Code:
paysite1|Paysite One|paysite1.com|http://www.paysiteone.com/index.php?id=blahblah Code:
paysite1|New Site One|newsite1.com|http://www.newsite1.com/index.php?id=blahblah Misc notes: Yes, this will work with .html files, so you can maintain the illusion that you are serving static html pages for SEs and finickly LL reviewers. You just need to add one line to your .htaccess file: Code:
AddHandler application/x-httpd-php .htm .html I hope this helps someone alleviate the pain of swapping out sponsor links! If you find this helpful and end up using it, feel free to throw up a link to my site http://www.asianslaveslinks.com/ with the anchor text 'Free Asian Porn.' Or, hit me up via pm if you've got an asian site and you'd like to trade links! |
Oops, I just realised I made a wee error in the links.php script above.
Replace this part: Code:
// Reorder the array keys Code:
// Reorder the array keys |
I'll bookmark this page, thanks. ;)
|
I have a similar script set up on my sites with the following code:
Code:
Example, if the file name is "links.php" and you want to link to the paysite Glamour Models Gone Bad, the URL you would use will be the following: Code:
http://www.pathtofile.com/links.php?id=glamourmodelsgonebad Code:
http://www.pathtofile.com/links/?id=glamourmodelsgonebad |
All times are GMT -4. The time now is 09:53 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc