<?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: How To Block Multiple IP Addresses Using PHP</title>
	<atom:link href="http://vidiame.com/php/how-to-block-multiple-ip-addresses-using-php/feed" rel="self" type="application/rss+xml" />
	<link>http://vidiame.com/php/how-to-block-multiple-ip-addresses-using-php</link>
	<description>Web development articles, including PHP, jQuery, CSS and more.</description>
	<lastBuildDate>Wed, 30 Jun 2010 08:37:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: revive</title>
		<link>http://vidiame.com/php/how-to-block-multiple-ip-addresses-using-php/comment-page-1#comment-469</link>
		<dc:creator>revive</dc:creator>
		<pubDate>Thu, 03 Dec 2009 08:31:55 +0000</pubDate>
		<guid isPermaLink="false">http://vidiame.com/?p=178#comment-469</guid>
		<description>Great post! I implemented it, but for some reason it wasn&#039;t catching any IPs (tested by blocking my own and echo&#039;ing it in the page).. so, I changed the getUserIp function to this:

	function getUserIP()
	    {
	        $alt_ip = $_SERVER[&#039;REMOTE_ADDR&#039;];

	        if (isset($_SERVER[&#039;HTTP_CLIENT_IP&#039;]))
	        {
	            $alt_ip = $_SERVER[&#039;HTTP_CLIENT_IP&#039;];
	        }
	        else if (isset($_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;]) AND preg_match_all(&#039;#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s&#039;, $_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;], $matches))
	        {
	            // make sure we dont pick up an internal IP defined by RFC1918
	            foreach ($matches[0] AS $ip)
	            {
	                if (!preg_match(&quot;#^(10&#124;172\.16&#124;192\.168)\.#&quot;, $ip))
	                {
	                    $alt_ip = $ip;
	                    break;
	                }
	            }
	        }
	        else if (isset($_SERVER[&#039;HTTP_FROM&#039;]))
	        {
	            $alt_ip = $_SERVER[&#039;HTTP_FROM&#039;];
	        }

	        return $alt_ip;
	    }


and it works great !!

Thanks again.</description>
		<content:encoded><![CDATA[<p>Great post! I implemented it, but for some reason it wasn&#8217;t catching any IPs (tested by blocking my own and echo&#8217;ing it in the page).. so, I changed the getUserIp function to this:</p>
<p>	function getUserIP()<br />
	    {<br />
	        $alt_ip = $_SERVER['REMOTE_ADDR'];</p>
<p>	        if (isset($_SERVER['HTTP_CLIENT_IP']))<br />
	        {<br />
	            $alt_ip = $_SERVER['HTTP_CLIENT_IP'];<br />
	        }<br />
	        else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND preg_match_all(&#8216;#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s&#8217;, $_SERVER['HTTP_X_FORWARDED_FOR'], $matches))<br />
	        {<br />
	            // make sure we dont pick up an internal IP defined by RFC1918<br />
	            foreach ($matches[0] AS $ip)<br />
	            {<br />
	                if (!preg_match(&#8220;#^(10|172\.16|192\.168)\.#&#8221;, $ip))<br />
	                {<br />
	                    $alt_ip = $ip;<br />
	                    break;<br />
	                }<br />
	            }<br />
	        }<br />
	        else if (isset($_SERVER['HTTP_FROM']))<br />
	        {<br />
	            $alt_ip = $_SERVER['HTTP_FROM'];<br />
	        }</p>
<p>	        return $alt_ip;<br />
	    }</p>
<p>and it works great !!</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Favorites from the Feeds #08 &#171; Blogoholics Anonymous</title>
		<link>http://vidiame.com/php/how-to-block-multiple-ip-addresses-using-php/comment-page-1#comment-304</link>
		<dc:creator>Favorites from the Feeds #08 &#171; Blogoholics Anonymous</dc:creator>
		<pubDate>Wed, 04 Nov 2009 22:26:55 +0000</pubDate>
		<guid isPermaLink="false">http://vidiame.com/?p=178#comment-304</guid>
		<description>[...] 9. How To Block Multiple IP Addresses Using PHP [...]</description>
		<content:encoded><![CDATA[<p>[...] 9. How To Block Multiple IP Addresses Using PHP [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed Amine</title>
		<link>http://vidiame.com/php/how-to-block-multiple-ip-addresses-using-php/comment-page-1#comment-74</link>
		<dc:creator>Mohamed Amine</dc:creator>
		<pubDate>Mon, 26 Oct 2009 10:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://vidiame.com/?p=178#comment-74</guid>
		<description>@Slyy
Yes, that is right. at the beginning i was planning to make the output like that.
[code lang=&quot;php&quot;]
echo &quot;YOUR IP &quot; . $status . &quot; HAS BEEN BANNED.&quot;;
[/code]
but eventually I figured out that i can just call the $visitorIp instead of $status. Thanks for the notice. but it works with both ways.</description>
		<content:encoded><![CDATA[<p>@Slyy<br />
Yes, that is right. at the beginning i was planning to make the output like that.</p>
<pre class="brush: php;">
echo "YOUR IP " . $status . " HAS BEEN BANNED.";
</pre>
<p>but eventually I figured out that i can just call the $visitorIp instead of $status. Thanks for the notice. but it works with both ways.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Slyy</title>
		<link>http://vidiame.com/php/how-to-block-multiple-ip-addresses-using-php/comment-page-1#comment-70</link>
		<dc:creator>Slyy</dc:creator>
		<pubDate>Mon, 26 Oct 2009 09:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://vidiame.com/?p=178#comment-70</guid>
		<description>Why using array_search when in_array is enough?
You don&#039;t want to retrieve the corresponding key for further work, you just want to know if the current IP is IN the blacklisted array...</description>
		<content:encoded><![CDATA[<p>Why using array_search when in_array is enough?<br />
You don&#8217;t want to retrieve the corresponding key for further work, you just want to know if the current IP is IN the blacklisted array&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed Amine</title>
		<link>http://vidiame.com/php/how-to-block-multiple-ip-addresses-using-php/comment-page-1#comment-33</link>
		<dc:creator>Mohamed Amine</dc:creator>
		<pubDate>Sun, 25 Oct 2009 12:10:29 +0000</pubDate>
		<guid isPermaLink="false">http://vidiame.com/?p=178#comment-33</guid>
		<description>@G Mali
Yes, that is true. This isn&#039;t the right solution for big projects but it can be useful in a multi-membership system with cookies. I guess you would like to read about http://en.wikipedia.org/wiki/Iptables</description>
		<content:encoded><![CDATA[<p>@G Mali<br />
Yes, that is true. This isn&#8217;t the right solution for big projects but it can be useful in a multi-membership system with cookies. I guess you would like to read about <a href="http://en.wikipedia.org/wiki/Iptables" rel="nofollow">http://en.wikipedia.org/wiki/Iptables</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
