<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Get visitor IP address &#8211; PHP</title>
	<atom:link href="http://neo22s.com/get-visitor-ip-address-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://neo22s.com/get-visitor-ip-address-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=get-visitor-ip-address-php</link>
	<description>Web development, scripts, source code and IT stuff</description>
	<lastBuildDate>Mon, 06 Feb 2012 10:49:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: router ip address</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-3834</link>
		<dc:creator>router ip address</dc:creator>
		<pubDate>Mon, 14 Feb 2011 22:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-3834</guid>
		<description>Great write-up, but it doesn&#039;t really to make use of my router ip, any hints?</description>
		<content:encoded><![CDATA[<p>Great write-up, but it doesn&#8217;t really to make use of my router ip, any hints?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chema</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-2369</link>
		<dc:creator>Chema</dc:creator>
		<pubDate>Sat, 02 Oct 2010 07:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-2369</guid>
		<description>That&#039;s a bad idea...there&#039;s going to be a moment were you can&#039;t handle anymore the file since it&#039;s too big....</description>
		<content:encoded><![CDATA[<p>That&#8217;s a bad idea&#8230;there&#8217;s going to be a moment were you can&#8217;t handle anymore the file since it&#8217;s too big&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-2367</link>
		<dc:creator>Nitin</dc:creator>
		<pubDate>Fri, 01 Oct 2010 17:33:49 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-2367</guid>
		<description>How can you use the above PHP code, for storing both the Remote address and Xforwarded IP&#039;s from the proxies,
and I am trying to store it into a flat text file and not into a DB.

so, can anyone please post the code for the same.
i guess $ip needs to be called with fwrite and fread with the filename,
but i needed it in correct syntax.
as i am not good at PHP skills

Thanks in advance</description>
		<content:encoded><![CDATA[<p>How can you use the above PHP code, for storing both the Remote address and Xforwarded IP&#8217;s from the proxies,<br />
and I am trying to store it into a flat text file and not into a DB.</p>
<p>so, can anyone please post the code for the same.<br />
i guess $ip needs to be called with fwrite and fread with the filename,<br />
but i needed it in correct syntax.<br />
as i am not good at PHP skills</p>
<p>Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chema</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-2120</link>
		<dc:creator>Chema</dc:creator>
		<pubDate>Thu, 15 Jul 2010 09:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-2120</guid>
		<description>I do it at the beginning of the script and I retrieve it always ;)</description>
		<content:encoded><![CDATA[<p>I do it at the beginning of the script and I retrieve it always ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sas</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-2119</link>
		<dc:creator>sas</dc:creator>
		<pubDate>Thu, 15 Jul 2010 09:51:59 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-2119</guid>
		<description>Can someone please tell me where the code should be pasted please? Should I paste the code at the registration page or? Thanks. I think it is very useful to know member IPs for additional security.</description>
		<content:encoded><![CDATA[<p>Can someone please tell me where the code should be pasted please? Should I paste the code at the registration page or? Thanks. I think it is very useful to know member IPs for additional security.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chema</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-1245</link>
		<dc:creator>Chema</dc:creator>
		<pubDate>Wed, 27 Jan 2010 16:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-1245</guid>
		<description>thanks this is really usefull ;)

for my app I only need the $_SERVER[&#039;REMOTE_ADDR&#039;];, that&#039;s all</description>
		<content:encoded><![CDATA[<p>thanks this is really usefull ;)</p>
<p>for my app I only need the $_SERVER['REMOTE_ADDR'];, that&#8217;s all</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nenillo</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-1244</link>
		<dc:creator>Nenillo</dc:creator>
		<pubDate>Wed, 27 Jan 2010 14:43:51 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-1244</guid>
		<description>REMOTE_ADDR as far as I know is never blank, it gives you who is connecting to your server, whatever the end point is (user or proxy)

I think is a good practice to store this value, wether the connection is from an user or not. Also, if you want, you can store the HTTP_X_FORWARDED_FOR value.

function get_show_ip() {
   if(isset($_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;)) {
       $ip = $_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;];
   } else {
       $ip = $_SERVER[&#039;REMOTE_ADDR&#039;];
   }
   return htmlspecialchars($ip);
}

$storeIP = $_SERVER[&#039;REMOTE_ADDR&#039;];
$showIP = get_show_ip()
if($showIP == $storeIP) {
   $storeForwarded = &#039;No&#039;;
} else {
   $storeForwarded = $showIP;
}

$storeIP var is only for storing in the DB. $showIP is the IP that will be showed in you app. $storeForward is the data that you&#039;ll store in your &quot;Forwarded&quot; field in the DB. You can also check if HTTP_X_FORWARDED_FOR is really an IP using preg_match and drop the value if the regexp does not match.</description>
		<content:encoded><![CDATA[<p>REMOTE_ADDR as far as I know is never blank, it gives you who is connecting to your server, whatever the end point is (user or proxy)</p>
<p>I think is a good practice to store this value, wether the connection is from an user or not. Also, if you want, you can store the HTTP_X_FORWARDED_FOR value.</p>
<p>function get_show_ip() {<br />
   if(isset($_SERVER['HTTP_X_FORWARDED_FOR')) {<br />
       $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];<br />
   } else {<br />
       $ip = $_SERVER['REMOTE_ADDR'];<br />
   }<br />
   return htmlspecialchars($ip);<br />
}</p>
<p>$storeIP = $_SERVER['REMOTE_ADDR'];<br />
$showIP = get_show_ip()<br />
if($showIP == $storeIP) {<br />
   $storeForwarded = &#8216;No&#8217;;<br />
} else {<br />
   $storeForwarded = $showIP;<br />
}</p>
<p>$storeIP var is only for storing in the DB. $showIP is the IP that will be showed in you app. $storeForward is the data that you&#8217;ll store in your &#8220;Forwarded&#8221; field in the DB. You can also check if HTTP_X_FORWARDED_FOR is really an IP using preg_match and drop the value if the regexp does not match.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chema</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-1243</link>
		<dc:creator>Chema</dc:creator>
		<pubDate>Wed, 27 Jan 2010 14:23:34 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-1243</guid>
		<description>mmm really interesting.

The problem here it&#039;s if the remote_addr it&#039;s blank?

What you should do then?

do you mind to paste here the code you use?

thanks!</description>
		<content:encoded><![CDATA[<p>mmm really interesting.</p>
<p>The problem here it&#8217;s if the remote_addr it&#8217;s blank?</p>
<p>What you should do then?</p>
<p>do you mind to paste here the code you use?</p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nenillo</title>
		<link>http://neo22s.com/get-visitor-ip-address-php/comment-page-1/#comment-1242</link>
		<dc:creator>Nenillo</dc:creator>
		<pubDate>Wed, 27 Jan 2010 13:36:51 +0000</pubDate>
		<guid isPermaLink="false">http://neo22s.com/?p=869#comment-1242</guid>
		<description>I think it&#039;s better to use the $_SERVER variable, anyway, the biggest problem I see is that you can&#039;t trust HTTP_X_FORWARDED_FOR.

REMOTE_ADDR will always value the IP that connects to the server and can not be cheated.

HTTP_X_FORWARDED_FOR is set by HTTP headers, so you can not trust it. A malicious user is able to just put &quot;0.0.0.0&quot; or any string he wants and if you are using your getIP() function to store logs you will be losing the trace of that user. Furthermore, as the malicious user is able to put any string on there, not just IPs, that can be used to hack something in you web app.

One of my apps was once hacked using HTTP_X_FORWARDED_FOR. I was trusting the value and someone put javascript code on it, making alert messages appearing on my site.

So I recommend to always store REMOTE_ADDR and if you want, store HTTP_X_FORWARDED_FOR as a plus, in a separate field, sanitizing the value.</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s better to use the $_SERVER variable, anyway, the biggest problem I see is that you can&#8217;t trust HTTP_X_FORWARDED_FOR.</p>
<p>REMOTE_ADDR will always value the IP that connects to the server and can not be cheated.</p>
<p>HTTP_X_FORWARDED_FOR is set by HTTP headers, so you can not trust it. A malicious user is able to just put &#8220;0.0.0.0&#8243; or any string he wants and if you are using your getIP() function to store logs you will be losing the trace of that user. Furthermore, as the malicious user is able to put any string on there, not just IPs, that can be used to hack something in you web app.</p>
<p>One of my apps was once hacked using HTTP_X_FORWARDED_FOR. I was trusting the value and someone put javascript code on it, making alert messages appearing on my site.</p>
<p>So I recommend to always store REMOTE_ADDR and if you want, store HTTP_X_FORWARDED_FOR as a plus, in a separate field, sanitizing the value.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Served from: neo22s.com @ 2012-02-12 12:32:43 by W3 Total Cache -->
