tags:

views:

148

answers:

4

I see this a lot now, jpg files displaying your IP address. To you of course, not to others, they would see their own

For example: yourip

How is this even possible? If this is possible, would it be possible to log an IP into a MySQL database from the picture as well? Is my IP getting logged when I view this?

EDIT: Sure, its possible when its on your OWN server, but how would you log it from directly linking a picture from your server on a nother, such as I've done here?

A: 

A server has to have your IP address to communicate with you. Here is a simple example using php that will grab the ip address. Writing it to an image is not a difficult problem to solve. Here is an example, also in php, of writing text to an image. And yes, you could do what ever you with with the IP. You could store it easily if you wanted. It could be used to assist you in identifying unique visitors.

Jeremy Roberts
Right but thats still a php file
Rob
@Rob: The extension you see in the URL is **NOT** always what you get
nc3b
+4  A: 
  • When you access a page, it "knows" your IP, it has it in text form. Thus, it can be inserted in any database ("logged")
  • To create an image from text, there is more than one option: gd, imagemagick, etc. More might be available, but you didn't specify any server-side technology so I can't point to any specific solutions.

EDIT: You seem to be making a few confusions. No matter what server you access, you have to establish a TCP session (and so on and so forth) and you have to tell it your IP, otherwise it won't be able to deliver the response. Now, when you request an image from a server, it is by no means understood that it is a static image. Sometimes (like this occasion) it is a script that simply renders an image and sends it back by manipulation the headers, content type and such :).

nc3b
This doesn't answer my question
Rob
@Rob: you mean "questions." If you read this answer a bit more carefully, you'd see that it answers some of your questions, and clears up most of your confusion.
Yar
A: 

I believe the server stored the image, has the ability to detect the IP address and display for us. I have also find out this website - IP2Location.com also has ability to detect my geographical location. Is it same technology to detect IP address on image to the website: http://www.ip2location.com/ ?

Kurosaki
A: 

Note that, whenever you include an image from another website in a question, stackoverflow doesn't actually store a copy of that image. Instead, it stores the location (URL) of the image. Whenever stackoverflow generates html for a page like this, it embeds that URL into the src attribute of the image tag. If you look at the html source of this page, you will see that the image tag for the picture you included in your question looks something like this:

<img src="http://moco-sux.net63.net/palm-sig.jpg&quot;&gt;

Every time a user views your question, his/her browser makes a request for that image from the web server that hosts it. In this case the domain name of that web server is moco-sux.net63.net.

As others have explained, when a web server receives any kind of internet request, it has complete control over how it responds. The fact that the extension of the filename at the end of the URL is .jpg does not necessarily mean that the web server will simply respond with a static image file. Instead, the web server can be configured to respond with a dynamically generated image file that contains your IP address.

So it's not the actual jpeg that computes your IP. Rather, the web server that receives the image-request crafts a jpeg file on the fly, just for you. Try uploading the picture to another web server. My guess is that its IP predicting capabilities won't be nearly as sharp : )

ali01