Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/54198-access-logging/
Share on other sites

 

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.

 

Link to comment
https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-268005
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-268011
Share on other sites

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="" />

Link to comment
https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-268317
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/54198-access-logging/#findComment-269868
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.