![]() |
Help: Info needed
Hello all,
I am wondering if anyone can point me to some software that does the following: I place an image (jpg, gif, whatever) on a website (not hosted by me, but I have access to) and on my own hosted website, can view all if the IP addresses (resolved or not) that have viewed that image. So basically it is working the same as viewing referring images for files anytime the page loads with that image on it, but I need to see IP addresses instead of the referring URL. In a sense it is just a hit logger for the image. It would be especially nice if it could simply filter those out to it's own log file. Thanks in advance! |
well, you can put the image on a definite webpage, and then just check on the IPs of those who look at that page, no?
|
Thanks for the reply :)
The problem with that is I don't have access to server logs on the other server, and they also don't allow php or java/javascript in just the html itself. Any thoughts anyone? I know there are some real smart and crafty people on this board. :) |
Put the image only on your server. Have the page on the other server pull the image from your server.
Then you have all the hits in your logs. If you want to keep it separate, how many visited your server versus the oother server, then make a copy of the pic and have the other server reference the copy. . |
Thanks, what software will tell me the IP address of the computer calling the image from my server? So far all I have seen just tell me the referring url.
|
Quote:
|
If you don't hace access to the logs on your server then you can put a little script out on your server to pull the image when the other server calls for it. In that script you could capture the ip address.
Who is your host and what log analyzer are they giving you access to your logs through? . |
I am renting space through a friend who is hosting. He rents from some place in NL I believe, but I don't know the name offhand.
There is an old version of Webalizer on there that I have access to by default, (but it doesn't show me IP addresses accessing specific files such as an image, just the referring URL) but if I could find a good one, I could install it myself. On my server I am allowed to use php/javascript/etc., but no ASP/ASP.NET etc. I'd really appreciate if you could point out a specific analyzer or simple little script that would do this. For some reason it doesn't seem very difficult at all, but it is eluding me. :) |
* bump *
|
As sarettah said, you'll need to host the image on a server which gives you access to the logs. Dreamhost would be one example, but just about any will do. Then grep the log for the image file name, and you'll be able to see everyone who visited the page.
|
If it's just about one image, here's my Perl quick'n'dirty solution:
Quote:
Quote:
Quote:
|
Quote:
Create a folder inside the domain space you will host the image on. Set the security on the folder to 777 (writable) inside the folder create an .htaccess file to redirect any image calls to a script name. in the same folder create a script that writes a time stamp and the incoming ip to a text file and then serves up the image. htaccess: AuthUserFile /dev/null AuthGroupFile /dev/null RewriteEngine On ReWriteRule .*\.(jpg|gif)$ http://www.your_domain_name.com/fold...scrip_name.php [R,L] in the script: <?php $fp=fopen('testit.txt','a'); if ($fp>0) { fwrite($fp, date("F j, Y, g:i a") . " " . $_SERVER['REMOTE_ADDR'] . "\n"); fclose($fp); } header("Location: http://www.your_domain_name.com/image_to_return.jpg"); ?> This will log each hit and show you the datetime and ip of the hit. Make sure not to put the image you are returning in the same folder as the script and htaccess, because you are redirecting all image hits you will end up going around and around and around. Anytime you want to reset it, just delete the file you are writing to and it will recreate itself on the next hit. When you want to look at the ips, just go to the file. Test of concept: http://www.sigamatic.com/testarea/anyoldimagewilldo.jpg file being created http://www.sigamatic.com/testarea/testit.txt Hope this helps, sorry I took so long to get back, sort of forgot about it till you bumped it :) |
Quote:
You beat me :)) Well, now he has a perl and a php version :thumbsup |
Quote:
Funny how few adult webmasters know how to code a simple script like that |
That looks awesome guys, thanks a million! :)
Just out of curiosity, is there a way to make it just a hair more robust by resolving the IP's as well? If not, no big deal, but it would be really nice. |
Quote:
fwrite($fp, date("F j, Y, g:i a") . " " . $_SERVER['REMOTE_ADDR'] . " " . $_SERVER['REMOTE_HOST'] . " \n"); Anymore costs ya :thumbsup |
It's working great. :)
For some reason, even with that remote host code, it's still only showing the IP address, and leaving the remote host blank. Another thing I am wondering about, in order to make it work, I needed to place a copy of the image in both the folder where the script is, and in the root of the site (where I edited in the php script), and then call the image form the folder's copy, (calling the one in the root folder doesn't write the txt file) which then redirects to the image at the root. I am wondering if this is an issue seeing that you mentioned in your post not to place the image in the folder with the script? By all outward appearances, it's not creating an infinite loop, it's just writing the visit to the txt file once. Thank you very much for all of your help. Now I have something to build on. (need to figure out how to filter out my own IP,etc.) :winkwink: |
Just an update to my last post, I got the resolution part working. I just switched it to:
Code:
$store_ip = $_SERVER['REMOTE_ADDR']; |
Quote:
Shouldn't have had to do that with the image. The copy being called by the script is all that should be needed. But without looking at exactly all you did I couldn't tell you why you are seeing that issue. The way I described it is exactly what I have set up in the test urls I listed above. Don't know why the remote_host isn't getting anything for you except that every server implementation is different :) But the get host from ip call should work too. I have the remote host in the test link above now too, so you can see that it does pull in on my server. You can do a filter of your ip with a simple if if($_SERVER['REMOTE_ADDR']<>ip_to_block) { all the code you are running now; } That will write any ips except whichever you put into the condition. If you want to get fancy with this then you ought to create a table in mysql and then you can keep track of number of hits by ip, and serve up different images based on conditions such as referral string etc. It could be done in text too, but easier to write against a simple table. Have fun :) |
Thanks again. :)
I'm working on figuring out how to make an array to store as many IP's to filter out as needed (dynamic), and I guess I'll do a loop through them, only processing the ip's that aren't in the array. The mysql idea sounds awesome too. :thumbsup Re: the weird handling of the actual .gif, I wonder if it has something to do with the .htaccess I already have at the root of the website? I know these work recursively, and I don't see anything in there that should cause it, but maybe your eyes can spot something that I'm missing? (note: the blocked IP's are from some guy that I had a spam problem with in the past.) Code:
<limit GET PUT POST> |
goodluck
|
Simple fix... ^^
This might sound retarded, however I going to say it...
Use a javascript or php counter to keep track of a web page views... Rather then trying to get every IP address from picture tracking... Even if you are able to get every IP address for every image; you are no better off... How are you going to deal with dynamic connections and their page loads ? Perhaps software firewalls, routers, dynamic connections, misc scripts and badly setup server, might be a little too much for you... It's why I'm pointing out the very easy fix... Good luck, |
All times are GMT -7. The time now is 02:15 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123