jwilson122 Posted February 24, 2011 Share Posted February 24, 2011 Okay, so I know how to get an IP address using $_SERVER['REMOTE_ADDR'], however, I need to get an IP a little different. How would I get the IP of the visitor on a remote site loading MY site using file_get_contents()? It just returns that remote websites server IP... :/ Thanks! Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/ Share on other sites More sharing options...
AbraCadaver Posted February 24, 2011 Share Posted February 24, 2011 Unless the file that is doing the file_get_contents() provides you with the $_SERVER['REMOTE_ADDR'] of the client that is running that file, you can't. Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/#findComment-1179140 Share on other sites More sharing options...
jwilson122 Posted February 24, 2011 Author Share Posted February 24, 2011 Unless the file that is doing the file_get_contents() provides you with the $_SERVER['REMOTE_ADDR'] of the client that is running that file, you can't. Thats what I thought.. What about getting HTTP details? Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/#findComment-1179143 Share on other sites More sharing options...
AbraCadaver Posted February 24, 2011 Share Posted February 24, 2011 Client makes HTTP request to server A via browser, server A makes HTTP request to server B via file_get_contents(). There is nothing in common between the two. Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/#findComment-1179146 Share on other sites More sharing options...
jwilson122 Posted February 24, 2011 Author Share Posted February 24, 2011 Client makes HTTP request to server A via browser, server A makes HTTP request to server B via file_get_contents(). There is nothing in common between the two. Well, see I'm trying to get HTTP_X_FORWARDED_FOR and those types of HTTP's from the website using the file_get_contents().. :/ Cant do that no way possible? Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/#findComment-1179147 Share on other sites More sharing options...
AbraCadaver Posted February 24, 2011 Share Posted February 24, 2011 No. The server is not forwarding the user to your site. They are two separate and independent HTTP requests with nothing in common. Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/#findComment-1179161 Share on other sites More sharing options...
jwilson122 Posted February 24, 2011 Author Share Posted February 24, 2011 No. The server is not forwarding the user to your site. They are two separate and independent HTTP requests with nothing in common. hmm :/ Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/#findComment-1179162 Share on other sites More sharing options...
kanoameha Posted February 25, 2011 Share Posted February 25, 2011 a file_get_contents call via a php script ... triggered by a client-user running the php page.. will not show any footprints from the client. server a hosts page a. server b hosts page b. page a does a file_get_contents to snag page b from server b. user c goes to page a on server a. page a gets the contents of page b. server b will get footprint info from server a, since server a is the content getter. essentially, in this relationship, server a is the client of server b's page. also, with curl, these variables can all be hacked, so from server b's perspective (the one which you are asking about), the only reliable data is the IP of where the request is coming from. that can be done through a proxy so it doesn't lead back to server a. IP can be spoofed, but it is pointless, because the data from the file_get_contents or curl call would be sent to the spoofed IP, not to the spoofer. you can lock down your content if you are concerned about screen scrapes and vultures through a combination of various methods (HTTACCESS etc). Link to comment https://forums.phpfreaks.com/topic/228707-getting-ip-address/#findComment-1179340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.