Hi, Guest ~ Login or Register

logging hotlinks..?

Posted in Website Programming » PHP - Sunday 21st October 2007 at 9:14PM

adam2z
Member

User Avatar

Joined October 2005
Posts: 113

i need a new, less process intensive way of logging hotlinks.

at the moment im loading the image into a php document using filegetcontent, logging it to mysql, and then printing it (with headers and all).

is there a better way to do this? perhaps use .htaccess to open a php file for every image file opened and log the information?

its for imageho.st... is it unrealistic for me to want to record the file views? should i allow direct hotlinking instead of faking it through a proxy php script?

id really appreciate any help you can give.

__________________________________

 

Replies (2)

Replied - Monday 29th October 2007 at 11:31PM [Post Link]

Will
Administrator

User Avatar

Joined October 2005
Posts: 133

Proxy PHP script is equal to death. Try using an Apache directive to direct to a PHP file, log to a .txt file differentiated on a day by day basis and then display the image by using cURL (faster, less resource intensive) or using header then include, or file_get_contents. To be honest I've forgotten which one is better, but the one that is is better by far.

Instead of doing multiple queries per second (potentially), you're going to be accessing a .txt file, probably in a CSV format (I would recommend it) and then using a cron job to process the data into MySQL.

Obvious drawbacks would be the fact this would not be realtime (at least not through MySQL) however it's going to be a few quick accesses. Try benchmarking it and investigating what you find.

__________________________________
Will Morgan
Freelance Web Developer
Next feature: How to fit 25 hours into a day!

 
Replied - Thursday 1st November 2007 at 4:46PM [Post Link]

Will
Administrator

User Avatar

Joined October 2005
Posts: 133

[QUOTE] PHP.net said:

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

__________________________________
Will Morgan
Freelance Web Developer
Next feature: How to fit 25 hours into a day!