Recent entries
- Install Windows Vista, Windows XP and Windows 7 from a USB Jumpdrive
- Attempting to Adopt a Dog in Colorado
- EMovies Will No Longer be Supported
- MySQL Database Backup .MYI and .MYD
- Tips to Avoid Spyware and Virus's
- Popular Torrent Usages
- Tips for Creating Aeonity Blog Templates
- Save The Internet
- Win a 1990 FJ62 Toyota Land Cruiser
- Mile-Hi SkyDiving near the Mile High City
Random entries
- So complicated
- Life Re-Charged Isagenix: Day 6 Shake Day
- Men Equals Happy People
- Body For Life - Not for Me
- HowTo: Windows XP VPN Server Setup
- Anticipation
- Back to PHP, Database and Web-based Programming
- Logitech X-230 2.1 32Watt Speakers
- PHP SetCookie with Localhost and Apache
- Weather for Denver Colorado
http://wwww.aeonity.com/frost
Tracking Traffic to a Specific Link
Tracking Traffic to a Specific Link
by FrosT
Introduction
My very first PHP script was dedicated to logging how many times a specific link has been clicked. The first version of the script the stats were logged to a flat file (text file located on the server) to avoid the need of MySQL. The LinkScript code will not immediately be available, but I will post it here in the future. Let's start with the history of LinkScript.
History of LinkScript
The first LinkScript was developed as a tool to count how many people have clicked on a specific link. The simplicity of this initial script allowed for all the data to be stored in a flat file on the server. This eliminated the need of MySQL for those uses that did not have access to a MySQL database on their server. The initial script would open the file, grab the line that is being accessed parse the data update the counter and than write all the lines back into the file with the newly updated count. This strategy shows a few problems, namely was errors would often be thrown due to write access and sometimes data would be over written.
At this point I had learned MySQL in and out and was able to tie LinkScript into a MySQL database. Although the original version of parsing a text file is still accessible, the flat file is not ideal. Incorporating a MySQL database allowed room for a lot of expansion. The expansions included, anti-hotlink options, extra statistics, including referrers and IP addresses of users clicking the link. The script was fairly simple, whenever there was a link you wanted to track you simply added the link to the database, and than the database would provide you with a URL to use to track the link. On that note let's get into the logistics of LinkScript.
Logistics of LinkScript
Tracking links can prove to be a difficult task, but one well worth it if you want to find out how popular a link is. The steps for the LinkScript would be as follows; add a link to the database, including name, description and the actual link URL. From this information the script would store that data in the database and return you the URL to use to track the link. This URL originally was in the form of linkScript.php?linkID=3. This may be changed for ease of use by adding a track back name so instead of linkID=3 it would be link=tack-back-name. Now when a user clicked on that link they would be re-directed to the file and or link that was requested. If the link indeed was a file, the PHP script knew that and if the anti-hotlink option was on for that link it would check the referrer and verify that the user came from the website. If they did not come from the website, or it looked like headers were modified they would be denied the file.
Future Revision to LinkScript
I have been working on future revisions for the LinkScript which include optimizing the database and the code and incorporate Object Oriented Programming into the script. Also a factor that may be looked into is making the actual links SEO friendly and figuring out if writing that would be worth the effort. In essence the URL would from linkScript.php?linkID=3 to /link-script/file-track-back-name.ext I am not sure if that would prove to be worth the effort but is definitely something to look into for the next revision.
Ending Notes
As of right now the code is not available as I have not worked on this script in a few years. I am currently looking into that code and doing many revisions and some optimization of the script and once that has been completed expect to see the script available under the resources section.
Resources
PHP.net
Add to Twitter | Post a comment