rtpmatt Posted June 5, 2007 Share Posted June 5, 2007 Hi, I am wondering if there is a way for me to log the access of a specific file on my server. I have a LAMP server, I know php (and how to use it with MySQL.) But i can seem to find a way to say have a script run every time say a picture is accessed. If possible I would like to track the IP address accessing it, and where the request is coming from. In other words If someone is using my pictures I would like to track how many requests I am getting from them because of it, and the IP of the individual user who is accessing it...I hope all that makes sense. I would really just like to throw this into a table in my DB so i can access it later. Thanks for any help you can provide. -matt Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/ Share on other sites More sharing options...
dbillings Posted June 5, 2007 Share Posted June 5, 2007 What does the user have to do to access the image? Simply right click and save image? Are they listed as thumbnails initially? Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-267989 Share on other sites More sharing options...
rtpmatt Posted June 5, 2007 Author Share Posted June 5, 2007 No, i mean if someone else users my image on their webpage, presumably using <img src="myserver/image.jpg"> or the like so they image would be the only file they would be touching on my server. Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-267994 Share on other sites More sharing options...
redarrow Posted June 5, 2007 Share Posted June 5, 2007 look into .htaccess files. you can use a .htaccess file and a rewrite code to stop users geting into your image folder also you can also confuse the user where the files are by using urlrewrite. 1. sorry but it inpossable for you to stop a user copying your pictures but you can be quit smart and use gd function to create text on top of the picture with your web site name that will result in less image theft. Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-268005 Share on other sites More sharing options...
rtpmatt Posted June 5, 2007 Author Share Posted June 5, 2007 I don't mind people using my images, I would just like to track it, so I can see who is using them. ill google .htaccess and see if it gets me anywhere. thanks for the help -matt ...I suppose i could have something that checks my access logs every so often and then possibly runs some code? just thinking out loud here Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-268011 Share on other sites More sharing options...
chigley Posted June 5, 2007 Share Posted June 5, 2007 Why not do this? image.php <?php $ip = $_SERVER["REMOTE_ADDR"]; // Do whatever you want with the IP here header("Content-type: image/jpeg"); $im = imagecreatefromjpeg("http://stationonetherock.tripod.com/sitebuildercontent/sitebuilderpictures/.pond/therock.jpg.w300h300.jpg"); imagejpeg($im); imagedestroy($im); ?> file.html <img src="image.php" alt="" /> Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-268317 Share on other sites More sharing options...
rtpmatt Posted June 7, 2007 Author Share Posted June 7, 2007 thanks all, using the logs seems to work, I just modded this a bit: http://www.php-scripts.com/php_diary/012103.php3 by any chance does anybody have a function to change the apache log dates into mysql type dates? I have already split up the dates and times, and would like to put them into my DB, I just don't really to write the fctn to do it...If you don't have a fctn, can you tell me if the apache logs use a rather standard 3 char month? I only have a few months to look at, and it seems they are, if i write the fctn i just want to make sure i do it the correct way. thanks -matt Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-269868 Share on other sites More sharing options...
rtpmatt Posted June 7, 2007 Author Share Posted June 7, 2007 hah, NM im an idiot thanks Quote Link to comment https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-270376 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.