<?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>Comentarios en: Obtener la IP del usuario mediante PHP</title>
	<atom:link href="http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/</link>
	<description>Desarrollo web, Wordpress, y alguna cosilla más</description>
	<lastBuildDate>Sun, 12 Feb 2012 12:01:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>Por: patyy</title>
		<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/#comment-56623</link>
		<dc:creator>patyy</dc:creator>
		<pubDate>Sat, 30 May 2009 04:32:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.anieto2k.com/?p=8029#comment-56623</guid>
		<description>ey no entiendoo nada de estoo como se hacee???</description>
		<content:encoded><![CDATA[<p>ey no entiendoo nada de estoo como se hacee???</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Ip del usuario con php</title>
		<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/#comment-55831</link>
		<dc:creator>Ip del usuario con php</dc:creator>
		<pubDate>Sun, 26 Apr 2009 22:36:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.anieto2k.com/?p=8029#comment-55831</guid>
		<description>[...] Fuente y Inspiracion: Anieto2k [...]</description>
		<content:encoded><![CDATA[<p>[...] Fuente y Inspiracion: Anieto2k [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Variables de Entorno y Anonimato en Internet &#171; El Blog de Pablo</title>
		<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/#comment-55801</link>
		<dc:creator>Variables de Entorno y Anonimato en Internet &#171; El Blog de Pablo</dc:creator>
		<pubDate>Fri, 24 Apr 2009 14:05:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.anieto2k.com/?p=8029#comment-55801</guid>
		<description>[...] de Entorno y Anonimato en&#160;Internet Llego a través de esta información de anieto2k para saber la IP de los usuario mediante php a este post. Ambas informaciones son interesantes y me [...]</description>
		<content:encoded><![CDATA[<p>[...] de Entorno y Anonimato en&nbsp;Internet Llego a través de esta información de anieto2k para saber la IP de los usuario mediante php a este post. Ambas informaciones son interesantes y me [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: aNieto2k</title>
		<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/#comment-55800</link>
		<dc:creator>aNieto2k</dc:creator>
		<pubDate>Fri, 24 Apr 2009 13:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.anieto2k.com/?p=8029#comment-55800</guid>
		<description>&lt;a href=&quot;#comment-55786&quot; title=&quot;Responder a matados2k&quot; rel=&quot;nofollow&quot;&gt;@matados2k&lt;/a&gt;: Muy intersante, gracias.</description>
		<content:encoded><![CDATA[<p><a href="#comment-55786" title="Responder a matados2k" rel="nofollow">@matados2k</a>: Muy intersante, gracias.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: aNieto2k</title>
		<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/#comment-55799</link>
		<dc:creator>aNieto2k</dc:creator>
		<pubDate>Fri, 24 Apr 2009 13:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.anieto2k.com/?p=8029#comment-55799</guid>
		<description>&lt;a  href=&quot;#comment-55790&quot; title=&quot;Responder a Pablo&quot; rel=&quot;nofollow&quot;&gt;@Pablo&lt;/a&gt;:  El problema es que &lt;code&gt;REMOTE_ADDR&lt;/code&gt; no permite validar a un usuario. Aunque &lt;code&gt;getIP()&lt;/code&gt; tampoco lo asegura, por lo menos podemos profundizar un poco más en la IP.</description>
		<content:encoded><![CDATA[<p><a href="#comment-55790" title="Responder a Pablo" rel="nofollow">@Pablo</a>:  El problema es que <code>REMOTE_ADDR</code> no permite validar a un usuario. Aunque <code>getIP()</code> tampoco lo asegura, por lo menos podemos profundizar un poco más en la IP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Pablo</title>
		<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/#comment-55790</link>
		<dc:creator>Pablo</dc:creator>
		<pubDate>Fri, 24 Apr 2009 07:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.anieto2k.com/?p=8029#comment-55790</guid>
		<description>Yo he utilizado estas variables del server y no he tenido buenos resultados.
Las IP que devuelven casi siempre son privadas y no sirven de nada para la gestion de usuarios.
Es preferible utilizar REMOTE_ADDR y luego trabajar con la session.
saludos</description>
		<content:encoded><![CDATA[<p>Yo he utilizado estas variables del server y no he tenido buenos resultados.<br />
Las IP que devuelven casi siempre son privadas y no sirven de nada para la gestion de usuarios.<br />
Es preferible utilizar REMOTE_ADDR y luego trabajar con la session.<br />
saludos</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: matados2k</title>
		<link>http://www.anieto2k.com/2009/04/23/obtener-la-ip-del-usuario-mediante-php/#comment-55786</link>
		<dc:creator>matados2k</dc:creator>
		<pubDate>Thu, 23 Apr 2009 21:47:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.anieto2k.com/?p=8029#comment-55786</guid>
		<description>Lo siento, sale mal, no caí en la revisión contra la inyección de código, y no salen las 2 primeras que son las interesantes, a ver si ahora:
&lt;pre&gt;&lt;code&gt;
public static function getRealIP()
  {
    if( isset ($_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;]) and $_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;] != &#039;&#039; )
    {
      $client_ip = (!empty($_SERVER[&#039;REMOTE_ADDR&#039;]) ) ? $_SERVER[&#039;REMOTE_ADDR&#039;] :
      ( ( !empty($_ENV[&#039;REMOTE_ADDR&#039;]) )?$_ENV[&#039;REMOTE_ADDR&#039;]:false );
      $entries = split(&#039;[, ]&#039;, $_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;]);
      reset($entries);
      while (list(, $entry) = each($entries))
      {
        $entry = trim($entry);
        if ( preg_match(&quot;/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/&quot;, $entry, $ip_list) )
        {
          $private_ip = array(
          &#039;/^0\./&#039;,
          &#039;/^127\.0\.0\.1/&#039;,
          &#039;/^192\.168\..*/&#039;,
          &#039;/^172\.((1[6-9])&#124;(2[0-9])&#124;(3[0-1]))\..*/&#039;,
          &#039;/^10\..*/&#039;);
          $found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
          if ($client_ip != $found_ip)
          {
            $client_ip = $found_ip;
            break;
          }
        }
      }
    }
    else
    {
      $client_ip =( !empty($_SERVER[&#039;REMOTE_ADDR&#039;]))?$_SERVER[&#039;REMOTE_ADDR&#039;]:((!empty($_ENV[&#039;REMOTE_ADDR&#039;]))?
      $_ENV[&#039;REMOTE_ADDR&#039;]:false );
    }
    return $client_ip;
  }

  public static function getIp()
  {
    if ($_SERVER[&quot;HTTP_X_FORWARDED_FOR&quot;] != &quot;&quot;)
    {
      $ip = $_SERVER[&quot;HTTP_X_FORWARDED_FOR&quot;];
      $ip_array = explode(&quot;,&quot;, $ip);
      $ip = $ip_array[0];
      $nums 	= sscanf($ip, &quot;%d.%d.%d.%d&quot;);
      if ($nums[0] === null &#124;&#124; $nums[1] === null &#124;&#124; $nums[2] === null &#124;&#124; $nums[3] === null &#124;&#124; $nums[0] == 10   &#124;&#124;
      ($nums[0] == 172  &amp;&amp; $nums[1] &gt;= 16 &amp;&amp; $nums[1] = 16 &amp;&amp; $nums[1] &lt;= 31) &#124;&#124; ($nums[0] == 192  &amp;&amp; $nums[1] == 168) &#124;&#124;
      $nums[0] == 239  &#124;&#124; $nums[0] == 0 &#124;&#124; $nums[0] == 127)
      $ip = $_SERVER[&quot;REMOTE_ADDR&quot;];
    }
    else
    $ip = $_SERVER[&quot;REMOTE_ADDR&quot;];
    return $ip;
  }
&lt;/code&gt;&lt;/pre&gt;
La primera es muy fiable. Si aun asi no salen y si quieres puedes ponerte en contacto con migo y te paso la clase entera</description>
		<content:encoded><![CDATA[<p>Lo siento, sale mal, no caí en la revisión contra la inyección de código, y no salen las 2 primeras que son las interesantes, a ver si ahora:</p>
<pre><code>
public static function getRealIP()
  {
    if( isset ($_SERVER['HTTP_X_FORWARDED_FOR']) and $_SERVER['HTTP_X_FORWARDED_FOR'] != '' )
    {
      $client_ip = (!empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] :
      ( ( !empty($_ENV['REMOTE_ADDR']) )?$_ENV['REMOTE_ADDR']:false );
      $entries = split('[, ]', $_SERVER['HTTP_X_FORWARDED_FOR']);
      reset($entries);
      while (list(, $entry) = each($entries))
      {
        $entry = trim($entry);
        if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list) )
        {
          $private_ip = array(
          '/^0\./',
          '/^127\.0\.0\.1/',
          '/^192\.168\..*/',
          '/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/',
          '/^10\..*/');
          $found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
          if ($client_ip != $found_ip)
          {
            $client_ip = $found_ip;
            break;
          }
        }
      }
    }
    else
    {
      $client_ip =( !empty($_SERVER['REMOTE_ADDR']))?$_SERVER['REMOTE_ADDR']:((!empty($_ENV['REMOTE_ADDR']))?
      $_ENV['REMOTE_ADDR']:false );
    }
    return $client_ip;
  }

  public static function getIp()
  {
    if ($_SERVER["HTTP_X_FORWARDED_FOR"] != "")
    {
      $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
      $ip_array = explode(",", $ip);
      $ip = $ip_array[0];
      $nums 	= sscanf($ip, "%d.%d.%d.%d");
      if ($nums[0] === null || $nums[1] === null || $nums[2] === null || $nums[3] === null || $nums[0] == 10   ||
      ($nums[0] == 172  &amp;&amp; $nums[1] &gt;= 16 &amp;&amp; $nums[1] = 16 &amp;&amp; $nums[1] &lt;= 31) || ($nums[0] == 192  &amp;&amp; $nums[1] == 168) ||
      $nums[0] == 239  || $nums[0] == 0 || $nums[0] == 127)
      $ip = $_SERVER["REMOTE_ADDR"];
    }
    else
    $ip = $_SERVER["REMOTE_ADDR"];
    return $ip;
  }
</code></pre>
<p>La primera es muy fiable. Si aun asi no salen y si quieres puedes ponerte en contacto con migo y te paso la clase entera</p>
]]></content:encoded>
	</item>
</channel>
</rss>

